From 4c39fc2cda1a91acc168c637d880575d19428ecb Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Sun, 11 Feb 2024 18:45:31 +0100 Subject: [PATCH] os/bluestore: lock collection on deferred _finish_write Leaving deferred map unprotected caused race conditions that must be dealt for correctness. This might impact performance. Signed-off-by: Pere Diaz Bou --- src/os/bluestore/BlueStore.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f78f9ed508d1e..fe332eea5fc4c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -13801,6 +13801,7 @@ void BlueStore::_txc_finish(TransContext *txc) for (auto &[onode, seq] : txc->buffers_written) { if (txc->deferred_txn && txc->deferred_txn->txc_seq == seq) { + std::unique_lock l(onode->c->lock); auto it = onode->c->deferred_seq_dependencies.find(seq); if (it != onode->c->deferred_seq_dependencies.end()) { for (auto &dependent_onode : it->second) { @@ -18167,6 +18168,7 @@ void BlueStore::_shutdown_cache() } for (auto& p : coll_map) { // Clear deferred write buffers before clearing up Onodes + std::unique_lock l(p.second->lock); for (auto &[seq, onodes] : p.second->deferred_seq_dependencies) { for (auto &onode : onodes) { onode->bc._finish_write(onode->c->cache, seq); -- 2.39.5