ceph-disk: do not use mount --move (or --bind)

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>
This commit is contained in:
Sage Weil 2013-06-13 21:56:23 -07:00
parent f3234c147e
commit e5ffe0d248

View File

@ -1248,6 +1248,7 @@ def auth_key(
def move_mount(
dev,
path,
cluster,
osd_id,
@ -1259,13 +1260,28 @@ 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',
'--',
dev,
osd_data,
],
)
subprocess.check_call(
args=[
'/bin/umount',
'-l', # lazy, in case someone else is peeking at the
# wrong moment
'--',
path,
osd_data,
],
)
@ -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,