1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-27 01:55:10 +03:00

Add --mirrorsonly arg to vgreduce. (Doesn't handle mirrors yet.)

This commit is contained in:
Alasdair Kergon 2005-12-21 21:21:45 +00:00
parent 2e6d308465
commit c9dcba6b16
4 changed files with 24 additions and 3 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.02 -
====================================
Add --mirrorsonly to vgreduce.
vgreduce replaces active LVs with error segment before removing them.
Set block_on_error parameter if available.
Add target_version.

View File

@ -44,6 +44,7 @@ arg(minor_ARG, '\0', "minor", minor_arg)
arg(type_ARG, '\0', "type", segtype_arg)
arg(alloc_ARG, '\0', "alloc", alloc_arg)
arg(separator_ARG, '\0', "separator", string_arg)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)

View File

@ -770,6 +770,7 @@ xx(vgreduce,
"\t[-A|--autobackup y|n]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[--mirrorsonly]\n"
"\t[--removemissing]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
@ -777,7 +778,7 @@ xx(vgreduce,
"\tVolumeGroupName\n"
"\t[PhysicalVolumePath...]\n",
all_ARG, autobackup_ARG, removemissing_ARG, test_ARG)
all_ARG, autobackup_ARG, mirrorsonly_ARG, removemissing_ARG, test_ARG)
xx(vgremove,
"Remove volume group(s)",

View File

@ -152,8 +152,9 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
struct physical_volume *pv;
struct lv_segment *seg;
unsigned int s;
int list_unsafe;
int list_unsafe, only_mirror_images_found;
LIST_INIT(lvs_changed);
only_mirror_images_found = 1;
/* Deactivate & remove necessary LVs */
restart_loop:
@ -172,6 +173,12 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
pv = seg_pv(seg, s);
if (!pv || !pv->dev) {
if (arg_count(cmd, mirrorsonly_ARG) &&
!(lv->status & MIRROR_IMAGE)) {
log_error("Non-mirror-image LV %s found: can't remove.", lv->name);
only_mirror_images_found = 0;
continue;
}
if (!_remove_lv(cmd, lv, &list_unsafe, &lvs_changed)) {
stack;
return 0;
@ -183,6 +190,11 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
}
}
if (!only_mirror_images_found) {
log_error("Aborting because --mirrorsonly was specified.");
return 0;
}
/* Remove missing PVs */
list_iterate_safe(pvh, pvht, &vg->pvs) {
pvl = list_item(pvh, struct pv_list);
@ -235,7 +247,7 @@ static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
/* FIXME If any lvs_changed belong to mirrors, reduce those mirrors */
/* Deactivate error LVs */
if (!test_mode) {
if (!test_mode()) {
list_iterate_items(lvl, &lvs_changed) {
log_verbose("Deactivating (if active) logical volume %s",
lvl->lv->name);
@ -340,6 +352,12 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (arg_count(cmd, mirrorsonly_ARG) &&
!arg_count(cmd, removemissing_ARG)) {
log_error("--mirrorsonly requires --removemissing");
return EINVALID_CMD_LINE;
}
if (argc == 1 && !arg_count(cmd, all_ARG)
&& !arg_count(cmd, removemissing_ARG)) {
log_error("Please enter physical volume paths or option -a");