Skip to content

Commit 9aec862

Browse files
committed
dm thin metadata: do not allow the data block size to change
The block size for the thin-pool's data device must remained fixed for the life of the thin-pool. Disallow any attempt to change the thin-pool's data block size. It should be noted that attempting to change the data block size via thin-pool table reload will be ignored as a side-effect of the thin-pool handover that the thin-pool target does during thin-pool table reload. Here is an example outcome of attempting to load a thin-pool table that reduced the thin-pool's data block size from 1024K to 512K. Before: kernel: device-mapper: thin: 253:4: growing the data device from 204800 to 409600 blocks After: kernel: device-mapper: thin metadata: changing the data block size (from 2048 to 1024) is not supported kernel: device-mapper: table: 253:4: thin-pool: Error creating metadata object kernel: device-mapper: ioctl: error adding target to table Signed-off-by: Mike Snitzer <snitzer@redhat.com> Acked-by: Joe Thornber <ejt@redhat.com> Cc: stable@vger.kernel.org
1 parent 7a7a3b4 commit 9aec862

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/md/dm-thin-metadata.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,15 @@ static int __open_metadata(struct dm_pool_metadata *pmd)
613613

614614
disk_super = dm_block_data(sblock);
615615

616+
/* Verify the data block size hasn't changed */
617+
if (le32_to_cpu(disk_super->data_block_size) != pmd->data_block_size) {
618+
DMERR("changing the data block size (from %u to %llu) is not supported",
619+
le32_to_cpu(disk_super->data_block_size),
620+
(unsigned long long)pmd->data_block_size);
621+
r = -EINVAL;
622+
goto bad_unlock_sblock;
623+
}
624+
616625
r = __check_incompat_features(disk_super, pmd);
617626
if (r < 0)
618627
goto bad_unlock_sblock;

0 commit comments

Comments
 (0)