]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: make Sequencer::flush() more efficient
authorSage Weil <sage@redhat.com>
Thu, 9 Mar 2017 23:05:48 +0000 (18:05 -0500)
committerSage Weil <sage@redhat.com>
Tue, 21 Mar 2017 18:56:28 +0000 (13:56 -0500)
BlueStore collection methods only need preceding transactions to be
applied to the kv db; they do not need to be committed.

Note that this is *only* needed for collection listings; all other read
operations are immediately safe after queue_transactions().

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

index 374e55c5736b3d33d5ae769d9204888de28a0ec6..19436c81e69d301be9fb0e452353c278b0665269 100644 (file)
@@ -7139,6 +7139,9 @@ 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);
@@ -7577,6 +7580,10 @@ void BlueStore::_kv_sync_thread()
        _txc_applied_kv(txc);
        --txc->osr->kv_committing_serially;
        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();
+       }
       }
       for (auto txc : kv_committing) {
        if (txc->had_ios) {
index 2e428d1cea302f77476e57c69169af54d54c19f3..658c8b0b80196c67e3f23b266cd93aa28e5afd0c 100644 (file)
@@ -1539,6 +1539,8 @@ public:
 
     std::atomic_int kv_committing_serially = {0};
 
+    std::atomic_int kv_submitted_waiters = {0};
+
     OpSequencer(CephContext* cct)
        //set the qlock to PTHREAD_MUTEX_RECURSIVE mode
       : Sequencer_impl(cct),
@@ -1554,16 +1556,26 @@ public:
       q.push_back(*txc);
     }
 
-    void flush() override {
+    void drain() {
       std::unique_lock<std::mutex> l(qlock);
       while (!q.empty())
        qcond.wait(l);
     }
 
-    void drain() {
+    void flush() override {
       std::unique_lock<std::mutex> l(qlock);
-      while (!q.empty())
+      while (true) {
+       if (q.empty()) {
+         return;
+       }
+       TransContext *txc = &q.back();
+       if (txc->state >= TransContext::STATE_KV_SUBMITTED) {
+         return;
+       }
+       ++kv_submitted_waiters;
        qcond.wait(l);
+       --kv_submitted_waiters;
+      }
     }
 
     bool flush_commit(Context *c) override {