unable to mount ceph root at boot due to stripping of trailing slashes

Bug #809221 reported by Damien Churchill
26
This bug affects 5 people
Affects Status Importance Assigned to Milestone
mountall (Ubuntu)
Fix Released
Medium
Steve Langasek

Bug Description

When the mount device doesn't start with UUID= or LABEL= update_mount will strip the trailing slashes from the mount device name. For most situations this is fine but with Ceph it's quite possible that, for example, 192.168.0.15:/ would be an acceptable mount device but mount at boot fails since it passes 192.168.0.15: to mount.ceph, which then complains about an invalid device.

I have attached a patch that resolves this issue. I don't know if it is the best way to do it but it works for me okay and shouldn't have an impact anywhere else.

Tags: patch
Revision history for this message
Damien Churchill (damoxc) wrote :
tags: added: patch
Steve Langasek (vorlon)
Changed in mountall (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
summary: - unable to mount ceph root at boot
+ unable to mount ceph root at boot due to stripping of trailing slashes
Revision history for this message
Matthew Roy (matthew-royhousehold) wrote :

Applying this patch and rebuilding mountall fixed the problem for me also. What needs to be done to get this patch merged and a fixed package released for precise?

Revision history for this message
Matthew Roy (matthew-royhousehold) wrote :

Debdiff of patch by Damien Churchill <email address hidden> attached.

Revision history for this message
Adam Conrad (adconrad) wrote :

Damien,

I'm a bit confused by this part of the patch, which seems a bit odd to me:

+ int devlen;
[...]
+ devlen = strlen(mnt->device);
+ if ( devlen < 2 || strcmp(mnt->device + (devlen - 2), ":/")) {
+ strip_slashes (mnt->device);
+ }

Neither part of that conditional makes a whole lot of sense to me (though, admittedly, I know little of ceph). If ceph doesn't need the trailing slashes removed, why do it "sometimes"?

(1) In the first case, "if ( devlen < 2) strip_slashes()" seems to assume that the device would be "/" and we're reducing it to an empty string. Is that a sane result?
(2) The second part of the conditional won't strip slashes from "127.0.0.1:/" (which is correct, and addresses the bug report), but would then needlessly strip slashes from "127.0.0.1:/foo/", which I'm told is pointless, since both :/foo/ and :/foo are valid device names.

Can you comment on the above notes? If this conditional is pointless, I'd happily remove it and sponsor the upload and SRUs to older releases. If either of these is actually necessary, some rationale explaining the code (maybe even some comments to throw in the code so later auditors don't ask WTF, as I've just done) would be lovely.

Revision history for this message
Steve Langasek (vorlon) wrote :

If :/foo and :/foo/ have the same meaning, then we would want to still normalize them for mountall's purposes. I think ceph is not the only network filesystem where stripping the only / may give unexpected results; I get strange results for NFSv4 root mounts too, though with NFS it doesn't actually fail to mount, it just looks strange.

I haven't reviewed the patch, but the above general principle makes sense to me.

Revision history for this message
Tv (tv42) wrote :

mountall calls strip_slashes for the device and the mount path. For mount path, it makes sense. For mounting /dev/sda on something, having /dev mounted first makes sense, and I guess for that you need strip_slashes. Perhaps the strip slashes and that part of the dependency logic should only trigger for bind mounts or things in /dev. A simpler check for that might be "not a remote filesystem" -- you already have is_remote, and for remote filesystems the device just isn't a local path ever.

Revision history for this message
Tv (tv42) wrote :

The Ceph device string can be (EBNF off the top of my head)

address = ip | hostname
mon = address [ ":" port ]
mons = mon [ "," mons ]
dev = mons ":" path

For example:

1.2.3.4:/
1.2.3.4:/foo
1.2.3.4:6789:/foo
1.2.3.4,2.3.4.5:/foo
1.2.3.4:6789,2.3.4.5:/foo
1.2.3.4:6789,2.3.4.5:6789:/foo

path always begins with a slash.

And there's IPv6 support in there too.

But really, mountall should treat dev as an opaque string until proven otherwise (is_remote gives false, etc).

Revision history for this message
Dan Mick (dan-mick) wrote :

Seems to me that the filesystem-specific mount and/or the filesystem module should get the 'device' path unmodified, and deal with it how it will. (For instance, as noted, nfs mounts can also contain a trailing path, and nfsserv:/ should work unsurprisingly).

nfs currently works because it doesn't try to validate that '/' exists; mount.nfs requires a :, and passes on a
potentially-empty path to the kernel mount function. Ceph's kernel module could accept that as well, but the
fact remains that mountall really should not be removing the trailing /.

Steve Langasek (vorlon)
Changed in mountall (Ubuntu):
assignee: nobody → Steve Langasek (vorlon)
Revision history for this message
Steve Langasek (vorlon) wrote :

Thanks, I've reviewed the patch here and pushed a fix to the mountall branch with some modifications. We don't actually want to special-case the 'ceph' filesystem type, the same parsing should be used for all network filesystems.

This fix will be included in the next upload.

Changed in mountall (Ubuntu):
status: Triaged → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package mountall - 2.40

---------------
mountall (2.40) unstable; urgency=low

  * Add /run/user as a default mountpoint, in support of $XDG_RUNTIME_DIR.
    LP: #894391.

mountall (2.39) unstable; urgency=low

  * Adjust parsing of device names so that network mounts pointing to the
    server's root don't have the path mis-normalized to the empty string.
    Thanks to Damien Churchill <email address hidden> for the initial
    implementation. LP: #809221.
  * Add compatibility jobs with names to match the historic sysvinit init
    scripts, so that startpar can DTRT.
 -- Steve Langasek <email address hidden> Fri, 31 Aug 2012 19:55:01 -0700

Changed in mountall (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.