public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools vgsplit.c
@ 2009-09-02 21:26 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:26:02

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit - remove bad2 label.
	
	No functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87

--- LVM2/tools/vgsplit.c	2009/09/02 21:25:44	1.86
+++ LVM2/tools/vgsplit.c	2009/09/02 21:26:01	1.87
@@ -287,7 +287,8 @@
 		if (vg_read_error(vg_to)) {
 			vg_release(vg_to);
 			stack;
-			goto bad2;
+			unlock_and_release_vg(cmd, vg_from, vg_name_from);
+			return ECMD_FAILED;
 		}
 
 	} else if (vg_read_error(vg_to) == SUCCESS) {
@@ -427,7 +428,6 @@
 
 bad:
 	unlock_and_release_vg(cmd, vg_to, vg_name_to);
-bad2:
 	unlock_and_release_vg(cmd, vg_from, vg_name_from);
 	return r;
 }


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:27 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:27:06

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit: _vgsplit_from or _vgsplit_to failure cleanup depends on order.
	
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91

--- LVM2/tools/vgsplit.c	2009/09/02 21:26:50	1.90
+++ LVM2/tools/vgsplit.c	2009/09/02 21:27:05	1.91
@@ -315,8 +315,11 @@
 	}
 
 	vg_from = _vgsplit_from(cmd, vg_name_from);
-	if (!vg_from)
+	if (!vg_from) {
+		if (!lock_vg_from_first)
+			unlock_and_release_vg(cmd, vg_to, vg_name_to);
 		return ECMD_FAILED;
+	}
 
 	/*
 	 * Set metadata format of original VG.
@@ -327,7 +330,8 @@
 
 	vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
 	if (!vg_to) {
-		unlock_and_release_vg(cmd, vg_from, vg_name_from);
+		if (lock_vg_from_first)
+			unlock_and_release_vg(cmd, vg_from, vg_name_from);
 		return ECMD_FAILED;
 	}
 	if (existing_vg) {


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:27 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:27:39

Modified files:
	tools          : vgsplit.c 

Log message:
	Change vgsplit behavior to open/lock first vg based on alphabetical ordering.
	
	If the destination vgname comes before the source vgname, we must open the
	destination first because of the locking rules.  Thus, do a strcmp and set
	the flag based on the comparison.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93

--- LVM2/tools/vgsplit.c	2009/09/02 21:27:22	1.92
+++ LVM2/tools/vgsplit.c	2009/09/02 21:27:39	1.93
@@ -314,6 +314,9 @@
 		return ECMD_FAILED;
 	}
 
+	if (strcmp(vg_name_to, vg_name_from) < 0)
+		lock_vg_from_first = 0;
+
 	if (lock_vg_from_first) {
 		vg_from = _vgsplit_from(cmd, vg_name_from);
 		if (!vg_from)


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:26 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:26:34

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit - create _vgsplit_to function which creates or opens dest vg.
	
	Move the creating/opening of the destination vg into its own function so later
	we can reorder the source / destination vg opening based on the alphabetical
	lock order rule.
	
	Should be no functional change but code is a bit tricky.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89

--- LVM2/tools/vgsplit.c	2009/09/02 21:26:18	1.88
+++ LVM2/tools/vgsplit.c	2009/09/02 21:26:34	1.89
@@ -198,6 +198,52 @@
 }
 
 /*
+ * Create or open the destination of the vgsplit operation.
+ * Returns
+ * - non-NULL: VG handle w/VG lock held
+ * - NULL: no VG lock held
+ */
+static struct volume_group *_vgsplit_to(struct cmd_context *cmd,
+					const char *vg_name_to,
+					int *existing_vg)
+{
+	struct volume_group *vg_to = NULL;
+
+	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
+	/*
+	 * First try to create a new VG.  If we cannot create it,
+	 * and we get FAILED_EXIST (we will not be holding a lock),
+	 * a VG must already exist with this name.  We then try to
+	 * read the existing VG - the vgsplit will be into an existing VG.
+	 *
+	 * Otherwise, if the lock was successful, it must be the case that
+	 * we obtained a WRITE lock and could not find the vgname in the
+	 * system.  Thus, the split will be into a new VG.
+	 */
+	vg_to = vg_create(cmd, vg_name_to);
+	if (vg_read_error(vg_to) == FAILED_LOCKING) {
+		log_error("Can't get lock for %s", vg_name_to);
+		vg_release(vg_to);
+		return NULL;
+	}
+	if (vg_read_error(vg_to) == FAILED_EXIST) {
+		*existing_vg = 1;
+		vg_release(vg_to);
+		vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
+
+		if (vg_read_error(vg_to)) {
+			vg_release(vg_to);
+			stack;
+			return NULL;
+		}
+
+	} else if (vg_read_error(vg_to) == SUCCESS) {
+		*existing_vg = 0;
+	}
+	return vg_to;
+}
+
+/*
  * Has the user given an option related to a new vg as the split destination?
  */
 static int new_vg_option_specified(struct cmd_context *cmd)
@@ -262,40 +308,11 @@
 	 */
 	cmd->fmt = vg_from->fid->fmt;
 
-	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
-	/*
-	 * First try to create a new VG.  If we cannot create it,
-	 * and we get FAILED_EXIST (we will not be holding a lock),
-	 * a VG must already exist with this name.  We then try to
-	 * read the existing VG - the vgsplit will be into an existing VG.
-	 *
-	 * Otherwise, if the lock was successful, it must be the case that
-	 * we obtained a WRITE lock and could not find the vgname in the
-	 * system.  Thus, the split will be into a new VG.
-	 */
-	vg_to = vg_create(cmd, vg_name_to);
-	if (vg_read_error(vg_to) == FAILED_LOCKING) {
-		log_error("Can't get lock for %s", vg_name_to);
-		vg_release(vg_to);
+	vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
+	if (!vg_to) {
 		unlock_and_release_vg(cmd, vg_from, vg_name_from);
 		return ECMD_FAILED;
 	}
-	if (vg_read_error(vg_to) == FAILED_EXIST) {
-		existing_vg = 1;
-		vg_release(vg_to);
-		vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
-
-		if (vg_read_error(vg_to)) {
-			vg_release(vg_to);
-			stack;
-			unlock_and_release_vg(cmd, vg_from, vg_name_from);
-			return ECMD_FAILED;
-		}
-
-	} else if (vg_read_error(vg_to) == SUCCESS) {
-		existing_vg = 0;
-	}
-
 	if (existing_vg) {
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:26 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:26:50

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit - create _vgsplit_from function to open source vg.
	
	Should be no functional change and allows future reorder of source and dest
	vgs.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90

--- LVM2/tools/vgsplit.c	2009/09/02 21:26:34	1.89
+++ LVM2/tools/vgsplit.c	2009/09/02 21:26:50	1.90
@@ -244,6 +244,27 @@
 }
 
 /*
+ * Open the source of the vgsplit operation.
+ * Returns
+ * - non-NULL: VG handle w/VG lock held
+ * - NULL: no VG lock held
+ */
+static struct volume_group *_vgsplit_from(struct cmd_context *cmd,
+					  const char *vg_name_from)
+{
+	struct volume_group *vg_from;
+
+	log_verbose("Checking for volume group \"%s\"", vg_name_from);
+
+	vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
+	if (vg_read_error(vg_from)) {
+		vg_release(vg_from);
+		return NULL;
+	}
+	return vg_from;
+}
+
+/*
  * Has the user given an option related to a new vg as the split destination?
  */
 static int new_vg_option_specified(struct cmd_context *cmd)
@@ -293,13 +314,9 @@
 		return ECMD_FAILED;
 	}
 
-	log_verbose("Checking for volume group \"%s\"", vg_name_from);
-
-	vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
-	if (vg_read_error(vg_from)) {
-		vg_release(vg_from);
+	vg_from = _vgsplit_from(cmd, vg_name_from);
+	if (!vg_from)
 		return ECMD_FAILED;
-	}
 
 	/*
 	 * Set metadata format of original VG.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:26 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:26:18

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit - add 'lock_vg_from_first' flag.
	
	Introduce 'lock_vg_from_first' flag to retain which vg was locked first.
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88

--- LVM2/tools/vgsplit.c	2009/09/02 21:26:01	1.87
+++ LVM2/tools/vgsplit.c	2009/09/02 21:26:18	1.88
@@ -218,6 +218,7 @@
 	int existing_vg = 0;
 	int r = ECMD_FAILED;
 	const char *lv_name;
+	int lock_vg_from_first = 1;
 
 	if ((arg_count(cmd, name_ARG) + argc) < 3) {
 		log_error("Existing VG, new VG and either physical volumes "
@@ -427,7 +428,12 @@
 	r = ECMD_PROCESSED;
 
 bad:
-	unlock_and_release_vg(cmd, vg_to, vg_name_to);
-	unlock_and_release_vg(cmd, vg_from, vg_name_from);
+	if (lock_vg_from_first) {
+		unlock_and_release_vg(cmd, vg_to, vg_name_to);
+		unlock_and_release_vg(cmd, vg_from, vg_name_from);
+	} else {
+		unlock_and_release_vg(cmd, vg_from, vg_name_from);
+		unlock_and_release_vg(cmd, vg_to, vg_name_to);
+	}
 	return r;
 }


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-09-02 21:25 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-09-02 21:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-09-02 21:25:45

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit to move existing_vg logic in a separate 'if' statement.
	
	This will aid in future refactorings and allow for us to reorder the source
	and destination vg based on alphabetical names.
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86

--- LVM2/tools/vgsplit.c	2009/07/14 02:16:05	1.85
+++ LVM2/tools/vgsplit.c	2009/09/02 21:25:44	1.86
@@ -290,6 +290,11 @@
 			goto bad2;
 		}
 
+	} else if (vg_read_error(vg_to) == SUCCESS) {
+		existing_vg = 0;
+	}
+
+	if (existing_vg) {
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
 				    "option specified", vg_name_to);
@@ -297,9 +302,7 @@
 		}
 		if (!vgs_are_compatible(cmd, vg_from,vg_to))
 			goto_bad;
-	} else if (vg_read_error(vg_to) == SUCCESS) {
-		existing_vg = 0;
-
+	} else {
 		vp_def.vg_name = NULL;
 		vp_def.extent_size = vg_from->extent_size;
 		vp_def.max_pv = vg_from->max_pv;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-07-09  5:41 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-07-09  5:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-09 05:40:59

Modified files:
	tools          : vgsplit.c 

Log message:
	Fix memory leak in vgsplit when re-reading the VG.
	
	Call vg_release() before re-reading the vg.
	Remove vgsplit whitespace and update copyright.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81

--- LVM2/tools/vgsplit.c	2009/07/08 14:33:17	1.80
+++ LVM2/tools/vgsplit.c	2009/07/09 05:40:59	1.81
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -100,7 +100,7 @@
 	struct logical_volume *lv = dm_list_item(lvh, struct lv_list)->lv;
 
 	dm_list_move(&vg_to->lvs, lvh);
-	
+
 	if (lv_is_active(lv)) {
 		log_error("Logical volume \"%s\" must be inactive", lv->name);
 		return 0;
@@ -162,7 +162,7 @@
 			}
 
 		}
-			
+
 		if (vg_with == vg_from)
 			continue;
 
@@ -245,7 +245,7 @@
 			    seg_in++;
 
 		log_in = (!seg->log_lv || _lv_is_in_vg(vg_to, seg->log_lv));
-		
+
 		if ((seg_in && seg_in < seg->area_count) ||
 		    (seg_in && seg->log_lv && !log_in) ||
 		    (!seg_in && seg->log_lv && log_in)) {
@@ -461,6 +461,7 @@
 	 * Finally, remove the EXPORTED flag from the new VG and write it out.
 	 */
 	if (!test_mode()) {
+		vg_release(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
 					   READ_ALLOW_EXPORTED);
 		if (vg_read_error(vg_to)) {


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-07-08 14:27 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-07-08 14:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-08 14:27:38

Modified files:
	tools          : vgsplit.c 

Log message:
	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>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/tools/vgsplit.c	2009/07/07 01:18:35	1.78
+++ LVM2/tools/vgsplit.c	2009/07/08 14:27:37	1.79
@@ -342,11 +342,13 @@
 		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 @@
 	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;
 }


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-07-01 17:04 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-07-01 17:04 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-01 17:04:22

Modified files:
	tools          : vgsplit.c 

Log message:
	Convert vgsplit to use vg_read_for_update.
	
	Sun May  3 13:12:28 CEST 2009  Petr Rockai <me@mornfall.net>
	* Convert vgsplit to use vg_read_for_update.
	
	Author: Petr Rockai <prockai@redhat.com>
	Committer: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77

--- LVM2/tools/vgsplit.c	2009/06/10 11:21:10	1.76
+++ LVM2/tools/vgsplit.c	2009/07/01 17:04:21	1.77
@@ -282,7 +282,6 @@
 	struct volume_group *vg_to = NULL, *vg_from = NULL;
 	int opt;
 	int existing_vg = 0;
-	int consistent;
 	int r = ECMD_FAILED;
 	const char *lv_name;
 	uint32_t rc;
@@ -315,11 +314,11 @@
 	}
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_from);
-	if (!(vg_from = vg_lock_and_read(cmd, vg_name_from, NULL, LCK_VG_WRITE,
-				       CLUSTERED | EXPORTED_VG |
-				       RESIZEABLE_VG | LVM_WRITE,
-				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
-		 return ECMD_FAILED;
+
+	vg_from = vg_read_for_update(cmd, vg_name_from, NULL,
+				     READ_REQUIRE_RESIZEABLE);
+	if (vg_read_error(vg_from))
+		return ECMD_FAILED;
 
 	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
 	/*
@@ -339,12 +338,14 @@
 	}
 	if (rc == FAILED_EXIST) {
 		existing_vg = 1;
-		if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL,
-					       LCK_VG_WRITE,
-					       CLUSTERED | EXPORTED_VG |
-					       RESIZEABLE_VG | LVM_WRITE,
-					       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
-			return ECMD_FAILED;
+		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
+					   READ_REQUIRE_RESIZEABLE |
+					   LOCK_NONBLOCKING | LOCK_KEEP |
+					   READ_CHECK_EXISTENCE);
+
+		if (vg_read_error(vg_to))
+			goto_bad;
+
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
 				    "option specified", vg_name_to);
@@ -456,13 +457,12 @@
 	/*
 	 * Finally, remove the EXPORTED flag from the new VG and write it out.
 	 */
-	consistent = 1;
 	if (!test_mode()) {
-		vg_release(vg_to);
-		if (!(vg_to = vg_read_internal(cmd, vg_name_to, NULL, &consistent)) ||
-		    !consistent) {
-			log_error("Volume group \"%s\" became inconsistent: please "
-				  "fix manually", vg_name_to);
+		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
+					   READ_ALLOW_EXPORTED);
+		if (vg_read_error(vg_to)) {
+			log_error("Volume group \"%s\" became inconsistent: "
+				  "please fix manually", vg_name_to);
 			goto_bad;
 		}
 	}


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-06-10 11:21 mbroz
  0 siblings, 0 replies; 22+ messages in thread
From: mbroz @ 2009-06-10 11:21 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-10 11:21:10

Modified files:
	tools          : vgsplit.c 

Log message:
	Fix compiler warning.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76

--- LVM2/tools/vgsplit.c	2009/06/09 14:31:20	1.75
+++ LVM2/tools/vgsplit.c	2009/06/10 11:21:10	1.76
@@ -281,7 +281,7 @@
 	char *vg_name_from, *vg_name_to;
 	struct volume_group *vg_to = NULL, *vg_from = NULL;
 	int opt;
-	int existing_vg;
+	int existing_vg = 0;
 	int consistent;
 	int r = ECMD_FAILED;
 	const char *lv_name;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2009-06-09 14:31 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2009-06-09 14:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-06-09 14:31:21

Modified files:
	tools          : vgsplit.c 

Log message:
	Update vgsplit to use new vg_reserve_newname() function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75

--- LVM2/tools/vgsplit.c	2009/05/21 03:04:54	1.74
+++ LVM2/tools/vgsplit.c	2009/06/09 14:31:20	1.75
@@ -285,6 +285,7 @@
 	int consistent;
 	int r = ECMD_FAILED;
 	const char *lv_name;
+	uint32_t rc;
 
 	if ((arg_count(cmd, name_ARG) + argc) < 3) {
 		log_error("Existing VG, new VG and either physical volumes "
@@ -321,15 +322,29 @@
 		 return ECMD_FAILED;
 
 	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
-	if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE)) {
+	/*
+	 * Try to lock the name of the new VG.  If we cannot reserve it,
+	 * then we assume it exists, and we will not be holding a lock.
+	 * We then try to read it - the vgsplit will be into an existing VG.
+	 *
+	 * Otherwise, if the lock was successful, it must be the case that
+	 * we obtained a WRITE lock and could not find the vgname in the
+	 * system.  Thus, the split will be into a new VG.
+	 */
+	rc = vg_lock_newname(cmd, vg_name_to);
+	if (rc == FAILED_LOCKING) {
 		log_error("Can't get lock for %s", vg_name_to);
 		unlock_and_release_vg(cmd, vg_from, vg_name_from);
 		return ECMD_FAILED;
 	}
-
-	consistent = 0;
-	if ((vg_to = vg_read_internal(cmd, vg_name_to, NULL, &consistent))) {
+	if (rc == FAILED_EXIST) {
 		existing_vg = 1;
+		if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL,
+					       LCK_VG_WRITE,
+					       CLUSTERED | EXPORTED_VG |
+					       RESIZEABLE_VG | LVM_WRITE,
+					       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
+			return ECMD_FAILED;
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
 				    "option specified", vg_name_to);
@@ -337,7 +352,7 @@
 		}
 		if (!vgs_are_compatible(cmd, vg_from,vg_to))
 			goto_bad;
-	} else {
+	} else if (rc == SUCCESS) {
 		existing_vg = 0;
 
 		/* Set metadata format of original VG */


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-04-15 14:57 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-04-15 14:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-15 14:57:12

Modified files:
	tools          : vgsplit.c 

Log message:
	missing stack

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66

--- LVM2/tools/vgsplit.c	2008/04/10 21:34:53	1.65
+++ LVM2/tools/vgsplit.c	2008/04/15 14:57:12	1.66
@@ -175,7 +175,7 @@
 
 		/* Move this LV */
 		if (!_move_one_lv(vg_from, vg_to, lvh))
-			return 0;
+			return_0;
 	}
 
 	/* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */
@@ -221,7 +221,7 @@
 			if (_lv_is_in_vg(vg_to, seg->cow) &&
 			    _lv_is_in_vg(vg_to, seg->origin)) {
 				if (!_move_one_lv(vg_from, vg_to, lvh))
-					return 0;
+					return_0;
 			}
 		}
 
@@ -263,7 +263,7 @@
 
 		if (seg_in == seg->area_count && log_in) {
 			if (!_move_one_lv(vg_from, vg_to, lvh))
-				return 0;
+				return_0;
 		}
 	}
 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-04-10 21:34 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-04-10 21:34 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-04-10 21:34:53

Modified files:
	tools          : vgsplit.c 

Log message:
	Update vgsplit to only restrict split with active LVs involved in split.
	
	Existing code will reject a vgsplit if any LVs in the source VG are active.
	This patch updates vgsplit to only check LVs involved in the split.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65

--- LVM2/tools/vgsplit.c	2008/04/10 20:02:04	1.64
+++ LVM2/tools/vgsplit.c	2008/04/10 21:34:53	1.65
@@ -93,7 +93,7 @@
 	return 0;
 }
 
-static void _move_one_lv(struct volume_group *vg_from,
+static int _move_one_lv(struct volume_group *vg_from,
 			 struct volume_group *vg_to,
 			 struct list *lvh)
 {
@@ -101,6 +101,11 @@
 
 	list_move(&vg_to->lvs, lvh);
 	
+	if (lv_is_active(lv)) {
+		log_error("Logical volume \"%s\" must be inactive", lv->name);
+		return 0;
+	}
+
 	if (lv->status & SNAPSHOT) {
 		vg_from->snapshot_count--;
 		vg_to->snapshot_count++;
@@ -108,6 +113,7 @@
 		vg_from->lv_count--;
 		vg_to->lv_count++;
 	}
+	return 1;
 }	
 
 static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
@@ -168,7 +174,8 @@
 			continue;
 
 		/* Move this LV */
-		_move_one_lv(vg_from, vg_to, lvh);
+		if (!_move_one_lv(vg_from, vg_to, lvh))
+			return 0;
 	}
 
 	/* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */
@@ -212,8 +219,10 @@
 			 * in vg_to.
 			 */
 			if (_lv_is_in_vg(vg_to, seg->cow) &&
-			    _lv_is_in_vg(vg_to, seg->origin))
-				_move_one_lv(vg_from, vg_to, lvh);
+			    _lv_is_in_vg(vg_to, seg->origin)) {
+				if (!_move_one_lv(vg_from, vg_to, lvh))
+					return 0;
+			}
 		}
 
 	}
@@ -252,8 +261,10 @@
 			return 0;
 		}
 
-		if (seg_in == seg->area_count && log_in)
-			_move_one_lv(vg_from, vg_to, lvh);
+		if (seg_in == seg->area_count && log_in) {
+			if (!_move_one_lv(vg_from, vg_to, lvh))
+				return 0;
+		}
 	}
 
 	return 1;
@@ -277,7 +288,6 @@
 	char *vg_name_from, *vg_name_to;
 	struct volume_group *vg_to, *vg_from;
 	int opt;
-	int active;
 	int existing_vg;
 	int consistent;
 	const char *lv_name;
@@ -316,14 +326,6 @@
 				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return ECMD_FAILED;
 
-	if ((active = lvs_in_vg_activated(vg_from))) {
-		/* FIXME Remove this restriction */
-		log_error("Logical volumes in \"%s\" must be inactive",
-			  vg_name_from);
-		unlock_vg(cmd, vg_name_from);
-		return ECMD_FAILED;
-	}
-
 	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
 	if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE | LCK_NONBLOCK)) {
 		log_error("Can't get lock for %s", vg_name_to);


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-04-10 20:02 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2008-04-10 20:02 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-04-10 20:02:04

Modified files:
	tools          : vgsplit.c 

Log message:
	.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64

--- LVM2/tools/vgsplit.c	2008/04/10 19:59:43	1.63
+++ LVM2/tools/vgsplit.c	2008/04/10 20:02:04	1.64
@@ -252,10 +252,8 @@
 			return 0;
 		}
 
-		if (seg_in == seg->area_count && log_in) {
-			if (!_move_one_lv(vg_from, vg_to, lvh))
-				return 0;
-		}
+		if (seg_in == seg->area_count && log_in)
+			_move_one_lv(vg_from, vg_to, lvh);
 	}
 
 	return 1;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-04-10  2:15 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-04-10  2:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-04-10 02:15:56

Modified files:
	tools          : vgsplit.c 

Log message:
	Minor vgsplit cleanups.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60

--- LVM2/tools/vgsplit.c	2008/04/10 01:30:22	1.59
+++ LVM2/tools/vgsplit.c	2008/04/10 02:15:56	1.60
@@ -33,7 +33,7 @@
 	vg_from->pv_count--;
 	vg_to->pv_count++;
 
-	pv = list_item(pvl, struct pv_list)->pv;
+	pv = pvl->pv;
 
 	vg_from->extent_count -= pv_pe_count(pv);
 	vg_to->extent_count += pv_pe_count(pv);
@@ -100,8 +100,7 @@
 	struct logical_volume *lv;
 
 	lv = list_item(lvh, struct lv_list)->lv;
-	list_del(lvh);
-	list_add(&vg_to->lvs, lvh);
+	list_move(lvh, &vg_to->lvs);
 	
 	if (lv->status & SNAPSHOT) {
 		vg_from->snapshot_count--;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-04-10  1:30 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-04-10  1:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-04-10 01:30:22

Modified files:
	tools          : vgsplit.c 

Log message:
	Add _move_one_lv() helper function for vgsplit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59

--- LVM2/tools/vgsplit.c	2008/04/09 20:56:06	1.58
+++ LVM2/tools/vgsplit.c	2008/04/10 01:30:22	1.59
@@ -93,6 +93,25 @@
 	return 0;
 }
 
+static int _move_one_lv(struct volume_group *vg_from,
+			struct volume_group *vg_to,
+			struct list *lvh)
+{
+	struct logical_volume *lv;
+
+	lv = list_item(lvh, struct lv_list)->lv;
+	list_del(lvh);
+	list_add(&vg_to->lvs, lvh);
+	
+	if (lv->status & SNAPSHOT) {
+		vg_from->snapshot_count--;
+		vg_to->snapshot_count++;
+	} else {
+		vg_from->lv_count--;
+		vg_to->lv_count++;
+	}
+	return 1;
+}	
 
 static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
 {
@@ -152,11 +171,8 @@
 			continue;
 
 		/* Move this LV */
-		list_del(lvh);
-		list_add(&vg_to->lvs, lvh);
-
-		vg_from->lv_count--;
-		vg_to->lv_count++;
+		if (!_move_one_lv(vg_from, vg_to, lvh))
+			return 0;
 	}
 
 	/* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */
@@ -201,11 +217,8 @@
 			 */
 			if (_lv_is_in_vg(vg_to, seg->cow) &&
 			    _lv_is_in_vg(vg_to, seg->origin)) {
-				list_del(lvh);
-				list_add(&vg_to->lvs, lvh);
-				
-				vg_from->snapshot_count--;
-				vg_to->snapshot_count++;
+				if (!_move_one_lv(vg_from, vg_to, lvh))
+					return 0;
 			}
 		}
 
@@ -246,11 +259,8 @@
 		}
 
 		if (seg_in == seg->area_count && log_in) {
-			list_del(lvh);
-			list_add(&vg_to->lvs, lvh);
-
-			vg_from->lv_count--;
-			vg_to->lv_count++;
+			if (!_move_one_lv(vg_from, vg_to, lvh))
+				return 0;
 		}
 	}
 


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-02-29  0:13 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-02-29  0:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-02-29 00:13:48

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor _move_pv() in vgsplit.
	Should be no functional change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51

--- LVM2/tools/vgsplit.c	2008/01/30 14:00:02	1.50
+++ LVM2/tools/vgsplit.c	2008/02/29 00:13:48	1.51
@@ -15,18 +15,11 @@
 
 #include "tools.h"
 
-static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
-		    char *pv_name)
+static void _move_pv(struct volume_group *vg_from, struct volume_group *vg_to,
+		     struct pv_list *pvl)
 {
-	struct pv_list *pvl;
 	struct physical_volume *pv;
 
-	if (!(pvl = find_pv_in_vg(vg_from, pv_name))) {
-		log_error("Physical volume %s not in volume group %s",
-			  pv_name, vg_from->name);
-		return 0;
-	}
-
 	list_del(&pvl->list);
 	list_add(&vg_to->pvs, &pvl->list);
 
@@ -40,8 +33,6 @@
 
 	vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
 	vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv);
-
-	return 1;
 }
 
 /* FIXME Why not (lv->vg == vg) ? */
@@ -230,6 +221,7 @@
 	int opt;
 	int active;
 	int existing_vg;
+	struct pv_list *pvl;
 
 	if (argc < 3) {
 		log_error("Existing VG, new VG and physical volumes required.");
@@ -312,8 +304,13 @@
 
 	/* Move PVs across to new structure */
 	for (opt = 0; opt < argc; opt++) {
-		if (!_move_pv(vg_from, vg_to, argv[opt]))
+		if (!(pvl = find_pv_in_vg(vg_from, argv[opt]))) {
+			log_error("Physical volume %s not in volume group %s",
+				  argv[opt], vg_from->name);
 			goto error;
+		}
+
+		_move_pv(vg_from, vg_to, pvl);
 	}
 
 	/* Move required LVs across, checking consistency */


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-01-22  3:49 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-01-22  3:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-01-22 03:49:39

Modified files:
	tools          : vgsplit.c 

Log message:
	Fix vgsplit test mode

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49

--- LVM2/tools/vgsplit.c	2008/01/22 03:25:45	1.48
+++ LVM2/tools/vgsplit.c	2008/01/22 03:49:39	1.49
@@ -361,7 +361,8 @@
 	}
 
 	/* Remove EXPORTED flag from new VG */
-	if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, LCK_NONE, 0,
+	if (!test_mode() &&
+	    !(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, LCK_NONE, 0,
 				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
 		log_error("Volume group \"%s\" became inconsistent: please "
 			  "fix manually", vg_name_to);


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2008-01-11 20:17 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2008-01-11 20:17 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-01-11 20:17:19

Modified files:
	tools          : vgsplit.c 

Log message:
	Refactor vgsplit for accepting existing vg as destination

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42

--- LVM2/tools/vgsplit.c	2007/11/15 21:59:11	1.41
+++ LVM2/tools/vgsplit.c	2008/01/11 20:17:18	1.42
@@ -239,6 +239,14 @@
 				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return ECMD_FAILED;
 
+	if ((active = lvs_in_vg_activated(vg_from))) {
+		/* FIXME Remove this restriction */
+		log_error("Logical volumes in \"%s\" must be inactive",
+			  vg_name_from);
+		unlock_vg(cmd, vg_name_from);
+		return ECMD_FAILED;
+	}
+
 	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
 	if ((vg_to = vg_lock_and_read(cmd, vg_name_to, NULL,
 				      LCK_VG_WRITE | LCK_NONBLOCK,
@@ -249,13 +257,6 @@
 		return ECMD_FAILED;
 	}
 
-	if ((active = lvs_in_vg_activated(vg_from))) {
-		/* FIXME Remove this restriction */
-		log_error("Logical volumes in \"%s\" must be inactive",
-			  vg_name_from);
-		goto error;
-	}
-
 	/* Set metadata format of original VG */
 	/* FIXME: need some common logic */
 	cmd->fmt = vg_from->fid->fmt;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2007-11-15  2:53 agk
  0 siblings, 0 replies; 22+ messages in thread
From: agk @ 2007-11-15  2:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-11-15 02:53:50

Modified files:
	tools          : vgsplit.c 

Log message:
	another vg_lock_and_read

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40

--- LVM2/tools/vgsplit.c	2007/11/15 02:20:03	1.39
+++ LVM2/tools/vgsplit.c	2007/11/15 02:53:49	1.40
@@ -216,7 +216,6 @@
 	struct volume_group *vg_to, *vg_from;
 	int opt;
 	int active;
-	int consistent = 1;
 
 	if (argc < 3) {
 		log_error("Existing VG, new VG and physical volumes required.");
@@ -240,27 +239,15 @@
 				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))
 		 return ECMD_FAILED;
 
-	log_verbose("Checking for volume group \"%s\"", vg_name_to);
-	if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE | LCK_NONBLOCK)) {
-		log_error("Can't get lock for %s", vg_name_to);
-		unlock_vg(cmd, vg_name_from);
-		return ECMD_FAILED;
-	}
-
-	if (!validate_new_vg_name(cmd, vg_name_to)) {
-		log_error("New volume group name \"%s\" is invalid",
-			   vg_name_to);
+	log_verbose("Checking for new volume group \"%s\"", vg_name_to);
+	if ((vg_to = vg_lock_and_read(cmd, vg_name_to, NULL,
+				      LCK_VG_WRITE | LCK_NONBLOCK,
+				      0, 0))) {
+		log_error("Volume group \"%s\" already exists", vg_name_to);
 		unlock_vg(cmd, vg_name_from);
 		return ECMD_FAILED;
 	}
 
-	consistent = 0;
-	if ((vg_to = vg_read(cmd, vg_name_to, NULL, &consistent))) {
-		/* FIXME Remove this restriction */
-		log_error("Volume group \"%s\" already exists", vg_name_to);
-		goto error;
-	}
-
 	if ((active = lvs_in_vg_activated(vg_from))) {
 		/* FIXME Remove this restriction */
 		log_error("Logical volumes in \"%s\" must be inactive",
@@ -336,8 +323,8 @@
 	}
 
 	/* Remove EXPORTED flag from new VG */
-	consistent = 1;
-	if (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) || !consistent) {
+	if (!(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, LCK_NONE, 0,
+				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) {
 		log_error("Volume group \"%s\" became inconsistent: please "
 			  "fix manually", vg_name_to);
 		goto error;


^ permalink raw reply	[flat|nested] 22+ messages in thread

* LVM2/tools vgsplit.c
@ 2007-07-23 21:10 wysochanski
  0 siblings, 0 replies; 22+ messages in thread
From: wysochanski @ 2007-07-23 21:10 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-07-23 21:10:36

Modified files:
	tools          : vgsplit.c 

Log message:
	Fix error introduced with previous checkin

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34

--- LVM2/tools/vgsplit.c	2007/07/23 21:03:42	1.33
+++ LVM2/tools/vgsplit.c	2007/07/23 21:10:36	1.34
@@ -240,7 +240,7 @@
 	}
 
 	log_verbose("Checking for volume group \"%s\"", vg_name_from);
-	if (!(vg_to = vg_lock_and_read(cmd, vg_name_from, LCK_VG_WRITE,
+	if (!(vg_from = vg_lock_and_read(cmd, vg_name_from, LCK_VG_WRITE,
 				       CLUSTERED | EXPORTED_VG |
 				       RESIZEABLE_VG | LVM_WRITE,
 				       CORRECT_INCONSISTENT | FAIL_INCONSISTENT)))


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2009-09-02 21:27 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 21:26 LVM2/tools vgsplit.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2009-09-02 21:27 wysochanski
2009-09-02 21:27 wysochanski
2009-09-02 21:26 wysochanski
2009-09-02 21:26 wysochanski
2009-09-02 21:26 wysochanski
2009-09-02 21:25 wysochanski
2009-07-09  5:41 wysochanski
2009-07-08 14:27 wysochanski
2009-07-01 17:04 wysochanski
2009-06-10 11:21 mbroz
2009-06-09 14:31 wysochanski
2008-04-15 14:57 agk
2008-04-10 21:34 wysochanski
2008-04-10 20:02 agk
2008-04-10  2:15 wysochanski
2008-04-10  1:30 wysochanski
2008-02-29  0:13 wysochanski
2008-01-22  3:49 wysochanski
2008-01-11 20:17 wysochanski
2007-11-15  2:53 agk
2007-07-23 21:10 wysochanski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).