From: Loic Dachary Date: Fri, 18 Dec 2015 23:53:03 +0000 (+0100) Subject: ceph-disk: protect deactivate with activate lock X-Git-Tag: v10.0.3~189^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F6926%2Fhead;p=ceph.git ceph-disk: protect deactivate with activate lock When ceph-disk prepares the disk, it triggers udev events and each of them ceph-disk activate. If systemctl stop ceph-osd@2 happens while there still are ceph-disk activate in flight, the systemctl stop may be cancelled by the systemctl enable issued by one of the pending ceph-disk activate. This only matters in a test environment where disks are destroyed shortly after they are activated. Signed-off-by: Loic Dachary --- diff --git a/src/ceph-disk b/src/ceph-disk index 62b57a04557a..05c1a89d412f 100755 --- a/src/ceph-disk +++ b/src/ceph-disk @@ -2664,6 +2664,13 @@ def _remove_osd_directory_files(mounted_path, cluster): def main_deactivate(args): + activate_lock.acquire() # noqa + try: + main_deactivate_locked(args) + finally: + activate_lock.release() # noqa + +def main_deactivate_locked(args): osd_id = args.deactivate_by_id path = args.path target_dev = None @@ -2725,8 +2732,6 @@ def main_deactivate(args): if dmcrypt: dmcrypt_unmap(part_uuid) - return - ########################### def _remove_from_crush_map(cluster, osd_id):