From dbbde306484276251cbd7a7b7a6fde0093f98ba2 Mon Sep 17 00:00:00 2001 From: linbing Date: Fri, 21 Dec 2018 08:22:30 +0800 Subject: [PATCH] os/bluestore: fixup access a destroy cond cause deadlock or undefine behavior. Fixes: https://tracker.ceph.com/issues/37733 Signed-off-by: linbing --- src/os/bluestore/BlockDevice.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 5faa26073ba..ad60ab32cd4 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -95,13 +95,14 @@ public: void try_aio_wake() { assert(num_running >= 1); + + std::lock_guard l(lock); if (num_running.fetch_sub(1) == 1) { // we might have some pending IOs submitted after the check // as there is no lock protection for aio_submit. // Hence we might have false conditional trigger. // aio_wait has to handle that hence do not care here. - std::lock_guard l(lock); cond.notify_all(); } } -- 2.47.3