master - pvresize: Prompt when non-default size supplied.
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=cbc69f8c693edf0d1307c9447e2e66d07a04bfe9 Commit: cbc69f8c693edf0d1307c9447e2e66d07a04bfe9 Parent: 78a0b4a08a7178250b9d0b3be7f975440975d9d4 Author: Alasdair G Kergon <[email protected]> AuthorDate: Thu Apr 27 02:36:34 2017 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Thu Apr 27 02:36:34 2017 +0100
pvresize: Prompt when non-default size supplied.
Seek confirmation before changing the PV size to one that differs from the underlying block device.
--- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 3 ++- lib/metadata/pv_manip.c | 30 +++++++++++++++++++++++------- liblvm/lvm_pv.c | 2 +- tools/pvresize.c | 2 +- 5 files changed, 28 insertions(+), 10 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.171 - ================================== + Adjust pvresize messages and add prompt if underlying dev size differs. lvconvert - preserve region size on raid1 image count changes raid - sanely handle insufficient space on takeover Fix configure --enable-notify-dbus status message.
lib/metadata/metadata-exported.h +2 -1
@@ -748,7 +748,8 @@ int pvremove_many(struct cmd_context *cmd, struct dm_list *pv_names,int pv_resize_single (struct cmd_context *cmd,struct volume_group *vg,struct physical_volume *pv, -const uint64_t new_size); +const uint64_t new_size, +int yes);int pv_analyze (struct cmd_context *cmd,const char *pv_name,uint64_t label_sector);
lib/metadata/pv_manip.c +23 -7
@@ -604,7 +604,7 @@ static int pv_resize(struct physical_volume *pv,log_verbose ("Resizing physical volume %s from %" PRIu32" to %" PRIu32" extents." , -pv_dev_name (pv), pv->pe_count, new_pe_count); +pv_dev_name (pv), old_pe_count, new_pe_count);if (new_pe_count > old_pe_count)return _extend_pv (pv, vg, old_pe_count, new_pe_count);
@@ -618,7 +618,8 @@ static int pv_resize(struct physical_volume *pv,int pv_resize_single (struct cmd_context *cmd,struct volume_group *vg,struct physical_volume *pv, -const uint64_t new_size) +const uint64_t new_size, +int yes) {uint64_t size =0 ;int r =0 ;
@@ -642,11 +643,26 @@ int pv_resize_single(struct cmd_context *cmd, }if (new_size) { -if (new_size > size) -log_warn ("WARNING: %s: Overriding real size. " -"You could lose data." , pv_name); -log_verbose ("%s: Pretending size is %" PRIu64" not %" PRIu64 -" sectors." , pv_name, new_size,pv_size (pv)); +if (new_size > size) { +log_warn ("WARNING: %s: Overriding real size %s. You could lose data." , + pv_name,display_size (cmd, (uint64_t ) size)); +if (!yes &&yes_no_prompt ("%s: Requested size %s exceeds real size %s. Proceed? [y/n]: " , + pv_name,display_size (cmd, (uint64_t ) new_size), +display_size (cmd, (uint64_t ) size)) =='n' ) + goto_out; + + }else if (new_size < size) +if (!yes &&yes_no_prompt ("%s: Requested size %s is less than real size %s. Proceed? [y/n]: " , + pv_name,display_size (cmd, (uint64_t ) new_size), +display_size (cmd, (uint64_t ) size)) =='n' ) + goto_out; + +if (new_size == size) +log_verbose ("%s: Size is already %s (%" PRIu64" sectors)." , + pv_name,display_size (cmd, (uint64_t ) new_size), new_size); +else +log_warn ("WARNING: %s: Pretending size is %" PRIu64" not %" PRIu64" sectors." , + pv_name, new_size, size); size = new_size; }
liblvm/lvm_pv.c +1 -1
@@ -312,7 +312,7 @@ static int _lvm_pv_resize(const pv_t pv, uint64_t new_size)if (!vg_check_write_mode (pv->vg))return -1 ; -if (!pv_resize_single (pv->vg->cmd, pv->vg, pv, size)) { +if (!pv_resize_single (pv->vg->cmd, pv->vg, pv, size,1 )) {log_error ("PV re-size failed!" );return -1 ; }
tools/pvresize.c +1 -1
@@ -52,7 +52,7 @@ static int _pvresize_single(struct cmd_context *cmd, cmd->lockd_gl_disable =1 ; } -if (!pv_resize_single (cmd, vg, pv, params->new_size)) +if (!pv_resize_single (cmd, vg, pv, params->new_size,arg_is_set (cmd, yes_ARG))) return_ECMD_FAILED; params->done++;