]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
BlueStore: Fix concurrency conflicts 23766/head
authorWang Hongxu <wanghongxu@t2cloud.net>
Tue, 28 Aug 2018 06:51:58 +0000 (14:51 +0800)
committerWang Hongxu <wanghongxu@t2cloud.net>
Tue, 28 Aug 2018 06:58:27 +0000 (14:58 +0800)
When the last two IOs of the same Context return at the same time, their
num_running may be 2 at the same time, causing the thread to not be
woken up, eventually resulting in a timeout.

Signed-off-by: Wang Hongxu <wanghongxu@t2cloud.net>
src/os/bluestore/BlockDevice.h

index 262619919c482234467fd186a9d60923bcf1f98a..c34fde3858549e2c729e6af253193d5e58d9bd83 100644 (file)
@@ -77,7 +77,8 @@ public:
   uint64_t get_num_ios() const;
 
   void try_aio_wake() {
-    if (num_running == 1) {
+    assert(num_running >= 1);
+    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.
@@ -85,10 +86,6 @@ public:
       // aio_wait has to handle that hence do not care here.
       std::lock_guard<std::mutex> l(lock);
       cond.notify_all();
-      --num_running;
-      ceph_assert(num_running >= 0);
-    } else {
-      --num_running;
     }
   }