diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2012-03-30 14:59:35 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2012-03-30 14:59:35 +0000 |
commit | 6e826bb6a4337f4b94749d1a40cdc00b1c477b68 (patch) | |
tree | 8ec357df9e5ec20b37a280fa54524aa9fa3a5eca /tools | |
parent | ebd9225245d02c8f31bfbc6ede62f419cb4ac3b8 (diff) | |
download | lvm2-6e826bb6a4337f4b94749d1a40cdc00b1c477b68.tar.gz lvm2-6e826bb6a4337f4b94749d1a40cdc00b1c477b68.tar.xz lvm2-6e826bb6a4337f4b94749d1a40cdc00b1c477b68.zip |
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)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/vgreduce.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/vgreduce.c b/tools/vgreduce.c index 7815abe5..ab448e05 100644 --- a/tools/vgreduce.c +++ b/tools/vgreduce.c @@ -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; |