From: Igor Fedotov Date: Fri, 21 Apr 2017 17:07:32 +0000 (-0700) Subject: os/bluestore: move TransContext finalization out of osr_lock to avoid potential conte... X-Git-Tag: v12.0.3~189^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6b457d168b42da8f5932cc5b5e49b96681bfcd87;p=ceph.git os/bluestore: move TransContext finalization out of osr_lock to avoid potential contention. Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 363184eb2f31..e54949231621 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7578,10 +7578,11 @@ void BlueStore::_txc_finish(TransContext *txc) OpSequencerRef osr = txc->osr; CollectionRef c; bool empty = false; + OpSequencer::q_list_t releasing_txc; { std::lock_guard l(osr->qlock); txc->state = TransContext::STATE_DONE; - + bool notify = false; while (!osr->q.empty()) { TransContext *txc = &osr->q.front(); dout(20) << __func__ << " txc " << txc << " " << txc->get_state_name() @@ -7590,23 +7591,19 @@ void BlueStore::_txc_finish(TransContext *txc) if (txc->state == TransContext::STATE_PREPARE && deferred_aggressive) { // for _osr_drain_preceding() - osr->qcond.notify_all(); + notify = true; } break; } - // release to allocator only after all preceding txc's have also - // finished any deferred writes that potentially land in these - // blocks - _txc_release_alloc(txc); - if (!c && txc->first_collection) { c = txc->first_collection; } - osr->q.pop_front(); - txc->log_state_latency(logger, l_bluestore_state_done_lat); - delete txc; + releasing_txc.push_back(*txc); + notify = true; + } + if (notify) { osr->qcond.notify_all(); } if (osr->q.empty()) { @@ -7614,6 +7611,17 @@ void BlueStore::_txc_finish(TransContext *txc) empty = true; } } + while (!releasing_txc.empty()) { + // release to allocator only after all preceding txc's have also + // finished any deferred writes that potentially land in these + // blocks + auto txc = &releasing_txc.front(); + _txc_release_alloc(txc); + releasing_txc.pop_front(); + txc->log_state_latency(logger, l_bluestore_state_done_lat); + delete txc; + } + if (c) { c->trim_cache(); }