Commit 9134f0c1 authored by Saravanan D's avatar Saravanan D Committed by Yu Kuai
Browse files

blk-mq: Fix spurious debugfs directory creation during initialization

mainline inclusion
from mainline-v5.13-rc1
commit 1e91e28e
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAGRKP
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1e91e28e374d0b0b912154c192716374609360d9



--------------------------------

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: default avatarSaravanan D <saravanand@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
parent 17ab4994
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -953,6 +953,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;