From: Sage Weil Date: Mon, 9 Oct 2017 16:37:23 +0000 (-0500) Subject: os/bluestore: simplify completion roll-ups X-Git-Tag: v13.0.2~743^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=df1c7308c9c4d0ccd54914ffb3a2af80cbcc86bf;p=ceph.git os/bluestore: simplify completion roll-ups 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 --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index d4fc72255c2..c830996cc69 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -587,17 +587,30 @@ public: assert(out_on_commit); assert(out_on_applied_sync); list on_applied, on_commit, on_applied_sync; - for (vector::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& t, + list *out_on_applied, + list *out_on_commit, + list *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); diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 205bd00abf1..43b6089e310 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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 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::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); } } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index b2ecb0f4453..38e829814a0 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1552,7 +1552,6 @@ public: set shared_blobs_written; ///< update these on io completion KeyValueDB::Transaction t; ///< then we will commit this - Context *oncommit = nullptr; ///< signal on commit list oncommits; ///< more commit completions list removed_collections; ///< colls we removed