Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block, bfq: correctly raise inject limit in bfq_choose_bfqq_for_injection

Function bfq_choose_bfqq_for_injection may temporarily raise inject limit
to one request if current inject_limit is 0 before search of the source
queue for injection. However the search below will reset inject limit to
bfqd->in_service_queue which is zero for raised inject limit. Then the
temporarily raised inject limit never works as expected.
Assigment limit to bfqd->in_service_queue in search is needed as limit
maybe overwriten to min_t(unsigned int, 1, limit) for condition that
a large in-flight request is on non-rotational devices in found queue.
So we need to reset limit to bfqd->in_service_queue for normal case.

Actually, we have already make sure bfqd->rq_in_driver is < limit before
search, then
-Limit is >= 1 as bfqd->rq_in_driver is >= 0. Then min_t(unsigned int,
1, limit) is always 1. So we can simply check bfqd->rq_in_driver with
1 instead of result of min_t(unsigned int, 1, limit) for larget request in
non-rotational device case to avoid overwritting limit and the bug is gone.
-For normal case, we have already check bfqd->rq_in_driver is < limit,
so we can return found bfqq unconditionally to remove unncessary check.

Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230116095153.3810101-2-shikemeng@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Kemeng Shi and committed by
Jens Axboe
0c3e09e8 b5fcf787

+4 -6
+4 -6
block/bfq-iosched.c
··· 4730 4730 */ 4731 4731 if (blk_queue_nonrot(bfqd->queue) && 4732 4732 blk_rq_sectors(bfqq->next_rq) >= 4733 - BFQQ_SECT_THR_NONROT) 4734 - limit = min_t(unsigned int, 1, limit); 4735 - else 4736 - limit = in_serv_bfqq->inject_limit; 4737 - 4738 - if (bfqd->tot_rq_in_driver < limit) { 4733 + BFQQ_SECT_THR_NONROT && 4734 + bfqd->tot_rq_in_driver >= 1) 4735 + continue; 4736 + else { 4739 4737 bfqd->rqs_injected = true; 4740 4738 return bfqq; 4741 4739 }