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

libdm: add dm_tree_node_add_thin_pool_target_v1

Supports thin-pool without crop.
This commit is contained in:
Zdenek Kabelac 2021-02-01 14:06:31 +01:00
parent 25b942a8ac
commit 48030389ce
4 changed files with 44 additions and 13 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.177 - Version 1.02.177 -
==================================== ====================================
Add dm_tree_node_add_thin_pool_target_v1 with crop_metadata support.
Version 1.02.175 - 08th January 2021 Version 1.02.175 - 08th January 2021
==================================== ====================================

View File

@ -0,0 +1 @@
dm_tree_node_add_thin_pool_target_v1

View File

@ -1968,10 +1968,10 @@ 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_MIN_DATA_BLOCK_SIZE (UINT32_C(128))
#define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152)) #define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152))
/* /*
* Max supported size for thin pool metadata device (17112760320 bytes) * Max supported size for thin pool metadata device (17045913600 bytes)
* Limitation is hardcoded into the kernel and bigger device size
* is not accepted.
* drivers/md/dm-thin-metadata.h THIN_METADATA_MAX_SECTORS * drivers/md/dm-thin-metadata.h THIN_METADATA_MAX_SECTORS
* But here DM_THIN_MAX_METADATA_SIZE got defined incorrectly
* Correct size is (UINT64_C(255) * ((1 << 14) - 64) * (4096 / (1 << 9)))
*/ */
#define DM_THIN_MAX_METADATA_SIZE (UINT64_C(255) * (1 << 14) * (4096 / (1 << 9)) - 256 * 1024) #define DM_THIN_MAX_METADATA_SIZE (UINT64_C(255) * (1 << 14) * (4096 / (1 << 9)) - 256 * 1024)
@ -1984,6 +1984,16 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t low_water_mark, uint64_t low_water_mark,
unsigned skip_block_zeroing); unsigned skip_block_zeroing);
int dm_tree_node_add_thin_pool_target_v1(struct dm_tree_node *node,
uint64_t size,
uint64_t transaction_id,
const char *metadata_uuid,
const char *pool_uuid,
uint32_t data_block_size,
uint64_t low_water_mark,
unsigned skip_block_zeroing,
unsigned crop_metadata);
/* Supported messages for thin provision target */ /* Supported messages for thin provision target */
typedef enum { typedef enum {
DM_THIN_MESSAGE_CREATE_SNAP, /* device_id, origin_id */ DM_THIN_MESSAGE_CREATE_SNAP, /* device_id, origin_id */

View File

@ -3502,6 +3502,24 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint32_t data_block_size, uint32_t data_block_size,
uint64_t low_water_mark, uint64_t low_water_mark,
unsigned skip_block_zeroing) unsigned skip_block_zeroing)
{
return dm_tree_node_add_thin_pool_target_v1(node, size, transaction_id,
metadata_uuid, pool_uuid,
data_block_size,
low_water_mark,
skip_block_zeroing,
1);
}
int dm_tree_node_add_thin_pool_target_v1(struct dm_tree_node *node,
uint64_t size,
uint64_t transaction_id,
const char *metadata_uuid,
const char *pool_uuid,
uint32_t data_block_size,
uint64_t low_water_mark,
unsigned skip_block_zeroing,
unsigned crop_metadata)
{ {
struct load_segment *seg, *mseg; struct load_segment *seg, *mseg;
uint64_t devsize = 0; uint64_t devsize = 0;
@ -3529,17 +3547,18 @@ int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
if (!_link_tree_nodes(node, seg->metadata)) if (!_link_tree_nodes(node, seg->metadata))
return_0; return_0;
/* FIXME: more complex target may need more tweaks */ if (crop_metadata)
dm_list_iterate_items(mseg, &seg->metadata->props.segs) { /* FIXME: more complex target may need more tweaks */
devsize += mseg->size; dm_list_iterate_items(mseg, &seg->metadata->props.segs) {
if (devsize > DM_THIN_MAX_METADATA_SIZE) { devsize += mseg->size;
log_debug_activation("Ignoring %" PRIu64 " of device.", if (devsize > DM_THIN_MAX_METADATA_SIZE) {
devsize - DM_THIN_MAX_METADATA_SIZE); log_debug_activation("Ignoring %" PRIu64 " of device.",
mseg->size -= (devsize - DM_THIN_MAX_METADATA_SIZE); devsize - DM_THIN_MAX_METADATA_SIZE);
devsize = DM_THIN_MAX_METADATA_SIZE; mseg->size -= (devsize - DM_THIN_MAX_METADATA_SIZE);
/* FIXME: drop remaining segs */ devsize = DM_THIN_MAX_METADATA_SIZE;
/* FIXME: drop remaining segs */
}
} }
}
if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) { if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) {
log_error("Missing pool uuid %s.", pool_uuid); log_error("Missing pool uuid %s.", pool_uuid);