From: Zdenek Kabelac Date: Wed, 2 Jul 2014 08:48:40 +0000 (UTC) Subject: master - thin: fix chunk_size conversion prompt skip Message-ID: <20140702084840.00ECD61054@fedorahosted.org> List-Id: To: lvm-devel@redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3af761ba167236a2d66f8687ade5db6311498d06 Commit: 3af761ba167236a2d66f8687ade5db6311498d06 Parent: 93a80018ae8e2f3f56e56b42237779661c9040b3 Author: Zdenek Kabelac AuthorDate: Tue Jul 1 11:04:14 2014 +0200 Committer: Zdenek Kabelac CommitterDate: Wed Jul 2 10:43:56 2014 +0200 thin: fix chunk_size conversion prompt skip Use --force only enables prompting for dangerous operation. User has to add --yes to skip this prompt. --- WHATS_NEW | 1 + tools/lvconvert.c | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 230bdf0..8934d6f 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.108 - ================================= + Require --yes option to skip prompt to lvconvert thin pool chunksize. Support lvremove -ff to remove thin volumes from broken thin pools. Require --yes to skip raid repair prompt. Change makefile %.d generation to handle filename changes without make clean. diff --git a/tools/lvconvert.c b/tools/lvconvert.c index d80fa60..be2c916 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -2805,14 +2805,25 @@ static int _lvconvert_to_pool(struct cmd_context *cmd, if (!arg_count(cmd, chunksize_ARG)) lp->chunk_size = seg->chunk_size; - else if ((lp->chunk_size != seg->chunk_size) && - !lp->force && - yes_no_prompt("Do you really want to change chunk size %s to %s for %s/%s " - "pool volume? [y/n]: ", display_size(cmd, seg->chunk_size), - display_size(cmd, lp->chunk_size), - pool_lv->vg->name, pool_lv->name) == 'n') { - log_error("Conversion aborted."); - return 0; + else if (lp->chunk_size != seg->chunk_size) { + if (lp->force == PROMPT) { + log_error("Chunk size can be only changed with --force. Conversion aborted."); + return 0; + } + /* Ok, user has likely some serious reason for this */ + if (!lp->yes && + yes_no_prompt("Do you really want to change chunk size %s to %s " + "for %s/%s pool volume? [y/n]: ", + display_size(cmd, seg->chunk_size), + display_size(cmd, lp->chunk_size), + pool_lv->vg->name, pool_lv->name) == 'n') { + log_error("Conversion aborted."); + return 0; + } + log_warn("WARNING: Changing chunk size %s to %s for %s/%s pool volume.", + display_size(cmd, seg->chunk_size), + display_size(cmd, lp->chunk_size), + pool_lv->vg->name, pool_lv->name); } if (!arg_count(cmd, discards_ARG)) lp->discards = seg->discards;