]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: simplify flush() wake-up condition
authorSage Weil <sage@redhat.com>
Fri, 17 Mar 2017 17:54:20 +0000 (13:54 -0400)
committerSage Weil <sage@redhat.com>
Tue, 21 Mar 2017 18:56:30 +0000 (13:56 -0500)
Clearer, and fewer wakeups.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 1cb89000b8ec6ffe8cbdc04729bbf9a5dd086f60..bd3e215cf5e82b01af6722d8f3c341f36898f319 100644 (file)
@@ -7093,9 +7093,6 @@ void BlueStore::_txc_state_proc(TransContext *txc)
        } else {
          _txc_finalize_kv(txc, txc->t);
          txc->state = TransContext::STATE_KV_SUBMITTED;
-         if (txc->osr->kv_submitted_waiters) {
-           txc->osr->qcond.notify_all();
-         }
          int r = db->submit_transaction(txc->t);
          assert(r == 0);
          _txc_applied_kv(txc);
@@ -7181,6 +7178,11 @@ void BlueStore::_txc_finish_io(TransContext *txc)
     _txc_state_proc(&*p++);
   } while (p != osr->q.end() &&
           p->state == TransContext::STATE_IO_DONE);
+
+  if (osr->kv_submitted_waiters &&
+      osr->_is_all_kv_submitted()) {
+    osr->qcond.notify_all();
+  }
 }
 
 void BlueStore::_txc_write_nodes(TransContext *txc, KeyValueDB::Transaction t)
@@ -7610,7 +7612,9 @@ void BlueStore::_kv_sync_thread()
        txc->state = TransContext::STATE_KV_SUBMITTED;
        if (txc->osr->kv_submitted_waiters) {
          std::lock_guard<std::mutex> l(txc->osr->qlock);
-         txc->osr->qcond.notify_all();
+         if (txc->osr->_is_all_kv_submitted()) {
+           txc->osr->qcond.notify_all();
+         }
        }
       }
       if (num_aios) {
index 89ca1c532eaec7ab55bf535ad7b031f90ef0ed14..87d436a18f665a7e1d7a8d9a3b2026d362c46d61 100644 (file)
@@ -1578,14 +1578,22 @@ public:
        qcond.wait(l);
     }
 
+    bool _is_all_kv_submitted() {
+      // caller must hold qlock
+      if (q.empty()) {
+       return true;
+      }
+      TransContext *txc = &q.back();
+      if (txc->state >= TransContext::STATE_KV_SUBMITTED) {
+       return true;
+      }
+      return false;
+    }
+
     void flush() override {
       std::unique_lock<std::mutex> l(qlock);
       while (true) {
-       if (q.empty()) {
-         return;
-       }
-       TransContext *txc = &q.back();
-       if (txc->state >= TransContext::STATE_KV_SUBMITTED) {
+       if (_is_all_kv_submitted()) {
          return;
        }
        ++kv_submitted_waiters;