1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvresize: Prompt when non-default size supplied.

Seek confirmation before changing the PV size to one that differs
from the underlying block device.
This commit is contained in:
Alasdair G Kergon 2017-04-27 02:36:34 +01:00
parent 78a0b4a08a
commit cbc69f8c69
5 changed files with 28 additions and 10 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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++;