From: Sage Weil Date: Thu, 14 Mar 2013 23:18:26 +0000 (-0700) Subject: ceph-disk-activate: abort if target position is already mounted X-Git-Tag: v0.60~68 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7370b5564606474f11b9ac5afb7cc60e0ac36ed1;p=ceph.git ceph-disk-activate: abort if target position is already mounted If the target position is already a mount point, fail to move our mount over to it. This usually indicates that a different osd.N from a different cluster instances is in that position. Signed-off-by: Sage Weil --- diff --git a/src/ceph-disk-activate b/src/ceph-disk-activate index 1eb696490e39..f5a33dd926b8 100755 --- a/src/ceph-disk-activate +++ b/src/ceph-disk-activate @@ -483,8 +483,10 @@ def mount_activate( try: (osd_id, cluster) = activate(path, activate_key_template, init) - # check if the disk is already active + # check if the disk is already active, or if something else is already + # mounted there active = False + other = False src_dev = os.stat(path).st_dev try: dst_dev = os.stat('/var/lib/ceph/osd/{cluster}-{osd_id}'.format( @@ -492,11 +494,17 @@ def mount_activate( osd_id=osd_id)).st_dev if src_dev == dst_dev: active = True + else: + parent_dev = os.stat('/var/lib/ceph/osd').st_dev + if dst_dev != parent_dev: + other = True except: pass if active: log.info('%s osd.%s already mounted in position; unmounting ours.' % (cluster, osd_id)) unmount(path) + elif other: + raise ActivateError('another %s osd.%s already mounted in position (old/different cluster instance?); unmounting ours.' % (cluster, osd_id)) else: move_mount( path=path,