Skip to content

Commit c8e846f

Browse files
ntsironsnitm
authored andcommitted
dm era: Verify the data block size hasn't changed
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: eec4057 ("dm: add era target") Cc: [email protected] # v3.15+ Signed-off-by: Nikos Tsironis <[email protected]> Reviewed-by: Ming-Hung Tsai <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent 2524933 commit c8e846f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/md/dm-era-target.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,15 @@ static int open_metadata(struct era_metadata *md)
564564
}
565565

566566
disk = dm_block_data(sblock);
567+
568+
/* Verify the data block size hasn't changed */
569+
if (le32_to_cpu(disk->data_block_size) != md->block_size) {
570+
DMERR("changing the data block size (from %u to %llu) is not supported",
571+
le32_to_cpu(disk->data_block_size), md->block_size);
572+
r = -EINVAL;
573+
goto bad;
574+
}
575+
567576
r = dm_tm_open_with_sm(md->bm, SUPERBLOCK_LOCATION,
568577
disk->metadata_space_map_root,
569578
sizeof(disk->metadata_space_map_root),
@@ -575,7 +584,6 @@ static int open_metadata(struct era_metadata *md)
575584

576585
setup_infos(md);
577586

578-
md->block_size = le32_to_cpu(disk->data_block_size);
579587
md->nr_blocks = le32_to_cpu(disk->nr_blocks);
580588
md->current_era = le32_to_cpu(disk->current_era);
581589

0 commit comments

Comments
 (0)