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

Thin api change for dm_tree_node_add_thin_target

A little code shuffling and adding support for
DM_THIN_ERROR_DEVICE_ID which might be eventually be used
for activation of thin which is going to be deleted.
For now we do not need it lvm.
This commit is contained in:
Zdenek Kabelac 2011-11-03 14:43:21 +00:00
parent f8aee4460a
commit 4d25c81bdd
2 changed files with 28 additions and 14 deletions

View File

@ -540,11 +540,9 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
* DATA_DEV_BLOCK_SIZE_MIN_SECTORS (64 * 1024 >> SECTOR_SHIFT)
* DATA_DEV_BLOCK_SIZE_MAX_SECTORS (1024 * 1024 * 1024 >> SECTOR_SHIFT)
* MAX_DEV_ID ((1 << 24) - 1)
*/
#define DM_THIN_MIN_DATA_BLOCK_SIZE (UINT32_C(128))
#define DM_THIN_MAX_DATA_BLOCK_SIZE (UINT32_C(2097152))
#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1))
int dm_tree_node_add_thin_pool_target(struct dm_tree_node *node,
uint64_t size,
@ -591,9 +589,18 @@ struct dm_thin_message {
int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
const struct dm_thin_message *message);
/*
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
* MAX_DEV_ID ((1 << 24) - 1)
*/
#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1))
/* Reserved device_id for error (deleted) thin device */
// FIXME - only needed for in-delete thin is not activated
#define DM_THIN_ERROR_DEVICE_ID (UINT32_MAX)
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
const char *thin_pool_uuid,
const char *pool_uuid,
uint32_t device_id);
void dm_tree_node_set_udev_flags(struct dm_tree_node *node, uint16_t udev_flags);

View File

@ -2973,26 +2973,33 @@ int dm_tree_node_add_thin_pool_message(struct dm_tree_node *node,
int dm_tree_node_add_thin_target(struct dm_tree_node *node,
uint64_t size,
const char *thin_pool_uuid,
const char *pool_uuid,
uint32_t device_id)
{
struct dm_tree_node *pool;
struct load_segment *seg;
if (!_thin_validate_device_id(device_id))
return_0;
if (!(seg = _add_segment(node, SEG_THIN, size)))
return_0;
if (!(seg->pool = dm_tree_find_node_by_uuid(node->dtree, thin_pool_uuid))) {
log_error("Missing thin pool uuid %s.", thin_pool_uuid);
if (!(pool = dm_tree_find_node_by_uuid(node->dtree, pool_uuid))) {
log_error("Missing thin pool uuid %s.", pool_uuid);
return 0;
}
if (!_link_tree_nodes(node, seg->pool))
if (!_link_tree_nodes(node, pool))
return_0;
seg->device_id = device_id;
if (device_id == DM_THIN_ERROR_DEVICE_ID) {
if (!dm_tree_node_add_error_target(node, size))
return_0;
} else {
if (!_thin_validate_device_id(device_id))
return_0;
if (!(seg = _add_segment(node, SEG_THIN, size)))
return_0;
seg->pool = pool;
seg->device_id = device_id;
}
return 1;
}