From 44dbc2eec576b2ce08926e7caffdc06d5e12a3a3 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Mon, 22 Jul 2019 22:02:41 +0800 Subject: [PATCH] os/bluestore: avoid unnecessary notify. Add parameter count waiting list for Onode::flush to avoid unnecessary notify. Signed-off-by: Jianpeng Ma --- src/os/bluestore/BlueStore.cc | 4 +++- src/os/bluestore/BlueStore.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index bf1407ba7b1af..e424f8449706c 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -3287,10 +3287,12 @@ void BlueStore::Onode::flush() { if (flushing_count.load()) { ldout(c->store->cct, 20) << __func__ << " cnt:" << flushing_count << dendl; + waiting_count++; std::unique_lock l(flush_lock); while (flushing_count.load()) { flush_cond.wait(l); } + waiting_count--; } ldout(c->store->cct, 20) << __func__ << " done" << dendl; } @@ -10201,7 +10203,7 @@ void BlueStore::_txc_applied_kv(TransContext *txc) for (auto& o : *ls) { dout(20) << __func__ << " onode " << o << " had " << o->flushing_count << dendl; - if (--o->flushing_count == 0) { + if (--o->flushing_count == 0 && o->waiting_count.load()) { std::lock_guard l(o->flush_lock); o->flush_cond.notify_all(); } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index c9b26ca731a6c..f31470e6860fa 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1060,6 +1060,7 @@ public: // track txc's that have not been committed to kv store (and whose // effects cannot be read via the kvdb read methods) std::atomic flushing_count = {0}; + std::atomic waiting_count = {0}; /// protect flush_txns ceph::mutex flush_lock = ceph::make_mutex("BlueStore::Onode::flush_lock"); ceph::condition_variable flush_cond; ///< wait here for uncommitted txns -- 2.39.5