Re: [PATCH] block: remove per-disk debugfs files in blk_unregister_queue

Christoph Hellwig
2022-05-27T07:15:51Z

On Tue, May 24, 2022 at 10:44:44PM +0800, Ming Lei wrote:
> The above line code may cause kernel panic in the following code paths:
>
> 1) blk_mq_debugfs_unregister_hctxs() called from __blk_mq_update_nr_hw_queues()
>
> 2) blk_mq_debugfs_unregister_sched_hctx() called from blk_mq_exit_sched()

Yes. Then again we already have the same sort of race window in reverse
at startup time, where nothing synchronizes between
blk_mq_debugfs_register_hctxs from __blk_mq_update_nr_hw_queues and
add_disk adding debugfs files.

All this probably needs serializing using debugfs_mutex and a check of
QUEUE_FLAG_REGISTERED.