Re: [PATCH 4/4] blk-mq: use blk_queue_enter/exit to protect debugfs file creation
From: Bart Van Assche <bvanassche@acm.org>
Date: 2026-02-09 16:40:43
Also in:
asahi, linux-block, linux-nvme
From: Bart Van Assche <bvanassche@acm.org>
Date: 2026-02-09 16:40:43
Also in:
asahi, linux-block, linux-nvme
On 2/9/26 12:29 AM, Yu Kuai wrote:
diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index faeaa1fc86a7..03583d0d3972 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c@@ -613,11 +613,6 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent, const struct blk_mq_debugfs_attr *attr) { lockdep_assert_held(&q->debugfs_mutex); - /* - * Creating new debugfs entries with queue freezed has the risk of - * deadlock. - */ - WARN_ON_ONCE(q->mq_freeze_depth != 0); /* * debugfs_mutex should not be nested under other locks that can be * grabbed while queue is frozen.
The above looks fine to me.
@@ -628,9 +623,19 @@ static void debugfs_create_files(struct request_queue *q, struct dentry *parent, if (IS_ERR_OR_NULL(parent)) return; + /* + * Avoid creating debugfs files while the queue is frozen, wait for + * the queue to be unfrozen and prevent new freeze while creating + * debugfs files. + */ + if (blk_queue_enter(q, 0)) + return; + for (; attr->name; attr++) debugfs_create_file_aux(attr->name, attr->mode, parent, (void *)attr, data, &blk_mq_debugfs_fops); + + blk_queue_exit(q); }
This is not clear to me. Why are concurrent queue freezes not allowed while debugfs attributes are created? I don't see any code in debugfs that calls back into the block layer while creating debugfs attributes? Did I perhaps overlook something? Thanks, Bart.