]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
md/raid0: use the atomic queue limit update APIs
authorChristoph Hellwig <hch@lst.de>
Sun, 3 Mar 2024 14:01:44 +0000 (07:01 -0700)
committerSong Liu <song@kernel.org>
Wed, 6 Mar 2024 16:59:53 +0000 (08:59 -0800)
Build the queue limits outside the queue and apply them using
queue_limits_set.  To make the code more obvious also split the queue
limits handling into a separate helper function.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed--by: Song Liu <song@kernel.org>
Tested-by: Song Liu <song@kernel.org>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20240303140150.5435-6-hch@lst.de
drivers/md/raid0.c

index 9f787ae77ede887611d6cdb8071936c9ec800acf..f65aa6ecec0482e0969ff7d158e4bd52656d4af7 100644 (file)
@@ -379,6 +379,19 @@ static void raid0_free(struct mddev *mddev, void *priv)
        free_conf(mddev, conf);
 }
 
+static int raid0_set_limits(struct mddev *mddev)
+{
+       struct queue_limits lim;
+
+       blk_set_stacking_limits(&lim);
+       lim.max_hw_sectors = mddev->chunk_sectors;
+       lim.max_write_zeroes_sectors = mddev->chunk_sectors;
+       lim.io_min = mddev->chunk_sectors << 9;
+       lim.io_opt = lim.io_min * mddev->raid_disks;
+       mddev_stack_rdev_limits(mddev, &lim);
+       return queue_limits_set(mddev->queue, &lim);
+}
+
 static int raid0_run(struct mddev *mddev)
 {
        struct r0conf *conf;
@@ -400,19 +413,9 @@ static int raid0_run(struct mddev *mddev)
        }
        conf = mddev->private;
        if (!mddev_is_dm(mddev)) {
-               struct md_rdev *rdev;
-
-               blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
-               blk_queue_max_write_zeroes_sectors(mddev->queue, mddev->chunk_sectors);
-
-               blk_queue_io_min(mddev->queue, mddev->chunk_sectors << 9);
-               blk_queue_io_opt(mddev->queue,
-                                (mddev->chunk_sectors << 9) * mddev->raid_disks);
-
-               rdev_for_each(rdev, mddev) {
-                       disk_stack_limits(mddev->gendisk, rdev->bdev,
-                                         rdev->data_offset << 9);
-               }
+               ret = raid0_set_limits(mddev);
+               if (ret)
+                       goto out_free_conf;
        }
 
        /* calculate array device size */
@@ -426,8 +429,10 @@ static int raid0_run(struct mddev *mddev)
 
        ret = md_integrity_register(mddev);
        if (ret)
-               free_conf(mddev, conf);
-
+               goto out_free_conf;
+       return 0;
+out_free_conf:
+       free_conf(mddev, conf);
        return ret;
 }