1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

lvconvert: use command defs for thin/cache/pool creation

Everything related to thin and cache.
This commit is contained in:
David Teigland 2016-12-07 14:30:57 -06:00
parent d71aaca07b
commit 0e3e611a13
10 changed files with 1394 additions and 74 deletions

View File

@ -81,9 +81,9 @@ grep "Pool zeroing and large" err
UUID=$(get lv_field $vg/$lv2 uuid)
# Fail is pool is active
# TODO maybe detect inactive pool and deactivate
fail lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $lv2
fail lvconvert --swapmetadata --yes --poolmetadata $lv2 $vg/$lv1
lvchange -an $vg
lvconvert --yes --thinpool $vg/$lv1 --poolmetadata $lv2
lvconvert --swapmetadata --yes --poolmetadata $lv2 $vg/$lv1
check lv_field $vg/${lv1}_tmeta uuid "$UUID"
lvremove -f $vg
@ -96,20 +96,20 @@ lvcreate -L1M -n $lv3 $vg
# chunk size is bigger then size of thin pool data
fail lvconvert --yes -c 1G --thinpool $vg/$lv3
# stripes can't be used with poolmetadata
invalid lvconvert --stripes 2 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
not lvconvert --stripes 2 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
# too small metadata (<2M)
fail lvconvert --yes -c 64 --thinpool $vg/$lv1 --poolmetadata $vg/$lv3
# too small chunk size fails
invalid lvconvert -c 4 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
not lvconvert -c 4 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
# too big chunk size fails
invalid lvconvert -c 2G --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
not lvconvert -c 2G --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
# negative chunk size fails
invalid lvconvert -c -256 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
not lvconvert -c -256 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
# non multiple of 64KiB fails
invalid lvconvert -c 88 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
not lvconvert -c 88 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2
# cannot use same LV for pool and convertion
invalid lvconvert --yes --thinpool $vg/$lv3 -T $vg/$lv3
not lvconvert --yes --thinpool $vg/$lv3 -T $vg/$lv3
# Warning about smaller then suggested
lvconvert --yes -c 256 --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 2>&1 | tee err
@ -129,7 +129,7 @@ if test "$TSIZE" = 64T; then
lvcreate -L24T -n $lv1 $vg
# Warning about bigger then needed (24T data and 16G -> 128K chunk)
lvconvert --yes -c 64 --thinpool $vg/$lv1 2>&1 | tee err
grep "WARNING: Chunk size is too small" err
grep "too small" err
lvremove -f $vg
fi

View File

@ -44,7 +44,7 @@ touch mntsnap/test_snap
lvs -o+tags,thin_id $vg
lvconvert --merge $vg/snap
lvconvert --mergethin $vg/snap
umount mnt
@ -107,7 +107,7 @@ fsck -n "$DM_DEV_DIR/$vg/$lv1"
check lv_not_exists $vg oldsnapof_${lv1}
# Add old snapshot to thin snapshot
lvcreate -s -L10 -n oldsnapof_snap $vg/snap
lvconvert --merge $vg/snap
lvconvert --mergethin $vg/snap
lvremove -f $vg/oldsnapof_snap
vgremove -ff $vg

View File

@ -34,7 +34,7 @@ mount "$DM_DEV_DIR/$vg/$lv1" mnt
lvcreate -s -n snap $vg/$lv1
check lv_field $vg/snap thin_id "3"
lvconvert --merge $vg/snap
lvconvert --mergethin $vg/snap
umount mnt

View File

@ -61,6 +61,7 @@ arg(logonly_ARG, '\0', "logonly", 0, 0, 0)
arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", sizekb_VAL, 0, 0)
arg(merge_ARG, '\0', "merge", 0, 0, 0)
arg(mergesnapshot_ARG, '\0', "mergesnapshot", 0, 0, 0)
arg(mergethin_ARG, '\0', "mergethin", 0, 0, 0)
arg(mergedconfig_ARG, '\0', "mergedconfig", 0, 0, 0)
arg(metadatacopies_ARG, '\0', "metadatacopies", metadatacopies_VAL, 0, 0)
arg(metadataignore_ARG, '\0', "metadataignore", bool_VAL, 0, 0)
@ -120,6 +121,7 @@ arg(showdeprecated_ARG, '\0', "showdeprecated", 0, 0, 0)
arg(showunsupported_ARG, '\0', "showunsupported", 0, 0, 0)
arg(startpoll_ARG, '\0', "startpoll", 0, 0, 0)
arg(stripes_long_ARG, '\0', "stripes", number_VAL, 0, 0)
arg(swapmetadata_ARG, '\0', "swapmetadata", 0, 0, 0)
arg(syncaction_ARG, '\0', "syncaction", syncaction_VAL, 0, 0)
arg(sysinit_ARG, '\0', "sysinit", 0, 0, 0)
arg(systemid_ARG, '\0', "systemid", string_VAL, 0, 0)

View File

@ -384,18 +384,22 @@ DESC: Change the type of mirror log used by a mirror LV.
# lvconvert utilities for creating/maintaining thin and cache objects.
# Create a new command set for these and migrate them out of lvconvert?
lvconvert --type thin --thinpool LV LV_linear_striped_raid
lvconvert --type thin --thinpool LV LV_linear_striped_raid_cache
OO: --thin, --originname LV_new, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_thin_with_external
DESC: Convert LV to type thin with an external origin.
DESC: Convert LV to a thin LV, using the original LV as an external origin.
RULE: all and lv_is_visible
RULE: all not lv_is_locked
# alternate form of lvconvert --type thin
lvconvert --thin --thinpool LV LV_linear_striped_raid
lvconvert --thin --thinpool LV LV_linear_striped_raid_cache
OO: --type thin, --originname LV_new, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_thin_with_external
DESC: Convert LV to type thin with an external origin
DESC: Convert LV to a thin LV, using the original LV as an external origin.
DESC: (variant, infers --type thin).
FLAGS: SECONDARY_SYNTAX
RULE: all and lv_is_visible
RULE: all not lv_is_locked
---
@ -404,6 +408,7 @@ OO: --cache, --cachemode CacheMode, --cachepolicy String,
--cachesettings String, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_vol
DESC: Convert LV to type cache.
RULE: all and lv_is_visible
# alternate form of lvconvert --type cache
lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool
@ -412,6 +417,7 @@ OO: --type cache, --cachemode CacheMode, --cachepolicy String,
ID: lvconvert_to_cache_vol
DESC: Convert LV to type cache (variant, infers --type cache).
FLAGS: SECONDARY_SYNTAX
RULE: all and lv_is_visible
---
@ -421,14 +427,18 @@ OO: --stripes_long Number, --stripesize SizeKB,
OP: PV ...
ID: lvconvert_to_thinpool
DESC: Convert LV to type thin-pool.
RULE: all and lv_is_visible
RULE: all not lv_is_locked lv_is_origin lv_is_merging_origin lv_is_external_origin lv_is_virtual
# alternate form of lvconvert --type thin-pool
# deprecated because of non-standard syntax (missing positional arg)
# Commands in this form are converted to standard form so that
# the validation of LV types and rules specified above will apply.
lvconvert --thinpool LV_linear_striped_raid_cache
OO: --type thin-pool, --stripes_long Number, --stripesize SizeKB,
--discards Discards, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
OP: PV ...
ID: lvconvert_to_thinpool
ID: lvconvert_to_thinpool_noarg
DESC: Convert LV to type thin-pool (variant, use --type thin-pool).
FLAGS: SECONDARY_SYNTAX
@ -443,10 +453,13 @@ DESC: Convert LV to type cache-pool.
# alternate form of lvconvert --type cache-pool
# deprecated because of non-standard syntax (missing positional arg)
# Commands in this form are converted to standard form so that
# the validation of LV types and rules specified above will apply.
lvconvert --cachepool LV_linear_striped_raid
OO: --type cache-pool, OO_LVCONVERT_POOL, OO_LVCONVERT,
--cachemode CacheMode, --cachepolicy String, --cachesettings String
ID: lvconvert_to_cachepool
OP: PV ...
ID: lvconvert_to_cachepool_noarg
DESC: Convert LV to type cache-pool (variant, use --type cache-pool).
FLAGS: SECONDARY_SYNTAX
@ -461,18 +474,15 @@ DESC: Separate and keep the cache pool from a cache LV.
lvconvert --uncache LV_cache_thinpool
OO: OO_LVCONVERT
ID: lvconvert_split_and_delete_cachepool
ID: lvconvert_split_and_remove_cachepool
DESC: Separate and delete the cache pool from a cache LV.
---
# FIXME: add a new option defining this operation, e.g. --swapmetadata
lvconvert --poolmetadata LV LV_thinpool_cachepool
OO: OO_LVCONVERT
lvconvert --swapmetadata --poolmetadata LV LV_thinpool_cachepool
OO: --chunksize SizeKB, OO_LVCONVERT
ID: lvconvert_swap_pool_metadata
DESC: Swap metadata LV in a thin pool or cache pool (temporary command).
FLAGS: SECONDARY_SYNTAX
DESC: Swap metadata LV in a thin pool or cache pool (for repair only).
---
@ -879,6 +889,15 @@ DESC: (infers --type thin).
---
lvconvert --mergethin LV_thin ...
OO: --background, --interval Number, OO_LVCONVERT
ID: lvconvert_merge_thin
DESC: Merge thin LV into its origin LV.
RULE: all not lv_is_locked lv_is_pvmove lv_is_merging_origin lv_is_virtual_origin lv_is_external_origin lv_is_merging_cow
RULE: all and lv_is_visible
---
# stripes option is not intuitive when creating a thin LV,
# but here it applies to creating the new thin pool that
# is used for the thin LV

File diff suppressed because it is too large Load Diff

View File

@ -134,30 +134,29 @@ struct command_function command_functions[COMMAND_ID_COUNT] = {
/* lvconvert utility to trigger polling on an LV. */
{ lvconvert_start_poll_CMD, lvconvert_start_poll_cmd },
/* lvconvert utilities for creating/maintaining thin and cache objects. */
{ lvconvert_to_thinpool_CMD, lvconvert_to_pool_cmd },
{ lvconvert_to_thinpool_noarg_CMD, lvconvert_to_pool_noarg_cmd },
{ lvconvert_to_cachepool_CMD, lvconvert_to_pool_cmd },
{ lvconvert_to_cachepool_noarg_CMD, lvconvert_to_pool_noarg_cmd },
{ lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external_cmd },
{ lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol_cmd },
{ lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata_cmd },
{ lvconvert_merge_thin_CMD, lvconvert_merge_thin_cmd },
{ lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_cachepool_cmd },
{ lvconvert_split_and_remove_cachepool_CMD, lvconvert_split_cachepool_cmd },
};
#if 0
/* all raid-related type conversions */
{ lvconvert_raid_types_CMD, lvconvert_raid_types_fn },
/* raid-related utilities (move into lvconvert_raid_types?) */
{ lvconvert_split_mirror_images_CMD, lvconvert_split_mirror_images_fn },
{ lvconvert_change_mirrorlog_CMD, lvconvert_change_mirrorlog_fn },
/* utilities for creating/maintaining thin and cache objects. */
{ lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external_fn },
{ lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol_fn },
{ lvconvert_to_thinpool_CMD, lvconvert_to_thinpool_fn },
{ lvconvert_to_cachepool_CMD, lvconvert_to_cachepool_fn },
{ lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_and_keep_cachepool_fn },
{ lvconvert_split_and_delete_cachepool_CMD, lvconvert_split_and_delete_cachepool_fn },
{ lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata_fn },
/* other misc. */
/* directed to one of the other merges (snap,thin,mirror) when all are implemented */
{ lvconvert_merge_CMD, lvconvert_merge_fn },
#endif
@ -1136,6 +1135,18 @@ struct lv_types *get_lv_type(int lvt_enum)
return &_lv_types[lvt_enum];
}
struct command *get_command(int cmd_enum)
{
int i;
for (i = 0; i < COMMAND_COUNT; i++) {
if (commands[i].command_line_enum == cmd_enum)
return &commands[i];
}
return NULL;
}
/*
* Also see merge_synonym(). The command definitions
* are written using just one variation of the option

View File

@ -2539,7 +2539,7 @@ static int _lv_is_type(struct cmd_context *cmd, struct logical_volume *lv, int l
return 0;
}
static int _get_lvt_enum(struct logical_volume *lv)
int get_lvt_enum(struct logical_volume *lv)
{
struct lv_segment *seg = first_seg(lv);
@ -2700,7 +2700,7 @@ static int _check_lv_types(struct cmd_context *cmd, struct logical_volume *lv, i
ret = _lv_types_match(cmd, lv, cmd->command->required_pos_args[pos-1].def.lvt_bits, NULL, NULL);
if (!ret) {
int lvt_enum = _get_lvt_enum(lv);
int lvt_enum = get_lvt_enum(lv);
struct lv_types *type = get_lv_type(lvt_enum);
log_warn("Operation on LV %s which has invalid type %s.",
display_lvname(lv), type ? type->name : "unknown");
@ -2723,7 +2723,7 @@ static int _check_lv_rules(struct cmd_context *cmd, struct logical_volume *lv)
int ret = 1;
int i;
lvt_enum = _get_lvt_enum(lv);
lvt_enum = get_lvt_enum(lv);
if (lvt_enum)
lvtype = get_lv_type(lvt_enum);

View File

@ -240,4 +240,6 @@ int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_na
int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
struct processing_handle *handle __attribute__((unused)));
int get_lvt_enum(struct logical_volume *lv);
#endif

View File

@ -241,6 +241,7 @@ int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vg
struct lv_props *get_lv_prop(int lvp_enum);
struct lv_types *get_lv_type(int lvt_enum);
struct command *get_command(int cmd_enum);
int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv);
@ -260,4 +261,12 @@ int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char
int lvconvert_start_poll_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_pool_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_cache_vol_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_thin_with_external_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_merge_thin_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv);
#endif