diff options
author | Sage Weil <sage@inktank.com> | 2012-10-30 14:17:56 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2012-11-12 11:53:23 -0800 |
commit | e35e7e2bcb749e3ee00f1f93bc6b17bde8329414 (patch) | |
tree | 2fb2a30e1d4cd0e8320b8e1f04166a325cdad29e | |
parent | 0c9bbb3b4b4dbe6f0a12960785e35af9c748701a (diff) | |
download | ceph-e35e7e2bcb749e3ee00f1f93bc6b17bde8329414.tar.gz |
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 <sage@inktank.com>
(cherry picked from commit c435d314caeb5424c1f4482ad02f8a085317ad5b)
-rwxr-xr-x | src/ceph-disk-activate | 25 |
1 files changed, 20 insertions, 5 deletions
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: |