Commit 6ac93117 authored by Omar Sandoval's avatar Omar Sandoval Committed by Jens Axboe

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: 07e4fead ("blk-mq: create debugfs directory tree")
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 62ebce16
...@@ -470,12 +470,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, ...@@ -470,12 +470,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
if (!blk_debugfs_root) if (!blk_debugfs_root)
goto err; goto err;
dir = debugfs_create_dir(buts->name, blk_debugfs_root); dir = debugfs_lookup(buts->name, blk_debugfs_root);
if (!dir)
bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);
if (!dir) if (!dir)
goto err; goto err;
bt->dir = dir;
bt->dev = dev; bt->dev = dev;
atomic_set(&bt->dropped, 0); atomic_set(&bt->dropped, 0);
INIT_LIST_HEAD(&bt->running_list); 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, ...@@ -517,9 +517,12 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
if (atomic_inc_return(&blk_probes_ref) == 1) if (atomic_inc_return(&blk_probes_ref) == 1)
blk_register_tracepoints(); blk_register_tracepoints();
return 0; ret = 0;
err: err:
blk_trace_free(bt); if (dir && !bt->dir)
dput(dir);
if (ret)
blk_trace_free(bt);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment