public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/4] blk-mq/nvme: fix debugfs creation with frozen queue
@ 2026-02-09  8:29 Yu Kuai
  2026-02-09  8:29 ` [PATCH 1/4] nvme-rdma: move blk_mq_update_nr_hw_queues after nvme_unfreeze Yu Kuai
                   ` (3 more replies)
  0 siblings, 4 replies; 29+ messages in thread
From: Yu Kuai @ 2026-02-09  8:29 UTC (permalink / raw)
  To: axboe, kbusch, hch, sagi, sven, j, linux-block, linux-nvme
  Cc: tj, nilay, ming.lei, neal, asahi, linux-arm-kernel, yukuai

blk_mq_update_nr_hw_queues() freezes and unfreezes queues internally.
When callers pre-freeze the queue before calling this function, the
freeze depth becomes 2. The internal unfreeze only decrements it to 1,
leaving the queue still frozen when debugfs_create_files() is called.

This triggers WARN_ON_ONCE(q->mq_freeze_depth != 0) in
debugfs_create_files() and risks deadlock.

Patch 1-3 fix nvme drivers by moving nvme_unfreeze() before
blk_mq_update_nr_hw_queues() so the queue is unfrozen before the call.

Patch 4 fixes the block layer debugfs_create_files() itself. I checked
all callers of debugfs_create_files():

  - blk_mq_debugfs_register() from blk_register_queue(): queue not frozen
  - blk_mq_debugfs_register_hctx() from blk_mq_debugfs_register_hctxs():
    called after blk_mq_elv_switch_back() which unfreezes the queue
  - blk_mq_debugfs_register_sched() from elv_register_queue():
    called after blk_mq_unfreeze_queue()
  - blk_mq_debugfs_register_rqos() from wbt paths:
    called after blk_mq_unfreeze_queue()

All callers have the queue unfrozen. However, the queue can be frozen
from another context at any time, so the WARN_ON_ONCE check is racy.
Replace it with blk_queue_enter()/blk_queue_exit() which properly waits
for the queue to be unfrozen and prevents new freezes while creating
debugfs files.

Yu Kuai (4):
  nvme-rdma: move blk_mq_update_nr_hw_queues after nvme_unfreeze
  nvme-tcp: move blk_mq_update_nr_hw_queues after nvme_unfreeze
  nvme-apple: move blk_mq_update_nr_hw_queues after nvme_unfreeze
  blk-mq: use blk_queue_enter/exit to protect debugfs file creation

 block/blk-mq-debugfs.c    | 15 ++++++++++-----
 drivers/nvme/host/apple.c |  2 +-
 drivers/nvme/host/rdma.c  |  2 +-
 drivers/nvme/host/tcp.c   |  2 +-
 4 files changed, 13 insertions(+), 8 deletions(-)

--
2.51.0


^ permalink raw reply	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2026-02-11 12:57 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-09  8:29 [PATCH 0/4] blk-mq/nvme: fix debugfs creation with frozen queue Yu Kuai
2026-02-09  8:29 ` [PATCH 1/4] nvme-rdma: move blk_mq_update_nr_hw_queues after nvme_unfreeze Yu Kuai
2026-02-09 14:57   ` Christoph Hellwig
2026-02-11  7:21   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 2/4] nvme-tcp: " Yu Kuai
2026-02-09 14:57   ` Christoph Hellwig
2026-02-11  7:22   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 3/4] nvme-apple: " Yu Kuai
2026-02-09 14:58   ` Christoph Hellwig
2026-02-09 15:35     ` Keith Busch
2026-02-10  6:47       ` Yu Kuai
2026-02-10 15:09         ` Keith Busch
2026-02-10 15:41           ` Christoph Hellwig
2026-02-10 16:01             ` Keith Busch
2026-02-10 16:28               ` Daniel Wagner
2026-02-11  1:57                 ` Yu Kuai
2026-02-11 12:57                   ` Keith Busch
2026-02-10  8:10       ` Nilay Shroff
2026-02-10 15:12         ` Keith Busch
2026-02-11  7:23   ` Nilay Shroff
2026-02-09  8:29 ` [PATCH 4/4] blk-mq: use blk_queue_enter/exit to protect debugfs file creation Yu Kuai
2026-02-09 14:59   ` Christoph Hellwig
2026-02-09 16:40   ` Bart Van Assche
2026-02-09 17:33     ` Keith Busch
2026-02-09 17:51       ` Bart Van Assche
2026-02-10  6:59         ` Yu Kuai
2026-02-10 15:41       ` Christoph Hellwig
2026-02-11  7:20   ` Nilay Shroff
2026-02-11  8:06     ` Yu Kuai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox