]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: simplify completion roll-ups
authorSage Weil <sage@redhat.com>
Mon, 9 Oct 2017 16:37:23 +0000 (11:37 -0500)
committerSage Weil <sage@redhat.com>
Mon, 11 Dec 2017 21:05:38 +0000 (15:05 -0600)
No need to wrap these in C_Contexts and do a new allocation; just slurp
up the list elements directly.

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

index d4fc72255c23f8944a5ad23c3e9a71d95c7c5757..c830996cc699a35503f5483fb1158df480879856 100644 (file)
@@ -587,17 +587,30 @@ public:
       assert(out_on_commit);
       assert(out_on_applied_sync);
       list<Context *> on_applied, on_commit, on_applied_sync;
-      for (vector<Transaction>::iterator i = t.begin();
-          i != t.end();
-          ++i) {
-       on_applied.splice(on_applied.end(), (*i).on_applied);
-       on_commit.splice(on_commit.end(), (*i).on_commit);
-       on_applied_sync.splice(on_applied_sync.end(), (*i).on_applied_sync);
+      for (auto& i : t) {
+       on_applied.splice(on_applied.end(), i.on_applied);
+       on_commit.splice(on_commit.end(), i.on_commit);
+       on_applied_sync.splice(on_applied_sync.end(), i.on_applied_sync);
       }
       *out_on_applied = C_Contexts::list_to_context(on_applied);
       *out_on_commit = C_Contexts::list_to_context(on_commit);
       *out_on_applied_sync = C_Contexts::list_to_context(on_applied_sync);
     }
+    static void collect_contexts(
+      vector<Transaction>& t,
+      list<Context*> *out_on_applied,
+      list<Context*> *out_on_commit,
+      list<Context*> *out_on_applied_sync) {
+      assert(out_on_applied);
+      assert(out_on_commit);
+      assert(out_on_applied_sync);
+      for (auto& i : t) {
+       out_on_applied->splice(out_on_applied->end(), i.on_applied);
+       out_on_commit->splice(out_on_commit->end(), i.on_commit);
+       out_on_applied_sync->splice(out_on_applied_sync->end(),
+                                   i.on_applied_sync);
+      }
+    }
 
     Context *get_on_applied() {
       return C_Contexts::list_to_context(on_applied);
index 205bd00abf1397d6ee9faafbf73c6314ff19b1c0..43b6089e3101c8af1c204120507c10647460c1ea 100644 (file)
@@ -8216,17 +8216,9 @@ void BlueStore::_txc_applied_kv(TransContext *txc)
 void BlueStore::_txc_committed_kv(TransContext *txc)
 {
   dout(20) << __func__ << " txc " << txc << dendl;
-
   unsigned n = txc->osr->parent->shard_hint.hash_to_shard(m_finisher_num);
-  if (txc->oncommit) {
-    logger->tinc(l_bluestore_commit_lat, ceph_clock_now() - txc->start);
-    finishers[n]->queue(txc->oncommit);
-    txc->oncommit = NULL;
-  }
-
-  if (!txc->oncommits.empty()) {
-    finishers[n]->queue(txc->oncommits);
-  }
+  logger->tinc(l_bluestore_commit_lat, ceph_clock_now() - txc->start);
+  finishers[n]->queue(txc->oncommits);
 }
 
 void BlueStore::_txc_finish(TransContext *txc)
@@ -8997,18 +8989,18 @@ int BlueStore::queue_transactions(
     ThreadPool::TPHandle *handle)
 {
   FUNCTRACE(cct);
-  Context *onreadable;
-  Context *ondisk;
-  Context *onreadable_sync;
+  list<Context *> on_applied, on_commit, on_applied_sync;
   ObjectStore::Transaction::collect_contexts(
-    tls, &onreadable, &ondisk, &onreadable_sync);
+    tls, &on_applied, &on_commit, &on_applied_sync);
 
   if (cct->_conf->objectstore_blackhole) {
     dout(0) << __func__ << " objectstore_blackhole = TRUE, dropping transaction"
            << dendl;
-    delete ondisk;
-    delete onreadable;
-    delete onreadable_sync;
+    for (auto& l : { on_applied, on_commit, on_applied_sync }) {
+      for (auto c : l) {
+       delete c;
+      }
+    }
     return 0;
   }
   utime_t start = ceph_clock_now();
@@ -9027,7 +9019,7 @@ int BlueStore::queue_transactions(
 
   // prepare
   TransContext *txc = _txc_create(osr);
-  txc->oncommit = ondisk;
+  txc->oncommits.swap(on_commit);
 
   for (vector<Transaction>::iterator p = tls.begin(); p != tls.end(); ++p) {
     (*p).set_osr(osr);
@@ -9081,15 +9073,15 @@ int BlueStore::queue_transactions(
   _txc_state_proc(txc);
 
   // we're immediately readable (unlike FileStore)
-  if (onreadable_sync) {
-    onreadable_sync->complete(0);
+  for (auto c : on_applied_sync) {
+    c->complete(0);
   }
-  if (onreadable) {
+  unsigned n = osr->parent->shard_hint.hash_to_shard(m_finisher_num);
+  for (auto c : on_applied) {
     // NOTE: these may complete out of order since some may be sync and some
     // may be async.
-    if (!onreadable->sync_complete(0)) {
-      unsigned n = osr->parent->shard_hint.hash_to_shard(m_finisher_num);
-      finishers[n]->queue(onreadable);
+    if (!c->sync_complete(0)) {
+      finishers[n]->queue(c);
     }
   }
 
index b2ecb0f4453819f10dd499d387e472389d139159..38e829814a076ada83d3e17b656691b1d282d08c 100644 (file)
@@ -1552,7 +1552,6 @@ public:
     set<SharedBlobRef> shared_blobs_written; ///< update these on io completion
 
     KeyValueDB::Transaction t; ///< then we will commit this
-    Context *oncommit = nullptr;         ///< signal on commit
     list<Context*> oncommits;  ///< more commit completions
     list<CollectionRef> removed_collections; ///< colls we removed