From: Yite Gu Date: Fri, 30 Aug 2024 11:31:36 +0000 (+0800) Subject: blk/kerneldevice: notify_all only required when discard_drain wait for condition X-Git-Tag: v18.2.7~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=77486958ab0589bbbb8ea5260a9b7df0802a0136;p=ceph-ci.git blk/kerneldevice: notify_all only required when discard_drain wait for condition This will cause discard threads to wake up each other if bdev_async_discard_threads >= 2. Fixes: https://tracker.ceph.com/issues/67835 Signed-off-by: Yite Gu (cherry picked from commit cec2e4550fe520fa60445678934c04ba605913be) (cherry picked from commit 3a901add5236835f37480a205cc86e9ea24d161b) (cherry picked from commit 9d6309c0088b080f87b60b2877aabb9170c5a7f0) --- diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 64be2466540..62e300ea124 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -589,6 +589,7 @@ void KernelDevice::discard_drain() dout(10) << __func__ << dendl; std::unique_lock l(discard_lock); while (!discard_queued.empty() || (discard_running > 0)) { + need_notify = true; discard_cond.wait(l); } } @@ -754,7 +755,10 @@ void KernelDevice::_discard_thread(uint64_t tid) if (thr->stop) break; dout(20) << __func__ << " sleep" << dendl; - discard_cond.notify_all(); // for the thread trying to drain... + if (need_notify) { + discard_cond.notify_all(); // for the thread trying to drain... + need_notify = false; + } discard_cond.wait(l); dout(20) << __func__ << " wake" << dendl; } else { diff --git a/src/blk/kernel/KernelDevice.h b/src/blk/kernel/KernelDevice.h index e3ecaa036d0..13badbe2aef 100644 --- a/src/blk/kernel/KernelDevice.h +++ b/src/blk/kernel/KernelDevice.h @@ -52,6 +52,7 @@ private: aio_callback_t discard_callback; void *discard_callback_priv; bool aio_stop; + bool need_notify = false; ceph::mutex discard_lock = ceph::make_mutex("KernelDevice::discard_lock"); ceph::condition_variable discard_cond;