Skip to content

Commit c45e6a0

Browse files
committed
blk-wbt: fix has-sleeper queueing check
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@amazon.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b788209 commit c45e6a0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

block/blk-wbt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,16 +492,17 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
492492
{
493493
struct rq_wait *rqw = get_rq_wait(rwb, wb_acct);
494494
DECLARE_WAITQUEUE(wait, current);
495+
bool has_sleeper;
495496

496-
if (!wq_has_sleeper(&rqw->wait) &&
497-
rq_wait_inc_below(rqw, get_limit(rwb, rw)))
497+
has_sleeper = wq_has_sleeper(&rqw->wait);
498+
if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw)))
498499
return;
499500

500501
add_wait_queue_exclusive(&rqw->wait, &wait);
501502
do {
502503
set_current_state(TASK_UNINTERRUPTIBLE);
503504

504-
if (rq_wait_inc_below(rqw, get_limit(rwb, rw)))
505+
if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw)))
505506
break;
506507

507508
if (lock) {
@@ -510,6 +511,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
510511
spin_lock_irq(lock);
511512
} else
512513
io_schedule();
514+
has_sleeper = false;
513515
} while (1);
514516

515517
__set_current_state(TASK_RUNNING);

0 commit comments

Comments
 (0)