Commit 0e187454 authored by Yu Kuai's avatar Yu Kuai
Browse files

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

parent bb9317b1
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -3953,10 +3953,12 @@ 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;

		if (md_bitmap_enabled(mddev, false)) {
			r = mddev->bitmap_ops->load(mddev);
			if (r)
				DMERR("Failed to load bitmap");
		}
	}

	return r;
}
@@ -4070,11 +4072,13 @@ 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;

		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 */
	if (mddev->resync_offset && mddev->resync_offset < MaxSector) {