public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-09-27 22:43 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2011-09-27 22:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-09-27 22:43:42

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h dev_manager.c 
	lib/locking    : cluster_locking.c file_locking.c locking.c 
	                 locking.h no_locking.c 
	libdm          : libdm-deptree.c 
	tools          : pvmove.c 

Log message:
	Introduce revert_lv for better pvmove cleanup.
	(One further fix needed to remove the stray pvmove LVs left behind.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2142&r2=1.2143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.214&r2=1.215
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.232&r2=1.233
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.68&r2=1.69
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90

--- LVM2/WHATS_NEW	2011/09/27 17:29:33	1.2142
+++ LVM2/WHATS_NEW	2011/09/27 22:43:40	1.2143
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Introduce revert_lv for better pvmove cleanup.
   Replace incomplete pvmove activation failure recovery code with a message.
   Abort if _finish_pvmove suspend_lvs fails instead of cleaning up incompletely.
   Change suspend_lvs to call vg_revert internally.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/09/24 20:50:36	1.124
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/09/27 22:43:40	1.125
@@ -406,7 +406,7 @@
 /* Resume the LV if it was active */
 static int do_resume_lv(char *resource, unsigned char lock_flags)
 {
-	int oldmode, origin_only, exclusive;
+	int oldmode, origin_only, exclusive, revert;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
@@ -416,8 +416,9 @@
 	}
 	origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
 	exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
+	revert = (lock_flags & LCK_REVERT_MODE) ? 1 : 0;
 
-	if (!lv_resume_if_active(cmd, resource, origin_only, exclusive))
+	if (!lv_resume_if_active(cmd, resource, origin_only, exclusive, revert))
 		return EIO;
 
 	return 0;
--- LVM2/lib/activate/activate.c	2011/09/26 10:17:51	1.214
+++ LVM2/lib/activate/activate.c	2011/09/27 22:43:40	1.215
@@ -190,7 +190,7 @@
 	return 1;
 }
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
-			unsigned origin_only, unsigned exclusive)
+			unsigned origin_only, unsigned exclusive, unsigned revert)
 {
 	return 1;
 }
@@ -1356,14 +1356,16 @@
 		laopts->origin_only = 0;
 
 	if (test_mode()) {
-		_skip("Resuming %s%s.", lv->name, laopts->origin_only ? " without snapshots" : "");
+		_skip("Resuming %s%s%s.", lv->name, laopts->origin_only ? " without snapshots" : "",
+		      laopts->revert ? " (reverting)" : "");
 		r = 1;
 		goto out;
 	}
 
-	log_debug("Resuming LV %s/%s%s%s.", lv->vg->name, lv->name,
+	log_debug("Resuming LV %s/%s%s%s%s.", lv->vg->name, lv->name,
 		  error_if_not_active ? "" : " if active",
-		  laopts->origin_only ? " without snapshots" : "");
+		  laopts->origin_only ? " without snapshots" : "",
+		  laopts->revert ? " (reverting)" : "");
 
 	if (!lv_info(cmd, lv, laopts->origin_only, &info, 0, 0))
 		goto_out;
@@ -1395,7 +1397,7 @@
 
 /* Returns success if the device is not active */
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
-			unsigned origin_only, unsigned exclusive)
+			unsigned origin_only, unsigned exclusive, unsigned revert)
 {
 	struct lv_activate_opts laopts = {
 		.origin_only = origin_only,
@@ -1404,7 +1406,8 @@
 		 * non-clustered target should be used.  This only happens
 		 * if exclusive is set.
 		 */
-		.exclusive = exclusive
+		.exclusive = exclusive,
+		.revert = revert
 	};
 
 	return _lv_resume(cmd, lvid_s, &laopts, 0);
--- LVM2/lib/activate/activate.h	2011/09/22 17:33:51	1.80
+++ LVM2/lib/activate/activate.h	2011/09/27 22:43:40	1.81
@@ -34,6 +34,7 @@
 	int exclusive;
 	int origin_only;
 	int no_merging;
+	unsigned revert;
 };
 
 /* target attribute flags */
@@ -63,7 +64,7 @@
 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
-			unsigned origin_only, unsigned exclusive);
+			unsigned origin_only, unsigned exclusive, unsigned revert);
 int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive);
 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s,
 			    int exclusive);
--- LVM2/lib/activate/dev_manager.c	2011/09/22 17:39:57	1.232
+++ LVM2/lib/activate/dev_manager.c	2011/09/27 22:43:41	1.233
@@ -1590,7 +1590,7 @@
 					     layer ? UINT32_C(0) : (uint32_t) lv->major,
 					     layer ? UINT32_C(0) : (uint32_t) lv->minor,
 					     _read_only_lv(lv),
-					     (lv->vg->status & PRECOMMITTED) ? 1 : 0,
+					     ((lv->vg->status & PRECOMMITTED) | laopts->revert) ? 1 : 0,
 					     lvlayer,
 					     _get_udev_flags(dm, lv, layer))))
 		return_0;
--- LVM2/lib/locking/cluster_locking.c	2011/08/30 14:55:17	1.58
+++ LVM2/lib/locking/cluster_locking.c	2011/09/27 22:43:41	1.59
@@ -327,6 +327,9 @@
 	if (flags & LCK_ORIGIN_ONLY)
 		args[1] |= LCK_ORIGIN_ONLY_MODE;
 
+	if (flags & LCK_REVERT)
+		args[1] |= LCK_REVERT_MODE;
+
 	if (mirror_in_sync())
 		args[1] |= LCK_MIRROR_NOSYNC_MODE;
 
--- LVM2/lib/locking/file_locking.c	2011/08/09 11:44:57	1.60
+++ LVM2/lib/locking/file_locking.c	2011/09/27 22:43:41	1.61
@@ -257,6 +257,7 @@
 {
 	char lockfile[PATH_MAX];
 	unsigned origin_only = (flags & LCK_ORIGIN_ONLY) ? 1 : 0;
+	unsigned revert = (flags & LCK_REVERT) ? 1 : 0;
 
 	switch (flags & LCK_SCOPE_MASK) {
 	case LCK_VG:
@@ -292,8 +293,8 @@
 	case LCK_LV:
 		switch (flags & LCK_TYPE_MASK) {
 		case LCK_UNLOCK:
-			log_very_verbose("Unlocking LV %s%s", resource, origin_only ? " without snapshots" : "");
-			if (!lv_resume_if_active(cmd, resource, origin_only, 0))
+			log_very_verbose("Unlocking LV %s%s%s", resource, origin_only ? " without snapshots" : "", revert ? " (reverting)" : "");
+			if (!lv_resume_if_active(cmd, resource, origin_only, 0, revert))
 				return 0;
 			break;
 		case LCK_NULL:
--- LVM2/lib/locking/locking.c	2011/09/27 17:09:43	1.99
+++ LVM2/lib/locking/locking.c	2011/09/27 22:43:41	1.100
@@ -493,6 +493,20 @@
 	return r;
 }
 
+/* Unlock and revert list of LVs */
+int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs)
+{
+	struct lv_list *lvl;
+	int r = 1;
+
+	dm_list_iterate_items(lvl, lvs)
+		if (!revert_lv(cmd, lvl->lv)) {
+			r = 0;
+			stack;
+		}
+
+	return r;
+}
 /*
  * Lock a list of LVs.
  * On failure to lock any LV, calls vg_revert() if vg_to_revert is set and 
@@ -511,7 +525,7 @@
 				vg_revert(vg_to_revert);
 			dm_list_uniterate(lvh, lvs, &lvl->list) {
 				lvl = dm_list_item(lvh, struct lv_list);
-				if (!resume_lv(cmd, lvl->lv))
+				if (!revert_lv(cmd, lvl->lv))
 					stack;
 			}
 
--- LVM2/lib/locking/locking.h	2011/09/27 17:09:43	1.68
+++ LVM2/lib/locking/locking.h	2011/09/27 22:43:41	1.69
@@ -97,6 +97,7 @@
 #define LCK_CLUSTER_VG	0x00000080U	/* VG is clustered */
 #define LCK_CACHE	0x00000100U	/* Operation on cache only using P_ lock */
 #define LCK_ORIGIN_ONLY	0x00000200U	/* Operation should bypass any snapshots */
+#define LCK_REVERT	0x00000400U	/* Revert any incomplete change */
 
 /*
  * Additional lock bits for cluster communication via args[1]
@@ -107,6 +108,7 @@
 #define LCK_CONVERT			0x08	/* Convert existing lock */
 #define LCK_ORIGIN_ONLY_MODE		0x20	/* Same as above */
 #define LCK_TEST_MODE			0x10    /* Test mode: No activation */
+#define LCK_REVERT_MODE			0x40	/* Remove inactive tables */
 
 /*
  * Special cases of VG locks.
@@ -164,6 +166,7 @@
 
 #define resume_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME)
 #define resume_lv_origin(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME | LCK_ORIGIN_ONLY)
+#define revert_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME | LCK_REVERT)
 #define suspend_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_SUSPEND | LCK_HOLD)
 #define suspend_lv_origin(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_SUSPEND | LCK_HOLD | LCK_ORIGIN_ONLY)
 #define deactivate_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE)
@@ -191,6 +194,7 @@
 int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs,
 		struct volume_group *vg_to_revert);
 int resume_lvs(struct cmd_context *cmd, struct dm_list *lvs);
+int revert_lvs(struct cmd_context *cmd, struct dm_list *lvs);
 int activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive);
 
 /* Interrupt handling */
--- LVM2/lib/locking/no_locking.c	2011/08/09 11:44:57	1.29
+++ LVM2/lib/locking/no_locking.c	2011/09/27 22:43:41	1.30
@@ -46,7 +46,7 @@
 		case LCK_NULL:
 			return lv_deactivate(cmd, resource);
 		case LCK_UNLOCK:
-			return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0);
+			return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0, (flags & LCK_REVERT) ? 1 : 0);
 		case LCK_READ:
 			return lv_activate_with_filter(cmd, resource, 0);
 		case LCK_WRITE:
--- LVM2/libdm/libdm-deptree.c	2011/09/26 10:17:52	1.112
+++ LVM2/libdm/libdm-deptree.c	2011/09/27 22:43:41	1.113
@@ -610,6 +610,8 @@
 	if (!info->exists || !info->inactive_table)
 		return 1;
 
+// FIXME Get inactive deps.  If any dev referenced has 1 opener and no live table, remove it after the clear.
+
 	log_verbose("Clearing inactive table %s (%" PRIu32 ":%" PRIu32 ")",
 		    name, info->major, info->minor);
 
--- LVM2/tools/pvmove.c	2011/09/27 17:29:33	1.89
+++ LVM2/tools/pvmove.c	2011/09/27 22:43:42	1.90
@@ -370,13 +370,19 @@
 
 	if (!_suspend_lvs(cmd, first_time, lv_mirr, lvs_changed, vg)) {
 		log_error("ABORTING: Volume group metadata update failed.");
-		goto out;
+		if (!first_time && !revert_lv(cmd, lv_mirr))
+			stack;
+		return 0;
 	}
 
 	/* Commit on-disk metadata */
 	if (!vg_commit(vg)) {
 		log_error("ABORTING: Volume group metadata update failed.");
-		goto out;
+		if (!_resume_lvs(cmd, first_time, lv_mirr, lvs_changed))
+			stack;
+		if (!first_time && !revert_lv(cmd, lv_mirr))
+			stack;
+		return 0;
 	}
 
 	/* Activate the temporary mirror LV */
@@ -403,7 +409,9 @@
 	if (!_resume_lvs(cmd, first_time, lv_mirr, lvs_changed))
 		r = 0;
 
-	backup(vg);
+	if (r)
+		backup(vg);
+
 	return r;
 }
 
@@ -546,6 +554,8 @@
 	/* Suspend LVs changed (implicitly suspends lv_mirr) */
 	if (!suspend_lvs(cmd, lvs_changed, vg)) {
 		log_error("ABORTING: Locking LVs to remove temporary mirror failed");
+		if (!revert_lv(cmd, lv_mirr))
+			stack;
 		return 0;
 	}
 
@@ -553,9 +563,9 @@
 	if (!vg_commit(vg)) {
 		log_error("ABORTING: Failed to write new data locations "
 			  "to disk.");
-		if (!resume_lv(cmd, lv_mirr))
+		if (!revert_lv(cmd, lv_mirr))
 			stack;
-		if (!resume_lvs(cmd, lvs_changed))
+		if (!revert_lvs(cmd, lvs_changed))
 			stack;
 		return 0;
 	}


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2012-01-20  0:27 jbrassow
  0 siblings, 0 replies; 33+ messages in thread
From: jbrassow @ 2012-01-20  0:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2012-01-20 00:27:24

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h 
	lib/locking    : file_locking.c no_locking.c 

Log message:
	Preserve exclusive activation of cluster mirror when converting.
	
	This patch to the suspend code - like the similar change for resume -
	queries the lock mode of a cluster volume and records whether it is active
	exclusively.  This is necessary for suspend due to the possibility of
	preloading targets.  Failure to check to exclusivity causes the cluster target
	of an exclusively activated mirror to be used when converting - rather than
	the single machine target.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2224&r2=1.2225
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.230&r2=1.231
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.93&r2=1.94
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31

--- LVM2/WHATS_NEW	2012/01/19 16:22:42	1.2224
+++ LVM2/WHATS_NEW	2012/01/20 00:27:18	1.2225
@@ -1,6 +1,7 @@
 Version 2.02.89 - 
 ==================================
-  Keep into about creation host and time for each logical volume.
+  Preserve exclusive activation of cluster mirror when converting.
+  Keep info about creation host and time for each logical volume.
   Make error message hit when preallocated memlock memory exceeded clearer.
   Use R lv_attr to indicate read-only activation of non-read-only device in lvs.
   Show read-only activation override in lvdisplay & add 4 to perms in -c.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/12/08 21:24:08	1.128
+++ LVM2/daemons/clvmd/lvm-functions.c	2012/01/20 00:27:19	1.129
@@ -430,6 +430,7 @@
 	int oldmode;
 	struct lvinfo lvi;
 	unsigned origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
+	unsigned exclusive;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
@@ -438,11 +439,14 @@
 		return 0; /* Not active, so it's OK */
 	}
 
+	exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
+
 	/* Only suspend it if it exists */
 	if (!lv_info_by_lvid(cmd, resource, origin_only, &lvi, 0, 0))
 		return EIO;
 
-	if (lvi.exists && !lv_suspend_if_active(cmd, resource, origin_only))
+	if (lvi.exists &&
+	    !lv_suspend_if_active(cmd, resource, origin_only, exclusive))
 		return EIO;
 
 	return 0;
--- LVM2/lib/activate/activate.c	2012/01/19 15:27:54	1.230
+++ LVM2/lib/activate/activate.c	2012/01/20 00:27:19	1.231
@@ -1455,9 +1455,12 @@
 }
 
 /* Returns success if the device is not active */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive)
 {
-	struct lv_activate_opts laopts = { .origin_only = origin_only };
+	struct lv_activate_opts laopts = {
+		.origin_only = origin_only,
+		.exclusive = exclusive
+	};
 
 	return _lv_suspend(cmd, lvid_s, &laopts, 0);
 }
--- LVM2/lib/activate/activate.h	2012/01/19 15:27:54	1.93
+++ LVM2/lib/activate/activate.h	2012/01/20 00:27:19	1.94
@@ -64,7 +64,7 @@
 void activation_exit(void);
 
 /* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only, unsigned exclusive);
 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
 int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
 			unsigned origin_only, unsigned exclusive, unsigned revert);
--- LVM2/lib/locking/file_locking.c	2011/09/27 22:43:41	1.61
+++ LVM2/lib/locking/file_locking.c	2012/01/20 00:27:20	1.62
@@ -312,7 +312,7 @@
 			break;
 		case LCK_WRITE:
 			log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
-			if (!lv_suspend_if_active(cmd, resource, origin_only))
+			if (!lv_suspend_if_active(cmd, resource, origin_only, 0))
 				return 0;
 			break;
 		case LCK_EXCL:
--- LVM2/lib/locking/no_locking.c	2011/09/27 22:43:41	1.30
+++ LVM2/lib/locking/no_locking.c	2012/01/20 00:27:21	1.31
@@ -50,7 +50,7 @@
 		case LCK_READ:
 			return lv_activate_with_filter(cmd, resource, 0);
 		case LCK_WRITE:
-			return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0);
+			return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0, 0);
 		case LCK_EXCL:
 			return lv_activate_with_filter(cmd, resource, 1);
 		default:


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-12-08 21:24 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2011-12-08 21:24 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-12-08 21:24:10

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	daemons/lvmetad: testclient.c 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/mm         : memlock.c 
	liblvm         : lvm_base.c 
	tools          : lvmcmdline.c 

Log message:
	Only use built-in stack size in clvmd - ignore lvm.conf.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2204&r2=1.2205
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.127&r2=1.128
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/lvmetad/testclient.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.148&r2=1.149

--- LVM2/WHATS_NEW	2011/12/06 19:30:15	1.2204
+++ LVM2/WHATS_NEW	2011/12/08 21:24:08	1.2205
@@ -47,7 +47,7 @@
   Fix lv_info open_count test for disabled verify_udev_operations (2.02.86).
   Simplify code for lvm worker thread in clvmd.                     
   Use pthread_barrier to synchronize clvmd threads at startup.
-  Limit clvmd's thread size to 128KiB.
+  Limit clvmd's thread size to 128KiB and ignore activation/reserved_stack.
   Reduce default preallocated stack size to 64KiB.
   Add check for access through NULL pointer when refresh_filter() fails.
   Use pthread condition for SINGLENODE lock implementation.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/12/08 18:32:34	1.127
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/12/08 21:24:08	1.128
@@ -880,7 +880,7 @@
 	if (!get_initial_state(excl_uuid))
 		log_error("Cannot load initial lock states.");
 
-	if (!(cmd = create_toolcontext(1, NULL, 0))) {
+	if (!(cmd = create_toolcontext(1, NULL, 0, 1))) {
 		log_error("Failed to allocate command context");
 		return 0;
 	}
--- LVM2/daemons/lvmetad/testclient.c	2011/07/20 15:15:41	1.9
+++ LVM2/daemons/lvmetad/testclient.c	2011/12/08 21:24:08	1.10
@@ -108,7 +108,7 @@
 
 	if (argc > 1) {
 		int i;
-		struct cmd_context *cmd = create_toolcontext(0, NULL, 0);
+		struct cmd_context *cmd = create_toolcontext(0, NULL, 0, 0);
 		for (i = 1; i < argc; ++i) {
 			const char *uuid = NULL;
 			scan(h, argv[i]);
--- LVM2/lib/commands/toolcontext.c	2011/11/28 20:37:51	1.142
+++ LVM2/lib/commands/toolcontext.c	2011/12/08 21:24:09	1.143
@@ -1224,7 +1224,8 @@
 /* Entry point */
 struct cmd_context *create_toolcontext(unsigned is_long_lived,
 				       const char *system_dir,
-				       unsigned set_buffering)
+				       unsigned set_buffering,
+				       unsigned threaded)
 {
 	struct cmd_context *cmd;
 
@@ -1246,6 +1247,7 @@
 		return NULL;
 	}
 	cmd->is_long_lived = is_long_lived;
+	cmd->threaded = threaded ? 1 : 0;
 	cmd->handles_missing_pvs = 0;
 	cmd->handles_unknown_segments = 0;
 	cmd->independent_metadata_areas = 0;
--- LVM2/lib/commands/toolcontext.h	2011/11/28 20:37:52	1.47
+++ LVM2/lib/commands/toolcontext.h	2011/12/08 21:24:09	1.48
@@ -85,6 +85,7 @@
 	unsigned partial_activation:1;
 	unsigned si_unit_consistency:1;
 	unsigned metadata_read_only:1;
+	unsigned threaded:1;		/* Set if running within a thread e.g. clvmd */
 
 	unsigned independent_metadata_areas:1;	/* Active formats have MDAs outside PVs */
 
@@ -117,7 +118,8 @@
  */
 struct cmd_context *create_toolcontext(unsigned is_long_lived,
 				       const char *system_dir,
-				       unsigned set_buffering);
+				       unsigned set_buffering,
+				       unsigned threaded);
 void destroy_toolcontext(struct cmd_context *cmd);
 int refresh_toolcontext(struct cmd_context *cmd);
 int refresh_filters(struct cmd_context *cmd);
--- LVM2/lib/mm/memlock.c	2011/08/30 14:55:18	1.46
+++ LVM2/lib/mm/memlock.c	2011/12/08 21:24:09	1.47
@@ -445,9 +445,10 @@
 
 void memlock_init(struct cmd_context *cmd)
 {
-	_size_stack = find_config_tree_int(cmd,
-				      "activation/reserved_stack",
-				      DEFAULT_RESERVED_STACK) * 1024;
+	/* When threaded, caller already limited stack size so just use the default. */
+	_size_stack = 1024 * (cmd->threaded ? DEFAULT_RESERVED_STACK :
+					      find_config_tree_int(cmd, "activation/reserved_stack",
+								   DEFAULT_RESERVED_STACK));
 	_size_malloc_tmp = find_config_tree_int(cmd,
 					   "activation/reserved_memory",
 					   DEFAULT_RESERVED_MEMORY) * 1024;
--- LVM2/liblvm/lvm_base.c	2011/06/15 13:29:48	1.22
+++ LVM2/liblvm/lvm_base.c	2011/12/08 21:24:09	1.23
@@ -37,7 +37,7 @@
 	/* create context */
 	/* FIXME: split create_toolcontext */
 	/* FIXME: make all globals configurable */
-	cmd = create_toolcontext(0, system_dir, 1);
+	cmd = create_toolcontext(0, system_dir, 1, 0);
 	if (!cmd)
 		return NULL;
 
--- LVM2/tools/lvmcmdline.c	2011/09/16 12:10:02	1.148
+++ LVM2/tools/lvmcmdline.c	2011/12/08 21:24:10	1.149
@@ -1237,7 +1237,7 @@
 	if (!udev_init_library_context())
 		stack;
 
-	if (!(cmd = create_toolcontext(0, NULL, 1)))
+	if (!(cmd = create_toolcontext(0, NULL, 1, 0)))
 		return_NULL;
 
 	_cmdline.arg_props = &_arg_props[0];


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-08-10 20:25 zkabelac
  0 siblings, 0 replies; 33+ messages in thread
From: zkabelac @ 2011-08-10 20:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-08-10 20:25:31

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c 
	lib/cache      : lvmcache.c 
	lib/format_pool: format_pool.c 
	lib/format_text: archive.c archiver.c format-text.c 
	                 import_vsn1.c 
	lib/locking    : locking.h 
	lib/metadata   : metadata-exported.h metadata.c 
	                 replicator_manip.c vg.c vg.h 
	liblvm         : lvm_vg.c 
	tools          : lvconvert.c lvcreate.c lvrename.c lvresize.c 
	                 polldaemon.c pvchange.c pvcreate.c pvdisplay.c 
	                 pvmove.c pvresize.c reporter.c toollib.c 
	                 vgcreate.c vgextend.c vgmerge.c vgreduce.c 
	                 vgrename.c vgsplit.c 

Log message:
	Replace free_vg with release_vg
	
	Move the free_vg() to  vg.c  and replace free_vg  with release_vg
	and make the _free_vg internal.
	
	Patch is needed for sharing VG in vginfo cache so the release_vg function name
	is a better fit here.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2057&r2=1.2058
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.209&r2=1.210
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.182&r2=1.183
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.195&r2=1.196
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.461&r2=1.462
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/vg.h.diff?cvsroot=lvm2&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.232&r2=1.233
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvrename.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.227&r2=1.228
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108

--- LVM2/WHATS_NEW	2011/08/10 20:17:33	1.2057
+++ LVM2/WHATS_NEW	2011/08/10 20:25:29	1.2058
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  Replace free_vg with release_vg and move it to vg.c.
   Remove INCONSISTENT_VG flag from the code.
   Remove lock from cache even if unlock fails.
   Initialise clvmd locks before lvm context to avoid open descriptor leaks.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/08/10 11:00:32	1.121
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/08/10 20:25:29	1.122
@@ -840,7 +840,7 @@
 	else
 		log_error("Error backing up metadata, can't find VG for group %s", vgname);
 
-	free_vg(vg);
+	release_vg(vg);
 	dm_pool_empty(cmd->mem);
 
 	pthread_mutex_unlock(&lvm_lock);
--- LVM2/lib/activate/activate.c	2011/07/08 15:35:50	1.209
+++ LVM2/lib/activate/activate.c	2011/08/10 20:25:29	1.210
@@ -521,7 +521,7 @@
 		origin_only = 0;
 
 	r = lv_info(cmd, lv, origin_only, info, with_open_count, with_read_ahead);
-	free_vg(lv->vg);
+	release_vg(lv->vg);
 
 	return r;
 }
@@ -1267,10 +1267,10 @@
 	r = 1;
 out:
 	if (lv_pre)
-		free_vg(lv_pre->vg);
+		release_vg(lv_pre->vg);
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		free_vg(lv->vg);
+		release_vg(lv->vg);
 	}
 
 	return r;
@@ -1351,7 +1351,7 @@
 	r = 1;
 out:
 	if (lv)
-		free_vg(lv->vg);
+		release_vg(lv->vg);
 
 	return r;
 }
@@ -1458,7 +1458,7 @@
 out:
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		free_vg(lv->vg);
+		release_vg(lv->vg);
 	}
 
 	return r;
@@ -1488,7 +1488,7 @@
 	r = 1;
 out:
 	if (lv)
-		free_vg(lv->vg);
+		release_vg(lv->vg);
 
 	return r;
 }
@@ -1557,7 +1557,7 @@
 out:
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		free_vg(lv->vg);
+		release_vg(lv->vg);
 	}
 
 	return r;
--- LVM2/lib/cache/lvmcache.c	2011/07/18 13:26:08	1.112
+++ LVM2/lib/cache/lvmcache.c	2011/08/10 20:25:30	1.113
@@ -683,7 +683,7 @@
 	return vg;
 
 bad:
-	free_vg(vg);
+	release_vg(vg);
 	_free_cached_vgmetadata(vginfo);
 	return NULL;
 }
--- LVM2/lib/format_pool/format_pool.c	2011/03/11 15:10:16	1.44
+++ LVM2/lib/format_pool/format_pool.c	2011/08/10 20:25:30	1.45
@@ -156,7 +156,7 @@
 	return vg;
 
 bad:
-	free_vg(vg);
+	release_vg(vg);
 
 	return NULL;
 }
--- LVM2/lib/format_text/archive.c	2011/03/11 15:08:32	1.43
+++ LVM2/lib/format_text/archive.c	2011/08/10 20:25:30	1.44
@@ -332,7 +332,7 @@
 	log_print("Description:\t%s", desc ? : "<No description>");
 	log_print("Backup Time:\t%s", ctime(&when));
 
-	free_vg(vg);
+	release_vg(vg);
 }
 
 int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
--- LVM2/lib/format_text/archiver.c	2011/03/11 15:08:32	1.46
+++ LVM2/lib/format_text/archiver.c	2011/08/10 20:25:30	1.47
@@ -362,7 +362,7 @@
 		log_error("Cannot restore Volume Group %s with %i PVs "
 			  "marked as missing.", vg->name, missing_pvs);
 
-	free_vg(vg);
+	release_vg(vg);
 	return r;
 }
 
@@ -447,7 +447,7 @@
 	    (vg->seqno == vg_backup->seqno) &&
 	    (id_equal(&vg->id, &vg_backup->id))) {
 		log_suppress(old_suppress);
-		free_vg(vg_backup);
+		release_vg(vg_backup);
 		return;
 	}
 	log_suppress(old_suppress);
@@ -455,7 +455,7 @@
 	if (vg_backup) {
 		if (!archive(vg_backup))
 			stack;
-		free_vg(vg_backup);
+		release_vg(vg_backup);
 	}
 	if (!archive(vg))
 		stack;
--- LVM2/lib/format_text/format-text.c	2011/06/15 17:45:02	1.182
+++ LVM2/lib/format_text/format-text.c	2011/08/10 20:25:30	1.183
@@ -855,7 +855,7 @@
 	 * check that it contains the correct volume group.
 	 */
 	if (vgname && strcmp(vgname, vg->name)) {
-		free_vg(vg);
+		release_vg(vg);
 		log_error("'%s' does not contain volume group '%s'.",
 			  read_path, vgname);
 		return NULL;
@@ -1091,7 +1091,7 @@
 							     path))) {
 					/* FIXME Store creation host in vg */
 					lvmcache_update_vg(vg, 0);
-					free_vg(vg);
+					release_vg(vg);
 				}
 			}
 
--- LVM2/lib/format_text/import_vsn1.c	2011/08/02 22:07:22	1.89
+++ LVM2/lib/format_text/import_vsn1.c	2011/08/10 20:25:30	1.90
@@ -814,7 +814,7 @@
 	if (lv_hash)
 		dm_hash_destroy(lv_hash);
 
-	free_vg(vg);
+	release_vg(vg);
 	return NULL;
 }
 
--- LVM2/lib/locking/locking.h	2011/06/01 21:16:56	1.66
+++ LVM2/lib/locking/locking.h	2011/08/10 20:25:30	1.67
@@ -156,10 +156,10 @@
 			sync_dev_names(cmd); \
 		lock_vol(cmd, vol, LCK_VG_UNLOCK); \
 	} while (0)
-#define unlock_and_free_vg(cmd, vg, vol) \
+#define unlock_and_release_vg(cmd, vg, vol) \
 	do { \
 		unlock_vg(cmd, vol); \
-		free_vg(vg); \
+		release_vg(vg); \
 	} while (0)
 
 #define resume_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME)
--- LVM2/lib/metadata/metadata-exported.h	2011/08/02 22:07:22	1.195
+++ LVM2/lib/metadata/metadata-exported.h	2011/08/10 20:25:30	1.196
@@ -479,12 +479,6 @@
  */
 void free_pv_fid(struct physical_volume *pv);
 
-/*
- * free_vg() must be called on every struct volume_group allocated
- * by vg_create() or vg_read_internal() to free it when no longer required.
- */
-void free_vg(struct volume_group *vg);
-
 /* Manipulate LVs */
 struct logical_volume *lv_create_empty(const char *name,
 				       union lvid *lvid,
--- LVM2/lib/metadata/metadata.c	2011/08/10 20:17:33	1.461
+++ LVM2/lib/metadata/metadata.c	2011/08/10 20:25:30	1.462
@@ -374,7 +374,7 @@
 		}
 	}
 out:
-	free_vg(vg);
+	release_vg(vg);
 	return r;
 }
 
@@ -928,7 +928,7 @@
 	/* is this vg name already in use ? */
 	if ((vg = vg_read_internal(cmd, vg_name, NULL, 1, &consistent))) {
 		log_error("A volume group called '%s' already exists.", vg_name);
-		unlock_and_free_vg(cmd, vg, vg_name);
+		unlock_and_release_vg(cmd, vg, vg_name);
 		return _vg_make_handle(cmd, NULL, FAILED_EXIST);
 	}
 
@@ -980,7 +980,7 @@
 	return _vg_make_handle(cmd, vg, SUCCESS);
 
 bad:
-	unlock_and_free_vg(cmd, vg, vg_name);
+	unlock_and_release_vg(cmd, vg, vg_name);
 	/* FIXME: use _vg_make_handle() w/proper error code */
 	return NULL;
 }
@@ -2730,7 +2730,7 @@
 	return vg;
 bad:
 	free_pv_fid(pv);
-	free_vg(vg);
+	release_vg(vg);
 	return NULL;
 }
 
@@ -2865,7 +2865,7 @@
 		*consistent = 1;
 		return correct_vg;
 	} else {
-		free_vg(correct_vg);
+		release_vg(correct_vg);
 		correct_vg = NULL;
 	}
 
@@ -2911,7 +2911,7 @@
 		    (!use_precommitted &&
 		     !(vg = mda->ops->vg_read(fid, vgname, mda)))) {
 			inconsistent = 1;
-			free_vg(vg);
+			release_vg(vg);
 			continue;
 		}
 
@@ -2930,7 +2930,7 @@
 				inconsistent = 1;
 
 			if (vg->seqno > correct_vg->seqno) {
-				free_vg(correct_vg);
+				release_vg(correct_vg);
 				correct_vg = vg;
 			} else {
 				mda->status |= MDA_INCONSISTENT;
@@ -2939,7 +2939,7 @@
 		}
 
 		if (vg != correct_vg)
-			free_vg(vg);
+			release_vg(vg);
 	}
 
 	/* Ensure every PV in the VG was in the cache */
@@ -3015,7 +3015,7 @@
 			if (critical_section())
 				inconsistent = 1;
 			else {
-				free_vg(correct_vg);
+				release_vg(correct_vg);
 				correct_vg = NULL;
 			}
 		} else dm_list_iterate_items(pvl, &correct_vg->pvs) {
@@ -3024,14 +3024,14 @@
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
 					  vgname);
-				free_vg(correct_vg);
+				release_vg(correct_vg);
 				correct_vg = NULL;
 				break;
 			}
 		}
 
 		if (correct_vg && inconsistent_mdas) {
-			free_vg(correct_vg);
+			release_vg(correct_vg);
 			correct_vg = NULL;
 		}
 	}
@@ -3076,7 +3076,7 @@
 				correct_vg = vg;
 				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg)) {
 					_free_pv_list(&all_pvs);
-					free_vg(vg);
+					release_vg(vg);
 					return_NULL;
 				}
 				continue;
@@ -3099,12 +3099,12 @@
 
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
 					_free_pv_list(&all_pvs);
-					free_vg(vg);
-					free_vg(correct_vg);
+					release_vg(vg);
+					release_vg(correct_vg);
 					return_NULL;
 				}
 				if (vg->seqno > correct_vg->seqno) {
-					free_vg(correct_vg);
+					release_vg(correct_vg);
 					correct_vg = vg;
 				} else {
 					mda->status |= MDA_INCONSISTENT;
@@ -3113,7 +3113,7 @@
 			}
 
 			if (vg != correct_vg)
-				free_vg(vg);
+				release_vg(vg);
 		}
 
 		/* Give up looking */
@@ -3159,7 +3159,7 @@
 				return correct_vg;
 			}
 			_free_pv_list(&all_pvs);
-			free_vg(correct_vg);
+			release_vg(correct_vg);
 			return NULL;
 		}
 
@@ -3191,7 +3191,7 @@
 		if (!vg_write(correct_vg)) {
 			log_error("Automatic metadata correction failed");
 			_free_pv_list(&all_pvs);
-			free_vg(correct_vg);
+			release_vg(correct_vg);
 			cmd->handles_missing_pvs = saved_handles_missing_pvs;
 			return NULL;
 		}
@@ -3200,7 +3200,7 @@
 		if (!vg_commit(correct_vg)) {
 			log_error("Automatic metadata correction commit "
 				  "failed");
-			free_vg(correct_vg);
+			release_vg(correct_vg);
 			return NULL;
 		}
 
@@ -3211,14 +3211,14 @@
 			}
 			if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
 				_free_pv_list(&all_pvs);
-				free_vg(correct_vg);
+				release_vg(correct_vg);
 				return_NULL;
 			}
 			log_error("Removing PV %s (%s) that no longer belongs to VG %s",
 				  pv_dev_name(pvl->pv), uuid, correct_vg->name);
 			if (!pv_write_orphan(cmd, pvl->pv)) {
 				_free_pv_list(&all_pvs);
-				free_vg(correct_vg);
+				release_vg(correct_vg);
 				return_NULL;
 			}
 
@@ -3242,7 +3242,7 @@
 			  "volume group %s", correct_vg->name);
 		log_error("Please restore the metadata by running "
 			  "vgcfgrestore.");
-		free_vg(correct_vg);
+		release_vg(correct_vg);
 		return NULL;
 	}
 
@@ -3262,7 +3262,7 @@
 	if (!check_pv_segments(vg)) {
 		log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
 			  vg->name);
-		free_vg(vg);
+		release_vg(vg);
 		return NULL;
 	}
 
@@ -3270,7 +3270,7 @@
 		if (!check_lv_segments(lvl->lv, 0)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
-			free_vg(vg);
+			release_vg(vg);
 			return NULL;
 		}
 	}
@@ -3282,7 +3282,7 @@
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
-			free_vg(vg);
+			release_vg(vg);
 			return NULL;
 		}
 	}
@@ -3299,22 +3299,6 @@
 		pv->fid->fmt->ops->destroy_instance(pv->fid);
 }
 
-void free_vg(struct volume_group *vg)
-{
-	if (!vg)
-		return;
-
-	vg_set_fid(vg, NULL);
-
-	if (vg->cmd && vg->vgmem == vg->cmd->mem) {
-		log_error(INTERNAL_ERROR "global memory pool used for VG %s",
-			  vg->name);
-		return;
-	}
-
-	dm_pool_destroy(vg->vgmem);
-}
-
 /* This is only called by lv_from_lvid, which is only called from
  * activate.c so we know the appropriate VG lock is already held and
  * the vg_read_internal is therefore safe.
@@ -3341,7 +3325,7 @@
 					  "inconsistent", vg->name);
 			return vg;
 		}
-		free_vg(vg);
+		release_vg(vg);
 	}
 
 	/* Mustn't scan if memory locked: ensure cache gets pre-populated! */
@@ -3370,12 +3354,12 @@
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vgname);
-				free_vg(vg);
+				release_vg(vg);
 				return NULL;
 			}
 			return vg;
 		}
-		free_vg(vg);
+		release_vg(vg);
 	}
 
 	return NULL;
@@ -3409,7 +3393,7 @@
 
 	return lvl->lv;
 out:
-	free_vg(vg);
+	release_vg(vg);
 	return NULL;
 }
 
@@ -3616,12 +3600,12 @@
 			dm_list_iterate_items(pvl, &vg->pvs) {
 				if (!(pvl_copy = _copy_pvl(cmd->mem, pvl))) {
 					log_error("PV list allocation failed");
-					free_vg(vg);
+					release_vg(vg);
 					return 0;
 				}
 				dm_list_add(results, &pvl_copy->list);
 			}
-		free_vg(vg);
+		release_vg(vg);
 	}
 	init_pvmove(old_pvmove);
 
@@ -3838,7 +3822,7 @@
 		return_NULL;
 
 	if (!consistent) {
-		free_vg(vg);
+		release_vg(vg);
 		return_NULL;
 	}
 
@@ -3910,7 +3894,7 @@
 
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
 	if (!consistent && !failure) {
-		free_vg(vg);
+		release_vg(vg);
 		if (!(vg = _recover_vg(cmd, vg_name, vgid))) {
 			log_error("Recovery of volume group \"%s\" failed.",
 				  vg_name);
--- LVM2/lib/metadata/replicator_manip.c	2010/12/08 20:50:50	1.7
+++ LVM2/lib/metadata/replicator_manip.c	2011/08/10 20:25:30	1.8
@@ -597,9 +597,9 @@
 	/* Backward iterate cmd_vg list */
 	dm_list_iterate_back_items(cvl, cmd_vgs) {
 		if (vg_read_error(cvl->vg))
-			free_vg(cvl->vg);
+			release_vg(cvl->vg);
 		else
-			unlock_and_free_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name);
+			unlock_and_release_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name);
 		cvl->vg = NULL;
 	}
 }
@@ -687,7 +687,7 @@
 
 	dm_list_iterate_back_items(rsite, &first_seg(lv)->replicator->rsites)
 		if (rsite->vg_name && rsite->vg) {
-			free_vg(rsite->vg);
+			release_vg(rsite->vg);
 			rsite->vg = NULL;
 		}
 }
--- LVM2/lib/metadata/vg.c	2011/06/01 19:29:33	1.10
+++ LVM2/lib/metadata/vg.c	2011/08/10 20:25:30	1.11
@@ -17,6 +17,7 @@
 #include "metadata.h"
 #include "display.h"
 #include "activate.h"
+#include "toolcontext.h"
 
 struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
 			      const char *vg_name)
@@ -51,6 +52,27 @@
 	return vg;
 }
 
+static void _free_vg(struct volume_group *vg)
+{
+	vg_set_fid(vg, NULL);
+
+	if (vg->cmd && vg->vgmem == vg->cmd->mem) {
+		log_error(INTERNAL_ERROR "global memory pool used for VG %s",
+			  vg->name);
+		return;
+	}
+
+	dm_pool_destroy(vg->vgmem);
+}
+
+void release_vg(struct volume_group *vg)
+{
+	if (!vg)
+		return;
+
+	_free_vg(vg);
+}
+
 char *vg_fmt_dup(const struct volume_group *vg)
 {
 	if (!vg->fid || !vg->fid->fmt)
--- LVM2/lib/metadata/vg.h	2011/06/01 19:29:33	1.12
+++ LVM2/lib/metadata/vg.h	2011/08/10 20:25:30	1.13
@@ -111,6 +111,12 @@
 struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
 			      const char *vg_name);
 
+/*
+ * release_vg() must be called on every struct volume_group allocated
+ * by vg_create() or vg_read_internal() to free it when no longer required.
+ */
+void release_vg(struct volume_group *vg);
+
 char *vg_fmt_dup(const struct volume_group *vg);
 char *vg_name_dup(const struct volume_group *vg);
 char *vg_system_id_dup(const struct volume_group *vg);
--- LVM2/liblvm/lvm_vg.c	2011/04/01 13:44:51	1.52
+++ LVM2/liblvm/lvm_vg.c	2011/08/10 20:25:30	1.53
@@ -56,7 +56,7 @@
 	vg = vg_create((struct cmd_context *)libh, vg_name);
 	/* FIXME: error handling is still TBD */
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		return NULL;
 	}
 	vg->open_mode = 'w';
@@ -160,9 +160,9 @@
 int lvm_vg_close(vg_t vg)
 {
 	if (vg_read_error(vg) == FAILED_LOCKING)
-		free_vg(vg);
+		release_vg(vg);
 	else
-		unlock_and_free_vg(vg->cmd, vg, vg->name);
+		unlock_and_release_vg(vg->cmd, vg, vg->name);
 	return 0;
 }
 
@@ -197,7 +197,7 @@
 	vg = vg_read((struct cmd_context *)libh, vgname, NULL, internal_flags);
 	if (vg_read_error(vg)) {
 		/* FIXME: use log_errno either here in inside vg_read */
-		free_vg(vg);
+		release_vg(vg);
 		return NULL;
 	}
 	/* FIXME: combine this with locking ? */
--- LVM2/tools/lvconvert.c	2011/07/08 19:42:11	1.166
+++ LVM2/tools/lvconvert.c	2011/08/10 20:25:31	1.167
@@ -1615,7 +1615,7 @@
 {
 	/*
 	 * Returns NULL if the requested LV doesn't exist;
-	 * otherwise the caller must free_vg(lv->vg)
+	 * otherwise the caller must release_vg(lv->vg)
 	 * - it is also up to the caller to unlock_vg() as needed
 	 */
 	struct volume_group *vg;
@@ -1623,13 +1623,13 @@
 
 	vg = _get_lvconvert_vg(cmd, vg_name, NULL);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		return_NULL;
 	}
 
 	if (!(lv = _get_lvconvert_lv(cmd, vg, lv_name, NULL, 0))) {
 		log_error("Can't find LV %s in VG %s", lv_name, vg_name);
-		unlock_and_free_vg(cmd, vg, vg_name);
+		unlock_and_release_vg(cmd, vg, vg_name);
 		return NULL;
 	}
 
@@ -1682,7 +1682,7 @@
 		ret = poll_logical_volume(cmd, lp->lv_to_poll,
 					  lp->wait_completion);
 
-	free_vg(lv->vg);
+	release_vg(lv->vg);
 out:
 	init_ignore_suspended_devices(saved_ignore_suspended_devices);
 	return ret;
@@ -1732,7 +1732,7 @@
 		}
 	}
 
-	free_vg(refreshed_lv->vg);
+	release_vg(refreshed_lv->vg);
 
 	return ret;
 }
--- LVM2/tools/lvcreate.c	2011/08/02 22:07:23	1.232
+++ LVM2/tools/lvcreate.c	2011/08/10 20:25:31	1.233
@@ -600,7 +600,7 @@
 	log_verbose("Finding volume group \"%s\"", lp.vg_name);
 	vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -615,6 +615,6 @@
 		r = ECMD_FAILED;
 	}
 out:
-	unlock_and_free_vg(cmd, vg, lp.vg_name);
+	unlock_and_release_vg(cmd, vg, lp.vg_name);
 	return r;
 }
--- LVM2/tools/lvrename.c	2010/12/08 20:50:51	1.57
+++ LVM2/tools/lvrename.c	2011/08/10 20:25:31	1.58
@@ -104,7 +104,7 @@
 	log_verbose("Checking for existing volume group \"%s\"", vg_name);
 	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -123,6 +123,6 @@
 
 	r = ECMD_PROCESSED;
 error:
-	unlock_and_free_vg(cmd, vg, vg_name);
+	unlock_and_release_vg(cmd, vg, vg_name);
 	return r;
 }
--- LVM2/tools/lvresize.c	2011/06/15 10:56:52	1.133
+++ LVM2/tools/lvresize.c	2011/08/10 20:25:31	1.134
@@ -773,7 +773,7 @@
 	log_verbose("Finding volume group %s", lp.vg_name);
 	vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -781,7 +781,7 @@
 	if (!(r = _lvresize(cmd, vg, &lp)))
 		stack;
 
-	unlock_and_free_vg(cmd, vg, lp.vg_name);
+	unlock_and_release_vg(cmd, vg, lp.vg_name);
 
 	return r;
 }
--- LVM2/tools/polldaemon.c	2011/02/18 15:05:40	1.44
+++ LVM2/tools/polldaemon.c	2011/08/10 20:25:31	1.45
@@ -187,7 +187,7 @@
 		/* Locks the (possibly renamed) VG again */
 		vg = parms->poll_fns->get_copy_vg(cmd, name, uuid);
 		if (vg_read_error(vg)) {
-			free_vg(vg);
+			release_vg(vg);
 			log_error("ABORTING: Can't reread VG for %s", name);
 			/* What more could we do here? */
 			return 0;
@@ -198,23 +198,23 @@
 		if (!lv && parms->lv_type == PVMOVE) {
 			log_print("%s: no pvmove in progress - already finished or aborted.",
 				  name);
-			unlock_and_free_vg(cmd, vg, vg->name);
+			unlock_and_release_vg(cmd, vg, vg->name);
 			return 1;
 		}
 
 		if (!lv) {
 			log_error("ABORTING: Can't find LV in %s for %s",
 				  vg->name, name);
-			unlock_and_free_vg(cmd, vg, vg->name);
+			unlock_and_release_vg(cmd, vg, vg->name);
 			return 0;
 		}
 
 		if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) {
-			unlock_and_free_vg(cmd, vg, vg->name);
+			unlock_and_release_vg(cmd, vg, vg->name);
 			return_0;
 		}
 
-		unlock_and_free_vg(cmd, vg, vg->name);
+		unlock_and_release_vg(cmd, vg, vg->name);
 
 		/*
 		 * FIXME Sleeping after testing, while preferred, also works around
--- LVM2/tools/pvchange.c	2011/02/28 13:19:03	1.91
+++ LVM2/tools/pvchange.c	2011/08/10 20:25:31	1.92
@@ -218,7 +218,7 @@
 			}
 			vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 			if (vg_read_error(vg)) {
-				free_vg(vg);
+				release_vg(vg);
 				stack;
 				continue;
 			}
@@ -232,7 +232,7 @@
 			total++;
 			done += _pvchange_single(cmd, vg,
 						 pvl->pv, NULL);
-			unlock_and_free_vg(cmd, vg, vg_name);
+			unlock_and_release_vg(cmd, vg, vg_name);
 		}
 	} else {
 		log_verbose("Scanning for physical volume names");
@@ -253,7 +253,7 @@
 			dm_list_iterate_items(sll, vgnames) {
 				vg = vg_read_for_update(cmd, sll->str, NULL, 0);
 				if (vg_read_error(vg)) {
-					free_vg(vg);
+					release_vg(vg);
 					stack;
 					continue;
 				}
@@ -263,7 +263,7 @@
 								 pvl->pv,
 								 NULL);
 				}
-				unlock_and_free_vg(cmd, vg, sll->str);
+				unlock_and_release_vg(cmd, vg, sll->str);
 			}
 		}
 		unlock_vg(cmd, VG_GLOBAL);
--- LVM2/tools/pvcreate.c	2011/06/01 19:29:34	1.95
+++ LVM2/tools/pvcreate.c	2011/08/10 20:25:31	1.96
@@ -74,7 +74,7 @@
 		pp->pe_start = pv_pe_start(existing_pvl->pv);
 		pp->extent_size = pv_pe_size(existing_pvl->pv);
 		pp->extent_count = pv_pe_count(existing_pvl->pv);
-		free_vg(vg);
+		release_vg(vg);
 	}
 
 	if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
--- LVM2/tools/pvdisplay.c	2010/12/08 20:50:51	1.55
+++ LVM2/tools/pvdisplay.c	2011/08/10 20:25:31	1.56
@@ -32,7 +32,7 @@
 		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
 		if (vg_read_error(vg)) {
 			log_error("Skipping volume group %s", vg_name);
-			free_vg(vg);
+			release_vg(vg);
 			/* FIXME If CLUSTERED should return ECMD_PROCESSED here */
 			return ECMD_FAILED;
 		}
@@ -85,7 +85,7 @@
 	if (vg_name)
 		unlock_vg(cmd, vg_name);
 	if (!old_vg)
-		free_vg(vg);
+		release_vg(vg);
 
 	return ret;
 }
--- LVM2/tools/pvmove.c	2011/06/11 00:03:07	1.84
+++ LVM2/tools/pvmove.c	2011/08/10 20:25:31	1.85
@@ -460,7 +460,7 @@
 
 	vg = _get_vg(cmd, pv_vg_name(pv));
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -526,7 +526,7 @@
 	r = ECMD_PROCESSED;
 out:
 	free_pv_fid(pv);
-	unlock_and_free_vg(cmd, vg, pv_vg_name(pv));
+	unlock_and_release_vg(cmd, vg, pv_vg_name(pv));
 	return r;
 }
 
--- LVM2/tools/pvresize.c	2011/06/01 19:29:34	1.45
+++ LVM2/tools/pvresize.c	2011/08/10 20:25:31	1.46
@@ -52,7 +52,7 @@
 		vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 
 		if (vg_read_error(vg)) {
-			free_vg(vg);
+			release_vg(vg);
 			log_error("Unable to read volume group \"%s\".",
 				  vg_name);
 			return 0;
@@ -129,7 +129,7 @@
 	if (is_orphan_vg(vg_name))
 		free_pv_fid(pv);
 	if (!old_vg)
-		free_vg(vg);
+		release_vg(vg);
 	return r;
 }
 
--- LVM2/tools/reporter.c	2011/03/09 12:44:43	1.66
+++ LVM2/tools/reporter.c	2011/08/10 20:25:31	1.67
@@ -142,7 +142,7 @@
 		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
 		if (vg_read_error(vg)) {
 			log_error("Skipping volume group %s", vg_name);
-			free_vg(vg);
+			release_vg(vg);
 			return ECMD_FAILED;
 		}
 
@@ -182,7 +182,7 @@
 		unlock_vg(cmd, vg_name);
 
 	if (!old_vg)
-		free_vg(vg);
+		release_vg(vg);
 
 	return ret;
 }
--- LVM2/tools/toollib.c	2011/06/01 19:29:34	1.227
+++ LVM2/tools/toollib.c	2011/08/10 20:25:31	1.228
@@ -403,7 +403,7 @@
 
 		vg = vg_read(cmd, vg_name, NULL, 0);
 		if (vg_read_error(vg)) {
-			free_vg(vg);
+			release_vg(vg);
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}
@@ -415,7 +415,7 @@
 		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
 			 log_error("Unable to find %s in volume group %s",
 				   pv_dev_name(pv), vg_name);
-			 unlock_and_free_vg(cmd, vg, vg_name);
+			 unlock_and_release_vg(cmd, vg, vg_name);
 			 return ECMD_FAILED;
 		}
 
@@ -438,7 +438,7 @@
 	if (vg_name)
 		unlock_vg(cmd, vg_name);
 	if (!old_vg)
-		free_vg(vg);
+		release_vg(vg);
 
 	return ret_max;
 }
@@ -795,7 +795,7 @@
 				vg = vg_read(cmd, sll->str, NULL, flags);
 				if (vg_read_error(vg)) {
 					ret_max = ECMD_FAILED;
-					free_vg(vg);
+					release_vg(vg);
 					stack;
 					continue;
 				}
@@ -804,7 +804,7 @@
 							    handle,
 							    process_single_pv);
 
-				unlock_and_free_vg(cmd, vg, sll->str);
+				unlock_and_release_vg(cmd, vg, sll->str);
 
 				if (ret > ret_max)
 					ret_max = ret;
--- LVM2/tools/vgcreate.c	2011/02/18 14:47:31	1.83
+++ LVM2/tools/vgcreate.c	2011/08/10 20:25:31	1.84
@@ -56,7 +56,7 @@
 			log_error("A volume group called %s already exists.", vp_new.vg_name);
 		else
 			log_error("Can't get lock for %s.", vp_new.vg_name);
-		free_vg(vg);
+		release_vg(vg);
 		return ECMD_FAILED;
 	}
 
@@ -120,13 +120,13 @@
 	log_print("%s%colume group \"%s\" successfully created",
 		  clustered_message, *clustered_message ? 'v' : 'V', vg->name);
 
-	free_vg(vg);
+	release_vg(vg);
 	return ECMD_PROCESSED;
 
 bad:
 	unlock_vg(cmd, VG_ORPHANS);
 bad_orphan:
-	free_vg(vg);
+	release_vg(vg);
 	unlock_vg(cmd, vp_new.vg_name);
 	return ECMD_FAILED;
 }
--- LVM2/tools/vgextend.c	2011/02/18 14:47:31	1.63
+++ LVM2/tools/vgextend.c	2011/08/10 20:25:31	1.64
@@ -72,7 +72,7 @@
 	log_verbose("Checking for volume group \"%s\"", vg_name);
 	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -92,7 +92,7 @@
 	} else { /* no --restore, normal vgextend */
 		if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
 			log_error("Can't get lock for orphan PVs");
-			unlock_and_free_vg(cmd, vg, vg_name);
+			unlock_and_release_vg(cmd, vg, vg_name);
 			return ECMD_FAILED;
 		}
 
@@ -135,6 +135,6 @@
 bad:
 	if (!arg_count(cmd, restoremissing_ARG))
 		unlock_vg(cmd, VG_ORPHANS);
-	unlock_and_free_vg(cmd, vg, vg_name);
+	unlock_and_release_vg(cmd, vg, vg_name);
 	return r;
 }
--- LVM2/tools/vgmerge.c	2011/03/30 14:35:00	1.73
+++ LVM2/tools/vgmerge.c	2011/08/10 20:25:31	1.74
@@ -22,7 +22,7 @@
 	log_verbose("Checking for volume group \"%s\"", vg_name);
 	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		return NULL;
 	}
 	return vg;
@@ -54,7 +54,7 @@
 		vg_to = _vgmerge_vg_read(cmd, vg_name_to);
 		if (!vg_to) {
 			stack;
-			unlock_and_free_vg(cmd, vg_from, vg_name_from);
+			unlock_and_release_vg(cmd, vg_from, vg_name_from);
 			return ECMD_FAILED;
 		}
 	} else {
@@ -67,7 +67,7 @@
 		vg_from = _vgmerge_vg_read(cmd, vg_name_from);
 		if (!vg_from) {
 			stack;
-			unlock_and_free_vg(cmd, vg_to, vg_name_to);
+			unlock_and_release_vg(cmd, vg_to, vg_name_to);
 			return ECMD_FAILED;
 		}
 	}
@@ -153,10 +153,10 @@
 bad:
 	/*
 	 * Note: as vg_to is referencing moved elements from vg_from
-	 * the order of free_vg calls is mandatory.
+	 * the order of release_vg calls is mandatory.
 	 */
-	unlock_and_free_vg(cmd, vg_to, vg_name_to);
-	unlock_and_free_vg(cmd, vg_from, vg_name_from);
+	unlock_and_release_vg(cmd, vg_to, vg_name_to);
+	unlock_and_release_vg(cmd, vg_from, vg_name_from);
 
 	return r;
 }
--- LVM2/tools/vgreduce.c	2011/07/08 19:42:11	1.112
+++ LVM2/tools/vgreduce.c	2011/08/10 20:25:31	1.113
@@ -194,7 +194,7 @@
 bad:
 	if (pvl)
 		free_pv_fid(pvl->pv);
-	unlock_and_free_vg(cmd, orphan_vg, VG_ORPHANS);
+	unlock_and_release_vg(cmd, orphan_vg, VG_ORPHANS);
 	return r;
 }
 
@@ -268,7 +268,7 @@
 			goto out;
 		}
 
-		free_vg(vg);
+		release_vg(vg);
 		log_verbose("Trying to open VG %s for recovery...", vg_name);
 
 		vg = vg_read_for_update(cmd, vg_name, NULL,
@@ -314,7 +314,7 @@
 	}
 out:
 	init_ignore_suspended_devices(saved_ignore_suspended_devices);
-	unlock_and_free_vg(cmd, vg, vg_name);
+	unlock_and_release_vg(cmd, vg, vg_name);
 
 	return ret;
 
--- LVM2/tools/vgrename.c	2011/02/18 14:47:31	1.75
+++ LVM2/tools/vgrename.c	2011/08/10 20:25:31	1.76
@@ -25,7 +25,7 @@
 	   nevertheless. */
 	vg = vg_read_for_update(cmd, vg_name_old, vgid, READ_ALLOW_EXPORTED);
 	if (vg_read_error(vg)) {
-		free_vg(vg);
+		release_vg(vg);
 		return_NULL;
 	}
 
@@ -117,7 +117,7 @@
 			return_0;
 
 		if (!_lock_new_vg_for_rename(cmd, vg_name_new)) {
-			unlock_and_free_vg(cmd, vg, vg_name_old);
+			unlock_and_release_vg(cmd, vg, vg_name_old);
 			return_0;
 		}
 	} else {
@@ -170,7 +170,7 @@
 		stack;
 
 	unlock_vg(cmd, vg_name_new);
-	unlock_and_free_vg(cmd, vg, vg_name_old);
+	unlock_and_release_vg(cmd, vg, vg_name_old);
 
 	log_print("Volume group \"%s\" successfully renamed to \"%s\"",
 		  vg_name_old, vg_name_new);
@@ -184,9 +184,9 @@
       error:
 	if (lock_vg_old_first) {
 		unlock_vg(cmd, vg_name_new);
-		unlock_and_free_vg(cmd, vg, vg_name_old);
+		unlock_and_release_vg(cmd, vg, vg_name_old);
 	} else {
-		unlock_and_free_vg(cmd, vg, vg_name_old);
+		unlock_and_release_vg(cmd, vg, vg_name_old);
 		unlock_vg(cmd, vg_name_new);
 	}
 	return 0;
--- LVM2/tools/vgsplit.c	2011/04/29 00:21:16	1.107
+++ LVM2/tools/vgsplit.c	2011/08/10 20:25:31	1.108
@@ -224,16 +224,16 @@
 	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);
-		free_vg(vg_to);
+		release_vg(vg_to);
 		return NULL;
 	}
 	if (vg_read_error(vg_to) == FAILED_EXIST) {
 		*existing_vg = 1;
-		free_vg(vg_to);
+		release_vg(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
 
 		if (vg_read_error(vg_to)) {
-			free_vg(vg_to);
+			release_vg(vg_to);
 			stack;
 			return NULL;
 		}
@@ -259,7 +259,7 @@
 
 	vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
 	if (vg_read_error(vg_from)) {
-		free_vg(vg_from);
+		release_vg(vg_from);
 		return NULL;
 	}
 	return vg_from;
@@ -334,7 +334,7 @@
 
 		vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
 		if (!vg_to) {
-			unlock_and_free_vg(cmd, vg_from, vg_name_from);
+			unlock_and_release_vg(cmd, vg_from, vg_name_from);
 			stack;
 			return ECMD_FAILED;
 		}
@@ -346,7 +346,7 @@
 		}
 		vg_from = _vgsplit_from(cmd, vg_name_from);
 		if (!vg_from) {
-			unlock_and_free_vg(cmd, vg_to, vg_name_to);
+			unlock_and_release_vg(cmd, vg_to, vg_name_to);
 			stack;
 			return ECMD_FAILED;
 		}
@@ -463,7 +463,7 @@
 	 * Finally, remove the EXPORTED flag from the new VG and write it out.
 	 */
 	if (!test_mode()) {
-		free_vg(vg_to);
+		release_vg(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
 					   READ_ALLOW_EXPORTED);
 		if (vg_read_error(vg_to)) {
@@ -491,8 +491,8 @@
 	 * vg_to references elements moved from vg_from
 	 * so vg_to has to be freed first.
 	 */
-	unlock_and_free_vg(cmd, vg_to, vg_name_to);
-	unlock_and_free_vg(cmd, vg_from, vg_name_from);
+	unlock_and_release_vg(cmd, vg_to, vg_name_to);
+	unlock_and_release_vg(cmd, vg_from, vg_name_from);
 
 	return r;
 }


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-02-18 14:16 zkabelac
  0 siblings, 0 replies; 33+ messages in thread
From: zkabelac @ 2011-02-18 14:16 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-18 14:16:12

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c fs.c 
	lib/cache      : lvmcache.c 
	lib/device     : dev-io.c 
	lib/format_text: format-text.c 
	lib/locking    : locking.c locking.h 
	lib/log        : log.c 
	lib/metadata   : metadata.c mirror.c 
	lib/mm         : memlock.c memlock.h 

Log message:
	Critical section
	
	New strategy for memory locking to decrease the number of call to
	to un/lock memory when processing critical lvm functions.
	
	Introducing functions for critical section.
	
	Inside the critical section - memory is always locked.
	When leaving the critical section, the memory stays locked
	until memlock_unlock() is called - this happens with
	sync_local_dev_names() and sync_dev_names() function call.
	
	memlock_reset() is needed to reset locking numbers after fork
	(polldaemon).
	
	The patch itself is mostly rename:
	
	memlock_inc  -> critical_section_inc
	memlock_dec  -> critical_section_dec
	memlock      -> critical_section
	
	Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec
	(mlockall()) thus they will never release or relock memory they've
	already locked memory.
	
	Macros sync_local_dev_names() and sync_dev_names() are functions.
	It's better for debugging - and also we do not need to add memlock.h
	to locking.h header (for memlock_unlock() prototyp).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1915&r2=1.1916
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/fs.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.154&r2=1.155
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.422&r2=1.423
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mm/memlock.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/WHATS_NEW	2011/02/18 14:11:22	1.1915
+++ LVM2/WHATS_NEW	2011/02/18 14:16:11	1.1916
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Change memory locking semantic and use critical sections.
   Add configurable pv_min_size to select block devices by its size.
   Add function to read 64bit ints from config find_config_tree_int64.
   Fix to make resuming exclusive cluster mirror use local target type.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/18 00:36:04	1.112
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/02/18 14:16:11	1.113
@@ -377,9 +377,9 @@
 		goto error;
 
 	if (lvi.suspended) {
-		memlock_inc(cmd);
+		critical_section_inc(cmd);
 		if (!lv_resume(cmd, resource, 0)) {
-			memlock_dec(cmd);
+			critical_section_dec(cmd);
 			goto error;
 		}
 	}
@@ -489,8 +489,8 @@
 {
 	int status = 0;
 
-	DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s, memlock = %d\n",
-		 resource, decode_locking_cmd(command), decode_flags(lock_flags), memlock());
+	DEBUGLOG("do_lock_lv: resource '%s', cmd = %s, flags = %s, critical_section = %d\n",
+		 resource, decode_locking_cmd(command), decode_flags(lock_flags), critical_section());
 
 	if (!cmd->config_valid || config_files_changed(cmd)) {
 		/* Reinitialise various settings inc. logging, filters */
@@ -551,7 +551,7 @@
 	dm_pool_empty(cmd->mem);
 	pthread_mutex_unlock(&lvm_lock);
 
-	DEBUGLOG("Command return is %d, memlock is %d\n", status, memlock());
+	DEBUGLOG("Command return is %d, critical_section is %d\n", status, critical_section());
 	return status;
 }
 
@@ -699,8 +699,8 @@
 	if (strncmp(resource, "P_#", 3) && !strncmp(resource, "P_", 2))
 		lock_cmd |= LCK_CACHE;
 
-	DEBUGLOG("do_lock_vg: resource '%s', cmd = %s, flags = %s, memlock = %d\n",
-		 resource, decode_full_locking_cmd(lock_cmd), decode_flags(lock_flags), memlock());
+	DEBUGLOG("do_lock_vg: resource '%s', cmd = %s, flags = %s, critical_section = %d\n",
+		 resource, decode_full_locking_cmd(lock_cmd), decode_flags(lock_flags), critical_section());
 
 	/* P_#global causes a full cache refresh */
 	if (!strcmp(resource, "P_" VG_GLOBAL)) {
--- LVM2/lib/activate/activate.c	2011/02/18 00:36:05	1.192
+++ LVM2/lib/activate/activate.c	2011/02/18 14:16:11	1.193
@@ -1096,7 +1096,7 @@
 		if (!error_if_not_suspended) {
 			r = 1;
 			if (info.suspended)
-				memlock_inc(cmd);
+				critical_section_inc(cmd);
 		}
 		goto out;
 	}
@@ -1118,14 +1118,14 @@
 		/* FIXME Consider aborting here */
 		stack;
 
-	memlock_inc(cmd);
+	critical_section_inc(cmd);
 
 	if (!origin_only &&
 	    (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
 		lockfs = 1;
 
 	if (!_lv_suspend_lv(lv, origin_only, lockfs, flush_required)) {
-		memlock_dec(cmd);
+		critical_section_dec(cmd);
 		fs_unlock();
 		goto out;
 	}
@@ -1210,7 +1210,7 @@
 	if (!_lv_activate_lv(lv, origin_only))
 		goto_out;
 
-	memlock_dec(cmd);
+	critical_section_dec(cmd);
 
 	if (!monitor_dev_for_events(cmd, lv, origin_only, 1))
 		stack;
@@ -1302,9 +1302,9 @@
 	if (!monitor_dev_for_events(cmd, lv, 0, 0))
 		stack;
 
-	memlock_inc(cmd);
+	critical_section_inc(cmd);
 	r = _lv_deactivate(lv);
-	memlock_dec(cmd);
+	critical_section_dec(cmd);
 
 	if (!lv_info(cmd, lv, 0, &info, 0, 0) || info.exists)
 		r = 0;
@@ -1399,10 +1399,10 @@
 	if (exclusive)
 		lv->status |= ACTIVATE_EXCL;
 
-	memlock_inc(cmd);
+	critical_section_inc(cmd);
 	if (!(r = _lv_activate_lv(lv, 0)))
 		stack;
-	memlock_dec(cmd);
+	critical_section_dec(cmd);
 
 	if (r && !monitor_dev_for_events(cmd, lv, 0, 1))
 		stack;
--- LVM2/lib/activate/fs.c	2011/02/04 22:07:44	1.60
+++ LVM2/lib/activate/fs.c	2011/02/18 14:16:11	1.61
@@ -433,7 +433,7 @@
 		  const char *lv_name, const char *dev, const char *old_lv_name,
 		  int check_udev)
 {
-	if (memlock()) {
+	if (critical_section()) {
 		if (!_stack_fs_op(type, dev_dir, vg_name, lv_name, dev,
 				  old_lv_name, check_udev))
 			return_0;
@@ -479,7 +479,7 @@
 
 void fs_unlock(void)
 {
-	if (!memlock()) {
+	if (!critical_section()) {
 		log_debug("Syncing device names");
 		/* Wait for all processed udev devices */
 		if (!dm_udev_wait(_fs_cookie))
--- LVM2/lib/cache/lvmcache.c	2011/01/10 13:15:57	1.102
+++ LVM2/lib/cache/lvmcache.c	2011/02/18 14:16:11	1.103
@@ -649,7 +649,7 @@
 	 * Note that we do not clear the PRECOMMITTED flag.
 	 */
 	if ((precommitted && !vginfo->precommitted) ||
-	    (!precommitted && vginfo->precommitted && !memlock()))
+	    (!precommitted && vginfo->precommitted && !critical_section()))
 		return NULL;
 
 	if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
@@ -783,7 +783,7 @@
 		}
 	}
 
-	if (memlock() || (scan_done_once && *scan_done_once))
+	if (critical_section() || (scan_done_once && *scan_done_once))
 		return NULL;
 
 	lvmcache_label_scan(cmd, 2);
@@ -1229,7 +1229,7 @@
 	/* If PV without mdas is already in a real VG, don't make it orphan */
 	if (is_orphan_vg(vgname) && info->vginfo &&
 	    mdas_empty_or_ignored(&info->mdas) &&
-	    !is_orphan_vg(info->vginfo->vgname) && memlock())
+	    !is_orphan_vg(info->vginfo->vgname) && critical_section())
 		return 1;
 
 	/* If moving PV from orphan to real VG, always mark it valid */
--- LVM2/lib/device/dev-io.c	2010/10/13 15:40:39	1.72
+++ LVM2/lib/device/dev-io.c	2011/02/18 14:16:11	1.73
@@ -399,7 +399,7 @@
 		dev_close_immediate(dev);
 	}
 
-	if (memlock())
+	if (critical_section())
 		/* FIXME Make this log_error */
 		log_verbose("dev_open(%s) called while suspended",
 			 dev_name(dev));
--- LVM2/lib/format_text/format-text.c	2011/02/03 01:41:03	1.154
+++ LVM2/lib/format_text/format-text.c	2011/02/18 14:16:12	1.155
@@ -1601,7 +1601,7 @@
 		return 1;
 
 	/* Perform full scan (just the first time) and try again */
-	if (!scan_label_only && !memlock() && !full_scan_done()) {
+	if (!scan_label_only && !critical_section() && !full_scan_done()) {
 		lvmcache_label_scan(info->fmt->cmd, 2);
 
 		if (_get_pv_if_in_vg(info, pv))
--- LVM2/lib/locking/locking.c	2011/02/04 20:30:18	1.92
+++ LVM2/lib/locking/locking.c	2011/02/18 14:16:12	1.93
@@ -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-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -167,7 +167,7 @@
 		return;
 
 	if (lv_op == LV_SUSPEND)
-		memlock_inc(cmd);
+		critical_section_inc(cmd);
 }
 
 static void _unlock_memory(struct cmd_context *cmd, lv_operation_t lv_op)
@@ -176,7 +176,7 @@
 		return;
 
 	if (lv_op == LV_RESUME)
-		memlock_dec(cmd);
+		critical_section_dec(cmd);
 }
 
 void reset_locking(void)
@@ -191,6 +191,8 @@
 
 	if (was_locked)
 		_unblock_signals();
+
+	memlock_reset();
 }
 
 static void _update_vg_lock_count(const char *resource, uint32_t flags)
@@ -568,3 +570,15 @@
 
 	return mode == LCK_NULL ? 0 : 1;
 }
+
+int sync_local_dev_names(struct cmd_context* cmd)
+{
+	memlock_unlock(cmd);
+	return lock_vol(cmd, VG_SYNC_NAMES, LCK_NONE | LCK_CACHE | LCK_LOCAL);
+}
+
+int sync_dev_names(struct cmd_context* cmd)
+{
+	memlock_unlock(cmd);
+	return lock_vol(cmd, VG_SYNC_NAMES, LCK_NONE | LCK_CACHE);
+}
--- LVM2/lib/locking/locking.h	2011/02/04 20:30:18	1.62
+++ LVM2/lib/locking/locking.h	2011/02/18 14:16:12	1.63
@@ -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-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -175,10 +175,14 @@
 	lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT)
 #define remote_backup_metadata(vg)	\
 	lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP)
+/* cleanup later
 #define sync_local_dev_names(cmd)	\
 	lock_vol(cmd, VG_SYNC_NAMES, LCK_NONE | LCK_CACHE | LCK_LOCAL)
 #define sync_dev_names(cmd)	\
 	lock_vol(cmd, VG_SYNC_NAMES, LCK_NONE | LCK_CACHE)
+*/
+int sync_local_dev_names(struct cmd_context* cmd);
+int sync_dev_names(struct cmd_context* cmd);
 
 /* Process list of LVs */
 int suspend_lvs(struct cmd_context *cmd, struct dm_list *lvs);
--- LVM2/lib/log/log.c	2010/10/26 08:53:25	1.60
+++ LVM2/lib/log/log.c	2011/02/18 14:16:12	1.61
@@ -336,7 +336,7 @@
 	if (level > debug_level())
 		return;
 
-	if (_log_to_file && (_log_while_suspended || !memlock())) {
+	if (_log_to_file && (_log_while_suspended || !critical_section())) {
 		fprintf(_log_file, "%s:%d %s%s", file, line, log_command_name(),
 			_msg_prefix);
 
@@ -348,14 +348,14 @@
 		fflush(_log_file);
 	}
 
-	if (_syslog && (_log_while_suspended || !memlock())) {
+	if (_syslog && (_log_while_suspended || !critical_section())) {
 		va_start(ap, format);
 		vsyslog(level, trformat, ap);
 		va_end(ap);
 	}
 
 	/* FIXME This code is unfinished - pre-extend & condense. */
-	if (!_already_logging && _log_direct && memlock()) {
+	if (!_already_logging && _log_direct && critical_section()) {
 		_already_logging = 1;
 		memset(&buf, ' ', sizeof(buf));
 		bufused = 0;
--- LVM2/lib/metadata/metadata.c	2011/02/18 14:11:23	1.422
+++ LVM2/lib/metadata/metadata.c	2011/02/18 14:16:12	1.423
@@ -2793,7 +2793,7 @@
 		lvmcache_label_scan(cmd, 0);
 		if (!(fmt = fmt_from_vgname(vgname, vgid, 1))) {
 			/* Independent MDAs aren't supported under low memory */
-			if (!cmd->independent_metadata_areas && memlock())
+			if (!cmd->independent_metadata_areas && critical_section())
 				return_NULL;
 			lvmcache_label_scan(cmd, 2);
 			if (!(fmt = fmt_from_vgname(vgname, vgid, 0)))
@@ -2922,7 +2922,7 @@
 			log_debug("Cached VG %s had incorrect PV list",
 				  vgname);
 
-			if (memlock())
+			if (critical_section())
 				inconsistent = 1;
 			else {
 				free_vg(correct_vg);
@@ -2953,7 +2953,7 @@
 		inconsistent = 0;
 
 		/* Independent MDAs aren't supported under low memory */
-		if (!cmd->independent_metadata_areas && memlock())
+		if (!cmd->independent_metadata_areas && critical_section())
 			return_NULL;
 		lvmcache_label_scan(cmd, 2);
 		if (!(fmt = fmt_from_vgname(vgname, vgid, 0)))
@@ -3213,7 +3213,7 @@
 	}
 
 	/* Mustn't scan if memory locked: ensure cache gets pre-populated! */
-	if (memlock())
+	if (critical_section())
 		return_NULL;
 
 	/* FIXME Need a genuine read by ID here - don't vg_read_internal by name! */
@@ -3892,10 +3892,10 @@
 		lvmcache_label_scan(cmd, 0);
 		if (!fmt_from_vgname(vgname, NULL, 1)) {
 			/* Independent MDAs aren't supported under low memory */
-			if (!cmd->independent_metadata_areas && memlock()) {
+			if (!cmd->independent_metadata_areas && critical_section()) {
 				/*
 				 * FIXME: Disallow calling this function if
-				 * memlock() is true.
+				 * critical_section() is true.
 				 */
 				unlock_vg(cmd, vgname);
 				return FAILED_LOCKING;
--- LVM2/lib/metadata/mirror.c	2011/01/24 14:19:05	1.141
+++ LVM2/lib/metadata/mirror.c	2011/02/18 14:16:12	1.142
@@ -974,7 +974,7 @@
 
 	/* FIXME: second suspend should not be needed
 	 * Explicitly suspend temporary LV
-	 * This balance memlock_inc() calls with memlock_dec() in resume
+	 * This balance critical_section_inc() calls with critical_section_dec() in resume
 	 * (both localy and in cluster) and also properly propagates precommited
 	 * metadata into dm table on other nodes.
 	 * (visible flag set causes the suspend is not properly propagated?)
--- LVM2/lib/mm/memlock.c	2010/12/20 13:12:57	1.33
+++ LVM2/lib/mm/memlock.c	2011/02/18 14:16:12	1.34
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -28,15 +28,27 @@
 
 #ifndef DEVMAPPER_SUPPORT
 
-void memlock_inc(struct cmd_context *cmd)
+void memlock_inc_daemon(struct cmd_context *cmd)
 {
 	return;
 }
-void memlock_dec(struct cmd_context *cmd)
+
+void memlock_dec_daemon(struct cmd_context *cmd)
 {
 	return;
 }
-int memlock(void)
+
+void critical_section_inc(struct cmd_context *cmd)
+{
+	return;
+}
+
+void critical_section_dec(struct cmd_context *cmd)
+{
+	return;
+}
+
+int critical_section(void)
 {
 	return 0;
 }
@@ -45,6 +57,16 @@
 	return;
 }
 
+void memlock_unlock(struct cmd_context *cmd)
+{
+	return;
+}
+
+void memlock_reset(void)
+{
+	return;
+}
+
 #else				/* DEVMAPPER_SUPPORT */
 
 static size_t _size_stack;
@@ -52,7 +74,8 @@
 static size_t _size_malloc = 2000000;
 
 static void *_malloc_mem = NULL;
-static int _memlock_count = 0;
+static int _mem_locked = 0;
+static int _critical_section_count = 0;
 static int _memlock_count_daemon = 0;
 static int _priority;
 static int _default_priority;
@@ -333,46 +356,59 @@
 
 static void _lock_mem_if_needed(struct cmd_context *cmd)
 {
-	if ((_memlock_count + _memlock_count_daemon) == 1)
+	if (!_mem_locked &&
+	    ((_critical_section_count + _memlock_count_daemon) == 1)) {
+		_mem_locked = 1;
 		_lock_mem(cmd);
+	}
 }
 
 static void _unlock_mem_if_possible(struct cmd_context *cmd)
 {
-	if ((_memlock_count + _memlock_count_daemon) == 0)
+	log_debug("UnlockMem l:%d cs:%d md:%d", _mem_locked,
+		  _critical_section_count, _memlock_count_daemon);
+	if (_mem_locked &&
+	    !_critical_section_count &&
+	    !_memlock_count_daemon) {
 		_unlock_mem(cmd);
+		_mem_locked = 0;
+	}
 }
 
-void memlock_inc(struct cmd_context *cmd)
+void critical_section_inc(struct cmd_context *cmd)
 {
-	++_memlock_count;
+	++_critical_section_count;
+	log_debug("critical_section_inc to %d", _critical_section_count);
 	_lock_mem_if_needed(cmd);
-	log_debug("memlock_count inc to %d", _memlock_count);
 }
 
-void memlock_dec(struct cmd_context *cmd)
+void critical_section_dec(struct cmd_context *cmd)
 {
-	if (!_memlock_count)
-		log_error(INTERNAL_ERROR "_memlock_count has dropped below 0.");
-	--_memlock_count;
-	_unlock_mem_if_possible(cmd);
-	log_debug("memlock_count dec to %d", _memlock_count);
+	if (!_critical_section_count)
+		log_error(INTERNAL_ERROR "_critical_section has dropped below 0.");
+	--_critical_section_count;
+	log_debug("critical_section_dec to %d", _critical_section_count);
+}
+
+int critical_section(void)
+{
+	return _critical_section_count;
 }
 
 /*
  * The memlock_*_daemon functions will force the mlockall() call that we need
  * to stay in memory, but they will have no effect on device scans (unlike
- * normal memlock_inc and memlock_dec). Memory is kept locked as long as either
- * of memlock or memlock_daemon is in effect.
+ * normal critical_section_inc/dec). Memory is kept locked as long as either
+ * of critical_section or memlock_daemon is in effect.
  */
 
 void memlock_inc_daemon(struct cmd_context *cmd)
 {
 	++_memlock_count_daemon;
-	if (_memlock_count_daemon == 1 && _memlock_count > 0)
-                log_error(INTERNAL_ERROR "_memlock_inc_daemon used after _memlock_inc.");
-	_lock_mem_if_needed(cmd);
+	if (_memlock_count_daemon == 1 && _critical_section_count > 0)
+                log_error(INTERNAL_ERROR "_memlock_inc_daemon used in critical section.");
 	log_debug("memlock_count_daemon inc to %d", _memlock_count_daemon);
+	_lock_mem_if_needed(cmd);
 }
 
 void memlock_dec_daemon(struct cmd_context *cmd)
@@ -380,19 +416,8 @@
 	if (!_memlock_count_daemon)
 		log_error(INTERNAL_ERROR "_memlock_count_daemon has dropped below 0.");
 	--_memlock_count_daemon;
-	_unlock_mem_if_possible(cmd);
 	log_debug("memlock_count_daemon dec to %d", _memlock_count_daemon);
-}
-
-/*
- * This disregards the daemon (dmeventd) locks, since we use memlock() to check
- * whether it is safe to run a device scan, which would normally coincide with
- * !memlock() -- but the daemon global memory lock breaks this assumption, so
- * we do not take those into account here.
- */
-int memlock(void)
-{
-	return _memlock_count;
+	_unlock_mem_if_possible(cmd);
 }
 
 void memlock_init(struct cmd_context *cmd)
@@ -408,4 +433,17 @@
 					    DEFAULT_PROCESS_PRIORITY);
 }
 
+void memlock_reset(void)
+{
+	log_debug("memlock reset.");
+	_mem_locked = 0;
+	_critical_section_count = 0;
+	_memlock_count_daemon = 0;
+}
+
+void memlock_unlock(struct cmd_context *cmd)
+{
+	_unlock_mem_if_possible(cmd);
+}
+
 #endif
--- LVM2/lib/mm/memlock.h	2010/03/05 14:48:34	1.6
+++ LVM2/lib/mm/memlock.h	2011/02/18 14:16:12	1.7
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
- * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -18,11 +18,13 @@
 
 struct cmd_context;
 
-void memlock_inc(struct cmd_context *cmd);
-void memlock_dec(struct cmd_context *cmd);
+void critical_section_inc(struct cmd_context *cmd);
+void critical_section_dec(struct cmd_context *cmd);
+int critical_section(void);
 void memlock_inc_daemon(struct cmd_context *cmd);
 void memlock_dec_daemon(struct cmd_context *cmd);
-int memlock(void);
 void memlock_init(struct cmd_context *cmd);
+void memlock_reset(void);
+void memlock_unlock(struct cmd_context *cmd);
 
 #endif


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-02-18  0:36 jbrassow
  0 siblings, 0 replies; 33+ messages in thread
From: jbrassow @ 2011-02-18  0:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-02-18 00:36:05

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h 
	lib/locking    : file_locking.c no_locking.c 

Log message:
	Fix for bug 677739: removing final exclusive cmirror snapshot,
	results in clvmd deadlock
	
	When a logical volume is activated exclusively in a cluster, the
	local (non-cluster-aware) target is used.  However, when creating
	a snapshot on the exclusive LV, the resulting suspend/resume fails
	to load the appropriate device-mapper table - instead loading the
	cluster-aware target.
	
	This patch adds an 'exclusive' parameter to the pertinent resume
	functions to allow for the right target type to be loaded.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1912&r2=1.1913
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.191&r2=1.192
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28

--- LVM2/WHATS_NEW	2011/02/09 12:11:21	1.1912
+++ LVM2/WHATS_NEW	2011/02/18 00:36:04	1.1913
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix to make resuming exclusive cluster mirror use local target type.
 
 Version 2.02.84 - 9th February 2011
 ===================================
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/04 20:30:17	1.111
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/02/18 00:36:04	1.112
@@ -399,7 +399,7 @@
 /* Resume the LV if it was active */
 static int do_resume_lv(char *resource, unsigned char lock_flags)
 {
-	int oldmode;
+	int oldmode, origin_only, exclusive;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
@@ -407,8 +407,10 @@
 		DEBUGLOG("do_resume_lv, lock not already held\n");
 		return 0;	/* We don't need to do anything */
 	}
+	origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
+	exclusive = (oldmode == LCK_EXCL) ? 1 : 0;
 
-	if (!lv_resume_if_active(cmd, resource, (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0))
+	if (!lv_resume_if_active(cmd, resource, origin_only, exclusive))
 		return EIO;
 
 	return 0;
--- LVM2/lib/activate/activate.c	2011/02/04 20:30:18	1.191
+++ LVM2/lib/activate/activate.c	2011/02/18 00:36:05	1.192
@@ -1156,8 +1156,18 @@
 }
 ***********/
 
+ /*
+  * _lv_resume
+  * @cmd
+  * @lvid_s
+  * @origin_only
+  * @exclusive:  This parameter only has an affect in cluster-context.
+  *		 It forces local target type to be used (instead of
+  *		 cluster-aware type).
+  * @error_if_not_active
+  */
 static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
-		      unsigned origin_only,
+		      unsigned origin_only, unsigned exclusive,
 		      int error_if_not_active)
 {
 	struct logical_volume *lv;
@@ -1189,6 +1199,14 @@
 		goto out;
 	}
 
+	/*
+	 * When targets are activated exclusively in a cluster, the
+	 * non-clustered target should be used.  This only happens
+	 * if ACTIVATE_EXCL is set in lv->status.
+	 */
+	if (exclusive)
+		lv->status |= ACTIVATE_EXCL;
+
 	if (!_lv_activate_lv(lv, origin_only))
 		goto_out;
 
@@ -1206,14 +1224,15 @@
 }
 
 /* Returns success if the device is not active */
-int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
+int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
+			unsigned origin_only, unsigned exclusive)
 {
-	return _lv_resume(cmd, lvid_s, origin_only, 0);
+	return _lv_resume(cmd, lvid_s, origin_only, exclusive, 0);
 }
 
 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
 {
-	return _lv_resume(cmd, lvid_s, origin_only, 1);
+	return _lv_resume(cmd, lvid_s, origin_only, 0, 1);
 }
 
 static int _lv_has_open_snapshots(struct logical_volume *lv)
--- LVM2/lib/activate/activate.h	2011/02/04 20:30:18	1.74
+++ LVM2/lib/activate/activate.h	2011/02/18 00:36:05	1.75
@@ -56,7 +56,8 @@
 /* int lv_suspend(struct cmd_context *cmd, const char *lvid_s); */
 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
 int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
-int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only);
+int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s,
+			unsigned origin_only, unsigned exclusive);
 int lv_activate(struct cmd_context *cmd, const char *lvid_s, int exclusive);
 int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s,
 			    int exclusive);
--- LVM2/lib/locking/file_locking.c	2011/02/04 19:18:17	1.57
+++ LVM2/lib/locking/file_locking.c	2011/02/18 00:36:05	1.58
@@ -293,7 +293,7 @@
 		switch (flags & LCK_TYPE_MASK) {
 		case LCK_UNLOCK:
 			log_very_verbose("Unlocking LV %s%s", resource, origin_only ? " without snapshots" : "");
-			if (!lv_resume_if_active(cmd, resource, origin_only))
+			if (!lv_resume_if_active(cmd, resource, origin_only, 0))
 				return 0;
 			break;
 		case LCK_NULL:
--- LVM2/lib/locking/no_locking.c	2011/02/04 19:21:47	1.27
+++ LVM2/lib/locking/no_locking.c	2011/02/18 00:36:05	1.28
@@ -46,7 +46,7 @@
 		case LCK_NULL:
 			return lv_deactivate(cmd, resource);
 		case LCK_UNLOCK:
-			return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0);
+			return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0, 0);
 		case LCK_READ:
 			return lv_activate_with_filter(cmd, resource, 0);
 		case LCK_WRITE:


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-02-04 20:30 jbrassow
  0 siblings, 0 replies; 33+ messages in thread
From: jbrassow @ 2011-02-04 20:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-02-04 20:30:19

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h dev_manager.c 
	lib/locking    : locking.c locking.h 
	lib/metadata   : lv_manip.c 
	tools          : vgchange.c 

Log message:
	Allow snapshots in a cluster as long as they are exclusively
	activated.
	
	In order to achieve this, we need to be able to query whether
	the origin is active exclusively (a condition of being able to
	add an exclusive snapshot).
	
	Once we are able to query the exclusive activation of an LV, we
	can safely create/activate the snapshot.
	
	A change to 'hold_lock' was also made so that a request to aquire
	a WRITE lock did not replace an EX lock, which is already a form
	of write lock.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1905&r2=1.1906
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.190&r2=1.191
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.73&r2=1.74
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.212&r2=1.213
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.246&r2=1.247
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119

--- LVM2/WHATS_NEW	2011/02/04 19:33:53	1.1905
+++ LVM2/WHATS_NEW	2011/02/04 20:30:17	1.1906
@@ -1,5 +1,6 @@
 Version 2.02.83 - 
 ===================================
+  Allow exclusive activation of snapshots in a cluster.
   Add --addnodeonresume, --addnodeoncreate options for dmsetup create.
   Use cluster-wide message to request device name sync.
   Fix operation node stacking for consecutive dm ops.
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/04 19:21:47	1.110
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/02/04 20:30:17	1.111
@@ -240,9 +240,17 @@
 
 	lvi = lookup_info(resource);
 
-	if (lvi && lvi->lock_mode == mode) {
-		DEBUGLOG("hold_lock, lock mode %d already held\n", mode);
-		return 0;
+	if (lvi) {
+		if (lvi->lock_mode == mode) {
+			DEBUGLOG("hold_lock, lock mode %d already held\n",
+				 mode);
+			return 0;
+		}
+		if ((lvi->lock_mode == LCK_EXCL) && (mode == LCK_WRITE)) {
+			DEBUGLOG("hold_lock, lock already held LCK_EXCL, "
+				 "ignoring LCK_WRITE request");
+			return 0;
+		}
 	}
 
 	/* Only allow explicit conversions */
--- LVM2/lib/activate/activate.c	2011/02/04 19:14:40	1.190
+++ LVM2/lib/activate/activate.c	2011/02/04 20:30:18	1.191
@@ -708,39 +708,108 @@
 }
 
 /*
+ * _lv_is_active
+ * @lv:        logical volume being queried
+ * @locally:   set if active locally (when provided)
+ * @exclusive: set if active exclusively (when provided)
+ *
  * Determine whether an LV is active locally or in a cluster.
- * Assumes vg lock held.
- * Returns:
- * 0 - not active locally or on any node in cluster
- * 1 - active either locally or some node in the cluster
+ * In addition to the return code which indicates whether or
+ * not the LV is active somewhere, two other values are set
+ * to yield more information about the status of the activation:
+ *	return	locally	exclusively	status
+ *	======	=======	===========	======
+ *	   0	   0	    0		not active
+ *	   1	   0	    0		active remotely
+ *	   1	   0	    1		exclusive remotely
+ *	   1	   1	    0		active locally and possibly remotely
+ *	   1	   1	    1		exclusive locally (or local && !cluster)
+ * The VG lock must be held to call this function.
+ *
+ * Returns: 0 or 1
  */
-int lv_is_active(struct logical_volume *lv)
+static int _lv_is_active(struct logical_volume *lv,
+			 int *locally, int *exclusive)
 {
-	int ret;
+	int r, l, e; /* remote, local, and exclusive */
+
+	r = l = e = 0;
 
 	if (_lv_active(lv->vg->cmd, lv))
-		return 1;
+		l = 1;
 
-	if (!vg_is_clustered(lv->vg))
-		return 0;
+	if (!vg_is_clustered(lv->vg)) {
+		e = 1;  /* exclusive by definition */
+		goto out;
+	}
+
+	/* Active locally, and the caller doesn't care about exclusive */
+	if (l && !exclusive)
+		goto out;
 
-	if ((ret = remote_lock_held(lv->lvid.s)) >= 0)
-		return ret;
+	if ((r = remote_lock_held(lv->lvid.s, &e)) >= 0)
+		goto out;
 
 	/*
-	 * Old compatibility code if locking doesn't support lock query
-	 * FIXME: check status to not deactivate already activate device
+	 * If lock query is not supported (due to interfacing with old
+	 * code), then we cannot evaluate exclusivity properly.
+	 *
+	 * Old users of this function will never be affected by this,
+	 * since they are only concerned about active vs. not active.
+	 * New users of this function who specifically ask for 'exclusive'
+	 * will be given an error message.
 	 */
+	if (l) {
+		if (exclusive)
+			log_error("Unable to determine exclusivity of %s",
+				  lv->name);
+		goto out;
+	}
+
 	if (activate_lv_excl(lv->vg->cmd, lv)) {
 		if (!deactivate_lv(lv->vg->cmd, lv))
 			stack;
 		return 0;
 	}
 
-	/*
-	 * Exclusive local activation failed so assume it is active elsewhere.
-	 */
-	return 1;
+out:
+	if (locally)
+		*locally = l;
+	if (exclusive)
+		*exclusive = e;
+
+	log_very_verbose("%s/%s is %sactive%s%s",
+			 lv->vg->name, lv->name,
+			 (r || l) ? "" : "not ",
+			 (exclusive && e) ? " exclusive" : "",
+			 e ? (l ? " locally" : " remotely") : "");
+
+	return r || l;
+}
+
+int lv_is_active(struct logical_volume *lv)
+{
+	return _lv_is_active(lv, NULL, NULL);
+}
+
+/*
+int lv_is_active_locally(struct logical_volume *lv)
+{
+	int l;
+	return _lv_is_active(lv, &l, NULL) && l;
+}
+*/
+
+int lv_is_active_exclusive_locally(struct logical_volume *lv)
+{
+	int l, e;
+	return _lv_is_active(lv, &l, &e) && l && e;
+}
+
+int lv_is_active_exclusive_remotely(struct logical_volume *lv)
+{
+	int l, e;
+	return _lv_is_active(lv, &l, &e) && !l && e;
 }
 
 #ifdef DMEVENTD
--- LVM2/lib/activate/activate.h	2011/01/10 14:02:31	1.73
+++ LVM2/lib/activate/activate.h	2011/02/04 20:30:18	1.74
@@ -94,6 +94,8 @@
 int lvs_in_vg_opened(const struct volume_group *vg);
 
 int lv_is_active(struct logical_volume *lv);
+int lv_is_active_exclusive_locally(struct logical_volume *lv);
+int lv_is_active_exclusive_remotely(struct logical_volume *lv);
 
 int lv_has_target_type(struct dm_pool *mem, struct logical_volume *lv,
 		       const char *layer, const char *target_type);
--- LVM2/lib/activate/dev_manager.c	2011/01/10 14:02:31	1.212
+++ LVM2/lib/activate/dev_manager.c	2011/02/04 20:30:18	1.213
@@ -1390,10 +1390,6 @@
 	/* If this is a snapshot origin, add real LV */
 	/* If this is a snapshot origin + merging snapshot, add cow + real LV */
 	} else if (lv_is_origin(seg->lv) && !layer) {
-		if (vg_is_clustered(seg->lv->vg)) {
-			log_error("Clustered snapshots are not yet supported");
-			return 0;
-		}
 		if (lv_is_merging_origin(seg->lv)) {
 			if (!_add_new_lv_to_dtree(dm, dtree,
 			     find_merging_cow(seg->lv)->cow, "cow"))
--- LVM2/lib/locking/locking.c	2011/02/02 13:34:00	1.91
+++ LVM2/lib/locking/locking.c	2011/02/04 20:30:18	1.92
@@ -545,7 +545,7 @@
 	return (_locking.flags & LCK_CLUSTERED) ? 1 : 0;
 }
 
-int remote_lock_held(const char *vol)
+int remote_lock_held(const char *vol, int *exclusive)
 {
 	int mode = LCK_NULL;
 
@@ -563,5 +563,8 @@
 		return 1;
 	}
 
+	if (exclusive)
+		*exclusive = (mode == LCK_EXCL);
+
 	return mode == LCK_NULL ? 0 : 1;
 }
--- LVM2/lib/locking/locking.h	2011/02/04 19:18:17	1.61
+++ LVM2/lib/locking/locking.h	2011/02/04 20:30:18	1.62
@@ -25,7 +25,7 @@
 int vg_write_lock_held(void);
 int locking_is_clustered(void);
 
-int remote_lock_held(const char *vol);
+int remote_lock_held(const char *vol, int *exclusive);
 
 /*
  * LCK_VG:
--- LVM2/lib/metadata/lv_manip.c	2011/01/28 02:58:01	1.246
+++ LVM2/lib/metadata/lv_manip.c	2011/02/04 20:30:18	1.247
@@ -3164,11 +3164,6 @@
 				  "device-mapper kernel driver");
 			return 0;
 		}
-		/* FIXME Allow exclusive activation. */
-		if (vg_is_clustered(vg)) {
-			log_error("Clustered snapshots are not yet supported.");
-			return 0;
-		}
 
 		/* Must zero cow */
 		status |= LVM_WRITE;
@@ -3217,6 +3212,13 @@
 				return 0;
 			}
 			origin_active = info.exists;
+
+			if (vg_is_clustered(vg) &&
+			    !lv_is_active_exclusive_locally(org)) {
+				log_error("%s must be active exclusively to"
+					  " create snapshot", org->name);
+				return 0;
+			}
 		}
 	}
 
--- LVM2/tools/vgchange.c	2011/01/24 13:38:32	1.118
+++ LVM2/tools/vgchange.c	2011/02/04 20:30:19	1.119
@@ -115,6 +115,16 @@
 		    ((lv->status & PVMOVE) ))
 			continue;
 
+		/*
+		 * If the LV is active exclusive remotely,
+		 * then ignore it here
+		 */
+		if (lv_is_active_exclusive_remotely(lv)) {
+			log_verbose("%s/%s is exclusively active on"
+				    " a remote node", vg->name, lv->name);
+			continue;
+		}
+
 		expected_count++;
 
 		if (activate == CHANGE_AN) {


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-02-03 16:03 zkabelac
  0 siblings, 0 replies; 33+ messages in thread
From: zkabelac @ 2011-02-03 16:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-03 16:03:13

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/format_text: import_vsn1.c 

Log message:
	Increase hash table size to 1024 lv names and 64 pv uuids

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1901&r2=1.1902
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82

--- LVM2/WHATS_NEW	2011/02/03 01:58:20	1.1901
+++ LVM2/WHATS_NEW	2011/02/03 16:03:13	1.1902
@@ -1,5 +1,6 @@
 Version 2.02.83 - 
 ===================================
+  Increase hash table size to 1024 lv names and 64 pv uuids.
   Remove fs_unlock() from lv_resume path.
   Fix wipe size when setting up mda.
   Remove unneeded checks for open_count in lv_info().
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/03 01:58:20	1.108
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/02/03 16:03:13	1.109
@@ -197,7 +197,7 @@
 void init_lvhash()
 {
 	/* Create hash table for keeping LV locks & status */
-	lv_hash = dm_hash_create(100);
+	lv_hash = dm_hash_create(1024);
 	pthread_mutex_init(&lv_hash_lock, NULL);
 	pthread_mutex_init(&lvm_lock, NULL);
 }
--- LVM2/lib/format_text/import_vsn1.c	2011/01/06 15:25:07	1.81
+++ LVM2/lib/format_text/import_vsn1.c	2011/02/03 16:03:13	1.82
@@ -756,7 +756,7 @@
 	 * The pv hash memorises the pv section names -> pv
 	 * structures.
 	 */
-	if (!(pv_hash = dm_hash_create(32))) {
+	if (!(pv_hash = dm_hash_create(64))) {
 		log_error("Couldn't create hash table.");
 		goto bad;
 	}
@@ -784,7 +784,7 @@
 	 * The lv hash memorises the lv section names -> lv
 	 * structures.
 	 */
-	if (!(lv_hash = dm_hash_create(32))) {
+	if (!(lv_hash = dm_hash_create(1024))) {
 		log_error("Couldn't create hash table.");
 		goto bad;
 	}


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2011-02-03  1:58 zkabelac
  0 siblings, 0 replies; 33+ messages in thread
From: zkabelac @ 2011-02-03  1:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-03 01:58:21

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c 

Log message:
	Remove fs_unlock from lv_resume path
	
	Keep it within clvmd until message for SYNC starts to work.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1900&r2=1.1901
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.188&r2=1.189

--- LVM2/WHATS_NEW	2011/02/03 01:41:03	1.1900
+++ LVM2/WHATS_NEW	2011/02/03 01:58:20	1.1901
@@ -1,5 +1,6 @@
 Version 2.02.83 - 
 ===================================
+  Remove fs_unlock() from lv_resume path.
   Fix wipe size when setting up mda.
   Remove unneeded checks for open_count in lv_info().
   Synchronize with udev before checking open_count in lv_info().
--- LVM2/daemons/clvmd/lvm-functions.c	2011/02/02 20:04:39	1.107
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/02/03 01:58:20	1.108
@@ -517,6 +517,7 @@
 	case LCK_UNLOCK:
 	case LCK_LV_RESUME:	/* if active */
 		status = do_resume_lv(resource, lock_flags);
+		fs_unlock();
 		break;
 
 	case LCK_LV_ACTIVATE:
--- LVM2/lib/activate/activate.c	2011/02/03 01:24:46	1.188
+++ LVM2/lib/activate/activate.c	2011/02/03 01:58:21	1.189
@@ -1124,7 +1124,6 @@
 		goto_out;
 
 	memlock_dec(cmd);
-	fs_unlock();
 
 	if (!monitor_dev_for_events(cmd, lv, origin_only, 1))
 		stack;


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-12-08 20:51 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2010-12-08 20:51 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-12-08 20:50:52

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c 
	lib/cache      : lvmcache.c 
	lib/format_text: archive.c archiver.c format-text.c 
	lib/locking    : locking.h 
	lib/metadata   : metadata-exported.h metadata.c 
	                 replicator_manip.c 
	liblvm         : lvm_vg.c 
	tools          : lvconvert.c lvcreate.c lvrename.c lvresize.c 
	                 polldaemon.c pvchange.c pvcreate.c pvdisplay.c 
	                 pvmove.c pvresize.c reporter.c toollib.c 
	                 vgcreate.c vgextend.c vgmerge.c vgreduce.c 
	                 vgrename.c vgsplit.c 

Log message:
	Rename vg_release to free_vg.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1831&r2=1.1832
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.181&r2=1.182
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.172&r2=1.173
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.414&r2=1.415
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.151&r2=1.152
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.226&r2=1.227
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvrename.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.216&r2=1.217
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103

--- LVM2/WHATS_NEW	2010/12/08 19:26:35	1.1831
+++ LVM2/WHATS_NEW	2010/12/08 20:50:48	1.1832
@@ -1,7 +1,7 @@
 Version 2.02.79 -
 ===================================
   Cope better with an undefined target_percent operation in _percent_run.
-  Fix write to released memory in vg_release().  (2.02.78)
+  Fix write to released memory in vg_release and rename to free_vg.  (2.02.78)
 
 Version 2.02.78 - 6th December 2010
 ===================================
--- LVM2/daemons/clvmd/lvm-functions.c	2010/12/06 17:57:15	1.103
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/12/08 20:50:48	1.104
@@ -863,7 +863,7 @@
 	else
 		log_error("Error backing up metadata, can't find VG for group %s", vgname);
 
-	vg_release(vg);
+	free_vg(vg);
 	dm_pool_empty(cmd->mem);
 
 	pthread_mutex_unlock(&lvm_lock);
--- LVM2/lib/activate/activate.c	2010/11/30 11:53:31	1.181
+++ LVM2/lib/activate/activate.c	2010/12/08 20:50:49	1.182
@@ -491,7 +491,7 @@
 		origin_only = 0;
 
 	r = lv_info(cmd, lv, origin_only, info, with_open_count, with_read_ahead);
-	vg_release(lv->vg);
+	free_vg(lv->vg);
 
 	return r;
 }
@@ -1052,10 +1052,10 @@
 	r = 1;
 out:
 	if (lv_pre)
-		vg_release(lv_pre->vg);
+		free_vg(lv_pre->vg);
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		vg_release(lv->vg);
+		free_vg(lv->vg);
 	}
 
 	return r;
@@ -1120,7 +1120,7 @@
 	r = 1;
 out:
 	if (lv)
-		vg_release(lv->vg);
+		free_vg(lv->vg);
 
 	return r;
 }
@@ -1213,7 +1213,7 @@
 out:
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		vg_release(lv->vg);
+		free_vg(lv->vg);
 	}
 
 	return r;
@@ -1243,7 +1243,7 @@
 	r = 1;
 out:
 	if (lv)
-		vg_release(lv->vg);
+		free_vg(lv->vg);
 
 	return r;
 }
@@ -1313,7 +1313,7 @@
 out:
 	if (lv) {
 		lv_release_replicator_vgs(lv);
-		vg_release(lv->vg);
+		free_vg(lv->vg);
 	}
 
 	return r;
--- LVM2/lib/cache/lvmcache.c	2010/12/01 10:39:29	1.98
+++ LVM2/lib/cache/lvmcache.c	2010/12/08 20:50:49	1.99
@@ -643,7 +643,7 @@
 
 	if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid))) {
 		_free_cached_vgmetadata(vginfo);
-		vg_release(vg);
+		free_vg(vg);
 		return_NULL;
 	}
 
--- LVM2/lib/format_text/archive.c	2010/09/09 13:13:12	1.39
+++ LVM2/lib/format_text/archive.c	2010/12/08 20:50:49	1.40
@@ -329,7 +329,7 @@
 	log_print("Description:\t%s", desc ? : "<No description>");
 	log_print("Backup Time:\t%s", ctime(&when));
 
-	vg_release(vg);
+	free_vg(vg);
 	tf->fmt->ops->destroy_instance(tf);
 }
 
--- LVM2/lib/format_text/archiver.c	2010/09/09 13:07:14	1.34
+++ LVM2/lib/format_text/archiver.c	2010/12/08 20:50:49	1.35
@@ -365,7 +365,7 @@
 		log_error("Cannot restore Volume Group %s with %i PVs "
 			  "marked as missing.", vg->name, missing_pvs);
 
-	vg_release(vg);
+	free_vg(vg);
 	return r;
 }
 
@@ -446,14 +446,14 @@
 	    (vg->seqno == vg_backup->seqno) &&
 	    (id_equal(&vg->id, &vg_backup->id))) {
 		log_suppress(old_suppress);
-		vg_release(vg_backup);
+		free_vg(vg_backup);
 		return;
 	}
 	log_suppress(old_suppress);
 
 	if (vg_backup) {
 		archive(vg_backup);
-		vg_release(vg_backup);
+		free_vg(vg_backup);
 	}
 	archive(vg);
 	backup_locally(vg);
--- LVM2/lib/format_text/format-text.c	2010/11/29 11:16:58	1.149
+++ LVM2/lib/format_text/format-text.c	2010/12/08 20:50:49	1.150
@@ -857,7 +857,7 @@
 	 * check that it contains the correct volume group.
 	 */
 	if (vgname && strcmp(vgname, vg->name)) {
-		dm_pool_destroy(vg->vgmem);
+		free_vg(vg);
 		log_error("'%s' does not contain volume group '%s'.",
 			  read_path, vgname);
 		return NULL;
@@ -1085,7 +1085,7 @@
 							     path))) {
 					/* FIXME Store creation host in vg */
 					lvmcache_update_vg(vg, 0);
-					dm_pool_destroy(vg->vgmem);
+					free_vg(vg);
 				}
 			}
 
--- LVM2/lib/locking/locking.h	2010/08/17 19:25:05	1.58
+++ LVM2/lib/locking/locking.h	2010/12/08 20:50:50	1.59
@@ -143,10 +143,10 @@
 		0)
 
 #define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
-#define unlock_and_release_vg(cmd, vg, vol) \
+#define unlock_and_free_vg(cmd, vg, vol) \
 	do { \
 		unlock_vg(cmd, vol); \
-		vg_release(vg); \
+		free_vg(vg); \
 	} while (0)
 
 #define resume_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_RESUME)
--- LVM2/lib/metadata/metadata-exported.h	2010/11/30 11:53:32	1.172
+++ LVM2/lib/metadata/metadata-exported.h	2010/12/08 20:50:50	1.173
@@ -425,10 +425,10 @@
 		     struct volume_group *vg,
 		     force_t force);
 /*
- * vg_release() must be called on every struct volume_group allocated
+ * free_vg() must be called on every struct volume_group allocated
  * by vg_create() or vg_read_internal() to free it when no longer required.
  */
-void vg_release(struct volume_group *vg);
+void free_vg(struct volume_group *vg);
 
 /* Manipulate LVs */
 struct logical_volume *lv_create_empty(const char *name,
@@ -682,7 +682,7 @@
 struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs,
 			     const char *vg_name, const char *vgid);
 int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs);
-void cmd_vg_release(struct dm_list *cmd_vgs);
+void free_cmd_vgs(struct dm_list *cmd_vgs);
 
 int find_replicator_vgs(struct logical_volume *lv);
 
--- LVM2/lib/metadata/metadata.c	2010/12/08 10:45:37	1.414
+++ LVM2/lib/metadata/metadata.c	2010/12/08 20:50:50	1.415
@@ -366,7 +366,7 @@
 		}
 	}
 out:
-	vg_release(vg);
+	free_vg(vg);
 	return r;
 }
 
@@ -920,7 +920,7 @@
 	/* is this vg name already in use ? */
 	if ((vg = vg_read_internal(cmd, vg_name, NULL, 1, &consistent))) {
 		log_error("A volume group called '%s' already exists.", vg_name);
-		unlock_and_release_vg(cmd, vg, vg_name);
+		unlock_and_free_vg(cmd, vg, vg_name);
 		return _vg_make_handle(cmd, NULL, FAILED_EXIST);
 	}
 
@@ -988,7 +988,7 @@
 	return _vg_make_handle(cmd, vg, SUCCESS);
 
 bad:
-	unlock_and_release_vg(cmd, vg, vg_name);
+	unlock_and_free_vg(cmd, vg, vg_name);
 	/* FIXME: use _vg_make_handle() w/proper error code */
 	return NULL;
 }
@@ -2700,7 +2700,7 @@
 		}
 		return correct_vg;
 	} else {
-		vg_release(correct_vg);
+		free_vg(correct_vg);
 		correct_vg = NULL;
 	}
 
@@ -2741,7 +2741,7 @@
 		    (!use_precommitted &&
 		     !(vg = mda->ops->vg_read(fid, vgname, mda)))) {
 			inconsistent = 1;
-			vg_release(vg);
+			free_vg(vg);
 			continue;
 		}
 		if (!correct_vg) {
@@ -2760,13 +2760,13 @@
 				inconsistent_seqno = 1;
 			}
 			if (vg->seqno > correct_vg->seqno) {
-				vg_release(correct_vg);
+				free_vg(correct_vg);
 				correct_vg = vg;
 			}
 		}
 
 		if (vg != correct_vg)
-			vg_release(vg);
+			free_vg(vg);
 	}
 
 	/* Ensure every PV in the VG was in the cache */
@@ -2841,7 +2841,7 @@
 			if (memlock())
 				inconsistent = 1;
 			else {
-				vg_release(correct_vg);
+				free_vg(correct_vg);
 				correct_vg = NULL;
 			}
 		} else dm_list_iterate_items(pvl, &correct_vg->pvs) {
@@ -2850,14 +2850,14 @@
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
 					  vgname);
-				vg_release(correct_vg);
+				free_vg(correct_vg);
 				correct_vg = NULL;
 				break;
 			}
 		}
 
 		if (correct_vg && inconsistent_mdas) {
-			vg_release(correct_vg);
+			free_vg(correct_vg);
 			correct_vg = NULL;
 		}
 	}
@@ -2896,7 +2896,7 @@
 			if (!correct_vg) {
 				correct_vg = vg;
 				if (!_update_pv_list(cmd->mem, &all_pvs, correct_vg)) {
-					vg_release(vg);
+					free_vg(vg);
 					return_NULL;
 				}
 				continue;
@@ -2920,18 +2920,18 @@
 					inconsistent_seqno = 1;
 				}
 				if (!_update_pv_list(cmd->mem, &all_pvs, vg)) {
-					vg_release(vg);
-					vg_release(correct_vg);
+					free_vg(vg);
+					free_vg(correct_vg);
 					return_NULL;
 				}
 				if (vg->seqno > correct_vg->seqno) {
-					vg_release(correct_vg);
+					free_vg(correct_vg);
 					correct_vg = vg;
 				}
 			}
 
 			if (vg != correct_vg)
-				vg_release(vg);
+				free_vg(vg);
 		}
 
 		/* Give up looking */
@@ -2961,7 +2961,7 @@
 				*consistent = 0;
 				return correct_vg;
 			}
-			vg_release(correct_vg);
+			free_vg(correct_vg);
 			return NULL;
 		}
 
@@ -2989,7 +2989,7 @@
 		cmd->handles_missing_pvs = 1;
 		if (!vg_write(correct_vg)) {
 			log_error("Automatic metadata correction failed");
-			vg_release(correct_vg);
+			free_vg(correct_vg);
 			cmd->handles_missing_pvs = saved_handles_missing_pvs;
 			return NULL;
 		}
@@ -2998,7 +2998,7 @@
 		if (!vg_commit(correct_vg)) {
 			log_error("Automatic metadata correction commit "
 				  "failed");
-			vg_release(correct_vg);
+			free_vg(correct_vg);
 			return NULL;
 		}
 
@@ -3008,13 +3008,13 @@
 					goto next_pv;
 			}
 			if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
-				vg_release(correct_vg);
+				free_vg(correct_vg);
 				return_NULL;
 			}
 			log_error("Removing PV %s (%s) that no longer belongs to VG %s",
 				  pv_dev_name(pvl->pv), uuid, correct_vg->name);
 			if (!pv_write_orphan(cmd, pvl->pv)) {
-				vg_release(correct_vg);
+				free_vg(correct_vg);
 				return_NULL;
 			}
 
@@ -3036,7 +3036,7 @@
 			  "volume group %s", correct_vg->name);
 		log_error("Please restore the metadata by running "
 			  "vgcfgrestore.");
-		vg_release(correct_vg);
+		free_vg(correct_vg);
 		return NULL;
 	}
 
@@ -3056,7 +3056,7 @@
 	if (!check_pv_segments(vg)) {
 		log_error(INTERNAL_ERROR "PV segments corrupted in %s.",
 			  vg->name);
-		vg_release(vg);
+		free_vg(vg);
 		return NULL;
 	}
 
@@ -3064,7 +3064,7 @@
 		if (!check_lv_segments(lvl->lv, 0)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
-			vg_release(vg);
+			free_vg(vg);
 			return NULL;
 		}
 	}
@@ -3076,7 +3076,7 @@
 		if (!check_lv_segments(lvl->lv, 1)) {
 			log_error(INTERNAL_ERROR "LV segments corrupted in %s.",
 				  lvl->lv->name);
-			vg_release(vg);
+			free_vg(vg);
 			return NULL;
 		}
 	}
@@ -3084,14 +3084,16 @@
 	return vg;
 }
 
-void vg_release(struct volume_group *vg)
+void free_vg(struct volume_group *vg)
 {
-	if (!vg || !vg->vgmem)
+	if (!vg)
 		return;
 
-	if (vg->cmd && vg->vgmem == vg->cmd->mem)
+	if (vg->cmd && vg->vgmem == vg->cmd->mem) {
 		log_error(INTERNAL_ERROR "global memory pool used for VG %s",
 			  vg->name);
+		return;
+	}
 
 	dm_pool_destroy(vg->vgmem);
 }
@@ -3122,7 +3124,7 @@
 					  "inconsistent", vg->name);
 			return vg;
 		}
-		vg_release(vg);
+		free_vg(vg);
 	}
 
 	/* Mustn't scan if memory locked: ensure cache gets pre-populated! */
@@ -3151,12 +3153,12 @@
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vgname);
-				vg_release(vg);
+				free_vg(vg);
 				return NULL;
 			}
 			return vg;
 		}
-		vg_release(vg);
+		free_vg(vg);
 	}
 
 	return NULL;
@@ -3190,7 +3192,7 @@
 
 	return lvl->lv;
 out:
-	vg_release(vg);
+	free_vg(vg);
 	return NULL;
 }
 
@@ -3384,12 +3386,12 @@
 			dm_list_iterate_items(pvl, &vg->pvs) {
 				if (!(pvl_copy = _copy_pvl(cmd->mem, pvl))) {
 					log_error("PV list allocation failed");
-					vg_release(vg);
+					free_vg(vg);
 					return 0;
 				}
 				dm_list_add(results, &pvl_copy->list);
 			}
-		vg_release(vg);
+		free_vg(vg);
 	}
 	init_pvmove(old_pvmove);
 
@@ -3592,7 +3594,7 @@
 		return_NULL;
 
 	if (!consistent) {
-		vg_release(vg);
+		free_vg(vg);
 		return_NULL;
 	}
 
@@ -3664,7 +3666,7 @@
 
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
 	if (!consistent && !failure) {
-		vg_release(vg);
+		free_vg(vg);
 		if (!(vg = _recover_vg(cmd, vg_name, vgid))) {
 			log_error("Recovery of volume group \"%s\" failed.",
 				  vg_name);
--- LVM2/lib/metadata/replicator_manip.c	2010/05/21 14:07:19	1.6
+++ LVM2/lib/metadata/replicator_manip.c	2010/12/08 20:50:50	1.7
@@ -590,16 +590,16 @@
  *
  * \param cmd_vgs	Contains list of cmd_vg entries.
  */
-void cmd_vg_release(struct dm_list *cmd_vgs)
+void free_cmd_vgs(struct dm_list *cmd_vgs)
 {
 	struct cmd_vg *cvl;
 
 	/* Backward iterate cmd_vg list */
 	dm_list_iterate_back_items(cvl, cmd_vgs) {
 		if (vg_read_error(cvl->vg))
-			vg_release(cvl->vg);
+			free_vg(cvl->vg);
 		else
-			unlock_and_release_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name);
+			unlock_and_free_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name);
 		cvl->vg = NULL;
 	}
 }
@@ -687,7 +687,7 @@
 
 	dm_list_iterate_back_items(rsite, &first_seg(lv)->replicator->rsites)
 		if (rsite->vg_name && rsite->vg) {
-			vg_release(rsite->vg);
+			free_vg(rsite->vg);
 			rsite->vg = NULL;
 		}
 }
--- LVM2/liblvm/lvm_vg.c	2010/11/17 20:12:40	1.48
+++ LVM2/liblvm/lvm_vg.c	2010/12/08 20:50:51	1.49
@@ -56,7 +56,7 @@
 	vg = vg_create((struct cmd_context *)libh, vg_name);
 	/* FIXME: error handling is still TBD */
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		return NULL;
 	}
 	vg->open_mode = 'w';
@@ -159,9 +159,9 @@
 int lvm_vg_close(vg_t vg)
 {
 	if (vg_read_error(vg) == FAILED_LOCKING)
-		vg_release(vg);
+		free_vg(vg);
 	else
-		unlock_and_release_vg(vg->cmd, vg, vg->name);
+		unlock_and_free_vg(vg->cmd, vg, vg->name);
 	return 0;
 }
 
@@ -196,7 +196,7 @@
 	vg = vg_read((struct cmd_context *)libh, vgname, NULL, internal_flags);
 	if (vg_read_error(vg)) {
 		/* FIXME: use log_errno either here in inside vg_read */
-		vg_release(vg);
+		free_vg(vg);
 		return NULL;
 	}
 	/* FIXME: combine this with locking ? */
--- LVM2/tools/lvconvert.c	2010/11/30 11:53:33	1.151
+++ LVM2/tools/lvconvert.c	2010/12/08 20:50:51	1.152
@@ -1619,7 +1619,7 @@
 {
 	/*
 	 * Returns NULL if the requested LV doesn't exist;
-	 * otherwise the caller must vg_release(lv->vg)
+	 * otherwise the caller must free_vg(lv->vg)
 	 * - it is also up to the caller to unlock_vg() as needed
 	 */
 	struct volume_group *vg;
@@ -1627,13 +1627,13 @@
 
 	vg = _get_lvconvert_vg(cmd, vg_name, NULL);
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		return_NULL;
 	}
 
 	if (!(lv = _get_lvconvert_lv(cmd, vg, lv_name, NULL, 0))) {
 		log_error("Can't find LV %s in VG %s", lv_name, vg_name);
-		unlock_and_release_vg(cmd, vg, vg_name);
+		unlock_and_free_vg(cmd, vg, vg_name);
 		return NULL;
 	}
 
@@ -1686,7 +1686,7 @@
 		ret = poll_logical_volume(cmd, lp->lv_to_poll,
 					  lp->wait_completion);
 
-	vg_release(lv->vg);
+	free_vg(lv->vg);
 out:
 	init_ignore_suspended_devices(saved_ignore_suspended_devices);
 	return ret;
@@ -1736,7 +1736,7 @@
 		}
 	}
 
-	vg_release(refreshed_lv->vg);
+	free_vg(refreshed_lv->vg);
 
 	return ret;
 }
--- LVM2/tools/lvcreate.c	2010/11/30 11:53:33	1.226
+++ LVM2/tools/lvcreate.c	2010/12/08 20:50:51	1.227
@@ -546,7 +546,7 @@
 	log_verbose("Finding volume group \"%s\"", lp.vg_name);
 	vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -561,6 +561,6 @@
 		r = ECMD_FAILED;
 	}
 out:
-	unlock_and_release_vg(cmd, vg, lp.vg_name);
+	unlock_and_free_vg(cmd, vg, lp.vg_name);
 	return r;
 }
--- LVM2/tools/lvrename.c	2009/09/14 22:47:49	1.56
+++ LVM2/tools/lvrename.c	2010/12/08 20:50:51	1.57
@@ -104,7 +104,7 @@
 	log_verbose("Checking for existing volume group \"%s\"", vg_name);
 	vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -123,6 +123,6 @@
 
 	r = ECMD_PROCESSED;
 error:
-	unlock_and_release_vg(cmd, vg, vg_name);
+	unlock_and_free_vg(cmd, vg, vg_name);
 	return r;
 }
--- LVM2/tools/lvresize.c	2010/11/30 11:53:33	1.126
+++ LVM2/tools/lvresize.c	2010/12/08 20:50:51	1.127
@@ -738,7 +738,7 @@
 	log_verbose("Finding volume group %s", lp.vg_name);
 	vg = vg_read_for_update(cmd, lp.vg_name, NULL, 0);
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -746,7 +746,7 @@
 	if (!(r = _lvresize(cmd, vg, &lp)))
 		stack;
 
-	unlock_and_release_vg(cmd, vg, lp.vg_name);
+	unlock_and_free_vg(cmd, vg, lp.vg_name);
 
 	return r;
 }
--- LVM2/tools/polldaemon.c	2010/11/30 11:53:33	1.38
+++ LVM2/tools/polldaemon.c	2010/12/08 20:50:51	1.39
@@ -183,7 +183,7 @@
 		/* Locks the (possibly renamed) VG again */
 		vg = parms->poll_fns->get_copy_vg(cmd, name, uuid);
 		if (vg_read_error(vg)) {
-			vg_release(vg);
+			free_vg(vg);
 			log_error("ABORTING: Can't reread VG for %s", name);
 			/* What more could we do here? */
 			return 0;
@@ -193,16 +193,16 @@
 							parms->lv_type))) {
 			log_error("ABORTING: Can't find LV in %s for %s",
 				  vg->name, name);
-			unlock_and_release_vg(cmd, vg, vg->name);
+			unlock_and_free_vg(cmd, vg, vg->name);
 			return 0;
 		}
 
 		if (!_check_lv_status(cmd, vg, lv, name, parms, &finished)) {
-			unlock_and_release_vg(cmd, vg, vg->name);
+			unlock_and_free_vg(cmd, vg, vg->name);
 			return 0;
 		}
 
-		unlock_and_release_vg(cmd, vg, vg->name);
+		unlock_and_free_vg(cmd, vg, vg->name);
 
 		/*
 		 * FIXME Sleeping after testing, while preferred, also works around
--- LVM2/tools/pvchange.c	2010/11/11 17:29:06	1.85
+++ LVM2/tools/pvchange.c	2010/12/08 20:50:51	1.86
@@ -240,7 +240,7 @@
 			}
 			vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 			if (vg_read_error(vg)) {
-				vg_release(vg);
+				free_vg(vg);
 				stack;
 				continue;
 			}
@@ -254,7 +254,7 @@
 			total++;
 			done += _pvchange_single(cmd, vg,
 						 pvl->pv, NULL);
-			unlock_and_release_vg(cmd, vg, vg_name);
+			unlock_and_free_vg(cmd, vg, vg_name);
 		}
 	} else {
 		log_verbose("Scanning for physical volume names");
@@ -275,7 +275,7 @@
 			dm_list_iterate_items(sll, vgnames) {
 				vg = vg_read_for_update(cmd, sll->str, NULL, 0);
 				if (vg_read_error(vg)) {
-					vg_release(vg);
+					free_vg(vg);
 					stack;
 					continue;
 				}
@@ -285,7 +285,7 @@
 								 pvl->pv,
 								 NULL);
 				}
-				unlock_and_release_vg(cmd, vg, sll->str);
+				unlock_and_free_vg(cmd, vg, sll->str);
 			}
 		}
 	}
--- LVM2/tools/pvcreate.c	2010/09/23 12:02:34	1.92
+++ LVM2/tools/pvcreate.c	2010/12/08 20:50:51	1.93
@@ -74,7 +74,7 @@
 		pp->pe_start = pv_pe_start(existing_pvl->pv);
 		pp->extent_size = pv_pe_size(existing_pvl->pv);
 		pp->extent_count = pv_pe_count(existing_pvl->pv);
-		vg_release(vg);
+		free_vg(vg);
 	}
 
 	if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) {
--- LVM2/tools/pvdisplay.c	2009/11/24 17:07:09	1.54
+++ LVM2/tools/pvdisplay.c	2010/12/08 20:50:51	1.55
@@ -32,7 +32,7 @@
 		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
 		if (vg_read_error(vg)) {
 			log_error("Skipping volume group %s", vg_name);
-			vg_release(vg);
+			free_vg(vg);
 			/* FIXME If CLUSTERED should return ECMD_PROCESSED here */
 			return ECMD_FAILED;
 		}
@@ -85,7 +85,7 @@
 	if (vg_name)
 		unlock_vg(cmd, vg_name);
 	if (!old_vg)
-		vg_release(vg);
+		free_vg(vg);
 
 	return ret;
 }
--- LVM2/tools/pvmove.c	2010/09/23 12:02:34	1.80
+++ LVM2/tools/pvmove.c	2010/12/08 20:50:51	1.81
@@ -445,7 +445,7 @@
 
 	vg = _get_vg(cmd, pv_vg_name(pv));
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -510,7 +510,7 @@
 	/* LVs are all in status LOCKED */
 	r = ECMD_PROCESSED;
 out:
-	unlock_and_release_vg(cmd, vg, pv_vg_name(pv));
+	unlock_and_free_vg(cmd, vg, pv_vg_name(pv));
 	return r;
 }
 
--- LVM2/tools/pvresize.c	2010/10/25 12:01:38	1.36
+++ LVM2/tools/pvresize.c	2010/12/08 20:50:51	1.37
@@ -58,7 +58,7 @@
 		vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 
 		if (vg_read_error(vg)) {
-			vg_release(vg);
+			free_vg(vg);
 			log_error("Unable to read volume group \"%s\".",
 				  vg_name);
 			return 0;
@@ -164,7 +164,7 @@
 out:
 	unlock_vg(cmd, vg_name);
 	if (!old_vg)
-		vg_release(vg);
+		free_vg(vg);
 	return r;
 }
 
--- LVM2/tools/reporter.c	2010/11/17 22:26:42	1.63
+++ LVM2/tools/reporter.c	2010/12/08 20:50:51	1.64
@@ -65,7 +65,7 @@
 	};
 
         if (!(_free_vg.vgmem = dm_pool_create("_free_vg", 10240)))
-            return ECMD_FAILED;
+		return ECMD_FAILED;
 
 	struct logical_volume _free_logical_volume = {
 		.vg = vg ?: &_free_vg,
@@ -110,7 +110,7 @@
                 goto_out;
 	}
  out:
-        dm_pool_destroy(_free_vg.vgmem);
+	free_vg(&_free_vg);
 	return ret;
 }
 
@@ -145,7 +145,7 @@
 		vg = vg_read(cmd, vg_name, (char *)&pv->vgid, 0);
 		if (vg_read_error(vg)) {
 			log_error("Skipping volume group %s", vg_name);
-			vg_release(vg);
+			free_vg(vg);
 			return ECMD_FAILED;
 		}
 
@@ -185,7 +185,7 @@
 		unlock_vg(cmd, vg_name);
 
 	if (!old_vg)
-		vg_release(vg);
+		free_vg(vg);
 
 	return ret;
 }
--- LVM2/tools/toollib.c	2010/12/01 12:22:49	1.216
+++ LVM2/tools/toollib.c	2010/12/08 20:50:51	1.217
@@ -311,7 +311,7 @@
 		}
 
 		if (!cmd_vg_read(cmd, &cmd_vgs)) {
-			cmd_vg_release(&cmd_vgs);
+			free_cmd_vgs(&cmd_vgs);
 			if (ret_max < ECMD_FAILED) {
 				log_error("Skipping volume group %s", vgname);
 				ret_max = ECMD_FAILED;
@@ -337,7 +337,7 @@
 						  dm_pool_strdup(cmd->mem,
 								 lv_name + 1))) {
 					log_error("strlist allocation failed");
-					cmd_vg_release(&cmd_vgs);
+					free_cmd_vgs(&cmd_vgs);
 					return ECMD_FAILED;
 				}
 			}
@@ -355,7 +355,7 @@
 			dm_list_init(&lvnames);
 			dm_list_splice(&lvnames, &failed_lvnames);
 
-			cmd_vg_release(&cmd_vgs);
+			free_cmd_vgs(&cmd_vgs);
 			if (!cmd_vg_read(cmd, &cmd_vgs)) {
 				ret = ECMD_FAILED; /* break */
 				break;
@@ -364,7 +364,7 @@
 		if (ret > ret_max)
 			ret_max = ret;
 
-		cmd_vg_release(&cmd_vgs);
+		free_cmd_vgs(&cmd_vgs);
 		/* FIXME: logic for breaking command is not consistent */
 		if (sigint_caught())
 			return ECMD_FAILED;
@@ -392,7 +392,7 @@
 
 		vg = vg_read(cmd, vg_name, NULL, 0);
 		if (vg_read_error(vg)) {
-			vg_release(vg);
+			free_vg(vg);
 			log_error("Skipping volume group %s", vg_name);
 			return ECMD_FAILED;
 		}
@@ -404,7 +404,7 @@
 		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
 			 log_error("Unable to find %s in volume group %s",
 				   pv_dev_name(pv), vg_name);
-			 unlock_and_release_vg(cmd, vg, vg_name);
+			 unlock_and_free_vg(cmd, vg, vg_name);
 			 return ECMD_FAILED;
 		}
 
@@ -427,7 +427,7 @@
 	if (vg_name)
 		unlock_vg(cmd, vg_name);
 	if (!old_vg)
-		vg_release(vg);
+		free_vg(vg);
 
 	return ret_max;
 }
@@ -498,10 +498,10 @@
 		if (!cvl_vg->vg->cmd_missing_vgs)
 			break;
 
-		cmd_vg_release(&cmd_vgs);
+		free_cmd_vgs(&cmd_vgs);
 	}
 
-	cmd_vg_release(&cmd_vgs);
+	free_cmd_vgs(&cmd_vgs);
 
 	return (ret > ret_max) ? ret : ret_max;
 }
@@ -774,7 +774,7 @@
 				vg = vg_read(cmd, sll->str, NULL, flags);
 				if (vg_read_error(vg)) {
 					ret_max = ECMD_FAILED;
-					vg_release(vg);
+					free_vg(vg);
 					stack;
 					continue;
 				}
@@ -783,7 +783,7 @@
 							    handle,
 							    process_single_pv);
 
-				unlock_and_release_vg(cmd, vg, sll->str);
+				unlock_and_free_vg(cmd, vg, sll->str);
 
 				if (ret > ret_max)
 					ret_max = ret;
--- LVM2/tools/vgcreate.c	2010/11/11 17:29:06	1.81
+++ LVM2/tools/vgcreate.c	2010/12/08 20:50:51	1.82
@@ -56,7 +56,7 @@
 			log_error("A volume group called %s already exists.", vp_new.vg_name);
 		else
 			log_error("Can't get lock for %s.", vp_new.vg_name);
-		vg_release(vg);
+		free_vg(vg);
 		return ECMD_FAILED;
 	}
 
@@ -120,13 +120,13 @@
 	log_print("%s%colume group \"%s\" successfully created",
 		  clustered_message, *clustered_message ? 'v' : 'V', vg->name);
 
-	vg_release(vg);
+	free_vg(vg);
 	return ECMD_PROCESSED;
 
 bad:
 	unlock_vg(cmd, VG_ORPHANS);
 bad_orphan:
-	vg_release(vg);
+	free_vg(vg);
 	unlock_vg(cmd, vp_new.vg_name);
 	return ECMD_FAILED;
 }
--- LVM2/tools/vgextend.c	2010/10/18 17:27:10	1.61
+++ LVM2/tools/vgextend.c	2010/12/08 20:50:51	1.62
@@ -72,7 +72,7 @@
 	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);
+		free_vg(vg);
 		stack;
 		return ECMD_FAILED;
 	}
@@ -92,7 +92,7 @@
 	} else { /* no --restore, normal vgextend */
 		if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
 			log_error("Can't get lock for orphan PVs");
-			unlock_and_release_vg(cmd, vg, vg_name);
+			unlock_and_free_vg(cmd, vg, vg_name);
 			return ECMD_FAILED;
 		}
 
@@ -135,6 +135,6 @@
 bad:
 	if (!arg_count(cmd, restoremissing_ARG))
 		unlock_vg(cmd, VG_ORPHANS);
-	unlock_and_release_vg(cmd, vg, vg_name);
+	unlock_and_free_vg(cmd, vg, vg_name);
 	return r;
 }
--- LVM2/tools/vgmerge.c	2010/07/09 15:34:48	1.69
+++ LVM2/tools/vgmerge.c	2010/12/08 20:50:51	1.70
@@ -22,7 +22,7 @@
 	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);
+		free_vg(vg);
 		return NULL;
 	}
 	return vg;
@@ -54,7 +54,7 @@
 		vg_to = _vgmerge_vg_read(cmd, vg_name_to);
 		if (!vg_to) {
 			stack;
-			unlock_and_release_vg(cmd, vg_from, vg_name_from);
+			unlock_and_free_vg(cmd, vg_from, vg_name_from);
 			return ECMD_FAILED;
 		}
 	} else {
@@ -67,7 +67,7 @@
 		vg_from = _vgmerge_vg_read(cmd, vg_name_from);
 		if (!vg_from) {
 			stack;
-			unlock_and_release_vg(cmd, vg_to, vg_name_to);
+			unlock_and_free_vg(cmd, vg_to, vg_name_to);
 			return ECMD_FAILED;
 		}
 	}
@@ -148,11 +148,11 @@
 	r = ECMD_PROCESSED;
 bad:
 	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);
+		unlock_and_free_vg(cmd, vg_to, vg_name_to);
+		unlock_and_free_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);
+		unlock_and_free_vg(cmd, vg_from, vg_name_from);
+		unlock_and_free_vg(cmd, vg_to, vg_name_to);
 	}
 	return r;
 }
--- LVM2/tools/vgreduce.c	2010/08/17 16:25:35	1.104
+++ LVM2/tools/vgreduce.c	2010/12/08 20:50:51	1.105
@@ -450,7 +450,7 @@
 	log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name);
 	r = ECMD_PROCESSED;
 bad:
-	unlock_and_release_vg(cmd, orphan_vg, VG_ORPHANS);
+	unlock_and_free_vg(cmd, orphan_vg, VG_ORPHANS);
 	return r;
 }
 
@@ -524,7 +524,7 @@
 			goto out;
 		}
 
-		vg_release(vg);
+		free_vg(vg);
 		log_verbose("Trying to open VG %s for recovery...", vg_name);
 
 		vg = vg_read_for_update(cmd, vg_name, NULL,
@@ -570,7 +570,7 @@
 	}
 out:
 	init_ignore_suspended_devices(saved_ignore_suspended_devices);
-	unlock_and_release_vg(cmd, vg, vg_name);
+	unlock_and_free_vg(cmd, vg, vg_name);
 
 	return ret;
 
--- LVM2/tools/vgrename.c	2010/04/14 13:03:06	1.72
+++ LVM2/tools/vgrename.c	2010/12/08 20:50:51	1.73
@@ -25,7 +25,7 @@
 	   nevertheless. */
 	vg = vg_read_for_update(cmd, vg_name_old, vgid, READ_ALLOW_EXPORTED);
 	if (vg_read_error(vg)) {
-		vg_release(vg);
+		free_vg(vg);
 		return_NULL;
 	}
 
@@ -117,7 +117,7 @@
 			return_0;
 
 		if (!_lock_new_vg_for_rename(cmd, vg_name_new)) {
-			unlock_and_release_vg(cmd, vg, vg_name_old);
+			unlock_and_free_vg(cmd, vg, vg_name_old);
 			return_0;
 		}
 	} else {
@@ -168,7 +168,7 @@
 	backup_remove(cmd, vg_name_old);
 
 	unlock_vg(cmd, vg_name_new);
-	unlock_and_release_vg(cmd, vg, vg_name_old);
+	unlock_and_free_vg(cmd, vg, vg_name_old);
 
 	log_print("Volume group \"%s\" successfully renamed to \"%s\"",
 		  vg_name_old, vg_name_new);
@@ -182,9 +182,9 @@
       error:
 	if (lock_vg_old_first) {
 		unlock_vg(cmd, vg_name_new);
-		unlock_and_release_vg(cmd, vg, vg_name_old);
+		unlock_and_free_vg(cmd, vg, vg_name_old);
 	} else {
-		unlock_and_release_vg(cmd, vg, vg_name_old);
+		unlock_and_free_vg(cmd, vg, vg_name_old);
 		unlock_vg(cmd, vg_name_new);
 	}
 	return 0;
--- LVM2/tools/vgsplit.c	2010/09/23 12:02:34	1.102
+++ LVM2/tools/vgsplit.c	2010/12/08 20:50:51	1.103
@@ -223,16 +223,16 @@
 	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);
+		free_vg(vg_to);
 		return NULL;
 	}
 	if (vg_read_error(vg_to) == FAILED_EXIST) {
 		*existing_vg = 1;
-		vg_release(vg_to);
+		free_vg(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL, 0);
 
 		if (vg_read_error(vg_to)) {
-			vg_release(vg_to);
+			free_vg(vg_to);
 			stack;
 			return NULL;
 		}
@@ -258,7 +258,7 @@
 
 	vg_from = vg_read_for_update(cmd, vg_name_from, NULL, 0);
 	if (vg_read_error(vg_from)) {
-		vg_release(vg_from);
+		free_vg(vg_from);
 		return NULL;
 	}
 	return vg_from;
@@ -333,7 +333,7 @@
 
 		vg_to = _vgsplit_to(cmd, vg_name_to, &existing_vg);
 		if (!vg_to) {
-			unlock_and_release_vg(cmd, vg_from, vg_name_from);
+			unlock_and_free_vg(cmd, vg_from, vg_name_from);
 			stack;
 			return ECMD_FAILED;
 		}
@@ -345,7 +345,7 @@
 		}
 		vg_from = _vgsplit_from(cmd, vg_name_from);
 		if (!vg_from) {
-			unlock_and_release_vg(cmd, vg_to, vg_name_to);
+			unlock_and_free_vg(cmd, vg_to, vg_name_to);
 			stack;
 			return ECMD_FAILED;
 		}
@@ -462,7 +462,7 @@
 	 * Finally, remove the EXPORTED flag from the new VG and write it out.
 	 */
 	if (!test_mode()) {
-		vg_release(vg_to);
+		free_vg(vg_to);
 		vg_to = vg_read_for_update(cmd, vg_name_to, NULL,
 					   READ_ALLOW_EXPORTED);
 		if (vg_read_error(vg_to)) {
@@ -487,11 +487,11 @@
 
 bad:
 	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);
+		unlock_and_free_vg(cmd, vg_to, vg_name_to);
+		unlock_and_free_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);
+		unlock_and_free_vg(cmd, vg_from, vg_name_from);
+		unlock_and_free_vg(cmd, vg_to, vg_name_to);
 	}
 	return r;
 }


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-11-23  1:56 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2010-11-23  1:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-11-23 01:56:02

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : pvremove.c toollib.c 

Log message:
	Suppress 'No PV label' message when removing several PVs without mdas.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1801&r2=1.1802
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.170&r2=1.171
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.409&r2=1.410
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.212&r2=1.213

--- LVM2/WHATS_NEW	2010/11/22 21:39:47	1.1801
+++ LVM2/WHATS_NEW	2010/11/23 01:55:53	1.1802
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Suppress 'No PV label' message when removing several PVs without mdas.
   Fix default /etc/lvm permissions to be 0755. (2.02.66)
 
 Version 2.02.77 - 22nd November 2010
--- LVM2/daemons/clvmd/lvm-functions.c	2010/08/17 19:25:05	1.99
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/11/23 01:55:58	1.100
@@ -848,7 +848,7 @@
 
 	pthread_mutex_lock(&lvm_lock);
 
-	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
+	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, 1, &consistent);
 
 	if (vg && consistent)
 		check_current_backup(vg);
--- LVM2/lib/metadata/metadata-exported.h	2010/11/11 17:29:06	1.170
+++ LVM2/lib/metadata/metadata-exported.h	2010/11/23 01:55:59	1.171
@@ -341,7 +341,7 @@
 int vg_commit(struct volume_group *vg);
 int vg_revert(struct volume_group *vg);
 struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
-			     const char *vgid, int *consistent);
+			     const char *vgid, int warnings, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
 				int warnings, int scan_label_only);
@@ -357,7 +357,7 @@
 
 struct dm_list *get_vgnames(struct cmd_context *cmd, int include_internal);
 struct dm_list *get_vgids(struct cmd_context *cmd, int include_internal);
-int scan_vgs_for_pvs(struct cmd_context *cmd);
+int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings);
 
 int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
 	     struct dm_list *mdas, int64_t label_sector);
--- LVM2/lib/metadata/metadata.c	2010/11/09 12:34:42	1.409
+++ LVM2/lib/metadata/metadata.c	2010/11/23 01:55:59	1.410
@@ -344,7 +344,7 @@
 	struct pv_list *pvl;
 	int r = 0, consistent = 0;
 
-	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, 1, &consistent))) {
 		log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
 			  vg_name);
 		return 0;
@@ -918,7 +918,7 @@
 	/* FIXME: Is this vg_read_internal necessary? Move it inside
 	   vg_lock_newname? */
 	/* is this vg name already in use ? */
-	if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
+	if ((vg = vg_read_internal(cmd, vg_name, NULL, 1, &consistent))) {
 		log_error("A volume group called '%s' already exists.", vg_name);
 		unlock_and_release_vg(cmd, vg, vg_name);
 		return _vg_make_handle(cmd, NULL, FAILED_EXIST);
@@ -1343,7 +1343,7 @@
 	 * system.
 	 */
 	if (pv && is_orphan(pv) && mdas_empty_or_ignored(&mdas)) {
-		if (!scan_vgs_for_pvs(cmd))
+		if (!scan_vgs_for_pvs(cmd, 0))
 			return_0;
 		pv = pv_read(cmd, name, NULL, NULL, 0, 0);
 	}
@@ -1812,7 +1812,7 @@
 
 	if (is_orphan_vg(pv->vg_name) && mdas_empty_or_ignored(&mdas)) {
 		/* If a PV has no MDAs - need to search all VGs for it */
-		if (!scan_vgs_for_pvs(cmd))
+		if (!scan_vgs_for_pvs(cmd, 1))
 			return_NULL;
 		if (!(pv = _pv_read(cmd, cmd->mem, pv_name, NULL, NULL, 1, 0))) {
 			log_error("Physical volume %s not found", pv_name);
@@ -2513,6 +2513,7 @@
 
 /* Make orphan PVs look like a VG */
 static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
+					     int warnings,
 					     const char *orphan_vgname)
 {
 	struct lvmcache_vginfo *vginfo;
@@ -2554,7 +2555,7 @@
 	}
 
 	dm_list_iterate_items(info, &vginfo->infos) {
-		if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, 1, 0))) {
+		if (!(pv = _pv_read(cmd, mem, dev_name(info->dev), NULL, NULL, warnings, 0))) {
 			continue;
 		}
 		if (!(pvl = dm_pool_zalloc(mem, sizeof(*pvl)))) {
@@ -2641,6 +2642,7 @@
 static struct volume_group *_vg_read(struct cmd_context *cmd,
 				     const char *vgname,
 				     const char *vgid,
+				     int warnings, 
 				     int *consistent, unsigned precommitted)
 {
 	struct format_instance *fid;
@@ -2667,7 +2669,7 @@
 			return NULL;
 		}
 		*consistent = 1;
-		return _vg_read_orphans(cmd, vgname);
+		return _vg_read_orphans(cmd, warnings, vgname);
 	}
 
 	/*
@@ -3035,12 +3037,12 @@
 }
 
 struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
-			     const char *vgid, int *consistent)
+			     const char *vgid, int warnings, int *consistent)
 {
 	struct volume_group *vg;
 	struct lv_list *lvl;
 
-	if (!(vg = _vg_read(cmd, vgname, vgid, consistent, 0)))
+	if (!(vg = _vg_read(cmd, vgname, vgid, warnings, consistent, 0)))
 		return NULL;
 
 	if (!check_pv_segments(vg)) {
@@ -3104,7 +3106,7 @@
 	/* Is corresponding vgname already cached? */
 	if ((vginfo = vginfo_from_vgid(vgid)) &&
 	    vginfo->vgname && !is_orphan_vg(vginfo->vgname)) {
-		if ((vg = _vg_read(cmd, NULL, vgid,
+		if ((vg = _vg_read(cmd, NULL, vgid, 1,
 				   &consistent, precommitted)) &&
 		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
 
@@ -3137,7 +3139,7 @@
 		if (!vgname)
 			continue;	// FIXME Unnecessary?
 		consistent = 0;
-		if ((vg = _vg_read(cmd, vgname, vgid, &consistent,
+		if ((vg = _vg_read(cmd, vgname, vgid, 1, &consistent,
 				   precommitted)) &&
 		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
 
@@ -3208,7 +3210,7 @@
 		 * every PV on the system.
 		 */
 		if (mdas_empty_or_ignored(&info->mdas)) {
-			if (!scan_vgs_for_pvs(cmd)) {
+			if (!scan_vgs_for_pvs(cmd, 1)) {
 				log_error("Rescan for PVs without "
 					  "metadata areas failed.");
 				return NULL;
@@ -3323,7 +3325,7 @@
 	return lvmcache_get_vgids(cmd, include_internal);
 }
 
-static int _get_pvs(struct cmd_context *cmd, struct dm_list **pvslist)
+static int _get_pvs(struct cmd_context *cmd, int warnings, struct dm_list **pvslist)
 {
 	struct str_list *strl;
 	struct dm_list * uninitialized_var(results);
@@ -3364,7 +3366,7 @@
 			stack;
 			continue;
 		}
-		if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vgname, vgid, warnings, &consistent))) {
 			stack;
 			continue;
 		}
@@ -3398,15 +3400,15 @@
 {
 	struct dm_list *results;
 
-	if (!_get_pvs(cmd, &results))
+	if (!_get_pvs(cmd, 1, &results))
 		return NULL;
 
 	return results;
 }
 
-int scan_vgs_for_pvs(struct cmd_context *cmd)
+int scan_vgs_for_pvs(struct cmd_context *cmd, int warnings)
 {
-	return _get_pvs(cmd, NULL);
+	return _get_pvs(cmd, warnings, NULL);
 }
 
 int pv_write(struct cmd_context *cmd __attribute__((unused)),
@@ -3581,7 +3583,7 @@
 	if (!lock_vol(cmd, vg_name, LCK_VG_WRITE))
 		return_NULL;
 
-	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent)))
 		return_NULL;
 
 	if (!consistent) {
@@ -3636,7 +3638,7 @@
 	consistent_in = consistent;
 
 	/* If consistent == 1, we get NULL here if correction fails. */
-	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, 1, &consistent))) {
 		if (consistent_in && !consistent) {
 			log_error("Volume group \"%s\" inconsistent.", vg_name);
 			failure |= FAILED_INCONSISTENT;
--- LVM2/tools/pvremove.c	2010/09/23 12:02:34	1.30
+++ LVM2/tools/pvremove.c	2010/11/23 01:56:02	1.31
@@ -48,7 +48,7 @@
 	 * PV on the system.
 	 */
 	if (is_orphan(pv) && !dm_list_size(&mdas)) {
-		if (!scan_vgs_for_pvs(cmd)) {
+		if (!scan_vgs_for_pvs(cmd, 0)) {
 			log_error("Rescan for PVs without metadata areas "
 				  "failed.");
 			return 0;
--- LVM2/tools/toollib.c	2010/11/17 10:19:30	1.212
+++ LVM2/tools/toollib.c	2010/11/23 01:56:02	1.213
@@ -629,7 +629,7 @@
 	int ret_max = ECMD_PROCESSED;
 	int ret = 0;
 
-	if (!scan_vgs_for_pvs(cmd)) {
+	if (!scan_vgs_for_pvs(cmd, 1)) {
 		stack;
 		return ECMD_FAILED;
 	}
@@ -744,7 +744,7 @@
 				if (!scanned && is_orphan(pv) &&
 				    !dm_list_size(&mdas)) {
 					if (!scan_label_only &&
-					    !scan_vgs_for_pvs(cmd)) {
+					    !scan_vgs_for_pvs(cmd, 1)) {
 						stack;
 						ret_max = ECMD_FAILED;
 						continue;


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-03-26 15:40 snitzer
  0 siblings, 0 replies; 33+ messages in thread
From: snitzer @ 2010-03-26 15:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-03-26 15:40:14

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : cluster_locking.c 

Log message:
	Fix clvmd cluster propagation of dmeventd monitoring mode.
	
	clvmd's do_lock_lv() already properly controls dmeventd monitoring based
	on LCK_DMEVENTD_MONITOR_MODE in lock_flags -- though one small fix was
	needed for this to work: _lock_for_cluster() must treat
	dmeventd_monitor_mode()'s return as a tri-state value.
	
	Also cleanup do_lock_lv() to:
	- explicitly init_dmeventd_monitor() based on LCK_DMEVENTD_MONITOR_MODE
	- no longer reset init_dmeventd_monitor() to default at the end of
	do_lock_lv() -- it is unnecessary

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1482&r2=1.1483
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41

--- LVM2/WHATS_NEW	2010/03/25 21:19:26	1.1482
+++ LVM2/WHATS_NEW	2010/03/26 15:40:13	1.1483
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Fix clvmd cluster propagation of dmeventd monitoring mode.
   Allow ALLOC_ANYWHERE to split contiguous areas.
   Use INTERNAL_ERROR for internal errors throughout tree.
   Add some assertions to allocation code.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/03/24 22:25:11	1.86
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/03/26 15:40:14	1.87
@@ -499,7 +499,9 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(1);
 
-	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
+	if (lock_flags & LCK_DMEVENTD_MONITOR_MODE)
+		init_dmeventd_monitor(1);
+	else
 		init_dmeventd_monitor(0);
 
 	cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
@@ -542,9 +544,6 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(0);
 
-	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
-		init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR);
-
 	cmd->partial_activation = 0;
 
 	/* clean the pool for another command */
--- LVM2/lib/locking/cluster_locking.c	2010/01/05 16:07:57	1.40
+++ LVM2/lib/locking/cluster_locking.c	2010/03/26 15:40:14	1.41
@@ -307,6 +307,7 @@
 	char *args;
 	const char *node = "";
 	int len;
+	int dmeventd_mode;
 	int saved_errno = errno;
 	lvm_response_t *response = NULL;
 	int num_responses;
@@ -324,7 +325,12 @@
 	if (mirror_in_sync())
 		args[1] |= LCK_MIRROR_NOSYNC_MODE;
 
-	if (dmeventd_monitor_mode())
+	/*
+	 * Must handle tri-state return from dmeventd_monitor_mode.
+	 * But DMEVENTD_MONITOR_IGNORE is not propagated across the cluster.
+	 */
+	dmeventd_mode = dmeventd_monitor_mode();
+	if (dmeventd_mode != DMEVENTD_MONITOR_IGNORE && dmeventd_mode)
 		args[1] |= LCK_DMEVENTD_MONITOR_MODE;
 
 	if (cmd->partial_activation)


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-03-23 22:30 snitzer
  0 siblings, 0 replies; 33+ messages in thread
From: snitzer @ 2010-03-23 22:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	snitzer@sourceware.org	2010-03-23 22:30:20

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	doc            : example.conf 
	lib/metadata   : lv_manip.c metadata-exported.h 
	liblvm         : lvm_lv.c 
	man            : lvchange.8.in lvcreate.8.in vgchange.8.in 
	tools          : commands.h lvchange.c lvcreate.c toollib.c 
	                 toollib.h vgchange.c 

Log message:
	Improve activation monitoring option processing
	
	. Add "monitoring" option to "activation" section of lvm.conf
	. Have clvmd consult the lvm.conf "activation/monitoring" too.
	. Introduce toollib.c:get_activation_monitoring_mode().
	. Error out when both --monitor and --ignoremonitoring are provided.
	. Add --monitor and --ignoremonitoring support to lvcreate.  Update
	lvcreate man page accordingly.
	. Clarify that '--monitor' controls the start and stop of monitoring in
	the {vg,lv}change man pages.
	
	Signed-off-by: Mike Snitzer <snitzer@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1475&r2=1.1476
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.211&r2=1.212
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.136&r2=1.137
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvchange.8.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.in.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgchange.8.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.215&r2=1.216
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.189&r2=1.190
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/WHATS_NEW	2010/03/23 15:07:55	1.1475
+++ LVM2/WHATS_NEW	2010/03/23 22:30:18	1.1476
@@ -1,5 +1,8 @@
 Version 2.02.63 - 
 ================================
+  Add "monitoring" option to "activation" section of lvm.conf.
+  Have clvmd consult the lvm.conf "activation/monitoring".
+  Add --monitor and --ignoremonitoring support to lvcreate.
   Allow dynamic extension of array of areas selected as allocation candidates.
   Export and use only valid cookie value in test suite.
   Remove const modifier for struct volume_group* from process_each_lv_in_vg().
--- LVM2/daemons/clvmd/lvm-functions.c	2010/01/26 08:00:03	1.84
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/03/23 22:30:19	1.85
@@ -542,8 +542,12 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(0);
 
-	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
-		init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR);
+	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE)) {
+		int dmeventd_mode =
+			find_config_tree_bool(cmd, "activation/monitoring",
+					      DEFAULT_DMEVENTD_MONITOR);
+		init_dmeventd_monitor(dmeventd_mode);
+	}
 
 	cmd->partial_activation = 0;
 
--- LVM2/doc/example.conf	2010/03/05 14:48:33	1.55
+++ LVM2/doc/example.conf	2010/03/23 22:30:19	1.56
@@ -428,6 +428,10 @@
     # which used mlockall() to pin the whole process's memory while activating
     # devices.
     # use_mlockall = 0
+
+    # Monitoring is enabled by default when activating logical volumes.
+    # Set to 0 to disable monitoring or use the --ignoremonitoring option.
+    # monitoring = 1
 }
 
 
--- LVM2/lib/metadata/lv_manip.c	2010/03/23 15:07:55	1.211
+++ LVM2/lib/metadata/lv_manip.c	2010/03/23 22:30:19	1.212
@@ -3061,6 +3061,8 @@
 
 	backup(vg);
 
+	init_dmeventd_monitor(lp->activation_monitoring);
+
 	if (lp->snapshot) {
 		if (!activate_lv_excl(cmd, lv)) {
 			log_error("Aborting. Failed to activate snapshot "
--- LVM2/lib/metadata/metadata-exported.h	2010/03/16 16:57:04	1.136
+++ LVM2/lib/metadata/metadata-exported.h	2010/03/23 22:30:19	1.137
@@ -535,6 +535,7 @@
 	int minor; /* all */
 	int log_count; /* mirror */
 	int nosync; /* mirror */
+	int activation_monitoring; /* all */
 
 	char *origin; /* snap */
 	const char *vg_name; /* all */
--- LVM2/liblvm/lvm_lv.c	2010/02/24 18:16:26	1.19
+++ LVM2/liblvm/lvm_lv.c	2010/03/23 22:30:19	1.20
@@ -111,6 +111,7 @@
 	lp->zero = 1;
 	lp->major = -1;
 	lp->minor = -1;
+	lp->activation_monitoring = DEFAULT_DMEVENTD_MONITOR;
 	lp->vg_name = vg->name;
 	lp->lv_name = lvname; /* FIXME: check this for safety */
 	lp->pvh = &vg->pvs;
--- LVM2/man/lvchange.8.in	2010/01/06 19:08:58	1.6
+++ LVM2/man/lvchange.8.in	2010/03/23 22:30:20	1.7
@@ -56,7 +56,7 @@
 Set the minor number.
 .TP
 .I \-\-monitor y|n
-Controls whether or not a mirrored logical volume is monitored by
+Start or stop monitoring a mirrored or snapshot logical volume with
 dmeventd, if it is installed.
 If a device used by a monitored mirror reports an I/O error,
 the failure is handled according to 
--- LVM2/man/lvcreate.8.in	2010/02/03 03:58:08	1.15
+++ LVM2/man/lvcreate.8.in	2010/03/23 22:30:20	1.16
@@ -7,6 +7,8 @@
 [\-\-alloc AllocationPolicy]
 [\-A|\-\-autobackup y|n] [\-C|\-\-contiguous y|n] [\-d|\-\-debug]
 [\-h|\-?|\-\-help] [\-\-noudevsync]
+[\-\-ignoremonitoring]
+[\-\-monitor {y|n}]
 [\-i|\-\-stripes Stripes [\-I|\-\-stripesize StripeSize]]
 {\-l|\-\-extents LogicalExtentsNumber[%{VG|PVS|FREE}] |
  \-L|\-\-size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
@@ -26,6 +28,8 @@
  \-L|\-\-size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}
 [\-c|\-\-chunksize ChunkSize]
 [\-\-noudevsync]
+[\-\-ignoremonitoring]
+[\-\-monitor {y|n}]
 \-n|\-\-name SnapshotLogicalVolumeName
 {{\-s|\-\-snapshot}
 OriginalLogicalVolumePath | 
@@ -129,6 +133,18 @@
 in the background.  You should only use this if udev is not running
 or has rules that ignore the devices LVM2 creates.
 .TP
+.I \-\-monitor y|n
+Start or avoid monitoring a mirrored or snapshot logical volume with
+dmeventd, if it is installed. 
+If a device used by a monitored mirror reports an I/O error,
+the failure is handled according to 
+\fBmirror_image_fault_policy\fP and \fBmirror_log_fault_policy\fP
+set in \fBlvm.conf\fP.
+.TP
+.I \-\-ignoremonitoring
+Make no attempt to interact with dmeventd unless \-\-monitor
+is specified.
+.TP
 .I \-p, \-\-permission r|rw
 Set access permissions to read only or read and write.
 .br
--- LVM2/man/vgchange.8.in	2010/01/06 19:08:58	1.7
+++ LVM2/man/vgchange.8.in	2010/03/23 22:30:20	1.8
@@ -78,7 +78,7 @@
 Generate new random UUID for specified Volume Groups.
 .TP
 .BR \-\-monitor " " { y | n }
-Controls whether or not a mirrored logical volume is monitored by
+Start or stop monitoring a mirrored or snapshot logical volume with
 dmeventd, if it is installed.
 If a device used by a monitored mirror reports an I/O error,
 the failure is handled according to 
--- LVM2/tools/commands.h	2010/02/03 03:58:08	1.141
+++ LVM2/tools/commands.h	2010/03/23 22:30:20	1.142
@@ -150,6 +150,8 @@
    "\t[-C|--contiguous {y|n}]\n"
    "\t[-d|--debug]\n"
    "\t[-h|-?|--help]\n"
+   "\t[--ignoremonitoring]\n"
+   "\t[--monitor {y|n}]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |\n"
    "\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
@@ -177,6 +179,8 @@
    "\t[-C|--contiguous {y|n}]\n"
    "\t[-d|--debug]\n"
    "\t[-h|-?|--help]\n"
+   "\t[--ignoremonitoring]\n"
+   "\t[--monitor {y|n}]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
    "\t{-l|--extents LogicalExtentsNumber[%{VG|FREE|ORIGIN}] |\n"
    "\t -L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}\n"
@@ -192,11 +196,11 @@
    "\t[PhysicalVolumePath...]\n\n",
 
    addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
-   corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
-   name_ARG, nosync_ARG, noudevsync_ARG, permission_ARG, persistent_ARG,
-   readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG,
-   stripesize_ARG, test_ARG, type_ARG, virtualoriginsize_ARG, virtualsize_ARG,
-   zero_ARG)
+   corelog_ARG, extents_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
+   mirrorlog_ARG, mirrors_ARG, monitor_ARG, name_ARG, nosync_ARG, noudevsync_ARG,
+   permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG,
+   snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG,
+   virtualoriginsize_ARG, virtualsize_ARG, zero_ARG)
 
 xx(lvdisplay,
    "Display information about a logical volume",
--- LVM2/tools/lvchange.c	2010/02/24 18:15:49	1.117
+++ LVM2/tools/lvchange.c	2010/03/23 22:30:20	1.118
@@ -518,7 +518,7 @@
 			   void *handle __attribute((unused)))
 {
 	int doit = 0, docmds = 0;
-	int archived = 0;
+	int dmeventd_mode, archived = 0;
 	struct logical_volume *origin;
 
 	if (!(lv->vg->status & LVM_WRITE) &&
@@ -575,9 +575,10 @@
 		return ECMD_FAILED;
 	}
 
-	init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG,
-					    (is_static() || arg_count(cmd, ignoremonitoring_ARG)) ?
-					    DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR));
+	if (!get_activation_monitoring_mode(cmd, &dmeventd_mode))
+		return ECMD_FAILED;
+
+	init_dmeventd_monitor(dmeventd_mode);
 
 	/*
 	 * FIXME: DEFAULT_BACKGROUND_POLLING should be "unspecified".
--- LVM2/tools/lvcreate.c	2010/02/03 03:58:08	1.215
+++ LVM2/tools/lvcreate.c	2010/03/23 22:30:20	1.216
@@ -482,6 +482,9 @@
 		return 0;
 	}
 
+	if (!get_activation_monitoring_mode(cmd, &lp->activation_monitoring))
+		return_0;
+
 	if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
 	    !_read_size_params(lp, lcp, cmd) ||
 	    !_read_stripe_params(lp, cmd) ||
--- LVM2/tools/toollib.c	2010/03/23 14:24:04	1.189
+++ LVM2/tools/toollib.c	2010/03/23 22:30:20	1.190
@@ -1423,3 +1423,24 @@
 	return 1;
 }
 
+int get_activation_monitoring_mode(struct cmd_context *cmd,
+				   int *monitoring_mode)
+{
+	*monitoring_mode = DEFAULT_DMEVENTD_MONITOR;
+
+	if (arg_count(cmd, monitor_ARG) &&
+	    arg_count(cmd, ignoremonitoring_ARG)) {
+		log_error("Conflicting monitor and ignoremonitoring options");
+		return 0;
+	}
+
+	if (arg_count(cmd, monitor_ARG))
+		*monitoring_mode = arg_int_value(cmd, monitor_ARG,
+						 DEFAULT_DMEVENTD_MONITOR);
+	else if (is_static() || arg_count(cmd, ignoremonitoring_ARG) ||
+		 !find_config_tree_bool(cmd, "activation/monitoring",
+					DEFAULT_DMEVENTD_MONITOR))
+		*monitoring_mode = DMEVENTD_MONITOR_IGNORE;
+	
+	return 1;
+}
--- LVM2/tools/toollib.h	2010/03/23 14:24:04	1.69
+++ LVM2/tools/toollib.h	2010/03/23 22:30:20	1.70
@@ -112,4 +112,7 @@
 			     int argc, char **argv,
 			     struct pvcreate_params *pp);
 
+int get_activation_monitoring_mode(struct cmd_context *cmd,
+				   int *monitoring_mode);
+
 #endif
--- LVM2/tools/vgchange.c	2010/02/24 18:15:06	1.99
+++ LVM2/tools/vgchange.c	2010/03/23 22:30:20	1.100
@@ -522,16 +522,17 @@
 			   struct volume_group *vg,
 			   void *handle __attribute((unused)))
 {
-	int r = ECMD_FAILED;
+	int dmeventd_mode, r = ECMD_FAILED;
 
 	if (vg_is_exported(vg)) {
 		log_error("Volume group \"%s\" is exported", vg_name);
 		return ECMD_FAILED;
 	}
 
-	init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG,
-					    (is_static() || arg_count(cmd, ignoremonitoring_ARG)) ?
-					    DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR));
+	if (!get_activation_monitoring_mode(cmd, &dmeventd_mode))
+		return ECMD_FAILED;
+
+	init_dmeventd_monitor(dmeventd_mode);
 
 	/*
 	 * FIXME: DEFAULT_BACKGROUND_POLLING should be "unspecified".


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-01-19 13:25 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2010-01-19 13:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-19 13:25:00

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c 

Log message:
	Never scan suspended devices in clvmd.
	
	For mirror repair (and similar tasks) it can happen that full
	device rescan is issued from clvmd.
	
	Because code can be in the middle of repair (calling suspend)
	clvmd should never try to scan suspended devices
	(otherwise it causes deadlock).
	
	Also code must not change ignore_suspended_device flag when
	doing refresh_filters (called from lvmcache scan code).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1394&r2=1.1395
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91

--- LVM2/WHATS_NEW	2010/01/15 20:47:52	1.1394
+++ LVM2/WHATS_NEW	2010/01/19 13:25:00	1.1395
@@ -1,5 +1,6 @@
 Version 2.02.59 - 
 ===================================
+  Fix clvmd to never scan suspended devices.
   Initial version of the cmirror init script (Red Hat).
   Initial version of the cmirrord man page.
   Make cluster log communication structures architecture independant.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:09:33	1.82
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/01/19 13:25:00	1.83
@@ -499,6 +499,9 @@
 
 	cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
 
+	/* clvmd should never try to read suspended device */
+	init_ignore_suspended_devices(1);
+
 	switch (command & LCK_MASK) {
 	case LCK_LV_EXCLUSIVE:
 		status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
@@ -627,6 +630,7 @@
 	}
 
 	init_full_scan_done(0);
+	init_ignore_suspended_devices(1);
 	lvmcache_label_scan(cmd, 2);
 	dm_pool_empty(cmd->mem);
 
@@ -860,6 +864,7 @@
 
 	/* Check lvm.conf is setup for cluster-LVM */
 	check_config();
+	init_ignore_suspended_devices(1);
 
 	/* Remove any non-LV locks that may have been left around */
 	if (using_gulm)
--- LVM2/lib/commands/toolcontext.c	2010/01/07 19:54:21	1.90
+++ LVM2/lib/commands/toolcontext.c	2010/01/19 13:25:00	1.91
@@ -1231,12 +1231,21 @@
 
 int refresh_filters(struct cmd_context *cmd)
 {
+	int r, saved_ignore_suspended_devices = ignore_suspended_devices();
+
 	if (cmd->filter) {
 		cmd->filter->destroy(cmd->filter);
 		cmd->filter = NULL;
 	}
 
-	return _init_filters(cmd, 0);
+	r = _init_filters(cmd, 0);
+
+	/*
+	 * During repair code must not reset suspended flag.
+	 */
+	init_ignore_suspended_devices(saved_ignore_suspended_devices);
+
+	return r;
 }
 
 int refresh_toolcontext(struct cmd_context *cmd)


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-01-05 16:09 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2010-01-05 16:09 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-05 16:09:34

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : locking.h 
	lib/metadata   : metadata.c 

Log message:
	Propagate commit and revert metadata event to other nodes in cluster.
	
	This patch tries to correctly track changes in lvmcache related to commit/revert.
	
	For vg_commit: if there is cached precommitted metadata, after successfull commit
	these metadata must be tracked as committed.
	
	For vg_revert: remote nodes must drop precommitted metadata and its flag in lvmcache.
	
	(N.B. Patch do not touch LV locks here in any way.)
	
	All this machinery is needed to properly solve remote node cache invalidaton which
	cause several problems recently observed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1360&r2=1.1361
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.307&r2=1.308

--- LVM2/WHATS_NEW	2010/01/05 16:07:56	1.1360
+++ LVM2/WHATS_NEW	2010/01/05 16:09:33	1.1361
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Propagate commit and revert metadata notification to other nodes in cluster.
   Use proper mask for VG lock mode in clvmd.
   Add possibility to drop precommitted metadata in lvmcache.
   Move processing of VG locks to separate function in clvmd.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:06:42	1.81
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:09:33	1.82
@@ -680,6 +680,7 @@
  */
 void do_lock_vg(unsigned char command, unsigned char lock_flags, char *resource)
 {
+	uint32_t lock_cmd = command;
 	char *vgname = resource + 2;
 
 	DEBUGLOG("do_lock_vg: resource '%s', cmd = %s, flags = %s, memlock = %d\n",
@@ -691,9 +692,29 @@
 		return;
 	}
 
+	lock_cmd &= (LCK_SCOPE_MASK | LCK_TYPE_MASK | LCK_HOLD);
+
+	/*
+	 * Check if LCK_CACHE should be set. All P_ locks except # are cache related.
+	 */
+	if (strncmp(resource, "P_#", 3) && !strncmp(resource, "P_", 2))
+		lock_cmd |= LCK_CACHE;
+
 	pthread_mutex_lock(&lvm_lock);
-	DEBUGLOG("Dropping metadata for VG %s\n", vgname);
-	lvmcache_drop_metadata(vgname, 0);
+	switch (lock_cmd) {
+		case LCK_VG_COMMIT:
+			DEBUGLOG("vg_commit notification for VG %s\n", vgname);
+			lvmcache_commit_metadata(vgname);
+			break;
+		case LCK_VG_REVERT:
+			DEBUGLOG("vg_revert notification for VG %s\n", vgname);
+			lvmcache_drop_metadata(vgname, 1);
+			break;
+		case LCK_VG_DROP_CACHE:
+		default:
+			DEBUGLOG("Invalidating cached metadata for VG %s\n", vgname);
+			lvmcache_drop_metadata(vgname, 0);
+	}
 	pthread_mutex_unlock(&lvm_lock);
 }
 
--- LVM2/lib/locking/locking.h	2009/10/01 14:15:34	1.52
+++ LVM2/lib/locking/locking.h	2010/01/05 16:09:34	1.53
@@ -33,7 +33,8 @@
  *   Use VG_ORPHANS to lock all orphan PVs.
  *   Use VG_GLOBAL as a global lock and to wipe the internal cache.
  *   char *vol holds volume group name.
- *   Set the LCK_CACHE flag to invalidate 'vol' in the internal cache.
+ *   Set LCK_CACHE flag when manipulating 'vol' metadata in the internal cache.
+ *   (Like commit, revert or invalidate metadata.)
  *   If more than one lock needs to be held simultaneously, they must be
  *   acquired in alphabetical order of 'vol' (to avoid deadlocks).
  *
@@ -48,6 +49,8 @@
  *   LCK_VG: Uses prefix V_ unless the vol begins with # (i.e. #global or #orphans)
  *           or the LCK_CACHE flag is set when it uses the prefix P_.
  * If LCK_CACHE is set, we do not take out a real lock.
+ * NB In clustered situations, LCK_CACHE is not propagated directly to remote nodes.
+ * (It can be deduced from lock name.)
  */
 
 /*
@@ -107,6 +110,11 @@
 #define LCK_VG_WRITE		(LCK_VG | LCK_WRITE | LCK_HOLD)
 #define LCK_VG_UNLOCK		(LCK_VG | LCK_UNLOCK)
 #define LCK_VG_DROP_CACHE	(LCK_VG | LCK_WRITE | LCK_CACHE)
+
+/* FIXME: LCK_HOLD abused here */
+#define LCK_VG_COMMIT		(LCK_VG | LCK_WRITE | LCK_CACHE | LCK_HOLD)
+#define LCK_VG_REVERT		(LCK_VG | LCK_READ  | LCK_CACHE | LCK_HOLD)
+
 #define LCK_VG_BACKUP		(LCK_VG | LCK_CACHE)
 
 #define LCK_LV_EXCLUSIVE	(LCK_LV | LCK_EXCL)
@@ -142,6 +150,10 @@
 	lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE | LCK_LOCAL)
 #define drop_cached_metadata(vg)	\
 	lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE)
+#define remote_commit_cached_metadata(vg)	\
+	lock_vol((vg)->cmd, (vg)->name, LCK_VG_COMMIT)
+#define remote_revert_cached_metadata(vg)	\
+	lock_vol((vg)->cmd, (vg)->name, LCK_VG_REVERT)
 #define remote_backup_metadata(vg)	\
 	lock_vol((vg)->cmd, (vg)->name, LCK_VG_BACKUP)
 
--- LVM2/lib/metadata/metadata.c	2010/01/05 16:01:22	1.307
+++ LVM2/lib/metadata/metadata.c	2010/01/05 16:09:34	1.308
@@ -2331,6 +2331,12 @@
 		}
 	}
 
+	/*
+	 * Instruct remote nodes to upgrade cached metadata.
+	 */
+	if (cache_updated)
+		remote_commit_cached_metadata(vg);
+
 	/* If update failed, remove any cached precommitted metadata. */
 	if (!cache_updated && !drop_cached_metadata(vg))
 		log_error("Attempt to drop cached metadata failed "
@@ -2356,6 +2362,8 @@
 		log_error("Attempt to drop cached metadata failed "
 			  "after reverted update for VG %s.", vg->name);
 
+	remote_revert_cached_metadata(vg);
+
 	return 1;
 }
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-01-05 16:06 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2010-01-05 16:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-05 16:06:43

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/cache      : lvmcache.c lvmcache.h 
	lib/locking    : file_locking.c 

Log message:
	Add possibility to handle precommitted metadata in lvmcache.
	
	- Add drop_precommitted flag to force drop precommitted metadata
	- add lvmcache_commit_metadata() which upgrades precommitted metadata in cache
	
	No functional change in this patch - just preparation for following change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1358&r2=1.1359
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44

--- LVM2/WHATS_NEW	2010/01/05 16:05:12	1.1358
+++ LVM2/WHATS_NEW	2010/01/05 16:06:42	1.1359
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Add possibility to drop precommitted metadata in lvmcache.
   Move processing of VG locks to separate function in clvmd.
   Properly decode flags even for VG locks.
   Properly handle precommitted flag in cache when commited data only present.
--- LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:05:12	1.80
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:06:42	1.81
@@ -693,7 +693,7 @@
 
 	pthread_mutex_lock(&lvm_lock);
 	DEBUGLOG("Dropping metadata for VG %s\n", vgname);
-	lvmcache_drop_metadata(vgname);
+	lvmcache_drop_metadata(vgname, 0);
 	pthread_mutex_unlock(&lvm_lock);
 }
 
--- LVM2/lib/cache/lvmcache.c	2009/12/16 19:22:12	1.74
+++ LVM2/lib/cache/lvmcache.c	2010/01/05 16:06:43	1.75
@@ -158,7 +158,7 @@
 	_update_cache_vginfo_lock_state(vginfo, locked);
 }
 
-static void _drop_metadata(const char *vgname)
+static void _drop_metadata(const char *vgname, int drop_precommitted)
 {
 	struct lvmcache_vginfo *vginfo;
 	struct lvmcache_info *info;
@@ -172,26 +172,48 @@
 	 * already invalidated the PV labels (before caching it)
 	 * and we must not do it again.
 	 */
+	if (!drop_precommitted && vginfo->precommitted && !vginfo->vgmetadata)
+		log_error(INTERNAL_ERROR "metadata commit (or revert) missing before "
+			  "dropping metadata from cache.");
 
-	if (!vginfo->precommitted)
+	if (drop_precommitted || !vginfo->precommitted)
 		dm_list_iterate_items(info, &vginfo->infos)
 			info->status |= CACHE_INVALID;
 
 	_free_cached_vgmetadata(vginfo);
 }
 
-void lvmcache_drop_metadata(const char *vgname)
+/*
+ * Remote node uses this to upgrade precommited metadata to commited state
+ * when receives vg_commit notification.
+ * (Note that devices can be suspended here, if so, precommited metadata are already read.)
+ */
+void lvmcache_commit_metadata(const char *vgname)
+{
+	struct lvmcache_vginfo *vginfo;
+
+	if (!(vginfo = vginfo_from_vgname(vgname, NULL)))
+		return;
+
+	if (vginfo->precommitted) {
+		log_debug("Precommitted metadata cache: VG %s upgraded to committed.",
+			  vginfo->vgname);
+		vginfo->precommitted = 0;
+	}
+}
+
+void lvmcache_drop_metadata(const char *vgname, int drop_precommitted)
 {
 	/* For VG_ORPHANS, we need to invalidate all labels on orphan PVs. */
 	if (!strcmp(vgname, VG_ORPHANS)) {
-		_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME);
-		_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME);
-		_drop_metadata(FMT_POOL_ORPHAN_VG_NAME);
+		_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME, 0);
+		_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME, 0);
+		_drop_metadata(FMT_POOL_ORPHAN_VG_NAME, 0);
 
 		/* Indicate that PVs could now be missing from the cache */
 		init_full_scan_done(0);
 	} else if (!vgname_is_locked(VG_GLOBAL))
-		_drop_metadata(vgname);
+		_drop_metadata(vgname, drop_precommitted);
 }
 
 /*
--- LVM2/lib/cache/lvmcache.h	2009/09/02 21:34:11	1.25
+++ LVM2/lib/cache/lvmcache.h	2010/01/05 16:06:43	1.26
@@ -111,6 +111,7 @@
 
 /* Returns cached volume group metadata. */
 struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted);
-void lvmcache_drop_metadata(const char *vgname);
+void lvmcache_drop_metadata(const char *vgname, int drop_precommitted);
+void lvmcache_commit_metadata(const char *vgname);
 
 #endif
--- LVM2/lib/locking/file_locking.c	2009/09/02 14:47:40	1.43
+++ LVM2/lib/locking/file_locking.c	2010/01/05 16:06:43	1.44
@@ -259,7 +259,7 @@
 	case LCK_VG:
 		/* Skip cache refresh for VG_GLOBAL - the caller handles it */
 		if (strcmp(resource, VG_GLOBAL))
-			lvmcache_drop_metadata(resource);
+			lvmcache_drop_metadata(resource, 0);
 
 		/* LCK_CACHE does not require a real lock */
 		if (flags & LCK_CACHE)


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2010-01-05 16:03 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2010-01-05 16:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-01-05 16:03:38

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : cluster_locking.c 

Log message:
	Properly decode flags even for VG locks.
	
	And decode flags in humar readable form in client.
	And clean some trailing whitespaces.
	
	No functional change in this patch (only debugging messages changed).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1356&r2=1.1357
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39

--- LVM2/WHATS_NEW	2010/01/05 16:01:22	1.1356
+++ LVM2/WHATS_NEW	2010/01/05 16:03:37	1.1357
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Properly decode flags even for VG locks.
   Properly handle precommitted flag in cache when commited data only present.
   Resume renamed volumes in reverse order to preserve memlock pairing.
   Drop metadata cache after device was autorepaired and removed from VG.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/12/09 19:30:56	1.78
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/01/05 16:03:37	1.79
@@ -74,23 +74,23 @@
 	const char *command;
 
 	switch (cmdl & LCK_TYPE_MASK) {
-	case LCK_NULL:   
-		type = "NULL";   
+	case LCK_NULL:
+		type = "NULL";
 		break;
-	case LCK_READ:   
-		type = "READ";   
+	case LCK_READ:
+		type = "READ";
 		break;
-	case LCK_PREAD:  
-		type = "PREAD";  
+	case LCK_PREAD:
+		type = "PREAD";
 		break;
-	case LCK_WRITE:  
-		type = "WRITE";  
+	case LCK_WRITE:
+		type = "WRITE";
 		break;
-	case LCK_EXCL:   
-		type = "EXCL";   
+	case LCK_EXCL:
+		type = "EXCL";
 		break;
-	case LCK_UNLOCK: 
-		type = "UNLOCK"; 
+	case LCK_UNLOCK:
+		type = "UNLOCK";
 		break;
 	default:
 		type = "unknown";
@@ -98,34 +98,35 @@
 	}
 
 	switch (cmdl & LCK_SCOPE_MASK) {
-	case LCK_VG: 
-		scope = "VG"; 
+	case LCK_VG:
+		scope = "VG";
+		command = "LCK_VG";
 		break;
-	case LCK_LV: 
+	case LCK_LV:
 		scope = "LV"; 
+		switch (cmdl & LCK_MASK) {
+		case LCK_LV_EXCLUSIVE & LCK_MASK:
+			command = "LCK_LV_EXCLUSIVE";
+			break;
+		case LCK_LV_SUSPEND & LCK_MASK:
+			command = "LCK_LV_SUSPEND";
+			break;
+		case LCK_LV_RESUME & LCK_MASK:
+			command = "LCK_LV_RESUME";
+			break;
+		case LCK_LV_ACTIVATE & LCK_MASK:
+			command = "LCK_LV_ACTIVATE";
+			break;
+		case LCK_LV_DEACTIVATE & LCK_MASK:
+			command = "LCK_LV_DEACTIVATE";
+			break;
+		default:
+			command = "unknown";
+			break;
+		}
 		break;
 	default:
 		scope = "unknown";
-		break;
-	}
-
-	switch (cmdl & LCK_MASK) {
-	case LCK_LV_EXCLUSIVE & LCK_MASK:
-		command = "LCK_LV_EXCLUSIVE";  
-		break;
-	case LCK_LV_SUSPEND & LCK_MASK:    
-		command = "LCK_LV_SUSPEND";    
-		break;
-	case LCK_LV_RESUME & LCK_MASK:     
-		command = "LCK_LV_RESUME";     
-		break;
-	case LCK_LV_ACTIVATE & LCK_MASK:   
-		command = "LCK_LV_ACTIVATE";   
-		break;
-	case LCK_LV_DEACTIVATE & LCK_MASK: 
-		command = "LCK_LV_DEACTIVATE"; 
-		break;
-	default:
 		command = "unknown";
 		break;
 	}
--- LVM2/lib/locking/cluster_locking.c	2009/12/09 18:28:27	1.38
+++ LVM2/lib/locking/cluster_locking.c	2010/01/05 16:03:37	1.39
@@ -450,12 +450,13 @@
 		return 0;
 	}
 
-	log_very_verbose("Locking %s %s %s %s%s%s%s (0x%x)", lock_scope, lockname,
-			 lock_type,
-			 flags & LCK_NONBLOCK ? "" : "B",
-			 flags & LCK_HOLD ? "H" : "",
-			 flags & LCK_LOCAL ? "L" : "",
-			 flags & LCK_CLUSTER_VG ? "C" : "",
+	log_very_verbose("Locking %s %s %s (%s%s%s%s%s%s) (0x%x)", lock_scope, lockname,
+			 lock_type, lock_scope,
+			 flags & LCK_NONBLOCK ? "|NONBLOCK" : "",
+			 flags & LCK_HOLD ? "|HOLD" : "",
+			 flags & LCK_LOCAL ? "|LOCAL" : "",
+			 flags & LCK_CLUSTER_VG ? "|CLUSTER" : "",
+			 flags & LCK_CACHE ? "|CACHE" : "",
 			 flags);
 
 	/* Send a message to the cluster manager */


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-11-23 10:44 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2009-11-23 10:44 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-11-23 10:44:51

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/metadata   : metadata-exported.h metadata.c 

Log message:
	Revert vg_read_internal change, clvmd cannot use vg_read now. (2.02.55)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1320&r2=1.1321
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.122&r2=1.123
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.297&r2=1.298

--- LVM2/WHATS_NEW	2009/11/19 19:53:58	1.1320
+++ LVM2/WHATS_NEW	2009/11/23 10:44:50	1.1321
@@ -1,5 +1,6 @@
 Version 2.02.56 - 
 ====================================
+  Revert vg_read_internal change, clvmd cannot use vg_read now. (2.02.55)
 
 Version 2.02.55 - 19th November 2009
 ====================================
--- LVM2/daemons/clvmd/lvm-functions.c	2009/11/19 12:13:37	1.71
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/11/23 10:44:51	1.72
@@ -774,14 +774,15 @@
 void lvm_do_backup(const char *vgname)
 {
 	struct volume_group * vg;
+	int consistent = 0;
 
 	DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
 
 	pthread_mutex_lock(&lvm_lock);
 
-	vg = vg_read(cmd, vgname, NULL /*vgid*/, 0 /*flags*/);
+	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
 
-	if (!vg_read_error(vg))
+	if (vg && consistent)
 		check_current_backup(vg);
 	else
 		log_error("Error backing up metadata, can't find VG for group %s", vgname);
--- LVM2/lib/metadata/metadata-exported.h	2009/11/19 12:13:37	1.122
+++ LVM2/lib/metadata/metadata-exported.h	2009/11/23 10:44:51	1.123
@@ -380,6 +380,8 @@
 int vg_write(struct volume_group *vg);
 int vg_commit(struct volume_group *vg);
 int vg_revert(struct volume_group *vg);
+struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
+			     const char *vgid, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
 				int warnings, int scan_label_only);
@@ -470,7 +472,7 @@
 		     force_t force);
 /*
  * vg_release() must be called on every struct volume_group allocated
- * by vg_create() or vg_read() to free it when no longer required.
+ * by vg_create() or vg_read_internal() to free it when no longer required.
  */
 void vg_release(struct volume_group *vg);
 
--- LVM2/lib/metadata/metadata.c	2009/11/19 13:44:37	1.297
+++ LVM2/lib/metadata/metadata.c	2009/11/23 10:44:51	1.298
@@ -58,10 +58,6 @@
 static uint32_t _vg_bad_status_bits(const struct volume_group *vg,
 				    uint32_t status);
 
-static struct volume_group *_vg_read_internal(struct cmd_context *cmd,
-					      const char *vgname,
-					      const char *vgid, int *consistent);
-
 const char _really_init[] =
     "Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
 
@@ -288,7 +284,7 @@
 	struct pv_list *pvl;
 	int r = 0, consistent = 0;
 
-	if (!(vg = _vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
 		log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
 			  vg_name);
 		return 0;
@@ -790,10 +786,10 @@
 		/* NOTE: let caller decide - this may be check for existence */
 		return _vg_make_handle(cmd, NULL, rc);
 
-	/* FIXME: Is this _vg_read_internal necessary? Move it inside
+	/* FIXME: Is this vg_read_internal necessary? Move it inside
 	   vg_lock_newname? */
 	/* is this vg name already in use ? */
-	if ((vg = _vg_read_internal(cmd, vg_name, NULL, &consistent))) {
+	if ((vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 		log_error("A volume group called '%s' already exists.", vg_name);
 		unlock_and_release_vg(cmd, vg, vg_name);
 		return _vg_make_handle(cmd, NULL, FAILED_EXIST);
@@ -2494,7 +2490,7 @@
 
 	if (is_orphan_vg(vgname)) {
 		if (use_precommitted) {
-			log_error("Internal error: _vg_read requires vgname "
+			log_error("Internal error: vg_read_internal requires vgname "
 				  "with pre-commit.");
 			return NULL;
 		}
@@ -2783,9 +2779,8 @@
 	return correct_vg;
 }
 
-static struct volume_group *_vg_read_internal(struct cmd_context *cmd,
-					      const char *vgname,
-					      const char *vgid, int *consistent)
+struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
+			     const char *vgid, int *consistent)
 {
 	struct volume_group *vg;
 	struct lv_list *lvl;
@@ -3050,7 +3045,7 @@
 			stack;
 			continue;
 		}
-		if (!(vg = _vg_read_internal(cmd, vgname, vgid, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) {
 			stack;
 			continue;
 		}
@@ -3284,7 +3279,7 @@
 	if (!lock_vol(cmd, lock_name, lock_flags))
 		return_NULL;
 
-	if (!(vg = _vg_read_internal(cmd, vg_name, vgid, &consistent)))
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
 		return_NULL;
 
 	if (!consistent) {
@@ -3341,7 +3336,7 @@
 	consistent_in = consistent;
 
 	/* If consistent == 1, we get NULL here if correction fails. */
-	if (!(vg = _vg_read_internal(cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) {
 		if (consistent_in && !consistent) {
 			log_error("Volume group \"%s\" inconsistent.", vg_name);
 			failure |= FAILED_INCONSISTENT;


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-07-24 18:15 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-07-24 18:15 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-24 18:15:07

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : locking.c locking.h 

Log message:
	All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1200&r2=1.1201
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49

--- LVM2/WHATS_NEW	2009/07/24 15:01:43	1.1200
+++ LVM2/WHATS_NEW	2009/07/24 18:15:06	1.1201
@@ -1,5 +1,6 @@
 Version 2.02.50 - 
 ================================
+  All LV locks are non-blocking so remove LCK_NONBLOCK from separate macros.
   Fix race condition with vgcreate and vgextend on same device (2.02.49).
   Remove redundant validate_name call from vgreduce.
   Add lvm_{pv|vg|lv}_get_{name|uuid} liblvm functions.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/07/16 00:36:59	1.66
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/07/24 18:15:07	1.67
@@ -65,8 +65,6 @@
 	int lock_mode;
 };
 
-#define LCK_MASK (LCK_TYPE_MASK | LCK_SCOPE_MASK)
-
 static const char *decode_locking_cmd(unsigned char cmdl)
 {
 	static char buf[128];
@@ -482,28 +480,28 @@
 	cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
 
 	switch (command) {
-	case LCK_LV_EXCLUSIVE:
+	case LCK_LV_EXCLUSIVE & LCK_MASK:
 		status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
 		break;
 
-	case LCK_LV_SUSPEND:
+	case LCK_LV_SUSPEND & LCK_MASK:
 		status = do_suspend_lv(resource);
 		if (!status)
 			suspended++;
 		break;
 
 	case LCK_UNLOCK:
-	case LCK_LV_RESUME:	/* if active */
+	case LCK_LV_RESUME & LCK_MASK:	/* if active */
 		status = do_resume_lv(resource);
 		if (!status)
 			suspended--;
 		break;
 
-	case LCK_LV_ACTIVATE:
+	case LCK_LV_ACTIVATE & LCK_MASK:
 		status = do_activate_lv(resource, lock_flags, LKM_CRMODE);
 		break;
 
-	case LCK_LV_DEACTIVATE:
+	case LCK_LV_DEACTIVATE & LCK_MASK:
 		status = do_deactivate_lv(resource, lock_flags);
 		break;
 
--- LVM2/lib/locking/locking.c	2009/07/15 05:49:47	1.62
+++ LVM2/lib/locking/locking.c	2009/07/24 18:15:07	1.63
@@ -386,9 +386,10 @@
 		/* If LVM1 driver knows about the VG, it can't be accessed. */
 		if (!check_lvm1_vg_inactive(cmd, vol))
 			return 0;
+		break;
 	case LCK_LV:
-		/* Suspend LV if it's active. */
-		strncpy(resource, vol, sizeof(resource));
+		/* All LV locks are non-blocking. */
+		flags |= LCK_NONBLOCK;
 		break;
 	default:
 		log_error("Unrecognised lock scope: %d",
@@ -396,6 +397,8 @@
 		return 0;
 	}
 
+	strncpy(resource, vol, sizeof(resource));
+
 	if (!_lock_vol(cmd, resource, flags))
 		return 0;
 
--- LVM2/lib/locking/locking.h	2009/06/12 08:30:19	1.48
+++ LVM2/lib/locking/locking.h	2009/07/24 18:15:07	1.49
@@ -106,17 +106,19 @@
 #define LCK_VG_DROP_CACHE	(LCK_VG | LCK_WRITE | LCK_CACHE)
 #define LCK_VG_BACKUP		(LCK_VG | LCK_CACHE)
 
-#define LCK_LV_EXCLUSIVE	(LCK_LV | LCK_EXCL | LCK_NONBLOCK)
-#define LCK_LV_SUSPEND		(LCK_LV | LCK_WRITE | LCK_NONBLOCK)
-#define LCK_LV_RESUME		(LCK_LV | LCK_UNLOCK | LCK_NONBLOCK)
-#define LCK_LV_ACTIVATE		(LCK_LV | LCK_READ | LCK_NONBLOCK)
-#define LCK_LV_DEACTIVATE	(LCK_LV | LCK_NULL | LCK_NONBLOCK)
+#define LCK_LV_EXCLUSIVE	(LCK_LV | LCK_EXCL)
+#define LCK_LV_SUSPEND		(LCK_LV | LCK_WRITE)
+#define LCK_LV_RESUME		(LCK_LV | LCK_UNLOCK)
+#define LCK_LV_ACTIVATE		(LCK_LV | LCK_READ)
+#define LCK_LV_DEACTIVATE	(LCK_LV | LCK_NULL)
+
+#define LCK_MASK (LCK_TYPE_MASK | LCK_SCOPE_MASK)
 
 #define LCK_LV_CLUSTERED(lv)	\
 	(vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0)
 
 #define lock_lv_vol(cmd, lv, flags)	\
-	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv))
+	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv) | LCK_NONBLOCK)
 
 #define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
 #define unlock_and_release_vg(cmd, vg, vol) \


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-07-16  0:37 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-07-16  0:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-16 00:37:00

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c 
	lib/log        : log.c lvm-logging.h 
	liblvm         : lvm_base.c 
	tools          : lvmcmdline.c 

Log message:
	Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
	Change create_toolcontext to still return an object if it fails part-way.
	Add EUNCLASSIFIED (-1) as the default LVM errno code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1190&r2=1.1191
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/lvm-logging.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102

--- LVM2/WHATS_NEW	2009/07/15 23:57:54	1.1190
+++ LVM2/WHATS_NEW	2009/07/16 00:36:59	1.1191
@@ -1,5 +1,8 @@
 Version 2.02.50 - 
 ================================
+  Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
+  Change create_toolcontext to still return an object if it fails part-way.
+  Add EUNCLASSIFIED (-1) as the default LVM errno code.
   Store any errno and error messages issued while processing each command.
   Use log_error macro consistently throughout in place of log_err.
 
--- LVM2/daemons/clvmd/lvm-functions.c	2009/07/15 23:57:55	1.65
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/07/16 00:36:59	1.66
@@ -792,6 +792,11 @@
 		return 0;
 	}
 
+	if (stored_errno()) {
+		destroy_toolcontext(cmd);
+		return 0;
+	}
+
 	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
--- LVM2/lib/commands/toolcontext.c	2009/07/15 23:57:55	1.81
+++ LVM2/lib/commands/toolcontext.c	2009/07/16 00:36:59	1.82
@@ -1083,6 +1083,9 @@
 	dm_list_init(&cmd->tags);
 	dm_list_init(&cmd->config_files);
 
+	/* FIXME Make this configurable? */
+	reset_lvm_errno(1);
+
 	/*
 	 * Environment variable LVM_SYSTEM_DIR overrides this below.
 	 */
@@ -1092,7 +1095,7 @@
 		strcpy(cmd->system_dir, DEFAULT_SYS_DIR);
 
 	if (!_get_env_vars(cmd))
-		goto error;
+		goto_out;
 
 	/* Create system directory if it doesn't already exist */
 	if (*cmd->system_dir && !dm_create_dir(cmd->system_dir)) {
@@ -1100,58 +1103,58 @@
 			  "files and internal cache.");
 		log_error("Set environment variable LVM_SYSTEM_DIR to alternative location "
 			  "or empty string.");
-		goto error;
+		goto out;
 	}
 
 	if (!(cmd->libmem = dm_pool_create("library", 4 * 1024))) {
 		log_error("Library memory pool creation failed");
-		goto error;
+		goto out;
 	}
 
 	if (!_init_lvm_conf(cmd))
-		goto error;
+		goto_out;
 
 	_init_logging(cmd);
 
 	if (!_init_hostname(cmd))
-		goto error;
+		goto_out;
 
 	if (!_init_tags(cmd, cmd->cft))
-		goto error;
+		goto_out;
 
 	if (!_init_tag_configs(cmd))
-		goto error;
+		goto_out;
 
 	if (!_merge_config_files(cmd))
-		goto error;
+		goto_out;
 
 	if (!_process_config(cmd))
-		goto error;
+		goto_out;
 
 	if (!_init_dev_cache(cmd))
-		goto error;
+		goto_out;
 
 	if (!_init_filters(cmd, 1))
-		goto error;
+		goto_out;
 
 	if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) {
 		log_error("Command memory pool creation failed");
-		goto error;
+		goto out;
 	}
 
 	memlock_init(cmd);
 
 	if (!_init_formats(cmd))
-		goto error;
+		goto_out;
 
 	if (!init_lvmcache_orphans(cmd))
-		goto error;
+		goto_out;
 
 	if (!_init_segtypes(cmd))
-		goto error;
+		goto_out;
 
 	if (!_init_backup(cmd))
-		goto error;
+		goto_out;
 
 	_init_rand(cmd);
 
@@ -1161,20 +1164,8 @@
 	cmd->current_settings = cmd->default_settings;
 
 	cmd->config_valid = 1;
-	reset_lvm_errno(1);  /* FIXME Move to top when cmd returned on error */
+out:
 	return cmd;
-
-      error:
-	_destroy_tag_configs(cmd);
-	dev_cache_exit();
-	if (cmd->filter)
-		cmd->filter->destroy(cmd->filter);
-	if (cmd->mem)
-		dm_pool_destroy(cmd->mem);
-	if (cmd->libmem)
-		dm_pool_destroy(cmd->libmem);
-	dm_free(cmd);
-	return NULL;
 }
 
 static void _destroy_formats(struct dm_list *formats)
--- LVM2/lib/log/log.c	2009/07/15 23:57:55	1.50
+++ LVM2/lib/log/log.c	2009/07/16 00:36:59	1.51
@@ -152,12 +152,12 @@
 	_store_errmsg = store_errmsg;
 }
 
-int lvm_errno(void)
+int stored_errno(void)
 {
 	return _lvm_errno;
 }
 
-const char *lvm_errmsg(void)
+const char *stored_errmsg(void)
 {
 	return _lvm_errmsg ? : "";
 }
--- LVM2/lib/log/lvm-logging.h	2009/07/15 23:57:55	1.4
+++ LVM2/lib/log/lvm-logging.h	2009/07/16 00:36:59	1.5
@@ -20,7 +20,8 @@
 	       const char *format, ...)
     __attribute__ ((format(printf, 5, 6)));
 
-#define LOG_LINE(l, x...) print_log(l, __FILE__, __LINE__ , 0, ## x)
+#define EUNCLASSIFIED -1	/* Generic error code */
+#define LOG_LINE(l, x...) print_log(l, __FILE__, __LINE__ , EUNCLASSIFIED, ## x)
 
 #include "log.h"
 
@@ -44,8 +45,8 @@
 
 int error_message_produced(void);
 void reset_lvm_errno(int store_errmsg);
-int lvm_errno(void);
-const char *lvm_errmsg(void);
+int stored_errno(void);
+const char *stored_errmsg(void);
 
 /* Suppress messages to stdout/stderr (1) or everywhere (2) */
 /* Returns previous setting */
--- LVM2/liblvm/lvm_base.c	2009/07/14 03:01:18	1.3
+++ LVM2/liblvm/lvm_base.c	2009/07/16 00:37:00	1.4
@@ -29,6 +29,10 @@
 	cmd = create_toolcontext(1, system_dir);
 	if (!cmd)
 		return NULL;
+
+	if (stored_errno())
+		return (lvm_t) cmd;
+
 	/*
 	 * FIXME: if an non memory error occured, return the cmd (maybe some
 	 * cleanup needed).
@@ -66,3 +70,13 @@
 	/* FIXME: re-init locking needed here? */
 	return refresh_toolcontext((struct cmd_context *)libh);
 }
+
+int lvm_errno(lvm_t libh)
+{
+	return stored_errno();
+}
+
+const char *lvm_errmsg(lvm_t libh)
+{
+	return stored_errmsg();
+}
--- LVM2/tools/lvmcmdline.c	2009/07/15 23:57:55	1.101
+++ LVM2/tools/lvmcmdline.c	2009/07/16 00:37:00	1.102
@@ -1181,6 +1181,11 @@
 	if (!(cmd = create_toolcontext(0, NULL)))
 		return_NULL;
 
+	if (stored_errno()) {
+		destroy_toolcontext(cmd);
+		return_NULL;
+	}
+
 	return cmd;
 }
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-07-15 23:57 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-07-15 23:57 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-15 23:57:55

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	doc            : example_cmdlib.c 
	lib/commands   : toolcontext.c 
	lib/log        : log.c lvm-logging.h 
	po             : pogen.h 
	tools          : lvmcmdline.c 

Log message:
	Store any errno and error messages issued while processing each command.
	(Enabled by default while we test it, but in due course we'll only store
	the error messages when we need to.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1189&r2=1.1190
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example_cmdlib.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/lvm-logging.h.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/po/pogen.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101

--- LVM2/WHATS_NEW	2009/07/15 20:02:46	1.1189
+++ LVM2/WHATS_NEW	2009/07/15 23:57:54	1.1190
@@ -1,5 +1,6 @@
 Version 2.02.50 - 
 ================================
+  Store any errno and error messages issued while processing each command.
   Use log_error macro consistently throughout in place of log_err.
 
 Version 2.02.49 - 15th July 2009
--- LVM2/daemons/clvmd/lvm-functions.c	2009/07/13 19:49:48	1.64
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/07/15 23:57:55	1.65
@@ -714,7 +714,7 @@
 	return NULL;
 }
 
-static void lvm2_log_fn(int level, const char *file, int line,
+static void lvm2_log_fn(int level, const char *file, int line, int dm_errno,
 			const char *message)
 {
 
@@ -723,7 +723,7 @@
  	   We need to NULL the function ptr otherwise it will just call
 	   back into here! */
 	init_log_fn(NULL);
-	print_log(level, file, line, "%s", message);
+	print_log(level, file, line, dm_errno, "%s", message);
 	init_log_fn(lvm2_log_fn);
 
 	/*
--- LVM2/doc/example_cmdlib.c	2004/03/30 19:54:59	1.1
+++ LVM2/doc/example_cmdlib.c	2009/07/15 23:57:55	1.2
@@ -15,7 +15,8 @@
 #include "lvm2cmd.h"
 
 /* All output gets passed to this function line-by-line */
-void test_log_fn(int level, const char *file, int line, const char *format)
+void test_log_fn(int level, int dm_errno, const char *file, int line,
+		 const char *format)
 {
 	/* Extract and process output here rather than printing it */
 
--- LVM2/lib/commands/toolcontext.c	2009/07/15 20:02:46	1.80
+++ LVM2/lib/commands/toolcontext.c	2009/07/15 23:57:55	1.81
@@ -190,7 +190,7 @@
 
 	/* Tell device-mapper about our logging */
 #ifdef DEVMAPPER_SUPPORT
-	dm_log_init(print_log);
+	dm_log_with_errno_init(print_log);
 #endif
 }
 
@@ -1161,6 +1161,7 @@
 	cmd->current_settings = cmd->default_settings;
 
 	cmd->config_valid = 1;
+	reset_lvm_errno(1);  /* FIXME Move to top when cmd returned on error */
 	return cmd;
 
       error:
@@ -1288,6 +1289,8 @@
 		persistent_filter_dump(cmd->filter);
 
 	cmd->config_valid = 1;
+
+	reset_lvm_errno(1);
 	return 1;
 }
 
@@ -1317,4 +1320,5 @@
 	activation_exit();
 	fin_log();
 	fin_syslog();
+	reset_lvm_errno(0);
 }
--- LVM2/lib/log/log.c	2008/10/30 17:27:27	1.49
+++ LVM2/lib/log/log.c	2009/07/15 23:57:55	1.50
@@ -38,6 +38,10 @@
 
 static lvm2_log_fn_t _lvm2_log_fn = NULL;
 
+static int _lvm_errno = 0;
+static int _store_errmsg = 0;
+static char *_lvm_errmsg = NULL;
+
 void init_log_fn(lvm2_log_fn_t log_fn)
 {
 	if (log_fn)
@@ -136,13 +140,37 @@
 	_indent = indent;
 }
 
-void print_log(int level, const char *file, int line, const char *format, ...)
+void reset_lvm_errno(int store_errmsg)
+{
+	_lvm_errno = 0;
+
+	if (_lvm_errmsg) {
+		dm_free(_lvm_errmsg);
+		_lvm_errmsg = NULL;
+	}
+
+	_store_errmsg = store_errmsg;
+}
+
+int lvm_errno(void)
+{
+	return _lvm_errno;
+}
+
+const char *lvm_errmsg(void)
+{
+	return _lvm_errmsg ? : "";
+}
+
+void print_log(int level, const char *file, int line, int dm_errno,
+	       const char *format, ...)
 {
 	va_list ap;
 	char buf[1024], buf2[4096], locn[4096];
 	int bufused, n;
 	const char *message;
 	const char *trformat;		/* Translated format string */
+	char *newbuf;
 	int use_stderr = level & _LOG_STDERR;
 
 	level &= ~_LOG_STDERR;
@@ -155,7 +183,10 @@
 
 	trformat = _(format);
 
-	if (_lvm2_log_fn) {
+	if (dm_errno && !_lvm_errno)
+		_lvm_errno = dm_errno;
+
+	if (_lvm2_log_fn || (_store_errmsg && (level == _LOG_ERR))) {
 		va_start(ap, format);
 		n = vsnprintf(buf2, sizeof(buf2) - 1, trformat, ap);
 		va_end(ap);
@@ -168,8 +199,21 @@
 
 		buf2[sizeof(buf2) - 1] = '\0';
 		message = &buf2[0];
+	}
 
-		_lvm2_log_fn(level, file, line, message);
+	if (_store_errmsg && (level == _LOG_ERR)) {
+		if (!_lvm_errmsg)
+			_lvm_errmsg = dm_strdup(message);
+		else if ((newbuf = dm_realloc(_lvm_errmsg,
+ 					      strlen(_lvm_errmsg) +
+					      strlen(message) + 2))) {
+			_lvm_errmsg = strcat(newbuf, "\n");
+			_lvm_errmsg = strcat(newbuf, message);
+		}
+	}
+
+	if (_lvm2_log_fn) {
+		_lvm2_log_fn(level, file, line, 0, message);
 
 		return;
 	}
--- LVM2/lib/log/lvm-logging.h	2009/07/10 09:59:37	1.3
+++ LVM2/lib/log/lvm-logging.h	2009/07/15 23:57:55	1.4
@@ -16,15 +16,16 @@
 #ifndef _LVM_LOGGING_H
 #define _LVM_LOGGING_H
 
-void print_log(int level, const char *file, int line, const char *format, ...)
-    __attribute__ ((format(printf, 4, 5)));
+void print_log(int level, const char *file, int line, int dm_errno,
+	       const char *format, ...)
+    __attribute__ ((format(printf, 5, 6)));
 
-#define LOG_LINE(l, x...) print_log(l, __FILE__, __LINE__ , ## x)
+#define LOG_LINE(l, x...) print_log(l, __FILE__, __LINE__ , 0, ## x)
 
 #include "log.h"
 
 typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
-			       const char *message);
+			       int dm_errno, const char *message);
 
 void init_log_fn(lvm2_log_fn_t log_fn);
 
@@ -42,6 +43,9 @@
 void fin_syslog(void);
 
 int error_message_produced(void);
+void reset_lvm_errno(int store_errmsg);
+int lvm_errno(void);
+const char *lvm_errmsg(void);
 
 /* Suppress messages to stdout/stderr (1) or everywhere (2) */
 /* Returns previous setting */
--- LVM2/po/pogen.h	2009/07/10 09:59:38	1.4
+++ LVM2/po/pogen.h	2009/07/15 23:57:55	1.5
@@ -19,8 +19,8 @@
  * different architectures.
  */
 
-#define print_log(level, file, line, format, args...) print_log(format, args)
+#define print_log(level, dm_errno, file, line, format, args...) print_log(format, args)
 #define dm_log(level, file, line, format, args...) dm_log(format, args)
-#define dm_log_with_errno(level, file, line, format, dm_errno, args...) \
-    dm_log(format, args)
+#define dm_log_with_errno(level, dm_errno, file, line, format, args...) \
+    dm_log(level, file, line, format, args)
 
--- LVM2/tools/lvmcmdline.c	2009/07/15 20:02:48	1.100
+++ LVM2/tools/lvmcmdline.c	2009/07/15 23:57:55	1.101
@@ -1054,6 +1054,8 @@
 	 */
 	dm_pool_empty(cmd->mem);
 
+	reset_lvm_errno(1);
+
 	return ret;
 }
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-07-13 19:49 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-07-13 19:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-07-13 19:49:49

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.h 
	tools          : lvmcmdline.c 

Log message:
	Make cmd->cmd_line const.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1177&r2=1.1178
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW	2009/07/13 11:25:35	1.1177
+++ LVM2/WHATS_NEW	2009/07/13 19:49:48	1.1178
@@ -1,5 +1,6 @@
 Version 2.02.49 - 
 ================================
+  Make cmd->cmd_line const.
   Fix dev name mismatch in vgcreate man page example.
   Refactor vg_remove_single for use in liblvm.
   Make all tools consistent with lock ordering - obtain VG_ORPHAN lock second.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/06/15 12:15:23	1.63
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/07/13 19:49:48	1.64
@@ -795,7 +795,7 @@
 	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
-	cmd->cmd_line = (char *)"clvmd";
+	cmd->cmd_line = "clvmd";
 
 	/* Check lvm.conf is setup for cluster-LVM */
 	check_config();
--- LVM2/lib/commands/toolcontext.h	2009/02/22 21:14:38	1.31
+++ LVM2/lib/commands/toolcontext.h	2009/07/13 19:49:49	1.32
@@ -63,7 +63,7 @@
 	const char *kernel_vsn;
 
 	unsigned rand_seed;
-	char *cmd_line;
+	const char *cmd_line;
 	struct command *command;
 	char **argv;
 	unsigned is_long_lived:1;	/* Optimises persistent_filter handling */
--- LVM2/tools/lvmcmdline.c	2009/07/07 01:51:00	1.98
+++ LVM2/tools/lvmcmdline.c	2009/07/13 19:49:49	1.99
@@ -918,7 +918,7 @@
 	cmd->handles_missing_pvs = 0;
 }
 
-static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
+static const char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
 {
 	int i, space;
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-06-12  8:30 mbroz
  0 siblings, 0 replies; 33+ messages in thread
From: mbroz @ 2009-06-12  8:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-12 08:30:19

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : cluster_locking.c locking.h 

Log message:
	Re-instate partial activation support in clustered mode. (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1145&r2=1.1146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/WHATS_NEW	2009/06/09 15:31:36	1.1145
+++ LVM2/WHATS_NEW	2009/06/12 08:30:19	1.1146
@@ -1,5 +1,6 @@
 Version 2.02.48 - 
 ===============================
+  Re-instate partial activation support in clustered mode. (2.02.40)
   Use 'lvm lvresize' instead of 'lvresize' in fsadm.
   Do not use '-n' realine option in fsadm for busybox compatiblity.
   Update vgrename, vgsplit, and vgcreate to use vg_lock_newname.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/05/19 10:39:00	1.61
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/06/12 08:30:19	1.62
@@ -145,7 +145,8 @@
 {
 	static char buf[128];
 
-	sprintf(buf, "0x%x (%s%s)", flags,
+	sprintf(buf, "0x%x (%s%s%s)", flags,
+		flags & LCK_PARTIAL_MODE	  ? "PARTIAL_MODE " : "",
 		flags & LCK_MIRROR_NOSYNC_MODE	  ? "MIRROR_NOSYNC " : "",
 		flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR " : "");
 
@@ -478,6 +479,8 @@
 	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
 		init_dmeventd_monitor(0);
 
+	cmd->partial_activation = (lock_flags & LCK_PARTIAL_MODE) ? 1 : 0;
+
 	switch (command) {
 	case LCK_LV_EXCLUSIVE:
 		status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
@@ -516,6 +519,8 @@
 	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
 		init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR);
 
+	cmd->partial_activation = 0;
+
 	/* clean the pool for another command */
 	dm_pool_empty(cmd->mem);
 	pthread_mutex_unlock(&lvm_lock);
--- LVM2/lib/locking/cluster_locking.c	2009/05/21 03:04:53	1.35
+++ LVM2/lib/locking/cluster_locking.c	2009/06/12 08:30:19	1.36
@@ -24,6 +24,7 @@
 #include "lvm-string.h"
 #include "locking.h"
 #include "locking_types.h"
+#include "toolcontext.h"
 
 #include <assert.h>
 #include <stddef.h>
@@ -298,7 +299,8 @@
 	return 1;
 }
 
-static int _lock_for_cluster(unsigned char clvmd_cmd, uint32_t flags, const char *name)
+static int _lock_for_cluster(struct cmd_context *cmd, unsigned char clvmd_cmd,
+			     uint32_t flags, const char *name)
 {
 	int status;
 	int i;
@@ -324,6 +326,9 @@
 	if (dmeventd_monitor_mode())
 		args[1] |= LCK_DMEVENTD_MONITOR_MODE;
 
+	if (cmd->partial_activation)
+		args[1] |= LCK_PARTIAL_MODE;
+
 	/*
 	 * VG locks are just that: locks, and have no side effects
 	 * so we only need to do them on the local node because all
@@ -389,7 +394,7 @@
 		if (flags == LCK_VG_BACKUP) {
 			log_very_verbose("Requesting backup of VG metadata for %s",
 					 resource);
-			return _lock_for_cluster(CLVMD_CMD_VG_BACKUP,
+			return _lock_for_cluster(cmd, CLVMD_CMD_VG_BACKUP,
 						 LCK_CLUSTER_VG, resource);
 		}
 
@@ -453,7 +458,7 @@
 			 flags);
 
 	/* Send a message to the cluster manager */
-	return _lock_for_cluster(clvmd_cmd, flags, lockname);
+	return _lock_for_cluster(cmd, clvmd_cmd, flags, lockname);
 }
 
 static int decode_lock_type(const char *response)
--- LVM2/lib/locking/locking.h	2009/05/21 03:04:53	1.47
+++ LVM2/lib/locking/locking.h	2009/06/12 08:30:19	1.48
@@ -85,6 +85,7 @@
 /*
  * Additional lock bits for cluster communication
  */
+#define LCK_PARTIAL_MODE        0x00000001U	/* Partial activation? */
 #define LCK_MIRROR_NOSYNC_MODE	0x00000002U	/* Mirrors don't require sync */
 #define LCK_DMEVENTD_MONITOR_MODE	0x00000004U	/* Register with dmeventd */
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-02-22 21:14 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-02-22 21:14 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-02-22 21:14:38

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c toolcontext.h 
	tools          : lvmcmdline.c 

Log message:
	Add system_dir parameter to create_toolcontext() and call it system_dir
	everywhere for consistency.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1048&r2=1.1049
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93

--- LVM2/WHATS_NEW	2009/02/22 19:00:26	1.1048
+++ LVM2/WHATS_NEW	2009/02/22 21:14:37	1.1049
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Add system_dir parameter to create_toolcontext().
   Add --dataalignment to pvcreate to specify alignment of data area.
   Exclude LCK_CACHE locks from _vg_lock_count, fixing interrupt unblocking.
   Provide da and mda locations in debug message when writing text format label.
--- LVM2/daemons/clvmd/lvm-functions.c	2009/01/26 19:01:32	1.56
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/02/22 21:14:38	1.57
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -724,7 +724,7 @@
 /* Called to initialise the LVM context of the daemon */
 int init_lvm(int using_gulm)
 {
-	if (!(cmd = create_toolcontext(1))) {
+	if (!(cmd = create_toolcontext(1, NULL))) {
 		log_error("Failed to allocate command context");
 		return 0;
 	}
--- LVM2/lib/commands/toolcontext.c	2008/12/18 05:27:18	1.72
+++ LVM2/lib/commands/toolcontext.c	2009/02/22 21:14:38	1.73
@@ -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.
  *
@@ -64,7 +64,7 @@
 
 	/* Set to "" to avoid using any system directory */
 	if ((e = getenv("LVM_SYSTEM_DIR"))) {
-		if (dm_snprintf(cmd->sys_dir, sizeof(cmd->sys_dir),
+		if (dm_snprintf(cmd->system_dir, sizeof(cmd->system_dir),
 				 "%s", e) < 0) {
 			log_error("LVM_SYSTEM_DIR environment variable "
 				  "is too long.");
@@ -393,7 +393,7 @@
 		filler = "_";
 
 	if (dm_snprintf(config_file, sizeof(config_file), "%s/lvm%s%s.conf",
-			 cmd->sys_dir, filler, tag) < 0) {
+			 cmd->system_dir, filler, tag) < 0) {
 		log_error("LVM_SYSTEM_DIR or tag was too long");
 		return 0;
 	}
@@ -442,7 +442,7 @@
 static int _init_lvm_conf(struct cmd_context *cmd)
 {
 	/* No config file if LVM_SYSTEM_DIR is empty */
-	if (!*cmd->sys_dir) {
+	if (!*cmd->system_dir) {
 		if (!(cmd->cft = create_config_tree(NULL, 0))) {
 			log_error("Failed to create config tree");
 			return 0;
@@ -663,7 +663,7 @@
 	if (cache_dir || cache_file_prefix) {
 		if (dm_snprintf(cache_file, sizeof(cache_file),
 		    "%s%s%s/%s.cache",
-		    cache_dir ? "" : cmd->sys_dir,
+		    cache_dir ? "" : cmd->system_dir,
 		    cache_dir ? "" : "/",
 		    cache_dir ? : DEFAULT_CACHE_SUBDIR,
 		    cache_file_prefix ? : DEFAULT_CACHE_FILE_PREFIX) < 0) {
@@ -673,7 +673,7 @@
 	} else if (!(dev_cache = find_config_tree_str(cmd, "devices/cache", NULL)) &&
 		   (dm_snprintf(cache_file, sizeof(cache_file),
 				"%s/%s/%s.cache",
-				cmd->sys_dir, DEFAULT_CACHE_SUBDIR,
+				cmd->system_dir, DEFAULT_CACHE_SUBDIR,
 				DEFAULT_CACHE_FILE_PREFIX) < 0)) {
 		log_error("Persistent cache filename too long.");
 		return 0;
@@ -691,7 +691,7 @@
 	if (find_config_tree_int(cmd, "devices/write_cache_state", 1))
 		cmd->dump_filter = 1;
 
-	if (!*cmd->sys_dir)
+	if (!*cmd->system_dir)
 		cmd->dump_filter = 0;
 
 	/*
@@ -924,7 +924,7 @@
 	char default_dir[PATH_MAX];
 	const char *dir;
 
-	if (!cmd->sys_dir) {
+	if (!cmd->system_dir) {
 		log_warn("WARNING: Metadata changes will NOT be backed up");
 		backup_init(cmd, "", 0);
 		archive_init(cmd, "", 0, 0, 0);
@@ -943,10 +943,10 @@
 					 DEFAULT_ARCHIVE_NUMBER);
 
 	if (dm_snprintf
-	    (default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir,
+	    (default_dir, sizeof(default_dir), "%s/%s", cmd->system_dir,
 	     DEFAULT_ARCHIVE_SUBDIR) == -1) {
 		log_err("Couldn't create default archive path '%s/%s'.",
-			cmd->sys_dir, DEFAULT_ARCHIVE_SUBDIR);
+			cmd->system_dir, DEFAULT_ARCHIVE_SUBDIR);
 		return 0;
 	}
 
@@ -965,10 +965,10 @@
 			     DEFAULT_BACKUP_ENABLED);
 
 	if (dm_snprintf
-	    (default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir,
+	    (default_dir, sizeof(default_dir), "%s/%s", cmd->system_dir,
 	     DEFAULT_BACKUP_SUBDIR) == -1) {
 		log_err("Couldn't create default backup path '%s/%s'.",
-			cmd->sys_dir, DEFAULT_BACKUP_SUBDIR);
+			cmd->system_dir, DEFAULT_BACKUP_SUBDIR);
 		return 0;
 	}
 
@@ -998,7 +998,8 @@
 }
 
 /* Entry point */
-struct cmd_context *create_toolcontext(unsigned is_long_lived)
+struct cmd_context *create_toolcontext(unsigned is_long_lived,
+				       const char *system_dir)
 {
 	struct cmd_context *cmd;
 
@@ -1028,13 +1029,19 @@
 	dm_list_init(&cmd->tags);
 	dm_list_init(&cmd->config_files);
 
-	strcpy(cmd->sys_dir, DEFAULT_SYS_DIR);
+	/*
+	 * Environment variable LVM_SYSTEM_DIR overrides this below.
+	 */
+        if (system_dir)
+		strncpy(cmd->system_dir, system_dir, sizeof(cmd->system_dir) - 1);
+	else
+		strcpy(cmd->system_dir, DEFAULT_SYS_DIR);
 
 	if (!_get_env_vars(cmd))
 		goto error;
 
 	/* Create system directory if it doesn't already exist */
-	if (*cmd->sys_dir && !dm_create_dir(cmd->sys_dir)) {
+	if (*cmd->system_dir && !dm_create_dir(cmd->system_dir)) {
 		log_error("Failed to create LVM2 system dir for metadata backups, config "
 			  "files and internal cache.");
 		log_error("Set environment variable LVM_SYSTEM_DIR to alternative location "
--- LVM2/lib/commands/toolcontext.h	2008/12/18 05:27:18	1.30
+++ LVM2/lib/commands/toolcontext.h	2009/02/22 21:14:38	1.31
@@ -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.
  *
@@ -88,13 +88,18 @@
 	struct dm_list tags;
 	int hosttags;
 
-	char sys_dir[PATH_MAX];
+	char system_dir[PATH_MAX];
 	char dev_dir[PATH_MAX];
 	char proc_dir[PATH_MAX];
 	char sysfs_dir[PATH_MAX];
 };
 
-struct cmd_context *create_toolcontext(unsigned is_long_lived);
+/*
+ * system_dir may be NULL to use the default value.
+ * The environment variable LVM_SYSTEM_DIR always takes precedence.
+ */
+struct cmd_context *create_toolcontext(unsigned is_long_lived,
+				       const char *system_dir);
 void destroy_toolcontext(struct cmd_context *cmd);
 int refresh_toolcontext(struct cmd_context *cmd);
 int config_files_changed(struct cmd_context *cmd);
--- LVM2/tools/lvmcmdline.c	2009/02/03 16:23:19	1.92
+++ LVM2/tools/lvmcmdline.c	2009/02/22 21:14:38	1.93
@@ -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.
  *
@@ -1158,7 +1158,7 @@
 
 	_cmdline.the_args = &_the_args[0];
 
-	if (!(cmd = create_toolcontext(0)))
+	if (!(cmd = create_toolcontext(0, NULL)))
 		return_NULL;
 
 	return cmd;


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2009-01-26 19:01 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2009-01-26 19:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-01-26 19:01:32

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	tools          : pvdisplay.c pvresize.c reporter.c toollib.c 
	                 vgreduce.c vgrename.c vgsplit.c 

Log message:
	Rename vg_read() to vg_read_internal(). (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1028&r2=1.1029
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.196&r2=1.197
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.187&r2=1.188
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.140&r2=1.141
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69

--- LVM2/WHATS_NEW	2009/01/26 14:46:09	1.1028
+++ LVM2/WHATS_NEW	2009/01/26 19:01:32	1.1029
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Rename vg_read() to vg_read_internal().
 
 Version 2.02.44 - 26th January 2009
 ===================================
--- LVM2/daemons/clvmd/lvm-functions.c	2008/12/18 05:27:17	1.55
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/01/26 19:01:32	1.56
@@ -711,7 +711,7 @@
 
 	DEBUGLOG("Triggering backup of VG metadata for %s. suspended=%d\n", vgname, suspended);
 
-	vg = vg_read(cmd, vgname, NULL /*vgid*/, &consistent);
+	vg = vg_read_internal(cmd, vgname, NULL /*vgid*/, &consistent);
 	if (vg) {
 		if (consistent)
 			check_current_backup(vg);
--- LVM2/lib/metadata/metadata-exported.h	2008/12/04 15:54:27	1.56
+++ LVM2/lib/metadata/metadata-exported.h	2009/01/26 19:01:32	1.57
@@ -76,7 +76,7 @@
 						   written out in metadata*/
 
 //#define POSTORDER_FLAG	0x02000000U /* Not real flags, reserved for
-//#define POSTORDER_OPEN_FLAG	0x04000000U    temporary use inside vg_read. */
+//#define POSTORDER_OPEN_FLAG	0x04000000U    temporary use inside vg_read_internal. */
 
 #define LVM_READ              	0x00000100U	/* LV VG */
 #define LVM_WRITE             	0x00000200U	/* LV VG */
@@ -328,7 +328,7 @@
 int vg_write(struct volume_group *vg);
 int vg_commit(struct volume_group *vg);
 int vg_revert(struct volume_group *vg);
-struct volume_group *vg_read(struct cmd_context *cmd, const char *vg_name,
+struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vg_name,
 			     const char *vgid, int *consistent);
 struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
 				struct dm_list *mdas, uint64_t *label_sector,
--- LVM2/lib/metadata/metadata.c	2008/12/04 15:54:27	1.196
+++ LVM2/lib/metadata/metadata.c	2009/01/26 19:01:32	1.197
@@ -224,8 +224,8 @@
 	struct pv_list *pvl;
 	int consistent = 0;
 
-	if (!(vg = vg_read(fmt->cmd, vg_name, vgid, &consistent))) {
-		log_error("get_pv_from_vg_by_id: vg_read failed to read VG %s",
+	if (!(vg = vg_read_internal(fmt->cmd, vg_name, vgid, &consistent))) {
+		log_error("get_pv_from_vg_by_id: vg_read_internal failed to read VG %s",
 			  vg_name);
 		return 0;
 	}
@@ -503,7 +503,7 @@
 		return_NULL;
 
 	/* is this vg name already in use ? */
-	if (vg_read(cmd, vg_name, NULL, &consistent)) {
+	if (vg_read_internal(cmd, vg_name, NULL, &consistent)) {
 		log_err("A volume group called '%s' already exists.", vg_name);
 		goto bad;
 	}
@@ -1684,12 +1684,12 @@
 	return ret;
 }
 
-/* Caller sets consistent to 1 if it's safe for vg_read to correct
+/* Caller sets consistent to 1 if it's safe for vg_read_internal to correct
  * inconsistent metadata on disk (i.e. the VG write lock is held).
  * This guarantees only consistent metadata is returned.
  * If consistent is 0, caller must check whether consistent == 1 on return
  * and take appropriate action if it isn't (e.g. abort; get write lock
- * and call vg_read again).
+ * and call vg_read_internal again).
  *
  * If precommitted is set, use precommitted metadata if present.
  *
@@ -1716,7 +1716,7 @@
 
 	if (is_orphan_vg(vgname)) {
 		if (use_precommitted) {
-			log_error("Internal error: vg_read requires vgname "
+			log_error("Internal error: vg_read_internal requires vgname "
 				  "with pre-commit.");
 			return NULL;
 		}
@@ -1974,7 +1974,7 @@
 	return correct_vg;
 }
 
-struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
+struct volume_group *vg_read_internal(struct cmd_context *cmd, const char *vgname,
 			     const char *vgid, int *consistent)
 {
 	struct volume_group *vg;
@@ -2002,7 +2002,7 @@
 
 /* This is only called by lv_from_lvid, which is only called from
  * activate.c so we know the appropriate VG lock is already held and
- * the vg_read is therefore safe.
+ * the vg_read_internal is therefore safe.
  */
 static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
 					    const char *vgid,
@@ -2034,7 +2034,7 @@
 	if (memlock())
 		return NULL;
 
-	/* FIXME Need a genuine read by ID here - don't vg_read by name! */
+	/* FIXME Need a genuine read by ID here - don't vg_read_internal by name! */
 	/* FIXME Disabled vgrenames while active for now because we aren't
 	 *       allowed to do a full scan here any more. */
 
@@ -2218,7 +2218,7 @@
 			stack;
 			continue;
 		}
-		if (!(vg = vg_read(cmd, vgname, vgid, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vgname, vgid, &consistent))) {
 			stack;
 			continue;
 		}
@@ -2446,7 +2446,7 @@
 		return NULL;
 	}
 
-	if (!(vg = vg_read(cmd, vg_name, vgid, &consistent)) ||
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)) ||
 	    ((misc_flags & FAIL_INCONSISTENT) && !consistent)) {
 		log_error("Volume group \"%s\" not found", vg_name);
 		unlock_vg(cmd, vg_name);
--- LVM2/lib/metadata/metadata.h	2009/01/09 22:44:33	1.187
+++ LVM2/lib/metadata/metadata.h	2009/01/26 19:01:32	1.188
@@ -79,7 +79,7 @@
 //						   written out in metadata*/
 
 #define POSTORDER_FLAG		0x02000000U /* Not real flags, reserved for  */
-#define POSTORDER_OPEN_FLAG	0x04000000U /* temporary use inside vg_read. */
+#define POSTORDER_OPEN_FLAG	0x04000000U /* temporary use inside vg_read_internal. */
 
 //#define LVM_READ              	0x00000100U	/* LV VG */
 //#define LVM_WRITE             	0x00000200U	/* LV VG */
--- LVM2/tools/pvdisplay.c	2008/01/30 14:00:02	1.46
+++ LVM2/tools/pvdisplay.c	2009/01/26 19:01:32	1.47
@@ -37,7 +37,7 @@
 
 	 	/*
 		 * Replace possibly incomplete PV structure with new one
-		 * allocated in vg_read() path.
+		 * allocated in vg_read_internal() path.
 		 */
 		 if (!(pvl = find_pv_in_vg(vg, pv_name))) {
 			 log_error("Unable to find \"%s\" in volume group \"%s\"",
--- LVM2/tools/pvresize.c	2008/11/03 22:14:30	1.23
+++ LVM2/tools/pvresize.c	2009/01/26 19:01:32	1.24
@@ -62,7 +62,7 @@
 			return 0;
 		}
 
-		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 			unlock_vg(cmd, vg_name);
 			log_error("Unable to find volume group of \"%s\"",
 				  pv_name);
--- LVM2/tools/reporter.c	2009/01/10 17:21:17	1.43
+++ LVM2/tools/reporter.c	2009/01/26 19:01:32	1.44
@@ -136,7 +136,7 @@
 
 		/*
 		 * Replace possibly incomplete PV structure with new one
-		 * allocated in vg_read() path.
+		 * allocated in vg_read_internal() path.
 		*/
 		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
 			log_error("Unable to find \"%s\" in volume group \"%s\"",
--- LVM2/tools/toollib.c	2008/12/22 09:00:51	1.140
+++ LVM2/tools/toollib.c	2009/01/26 19:01:32	1.141
@@ -291,7 +291,7 @@
 			consistent = 1;
 		else
 			consistent = 0;
-		if (!(vg = vg_read(cmd, vgname, NULL, &consistent)) || !consistent) {
+		if (!(vg = vg_read_internal(cmd, vgname, NULL, &consistent)) || !consistent) {
 			unlock_vg(cmd, vgname);
 			if (!vg)
 				log_error("Volume group \"%s\" "
@@ -433,7 +433,7 @@
 	}
 
 	log_verbose("Finding volume group \"%s\"", vg_name);
-	if (!(vg = vg_read(cmd, vg_name, vgid, &consistent))) {
+	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) {
 		log_error("Volume group \"%s\" not found", vg_name);
 		unlock_vg(cmd, vg_name);
 		return ECMD_FAILED;
@@ -720,7 +720,7 @@
 					log_error("Can't lock %s: skipping", sll->str);
 					continue;
 				}
-				if (!(vg = vg_read(cmd, sll->str, NULL, &consistent))) {
+				if (!(vg = vg_read_internal(cmd, sll->str, NULL, &consistent))) {
 					log_error("Volume group \"%s\" not found", sll->str);
 					unlock_vg(cmd, sll->str);
 					ret_max = ECMD_FAILED;
@@ -1143,7 +1143,7 @@
 		return NULL;
 	}
 
-	return vg_read(cmd, vgname, NULL, &consistent);
+	return vg_read_internal(cmd, vgname, NULL, &consistent);
 }
 
 int apply_lvname_restrictions(const char *name)
--- LVM2/tools/vgreduce.c	2008/11/03 22:14:30	1.85
+++ LVM2/tools/vgreduce.c	2009/01/26 19:01:32	1.86
@@ -426,7 +426,7 @@
 	vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv);
 	vg->extent_count -= pv_pe_count(pv);
 
-	if(!(orphan_vg = vg_read(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
+	if(!(orphan_vg = vg_read_internal(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) ||
 	   !consistent) {
 		log_error("Unable to read existing orphan PVs");
 		unlock_vg(cmd, VG_ORPHANS);
@@ -520,7 +520,7 @@
 		return ECMD_FAILED;
 	}
 
-	if ((!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent)
+	if ((!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent)) || !consistent)
 	    && !repairing) {
 		log_error("Volume group \"%s\" doesn't exist", vg_name);
 		unlock_vg(cmd, vg_name);
@@ -541,7 +541,7 @@
 		}
 
 		consistent = !arg_count(cmd, force_ARG);
-		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
+		if (!(vg = vg_read_internal(cmd, vg_name, NULL, &consistent))) {
 			log_error("Volume group \"%s\" not found", vg_name);
 			unlock_vg(cmd, vg_name);
 			return ECMD_FAILED;
--- LVM2/tools/vgrename.c	2008/12/22 09:00:51	1.57
+++ LVM2/tools/vgrename.c	2009/01/26 19:01:32	1.58
@@ -75,7 +75,7 @@
 		return 0;
 	}
 
-	if (!(vg = vg_read(cmd, vg_name_old, vgid, &consistent)) || !consistent) {
+	if (!(vg = vg_read_internal(cmd, vg_name_old, vgid, &consistent)) || !consistent) {
 		log_error("Volume group %s %s%s%snot found.", vg_name_old,
 		vgid ? "(" : "", vgid ? vgid : "", vgid ? ") " : "");
 		unlock_vg(cmd, vg_name_old);
@@ -107,7 +107,7 @@
 	}
 
 	consistent = 0;
-	if ((vg_new = vg_read(cmd, vg_name_new, NULL, &consistent))) {
+	if ((vg_new = vg_read_internal(cmd, vg_name_new, NULL, &consistent))) {
 		log_error("New volume group \"%s\" already exists",
 			  vg_name_new);
 		goto error;
--- LVM2/tools/vgsplit.c	2008/11/03 22:14:30	1.68
+++ LVM2/tools/vgsplit.c	2009/01/26 19:01:32	1.69
@@ -334,7 +334,7 @@
 	}
 
 	consistent = 0;
-	if ((vg_to = vg_read(cmd, vg_name_to, NULL, &consistent))) {
+	if ((vg_to = vg_read_internal(cmd, vg_name_to, NULL, &consistent))) {
 		existing_vg = 1;
 		if (new_vg_option_specified(cmd)) {
 			log_error("Volume group \"%s\" exists, but new VG "
@@ -451,7 +451,7 @@
 	 */
 	consistent = 1;
 	if (!test_mode() &&
-	    (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) ||
+	    (!(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);


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2008-09-19  6:42 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2008-09-19  6:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-09-19 06:42:00

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	doc            : example.conf 
	lib/activate   : activate.c dev_manager.c 
	lib/commands   : toolcontext.c toolcontext.h 
	lib/config     : defaults.h 
	lib/display    : display.c 
	lib/format1    : disk-rep.h format1.c import-export.c 
	lib/format_text: archiver.c flags.c import_vsn1.c 
	lib/locking    : cluster_locking.c locking.h 
	lib/log        : log.c log.h 
	lib/metadata   : metadata-exported.h metadata.c metadata.h 
	lib/report     : report.c 
	man            : lvm.conf.5 vgreduce.8 
	tools          : commands.h lvmcmdline.c lvremove.c pvcreate.c 
	                 vgcfgbackup.c vgreduce.c 

Log message:
	Improve the way VGs with PVs missing are handled so manual intervention
	is required in fewer circumstances.  (mornfall)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.959&r2=1.960
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.137&r2=1.138
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.139&r2=1.140
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/disk-rep.h.diff?cvsroot=lvm2&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/format1.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archiver.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.190&r2=1.191
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.181&r2=1.182
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgreduce.8.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.118&r2=1.119
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvremove.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcfgbackup.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83

--- LVM2/WHATS_NEW	2008/09/19 05:33:37	1.959
+++ LVM2/WHATS_NEW	2008/09/19 06:41:57	1.960
@@ -1,5 +1,11 @@
 Version 2.02.40 - 
 ================================
+  In VG with PVs missing, by default allow activation of LVs that are complete.
+  Track PARTIAL_LV and MISSING_PV flags internally.
+  Require --force with --removemissing in vgreduce to remove partial LVs.
+  No longer write out PARTIAL flag into metadata backups.
+  Treat new default activation/missing_stripe_filler "error" as an error target.
+  Remove internal partial_mode.
   Add device/md_chunk_alignment to lvm.conf.
   Pass struct physical_volume to pe_align and adjust for md chunk size.
   Store sysfs location in struct cmd_context.
--- LVM2/daemons/clvmd/lvm-functions.c	2008/06/06 16:37:51	1.44
+++ LVM2/daemons/clvmd/lvm-functions.c	2008/09/19 06:41:57	1.45
@@ -413,9 +413,6 @@
 		}
 	}
 
-	if (lock_flags & LCK_PARTIAL_MODE)
-		init_partial(1);
-
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(1);
 
@@ -454,9 +451,6 @@
 		break;
 	}
 
-	if (lock_flags & LCK_PARTIAL_MODE)
-		init_partial(0);
-
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(0);
 
--- LVM2/doc/example.conf	2008/09/19 05:33:36	1.37
+++ LVM2/doc/example.conf	2008/09/19 06:41:57	1.38
@@ -271,11 +271,13 @@
 }
 
 activation {
-    # Device used in place of missing stripes if activating incomplete volume.
-    # For now, you need to set this up yourself first (e.g. with 'dmsetup')
-    # For example, you could make it return I/O errors using the 'error' 
-    # target or make it return zeros.
-    missing_stripe_filler = "/dev/ioerror"
+    # How to fill in missing stripes if activating an incomplete volume.
+    # Using "error" will make inaccessible parts of the device return
+    # I/O errors on access.  You can instead use a device path, in which 
+    # case, that device will be used to in place of missing stripes.
+    # But note that using anything other than "error" with mirrored 
+    # or snapshotted volumes is likely to result in data corruption.
+    missing_stripe_filler = "error"
 
     # How much stack (in KB) to reserve for use while devices suspended
     reserved_stack = 256
--- LVM2/lib/activate/activate.c	2008/06/08 11:33:15	1.137
+++ LVM2/lib/activate/activate.c	2008/09/19 06:41:57	1.138
@@ -1027,6 +1027,12 @@
 		return 0;
 	}
 
+	if ((!lv->vg->cmd->partial_activate) && (lv->status & PARTIAL_LV)) {
+		log_error("Refusing activation of partial LV %s. Use --partial to override.",
+			  lv->name);
+		return_0;
+	}
+
 	if (test_mode()) {
 		_skip("Activating '%s'.", lv->name);
 		return 1;
--- LVM2/lib/activate/dev_manager.c	2008/07/15 00:25:51	1.139
+++ LVM2/lib/activate/dev_manager.c	2008/09/19 06:41:57	1.140
@@ -47,7 +47,6 @@
 
 	struct cmd_context *cmd;
 
-	const char *stripe_filler;
 	void *target_state;
 	uint32_t pvmove_mirror_count;
 
@@ -59,8 +58,6 @@
 	const char *old_name;
 };
 
-static const char *stripe_filler = NULL;
-
 static char *_build_dlid(struct dm_pool *mem, const char *lvid, const char *layer)
 {
 	char *dlid;
@@ -443,13 +440,6 @@
 	dm->cmd = cmd;
 	dm->mem = mem;
 
-	if (!stripe_filler) {
-		stripe_filler = find_config_tree_str(cmd,
-						"activation/missing_stripe_filler",
-						DEFAULT_STRIPE_FILLER);
-	}
-	dm->stripe_filler = stripe_filler;
-
 	if (!(dm->vg_name = dm_pool_strdup(dm->mem, vg_name)))
 		goto_bad;
 
@@ -699,6 +689,68 @@
 	return NULL;
 }
 
+static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
+			       struct lv_segment *seg, int s)
+{
+	char *id, *name;
+	char errid[32];
+	struct dm_tree_node *node;
+	struct lv_segment *seg_i;
+	int segno = -1, i = 0;;
+	uint64_t size = seg->len * seg->lv->vg->extent_size;
+
+	list_iterate_items(seg_i, &seg->lv->segments) {
+		if (seg == seg_i)
+			segno = i;
+		++i;
+	}
+
+	if (segno < 0) {
+		log_error("_add_error_device called with bad segment");
+		return_NULL;
+	}
+
+	sprintf(errid, "missing_%d_%d", segno, s);
+
+	if (!(id = build_dlid(dm, seg->lv->lvid.s, errid))) 
+		return_NULL;
+
+	if (!(name = build_dm_name(dm->mem, seg->lv->vg->name,
+				   seg->lv->name, errid)))
+		return_NULL;
+	if (!(node = dm_tree_add_new_dev(dtree, name, id, 0, 0, 0, 0, 0)))
+		return_NULL;
+	if (!dm_tree_node_add_error_target(node, size))
+		return_NULL;
+
+	return id;
+}
+
+static int _add_error_area(struct dev_manager *dm, struct dm_tree_node *node,
+			   struct lv_segment *seg, int s)
+{
+	char *dlid;
+	uint64_t extent_size = seg->lv->vg->extent_size;
+
+	if (!strcmp(dm->cmd->stripe_filler, "error")) {
+		/*
+		 * FIXME, the tree pointer is first field of dm_tree_node, but
+		 * we don't have the struct definition available.
+		 */
+		struct dm_tree **tree = (struct dm_tree **) node;
+		dlid = _add_error_device(dm, *tree, seg, s);
+		if (!dlid)
+			return_0;
+		dm_tree_node_add_target_area(node, NULL, dlid,
+					     extent_size * seg_le(seg, s));
+	} else {
+		dm_tree_node_add_target_area(node,
+					     dm->cmd->stripe_filler,
+					     NULL, UINT64_C(0));
+	}
+	return 1;
+}
+
 int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
 		   struct dm_tree_node *node, uint32_t start_area,
 		   uint32_t areas)
@@ -712,11 +764,10 @@
 		     (!seg_pvseg(seg, s) ||
 		      !seg_pv(seg, s) ||
 		      !seg_dev(seg, s))) ||
-		    (seg_type(seg, s) == AREA_LV && !seg_lv(seg, s)))
-			dm_tree_node_add_target_area(node,
-							dm->stripe_filler,
-							NULL, UINT64_C(0));
-		else if (seg_type(seg, s) == AREA_PV)
+		    (seg_type(seg, s) == AREA_LV && !seg_lv(seg, s))) {
+			if (!_add_error_area(dm, node, seg, s))
+				return_0;
+		} else if (seg_type(seg, s) == AREA_PV)
 			dm_tree_node_add_target_area(node,
 							dev_name(seg_dev(seg, s)),
 							NULL,
--- LVM2/lib/commands/toolcontext.c	2008/09/19 03:42:37	1.61
+++ LVM2/lib/commands/toolcontext.c	2008/09/19 06:41:58	1.62
@@ -197,6 +197,7 @@
 {
 	mode_t old_umask;
 	const char *read_ahead;
+	struct stat st;
 
 	/* umask */
 	cmd->default_settings.umask = find_config_tree_int(cmd,
@@ -263,6 +264,24 @@
 		return 0;
 	}
 
+	cmd->stripe_filler = find_config_tree_str(cmd,
+						  "activation/missing_stripe_filler",
+						  DEFAULT_STRIPE_FILLER);
+	if (strcmp(cmd->stripe_filler, "error")) {
+		if (stat(cmd->stripe_filler, &st)) {
+			log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
+				 "is invalid,", cmd->stripe_filler);
+			log_warn("         stat failed: %s", strerror(errno));
+			log_warn("Falling back to \"error\" missing_stripe_filler.");
+			cmd->stripe_filler = "error";
+		} else if (!S_ISBLK(st.st_mode)) {
+			log_warn("WARNING: activation/missing_stripe_filler = \"%s\" "
+				 "is not a block device.", cmd->stripe_filler);
+			log_warn("Falling back to \"error\" missing_stripe_filler.");
+			cmd->stripe_filler = "error";
+		}
+	}
+
 	return 1;
 }
 
@@ -981,6 +1000,7 @@
 	cmd->args = the_args;
 	cmd->is_static = is_static;
 	cmd->is_long_lived = is_long_lived;
+	cmd->handles_missing_pvs = 0;
 	cmd->hosttags = 0;
 	list_init(&cmd->formats);
 	list_init(&cmd->segtypes);
--- LVM2/lib/commands/toolcontext.h	2008/09/19 03:42:37	1.24
+++ LVM2/lib/commands/toolcontext.h	2008/09/19 06:41:58	1.25
@@ -66,8 +66,10 @@
 	struct command *command;
 	struct arg *args;
 	char **argv;
-	unsigned is_static;	/* Static binary? */
-	unsigned is_long_lived;	/* Optimises persistent_filter handling */
+	unsigned is_static:1;	/* Static binary? */
+	unsigned is_long_lived:1;	/* Optimises persistent_filter handling */
+	unsigned handles_missing_pvs:1;
+	unsigned partial_activate:1;
 
 	struct dev_filter *filter;
 	int dump_filter;	/* Dump filter when exiting? */
@@ -81,6 +83,7 @@
 
 	struct archive_params *archive_params;
 	struct backup_params *backup_params;
+	const char *stripe_filler;
 
 	/* List of defined tags */
 	struct list tags;
--- LVM2/lib/config/defaults.h	2008/09/19 05:33:37	1.43
+++ LVM2/lib/config/defaults.h	2008/09/19 06:41:58	1.44
@@ -92,7 +92,7 @@
 #  define DEFAULT_ACTIVATION 0
 #endif
 
-#define DEFAULT_STRIPE_FILLER "/dev/ioerror"
+#define DEFAULT_STRIPE_FILLER "error"
 #define DEFAULT_MIRROR_REGION_SIZE 512	/* KB */
 #define DEFAULT_INTERVAL 15
 
--- LVM2/lib/display/display.c	2008/08/07 14:01:17	1.91
+++ LVM2/lib/display/display.c	2008/09/19 06:41:58	1.92
@@ -578,10 +578,7 @@
 	struct lv_list *lvl;
 	char uuid[64] __attribute((aligned(8)));
 
-	if (vg->status & PARTIAL_VG)
-		active_pvs = list_size(&vg->pvs);
-	else
-		active_pvs = vg->pv_count;
+	active_pvs = vg->pv_count - vg_missing_pv_count(vg);
 
 	log_print("--- Volume group ---");
 	log_print("VG Name               %s", vg->name);
@@ -664,10 +661,7 @@
 	const char *access;
 	char uuid[64] __attribute((aligned(8)));
 
-	if (vg->status & PARTIAL_VG)
-		active_pvs = list_size(&vg->pvs);
-	else
-		active_pvs = vg->pv_count;
+	active_pvs = vg->pv_count - vg_missing_pv_count(vg);
 
 	list_iterate_items(lvl, &vg->lvs)
 		if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT))
--- LVM2/lib/format1/disk-rep.h	2007/08/20 20:55:25	1.51
+++ LVM2/lib/format1/disk-rep.h	2008/09/19 06:41:58	1.52
@@ -212,7 +212,7 @@
 	      struct pv_disk *pvd, struct physical_volume *pv);
 
 int import_vg(struct dm_pool *mem,
-	      struct volume_group *vg, struct disk_list *dl, int partial);
+	      struct volume_group *vg, struct disk_list *dl);
 int export_vg(struct vg_disk *vgd, struct volume_group *vg);
 
 int import_lv(struct dm_pool *mem, struct logical_volume *lv, struct lv_disk *lvd);
--- LVM2/lib/format1/format1.c	2008/03/17 16:51:31	1.107
+++ LVM2/lib/format1/format1.c	2008/09/19 06:41:58	1.108
@@ -23,7 +23,7 @@
 #include "segtype.h"
 
 /* VG consistency checks */
-static int _check_vgs(struct list *pvs, int *partial)
+static int _check_vgs(struct list *pvs)
 {
 	struct list *pvh, *t;
 	struct disk_list *dl = NULL;
@@ -33,8 +33,6 @@
 	uint32_t exported = 0;
 	int first_time = 1;
 
-	*partial = 0;
-
 	/*
 	 * If there are exported and unexported PVs, ignore exported ones.
 	 * This means an active VG won't be affected if disks are inserted
@@ -98,10 +96,6 @@
 				  dl->vgd.pe_total, dl->vgd.pe_allocated,
 				  dl->vgd.pvg_total);
 			list_del(pvh);
-			if (partial_mode()) {
-				*partial = 1;
-				continue;
-			}
 			return 0;
 		}
 		pv_count++;
@@ -111,9 +105,6 @@
 	if (pv_count != first->vgd.pv_cur) {
 		log_error("%d PV(s) found for VG %s: expected %d",
 			  pv_count, first->pvd.vg_name, first->vgd.pv_cur);
-		if (!partial_mode())
-			return 0;
-		*partial = 1;
 	}
 
 	return 1;
@@ -125,7 +116,6 @@
 	struct dm_pool *mem = fid->fmt->cmd->mem;
 	struct volume_group *vg = dm_pool_alloc(mem, sizeof(*vg));
 	struct disk_list *dl;
-	int partial;
 
 	if (!vg)
 		goto_bad;
@@ -142,12 +132,12 @@
 	list_init(&vg->lvs);
 	list_init(&vg->tags);
 
-	if (!_check_vgs(pvs, &partial))
+	if (!_check_vgs(pvs))
 		goto_bad;
 
 	dl = list_item(pvs->n, struct disk_list);
 
-	if (!import_vg(mem, vg, dl, partial))
+	if (!import_vg(mem, vg, dl))
 		goto_bad;
 
 	if (!import_pvs(fid->fmt, mem, vg, pvs, &vg->pvs, &vg->pv_count))
--- LVM2/lib/format1/import-export.c	2008/09/19 04:27:26	1.98
+++ LVM2/lib/format1/import-export.c	2008/09/19 06:41:58	1.99
@@ -214,7 +214,7 @@
 }
 
 int import_vg(struct dm_pool *mem,
-	      struct volume_group *vg, struct disk_list *dl, int partial)
+	      struct volume_group *vg, struct disk_list *dl)
 {
 	struct vg_disk *vgd = &dl->vgd;
 	memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
@@ -236,10 +236,10 @@
 	if (vgd->vg_status & VG_EXTENDABLE)
 		vg->status |= RESIZEABLE_VG;
 
-	if (partial || (vgd->vg_access & VG_READ))
+	if (vgd->vg_access & VG_READ)
 		vg->status |= LVM_READ;
 
-	if (!partial && (vgd->vg_access & VG_WRITE))
+	if (vgd->vg_access & VG_WRITE)
 		vg->status |= LVM_WRITE;
 
 	if (vgd->vg_access & VG_CLUSTERED)
@@ -255,9 +255,6 @@
 	vg->max_pv = vgd->pv_max;
 	vg->alloc = ALLOC_NORMAL;
 
-	if (partial)
-		vg->status |= PARTIAL_VG;
-
 	return 1;
 }
 
--- LVM2/lib/format_text/archiver.c	2008/01/30 13:59:59	1.13
+++ LVM2/lib/format_text/archiver.c	2008/09/19 06:41:58	1.14
@@ -134,10 +134,8 @@
 {
 	int r1, r2;
 
-	init_partial(1);
 	r1 = archive_list(cmd, cmd->archive_params->dir, vg_name);
 	r2 = backup_list(cmd, cmd->backup_params->dir, vg_name);
-	init_partial(0);
 
 	return r1 && r2;
 }
@@ -146,9 +144,7 @@
 {
 	int r;
 
-	init_partial(1);
 	r = archive_list_file(cmd, file);
-	init_partial(0);
 
 	return r;
 }
@@ -393,7 +389,7 @@
 	char path[PATH_MAX];
 	struct volume_group *vg_backup;
 
-	if ((vg->status & PARTIAL_VG) || (vg->status & EXPORTED_VG))
+	if (vg->status & EXPORTED_VG)
 		return;
 
 	if (dm_snprintf(path, sizeof(path), "%s/%s",
--- LVM2/lib/format_text/flags.c	2008/07/10 11:30:57	1.34
+++ LVM2/lib/format_text/flags.c	2008/09/19 06:41:58	1.35
@@ -31,12 +31,12 @@
 static struct flag _vg_flags[] = {
 	{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
 	{RESIZEABLE_VG, "RESIZEABLE", STATUS_FLAG},
-	{PARTIAL_VG, "PARTIAL", STATUS_FLAG},
 	{PVMOVE, "PVMOVE", STATUS_FLAG},
 	{LVM_READ, "READ", STATUS_FLAG},
 	{LVM_WRITE, "WRITE", STATUS_FLAG},
 	{CLUSTERED, "CLUSTERED", STATUS_FLAG},
 	{SHARED, "SHARED", STATUS_FLAG},
+	{PARTIAL_VG, NULL, 0},
 	{PRECOMMITTED, NULL, 0},
 	{0, NULL, 0}
 };
@@ -44,6 +44,7 @@
 static struct flag _pv_flags[] = {
 	{ALLOCATABLE_PV, "ALLOCATABLE", STATUS_FLAG},
 	{EXPORTED_VG, "EXPORTED", STATUS_FLAG},
+	{MISSING_PV, "MISSING", COMPATIBLE_FLAG},
 	{0, NULL, 0}
 };
 
@@ -62,6 +63,8 @@
 	{SNAPSHOT, NULL, 0},
 	{ACTIVATE_EXCL, NULL, 0},
 	{CONVERTING, NULL, 0},
+	{PARTIAL_LV, NULL, 0},
+	{POSTORDER_FLAG, NULL, 0},
 	{0, NULL, 0}
 };
 
@@ -155,7 +158,16 @@
 				break;
 			}
 
-		if (!flags[f].description && (type & STATUS_FLAG)) {
+		if (type == VG_FLAGS && !strcmp(cv->v.str, "PARTIAL")) {
+			/*
+			 * Exception: We no longer write this flag out, but it
+			 * might be encountered in old backup files, so restore
+			 * it in that case. It is never part of live metadata
+			 * though, so only vgcfgrestore needs to be concerned
+			 * by this case.
+			 */
+			s |= PARTIAL_VG;
+		} else if (!flags[f].description && (type & STATUS_FLAG)) {
 			log_err("Unknown status flag '%s'.", cv->v.str);
 			return 0;
 		}
--- LVM2/lib/format_text/import_vsn1.c	2008/09/19 04:27:26	1.53
+++ LVM2/lib/format_text/import_vsn1.c	2008/09/19 06:41:58	1.54
@@ -194,11 +194,6 @@
 		else
 			log_error("Couldn't find device with uuid '%s'.",
 				  buffer);
-
-		if (partial_mode())
-			vg->status |= PARTIAL_VG;
-		else
-			return 0;
 	}
 
 	if (!(pv->vg_name = dm_pool_strdup(mem, vg->name)))
@@ -211,6 +206,9 @@
 		return 0;
 	}
 
+	if (!pv->dev)
+		pv->status |= MISSING_PV;
+
 	/* Late addition */
 	_read_int64(pvn, "dev_size", &pv->size);
 
@@ -800,11 +798,6 @@
 
 	dm_hash_destroy(pv_hash);
 
-	if (vg->status & PARTIAL_VG) {
-		vg->status &= ~LVM_WRITE;
-		vg->status |= LVM_READ;
-	}
-
 	/*
 	 * Finished.
 	 */
--- LVM2/lib/locking/cluster_locking.c	2008/05/09 18:45:15	1.29
+++ LVM2/lib/locking/cluster_locking.c	2008/09/19 06:41:58	1.30
@@ -315,9 +315,6 @@
 	args[0] = flags & 0x7F; /* Maskoff lock flags */
 	args[1] = flags & 0xC0; /* Bitmap flags */
 
-	if (partial_mode())
-		args[1] |= LCK_PARTIAL_MODE;
-
 	if (mirror_in_sync())
 		args[1] |= LCK_MIRROR_NOSYNC_MODE;
 
--- LVM2/lib/locking/locking.h	2008/05/09 19:26:58	1.41
+++ LVM2/lib/locking/locking.h	2008/09/19 06:41:58	1.42
@@ -83,7 +83,6 @@
 /*
  * Additional lock bits for cluster communication
  */
-#define LCK_PARTIAL_MODE	0x00000001U	/* Running in partial mode */
 #define LCK_MIRROR_NOSYNC_MODE	0x00000002U	/* Mirrors don't require sync */
 #define LCK_DMEVENTD_MONITOR_MODE	0x00000004U	/* Register with dmeventd */
 
--- LVM2/lib/log/log.c	2008/06/17 14:14:00	1.47
+++ LVM2/lib/log/log.c	2008/09/19 06:41:59	1.48
@@ -29,7 +29,6 @@
 
 static int _verbose_level = VERBOSE_BASE_LEVEL;
 static int _test = 0;
-static int _partial = 0;
 static int _md_filtering = 0;
 static int _pvmove = 0;
 static int _full_scan_done = 0;	/* Restrict to one full scan during each cmd */
@@ -154,11 +153,6 @@
 	_test = level;
 }
 
-void init_partial(int level)
-{
-	_partial = level;
-}
-
 void init_md_filtering(int level)
 {
 	_md_filtering = level;
@@ -254,11 +248,6 @@
 	return _test;
 }
 
-int partial_mode()
-{
-	return _partial;
-}
-
 int md_filtering()
 {
 	return _md_filtering;
--- LVM2/lib/log/log.h	2008/06/06 19:28:34	1.41
+++ LVM2/lib/log/log.h	2008/09/19 06:41:59	1.42
@@ -64,7 +64,6 @@
 
 void init_verbose(int level);
 void init_test(int level);
-void init_partial(int level);
 void init_md_filtering(int level);
 void init_pvmove(int level);
 void init_full_scan_done(int level);
@@ -84,7 +83,6 @@
 void set_cmd_name(const char *cmd_name);
 
 int test_mode(void);
-int partial_mode(void);
 int md_filtering(void);
 int pvmove_mode(void);
 int full_scan_done(void);
--- LVM2/lib/metadata/metadata-exported.h	2008/09/19 04:27:27	1.52
+++ LVM2/lib/metadata/metadata-exported.h	2008/09/19 06:41:59	1.53
@@ -71,6 +71,13 @@
 //#define PRECOMMITTED		0x00200000U	/* VG - internal use only */
 #define CONVERTING		0x00400000U	/* LV */
 
+#define MISSING_PV              0x00800000U	/* PV */
+#define PARTIAL_LV              0x01000000U	/* LV - derived flag, not
+						   written out in metadata*/
+
+//#define POSTORDER_FLAG	0x02000000U /* Not a real flag, reserved for
+//					       temporary use inside vg_read. */
+
 #define LVM_READ              	0x00000100U	/* LV VG */
 #define LVM_WRITE             	0x00000200U	/* LV VG */
 #define CLUSTERED         	0x00000400U	/* VG */
@@ -564,6 +571,7 @@
 uint32_t pv_pe_count(const pv_t *pv);
 uint32_t pv_pe_alloc_count(const pv_t *pv);
 
+int vg_missing_pv_count(const vg_t *vg);
 uint32_t vg_status(const vg_t *vg);
 #define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED)
 
--- LVM2/lib/metadata/metadata.c	2008/09/19 05:33:36	1.190
+++ LVM2/lib/metadata/metadata.c	2008/09/19 06:41:59	1.191
@@ -334,9 +334,9 @@
 	struct pv_list *pvl;
 	int ret = 1;
 
-	if (!vg || !consistent || (vg_status(vg) & PARTIAL_VG)) {
-		log_error("Volume group \"%s\" not found or inconsistent.",
-			  vg_name);
+	if (!vg || !consistent || vg_missing_pv_count(vg)) {
+		log_error("Volume group \"%s\" not found, is inconsistent "
+			  "or has PVs missing.", vg_name);
 		log_error("Consider vgreduce --removemissing if metadata "
 			  "is inconsistent.");
 		return 0;
@@ -488,19 +488,15 @@
 	struct volume_group *vg;
 	struct dm_pool *mem = cmd->mem;
 	int consistent = 0;
-	int old_partial;
 
 	if (!(vg = dm_pool_zalloc(mem, sizeof(*vg))))
 		return_NULL;
 
 	/* is this vg name already in use ? */
-	old_partial = partial_mode();
-	init_partial(1);
 	if (vg_read(cmd, vg_name, NULL, &consistent)) {
 		log_err("A volume group called '%s' already exists.", vg_name);
 		goto bad;
 	}
-	init_partial(old_partial);
 
 	if (!id_create(&vg->id)) {
 		log_err("Couldn't create uuid for volume group '%s'.", vg_name);
@@ -1191,6 +1187,157 @@
 	return 1;
 }
 
+struct _lv_postorder_baton {
+	int (*fn)(struct logical_volume *lv, void *data);
+	void *data;
+};
+
+static int _lv_postorder_visit(struct logical_volume *,
+			       int (*fn)(struct logical_volume *lv, void *data),
+			       void *data);
+
+static int _lv_postorder_level(struct logical_volume *lv, void *data)
+{
+	struct _lv_postorder_baton *baton = data;
+	int r =_lv_postorder_visit(lv, baton->fn, baton->data);
+	lv->status |= POSTORDER_FLAG;
+	return r;
+};
+
+static int _lv_each_dependency(struct logical_volume *lv,
+			       int (*fn)(struct logical_volume *lv, void *data),
+			       void *data)
+{
+	int i, s;
+	struct lv_segment *lvseg;
+
+	struct logical_volume *deps[] = {
+		lv->snapshot ? lv->snapshot->origin : 0,
+		lv->snapshot ? lv->snapshot->cow : 0 };
+	for (i = 0; i < sizeof(deps) / sizeof(*deps); ++i) {
+		if (deps[i] && !fn(deps[i], data))
+			return_0;
+	}
+
+	list_iterate_items(lvseg, &lv->segments) {
+		if (lvseg->log_lv && !fn(lvseg->log_lv, data))
+			return_0;
+		for (s = 0; s < lvseg->area_count; ++s) {
+			if (seg_type(lvseg, s) == AREA_LV && !fn(seg_lv(lvseg,s), data))
+				return_0;
+		}
+	}
+	return 1;
+}
+
+static int _lv_postorder_cleanup(struct logical_volume *lv, void *data)
+{
+	if (!(lv->status & POSTORDER_FLAG))
+		return 1;
+	lv->status &= ~POSTORDER_FLAG;
+
+	if (!_lv_each_dependency(lv, _lv_postorder_cleanup, data))
+		return_0;
+	return 1;
+}
+
+static int _lv_postorder_visit(struct logical_volume *lv,
+			       int (*fn)(struct logical_volume *lv, void *data),
+			       void *data)
+{
+	struct _lv_postorder_baton baton;
+	int r;
+
+	if (lv->status & POSTORDER_FLAG)
+		return 1;
+
+	baton.fn = fn;
+	baton.data = data;
+	r = _lv_each_dependency(lv, _lv_postorder_level, &baton);
+	if (r) {
+		r = fn(lv, data);
+		log_verbose("visited %s", lv->name);
+	}
+	return r;
+}
+
+/*
+ * This will walk the LV dependency graph in depth-first order and in the
+ * postorder, call a callback function "fn". The void *data is passed along all
+ * the calls. The callback may return zero to indicate an error and terminate
+ * the depth-first walk. The error is propagated to return value of
+ * _lv_postorder.
+ */
+static int _lv_postorder(struct logical_volume *lv,
+			       int (*fn)(struct logical_volume *lv, void *data),
+			       void *data)
+{
+	int r;
+	r = _lv_postorder_visit(lv, fn, data);
+	_lv_postorder_cleanup(lv, 0);
+	return r;
+}
+
+struct _lv_mark_if_partial_baton {
+	int partial;
+};
+
+static int _lv_mark_if_partial_collect(struct logical_volume *lv, void *data)
+{
+	struct _lv_mark_if_partial_baton *baton = data;
+	if (lv->status & PARTIAL_LV)
+		baton->partial = 1;
+
+	return 1;
+}
+
+static int _lv_mark_if_partial_single(struct logical_volume *lv, void *data)
+{
+	int s;
+	struct _lv_mark_if_partial_baton baton;
+	struct lv_segment *lvseg;
+
+	list_iterate_items(lvseg, &lv->segments) {
+		for (s = 0; s < lvseg->area_count; ++s) {
+			if (seg_type(lvseg, s) == AREA_PV) {
+				if (seg_pv(lvseg, s)->status & MISSING_PV)
+					lv->status |= PARTIAL_LV;
+			}
+		}
+	}
+
+	baton.partial = 0;
+	_lv_each_dependency(lv, _lv_mark_if_partial_collect, &baton);
+
+	if (baton.partial)
+		lv->status |= PARTIAL_LV;
+
+	return 1;
+}
+
+static int _lv_mark_if_partial(struct logical_volume *lv)
+{
+	return _lv_postorder(lv, _lv_mark_if_partial_single, NULL);
+}
+
+/*
+ * Mark LVs with missing PVs using PARTIAL_LV status flag. The flag is
+ * propagated transitively, so LVs referencing other LVs are marked
+ * partial as well, if any of their referenced LVs are marked partial.
+ */
+static int _vg_mark_partial_lvs(struct volume_group *vg)
+{
+	struct logical_volume *lv;
+	struct lv_list *lvl;
+
+	list_iterate_items(lvl, &vg->lvs) {
+		lv = lvl->lv;
+		if (!_lv_mark_if_partial(lv))
+			return_0;
+	}
+	return 1;
+}
+
 int vg_validate(struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
@@ -1295,8 +1442,13 @@
 		return_0;
 
 	if (vg->status & PARTIAL_VG) {
-		log_error("Cannot change metadata for partial volume group %s",
-			  vg->name);
+		log_error("Cannot update partial volume group %s.", vg->name);
+		return 0;
+	}
+
+	if (vg_missing_pv_count(vg) && !vg->cmd->handles_missing_pvs) {
+		log_error("Cannot update volume group %s while physical "
+			  "volumes are missing.", vg->name);
 		return 0;
 	}
 
@@ -1495,9 +1647,20 @@
 	return 1;
 }
 
+int vg_missing_pv_count(const vg_t *vg)
+{
+	int ret = 0;
+	struct pv_list *pvl;
+	list_iterate_items(pvl, &vg->pvs) {
+		if (pvl->pv->status & MISSING_PV)
+			++ ret;
+	}
+	return ret;
+}
+
 /* Caller sets consistent to 1 if it's safe for vg_read to correct
  * inconsistent metadata on disk (i.e. the VG write lock is held).
- * This guarantees only consistent metadata is returned unless PARTIAL_VG.
+ * This guarantees only consistent metadata is returned.
  * If consistent is 0, caller must check whether consistent == 1 on return
  * and take appropriate action if it isn't (e.g. abort; get write lock
  * and call vg_read again).
@@ -1536,6 +1699,11 @@
 	}
 
 	if ((correct_vg = lvmcache_get_vg(vgid, precommitted))) {
+		if (vg_missing_pv_count(correct_vg)) {
+			log_verbose("There are %d physical volumes missing.",
+				    vg_missing_pv_count(correct_vg));
+			_vg_mark_partial_lvs(correct_vg);
+		}
 		*consistent = 1;
 		return correct_vg;
 	}
@@ -1631,7 +1799,8 @@
 			}
 		}
 
-		if (list_size(&correct_vg->pvs) != list_size(pvids)) {
+		if (list_size(&correct_vg->pvs) != list_size(pvids)
+		    + vg_missing_pv_count(correct_vg)) {
 			log_debug("Cached VG %s had incorrect PV list",
 				  vgname);
 
@@ -1640,6 +1809,8 @@
 			else
 				correct_vg = NULL;
 		} else list_iterate_items(pvl, &correct_vg->pvs) {
+			if (pvl->pv->status & MISSING_PV)
+				continue;
 			if (!str_list_match_item(pvids, pvl->pv->dev->pvid)) {
 				log_debug("Cached VG %s had incorrect PV list",
 					  vgname);
@@ -1722,15 +1893,6 @@
 		if (!*consistent)
 			return correct_vg;
 
-		/* Don't touch partial volume group metadata */
-		/* Should be fixed manually with vgcfgbackup/restore etc. */
-		if ((correct_vg->status & PARTIAL_VG)) {
-			log_error("Inconsistent metadata copies found for "
-				  "partial volume group %s", vgname);
-			*consistent = 0;
-			return correct_vg;
-		}
-
 		/* Don't touch if vgids didn't match */
 		if (inconsistent_vgid) {
 			log_error("Inconsistent metadata UUIDs found for "
@@ -1769,6 +1931,12 @@
 		}
 	}
 
+	if (vg_missing_pv_count(correct_vg)) {
+		log_verbose("There are %d physical volumes missing.",
+			    vg_missing_pv_count(correct_vg));
+		_vg_mark_partial_lvs(correct_vg);
+	}
+
 	if ((correct_vg->status & PVMOVE) && !pvmove_mode()) {
 		log_error("WARNING: Interrupted pvmove detected in "
 			  "volume group %s", correct_vg->name);
@@ -1828,11 +1996,10 @@
 		if ((vg = _vg_read(cmd, NULL, vgid,
 				   &consistent, precommitted)) &&
 		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
+
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vg->name);
-				if (!partial_mode())
-					return NULL;
 			}
 			return vg;
 		}
@@ -1860,6 +2027,7 @@
 		if ((vg = _vg_read(cmd, vgname, vgid, &consistent,
 				   precommitted)) &&
 		    !strncmp((char *)vg->id.uuid, vgid, ID_LEN)) {
+
 			if (!consistent) {
 				log_error("Volume group %s metadata is "
 					  "inconsistent", vgname);
@@ -1993,7 +2161,6 @@
 	struct list *vgids;
 	struct volume_group *vg;
 	int consistent = 0;
-	int old_partial;
 	int old_pvmove;
 
 	lvmcache_label_scan(cmd, 0);
@@ -2015,9 +2182,7 @@
 
 	/* Read every VG to ensure cache consistency */
 	/* Orphan VG is last on list */
-	old_partial = partial_mode();
 	old_pvmove = pvmove_mode();
-	init_partial(1);
 	init_pvmove(1);
 	list_iterate_items(strl, vgids) {
 		vgid = strl->str;
@@ -2042,7 +2207,6 @@
 				list_add(results, pvh);
 	}
 	init_pvmove(old_pvmove);
-	init_partial(old_partial);
 
 	if (pvslist)
 		*pvslist = results;
--- LVM2/lib/metadata/metadata.h	2008/09/19 04:28:58	1.181
+++ LVM2/lib/metadata/metadata.h	2008/09/19 06:41:59	1.182
@@ -61,6 +61,14 @@
 //#define MIRROR_NOTSYNCED	0x00080000U	/* LV */
 #define ACTIVATE_EXCL		0x00100000U	/* LV - internal use only */
 #define PRECOMMITTED		0x00200000U	/* VG - internal use only */
+//#define CONVERTING		0x00400000U	/* LV */
+
+//#define MISSING_PV		0x00800000U	/* PV */
+//#define PARTIAL_LV		0x01000000U	/* LV - derived flag, not
+//						   written out in metadata*/
+
+#define POSTORDER_FLAG		0x02000000U /* Not a real flag, reserved for
+					       temporary use inside vg_read. */
 
 //#define LVM_READ              	0x00000100U	/* LV VG */
 //#define LVM_WRITE             	0x00000200U	/* LV VG */
--- LVM2/lib/report/report.c	2008/06/25 16:52:27	1.87
+++ LVM2/lib/report/report.c	2008/09/19 06:41:59	1.88
@@ -439,7 +439,7 @@
 	else
 		repstr[2] = '-';
 
-	if (vg->status & PARTIAL_VG)
+	if (vg_missing_pv_count(vg))
 		repstr[3] = 'p';
 	else
 		repstr[3] = '-';
--- LVM2/man/lvm.conf.5	2008/04/10 18:50:02	1.22
+++ LVM2/man/lvm.conf.5	2008/09/19 06:41:59	1.23
@@ -300,12 +300,16 @@
 .TP
 \fBactivation\fP \(em Settings affecting device-mapper activation
 .IP
-\fBmissing_stripe_filler\fP \(em When activating an incomplete
-logical volume in partial mode, this missing data is replaced
-with this device.  It could perhaps be a block device that always
-returns an error when it is accessed, or one that always
-returns zeros.  See \fBlvcreate\fP (8) for how to create
-such devices.
+\fBmissing_stripe_filler\fP \(em When activating an incomplete logical
+volume in partial mode, this option dictates how the missing data is
+replaced.  A value of "error" will cause activation to create error
+mappings for the missing data, meaning that read access to missing
+portions of the volume will result in I/O errors. You can instead also
+use a device path, and in that case this device will be used in place of
+missing stripes. However, note that using anything other than
+"error" with mirrored or snapshotted volumes is likely to result in data
+corruption.  For instructions on how to create a device that always
+returns zeros, see \fBlvcreate\fP (8).
 .IP
 \fBmirror_region_size\fP \(em Unit size in KB for copy operations
 when mirroring.
--- LVM2/man/vgreduce.8	2003/01/17 21:04:26	1.3
+++ LVM2/man/vgreduce.8	2008/09/19 06:41:59	1.4
@@ -18,11 +18,13 @@
 Removes all empty physical volumes if none are given on command line.
 .TP
 .I \-\-removemissing
-Removes all missing physical volumes from the volume group and makes 
-the volume group consistent again.  
+Removes all missing physical volumes from the volume group, if there are no
+logical volumes allocated on those. This resumes normal operation of the volume
+group (new logical volumes may again be created, changed and so on).
 
-It's a good idea to run this option with --test first to find out what it 
-would remove before running it for real.  
+If this is not possible (there are logical volumes referencing the missing
+physical volumes) and you cannot or do not want to remove them manually, you
+can run this option with --force to have vgreduce remove any partial LVs.
 
 Any logical volumes and dependent snapshots that were partly on the 
 missing disks get removed completely. This includes those parts 
--- LVM2/tools/commands.h	2008/06/24 22:48:53	1.118
+++ LVM2/tools/commands.h	2008/09/19 06:42:00	1.119
@@ -850,13 +850,15 @@
    "\t[-h|--help]\n"
    "\t[--mirrorsonly]\n"
    "\t[--removemissing]\n"
+   "\t[-f|--force]\n"
    "\t[-t|--test]\n"
    "\t[-v|--verbose]\n"
    "\t[--version]" "\n"
    "\tVolumeGroupName\n"
    "\t[PhysicalVolumePath...]\n",
 
-   all_ARG, autobackup_ARG, mirrorsonly_ARG, removemissing_ARG, test_ARG)
+   all_ARG, autobackup_ARG, mirrorsonly_ARG, removemissing_ARG,
+   force_ARG, test_ARG)
 
 xx(vgremove,
    "Remove volume group(s)",
--- LVM2/tools/lvmcmdline.c	2008/08/01 19:51:27	1.69
+++ LVM2/tools/lvmcmdline.c	2008/09/19 06:42:00	1.70
@@ -710,13 +710,13 @@
 	cmd->current_settings.archive = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.archive);
 	cmd->current_settings.backup = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.backup);
 	cmd->current_settings.cache_vgmetadata = cmd->command->flags & CACHE_VGMETADATA ? 1 : 0;
+	cmd->partial_activate = 0;
 
 	if (arg_count(cmd, partial_ARG)) {
-		init_partial(1);
+		cmd->partial_activate = 1;
 		log_print("Partial mode. Incomplete volume groups will "
 			  "be activated read-only.");
-	} else
-		init_partial(0);
+	}
 
 	if (arg_count(cmd, ignorelockingfailure_ARG))
 		init_ignorelockingfailure(1);
@@ -826,6 +826,7 @@
 
 	cmd->fmt = arg_ptr_value(cmd, metadatatype_ARG,
 				 cmd->current_settings.fmt);
+	cmd->handles_missing_pvs = 0;
 }
 
 static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
--- LVM2/tools/lvremove.c	2008/01/30 14:00:02	1.54
+++ LVM2/tools/lvremove.c	2008/09/19 06:42:00	1.55
@@ -31,6 +31,8 @@
 		return EINVALID_CMD_LINE;
 	}
 
+	cmd->handles_missing_pvs = 1;
+
 	return process_each_lv(cmd, argc, argv, LCK_VG_WRITE, NULL,
 			       &lvremove_single);
 }
--- LVM2/tools/pvcreate.c	2008/07/29 21:05:20	1.74
+++ LVM2/tools/pvcreate.c	2008/09/19 06:42:00	1.75
@@ -49,7 +49,6 @@
 	/* FIXME Check partition type is LVM unless --force is given */
 
 	/* Is there a pv here already? */
-	/* FIXME Use partial mode here? */
 	pv = pv_read(cmd, name, NULL, NULL, 0);
 
 	/*
@@ -272,13 +271,11 @@
 	if (arg_count(cmd, restorefile_ARG)) {
 		pp->restorefile = arg_str_value(cmd, restorefile_ARG, "");
 		/* The uuid won't already exist */
-		init_partial(1);
 		if (!(vg = backup_read_vg(cmd, NULL, pp->restorefile))) {
 			log_error("Unable to read volume group from %s",
 				  pp->restorefile);
 			return 0;
 		}
-		init_partial(0);
 		if (!(existing_pv = find_pv_in_vg_by_uuid(vg, pp->idp))) {
 			log_error("Can't find uuid %s in backup file %s",
 				  uuid, pp->restorefile);
--- LVM2/tools/vgcfgbackup.c	2008/08/13 12:44:24	1.25
+++ LVM2/tools/vgcfgbackup.c	2008/09/19 06:42:00	1.26
@@ -96,8 +96,7 @@
 	int ret;
 	char *last_filename = NULL;
 
-	if (partial_mode())
-		init_pvmove(1);
+	init_pvmove(1);
 
 	ret = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, &last_filename,
 			      &vg_backup_single);
--- LVM2/tools/vgreduce.c	2008/09/19 03:45:34	1.82
+++ LVM2/tools/vgreduce.c	2008/09/19 06:42:00	1.83
@@ -16,7 +16,7 @@
 #include "tools.h"
 #include "lv_alloc.h"
 
-static int _remove_pv(struct volume_group *vg, struct pv_list *pvl)
+static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)
 {
 	char uuid[64] __attribute((aligned(8)));
 
@@ -31,8 +31,9 @@
 	log_verbose("Removing PV with UUID %s from VG %s", uuid, vg->name);
 
 	if (pvl->pv->pe_alloc_count) {
-		log_error("LVs still present on PV with UUID %s: Can't remove "
-			  "from VG %s", uuid, vg->name);
+		if (!silent)
+			log_error("LVs still present on PV with UUID %s: "
+				  "Can't remove from VG %s", uuid, vg->name);
 		return 0;
 	}
 
@@ -130,11 +131,39 @@
 	return 1;
 }
 
+static int _consolidate_vg(struct cmd_context *cmd, struct volume_group *vg)
+{
+	struct pv_list *pvl;
+	struct lv_list *lvl;
+	int r = 1;
+
+	list_iterate_items(lvl, &vg->lvs)
+		if (lvl->lv->status & PARTIAL_LV) {
+			log_warn("WARNING: Partial LV %s needs to be repaired "
+				 "or removed. ", lvl->lv->name);
+			r = 0;
+		}
+
+	if (!r) {
+		cmd->handles_missing_pvs = 1;
+		log_warn("WARNING: There are still partial LVs in VG %s.", vg->name);
+		log_warn("To remove them unconditionally use: vgreduce --removemissing --force.");
+		log_warn("Proceeding to remove empty missing PVs.");
+	}
+
+	list_iterate_items(pvl, &vg->pvs) {
+		if (pvl->pv->dev && !(pvl->pv->status & MISSING_PV))
+			continue;
+		if (r && !_remove_pv(vg, pvl, 0))
+			return_0;
+	}
+
+	return r;
+}
+
 static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
 {
-	struct list *pvh, *pvht;
 	struct list *lvh, *lvht;
-	struct pv_list *pvl;
 	struct lv_list *lvl, *lvl2, *lvlt;
 	struct logical_volume *lv;
 	struct physical_volume *pv;
@@ -182,20 +211,8 @@
 		return 0;
 	}
 
-	/* Remove missing PVs */
-	list_iterate_safe(pvh, pvht, &vg->pvs) {
-		pvl = list_item(pvh, struct pv_list);
-		if (pvl->pv->dev)
-			continue;
-		if (!_remove_pv(vg, pvl))
-			return_0;
-	}
-
-	/* VG is now consistent */
-	vg->status &= ~PARTIAL_VG;
-	vg->status |= LVM_WRITE;
-
-	init_partial(0);
+	if (!_consolidate_vg(cmd, vg))
+		return_0;
 
 	/* FIXME Recovery.  For now people must clean up by hand. */
 
@@ -208,14 +225,11 @@
 
 		if (!test_mode()) {
 			/* Suspend lvs_changed */
-			init_partial(1);
 			if (!suspend_lvs(cmd, &lvs_changed)) {
 				stack;
-				init_partial(0);
 				vg_revert(vg);
 				return 0;
 			}
-			init_partial(0);
 		}
 
 		if (!vg_commit(vg)) {
@@ -439,26 +453,26 @@
 	char *vg_name;
 	int ret = 1;
 	int consistent = 1;
+	int fixed = 1;
+	int repairing = arg_count(cmd, removemissing_ARG);
 
-	if (!argc && !arg_count(cmd, removemissing_ARG)) {
+	if (!argc && !repairing) {
 		log_error("Please give volume group name and "
 			  "physical volume paths");
 		return EINVALID_CMD_LINE;
 	}
-
-	if (!argc && arg_count(cmd, removemissing_ARG)) {
+	
+	if (!argc && repairing) {
 		log_error("Please give volume group name");
 		return EINVALID_CMD_LINE;
 	}
 
-	if (arg_count(cmd, mirrorsonly_ARG) &&
-	    !arg_count(cmd, removemissing_ARG)) {
+	if (arg_count(cmd, mirrorsonly_ARG) && !repairing) {
 		log_error("--mirrorsonly requires --removemissing");
 		return EINVALID_CMD_LINE;
 	}
 
-	if (argc == 1 && !arg_count(cmd, all_ARG)
-	    && !arg_count(cmd, removemissing_ARG)) {
+	if (argc == 1 && !arg_count(cmd, all_ARG) && !repairing) {
 		log_error("Please enter physical volume paths or option -a");
 		return EINVALID_CMD_LINE;
 	}
@@ -469,7 +483,7 @@
 		return EINVALID_CMD_LINE;
 	}
 
-	if (argc > 1 && arg_count(cmd, removemissing_ARG)) {
+	if (argc > 1 && repairing) {
 		log_error("Please only specify the volume group");
 		return EINVALID_CMD_LINE;
 	}
@@ -490,8 +504,8 @@
 		return ECMD_FAILED;
 	}
 
-	if ((!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent) &&
-	    !arg_count(cmd, removemissing_ARG)) {
+	if ((!(vg = vg_read(cmd, vg_name, NULL, &consistent)) || !consistent)
+	    && !repairing) {
 		log_error("Volume group \"%s\" doesn't exist", vg_name);
 		unlock_vg(cmd, vg_name);
 		return ECMD_FAILED;
@@ -502,16 +516,15 @@
 		return ECMD_FAILED;
 	}
 
-	if (arg_count(cmd, removemissing_ARG)) {
-		if (vg && consistent) {
+	if (repairing) {
+		if (vg && consistent && !vg_missing_pv_count(vg)) {
 			log_error("Volume group \"%s\" is already consistent",
 				  vg_name);
 			unlock_vg(cmd, vg_name);
 			return ECMD_PROCESSED;
 		}
 
-		init_partial(1);
-		consistent = 0;
+		consistent = !arg_count(cmd, force_ARG);
 		if (!(vg = vg_read(cmd, vg_name, NULL, &consistent))) {
 			log_error("Volume group \"%s\" not found", vg_name);
 			unlock_vg(cmd, vg_name);
@@ -522,16 +535,17 @@
 			return ECMD_FAILED;
 		}
 		if (!archive(vg)) {
-			init_partial(0);
 			unlock_vg(cmd, vg_name);
 			return ECMD_FAILED;
 		}
 
-		if (!_make_vg_consistent(cmd, vg)) {
-			init_partial(0);
-			unlock_vg(cmd, vg_name);
-			return ECMD_FAILED;
-		}
+		if (arg_count(cmd, force_ARG)) {
+			if (!_make_vg_consistent(cmd, vg)) {
+				unlock_vg(cmd, vg_name);
+				return ECMD_FAILED;
+			}
+		} else
+			fixed = _consolidate_vg(cmd, vg);
 
 		if (!vg_write(vg) || !vg_commit(vg)) {
 			log_error("Failed to write out a consistent VG for %s",
@@ -542,7 +556,9 @@
 
 		backup(vg);
 
-		log_print("Wrote out consistent volume group %s", vg_name);
+		if (fixed)
+			log_print("Wrote out consistent volume group %s",
+				  vg_name);
 
 	} else {
 		if (!vg_check_status(vg, EXPORTED_VG | LVM_WRITE | RESIZEABLE_VG)) {


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2007-08-07  9:06 meyering
  0 siblings, 0 replies; 33+ messages in thread
From: meyering @ 2007-08-07  9:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	meyering@sourceware.org	2007-08-07 09:06:05

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c lvm-functions.h refresh_clvmd.c 
	lib/activate   : activate.c activate.h 
	lib/datastruct : btree.c btree.h list.c list.h str_list.c 
	                 str_list.h 
	lib/display    : display.c display.h 
	lib/metadata   : metadata-exported.h metadata.c 
	tools          : toollib.c toollib.h tools.h vgdisplay.c 

Log message:
	Add "const" attributes where possible: first cut.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.678&r2=1.679
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/refresh_clvmd.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/btree.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/btree.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/str_list.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.130&r2=1.131
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgdisplay.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18

--- LVM2/WHATS_NEW	2007/08/06 20:38:41	1.678
+++ LVM2/WHATS_NEW	2007/08/07 09:06:04	1.679
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Add const attributes where possible, first cut.
   Add support for renaming mirrored LVs.
   Factor out core of lvrename() to lv_rename lvm library function.
   Add --log argument to specify log type for mirrors.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/04/27 17:46:16	1.30
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/08/07 09:06:05	1.31
@@ -431,7 +431,7 @@
 }
 
 /* Check if a VG is un use by LVM1 so we don't stomp on it */
-int do_check_lvm1(char *vgname)
+int do_check_lvm1(const char *vgname)
 {
 	int status;
 
--- LVM2/daemons/clvmd/lvm-functions.h	2006/10/05 13:55:50	1.4
+++ LVM2/daemons/clvmd/lvm-functions.h	2007/08/07 09:06:05	1.5
@@ -24,7 +24,7 @@
 		      char *resource);
 extern int post_lock_lv(unsigned char lock_cmd, unsigned char lock_flags,
 			char *resource);
-extern int do_check_lvm1(char *vgname);
+extern int do_check_lvm1(const char *vgname);
 extern int do_refresh_cache(void);
 extern int init_lvm(int using_gulm);
 extern void init_lvhash(void);
--- LVM2/daemons/clvmd/refresh_clvmd.c	2006/12/01 23:10:25	1.2
+++ LVM2/daemons/clvmd/refresh_clvmd.c	2007/08/07 09:06:05	1.3
@@ -79,7 +79,7 @@
 }
 
 /* Send a request and return the status */
-static int _send_request(char *inbuf, int inlen, char **retbuf)
+static int _send_request(const char *inbuf, int inlen, char **retbuf)
 {
 	char outbuf[PIPE_BUF];
 	struct clvm_header *outheader = (struct clvm_header *) outbuf;
--- LVM2/lib/activate/activate.c	2007/08/01 20:29:07	1.125
+++ LVM2/lib/activate/activate.c	2007/08/07 09:06:05	1.126
@@ -642,9 +642,9 @@
 	return _lvs_in_vg_activated(vg, 0);
 }
 
-int lvs_in_vg_opened(struct volume_group *vg)
+int lvs_in_vg_opened(const struct volume_group *vg)
 {
-	struct lv_list *lvl;
+	const struct lv_list *lvl;
 	int count = 0;
 
 	if (!activation())
--- LVM2/lib/activate/activate.h	2007/07/18 15:38:57	1.56
+++ LVM2/lib/activate/activate.h	2007/08/07 09:06:05	1.57
@@ -84,7 +84,7 @@
  */
 int lvs_in_vg_activated(struct volume_group *vg);
 int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg);
-int lvs_in_vg_opened(struct volume_group *vg);
+int lvs_in_vg_opened(const struct volume_group *vg);
 
 
 int monitor_dev_for_events(struct cmd_context *cmd,
--- LVM2/lib/datastruct/btree.c	2006/04/19 15:33:05	1.9
+++ LVM2/lib/datastruct/btree.c	2007/08/07 09:06:05	1.10
@@ -55,7 +55,8 @@
 #endif
 }
 
-static struct node **_lookup(struct node **c, uint32_t key, struct node **p)
+static struct node **_lookup(struct node *const *c, uint32_t key,
+			     struct node **p)
 {
 	*p = NULL;
 	while (*c) {
@@ -70,10 +71,10 @@
 			c = &(*c)->r;
 	}
 
-	return c;
+	return (struct node **)c;
 }
 
-void *btree_lookup(struct btree *t, uint32_t k)
+void *btree_lookup(const struct btree *t, uint32_t k)
 {
 	uint32_t key = _shuffle(k);
 	struct node *p, **c = _lookup(&t->root, key, &p);
@@ -102,7 +103,7 @@
 	return 1;
 }
 
-void *btree_get_data(struct btree_iter *it)
+void *btree_get_data(const struct btree_iter *it)
 {
 	return ((struct node *) it)->data;
 }
@@ -114,7 +115,7 @@
 	return n;
 }
 
-struct btree_iter *btree_first(struct btree *t)
+struct btree_iter *btree_first(const struct btree *t)
 {
 	if (!t->root)
 		return NULL;
@@ -122,7 +123,7 @@
 	return (struct btree_iter *) _left(t->root);
 }
 
-struct btree_iter *btree_next(struct btree_iter *it)
+struct btree_iter *btree_next(const struct btree_iter *it)
 {
 	struct node *n = (struct node *) it;
 	uint32_t k = n->key;
--- LVM2/lib/datastruct/btree.h	2005/10/16 23:03:57	1.4
+++ LVM2/lib/datastruct/btree.h	2007/08/07 09:06:05	1.5
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.  
+ * Copyright (C) 2001-2004, 2007 Sistina Software, Inc. All rights reserved.  
  * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
@@ -20,13 +20,13 @@
 
 struct btree *btree_create(struct dm_pool *mem);
 
-void *btree_lookup(struct btree *t, uint32_t k);
+void *btree_lookup(const struct btree *t, uint32_t k);
 int btree_insert(struct btree *t, uint32_t k, void *data);
 
 struct btree_iter;
-void *btree_get_data(struct btree_iter *it);
+void *btree_get_data(const struct btree_iter *it);
 
-struct btree_iter *btree_first(struct btree *t);
-struct btree_iter *btree_next(struct btree_iter *it);
+struct btree_iter *btree_first(const struct btree *t);
+struct btree_iter *btree_next(const struct btree_iter *it);
 
 #endif
--- LVM2/lib/datastruct/list.c	2006/04/19 18:12:33	1.1
+++ LVM2/lib/datastruct/list.c	2007/08/07 09:06:05	1.2
@@ -68,7 +68,7 @@
 /*
  * Is the list empty?
  */
-int list_empty(struct list *head)
+int list_empty(const struct list *head)
 {
 	return head->n == head;
 }
@@ -76,7 +76,7 @@
 /*
  * Is this the first element of the list?
  */
-int list_start(struct list *head, struct list *elem)
+int list_start(const struct list *head, const struct list *elem)
 {
 	return elem->p == head;
 }
@@ -84,7 +84,7 @@
 /*
  * Is this the last element of the list?
  */
-int list_end(struct list *head, struct list *elem)
+int list_end(const struct list *head, const struct list *elem)
 {
 	return elem->n == head;
 }
@@ -92,7 +92,7 @@
 /*
  * Return first element of the list or NULL if empty
  */
-struct list *list_first(struct list *head)
+struct list *list_first(const struct list *head)
 {
 	return (list_empty(head) ? NULL : head->n);
 }
@@ -100,7 +100,7 @@
 /*
  * Return last element of the list or NULL if empty
  */
-struct list *list_last(struct list *head)
+struct list *list_last(const struct list *head)
 {
 	return (list_empty(head) ? NULL : head->p);
 }
@@ -108,7 +108,7 @@
 /*
  * Return the previous element of the list, or NULL if we've reached the start.
  */
-struct list *list_prev(struct list *head, struct list *elem)
+struct list *list_prev(const struct list *head, const struct list *elem)
 {
 	return (list_start(head, elem) ? NULL : elem->p);
 }
@@ -116,7 +116,7 @@
 /*
  * Return the next element of the list, or NULL if we've reached the end.
  */
-struct list *list_next(struct list *head, struct list *elem)
+struct list *list_next(const struct list *head, const struct list *elem)
 {
 	return (list_end(head, elem) ? NULL : elem->n);
 }
--- LVM2/lib/datastruct/list.h	2006/04/19 15:33:05	1.23
+++ LVM2/lib/datastruct/list.h	2007/08/07 09:06:05	1.24
@@ -57,37 +57,37 @@
 /*
  * Is the list empty?
  */
-int list_empty(struct list *head);
+int list_empty(const struct list *head);
 
 /*
  * Is this the first element of the list?
  */
-int list_start(struct list *head, struct list *elem);
+int list_start(const struct list *head, const struct list *elem);
 
 /*
  * Is this the last element of the list?
  */
-int list_end(struct list *head, struct list *elem);
+int list_end(const struct list *head, const struct list *elem);
 
 /*
  * Return first element of the list or NULL if empty
  */
-struct list *list_first(struct list *head);
+struct list *list_first(const struct list *head);
 
 /*
  * Return last element of the list or NULL if empty
  */
-struct list *list_last(struct list *head);
+struct list *list_last(const struct list *head);
 
 /*
  * Return the previous element of the list, or NULL if we've reached the start.
  */
-struct list *list_prev(struct list *head, struct list *elem);
+struct list *list_prev(const struct list *head, const struct list *elem);
 
 /*
  * Return the next element of the list, or NULL if we've reached the end.
  */
-struct list *list_next(struct list *head, struct list *elem);
+struct list *list_next(const struct list *head, const struct list *elem);
 
 /*
  * Given the address v of an instance of 'struct list' called 'head' 
--- LVM2/lib/datastruct/str_list.c	2005/10/16 23:03:57	1.6
+++ LVM2/lib/datastruct/str_list.c	2007/08/07 09:06:05	1.7
@@ -66,7 +66,8 @@
 	return 1;
 }
 
-int str_list_dup(struct dm_pool *mem, struct list *sllnew, struct list *sllold)
+int str_list_dup(struct dm_pool *mem, struct list *sllnew,
+		 const struct list *sllold)
 {
 	struct str_list *sl;
 
@@ -85,7 +86,7 @@
 /*
  * Is item on list?
  */
-int str_list_match_item(struct list *sll, const char *str)
+int str_list_match_item(const struct list *sll, const char *str)
 {
 	struct str_list *sl;
 
@@ -99,7 +100,7 @@
 /*
  * Is at least one item on both lists?
  */
-int str_list_match_list(struct list *sll, struct list *sll2)
+int str_list_match_list(const struct list *sll, const struct list *sll2)
 {
 	struct str_list *sl;
 
@@ -113,7 +114,7 @@
 /*
  * Do both lists contain the same set of items?
  */
-int str_list_lists_equal(struct list *sll, struct list *sll2)
+int str_list_lists_equal(const struct list *sll, const struct list *sll2)
 {
 	struct str_list *sl;
 
--- LVM2/lib/datastruct/str_list.h	2005/10/16 23:03:57	1.6
+++ LVM2/lib/datastruct/str_list.h	2007/08/07 09:06:05	1.7
@@ -19,9 +19,10 @@
 struct list *str_list_create(struct dm_pool *mem);
 int str_list_add(struct dm_pool *mem, struct list *sll, const char *str);
 int str_list_del(struct list *sll, const char *str);
-int str_list_match_item(struct list *sll, const char *str);
-int str_list_match_list(struct list *sll, struct list *sll2);
-int str_list_lists_equal(struct list *sll, struct list *sll2);
-int str_list_dup(struct dm_pool *mem, struct list *sllnew, struct list *sllold);
+int str_list_match_item(const struct list *sll, const char *str);
+int str_list_match_list(const struct list *sll, const struct list *sll2);
+int str_list_lists_equal(const struct list *sll, const struct list *sll2);
+int str_list_dup(struct dm_pool *mem, struct list *sllnew,
+		 const struct list *sllold);
 
 #endif
--- LVM2/lib/display/display.c	2007/05/31 20:26:11	1.75
+++ LVM2/lib/display/display.c	2007/08/07 09:06:05	1.76
@@ -147,7 +147,8 @@
 }
 
 /* Size supplied in sectors */
-static const char *_display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
+static const char *_display_size(const struct cmd_context *cmd,
+				 uint64_t size, size_len_t sl)
 {
 	int s;
 	int suffix = 1, precision;
@@ -217,22 +218,22 @@
 	return size_buf;
 }
 
-const char *display_size_long(struct cmd_context *cmd, uint64_t size)
+const char *display_size_long(const struct cmd_context *cmd, uint64_t size)
 {
 	return _display_size(cmd, size, SIZE_LONG);
 }
 
-const char *display_size_units(struct cmd_context *cmd, uint64_t size)
+const char *display_size_units(const struct cmd_context *cmd, uint64_t size)
 {
 	return _display_size(cmd, size, SIZE_UNIT);
 }
 
-const char *display_size(struct cmd_context *cmd, uint64_t size)
+const char *display_size(const struct cmd_context *cmd, uint64_t size)
 {
 	return _display_size(cmd, size, SIZE_SHORT);
 }
 
-void pvdisplay_colons(struct physical_volume *pv)
+void pvdisplay_colons(const struct physical_volume *pv)
 {
 	char uuid[64] __attribute((aligned(8)));
 
@@ -258,9 +259,9 @@
 	return;
 }
 
-void pvdisplay_segments(struct physical_volume *pv)
+void pvdisplay_segments(const struct physical_volume *pv)
 {
-	struct pv_segment *pvseg;
+	const struct pv_segment *pvseg;
 
 	if (pv->pe_size)
 		log_print("--- Physical Segments ---");
@@ -286,7 +287,8 @@
 }
 
 /* FIXME Include label fields */
-void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
+void pvdisplay_full(const struct cmd_context *cmd,
+		    const struct physical_volume *pv,
 		    void *handle __attribute((unused)))
 {
 	char uuid[64] __attribute((aligned(8)));
@@ -346,9 +348,9 @@
 	return;
 }
 
-int pvdisplay_short(struct cmd_context *cmd __attribute((unused)),
-		    struct volume_group *vg __attribute((unused)),
-		    struct physical_volume *pv,
+int pvdisplay_short(const struct cmd_context *cmd __attribute((unused)),
+		    const struct volume_group *vg __attribute((unused)),
+		    const struct physical_volume *pv,
 		    void *handle __attribute((unused)))
 {
 	char uuid[64] __attribute((aligned(8)));
@@ -373,7 +375,7 @@
 	return 0;
 }
 
-void lvdisplay_colons(struct logical_volume *lv)
+void lvdisplay_colons(const struct logical_volume *lv)
 {
 	int inkernel;
 	struct lvinfo info;
@@ -393,7 +395,8 @@
 	return;
 }
 
-int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
+int lvdisplay_full(struct cmd_context *cmd,
+		   const struct logical_volume *lv,
 		   void *handle __attribute((unused)))
 {
 	struct lvinfo info;
@@ -535,9 +538,9 @@
 	}
 }
 
-int lvdisplay_segments(struct logical_volume *lv)
+int lvdisplay_segments(const struct logical_volume *lv)
 {
-	struct lv_segment *seg;
+	const struct lv_segment *seg;
 
 	log_print("--- Segments ---");
 
@@ -555,12 +558,12 @@
 	return 1;
 }
 
-void vgdisplay_extents(struct volume_group *vg __attribute((unused)))
+void vgdisplay_extents(const struct volume_group *vg __attribute((unused)))
 {
 	return;
 }
 
-void vgdisplay_full(struct volume_group *vg)
+void vgdisplay_full(const struct volume_group *vg)
 {
 	uint32_t access;
 	uint32_t active_pvs;
@@ -639,7 +642,7 @@
 	return;
 }
 
-void vgdisplay_colons(struct volume_group *vg)
+void vgdisplay_colons(const struct volume_group *vg)
 {
 	uint32_t active_pvs;
 	const char *access;
@@ -691,7 +694,7 @@
 	return;
 }
 
-void vgdisplay_short(struct volume_group *vg)
+void vgdisplay_short(const struct volume_group *vg)
 {
 	log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
 /********* FIXME if "open" print "/used" else print "/idle"???  ******/
@@ -705,18 +708,18 @@
 	return;
 }
 
-void display_formats(struct cmd_context *cmd)
+void display_formats(const struct cmd_context *cmd)
 {
-	struct format_type *fmt;
+	const struct format_type *fmt;
 
 	list_iterate_items(fmt, &cmd->formats) {
 		log_print("%s", fmt->name);
 	}
 }
 
-void display_segtypes(struct cmd_context *cmd)
+void display_segtypes(const struct cmd_context *cmd)
 {
-	struct segment_type *segtype;
+	const struct segment_type *segtype;
 
 	list_iterate_items(segtype, &cmd->segtypes) {
 		log_print("%s", segtype->name);
--- LVM2/lib/display/display.h	2007/07/18 15:38:57	1.18
+++ LVM2/lib/display/display.h	2007/08/07 09:06:05	1.19
@@ -23,32 +23,34 @@
 uint64_t units_to_bytes(const char *units, char *unit_type);
 
 /* Specify size in KB */
-const char *display_size(struct cmd_context *cmd, uint64_t size);
-const char *display_size_long(struct cmd_context *cmd, uint64_t size);
-const char *display_size_units(struct cmd_context *cmd, uint64_t size);
+const char *display_size(const struct cmd_context *cmd, uint64_t size);
+const char *display_size_long(const struct cmd_context *cmd, uint64_t size);
+const char *display_size_units(const struct cmd_context *cmd, uint64_t size);
 
 char *display_uuid(char *uuidstr);
 void display_stripe(const struct lv_segment *seg, uint32_t s, const char *pre);
 
-void pvdisplay_colons(struct physical_volume *pv);
-void pvdisplay_segments(struct physical_volume *pv);
-void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
+void pvdisplay_colons(const struct physical_volume *pv);
+void pvdisplay_segments(const struct physical_volume *pv);
+void pvdisplay_full(const struct cmd_context *cmd,
+		    const struct physical_volume *pv,
 		    void *handle);
-int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
-		    struct physical_volume *pv, void *handle);
-
-void lvdisplay_colons(struct logical_volume *lv);
-int lvdisplay_segments(struct logical_volume *lv);
-int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
+int pvdisplay_short(const struct cmd_context *cmd,
+		    const struct volume_group *vg,
+		    const struct physical_volume *pv, void *handle);
+
+void lvdisplay_colons(const struct logical_volume *lv);
+int lvdisplay_segments(const struct logical_volume *lv);
+int lvdisplay_full(struct cmd_context *cmd, const struct logical_volume *lv,
 		   void *handle);
 
-void vgdisplay_extents(struct volume_group *vg);
-void vgdisplay_full(struct volume_group *vg);
-void vgdisplay_colons(struct volume_group *vg);
-void vgdisplay_short(struct volume_group *vg);
+void vgdisplay_extents(const struct volume_group *vg);
+void vgdisplay_full(const struct volume_group *vg);
+void vgdisplay_colons(const struct volume_group *vg);
+void vgdisplay_short(const struct volume_group *vg);
 
-void display_formats(struct cmd_context *cmd);
-void display_segtypes(struct cmd_context *cmd);
+void display_formats(const struct cmd_context *cmd);
+void display_segtypes(const struct cmd_context *cmd);
 
 /*
  * Allocation policy display conversion routines.
--- LVM2/lib/metadata/metadata-exported.h	2007/08/06 14:57:48	1.6
+++ LVM2/lib/metadata/metadata-exported.h	2007/08/07 09:06:05	1.7
@@ -397,7 +397,7 @@
 
 int vg_remove_snapshot(struct logical_volume *cow);
 
-int vg_check_status(struct volume_group *vg, uint32_t status);
+int vg_check_status(const struct volume_group *vg, uint32_t status);
 
 /*
 * Mirroring functions
--- LVM2/lib/metadata/metadata.c	2007/08/06 21:11:27	1.130
+++ LVM2/lib/metadata/metadata.c	2007/08/07 09:06:05	1.131
@@ -1763,7 +1763,7 @@
  * 0 - fail
  * 1 - success
  */
-int vg_check_status(struct volume_group *vg, uint32_t status)
+int vg_check_status(const struct volume_group *vg, uint32_t status)
 {
 	if ((status & CLUSTERED) &&
 	    (vg->status & CLUSTERED) && !locking_is_clustered() &&
--- LVM2/tools/toollib.c	2007/07/10 17:51:26	1.102
+++ LVM2/tools/toollib.c	2007/08/07 09:06:05	1.103
@@ -25,7 +25,7 @@
 #define MIRROR_DISK_VERSION 2
 
 /* Command line args */
-unsigned arg_count(struct cmd_context *cmd, int a)
+unsigned arg_count(const struct cmd_context *cmd, int a)
 {
 	return cmd->args[a].count;
 }
@@ -142,12 +142,12 @@
 /*
  * Metadata iteration functions
  */
-int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
-			  struct list *arg_lvnames, struct list *tags,
+int process_each_lv_in_vg(struct cmd_context *cmd,
+			  const struct volume_group *vg,
+			  const struct list *arg_lvnames,
+			  const struct list *tags,
 			  void *handle,
-			  int (*process_single) (struct cmd_context * cmd,
-						 struct logical_volume * lv,
-						 void *handle))
+			  process_single_lv_fn_t process_single)
 {
 	int ret_max = 0;
 	int ret = 0;
@@ -603,11 +603,8 @@
 }
 
 int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
-			  struct list *tags, void *handle,
-			  int (*process_single) (struct cmd_context * cmd,
-						 struct volume_group * vg,
-						 struct physical_volume * pv,
-						 void *handle))
+			  const struct list *tags, void *handle,
+			  process_single_pv_fn_t process_single)
 {
 	int ret_max = 0;
 	int ret = 0;
--- LVM2/tools/toollib.h	2007/07/18 15:38:58	1.47
+++ LVM2/tools/toollib.h	2007/08/07 09:06:05	1.48
@@ -60,19 +60,25 @@
 						      struct lv_segment * seg,
 						      void *handle));
 
+typedef int (*process_single_pv_fn_t) (struct cmd_context *cmd,
+				  struct volume_group *vg,
+				  struct physical_volume *pv,
+				  void *handle);
+
 int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
-			  struct list *tags, void *handle,
-			  int (*process_single) (struct cmd_context * cmd,
-						 struct volume_group * vg,
-						 struct physical_volume * pv,
-						 void *handle));
+			  const struct list *tags, void *handle,
+			  process_single_pv_fn_t process_single);
 
-int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
-			  struct list *arg_lvnames, struct list *tags,
+typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
+				  struct logical_volume *lv,
+				  void *handle);
+
+int process_each_lv_in_vg(struct cmd_context *cmd,
+			  const struct volume_group *vg,
+			  const struct list *arg_lvnames,
+			  const struct list *tags,
 			  void *handle,
-			  int (*process_single) (struct cmd_context * cmd,
-						 struct logical_volume * lv,
-						 void *handle));
+			  process_single_lv_fn_t process_single);
 
 char *default_vgname(struct cmd_context *cmd);
 const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
--- LVM2/tools/tools.h	2007/07/18 15:38:58	1.53
+++ LVM2/tools/tools.h	2007/08/07 09:06:05	1.54
@@ -147,7 +147,7 @@
 char yes_no_prompt(const char *prompt, ...);
 
 /* we use the enums to access the switches */
-unsigned int arg_count(struct cmd_context *cmd, int a);
+unsigned int arg_count(const struct cmd_context *cmd, int a);
 const char *arg_value(struct cmd_context *cmd, int a);
 const char *arg_str_value(struct cmd_context *cmd, int a, const char *def);
 int32_t arg_int_value(struct cmd_context *cmd, int a, const int32_t def); 
--- LVM2/tools/vgdisplay.c	2007/06/19 04:36:12	1.17
+++ LVM2/tools/vgdisplay.c	2007/08/07 09:06:05	1.18
@@ -46,10 +46,11 @@
 		vgdisplay_extents(vg);
 
 		process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL,
-				      &lvdisplay_full);
+				      (process_single_lv_fn_t)lvdisplay_full);
 
 		log_print("--- Physical volumes ---");
-		process_each_pv_in_vg(cmd, vg, NULL, NULL, &pvdisplay_short);
+		process_each_pv_in_vg(cmd, vg, NULL, NULL,
+				      (process_single_pv_fn_t)pvdisplay_short);
 	}
 
 	check_current_backup(vg);
@@ -98,7 +99,7 @@
 **********/
 
 	process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, NULL,
-			&vgdisplay_single);
+			vgdisplay_single);
 
 /******** FIXME Need to count number processed 
 	  Add this to process_each_vg if arg_count(cmd,activevolumegroups_ARG) ? 


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2007-01-25 14:37 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2007-01-25 14:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-25 14:37:48

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c 
	lib/config     : config.c 
	lib/device     : dev-io.c 
	lib/filters    : filter-persistent.c filter-sysfs.c filter.c 
	lib/format_text: archive.c format-text.c 
	lib/locking    : file_locking.c 
	lib/log        : log.c 
	lib/misc       : lvm-file.c 
	tools          : lvmcmdline.c reporter.c 

Log message:
	Add some missing close() and fclose() return code checks.
	Fix exit statuses of reporting tools (2.02.19).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.557&r2=1.558
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-sysfs.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18

--- LVM2/WHATS_NEW	2007/01/24 23:44:43	1.557
+++ LVM2/WHATS_NEW	2007/01/25 14:37:46	1.558
@@ -1,5 +1,7 @@
 Version 2.02.20 -
 ===================================
+  Add some missing close() and fclose() return code checks.
+  Fix exit statuses of reporting tools (2.02.19).
   Add init script for dmeventd monitoring.
   lvm.static no longer interacts with dmeventd unless explicitly asked to.
   Add field definitions to report help text.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/01/23 15:58:05	1.27
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/01/25 14:37:47	1.28
@@ -473,7 +473,8 @@
 		sync_unlock(vg, LCK_EXCL);
 
 	}
-	fclose(vgs);
+	if (fclose(vgs))
+		DEBUGLOG("vgs fclose failed: %s\n", strerror(errno));
 }
 
 /*
@@ -523,7 +524,8 @@
 			}
 		}
 	}
-	fclose(lvs);
+	if (fclose(lvs))
+		DEBUGLOG("lvs fclose failed: %s\n", strerror(errno));
 	return NULL;
 }
 
--- LVM2/lib/commands/toolcontext.c	2007/01/23 16:03:54	1.45
+++ LVM2/lib/commands/toolcontext.c	2007/01/25 14:37:47	1.46
@@ -59,8 +59,6 @@
 #  include <malloc.h>
 #endif
 
-static FILE *_log;
-
 static int _get_env_vars(struct cmd_context *cmd)
 {
 	const char *e;
@@ -1114,8 +1112,4 @@
 	activation_exit();
 	fin_log();
 	fin_syslog();
-
-	if (_log)
-		fclose(_log);
-
 }
--- LVM2/lib/config/config.c	2007/01/17 16:22:59	1.52
+++ LVM2/lib/config/config.c	2007/01/25 14:37:47	1.53
@@ -435,13 +435,13 @@
 	log_verbose("Dumping configuration to %s", file);
 	if (!argc) {
 		if (!_write_config(cft->root, 0, fp, 0)) {
-			log_error("Failure while writing configuration");
+			log_error("Failure while writing to %s", file);
 			r = 0;
 		}
 	} else while (argc--) {
 		if ((cn = find_config_node(cft->root, *argv))) {
 			if (!_write_config(cn, 1, fp, 0)) {
-				log_error("Failure while writing configuration");
+				log_error("Failure while writing to %s", file);
 				r = 0;
 			}
 		} else {
@@ -451,8 +451,10 @@
 		argv++;
 	}
 
-	if (fp != stdout)
-		fclose(fp);
+	if ((fp != stdout) && fclose(fp)) {
+		log_sys_error("fclose", file);
+		r = 0;
+	}
 
 	return r;
 }
--- LVM2/lib/device/dev-io.c	2006/11/30 23:11:40	1.55
+++ LVM2/lib/device/dev-io.c	2007/01/25 14:37:47	1.56
@@ -292,11 +292,14 @@
 
 	if (ioctl(fd, BLKSSZGET, &s) < 0) {
 		log_sys_error("ioctl BLKSSZGET", name);
-		close(fd);
+		if (close(fd))
+			log_sys_error("close", name);
 		return 0;
 	}
 
-	close(fd);
+	if (close(fd))
+		log_sys_error("close", name);
+
 	*size = (uint32_t) s;
 
 	log_very_verbose("%s: sector size is %" PRIu32 " bytes", name, *size);
--- LVM2/lib/filters/filter-persistent.c	2006/11/04 03:34:09	1.28
+++ LVM2/lib/filters/filter-persistent.c	2007/01/25 14:37:47	1.29
@@ -239,7 +239,10 @@
 	/* _write_array(pf, fp, "invalid_devices", PF_BAD_DEVICE); */
 
 	fprintf(fp, "}\n");
-	fclose(fp);
+	if (fclose(fp)) {
+		log_sys_error("fclose", tmp_file);
+		goto out;
+	}
 
 	if (rename(tmp_file, pf->file))
 		log_error("%s: rename to %s failed: %s", tmp_file, pf->file,
--- LVM2/lib/filters/filter-sysfs.c	2006/08/21 12:54:52	1.13
+++ LVM2/lib/filters/filter-sysfs.c	2007/01/25 14:37:47	1.14
@@ -54,7 +54,9 @@
 		}
 	}
 
-	fclose(fp);
+	if (fclose(fp))
+		log_sys_error("fclose", proc_mounts);
+
 	return r;
 }
 
@@ -156,7 +158,9 @@
 	}
 
 	r = _parse_dev(file, fp, result);
-	fclose(fp);
+
+	if (fclose(fp))
+		log_sys_error("fclose", file);
 
 	return r;
 }
--- LVM2/lib/filters/filter.c	2006/08/21 12:54:52	1.36
+++ LVM2/lib/filters/filter.c	2007/01/25 14:37:47	1.37
@@ -204,7 +204,8 @@
 			if (cv->type != CFG_STRING) {
 				log_error("Expecting string in devices/types "
 					  "in config file");
-				fclose(pd);
+				if (fclose(pd))
+					log_sys_error("fclose", proc_devices);
 				return 0;
 			}
 			dev_len = strlen(cv->v.str);
@@ -214,14 +215,16 @@
 				log_error("Max partition count missing for %s "
 					  "in devices/types in config file",
 					  name);
-				fclose(pd);
+				if (fclose(pd))
+					log_sys_error("fclose", proc_devices);
 				return 0;
 			}
 			if (!cv->v.i) {
 				log_error("Zero partition count invalid for "
 					  "%s in devices/types in config file",
 					  name);
-				fclose(pd);
+				if (fclose(pd))
+					log_sys_error("fclose", proc_devices);
 				return 0;
 			}
 			if (dev_len <= strlen(line + i) &&
@@ -232,7 +235,10 @@
 			}
 		}
 	}
-	fclose(pd);
+
+	if (fclose(pd))
+		log_sys_error("fclose", proc_devices);
+
 	return 1;
 }
 
--- LVM2/lib/format_text/archive.c	2006/08/21 12:54:52	1.24
+++ LVM2/lib/format_text/archive.c	2007/01/25 14:37:48	1.25
@@ -249,17 +249,23 @@
 
 	if (!(fp = fdopen(fd, "w"))) {
 		log_err("Couldn't create FILE object for archive.");
-		close(fd);
+		if (close(fd))
+			log_sys_error("close", temp_file);
 		return 0;
 	}
 
 	if (!text_vg_export_file(vg, desc, fp)) {
 		stack;
-		fclose(fp);
+		if (fclose(fp))
+			log_sys_error("fclose", temp_file);
 		return 0;
 	}
 
-	fclose(fp);
+	if (fclose(fp)) {
+		log_sys_error("fclose", temp_file);
+		/* Leave file behind as evidence of failure */
+		return 0;
+	}
 
 	/*
 	 * Now we want to rename this file to <vg>_index.vg.
--- LVM2/lib/format_text/format-text.c	2007/01/09 21:12:41	1.71
+++ LVM2/lib/format_text/format-text.c	2007/01/25 14:37:48	1.72
@@ -710,7 +710,8 @@
 
 	if (!(fp = fdopen(fd, "w"))) {
 		log_sys_error("fdopen", temp_file);
-		close(fd);
+		if (close(fd))
+			log_sys_error("fclose", temp_file);
 		return 0;
 	}
 
@@ -718,13 +719,15 @@
 
 	if (!text_vg_export_file(vg, tc->desc, fp)) {
 		log_error("Failed to write metadata to %s.", temp_file);
-		fclose(fp);
+		if (fclose(fp))
+			log_sys_error("fclose", temp_file);
 		return 0;
 	}
 
 	if (fsync(fd) && (errno != EROFS) && (errno != EINVAL)) {
 		log_sys_error("fsync", tc->path_edit);
-		fclose(fp);
+		if (fclose(fp))
+			log_sys_error("fclose", tc->path_edit);
 		return 0;
 	}
 
--- LVM2/lib/locking/file_locking.c	2006/08/21 12:54:52	1.25
+++ LVM2/lib/locking/file_locking.c	2007/01/25 14:37:48	1.26
@@ -163,8 +163,8 @@
 	log_very_verbose("Locking %s %c%c", ll->res, state,
 			 flags & LCK_NONBLOCK ? ' ' : 'B');
 	do {
-		if (ll->lf > -1)
-			close(ll->lf);
+		if ((ll->lf > -1) && close(ll->lf))
+			log_sys_error("close", file);
 
 		if ((ll->lf = open(file, O_CREAT | O_APPEND | O_RDWR, 0777))
 		    < 0) {
--- LVM2/lib/log/log.c	2007/01/19 22:21:45	1.36
+++ LVM2/lib/log/log.c	2007/01/25 14:37:48	1.37
@@ -120,7 +120,8 @@
 	}
 
 	if (_log_to_file) {
-		fclose(_log_file);
+		if (fclose(_log_file))
+			fprintf(stderr, "fclose() on log file failed: %s", strerror(errno));
 		_log_to_file = 0;
 	}
 }
--- LVM2/lib/misc/lvm-file.c	2006/11/04 03:34:10	1.17
+++ LVM2/lib/misc/lvm-file.c	2007/01/25 14:37:48	1.18
@@ -66,7 +66,8 @@
 		if (!fcntl(*fd, F_SETLK, &lock))
 			return 1;
 
-		close(*fd);
+		if (close(*fd))
+			log_sys_error("close", buffer);
 	}
 
 	return 0;
@@ -239,7 +240,8 @@
 	if (fsync(fd) && (errno != EROFS) && (errno != EINVAL))
 		log_sys_error("fsync", dir);
 
-	close(fd);
+	if (close(fd))
+		log_sys_error("close", dir);
 
       out:
 	dm_free(dir);
--- LVM2/tools/lvmcmdline.c	2007/01/23 15:58:06	1.39
+++ LVM2/tools/lvmcmdline.c	2007/01/25 14:37:48	1.40
@@ -1065,8 +1065,9 @@
 	char buffer[CMD_LEN];
 	int ret = 0;
 	int magic_number = 0;
+	char *script_file = argv[0];
 
-	if ((script = fopen(argv[0], "r")) == NULL)
+	if ((script = fopen(script_file, "r")) == NULL)
 		return ENO_SUCH_CMD;
 
 	while (fgets(buffer, sizeof(buffer), script) != NULL) {
@@ -1099,7 +1100,9 @@
 		lvm_run_command(cmd, argc, argv);
 	}
 
-	fclose(script);
+	if (fclose(script))
+		log_sys_error("fclose", script_file);
+
 	return ret;
 }
 
--- LVM2/tools/reporter.c	2007/01/16 18:06:12	1.17
+++ LVM2/tools/reporter.c	2007/01/25 14:37:48	1.18
@@ -25,7 +25,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (!report_object(handle, vg, NULL, NULL, NULL, NULL));
+	if (!report_object(handle, vg, NULL, NULL, NULL, NULL))
 		return ECMD_FAILED;
 
 	check_current_backup(vg);
@@ -39,7 +39,7 @@
 	if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
 		return ECMD_PROCESSED;
 
-	if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL));
+	if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL))
 		return ECMD_FAILED;
 
 	return ECMD_PROCESSED;
@@ -48,7 +48,7 @@
 static int _segs_single(struct cmd_context *cmd __attribute((unused)),
 			struct lv_segment *seg, void *handle)
 {
-	if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL));
+	if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL))
 		return ECMD_FAILED;
 
 	return ECMD_PROCESSED;
@@ -78,7 +78,7 @@
 		goto out;
 	}
 
-	if (!report_object(handle, vg, NULL, pv, NULL, pvseg));
+	if (!report_object(handle, vg, NULL, pv, NULL, pvseg))
 		ret = ECMD_FAILED;
 
 out:
@@ -128,7 +128,7 @@
 		}
 	}
 
-	if (!report_object(handle, vg, NULL, pv, NULL, NULL));
+	if (!report_object(handle, vg, NULL, pv, NULL, NULL))
 		ret = ECMD_FAILED;
 
 out:


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2007-01-23 15:58 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2007-01-23 15:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-23 15:58:06

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/commands   : toolcontext.c toolcontext.h 
	tools          : lvmcmdline.c 

Log message:
	Fix refresh_toolcontext() always to wipe persistent device filter cache.
	Add is_long_lived to toolcontext.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.551&r2=1.552
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39

--- LVM2/WHATS_NEW	2007/01/23 13:08:34	1.551
+++ LVM2/WHATS_NEW	2007/01/23 15:58:05	1.552
@@ -1,5 +1,7 @@
 Version 2.02.20 -
 ===================================
+  Fix refresh_toolcontext() always to wipe persistent device filter cache.
+  Add is_long_lived to toolcontext.
   Add --clustered to man pages.
   Streamline dm_report_field_* interface.
   Change remaining dmeventd terminology 'register' to 'monitor'.
--- LVM2/daemons/clvmd/lvm-functions.c	2007/01/19 22:21:45	1.26
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/01/23 15:58:05	1.27
@@ -575,7 +575,7 @@
 /* Called to initialise the LVM context of the daemon */
 int init_lvm(int using_gulm)
 {
-	if (!(cmd = create_toolcontext(NULL, 0))) {
+	if (!(cmd = create_toolcontext(NULL, 0, 1))) {
 		log_error("Failed to allocate command context");
 		return 0;
 	}
--- LVM2/lib/commands/toolcontext.c	2006/11/04 03:34:09	1.43
+++ LVM2/lib/commands/toolcontext.c	2007/01/23 15:58:05	1.44
@@ -575,7 +575,7 @@
 	    filters[0] : composite_filter_create(nr_filt, filters);
 }
 
-static int _init_filters(struct cmd_context *cmd)
+static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache)
 {
 	const char *dev_cache;
 	struct dev_filter *f3, *f4;
@@ -608,8 +608,13 @@
 	if (!*cmd->sys_dir)
 		cmd->dump_filter = 0;
 
-	if (!stat(dev_cache, &st) &&
-	    (st.st_ctime != config_file_timestamp(cmd->cft)) &&
+	/*
+	 * Only load persistent filter device cache on startup if it is newer
+	 * than the config file and this is not a long-lived process.
+	 */
+	if (load_persistent_cache && !cmd->is_long_lived &&
+	    !stat(dev_cache, &st) &&
+	    (st.st_ctime > config_file_timestamp(cmd->cft)) &&
 	    !persistent_filter_load(f4, NULL))
 		log_verbose("Failed to load existing device cache from %s",
 			    dev_cache);
@@ -881,7 +886,8 @@
 }
 
 /* Entry point */
-struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static)
+struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static,
+				       unsigned is_long_lived)
 {
 	struct cmd_context *cmd;
 
@@ -905,6 +911,7 @@
 	memset(cmd, 0, sizeof(*cmd));
 	cmd->args = the_args;
 	cmd->is_static = is_static;
+	cmd->is_long_lived = is_long_lived;
 	cmd->hosttags = 0;
 	list_init(&cmd->formats);
 	list_init(&cmd->segtypes);
@@ -953,7 +960,7 @@
 	if (!_init_dev_cache(cmd))
 		goto error;
 
-	if (!_init_filters(cmd))
+	if (!_init_filters(cmd, 1))
 		goto error;
 
 	if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) {
@@ -1022,10 +1029,10 @@
 {
 	log_verbose("Reloading config files");
 
-	if (cmd->config_valid) {
-		if (cmd->dump_filter)
-			persistent_filter_dump(cmd->filter);
-	}
+	/*
+	 * Don't update the persistent filter cache as we will
+	 * perform a full rescan.
+	 */
 
 	activation_release();
 	lvmcache_destroy();
@@ -1064,7 +1071,7 @@
 	if (!_init_dev_cache(cmd))
 		return 0;
 
-	if (!_init_filters(cmd))
+	if (!_init_filters(cmd, 0))
 		return 0;
 
 	if (!_init_formats(cmd))
--- LVM2/lib/commands/toolcontext.h	2006/08/18 21:17:18	1.18
+++ LVM2/lib/commands/toolcontext.h	2007/01/23 15:58:06	1.19
@@ -65,6 +65,7 @@
 	struct arg *args;
 	char **argv;
 	unsigned is_static;	/* Static binary? */
+	unsigned is_long_lived;	/* Optimises persistent_filter handling */
 
 	struct dev_filter *filter;
 	int dump_filter;	/* Dump filter when exiting? */
@@ -88,7 +89,7 @@
 	char proc_dir[PATH_MAX];
 };
 
-struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static);
+struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived);
 void destroy_toolcontext(struct cmd_context *cmd);
 int refresh_toolcontext(struct cmd_context *cmd);
 int config_files_changed(struct cmd_context *cmd);
--- LVM2/tools/lvmcmdline.c	2006/11/14 15:28:50	1.38
+++ LVM2/tools/lvmcmdline.c	2007/01/23 15:58:06	1.39
@@ -1030,7 +1030,7 @@
 {
 	struct cmd_context *cmd;
 
-	if (!(cmd = create_toolcontext(&the_args[0], is_static))) {
+	if (!(cmd = create_toolcontext(&the_args[0], is_static, 0))) {
 		stack;
 		return NULL;
 	}


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2007-01-19 22:21 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2007-01-19 22:21 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2007-01-19 22:21:46

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h 
	lib/locking    : cluster_locking.c locking.h 
	lib/log        : log.c log.h 
	lib/metadata   : segtype.h 
	lib/mirror     : mirrored.c 
	tools          : lvchange.c vgchange.c 

Log message:
	register->monitor etc.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.548&r2=1.549
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.52&r2=1.53
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56

--- LVM2/WHATS_NEW	2007/01/18 22:33:24	1.548
+++ LVM2/WHATS_NEW	2007/01/19 22:21:44	1.549
@@ -1,5 +1,6 @@
 Version 2.02.20 -
 ===================================
+  Change remaining dmeventd terminology 'register' to 'monitor'.
   Update reporting man pages.
   No longer necessary to specify alignment for report fields.
 
--- LVM2/daemons/clvmd/lvm-functions.c	2006/10/24 18:49:31	1.25
+++ LVM2/daemons/clvmd/lvm-functions.c	2007/01/19 22:21:45	1.26
@@ -325,8 +325,8 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(1);
 
-	if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE))
-		init_dmeventd_register(0);
+	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
+		init_dmeventd_monitor(0);
 
 	switch (command) {
 	case LCK_LV_EXCLUSIVE:
@@ -362,8 +362,8 @@
 	if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
 		init_mirror_in_sync(0);
 
-	if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE))
-		init_dmeventd_register(DEFAULT_DMEVENTD_MONITOR);
+	if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE))
+		init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR);
 
 	/* clean the pool for another command */
 	dm_pool_empty(cmd->mem);
--- LVM2/lib/activate/activate.c	2007/01/12 20:38:29	1.116
+++ LVM2/lib/activate/activate.c	2007/01/19 22:21:45	1.117
@@ -640,28 +640,23 @@
 }
 
 /*
- * register_dev_for_events
- *
- * This function uses proper error codes (but breaks convention)
- * to return:
- *      -1 on error
- *       0 if the lv's targets don't do event [un]registration
- *       0 if the lv is already [un]registered -- FIXME: not implemented
- *       1 if the lv had a segment which was [un]registered
- *
- * Returns: -1 on error
+ * Returns 0 if an attempt to (un)monitor the device failed.
+ * Returns 1 otherwise.
  */
-int register_dev_for_events(struct cmd_context *cmd,
-			    struct logical_volume *lv, int do_reg)
+int monitor_dev_for_events(struct cmd_context *cmd,
+			    struct logical_volume *lv, int monitor)
 {
 #ifdef DMEVENTD
-	int i, pending = 0, registered;
-	int r = 0;
+	int i, pending = 0, monitored;
+	int r = 1;
 	struct list *tmp;
 	struct lv_segment *seg;
-	int (*reg) (struct cmd_context *c, struct lv_segment *s, int e);
+	int (*monitor_fn) (struct cmd_context *c, struct lv_segment *s, int e);
 
-	if (do_reg && !dmeventd_register_mode())
+	/*
+	 * Nothing to do if dmeventd configured not to be used.
+	 */
+	if (monitor && !dmeventd_monitor_mode())
 		return 1;
 
 	list_iterate(tmp, &lv->segments) {
@@ -669,57 +664,61 @@
 
 		if (!seg_monitored(seg) || (seg->status & PVMOVE))
 			continue;
-		reg = NULL;
+
+		monitor_fn = NULL;
 
 		/* Check monitoring status */
-		if (seg->segtype->ops->target_registered)
-			registered = seg->segtype->ops->target_registered(seg, &pending);
+		if (seg->segtype->ops->target_monitored)
+			monitored = seg->segtype->ops->target_monitored(seg, &pending);
 		else
 			continue;  /* segtype doesn't support registration */
 
 		/*
 		 * FIXME: We should really try again if pending
 		 */
-		registered = (pending) ? 0 : registered;
+		monitored = (pending) ? 0 : monitored;
 
-		if (do_reg) {
-			if (registered)
+		if (monitor) {
+			if (monitored)
 				log_verbose("%s/%s already monitored.", lv->vg->name, lv->name);
-			else if (seg->segtype->ops->target_register_events)
-				reg = seg->segtype->ops->target_register_events;
+			else if (seg->segtype->ops->target_monitor_events)
+				monitor_fn = seg->segtype->ops->target_monitor_events;
 		} else {
-			if (!registered)
+			if (!monitored)
 				log_verbose("%s/%s already not monitored.", lv->vg->name, lv->name);
-			else if (seg->segtype->ops->target_unregister_events)
-				reg = seg->segtype->ops->target_unregister_events;
+			else if (seg->segtype->ops->target_unmonitor_events)
+				monitor_fn = seg->segtype->ops->target_unmonitor_events;
 		}
 
 		/* Do [un]monitor */
-		if (!reg)
+		if (!monitor_fn)
 			continue;
 
+		log_verbose("%sonitoring %s/%s", monitor ? "M" : "Not m", lv->vg->name, lv->name);
+
 		/* FIXME specify events */
-		if (!reg(cmd, seg, 0)) {
-			stack;
-			return -1;
+		if (!monitor_fn(cmd, seg, 0)) {
+			log_error("%s/%s: %s segment monitoring function failed.",
+				  lv->vg->name, lv->name, seg->segtype->name);
+			return 0;
 		}
 
 		/* Check [un]monitor results */
 		/* Try a couple times if pending, but not forever... */
 		for (i = 0; i < 10; i++) {
 			pending = 0;
-			registered = seg->segtype->ops->target_registered(seg, &pending);
+			monitored = seg->segtype->ops->target_monitored(seg, &pending);
 			if (pending ||
-			    (!registered && do_reg) ||
-			    (registered && !do_reg))
-				log_very_verbose("%s/%s %smonitoring still pending.",
-						 lv->vg->name, lv->name, do_reg ? "" : "un");
+			    (!monitored && monitor) ||
+			    (monitored && !monitor))
+				log_very_verbose("%s/%s %smonitoring still pending: waiting...",
+						 lv->vg->name, lv->name, monitor ? "" : "un");
 			else
 				break;
 			sleep(1);
 		}
 
-		r = (registered && do_reg) || (!registered && !do_reg);
+		r = (monitored && monitor) || (!monitored && !monitor);
 	}
 
 	return r;
@@ -764,7 +763,7 @@
 		}
 	}
 
-	if (register_dev_for_events(cmd, lv, 0) < 0)
+	if (!monitor_dev_for_events(cmd, lv, 0))
 		/* FIXME Consider aborting here */
 		stack;
 
@@ -822,7 +821,7 @@
 	memlock_dec();
 	fs_unlock();
 
-	if (register_dev_for_events(cmd, lv, 1) < 0)
+	if (!monitor_dev_for_events(cmd, lv, 1))
 		stack;
 
 	return 1;
@@ -868,7 +867,7 @@
 		return 0;
 	}
 
-	if (register_dev_for_events(cmd, lv, 0) < 0)
+	if (!monitor_dev_for_events(cmd, lv, 0))
 		stack;
 
 	memlock_inc();
@@ -941,7 +940,7 @@
 	memlock_dec();
 	fs_unlock();
 
-	if (!register_dev_for_events(cmd, lv, 1) < 0)
+	if (!monitor_dev_for_events(cmd, lv, 1))
 		stack;
 
 	return r;
--- LVM2/lib/activate/activate.h	2006/10/03 17:55:19	1.52
+++ LVM2/lib/activate/activate.h	2007/01/19 22:21:45	1.53
@@ -86,7 +86,7 @@
 int lvs_in_vg_opened(struct volume_group *vg);
 
 
-int register_dev_for_events(struct cmd_context *cmd,
+int monitor_dev_for_events(struct cmd_context *cmd,
 			    struct logical_volume *lv, int do_reg);
 
 /*
--- LVM2/lib/locking/cluster_locking.c	2006/12/01 23:10:26	1.16
+++ LVM2/lib/locking/cluster_locking.c	2007/01/19 22:21:45	1.17
@@ -321,8 +321,8 @@
 	if (mirror_in_sync())
 		args[1] |= LCK_MIRROR_NOSYNC_MODE;
 
-	if (dmeventd_register_mode())
-		args[1] |= LCK_DMEVENTD_REGISTER_MODE;
+	if (dmeventd_monitor_mode())
+		args[1] |= LCK_DMEVENTD_MONITOR_MODE;
 
 	/*
 	 * VG locks are just that: locks, and have no side effects
--- LVM2/lib/locking/locking.h	2006/12/11 14:00:26	1.29
+++ LVM2/lib/locking/locking.h	2007/01/19 22:21:45	1.30
@@ -75,7 +75,7 @@
  */
 #define LCK_PARTIAL_MODE	0x00000001	/* Running in partial mode */
 #define LCK_MIRROR_NOSYNC_MODE	0x00000002	/* Mirrors don't require sync */
-#define LCK_DMEVENTD_REGISTER_MODE	0x00000004	/* Register with dmeventd */
+#define LCK_DMEVENTD_MONITOR_MODE	0x00000004	/* Register with dmeventd */
 
 
 /*
--- LVM2/lib/log/log.c	2006/08/21 12:54:53	1.35
+++ LVM2/lib/log/log.c	2007/01/19 22:21:45	1.36
@@ -48,7 +48,7 @@
 static char _msg_prefix[30] = "  ";
 static int _already_logging = 0;
 static int _mirror_in_sync = 0;
-static int _dmeventd_register = DEFAULT_DMEVENTD_MONITOR;
+static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR;
 
 static lvm2_log_fn_t _lvm2_log_fn = NULL;
 
@@ -189,9 +189,9 @@
 	_mirror_in_sync = in_sync;
 }
 
-void init_dmeventd_register(int reg)
+void init_dmeventd_monitor(int reg)
 {
-	_dmeventd_register = reg;
+	_dmeventd_monitor = reg;
 }
 
 void init_cmd_name(int status)
@@ -268,9 +268,9 @@
 	return _mirror_in_sync;
 }
 
-int dmeventd_register_mode(void)
+int dmeventd_monitor_mode(void)
 {
-	return _dmeventd_register;
+	return _dmeventd_monitor;
 }
 
 void init_debug(int level)
--- LVM2/lib/log/log.h	2006/08/01 14:56:33	1.32
+++ LVM2/lib/log/log.h	2007/01/19 22:21:45	1.33
@@ -75,7 +75,7 @@
 void init_lockingfailed(int level);
 void init_security_level(int level);
 void init_mirror_in_sync(int in_sync);
-void init_dmeventd_register(int reg);
+void init_dmeventd_monitor(int reg);
 
 void set_cmd_name(const char *cmd_name);
 
@@ -90,7 +90,7 @@
 int lockingfailed(void);
 int security_level(void);
 int mirror_in_sync(void);
-int dmeventd_register_mode(void);
+int dmeventd_monitor_mode(void);
 
 /* Suppress messages to stdout/stderr (1) or everywhere (2) */
 /* Returns previous setting */
--- LVM2/lib/metadata/segtype.h	2007/01/12 20:38:29	1.15
+++ LVM2/lib/metadata/segtype.h	2007/01/19 22:21:45	1.16
@@ -83,10 +83,10 @@
 			       const struct lv_segment *seg,
 			       struct list *modules);
 	void (*destroy) (const struct segment_type * segtype);
-	int (*target_registered) (struct lv_segment *seg, int *pending);
-	int (*target_register_events) (struct cmd_context *cmd,
+	int (*target_monitored) (struct lv_segment *seg, int *pending);
+	int (*target_monitor_events) (struct cmd_context *cmd,
 				       struct lv_segment *seg, int events);
-	int (*target_unregister_events) (struct cmd_context *cmd,
+	int (*target_unmonitor_events) (struct cmd_context *cmd,
 					 struct lv_segment *seg, int events);
 };
 
--- LVM2/lib/mirror/mirrored.c	2007/01/17 15:00:57	1.43
+++ LVM2/lib/mirror/mirrored.c	2007/01/19 22:21:45	1.44
@@ -411,7 +411,7 @@
 	return NULL;
 }
 
-static int _target_registered(struct lv_segment *seg, int *pending)
+static int _target_monitored(struct lv_segment *seg, int *pending)
 {
 	char *dso, *name;
 	struct logical_volume *lv;
@@ -476,19 +476,19 @@
 	if (!r)
 		return_0;
 
-	log_info("%s %s for events", set ? "Registered" : "Unregistered", name);
+	log_info("%s %s for events", set ? "Monitored" : "Unmonitored", name);
 
 	return 1;
 }
 
-static int _target_register_events(struct cmd_context *cmd,
+static int _target_monitor_events(struct cmd_context *cmd,
 				     struct lv_segment *seg,
 				     int events)
 {
 	return _target_set_events(cmd, seg, events, 1);
 }
 
-static int _target_unregister_events(struct cmd_context *cmd,
+static int _target_unmonitor_events(struct cmd_context *cmd,
 				     struct lv_segment *seg,
 				     int events)
 {
@@ -536,9 +536,9 @@
 	.target_percent = _mirrored_target_percent,
 	.target_present = _mirrored_target_present,
 #ifdef DMEVENTD
-	.target_registered = _target_registered,
-	.target_register_events = _target_register_events,
-	.target_unregister_events = _target_unregister_events,
+	.target_monitored = _target_monitored,
+	.target_monitor_events = _target_monitor_events,
+	.target_unmonitor_events = _target_unmonitor_events,
 #endif
 #endif
 	.modules_needed = _mirrored_modules_needed,
--- LVM2/tools/lvchange.c	2007/01/12 20:38:30	1.76
+++ LVM2/tools/lvchange.c	2007/01/19 22:21:45	1.77
@@ -80,10 +80,9 @@
 	return 1;
 }
 
-static int lvchange_registration(struct cmd_context *cmd,
-				 struct logical_volume *lv)
+static int lvchange_monitoring(struct cmd_context *cmd,
+			       struct logical_volume *lv)
 {
-	int r;
 	struct lvinfo info;
 
 	if (!lv_info(cmd, lv, &info, 0) || !info.exists) {
@@ -91,27 +90,14 @@
 		return 0;
 	}
 
-	/* do not register pvmove lv's */
+	/* do not monitor pvmove lv's */
 	if (lv->status & PVMOVE)
 		return 1;
 
-	log_verbose("%smonitoring logical volume \"%s\"",
-		    (dmeventd_register_mode()) ? "" : "Not ", lv->name);
-	r = register_dev_for_events(cmd, lv, dmeventd_register_mode());
-
-	if (r < 0) {
-		log_error("Unable to %smonitor logical volume, %s",
-			  (dmeventd_register_mode()) ? "" : "un", lv->name);
-		r = 0;
-	} else if (!r) {
-		log_verbose("Logical volume %s needs no %smonitoring, or is already %smonitored",
-			    (dmeventd_register_mode()) ? "" : "un",
-			    lv->name,
-			    (dmeventd_register_mode()) ? "" : "un");
-		r = 1;
-	}
+	if (!monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode()))
+		stack;
 
-	return r;
+	return 1;
 }
 
 static int lvchange_availability(struct cmd_context *cmd,
@@ -605,7 +591,7 @@
 		return ECMD_FAILED;
 	}
 
-	init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
+	init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
 
 	/* access permission change */
 	if (arg_count(cmd, permission_ARG)) {
@@ -675,7 +661,7 @@
 	if (!arg_count(cmd, available_ARG) &&
 	    !arg_count(cmd, refresh_ARG) &&
 	    arg_count(cmd, monitor_ARG)) {
-		if (!lvchange_registration(cmd, lv))
+		if (!lvchange_monitoring(cmd, lv))
 			return ECMD_FAILED;
 	}
 
--- LVM2/tools/vgchange.c	2007/01/12 20:38:30	1.55
+++ LVM2/tools/vgchange.c	2007/01/19 22:21:45	1.56
@@ -15,7 +15,7 @@
 
 #include "tools.h"
 
-static int _register_lvs_in_vg(struct cmd_context *cmd,
+static int _monitor_lvs_in_vg(struct cmd_context *cmd,
 			       struct volume_group *vg, int reg)
 {
 	struct lv_list *lvl;
@@ -23,7 +23,6 @@
 	struct lvinfo info;
 	int lv_active;
 	int count = 0;
-	int r;
 
 	list_iterate_items(lvl, &vg->lvs) {
 		lv = lvl->lv;
@@ -39,16 +38,9 @@
 		if ((lv->status & PVMOVE) || !lv_active)
 			continue;
 
-		r = register_dev_for_events(cmd, lv, reg);
-
-		if (r < 0) {
-			log_error("Failed to %s logical volume, %s",
-				  (reg) ? "register" : "unregister",
-				  lv->name);
+		if (!monitor_dev_for_events(cmd, lv, reg)) {
 			continue;
-		}
-
-		if (r)
+		} else
 			count++;
 	}
 
@@ -114,10 +106,10 @@
 	int active, monitored;
 
 	if ((active = lvs_in_vg_activated(vg))) {
-		monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode());
+		monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode());
 		log_print("%d logical volume(s) in volume group "
 			    "\"%s\" %smonitored",
-			    monitored, vg->name, (dmeventd_register_mode()) ? "" : "un");
+			    monitored, vg->name, (dmeventd_monitor_mode()) ? "" : "un");
 	}
 
 	return ECMD_PROCESSED;
@@ -154,11 +146,11 @@
 	if (activate && (active = lvs_in_vg_activated(vg))) {
 		log_verbose("%d logical volume(s) in volume group \"%s\" "
 			    "already active", active, vg->name);
-		monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode());
+		monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode());
 		log_verbose("%d existing logical volume(s) in volume "
 			    "group \"%s\" %smonitored",
 			    monitored, vg->name,
-			    dmeventd_register_mode() ? "" : "un");
+			    dmeventd_monitor_mode() ? "" : "un");
 	}
 
 	if (activate && _activate_lvs_in_vg(cmd, vg, available))
@@ -540,7 +532,7 @@
 		return ECMD_FAILED;
 	}
 
-	init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
+	init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
 
 	if (arg_count(cmd, available_ARG))
 		r = _vgchange_available(cmd, vg);


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2006-05-11 19:05 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2006-05-11 19:05 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-05-11 19:05:21

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : cluster_locking.c locking.h 
	lib/metadata   : mirror.c 

Log message:
	Propagate nosync flag around cluster.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.382&r2=1.383
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2006-03-09 22:34 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2006-03-09 22:34 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-03-09 22:34:13

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/locking    : cluster_locking.c locking.h 

Log message:
	Propagate partial mode around cluster.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.346&r2=1.347
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.23&r2=1.24


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

* LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ...
@ 2005-08-14 23:18 agk
  0 siblings, 0 replies; 33+ messages in thread
From: agk @ 2005-08-14 23:18 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-08-14 23:18:28

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : lvm-functions.c 
	lib/activate   : activate.c activate.h 
	lib/format_text: flags.c 
	lib/locking    : file_locking.c no_locking.c 
	lib/metadata   : metadata.h 
	lib/mirror     : mirrored.c 
	tools          : lvcreate.c pvmove.c vgchange.c 

Log message:
	Prepare tools to support clustered mirrors.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.280&r2=1.281
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.127&r2=1.128
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49


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

end of thread, other threads:[~2012-01-20  0:27 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-27 22:43 LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c agk
  -- strict thread matches above, loose matches on Subject: below --
2012-01-20  0:27 jbrassow
2011-12-08 21:24 agk
2011-08-10 20:25 zkabelac
2011-02-18 14:16 zkabelac
2011-02-18  0:36 jbrassow
2011-02-04 20:30 jbrassow
2011-02-03 16:03 zkabelac
2011-02-03  1:58 zkabelac
2010-12-08 20:51 agk
2010-11-23  1:56 agk
2010-03-26 15:40 snitzer
2010-03-23 22:30 snitzer
2010-01-19 13:25 mbroz
2010-01-05 16:09 mbroz
2010-01-05 16:06 mbroz
2010-01-05 16:03 mbroz
2009-11-23 10:44 mbroz
2009-07-24 18:15 agk
2009-07-16  0:37 agk
2009-07-15 23:57 agk
2009-07-13 19:49 agk
2009-06-12  8:30 mbroz
2009-02-22 21:14 agk
2009-01-26 19:01 agk
2008-09-19  6:42 agk
2007-08-07  9:06 meyering
2007-01-25 14:37 agk
2007-01-23 15:58 agk
2007-01-19 22:21 agk
2006-05-11 19:05 agk
2006-03-09 22:34 agk
2005-08-14 23:18 agk

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).