]> www.infradead.org Git - users/hch/block.git/commitdiff
md/raid1: use the atomic queue limit update APIs
authorChristoph Hellwig <hch@lst.de>
Mon, 26 Feb 2024 13:41:16 +0000 (14:41 +0100)
committerChristoph Hellwig <hch@lst.de>
Mon, 26 Feb 2024 15:53:30 +0000 (10:53 -0500)
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>
drivers/md/raid1.c

index 3b1227f67a6d611172bac8f7aca1bf39966af9b3..75329ab2dbd8ded8daf9e073bfc9eaa5cc30a110 100644 (file)
@@ -1782,10 +1782,9 @@ static int raid1_add_disk(struct mddev *mddev, struct md_rdev *rdev)
        for (mirror = first; mirror <= last; mirror++) {
                p = conf->mirrors + mirror;
                if (!p->rdev) {
-                       if (!mddev_is_dm(mddev))
-                               disk_stack_limits(mddev->gendisk, rdev->bdev,
-                                                 rdev->data_offset << 9);
-
+                       err = mddev_stack_new_rdev(mddev, rdev);
+                       if (err)
+                               return err;
                        p->head_position = 0;
                        rdev->raid_disk = mirror;
                        err = 0;
@@ -3077,12 +3076,21 @@ static struct r1conf *setup_conf(struct mddev *mddev)
        return ERR_PTR(err);
 }
 
+static int raid1_set_limits(struct mddev *mddev)
+{
+       struct queue_limits lim;
+
+       blk_set_stacking_limits(&lim);
+       lim.max_write_zeroes_sectors = 0;
+       mddev_stack_rdev_limits(mddev, &lim);
+       return queue_limits_set(mddev->queue, &lim);
+}
+
 static void raid1_free(struct mddev *mddev, void *priv);
 static int raid1_run(struct mddev *mddev)
 {
        struct r1conf *conf;
        int i;
-       struct md_rdev *rdev;
        int ret;
 
        if (mddev->level != 1) {
@@ -3110,10 +3118,9 @@ static int raid1_run(struct mddev *mddev)
                return PTR_ERR(conf);
 
        if (!mddev_is_dm(mddev)) {
-               blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
-               rdev_for_each(rdev, mddev)
-                       disk_stack_limits(mddev->gendisk, rdev->bdev,
-                                         rdev->data_offset << 9);
+               ret = raid1_set_limits(mddev);
+               if (ret)
+                       goto abort;
        }
 
        mddev->degraded = 0;