Skip to content

Commit db599f9

Browse files
Algodev-githubaxboe
authored andcommitted
block, bfq: fix rq_in_driver check in bfq_update_inject_limit
One of the cases where the parameters for injection may be updated is when there are no more in-flight I/O requests. The number of in-flight requests is stored in the field bfqd->rq_in_driver of the descriptor bfqd of the device. So, the controlled condition is bfqd->rq_in_driver == 0. Unfortunately, this is wrong because, the instruction that checks this condition is in the code path that handles the completion of a request, and, in particular, the instruction is executed before bfqd->rq_in_driver is decremented in such a code path. This commit fixes this issue by just replacing 0 with 1 in the comparison. Reported-by: Srivatsa S. Bhat (VMware) <[email protected]> Tested-by: Srivatsa S. Bhat (VMware) <[email protected]> Signed-off-by: Paolo Valente <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 766d614 commit db599f9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

block/bfq-iosched.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5481,8 +5481,14 @@ static void bfq_update_inject_limit(struct bfq_data *bfqd,
54815481
* total service time, and there seem to be the right
54825482
* conditions to do it, or we can lower the last base value
54835483
* computed.
5484+
*
5485+
* NOTE: (bfqd->rq_in_driver == 1) means that there is no I/O
5486+
* request in flight, because this function is in the code
5487+
* path that handles the completion of a request of bfqq, and,
5488+
* in particular, this function is executed before
5489+
* bfqd->rq_in_driver is decremented in such a code path.
54845490
*/
5485-
if ((bfqq->last_serv_time_ns == 0 && bfqd->rq_in_driver == 0) ||
5491+
if ((bfqq->last_serv_time_ns == 0 && bfqd->rq_in_driver == 1) ||
54865492
tot_time_ns < bfqq->last_serv_time_ns) {
54875493
bfqq->last_serv_time_ns = tot_time_ns;
54885494
/*

0 commit comments

Comments
 (0)