Blktrace: bail out early if block debugfs is not configured
authorLiu Bo <bo.liu@linux.alibaba.com>
Fri, 29 Jun 2018 01:56:08 +0000 (09:56 +0800)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Jul 2018 15:07:52 +0000 (09:07 -0600)
Since @blk_debugfs_root couldn't be configured dynamically, we can
save a few memory allocation if it's not there.

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
kernel/trace/blktrace.c

index 987d9a9ae2839a2daefdd5c2d24ffe9c6d440bde..b951aa1fac6177cbed5e7a8d19de6a938bc2c241 100644 (file)
@@ -494,6 +494,9 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
        if (!buts->buf_size || !buts->buf_nr)
                return -EINVAL;
 
+       if (!blk_debugfs_root)
+               return -ENOENT;
+
        strncpy(buts->name, name, BLKTRACE_BDEV_SIZE);
        buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0';
 
@@ -518,9 +521,6 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
 
        ret = -ENOENT;
 
-       if (!blk_debugfs_root)
-               goto err;
-
        dir = debugfs_lookup(buts->name, blk_debugfs_root);
        if (!dir)
                bt->dir = dir = debugfs_create_dir(buts->name, blk_debugfs_root);