]> www.infradead.org Git - users/hch/misc.git/commitdiff
md/dm-raid: check before referencing mddev->bitmap_ops
authorYu Kuai <yukuai3@huawei.com>
Mon, 7 Jul 2025 01:27:09 +0000 (09:27 +0800)
committerYu Kuai <yukuai3@huawei.com>
Sat, 6 Sep 2025 09:12:15 +0000 (17:12 +0800)
Prepare to introduce CONFIG_MD_BITMAP.

Link: https://lore.kernel.org/linux-raid/20250707012711.376844-14-yukuai1@huaweicloud.com
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
drivers/md/dm-raid.c

index 05811316dedde692c28ac2870475b8eb01794246..967d72929909cc2b9857834d987fc1afc59107d5 100644 (file)
@@ -3953,9 +3953,11 @@ static int __load_dirty_region_bitmap(struct raid_set *rs)
            !test_and_set_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags)) {
                struct mddev *mddev = &rs->md;
 
-               r = mddev->bitmap_ops->load(mddev);
-               if (r)
-                       DMERR("Failed to load bitmap");
+               if (md_bitmap_enabled(mddev, false)) {
+                       r = mddev->bitmap_ops->load(mddev);
+                       if (r)
+                               DMERR("Failed to load bitmap");
+               }
        }
 
        return r;
@@ -4070,10 +4072,12 @@ static int raid_preresume(struct dm_target *ti)
               mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)))) {
                int chunksize = to_bytes(rs->requested_bitmap_chunk_sectors) ?: mddev->bitmap_info.chunksize;
 
-               r = mddev->bitmap_ops->resize(mddev, mddev->dev_sectors,
-                                             chunksize);
-               if (r)
-                       DMERR("Failed to resize bitmap");
+               if (md_bitmap_enabled(mddev, false)) {
+                       r = mddev->bitmap_ops->resize(mddev, mddev->dev_sectors,
+                                                     chunksize);
+                       if (r)
+                               DMERR("Failed to resize bitmap");
+               }
        }
 
        /* Check for any resize/reshape on @rs and adjust/initiate */