Skip to content

Commit c25c0c9

Browse files
Ming Leiaxboe
Ming Lei
authored andcommitted
blk-mq: setup queue ->tag_set before initializing hctx
Commit 7b81581 ("blk-mq: add helper for checking if one CPU is mapped to specified hctx") needs to check queue mapping via tag set in hctx's cpuhp handler. However, q->tag_set may not be setup yet when the cpuhp handler is enabled, then kernel oops is triggered. Fix the issue by setup queue tag_set before initializing hctx. Cc: [email protected] Reported-and-tested-by: Rick Koch <[email protected]> Closes: https://lore.kernel.org/linux-block/CANa58eeNDozLaBHKPLxSAhEy__FPfJT_F71W=sEQw49UCrC9PQ@mail.gmail.com Fixes: 7b81581 ("blk-mq: add helper for checking if one CPU is mapped to specified hctx") Signed-off-by: Ming Lei <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ee7ff15 commit c25c0c9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

block/blk-mq.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -4310,6 +4310,12 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
43104310
/* mark the queue as mq asap */
43114311
q->mq_ops = set->ops;
43124312

4313+
/*
4314+
* ->tag_set has to be setup before initialize hctx, which cpuphp
4315+
* handler needs it for checking queue mapping
4316+
*/
4317+
q->tag_set = set;
4318+
43134319
if (blk_mq_alloc_ctxs(q))
43144320
goto err_exit;
43154321

@@ -4328,8 +4334,6 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
43284334
INIT_WORK(&q->timeout_work, blk_mq_timeout_work);
43294335
blk_queue_rq_timeout(q, set->timeout ? set->timeout : 30 * HZ);
43304336

4331-
q->tag_set = set;
4332-
43334337
q->queue_flags |= QUEUE_FLAG_MQ_DEFAULT;
43344338

43354339
INIT_DELAYED_WORK(&q->requeue_work, blk_mq_requeue_work);

0 commit comments

Comments
 (0)