From c435d314caeb5424c1f4482ad02f8a085317ad5b Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 30 Oct 2012 14:17:56 -0700 Subject: [PATCH] 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 --- src/ceph-disk-activate | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/ceph-disk-activate b/src/ceph-disk-activate index e3b26e15b1e61..5fcc5bd177a5a 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: -- 2.39.5