From: Sage Weil Date: Tue, 30 Oct 2012 21:17:56 +0000 (-0700) Subject: ceph-disk-activate: avoid duplicating mounts if already activated X-Git-Tag: v0.54~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c435d314caeb5424c1f4482ad02f8a085317ad5b;p=ceph.git ceph-disk-activate: avoid duplicating mounts if already activated 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 --- diff --git a/src/ceph-disk-activate b/src/ceph-disk-activate index e3b26e15b1e..5fcc5bd177a 100755 --- a/src/ceph-disk-activate +++ b/src/ceph-disk-activate @@ -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: