master - lvconvert: use command defs for thin/cache/pool creation
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0e3e611a137a264a343335d18d500fce7af8e0f7 Commit: 0e3e611a137a264a343335d18d500fce7af8e0f7 Parent: d71aaca07b2c14049130ab368221510c65236af7 Author: David Teigland <[email protected]> AuthorDate: Wed Dec 7 14:30:57 2016 -0600 Committer: David Teigland <[email protected]> CommitterDate: Mon Feb 13 08:20:10 2017 -0600
lvconvert: use command defs for thin/cache/pool creation
Everything related to thin and cache.
--- test/shell/lvconvert-thin.sh | 18 +- test/shell/thin-merge.sh | 4 +- test/shell/thin-vglock.sh | 2 +- tools/args.h | 2 + tools/command-lines.in | 45 +- tools/lvconvert.c | 1361 ++++++++++++++++++++++++++++++++++++++++-- tools/lvmcmdline.c | 39 +- tools/toollib.c | 6 +- tools/toollib.h | 2 + tools/tools.h | 9 + 10 files changed, 1404 insertions(+), 84 deletions(-)
test/shell/lvconvert-thin.sh +9 -9
@@ -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
test/shell/thin-merge.sh +2 -2
@@ -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
test/shell/thin-vglock.sh +1 -1
@@ -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
tools/args.h +2 -0
@@ -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 )
tools/command-lines.in +32 -13
110 lines not on this page · raw message
tools/lvconvert.c +1319 -42
1,477 lines not on this page · raw message
tools/lvmcmdline.c +25 -14
@@ -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
tools/toollib.c +3 -3
@@ -2539,7 +2539,7 @@ static int _lv_is_type(struct cmd_context *cmd, struct logical_volume *lv, int lreturn 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);
tools/toollib.h +2 -0
@@ -240,4 +240,6 @@ int validate_restricted_lvname_param(struct cmd_context *cmd, const char **vg_naint 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
tools/tools.h +9 -0
@@ -241,6 +241,7 @@ int vgchange_background_polling(struct cmd_context *cmd, struct volume_group *vgstruct 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, charint 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