Skip to content
This repository was archived by the owner on Oct 30, 2021. It is now read-only.

Commit 6ac9311

Browse files
osandovaxboe
authored andcommitted
blktrace: use existing disk debugfs directory
We may already have a directory to put the blktrace stuff in if 1. The disk uses blk-mq 2. CONFIG_BLK_DEBUG_FS is enabled 3. We are tracing the whole disk and not a partition Instead of hardcoding this very specific case, let's use the new debugfs_lookup(). If the directory exists, we use it, otherwise we create one and clean it up later. Fixes: 07e4fea ("blk-mq: create debugfs directory tree") Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: Jens Axboe <axboe@fb.com>
1 parent 62ebce1 commit 6ac9311

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/trace/blktrace.c

+8-5
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
470470
if (!blk_debugfs_root)
471471
goto err;
472472

473-
dir = debugfs_create_dir(buts->name, blk_debugfs_root);
474-
473+
dir = debugfs_lookup(buts->name, blk_debugfs_root);
474+
if (!dir)
475+
bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
475476
if (!dir)
476477
goto err;
477478

478-
bt->dir = dir;
479479
bt->dev = dev;
480480
atomic_set(&bt->dropped, 0);
481481
INIT_LIST_HEAD(&bt->running_list);
@@ -517,9 +517,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
517517
if (atomic_inc_return(&blk_probes_ref) == 1)
518518
blk_register_tracepoints();
519519

520-
return 0;
520+
ret = 0;
521521
err:
522-
blk_trace_free(bt);
522+
if (dir && !bt->dir)
523+
dput(dir);
524+
if (ret)
525+
blk_trace_free(bt);
523526
return ret;
524527
}
525528

0 commit comments

Comments
 (0)