Skip to contentSkip to conversation

Do not try to unlock VG which is not locked.

PATCH New Milan Broz 2 participants 2 messages Nov 24, 2009

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Do not try to unlock VG which is not locked.

If the vg_read() returned error, no lock was taken, so always call vg_release().

Otherwise this can happen because of missing FAILED_*:

# vgchange -a y x --ignorelockingfailure
  Volume group "x" not found
  Internal error: Attempt to unlock unlocked VG x
---
 tools/toollib.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
tools/toollib.c +1 -2
index 39a6d69..33daf30 100644
@@ -452,8 +452,7 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
 		ret_max = ret;
 
 out:
-	if ((vg_read_error(vg) == FAILED_ALLOCATION)||
-	    (vg_read_error(vg) == FAILED_LOCKING))
+	if (vg_read_error(vg))
 		vg_release(vg);
 	else
 		unlock_and_release_vg(cmd, vg, vg_name);
Signature · 1 line
1.6.5.3
#1 lore raw

PATCH 1/1 Do not try to unlock VG which is not locked.

Hi,

Quoted 14 lines · Milan Broz
# vgchange -a y x --ignorelockingfailure
  Volume group "x" not found
  Internal error: Attempt to unlock unlocked VG x
---
 tools/toollib.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
tools/toollib.c +0 -0
index 39a6d69..33daf30 100644

tools/toollib.c static int _process_one_vg(struct cmd_context *cmd, const char *vg_name, · line 458

Quoted 9 lines
tools/toollib.c +1 -2
@@ -452,8 +452,7 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
 		ret_max = ret;
 
 out:
-	if ((vg_read_error(vg) == FAILED_ALLOCATION)||
-	    (vg_read_error(vg) == FAILED_LOCKING))
+	if (vg_read_error(vg))
 		vg_release(vg);
 	else
 		unlock_and_release_vg(cmd, vg, vg_name);

looks good to me. The error path in vg_read (metadata.c) makes sure that the VG is unlocked if any errors have happened.

=> ACK.

Yours,
Petr.