]> git.itanic.dy.fi Git - linux-stable/commitdiff
dm era: Verify the data block size hasn't changed
authorNikos Tsironis <ntsironis@arrikto.com>
Fri, 22 Jan 2021 15:25:53 +0000 (17:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Mar 2021 16:44:45 +0000 (17:44 +0100)
commit c8e846ff93d5eaa5384f6f325a1687ac5921aade upstream.

dm-era doesn't support changing the data block size of existing devices,
so check explicitly that the requested block size for a new target
matches the one stored in the metadata.

Fixes: eec40579d84873 ("dm: add era target")
Cc: stable@vger.kernel.org # v3.15+
Signed-off-by: Nikos Tsironis <ntsironis@arrikto.com>
Reviewed-by: Ming-Hung Tsai <mtsai@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-era-target.c

index 04f2638f635a29c21a28007547e750f652be6f37..5c5116b0cce5c86be87d1fd35bb50cc6a9706d9a 100644 (file)
@@ -564,6 +564,15 @@ static int open_metadata(struct era_metadata *md)
        }
 
        disk = dm_block_data(sblock);
+
+       /* Verify the data block size hasn't changed */
+       if (le32_to_cpu(disk->data_block_size) != md->block_size) {
+               DMERR("changing the data block size (from %u to %llu) is not supported",
+                     le32_to_cpu(disk->data_block_size), md->block_size);
+               r = -EINVAL;
+               goto bad;
+       }
+
        r = dm_tm_open_with_sm(md->bm, SUPERBLOCK_LOCATION,
                               disk->metadata_space_map_root,
                               sizeof(disk->metadata_space_map_root),
@@ -575,7 +584,6 @@ static int open_metadata(struct era_metadata *md)
 
        setup_infos(md);
 
-       md->block_size = le32_to_cpu(disk->data_block_size);
        md->nr_blocks = le32_to_cpu(disk->nr_blocks);
        md->current_era = le32_to_cpu(disk->current_era);