From: Jianpeng Ma Date: Mon, 22 Jul 2019 14:02:41 +0000 (+0800) Subject: os/bluestore: avoid unnecessary notify. X-Git-Tag: v15.1.0~2048^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=44dbc2eec576b2ce08926e7caffdc06d5e12a3a3;p=ceph.git os/bluestore: avoid unnecessary notify. Add parameter count waiting list for Onode::flush to avoid unnecessary notify. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index bf1407ba7b1a..e424f8449706 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 c9b26ca731a6..f31470e6860f 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