]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk-activate: abort if target position is already mounted
authorSage Weil <sage@inktank.com>
Thu, 14 Mar 2013 23:18:26 +0000 (16:18 -0700)
committerSage Weil <sage@inktank.com>
Fri, 26 Apr 2013 20:40:03 +0000 (13:40 -0700)
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 <sage@inktank.com>
(cherry picked from commit 7370b5564606474f11b9ac5afb7cc60e0ac36ed1)

src/ceph-disk-activate

index 1eb696490e3927d715e7ca28231a4a9a527b5228..f5a33dd926b8e84205349a6dfbf08ea4fba088ec 100755 (executable)
@@ -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,