1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

vdo: extend vdo segment validation

Try to catch all suspicious VDO segments in metadata early.
This commit is contained in:
Zdenek Kabelac 2020-09-22 23:17:54 +02:00
parent 642ef54399
commit f38b7afd62

View File

@ -541,11 +541,61 @@ static void _check_lv_segment(struct logical_volume *lv, struct lv_segment *seg,
seg_error("is missing a VDO pool data LV"); seg_error("is missing a VDO pool data LV");
} else if (!lv_is_vdo_pool_data(seg_lv(seg, 0))) } else if (!lv_is_vdo_pool_data(seg_lv(seg, 0)))
seg_error("is not VDO pool data LV"); seg_error("is not VDO pool data LV");
if ((seg->vdo_params.minimum_io_size != (512 >> SECTOR_SHIFT)) &&
(seg->vdo_params.minimum_io_size != (4096 >> SECTOR_SHIFT)))
seg_error("sets unsupported VDO minimum io size");
if ((seg->vdo_params.block_map_cache_size_mb < DM_VDO_BLOCK_MAP_CACHE_SIZE_MINIMUM_MB) ||
(seg->vdo_params.block_map_cache_size_mb > DM_VDO_BLOCK_MAP_CACHE_SIZE_MAXIMUM_MB))
seg_error("sets unsupported VDO block map cache size");
if ((seg->vdo_params.block_map_era_length < DM_VDO_BLOCK_MAP_ERA_LENGTH_MINIMUM) ||
(seg->vdo_params.block_map_era_length > DM_VDO_BLOCK_MAP_ERA_LENGTH_MAXIMUM))
seg_error("sets unsupported VDO block map era length");
if ((seg->vdo_params.index_memory_size_mb < DM_VDO_INDEX_MEMORY_SIZE_MINIMUM_MB) ||
(seg->vdo_params.index_memory_size_mb > DM_VDO_INDEX_MEMORY_SIZE_MAXIMUM_MB))
seg_error("sets unsupported VDO index memory size");
if ((seg->vdo_params.slab_size_mb < DM_VDO_SLAB_SIZE_MINIMUM_MB) ||
(seg->vdo_params.slab_size_mb > DM_VDO_SLAB_SIZE_MAXIMUM_MB))
seg_error("sets unsupported VDO slab size");
if ((seg->vdo_params.max_discard < DM_VDO_MAX_DISCARD_MINIMUM) ||
(seg->vdo_params.max_discard > DM_VDO_MAX_DISCARD_MAXIMUM))
seg_error("sets unsupported VDO max discard");
if (seg->vdo_params.ack_threads > DM_VDO_ACK_THREADS_MAXIMUM)
seg_error("sets unsupported VDO ack threads");
if ((seg->vdo_params.bio_threads < DM_VDO_BIO_THREADS_MINIMUM) ||
(seg->vdo_params.bio_threads > DM_VDO_BIO_THREADS_MAXIMUM))
seg_error("sets unsupported VDO bio threads");
if ((seg->vdo_params.bio_rotation < DM_VDO_BIO_ROTATION_MINIMUM) ||
(seg->vdo_params.bio_rotation > DM_VDO_BIO_ROTATION_MAXIMUM))
seg_error("sets unsupported VDO bio rotation");
if ((seg->vdo_params.cpu_threads < DM_VDO_CPU_THREADS_MINIMUM) ||
(seg->vdo_params.cpu_threads > DM_VDO_CPU_THREADS_MAXIMUM))
seg_error("sets unsupported VDO cpu threads");
if (seg->vdo_params.hash_zone_threads > DM_VDO_HASH_ZONE_THREADS_MAXIMUM)
seg_error("sets unsupported VDO hash zone threads");
if (seg->vdo_params.logical_threads > DM_VDO_LOGICAL_THREADS_MAXIMUM)
seg_error("sets unsupported VDO logical threads");
if (seg->vdo_params.physical_threads > DM_VDO_PHYSICAL_THREADS_MAXIMUM)
seg_error("sets unsupported VDO physical threads");
} else { /* !VDO pool */ } else { /* !VDO pool */
if (seg->vdo_pool_header_size) if (seg->vdo_pool_header_size)
seg_error("sets vdo_pool_header_size"); seg_error("sets vdo_pool_header_size");
if (seg->vdo_pool_virtual_extents) if (seg->vdo_pool_virtual_extents)
seg_error("sets vdo_pool_virtual_extents"); seg_error("sets vdo_pool_virtual_extents");
if (seg->vdo_params.minimum_io_size |
seg->vdo_params.block_map_cache_size_mb |
seg->vdo_params.block_map_era_length |
seg->vdo_params.check_point_frequency |
seg->vdo_params.index_memory_size_mb |
seg->vdo_params.slab_size_mb |
seg->vdo_params.max_discard |
seg->vdo_params.ack_threads |
seg->vdo_params.bio_threads |
seg->vdo_params.bio_rotation |
seg->vdo_params.cpu_threads |
seg->vdo_params.hash_zone_threads |
seg->vdo_params.logical_threads |
seg->vdo_params.physical_threads)
seg_error("sets vdo_params");
} }
if (seg_is_vdo(seg)) { if (seg_is_vdo(seg)) {