Skip to contentSkip to conversation

blk-mq: restore shared-tag flag after hctx reallocation

PATCH New Nirmoy Das 1 participant 1 message Oct 20

Subsystems (4)
lore
Share & tools
lore

Nirmoy Das

author
#0 lore raw

PATCH 1/1 blk-mq: restore shared-tag flag after hctx reallocation

__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")
Assisted-by LLM Specula
---
 block/blk-mq.c | 1 +
 1 file changed, 1 insertion(+)
block/blk-mq.c +1 -0
index 00b75eb95dd943a..ec3a7e5300d0e31 100644
@@ -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:
Signature · 1 line
2.43.0