]> 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>
Thu, 6 Mar 2025 09:38:13 +0000 (17:38 +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>
(cherry picked from commit cec2e4550fe520fa60445678934c04ba605913be)

src/blk/kernel/KernelDevice.cc
src/blk/kernel/KernelDevice.h

index cb2b06a3de46eca832cc9ba15f371172326312c5..b6e637a6b21729e0e703af60ff520af88e0751d4 100644 (file)
@@ -591,6 +591,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);
   }
 }
@@ -756,7 +757,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 99098d7fe401a760941b3ce2a954526174e8c66f..c7d55d73edc9488144086e9ddf2469a5422ac727 100644 (file)
@@ -53,6 +53,7 @@ private:
   void *discard_callback_priv;
   bool aio_stop;
   bool discard_stop;
+  bool need_notify = false;
 
   ceph::mutex discard_lock = ceph::make_mutex("KernelDevice::discard_lock");
   ceph::condition_variable discard_cond;