]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
md: factor out a helper raid_is_456()
authorYu Kuai <yukuai3@huawei.com>
Fri, 29 Aug 2025 08:04:17 +0000 (16:04 +0800)
committerYu Kuai <yukuai3@huawei.com>
Sat, 6 Sep 2025 09:17:58 +0000 (17:17 +0800)
There are no functional changes, the helper will be used by llbitmap in
following patches.

Link: https://lore.kernel.org/linux-raid/20250829080426.1441678-3-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Li Nan <linan122@huawei.com>
drivers/md/md.c
drivers/md/md.h

index 528c993964580a87c1fc60f69dd0b8fc5bd4a4f8..4bc35362f4d0ad6ccca3661f09ac6362f1de67fc 100644 (file)
@@ -9121,19 +9121,12 @@ static sector_t md_sync_position(struct mddev *mddev, enum sync_action action)
 
 static bool sync_io_within_limit(struct mddev *mddev)
 {
-       int io_sectors;
-
        /*
         * For raid456, sync IO is stripe(4k) per IO, for other levels, it's
         * RESYNC_PAGES(64k) per IO.
         */
-       if (mddev->level == 4 || mddev->level == 5 || mddev->level == 6)
-               io_sectors = 8;
-       else
-               io_sectors = 128;
-
        return atomic_read(&mddev->recovery_active) <
-               io_sectors * sync_io_depth(mddev);
+              (raid_is_456(mddev) ? 8 : 128) * sync_io_depth(mddev);
 }
 
 #define SYNC_MARKS     10
index cadd9bc99938e544aebe76fb511e649643508a96..5ef73109d14d9fa56a7f4d5ef078de93b8e16b89 100644 (file)
@@ -1033,6 +1033,12 @@ static inline bool mddev_is_dm(struct mddev *mddev)
        return !mddev->gendisk;
 }
 
+static inline bool raid_is_456(struct mddev *mddev)
+{
+       return mddev->level == ID_RAID4 || mddev->level == ID_RAID5 ||
+              mddev->level == ID_RAID6;
+}
+
 static inline void mddev_trace_remap(struct mddev *mddev, struct bio *bio,
                sector_t sector)
 {