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

Fix unlocking in error path of vgreduce

When vg_read fails, it internally unlocks VG if it's been locked,
so in error path we should skip unlock_vg for this case.
(user would see ugly internal warning)
This commit is contained in:
Zdenek Kabelac 2012-03-30 14:59:35 +00:00
parent ebd9225245
commit 6e826bb6a4
2 changed files with 9 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.96 -
================================
Fix unlocking volume group in vgreduce in error path.
Exit immediately if LISTEN_PID env var incorrect during systemd handover.
Detect VG name being part of the LV name in lvconvert --splitmirrors -n.
Fix exclusive lvchange running from other node. (2.02.89)

View File

@ -206,6 +206,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
int fixed = 1;
int repairing = arg_count(cmd, removemissing_ARG);
int saved_ignore_suspended_devices = ignore_suspended_devices();
int locked = 0;
if (!argc && !repairing) {
log_error("Please give volume group name and "
@ -260,6 +261,8 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
&& !arg_count(cmd, removemissing_ARG))
goto_out;
locked = !vg_read_error(vg);
if (repairing) {
if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
log_error("Volume group \"%s\" is already consistent",
@ -275,6 +278,7 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
READ_ALLOW_INCONSISTENT
| READ_ALLOW_EXPORTED);
locked |= !vg_read_error(vg);
if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
&& vg_read_error(vg) != FAILED_INCONSISTENT)
goto_out;
@ -314,7 +318,10 @@ int vgreduce(struct cmd_context *cmd, int argc, char **argv)
}
out:
init_ignore_suspended_devices(saved_ignore_suspended_devices);
unlock_and_release_vg(cmd, vg, vg_name);
if (locked)
unlock_vg(cmd, vg_name);
release_vg(vg);
return ret;