From 986776d30d18719e18478da3627680ee7ce57b29 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 8 Mar 2017 15:01:28 -0500 Subject: [PATCH] os/bluestore: reimplement/rename _sync -> _flush_all The old implementation is racy and doesn't actually work. Instead, rely on a list of all OpSequencers and drain them all. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 39 +++++++++++++++++++---------------- src/os/bluestore/BlueStore.h | 2 +- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d726469ad64..04ca35354cc 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4814,7 +4814,7 @@ int BlueStore::umount() assert(mounted); dout(1) << __func__ << dendl; - _sync(); + _osr_drain_all(); mempool_thread.shutdown(); @@ -5408,23 +5408,6 @@ int BlueStore::fsck(bool deep) return errors; } -void BlueStore::_sync() -{ - dout(10) << __func__ << dendl; - - // flush aios in flight - bdev->flush(); - - std::unique_lock l(kv_lock); - while (!kv_committing.empty() || - !kv_queue.empty()) { - dout(20) << " waiting for kv to commit" << dendl; - kv_sync_cond.wait(l); - } - - dout(10) << __func__ << " done" << dendl; -} - int BlueStore::statfs(struct store_statfs_t *buf) { buf->reset(); @@ -7512,6 +7495,26 @@ void BlueStore::_txc_release_alloc(TransContext *txc) txc->released.clear(); } +void BlueStore::_osr_drain_all() +{ + dout(10) << __func__ << dendl; + + // WARNING: we make a (somewhat sloppy) assumption here that + // no OpSequencers will be created or destroyed for the duration + // of this method. + set s; + { + std::lock_guard l(osr_lock); + s = osr_set; + } + for (auto osr : s) { + dout(20) << __func__ << " flush " << osr << dendl; + osr->drain(); + } + + dout(10) << __func__ << " done" << dendl; +} + void BlueStore::_kv_sync_thread() { dout(10) << __func__ << " start" << dendl; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index d419e4b14d6..6bd3b20c25b 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1889,6 +1889,7 @@ private: void _txc_release_alloc(TransContext *txc); void _osr_reap_done(OpSequencer *osr); + void _osr_drain_all(); void _kv_sync_thread(); void _kv_stop() { @@ -1974,7 +1975,6 @@ public: int mount() override; int umount() override; - void _sync(); int fsck(bool deep) override; -- 2.39.5