md/dm-raid: check before referencing mddev->bitmap_ops

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>
This commit is contained in:
Yu Kuai
2025-07-07 09:27:09 +08:00
parent bb9317b13a
commit 0e18745420

View 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 */