[Devel] [PATCH RH7 05/12] blk-wbt: fix has-sleeper queueing check
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Sep 29 14:30:05 MSK 2022
From: Jens Axboe <axboe at kernel.dk>
We need to do this inside the loop as well, or we can allow new
IO to supersede previous IO.
Tested-by: Anchal Agarwal <anchalag at amazon.com>
Signed-off-by: Jens Axboe <axboe at kernel.dk>
https://jira.sw.ru/browse/PSBM-141883
(cherry picked from commit c45e6a037a536530bd25781ac7c989e52deb2a63)
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
block/blk-wbt.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 26986435d969..97adb724df09 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -519,16 +519,17 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
{
struct rq_wait *rqw = get_rq_wait(rwb, current_is_kswapd());
DECLARE_WAITQUEUE(wait, current);
+ bool has_sleeper;
- if (!wq_has_sleeper(&rqw->wait) &&
- rq_wait_inc_below(rqw, get_limit(rwb, rw)))
+ has_sleeper = wq_has_sleeper(&rqw->wait);
+ if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw)))
return;
add_wait_queue_exclusive(&rqw->wait, &wait);
do {
set_current_state(TASK_UNINTERRUPTIBLE);
- if (rq_wait_inc_below(rqw, get_limit(rwb, rw)))
+ if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw)))
break;
if (lock)
@@ -538,6 +539,8 @@ static void __wbt_wait(struct rq_wb *rwb, unsigned long rw, spinlock_t *lock)
if (lock)
spin_lock_irq(lock);
+
+ has_sleeper = false;
} while (1);
__set_current_state(TASK_RUNNING);
--
2.37.1
More information about the Devel
mailing list