summaryrefslogtreecommitdiff
path: root/drivers/md/dm-era-target.c
diff options
context:
space:
mode:
authorNikos Tsironis <ntsironis@arrikto.com>2021-01-22 18:25:53 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-03-04 13:38:45 +0300
commitede89488369d72be17f1e6e166ff053cc5e978af (patch)
tree317af3f6a838c3e3281a1adaba98a0057da6ddbd /drivers/md/dm-era-target.c
parente6039db4f1f1832dcba96d9feefc1bf5933dc9df (diff)
downloadlinux-ede89488369d72be17f1e6e166ff053cc5e978af.tar.xz
dm era: Verify the data block size hasn't changed
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>
Diffstat (limited to 'drivers/md/dm-era-target.c')
-rw-r--r--drivers/md/dm-era-target.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c
index 62f679faf9e7..b0c4c80c0ee3 100644
--- a/drivers/md/dm-era-target.c
+++ b/drivers/md/dm-era-target.c
@@ -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);