Merge lp:~csurbhi/ubuntu/natty/os-prober/os-prober.fix764893 into lp:ubuntu/natty/os-prober

Proposed by Surbhi Palande
Status: Needs review
Proposed branch: lp:~csurbhi/ubuntu/natty/os-prober/os-prober.fix764893
Merge into: lp:ubuntu/natty/os-prober
Diff against target: 123 lines (+80/-0)
3 files modified
debian/changelog (+7/-0)
linux-boot-probes/common/50mounted-tests (+37/-0)
os-probes/common/50mounted-tests (+36/-0)
To merge this branch: bzr merge lp:~csurbhi/ubuntu/natty/os-prober/os-prober.fix764893
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+58654@code.launchpad.net

Description of the change

Hi,

This patch adds support to mount the "@" subvolume to access a btrfs formatted rootfs. It checks if "@" is present and if so, then unmounts the partition before trying to mount the subvolume. Releases previous to Natty and other OS distros may not have the "/" on the "@" subvolume.

Tested lightly on kvm with Natty-btrfs rootfs.

Please do consider this as a *SRU* for Natty.

Thanks,
Surbhi.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

> mounted=1
> + debug "mounted as $type filesystem"

The indentation is in general wrong here - make sure to check whether
the code you're patching is using tabs or spaces for indentation, and
match it.

> + if [ $type="btrfs" ] && [ -x "$tmpmnt/@" ]; then

The first test is wrong shell syntax. This must be [ "$type" = btrfs ]
instead.

Furthermore, this won't work when we're using grub-mount, which we
generally will be nowadays; and remounting with 'mount -o ro,subvol=@ -t
btrfs' will bring us back to the bad old days before grub-mount, when we
had to choose between either corrupting hibernated filesystems or
failing to mount journalled filesystems that weren't cleanly unmounted.

I suggest instead that we check whether $type is either btrfs or fuse
(using 'case') and whether $tmpmnt/@/lib exists (this should be
reasonably safe since btrfs is only used on Linux); in that case,
bind-mount $tmpmnt/@ on $tmpmnt and remember to umount it twice at the
end. (Alternatively, we could arrange for everything to read from
$tmpmnt/@ without a bind-mount, but I think that would be rather more
code churn.)

> + warn "failed to mount" \
> + "@ ($partition)"

Try to make the warnings a bit more descriptive; most people will have
no idea what our subvolume scheme involves. They should still be
one-line warnings or thereabouts, not essays, but for example
consistently referring to "btrfs subvolume @ on $partition" would be an
improvement.

Revision history for this message
Surbhi Palande (csurbhi) wrote :

Hi Colin,

Thanks a lot for the insightful review. Did not know about the fs-corruption issue before. The reading of the $tmpmnt/@ indeed is a lot more code than mount-bind (or remount) and I decided against it just for the same reason before.

I have uploaded the changes after testing them on kvm. Please do let me know if they look good now.

Regards,
Surbhi.

18. By Surbhi Palande

mount btrfs subvolume @ when present to access a btrfs formatted rootfs.
(LP: #764893)

Revision history for this message
Colin Watson (cjwatson) wrote :

This looks fine now - thanks, and sorry for the delay! I'm merging this (although rebased against lp:os-prober), and adjusting for some minor style nits.

review: Approve

Unmerged revisions

18. By Surbhi Palande

mount btrfs subvolume @ when present to access a btrfs formatted rootfs.
(LP: #764893)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2011-04-10 00:36:21 +0000
+++ debian/changelog 2011-04-21 15:53:23 +0000
@@ -1,3 +1,10 @@
1os-prober (1.44ubuntu2) natty; urgency=low
2
3 * mount btrfs subvolume @ when present to access a btrfs formatted rootfs.
4 (LP: #764893)
5
6 -- Surbhi Palande <surbhi.palande@canonical.com> Thu, 21 Apr 2011 17:44:10 +0300
7
1os-prober (1.44ubuntu1) natty; urgency=low8os-prober (1.44ubuntu1) natty; urgency=low
29
3 * Cherry-pick from trunk:10 * Cherry-pick from trunk:
411
=== modified file 'linux-boot-probes/common/50mounted-tests'
--- linux-boot-probes/common/50mounted-tests 2011-04-10 00:36:21 +0000
+++ linux-boot-probes/common/50mounted-tests 2011-04-21 15:53:23 +0000
@@ -43,6 +43,26 @@
43 for type in $types; do43 for type in $types; do
44 if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then44 if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
45 mounted=145 mounted=1
46 case "$type" in
47 btrfs|fuse)
48 if [ -x "$tmpmnt/@/lib" ]; then
49 if ! mount --bind "$tmpmnt/@" \
50 "$tmpmnt";
51 then
52 warn "failed to bind mount" \
53 "the subvolume:@ on $partition"
54 if ! umount $tmpmnt
55 then
56 warn "failed to" \
57 "unmount $tmpmnt"
58 fi
59 mounted=
60 fi
61 fi
62 ;;
63 *)
64 ;;
65 esac
46 break66 break
47 fi67 fi
48 done68 done
@@ -62,6 +82,23 @@
62 if ! umount "$tmpmnt"; then82 if ! umount "$tmpmnt"; then
63 warn "failed to umount $tmpmnt"83 warn "failed to umount $tmpmnt"
64 fi84 fi
85 case $type in
86 btrfs|fuse)
87 if [ -x "$tmpmnt/@/lib" ]
88 then
89 # umount to account
90 # for the mount-bind
91 if ! umount $tmpmnt
92 then
93 warn "failed to "\
94 "umount $tmpmnt"
95 fi
96 fi
97 ;;
98 *)
99 ;;
100 esac
101
65 rmdir "$tmpmnt" || true102 rmdir "$tmpmnt" || true
66 exit 0103 exit 0
67 fi104 fi
68105
=== modified file 'os-probes/common/50mounted-tests'
--- os-probes/common/50mounted-tests 2011-04-10 00:36:21 +0000
+++ os-probes/common/50mounted-tests 2011-04-21 15:53:23 +0000
@@ -57,6 +57,26 @@
57 if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then57 if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
58 debug "mounted as $type filesystem"58 debug "mounted as $type filesystem"
59 mounted=159 mounted=1
60 case "$type" in
61 btrfs|fuse)
62 if [ -x "$tmpmnt/@/lib" ]; then
63 if ! mount --bind "$tmpmnt/@" \
64 "$tmpmnt"
65 then
66 warn "failed to bind mount" \
67 "the subvolume:@ on $partition"
68 if ! umount $tmpmnt
69 then
70 warn "failed to" \
71 "unmount $tmpmnt"
72 fi
73 mounted=
74 fi
75 fi
76 ;;
77 *)
78 ;;
79 esac
60 break80 break
61 fi81 fi
62 done82 done
@@ -71,6 +91,22 @@
71 if ! umount "$tmpmnt"; then91 if ! umount "$tmpmnt"; then
72 warn "failed to umount $tmpmnt"92 warn "failed to umount $tmpmnt"
73 fi93 fi
94 case "$type" in
95 btrfs|fuse)
96 if [ -x "$tmpmnt/@/lib" ]
97 then
98 # umount to account
99 # for the mount-bind
100 if ! umount $tmpmnt
101 then
102 warn "failed to "\
103 "umount $tmpmnt"
104 fi
105 fi
106 ;;
107 *)
108 ;;
109 esac
74 rmdir "$tmpmnt" || true110 rmdir "$tmpmnt" || true
75 exit 0111 exit 0
76 fi112 fi

Subscribers

People subscribed via source and target branches