Skip to content

Commit

Permalink
blk-wbt: fix has-sleeper queueing check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
axboe committed Aug 22, 2018
1 parent b788209 commit c45e6a0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions block/blk-wbt.c
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,17 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
{
struct rq_wait *rqw = get_rq_wait(rwb, wb_acct);
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) {
Expand All @@ -510,6 +511,7 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
spin_lock_irq(lock);
} else
io_schedule();
has_sleeper = false;
} while (1);

__set_current_state(TASK_RUNNING);
Expand Down

0 comments on commit c45e6a0

Please sign in to comment.