From 6b457d168b42da8f5932cc5b5e49b96681bfcd87 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 21 Apr 2017 10:07:32 -0700 Subject: [PATCH] os/bluestore: move TransContext finalization out of osr_lock to avoid potential contention. Signed-off-by: Igor Fedotov --- src/os/bluestore/BlueStore.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) 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(); } -- 2.47.3