Skip to content

Commit 7222657

Browse files
Chengming Zhouaxboe
authored andcommitted
blk-mq: prealloc tags when increase tagset nr_hw_queues
Just like blk_mq_alloc_tag_set(), it's better to prepare all tags before using to map to queue ctxs in blk_mq_map_swqueue(), which now have to consider empty set->tags[]. The good point is that we can fallback easily if increasing nr_hw_queues fail, instead of just mapping to hctx[0] when fail in blk_mq_map_swqueue(). And the fallback path already has tags free & clean handling, so all is good. Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20230821095602.70742-3-chengming.zhou@linux.dev Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2bc4d7a commit 7222657

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

block/blk-mq.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4397,6 +4397,16 @@ static int blk_mq_realloc_tag_set_tags(struct blk_mq_tag_set *set,
43974397
sizeof(*set->tags));
43984398
kfree(set->tags);
43994399
set->tags = new_tags;
4400+
4401+
for (i = set->nr_hw_queues; i < new_nr_hw_queues; i++) {
4402+
if (!__blk_mq_alloc_map_and_rqs(set, i)) {
4403+
while (--i >= set->nr_hw_queues)
4404+
__blk_mq_free_map_and_rqs(set, i);
4405+
return -ENOMEM;
4406+
}
4407+
cond_resched();
4408+
}
4409+
44004410
done:
44014411
set->nr_hw_queues = new_nr_hw_queues;
44024412
return 0;

0 commit comments

Comments
 (0)