diff mbox series

blk-mq: Fix spurious debugfs directory creation during initialization

Message ID 20210407175958.4129976-1-saravanand@fb.com (mailing list archive)
State New, archived
Headers show
Series blk-mq: Fix spurious debugfs directory creation during initialization | expand

Commit Message

Saravanan D April 7, 2021, 5:59 p.m. UTC
blk_mq_debugfs_register_sched_hctx() called from
device_add_disk()->elevator_init_mq()->blk_mq_init_sched()
initialization sequence does not have relevant parent directory
setup and thus spuriously attempts "sched" directory creation
from root mount of debugfs for every hw queue detected on the
block device

dmesg
...
debugfs: Directory 'sched' with parent '/' already present!
debugfs: Directory 'sched' with parent '/' already present!
.
.
debugfs: Directory 'sched' with parent '/' already present!
...

The parent debugfs directory for hw queues get properly setup
device_add_disk()->blk_register_queue()->blk_mq_debugfs_register()
->blk_mq_debugfs_register_hctx() later in the block device
initialization sequence.

A simple check for debugfs_dir has been added to thwart premature
debugfs directory/file creation attempts.

Signed-off-by: Saravanan D <saravanand@fb.com>
---
 block/blk-mq-debugfs.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jens Axboe April 16, 2021, 9:17 p.m. UTC | #1
On 4/7/21 11:59 AM, Saravanan D wrote:
> blk_mq_debugfs_register_sched_hctx() called from
> device_add_disk()->elevator_init_mq()->blk_mq_init_sched()
> initialization sequence does not have relevant parent directory
> setup and thus spuriously attempts "sched" directory creation
> from root mount of debugfs for every hw queue detected on the
> block device
> 
> dmesg
> ...
> debugfs: Directory 'sched' with parent '/' already present!
> debugfs: Directory 'sched' with parent '/' already present!
> .
> .
> debugfs: Directory 'sched' with parent '/' already present!
> ...
> 
> The parent debugfs directory for hw queues get properly setup
> device_add_disk()->blk_register_queue()->blk_mq_debugfs_register()
> ->blk_mq_debugfs_register_hctx() later in the block device
> initialization sequence.
> 
> A simple check for debugfs_dir has been added to thwart premature
> debugfs directory/file creation attempts.

Applied, thanks.
diff mbox series

Patch

diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c
index 271f6596435b..2a75bc7401df 100644
--- a/block/blk-mq-debugfs.c
+++ b/block/blk-mq-debugfs.c
@@ -972,6 +972,14 @@  void blk_mq_debugfs_register_sched_hctx(struct request_queue *q,
 {
 	struct elevator_type *e = q->elevator->type;
 
+	/*
+	 * If the parent debugfs directory has not been created yet, return;
+	 * We will be called again later on with appropriate parent debugfs
+	 * directory from blk_register_queue()
+	 */
+	if (!hctx->debugfs_dir)
+		return;
+
 	if (!e->hctx_debugfs_attrs)
 		return;