From: Ming Lei <ming.lei@xxxxxxxxxx> commit 357e1b7f730bd85a383e7afa75a3caba329c5707 upstream. elevator_init_mq() is only called at the entry of add_disk_fwnode() when disk IO isn't allowed yet. So not verify io lock(q->io_lockdep_map) for freeze & unfreeze in elevator_init_mq(). Reported-by: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx> Reported-by: Lai Yi <yi1.lai@xxxxxxxxxxxxxxx> Fixes: f1be1788a32e ("block: model freeze & enter queue as lock for supporting lockdep") Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> Link: https://lore.kernel.org/r/20241031133723.303835-5-ming.lei@xxxxxxxxxx Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- block/elevator.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/block/elevator.c +++ b/block/elevator.c @@ -598,13 +598,19 @@ void elevator_init_mq(struct request_que * drain any dispatch activities originated from passthrough * requests, then no need to quiesce queue which may add long boot * latency, especially when lots of disks are involved. + * + * Disk isn't added yet, so verifying queue lock only manually. */ - blk_mq_freeze_queue(q); + blk_freeze_queue_start_non_owner(q); + blk_freeze_acquire_lock(q, true, false); + blk_mq_freeze_queue_wait(q); + blk_mq_cancel_work_sync(q); err = blk_mq_init_sched(q, e); - blk_mq_unfreeze_queue(q); + blk_unfreeze_release_lock(q, true, false); + blk_mq_unfreeze_queue_non_owner(q); if (err) { pr_warn("\"%s\" elevator initialization failed, " Patches currently in stable-queue which might be from ming.lei@xxxxxxxxxx are queue-6.12/block-fix-ordering-between-checking-queue_flag_quiesced-request-adding.patch queue-6.12/block-fix-missing-dispatching-request-when-queue-is-started-or-unquiesced.patch queue-6.12/blk-mq-add-non_owner-variant-of-start_freeze-unfreez.patch queue-6.12/brd-decrease-the-number-of-allocated-pages-which-dis.patch queue-6.12/block-fix-ordering-between-checking-blk_mq_s_stopped-request-adding.patch queue-6.12/block-don-t-verify-io-lock-for-freeze-unfreeze-in-elevator_init_mq.patch queue-6.12/nvme-fabrics-fix-kernel-crash-while-shutting-down-co.patch queue-6.12/block-always-verify-unfreeze-lock-on-the-owner-task.patch queue-6.12/block-fix-uaf-for-flush-rq-while-iterating-tags.patch queue-6.12/ublk-fix-error-code-for-unsupported-command.patch queue-6.12/ublk-fix-ublk_ch_mmap-for-64k-page-size.patch queue-6.12/blk-mq-make-blk_mq_quiesce_tagset-hold-the-tag-list-mutex-less-long.patch queue-6.12/loop-fix-type-of-block-size.patch queue-6.12/block-model-freeze-enter-queue-as-lock-for-supportin.patch