]> git.hungrycats.org Git - linux/commit
blk-mq: set up a queue under tag_list_lock
authorJosef Bacik <josef@toxicpanda.com>
Wed, 28 Oct 2026 16:41:41 +0000 (10:41 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 29 Oct 2026 13:15:47 +0000 (07:15 -0600)
commit4fcc499ea9bc31b02393904a1903e794d146f5f7
treedaf05d22325ffd8a5139d14567a6139ce70053c9
parent89a2381482d8ff8e4fe0b7d32797bb4f77503b89
blk-mq: set up a queue under tag_list_lock

blk_mq_init_allocated_queue() only takes tag_list_lock at the end, when
it adds the queue to the set. Before that it sizes the queue by
set->nr_hw_queues, hands out set->tags[], maps by set->map[], and
blk_mq_map_swqueue() frees tags of the set. An update clearing the maps
at that time makes the new queue free tags that all the other queues
share. An NVMe controller reset during a namespace scan does exactly
that.

Take the lock before the first look at the set. An update can be part of
error handling, so the allocations under the lock must not wait for IO:
memalloc_noio_save(), as in add_disk_fwnode().

Fixes: 868f2f0b7206 ("blk-mq: dynamic h/w context count")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Link: https://patch.msgid.link/20261028164415.1262013-39-axboe@kernel.dk
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c