blk-mq: keep sharing tags fairly after a queue update

A hctx only gets BLK_MQ_F_TAG_QUEUE_SHARED from
blk_mq_add_queue_tag_set(). The hctxs blk_mq_update_nr_hw_queues()
allocates for queues that joined long ago never get it, so they aren't
counted in active_queues and hctx_may_queue() lets them take all the
tags. One NVMe namespace can starve the others after the first update.

Set the flag on the new hctxs.

Fixes: 868f2f0b72 ("blk-mq: dynamic h/w context count")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://patch.msgid.link/20261028164415.1262013-30-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Josef Bacik 2026-10-28 10:41:32 -06:00 committed by Jens Axboe
parent 2497418599
commit 620cfc7a66

View File

@ -5183,6 +5183,9 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
goto fallback;
}
blk_mq_map_swqueue(q);
/* The new hctxs don't know yet that they share their tags */
if (set->flags & BLK_MQ_F_TAG_QUEUE_SHARED)
queue_set_hctx_shared(q, true);
}
switch_back:
/* The blk_mq_elv_switch_back unfreezes queue for us. */