]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 09:29:02 +0000 (10:29 +0100)
commit e1a413245a564683697a3d02ec197b72cf009b89 upstream.

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>
[bwh: Cherry-picked for 4.14 to ease backporting a later fix]
Signed-off-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/trace/blktrace.c

index 987daf9cc6e54d929813b5ad963766cf6b9da813..38e0b97eede69cbf8af82d7d442ab899ab35c55e 100644 (file)
@@ -498,6 +498,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';
 
@@ -532,9 +535,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);