From 3cf2b0f9b7115bece4ca49986bac3d179509d7dc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 13 Mar 2017 22:49:41 -0400 Subject: [PATCH] os/bluestore: keep all OpSequencers registered Maintain the set of all live OpSequencers. Signed-off-by: Sage Weil --- src/os/bluestore/BlueStore.cc | 4 ++-- src/os/bluestore/BlueStore.h | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 9357510557e..d726469ad64 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -7759,7 +7759,7 @@ int BlueStore::_do_deferred_op(TransContext *txc, bluestore_deferred_op_t& wo) int BlueStore::_deferred_replay() { dout(10) << __func__ << " start" << dendl; - OpSequencerRef osr = new OpSequencer(cct); + OpSequencerRef osr = new OpSequencer(cct, this); int count = 0; KeyValueDB::Iterator it = db->get_iterator(PREFIX_DEFERRED); for (it->lower_bound(string()); it->valid(); it->next(), ++count) { @@ -7819,7 +7819,7 @@ int BlueStore::queue_transactions( osr = static_cast(posr->p.get()); dout(10) << __func__ << " existing " << osr << " " << *osr << dendl; } else { - osr = new OpSequencer(cct); + osr = new OpSequencer(cct, this); osr->parent = posr; posr->p = osr; dout(10) << __func__ << " new " << osr << " " << *osr << dendl; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index eb2dd1dd565..d419e4b14d6 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1535,6 +1535,7 @@ public: boost::intrusive::list_member_hook<> deferred_osr_queue_item; Sequencer *parent; + BlueStore *store; std::mutex deferred_apply_mutex; @@ -1546,13 +1547,15 @@ public: std::atomic_int kv_submitted_waiters = {0}; - OpSequencer(CephContext* cct) + OpSequencer(CephContext* cct, BlueStore *store) //set the qlock to PTHREAD_MUTEX_RECURSIVE mode : Sequencer_impl(cct), - parent(NULL) { + parent(NULL), store(store) { + store->register_osr(this); } ~OpSequencer() { assert(q.empty()); + store->unregister_osr(this); } void queue_new(TransContext *txc) { @@ -1717,6 +1720,9 @@ private: vector cache_shards; + std::mutex osr_lock; ///< protect osd_set + std::set osr_set; ///< set of all OpSequencers + std::atomic nid_last = {0}; std::atomic nid_max = {0}; std::atomic blobid_last = {0}; @@ -1995,6 +2001,15 @@ public: f->close_section(); } + void register_osr(OpSequencer *osr) { + std::lock_guard l(osr_lock); + osr_set.insert(osr); + } + void unregister_osr(OpSequencer *osr) { + std::lock_guard l(osr_lock); + osr_set.erase(osr); + } + public: int statfs(struct store_statfs_t *buf) override; -- 2.39.5