[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [lvm-devel] [PATCH] Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.



On Tue, 2009-07-07 at 11:01 +0200, Milan Broz wrote:
> Dave Wysochanski wrote:
> > diff --git a/tools/vgsplit.c b/tools/vgsplit.c
> > index 9cd90b8..0dc5bc4 100644
> > --- a/tools/vgsplit.c
> > +++ b/tools/vgsplit.c
> > @@ -342,11 +342,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
> >  		existing_vg = 1;
> >  		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
> >  					   READ_REQUIRE_RESIZEABLE |
> > -					   LOCK_NONBLOCKING | LOCK_KEEP |
> > -					   READ_CHECK_EXISTENCE);
> > +					   LOCK_NONBLOCKING);
> >  
> > -		if (vg_read_error(vg_to))
> > -			goto_bad;
> > +		if (vg_read_error(vg_to)) {
> 
> 	but vg_name_to is locked by vg_lock_newname() previously?
> 	so unlock_and_release here?
> 

No - if vg_lock_newname() returns any failure code, it releases the
lock.  In this case it is FAILED_EXIST.


> 	also now code missing stack; (note goto_bad before)
> 

Right - good catch.


> > +			vg_release(vg_to);
> > +			goto bad2;
> > +		}
> >  
> 
> 
> Milan
> 
> --
> lvm-devel mailing list
> lvm-devel redhat com
> https://www.redhat.com/mailman/listinfo/lvm-devel
>From 89907a7a99469e2934258261b824b055b8f3ad4b Mon Sep 17 00:00:00 2001
From: Dave Wysochanski <dwysocha redhat com>
Date: Tue, 7 Jul 2009 09:03:17 -0400
Subject: [PATCH] Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.

Remove LOCK_KEEP and READ_CHECK_EXISTENCE from vgsplit.
These flags are no longer necessary.  We now check for existence
in a differnet function, and it is not necessary to keep the lock.
Removing these flags simplifies the new vg_read() interface.
After this patch, we can fully remove LOCK_KEEP.
READ_CHECK_EXISTENCE needs a bit more work before full removal.

Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 tools/vgsplit.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index 9cd90b8..c1a1b06 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -342,11 +342,13 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
 		existing_vg = 1;
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
 					   READ_REQUIRE_RESIZEABLE |
-					   LOCK_NONBLOCKING | LOCK_KEEP |
-					   READ_CHECK_EXISTENCE);
+					   LOCK_NONBLOCKING);
 
-		if (vg_read_error(vg_to))
-			goto_bad;
+		if (vg_read_error(vg_to)) {
+			vg_release(vg_to);
+			stack;
+			goto bad2;
+		}
 
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
@@ -483,7 +485,8 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
 	r = ECMD_PROCESSED;
 
 bad:
-	unlock_and_release_vg(cmd, vg_from, vg_name_from);
 	unlock_and_release_vg(cmd, vg_to, vg_name_to);
+bad2:
+	unlock_and_release_vg(cmd, vg_from, vg_name_from);
 	return r;
 }
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]