]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-disk-activate: avoid duplicating mounts if already activated
authorSage Weil <sage@inktank.com>
Tue, 30 Oct 2012 21:17:56 +0000 (14:17 -0700)
committerSage Weil <sage@inktank.com>
Thu, 1 Nov 2012 00:14:31 +0000 (17:14 -0700)
If the given device is already mounted at the target location, do not
mount --move it again and create a bunch of dup entries in the /etc/mtab
and kernel mount table.

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

index e3b26e15b1e6112659f0e8b436ac0002c92457d0..5fcc5bd177a5a501a4ec62b2911f9c9e601678bb 100755 (executable)
@@ -484,11 +484,26 @@ def activate(
                 )
             write_one_line(path, 'active', 'ok')
 
-        move_mount(
-            path=path,
-            cluster=cluster,
-            osd_id=osd_id,
-            )
+        # check if the disk is already active
+        active = False
+        src_dev = os.stat(path).st_dev
+        try:
+            dst_dev = os.stat('/var/lib/ceph/osd/{cluster}-{osd_id}'.format(
+                    cluster=cluster,
+                    osd_id=osd_id)).st_dev
+            if src_dev == dst_dev:
+                active = True
+        except:
+            pass
+        if active:
+            log.debug('OSD already mounted')
+            unmount(path)
+        else:
+            move_mount(
+                path=path,
+                cluster=cluster,
+                osd_id=osd_id,
+                )
     except:
         unmount(path)
     finally: