diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index dba854801..bada7759e 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -749,6 +749,13 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node, */ #define DM_THIN_MIN_DATA_BLOCK_SIZE (UINT32_C(128)) #define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152)) +/* + * Max supported size for thin pool metadata device (17112760320 bytes) + * Limitation is hardcoded into the kernel and bigger device size + * is not accepted. + * drivers/md/dm-thin-metadata.h THIN_METADATA_MAX_SECTORS + */ +#define DM_THIN_MAX_METADATA_SIZE (UINT64_C(255) * (1 << 14) * (4096 / (1 << 9)) - 256 * 1024) int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, uint64_t size, diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index f8c0d7a52..50ed9083b 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -3232,13 +3232,6 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, { struct load_segment *seg, *mseg; uint64_t devsize = 0; - /* - * Max supported size for thin pool metadata device - * Limitation is hardcoded into kernel and bigger - * device size is not accepted. (16978542592) - */ - const uint64_t max_metadata_size = - 255ULL * (1 << 14) * (4096 / (1 << 9)) - 256 * 1024; if (data_block_size < DM_THIN_MIN_DATA_BLOCK_SIZE) { log_error("Data block size %u is lower then %u sectors.", @@ -3266,11 +3259,11 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node, /* FIXME: more complex target may need more tweaks */ dm_list_iterate_items(mseg, &seg->metadata->props.segs) { devsize += mseg->size; - if (devsize > max_metadata_size) { + if (devsize > DM_THIN_MAX_METADATA_SIZE) { log_debug_activation("Ignoring %" PRIu64 " of device.", - devsize - max_metadata_size); - mseg->size -= (devsize - max_metadata_size); - devsize = max_metadata_size; + devsize - DM_THIN_MAX_METADATA_SIZE); + mseg->size -= (devsize - DM_THIN_MAX_METADATA_SIZE); + devsize = DM_THIN_MAX_METADATA_SIZE; /* FIXME: drop remaining segs */ } }