Skip to content

Commit ffa358d

Browse files
committed
blk-wbt: move disable check into get_limit()
Check it in one place, instead of in multiple places. Tested-by: Anchal Agarwal <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3943b04 commit ffa358d

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

block/blk-wbt.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,13 @@ static inline unsigned int get_limit(struct rq_wb *rwb, unsigned long rw)
449449
{
450450
unsigned int limit;
451451

452+
/*
453+
* If we got disabled, just return UINT_MAX. This ensures that
454+
* we'll properly inc a new IO, and dec+wakeup at the end.
455+
*/
456+
if (!rwb_enabled(rwb))
457+
return UINT_MAX;
458+
452459
if ((rw & REQ_OP_MASK) == REQ_OP_DISCARD)
453460
return rwb->wb_background;
454461

@@ -486,16 +493,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
486493
struct rq_wait *rqw = get_rq_wait(rwb, wb_acct);
487494
DECLARE_WAITQUEUE(wait, current);
488495

489-
/*
490-
* inc it here even if disabled, since we'll dec it at completion.
491-
* this only happens if the task was sleeping in __wbt_wait(),
492-
* and someone turned it off at the same time.
493-
*/
494-
if (!rwb_enabled(rwb)) {
495-
atomic_inc(&rqw->inflight);
496-
return;
497-
}
498-
499496
if (!waitqueue_active(&rqw->wait)
500497
&& rq_wait_inc_below(rqw, get_limit(rwb, rw)))
501498
return;
@@ -504,11 +501,6 @@ static void __wbt_wait(struct rq_wb *rwb, enum wbt_flags wb_acct,
504501
do {
505502
set_current_state(TASK_UNINTERRUPTIBLE);
506503

507-
if (!rwb_enabled(rwb)) {
508-
atomic_inc(&rqw->inflight);
509-
break;
510-
}
511-
512504
if (rq_wait_inc_below(rqw, get_limit(rwb, rw)))
513505
break;
514506

0 commit comments

Comments
 (0)