]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
block/blk-iocost: Combine two error paths in ioc_qos_write()
authorBart Van Assche <bvanassche@acm.org>
Fri, 5 Jun 2026 18:00:59 +0000 (11:00 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 5 Jun 2026 19:41:11 +0000 (13:41 -0600)
Reduce code duplication by combining two error paths. No functionality
has been changed.

Suggested-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://patch.msgid.link/80d4fc1ecd5eaf187c0a31c63a1033a7326d4c7e.1780682325.git.bvanassche@acm.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c

index 3e4e28ecc21f054eacff8d659e48ee43264d3aaf..050bfbc6d80622f219e0c693643b1381a282e919 100644 (file)
@@ -3239,7 +3239,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
        bool enable, user;
        char *body, *p;
        unsigned long memflags;
-       int ret;
+       int ret = 0;
 
        blkg_conf_init(&ctx, input);
 
@@ -3251,14 +3251,14 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
        disk = ctx.bdev->bd_disk;
        if (!queue_is_mq(disk->queue)) {
                ret = -EOPNOTSUPP;
-               goto err;
+               goto close_bdev;
        }
 
        ioc = q_to_ioc(disk->queue);
        if (!ioc) {
                ret = blk_iocost_init(disk);
                if (ret)
-                       goto err;
+                       goto close_bdev;
                ioc = q_to_ioc(disk->queue);
        }
 
@@ -3362,15 +3362,15 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input,
 
        blk_mq_unquiesce_queue(disk->queue);
 
+close_bdev:
        blkg_conf_close_bdev_frozen(&ctx, memflags);
-       return nbytes;
+       return ret ?: nbytes;
+
 einval:
        spin_unlock_irq(&ioc->lock);
        blk_mq_unquiesce_queue(disk->queue);
        ret = -EINVAL;
-err:
-       blkg_conf_close_bdev_frozen(&ctx, memflags);
-       return ret;
+       goto close_bdev;
 }
 
 static u64 ioc_cost_model_prfill(struct seq_file *sf,