Skip to content

Commit 3786407

Browse files
Merge pull request ceph#59529 from YiteGu/fix-discard-thread-wakeup-each-other
blk/kerneldevice: notify_all only required when discard_drain wait for condition
2 parents 4951b08 + cec2e45 commit 3786407

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/blk/kernel/KernelDevice.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ void KernelDevice::discard_drain()
604604
dout(10) << __func__ << dendl;
605605
std::unique_lock l(discard_lock);
606606
while (!discard_queued.empty() || (discard_running > 0)) {
607+
need_notify = true;
607608
discard_cond.wait(l);
608609
}
609610
}
@@ -769,7 +770,10 @@ void KernelDevice::_discard_thread(uint64_t tid)
769770
if (thr->stop)
770771
break;
771772
dout(20) << __func__ << " sleep" << dendl;
772-
discard_cond.notify_all(); // for the thread trying to drain...
773+
if (need_notify) {
774+
discard_cond.notify_all(); // for the thread trying to drain...
775+
need_notify = false;
776+
}
773777
discard_cond.wait(l);
774778
dout(20) << __func__ << " wake" << dendl;
775779
} else {

src/blk/kernel/KernelDevice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class KernelDevice : public BlockDevice,
5858
aio_callback_t discard_callback;
5959
void *discard_callback_priv;
6060
bool aio_stop;
61+
bool need_notify = false;
6162
std::unique_ptr<PerfCounters> logger;
6263

6364
ceph::mutex discard_lock = ceph::make_mutex("KernelDevice::discard_lock");

0 commit comments

Comments
 (0)