]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
blk/kerneldevice: notify_all only required when discard_drain wait for condition
authorYite Gu <yitegu0@gmail.com>
Fri, 30 Aug 2024 11:31:36 +0000 (19:31 +0800)
committerYite Gu <yitegu0@gmail.com>
Sat, 19 Oct 2024 05:45:06 +0000 (13:45 +0800)
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 <yitegu0@gmail.com>
src/blk/kernel/KernelDevice.cc
src/blk/kernel/KernelDevice.h

index 72921e6d9f08bf2fa9317a0e78547ec1a581207c..63fd05dad20807630342de5bc65c673a5f93bac5 100644 (file)
@@ -604,6 +604,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);
   }
 }
@@ -769,7 +770,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 {
index ac555cdd3daf37dc2afe994f83ee377d3ccde613..1c8fc4a0a8de6168e5a037a1238e68de3cbd235f 100644 (file)
@@ -58,6 +58,7 @@ private:
   aio_callback_t discard_callback;
   void *discard_callback_priv;
   bool aio_stop;
+  bool need_notify = false;
   std::unique_ptr<PerfCounters> logger;
 
   ceph::mutex discard_lock = ceph::make_mutex("KernelDevice::discard_lock");