Skip to content

Commit

Permalink
dm era: Verify the data block size hasn't changed
Browse files Browse the repository at this point in the history
commit c8e846f 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: eec4057 ("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>
  • Loading branch information
ntsiron authored and gregkh committed Mar 4, 2021
1 parent e8a146e commit 8ca8908
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/md/dm-era-target.c
Expand Up @@ -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),
Expand All @@ -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);

Expand Down

0 comments on commit 8ca8908

Please sign in to comment.