]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk: do not use mount --move (or --bind)
authorSage Weil <sage@inktank.com>
Fri, 14 Jun 2013 04:56:23 +0000 (21:56 -0700)
committerSage Weil <sage@inktank.com>
Fri, 14 Jun 2013 21:04:54 +0000 (14:04 -0700)
The kernel does not let you mount --move when the parent mount is
shared (see, e.g., https://bugzilla.redhat.com/show_bug.cgi?id=917008
for another person this also confused).  We can't use --bind either
since that (on RHEL at least) screws up /etc/mtab so that the final
result looks like

 /var/lib/ceph/tmp/mnt.HNHoXU /var/lib/ceph/osd/ceph-0 none rw,bind 0 0

Instead, mount the original dev in the final location and then umount
from the old location.

Signed-off-by: Sage Weil <sage@inktank.com>
src/ceph-disk

index 1d1a1501e79e04cb8d86a910f5ad8bd6eb15c3a9..127d809902db0596aa69790b87f6b249c0ea6526 100755 (executable)
@@ -1248,6 +1248,7 @@ def auth_key(
 
 
 def move_mount(
+    dev,
     path,
     cluster,
     osd_id,
@@ -1259,15 +1260,30 @@ def move_mount(
         '{cluster}-{osd_id}'.format(cluster=cluster, osd_id=osd_id),
         )
     maybe_mkdir(osd_data)
+
+    # we really want to mount --move, but that is not supported when
+    # the parent mount is shared, as it is by default on RH, Fedora,
+    # and probably others.  Also, --bind doesn't properly manipulate
+    # /etc/mtab, which *still* isn't a symlink to /proc/mounts despite
+    # this being 2013.  Instead, mount the original device at the final
+    # location.
     subprocess.check_call(
         args=[
             '/bin/mount',
-            '--move',
             '--',
-            path,
+            dev,
             osd_data,
             ],
         )
+    subprocess.check_call(
+        args=[
+            '/bin/umount',
+            '-l',   # lazy, in case someone else is peeking at the
+                    # wrong moment
+            '--',
+            path,
+            ],
+        )
 
 
 def start_daemon(
@@ -1405,6 +1421,7 @@ def mount_activate(
             raise Error('another %s osd.%s already mounted in position (old/different cluster instance?); unmounting ours.' % (cluster, osd_id))
         else:
             move_mount(
+                dev=dev,
                 path=path,
                 cluster=cluster,
                 osd_id=osd_id,