public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools vgmerge.c
@ 2009-09-02 21:27 wysochanski
  0 siblings, 0 replies; 5+ 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:55

Modified files:
	tools          : vgmerge.c 

Log message:
	Refactor vgmerge - introduce lock_vg_from_first flag.
	
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

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

--- LVM2/tools/vgmerge.c	2009/07/08 14:33:17	1.60
+++ LVM2/tools/vgmerge.c	2009/09/02 21:27:55	1.61
@@ -21,6 +21,7 @@
 	struct volume_group *vg_to, *vg_from;
 	struct lv_list *lvl1, *lvl2;
 	int r = ECMD_FAILED;
+	int lock_vg_from_first = 0;
 
 	if (!strcmp(vg_name_to, vg_name_from)) {
 		log_error("Duplicate volume group name \"%s\"", vg_name_from);
@@ -116,8 +117,13 @@
 		  vg_from->name, vg_to->name);
 	r = ECMD_PROCESSED;
 bad:
-	unlock_and_release_vg(cmd, vg_from, vg_name_from);
-	unlock_and_release_vg(cmd, vg_to, vg_name_to);
+	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] 5+ messages in thread

* LVM2/tools vgmerge.c
@ 2010-06-28 20:39 wysochanski
  0 siblings, 0 replies; 5+ messages in thread
From: wysochanski @ 2010-06-28 20:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2010-06-28 20:39:08

Modified files:
	tools          : vgmerge.c 

Log message:
	Update _vgmerge_single() to move fid->metadata_areas_ignored.
	
	When vgmerge is called we move the mdas from the source to the
	destination.  With metadata balancing we now have another mda
	list, fid->metadata_areas_ignored, so move the mdas on this list
	as well.
	
	This patch should not matter as the code is written today.  However
	we include it for completeness in the case that _vgmerge_single()
	is refactored and/or moved into a library function.
	
	Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68

--- LVM2/tools/vgmerge.c	2010/06/28 20:32:47	1.67
+++ LVM2/tools/vgmerge.c	2010/06/28 20:39:08	1.68
@@ -126,6 +126,12 @@
 		dm_list_move(&vg_to->fid->metadata_areas_in_use, mdah);
 	}
 
+	while (!dm_list_empty(&vg_from->fid->metadata_areas_ignored)) {
+		struct dm_list *mdah = vg_from->fid->metadata_areas_ignored.n;
+
+		dm_list_move(&vg_to->fid->metadata_areas_ignored, mdah);
+	}
+
 	vg_to->extent_count += vg_from->extent_count;
 	vg_to->free_count += vg_from->free_count;
 


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

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

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

Modified files:
	tools          : vgmerge.c 

Log message:
	Refactor vgmerge - create _vgmerge_from and _vgmerge_to.
	
	These functions are really identical but for clarity I made them separate
	functions in this patch.
	
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62

--- LVM2/tools/vgmerge.c	2009/09/02 21:27:55	1.61
+++ LVM2/tools/vgmerge.c	2009/09/02 21:28:10	1.62
@@ -15,6 +15,33 @@
 
 #include "tools.h"
 
+static struct volume_group *_vgmerge_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;
+}
+
+static struct volume_group *_vgmerge_to(struct cmd_context *cmd,
+					const char *vg_name_to)
+{
+	struct volume_group *vg_to;
+
+	log_verbose("Checking for volume group \"%s\"", vg_name_to);
+	vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
+	if (vg_read_error(vg_to)) {
+		vg_release(vg_to);
+		return NULL;
+	}
+	return vg_to;
+}
+
 static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
 			   const char *vg_name_from)
 {
@@ -28,17 +55,12 @@
 		return ECMD_FAILED;
 	}
 
-	log_verbose("Checking for volume group \"%s\"", vg_name_to);
-	vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
-	if (vg_read_error(vg_to)) {
-		vg_release(vg_to);
+	vg_to = _vgmerge_to(cmd, vg_name_to);
+	if (!vg_to)
 		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 = _vgmerge_from(cmd, vg_name_from);
+	if (!vg_from) {
 		unlock_and_release_vg(cmd, vg_to, vg_name_to);
 		return ECMD_FAILED;
 	}


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

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

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

Modified files:
	tools          : vgmerge.c 

Log message:
	Refactor vgmerge - combine _vgmerge_to and _vgmerge_from into _vgmerge_vg_read.
	
	These functions are identical so should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

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

--- LVM2/tools/vgmerge.c	2009/09/02 21:28:10	1.62
+++ LVM2/tools/vgmerge.c	2009/09/02 21:28:27	1.63
@@ -15,31 +15,17 @@
 
 #include "tools.h"
 
-static struct volume_group *_vgmerge_from(struct cmd_context *cmd,
-					  const char *vg_name_from)
+static struct volume_group *_vgmerge_vg_read(struct cmd_context *cmd,
+					     const char *vg_name)
 {
-	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);
+	struct volume_group *vg;
+	log_verbose("Checking for volume group \"%s\"", vg_name);
+	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
+	if (vg_read_error(vg)) {
+		vg_release(vg);
 		return NULL;
 	}
-	return vg_from;
-}
-
-static struct volume_group *_vgmerge_to(struct cmd_context *cmd,
-					const char *vg_name_to)
-{
-	struct volume_group *vg_to;
-
-	log_verbose("Checking for volume group \"%s\"", vg_name_to);
-	vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
-	if (vg_read_error(vg_to)) {
-		vg_release(vg_to);
-		return NULL;
-	}
-	return vg_to;
+	return vg;
 }
 
 static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
@@ -55,11 +41,11 @@
 		return ECMD_FAILED;
 	}
 
-	vg_to = _vgmerge_to(cmd, vg_name_to);
+	vg_to = _vgmerge_vg_read(cmd, vg_name_to);
 	if (!vg_to)
 		return ECMD_FAILED;
 
-	vg_from = _vgmerge_from(cmd, vg_name_from);
+	vg_from = _vgmerge_vg_read(cmd, vg_name_from);
 	if (!vg_from) {
 		unlock_and_release_vg(cmd, vg_to, vg_name_to);
 		return ECMD_FAILED;


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

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

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

Modified files:
	tools          : vgmerge.c 

Log message:
	Change vgmerge behavior to open/lock first vg based on alphabetical ordering.
	
	This enforces our alphabetical lock ordering rules for vgmerge.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

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

--- LVM2/tools/vgmerge.c	2009/09/02 21:28:27	1.63
+++ LVM2/tools/vgmerge.c	2009/09/02 21:28:43	1.64
@@ -41,14 +41,28 @@
 		return ECMD_FAILED;
 	}
 
-	vg_to = _vgmerge_vg_read(cmd, vg_name_to);
-	if (!vg_to)
-		return ECMD_FAILED;
+	if (strcmp(vg_name_to, vg_name_from) > 0)
+		lock_vg_from_first = 1;
 
-	vg_from = _vgmerge_vg_read(cmd, vg_name_from);
-	if (!vg_from) {
-		unlock_and_release_vg(cmd, vg_to, vg_name_to);
-		return ECMD_FAILED;
+	if (lock_vg_from_first) {
+		vg_from = _vgmerge_vg_read(cmd, vg_name_from);
+		if (!vg_from)
+			return ECMD_FAILED;
+		vg_to = _vgmerge_vg_read(cmd, vg_name_to);
+		if (!vg_to) {
+			unlock_and_release_vg(cmd, vg_from, vg_name_from);
+			return ECMD_FAILED;
+		}
+	} else {
+		vg_to = _vgmerge_vg_read(cmd, vg_name_to);
+		if (!vg_to)
+			return ECMD_FAILED;
+
+		vg_from = _vgmerge_vg_read(cmd, vg_name_from);
+		if (!vg_from) {
+			unlock_and_release_vg(cmd, vg_to, vg_name_to);
+			return ECMD_FAILED;
+		}
 	}
 
 	if (!vgs_are_compatible(cmd, vg_from, vg_to))


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

end of thread, other threads:[~2010-06-28 20:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-02 21:27 LVM2/tools vgmerge.c wysochanski
2009-09-02 21:28 wysochanski
2009-09-02 21:28 wysochanski
2009-09-02 21:28 wysochanski
2010-06-28 20:39 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).