From: Sage Weil Date: Wed, 8 Mar 2017 20:01:28 +0000 (-0500) Subject: os/bluestore: reimplement/rename _sync -> _flush_all X-Git-Tag: v12.0.1~12^2~27 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=986776d30d18719e18478da3627680ee7ce57b29;p=ceph.git 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index d726469ad649..04ca35354cc8 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 d419e4b14d6d..6bd3b20c25be 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;