Commit 524ce5d7 authored by Yu Kuai's avatar Yu Kuai
Browse files

blktrace: fix blktrace is disabled when CONFIG_BLK_DEBUG_FS is disabled

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/IAGRKP


CVE: NA

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

Commit 17ab4994 ("block: create the request_queue debugfs_dir on
registration") changed that "q->debugfs_dir" will always be created even
if CONFIG_BLK_DEBUG_FS is disabled, in this case create the same dir
in do_blk_trace_setup() will fail hence blktrace can't be used.

Fix the problem by always use "q->debugfs_dir" for the whole bdev, and
always create new debugfs_dir for partitions.

Fixes: 17ab4994 ("block: create the request_queue debugfs_dir on registration")
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
parent eb7a7a93
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -553,18 +553,15 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
	if (!bt->msg_data)
		goto err;

#ifdef CONFIG_BLK_DEBUG_FS
	/*
	 * When tracing whole make_request drivers (multiqueue) block devices,
	 * reuse the existing debugfs directory created by the block layer on
	 * init. For request-based block devices, all partitions block devices,
	 * When tracing the whole disk reuse the existing debugfs directory
	 * created by the block layer on init. For partitions block devices,
	 * and scsi-generic block devices we create a temporary new debugfs
	 * directory that will be removed once the trace ends.
	 */
	if (q->mq_ops && bdev && bdev == bdev->bd_contains)
	if (bdev && bdev == bdev->bd_contains)
		dir = q->debugfs_dir;
	else
#endif
		bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);

	/*