From 6395bf856b4d4511f0758174ef915ebcafbe3777 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Sat, 19 Dec 2015 00:53:03 +0100 Subject: [PATCH] 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 --- src/ceph-disk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ceph-disk b/src/ceph-disk index 62b57a04557ab..05c1a89d412fc 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): -- 2.39.5