dm raid: support to change bitmap region size
authorHeinz Mauelshagen <heinzm@redhat.com>
Mon, 13 Jun 2016 23:46:03 +0000 (01:46 +0200)
committerMike Snitzer <snitzer@redhat.com>
Tue, 14 Jun 2016 22:52:13 +0000 (18:52 -0400)
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-raid.c

index e4c41232107f5004384d0495944d0308a06ef1c2..7df4508774233a5d43fc60e587727020c3365037 100644 (file)
@@ -217,6 +217,7 @@ struct raid_set {
        int delta_disks;
        int data_offset;
        int raid10_copies;
+       int requested_bitmap_chunk_sectors;
 
        struct mddev md;
        struct raid_type *raid_type;
@@ -1277,6 +1278,7 @@ static int parse_raid_params(struct raid_set *rs, struct dm_arg_set *as,
                        }
 
                        region_size = value;
+                       rs->requested_bitmap_chunk_sectors = value;
                } else if (!strcasecmp(key, dm_raid_arg_name_by_flag(CTR_FLAG_RAID10_COPIES))) {
                        if (test_and_set_bit(__CTR_FLAG_RAID10_COPIES, &rs->ctr_flags)) {
                                rs->ti->error = "Only one raid10_copies argument pair allowed";
@@ -3401,6 +3403,15 @@ static int raid_preresume(struct dm_target *ti)
        if (r)
                return r;
 
+       /* Resize bitmap to adjust to changed region size (aka MD bitmap chunksize) */
+       if (test_bit(RT_FLAG_RS_BITMAP_LOADED, &rs->runtime_flags) &&
+           mddev->bitmap_info.chunksize != to_bytes(rs->requested_bitmap_chunk_sectors)) {
+               r = bitmap_resize(mddev->bitmap, mddev->dev_sectors,
+                                 to_bytes(rs->requested_bitmap_chunk_sectors), 0);
+               if (r)
+                       DMERR("Failed to resize bitmap");
+       }
+
        /* Check for any resize/reshape on @rs and adjust/initiate */
        /* Be prepared for mddev_resume() in raid_resume() */
        set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);