master - lvconvert: snapshot prompts to confirm conversion
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=56c5ad7b194f5b991ae3835abca1c951450f34df Commit: 56c5ad7b194f5b991ae3835abca1c951450f34df Parent: 64828d877edbf1907557d76e44eb86d00f7a1f3a Author: Zdenek Kabelac <[email protected]> AuthorDate: Mon Jul 7 22:33:31 2014 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Fri Jul 11 12:49:55 2014 +0200
lvconvert: snapshot prompts to confirm conversion
Since the type passed LV is changed and content of data detroyed, query user with prompt to confirm this operation.
Also add a proper wiping of header.
Using '--yes' will skip this prompt:
lvconvert -s --yes vg/lv vg/lvcow
--- WHATS_NEW | 1 + test/shell/lvconvert-snapshot.sh | 4 +++- tools/lvconvert.c | 30 +++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.108 - ================================= + Prompt for confirmation before change LV into a snapshot exception store. Return proper error codes for some failing lvconvert funtions. Add initial code to use cache tools (cache_check|dump|repair|restore). Add "degraded" activation mode and make it the default.
test/shell/lvconvert-snapshot.sh +3 -1
@@ -25,6 +25,7 @@ lvcreate -L1 -s -n $lv3 $vg/$lv2 lvcreate -l1 -n $lv4 $vg lvcreate -L1 -n $lv5 $vg +lvcreate -L1 -n $lv6 $vg not lvconvert -s $vg/$lv1 $vg/not_exist
@@ -52,6 +53,7 @@ not lvconvert -s $vg/$lv2 $vg/$lv4 2>&1 | tee err grep "smaller" err # This should pass -lvconvert -s $vg/$lv2 $vg/$lv5 +lvconvert --yes -s $vg/$lv2 $vg/$lv5 +lvconvert --yes --type snapshot $vg/$lv2 $vg/$lv6 vgremove -f $vg
tools/lvconvert.c +25 -5
@@ -2063,11 +2063,14 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,return 0 ; } -if (!lp->zero || !(lv->status &LVM_WRITE )) -log_warn ("WARNING: \"%s\" not zeroed" , lv->name); -else if (!wipe_lv (lv, (struct wipe_params ) { .do_zero =1 })) { -log_error ("Aborting. Failed to wipe snapshot " -"exception store." ); +log_warn ("WARNING: Converting logical volume %s to snapshot exception store." , +display_lvname (lv)); +log_warn ("THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)" ); + +if (!lp->yes && +yes_no_prompt ("Do you really want to convert %s? [y/n]: " , +display_lvname (lv)) =='n' ) { +log_error ("Conversion aborted." );return 0 ; }
@@ -2076,6 +2079,23 @@ static int _lvconvert_snapshot(struct cmd_context *cmd,return 0 ; } +if (!lp->zero || !(lv->status &LVM_WRITE )) +log_warn ("WARNING: \"%s\" not zeroed" , lv->name); +else { + lv->status |=LV_TEMPORARY ; +if (!activate_lv_local (cmd, lv) || + !wipe_lv (lv, (struct wipe_params ) { .do_zero =1 })) { +log_error ("Aborting. Failed to wipe snapshot exception store." ); +return 0 ; + } + lv->status &= ~LV_TEMPORARY ; +/* Deactivates cleared metadata LV */ +if (!deactivate_lv_local (lv->vg->cmd, lv)) { +log_error ("Failed to deactivate zeroed snapshot exception store." ); +return 0 ; + } + } +if (!archive (lv->vg)) return_0;