diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e8da12cb655..4a87a6e7189 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -8327,9 +8327,10 @@ void BlueStore::get_db_statistics(Formatter *f) } BlueStore::TransContext *BlueStore::_txc_create( - Collection *c, OpSequencer *osr) + Collection *c, OpSequencer *osr, + list *on_commits) { - TransContext *txc = new TransContext(cct, c, osr); + TransContext *txc = new TransContext(cct, c, osr, on_commits); txc->t = db->get_transaction(); osr->queue_new(txc); dout(20) << __func__ << " osr " << osr << " = " << txc @@ -8441,8 +8442,6 @@ void BlueStore::_txc_state_proc(TransContext *txc) } return; case TransContext::STATE_KV_SUBMITTED: - txc->log_state_latency(logger, l_bluestore_state_kv_committing_lat); - txc->state = TransContext::STATE_KV_DONE; _txc_committed_kv(txc); // ** fall-thru ** @@ -8634,8 +8633,13 @@ void BlueStore::_txc_applied_kv(TransContext *txc) void BlueStore::_txc_committed_kv(TransContext *txc) { dout(20) << __func__ << " txc " << txc << dendl; + { + std::lock_guard l(txc->osr->qlock); + txc->state = TransContext::STATE_KV_DONE; + finishers[txc->osr->shard]->queue(txc->oncommits); + } + txc->log_state_latency(logger, l_bluestore_state_kv_committing_lat); logger->tinc(l_bluestore_commit_lat, ceph_clock_now() - txc->start); - finishers[txc->osr->shard]->queue(txc->oncommits); } void BlueStore::_txc_finish(TransContext *txc) @@ -9421,7 +9425,7 @@ int BlueStore::_deferred_replay() r = -EIO; goto out; } - TransContext *txc = _txc_create(ch.get(), osr); + TransContext *txc = _txc_create(ch.get(), osr, nullptr); txc->deferred_txn = deferred_txn; txc->state = TransContext::STATE_KV_DONE; _txc_state_proc(txc); @@ -9468,8 +9472,8 @@ int BlueStore::queue_transactions( dout(10) << __func__ << " ch " << c << " " << c->cid << dendl; // prepare - TransContext *txc = _txc_create(static_cast(ch.get()), osr); - txc->oncommits.swap(on_commit); + TransContext *txc = _txc_create(static_cast(ch.get()), osr, + &on_commit); for (vector::iterator p = tls.begin(); p != tls.end(); ++p) { txc->bytes += (*p).get_num_bytes(); diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 7903fec564c..77de7df2163 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1593,12 +1593,16 @@ public: uint64_t last_nid = 0; ///< if non-zero, highest new nid we allocated uint64_t last_blobid = 0; ///< if non-zero, highest new blobid we allocated - explicit TransContext(CephContext* cct, Collection *c, OpSequencer *o) + explicit TransContext(CephContext* cct, Collection *c, OpSequencer *o, + list *on_commits) : ch(c), osr(o), ioc(cct, this), start(ceph_clock_now()) { last_stamp = start; + if (on_commits) { + oncommits.swap(*on_commits); + } } ~TransContext() { delete deferred_txn; @@ -2018,7 +2022,8 @@ private: template void _dump_extent_map(ExtentMap& em); template void _dump_transaction(Transaction *t); - TransContext *_txc_create(Collection *c, OpSequencer *osr); + TransContext *_txc_create(Collection *c, OpSequencer *osr, + list *on_commits); void _txc_update_store_statfs(TransContext *txc); void _txc_add_transaction(TransContext *txc, Transaction *t); void _txc_calc_cost(TransContext *txc);