[PATCH] blk-mq: restore shared-tag flag after hctx reallocation

Nirmoy Das nirmoyd at nvidia.com
Tue Oct 20 10:44:35 PDT 2026


__blk_mq_update_nr_hw_queues() reallocates the hctxs of queues already
on set->tag_list, so blk_mq_add_queue_tag_set() never sets
BLK_MQ_F_TAG_QUEUE_SHARED on them again. A new hctx starts without the
bit and a reused hctx keeps whatever it had when it was parked. An
NVMe/TCP controller reset goes through this path.

With the bit clear and an I/O scheduler, blk_mq_mark_tag_wait() sets
SCHED_RESTART without adding a tag waiter and relies on a completion on
the same hctx to run the queue again. If other queues on the set hold
all the driver tags, this hctx has nothing in flight. Once its
submitters block on scheduler tags, nothing runs it again and I/O
hangs.

Reapply the tag set's shared state after reallocating the hctxs, while
the queues are still frozen.

Reproduced on v7.3 in an arm64 QEMU/KVM guest with a loopback NVMe/TCP
target, four namespaces and mq-deadline. After one controller reset all
four namespaces lost TAG_QUEUE_SHARED and fio stalled. With this change
the bit survives five resets, and fio completes after a reset.

Fixes: 868f2f0b7206 ("blk-mq: dynamic h/w context count")
Reported-by: Lev <lev at zadarastorage.com>
Closes: https://lore.kernel.org/all/00cb01dd3099$c82b66c0$58823440$@zadarastorage.com/
Cc: stable at vger.kernel.org
Assisted-by: LLM Specula
Signed-off-by: Nirmoy Das <nirmoyd at nvidia.com>
---
 block/blk-mq.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 00b75eb95dd943a..ec3a7e5300d0e31 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -5188,6 +5188,7 @@ static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set,
 			set->nr_hw_queues = prev_nr_hw_queues;
 			goto fallback;
 		}
+		queue_set_hctx_shared(q, set->flags & BLK_MQ_F_TAG_QUEUE_SHARED);
 		blk_mq_map_swqueue(q);
 	}
 switch_back:
-- 
2.43.0




More information about the Linux-nvme mailing list