mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
- Ignore suspended devices during repair (Milan).
- Call vgreduce --removemissing (without --force) automatically to clean up bad PVs (Milan).
This commit is contained in:
parent
1bf740434a
commit
1f164ad9d0
@ -161,6 +161,12 @@ static int _remove_failed_devices(const char *device)
|
|||||||
|
|
||||||
r = lvm2_run(_lvm_handle, cmd_str);
|
r = lvm2_run(_lvm_handle, cmd_str);
|
||||||
|
|
||||||
|
if (r == 1) {
|
||||||
|
snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg);
|
||||||
|
if (lvm2_run(_lvm_handle, cmd_str) != 1)
|
||||||
|
syslog(LOG_ERR, "Unable to remove failed PVs from VG %s", vg);
|
||||||
|
}
|
||||||
|
|
||||||
dm_pool_empty(_mem_pool); /* FIXME: not safe with multiple threads */
|
dm_pool_empty(_mem_pool); /* FIXME: not safe with multiple threads */
|
||||||
return (r == 1) ? 0 : -1;
|
return (r == 1) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
@ -926,18 +926,22 @@ int lvconvert(struct cmd_context * cmd, int argc, char **argv)
|
|||||||
struct lvconvert_params lp;
|
struct lvconvert_params lp;
|
||||||
int ret = ECMD_FAILED;
|
int ret = ECMD_FAILED;
|
||||||
struct lvinfo info;
|
struct lvinfo info;
|
||||||
|
int saved_ignore_suspended_devices = ignore_suspended_devices();
|
||||||
|
|
||||||
if (!_read_params(&lp, cmd, argc, argv)) {
|
if (!_read_params(&lp, cmd, argc, argv)) {
|
||||||
stack;
|
stack;
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg_count(cmd, repair_ARG))
|
||||||
|
init_ignore_suspended_devices(1);
|
||||||
|
|
||||||
log_verbose("Checking for existing volume group \"%s\"", lp.vg_name);
|
log_verbose("Checking for existing volume group \"%s\"", lp.vg_name);
|
||||||
|
|
||||||
if (!(vg = vg_lock_and_read(cmd, lp.vg_name, NULL, LCK_VG_WRITE,
|
if (!(vg = vg_lock_and_read(cmd, lp.vg_name, NULL, LCK_VG_WRITE,
|
||||||
CLUSTERED | EXPORTED_VG | LVM_WRITE,
|
CLUSTERED | EXPORTED_VG | LVM_WRITE,
|
||||||
CORRECT_INCONSISTENT)))
|
CORRECT_INCONSISTENT)))
|
||||||
return ECMD_FAILED;
|
goto out;
|
||||||
|
|
||||||
if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) {
|
if (!(lvl = find_lv_in_vg(vg, lp.lv_name))) {
|
||||||
log_error("Logical volume \"%s\" not found in "
|
log_error("Logical volume \"%s\" not found in "
|
||||||
@ -966,6 +970,7 @@ bad:
|
|||||||
lp.wait_completion ? 0 : 1U);
|
lp.wait_completion ? 0 : 1U);
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
init_ignore_suspended_devices(saved_ignore_suspended_devices);
|
||||||
vg_release(vg);
|
vg_release(vg);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -466,6 +466,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
int consistent = 1;
|
int consistent = 1;
|
||||||
int fixed = 1;
|
int fixed = 1;
|
||||||
int repairing = arg_count(cmd, removemissing_ARG);
|
int repairing = arg_count(cmd, removemissing_ARG);
|
||||||
|
int saved_ignore_suspended_devices = ignore_suspended_devices();
|
||||||
|
|
||||||
if (!argc && !repairing) {
|
if (!argc && !repairing) {
|
||||||
log_error("Please give volume group name and "
|
log_error("Please give volume group name and "
|
||||||
@ -515,6 +516,9 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (repairing)
|
||||||
|
init_ignore_suspended_devices(1);
|
||||||
|
|
||||||
if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
|
if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
|
||||||
&& !repairing) {
|
&& !repairing) {
|
||||||
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
log_error("Volume group \"%s\" doesn't exist", vg_name);
|
||||||
@ -574,6 +578,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
|
init_ignore_suspended_devices(saved_ignore_suspended_devices);
|
||||||
unlock_and_release_vg(cmd, vg, vg_name);
|
unlock_and_release_vg(cmd, vg, vg_name);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user