lvm2: honor yes and force option by lvconvert
PATCH 1/1 lvm2: honor yes and force option by lvconvert
This patch suppresses a following prompt by lvconvert command when --yes or --force option is specified.
Full resync required to convert inactive mirror <lv> to core log. Proceed? [y/n]:
This change is useful when lvconvert command is used in a script and a test case.
Signed-off-by Takahiro Yasui <[email protected]>
--- lib/metadata/metadata-exported.h | 2 +- lib/metadata/mirror.c | 5 +++-- tools/lvconvert.c | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-)
lib/metadata/metadata-exported.h +1 -1
@@ -779,7 +779,7 @@ int add_mirror_images(struct cmd_contextstruct logical_volume *detach_mirror_log (struct lv_segment *seg);int attach_mirror_log (struct lv_segment *seg,struct logical_volume *lv);int remove_mirror_log (struct cmd_context *cmd,struct logical_volume *lv, -struct dm_list *removable_pvs); +struct dm_list *removable_pvs,int force);int add_mirror_log (struct cmd_context *cmd,struct logical_volume *lv,uint32_t log_count,uint32_t region_size,struct dm_list *allocatable_pvs,alloc_policy_t alloc);
lib/metadata/mirror.c +3 -2
@@ -1517,7 +1517,8 @@ int add_mirrors_to_segments(struct cmd_c*/ int remove_mirror_log (struct cmd_context *cmd,struct logical_volume *lv, -struct dm_list *removable_pvs) +struct dm_list *removable_pvs, +int force) {float sync_percent;percent_range_t percent_range =PERCENT_0 ;
@@ -1541,7 +1542,7 @@ int remove_mirror_log(struct cmd_contextlog_error ("Unable to convert the log of an inactive " "cluster mirror, %s" , lv->name);return 0 ; - }else if (yes_no_prompt ("Full resync required to convert " + }else if (force ||yes_no_prompt ("Full resync required to convert " "inactive mirror %s to core log. " "Proceed? [y/n]: " , lv->name) =='y' ) sync_percent =0 ;
tools/lvconvert.c +3 -1
@@ -719,7 +719,9 @@ static int _lv_update_log_type(struct cm/* Remove an existing log completely */ if (!log_count) { -if (!remove_mirror_log (cmd, original_lv, operable_pvs)) +if (!remove_mirror_log (cmd, original_lv, operable_pvs, +arg_count (cmd, yes_ARG) || +arg_count (cmd, force_ARG))) return_0;return 1 ; }