public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2010-08-17 16:25 agk
  0 siblings, 0 replies; 11+ messages in thread
From: agk @ 2010-08-17 16:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-08-17 16:25:36

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c lvm-functions.c lvm-functions.h 
	lib/activate   : activate.c activate.h dev_manager.c 
	                 dev_manager.h 
	lib/display    : display.c 
	lib/locking    : file_locking.c no_locking.c 
	lib/metadata   : lv_manip.c mirror.c 
	lib/mirror     : mirrored.c 
	lib/report     : report.c 
	liblvm         : lvm_lv.c 
	tools          : lvchange.c lvconvert.c lvresize.c lvscan.c 
	                 vgchange.c vgconvert.c vgreduce.c 

Log message:
	Allow internal suspend and resume of origin without its snapshots.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1707&r2=1.1708
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.176&r2=1.177
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.70&r2=1.71
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.33&r2=1.34
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.231&r2=1.232
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.123&r2=1.124
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.145&r2=1.146
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvscan.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgconvert.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104

--- LVM2/WHATS_NEW	2010/08/17 01:51:12	1.1707
+++ LVM2/WHATS_NEW	2010/08/17 16:25:32	1.1708
@@ -1,5 +1,6 @@
 Version 2.02.73 - 
 ================================
+  Allow internal suspend and resume of origin without its snapshots.
   Fix dev_manager_transient to access -real device not snapshot-origin.
   Monitor origin -real device below snapshot instead of overlay device.
   Don't really change monitoring status when in test mode.
--- LVM2/daemons/clvmd/clvmd.c	2010/08/03 13:06:35	1.76
+++ LVM2/daemons/clvmd/clvmd.c	2010/08/17 16:25:32	1.77
@@ -1885,7 +1885,7 @@
 	pthread_sigmask(SIG_BLOCK, &ss, NULL);
 
 	/* Initialise the interface to liblvm */
-	init_lvm(lvm_params->using_gulm, lvm_params->argv);
+	init_clvm(lvm_params->using_gulm, lvm_params->argv);
 
 	/* Allow others to get moving */
 	pthread_mutex_unlock(&lvm_start_mutex);
--- LVM2/daemons/clvmd/lvm-functions.c	2010/08/03 13:06:35	1.97
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/08/17 16:25:32	1.98
@@ -214,7 +214,7 @@
 }
 
 /* Gets a real lock and keeps the info in the hash table */
-int hold_lock(char *resource, int mode, int flags)
+static int hold_lock(char *resource, int mode, int flags)
 {
 	int status;
 	int saved_errno;
@@ -269,7 +269,7 @@
 }
 
 /* Unlock and remove it from the hash table */
-int hold_unlock(char *resource)
+static int hold_unlock(char *resource)
 {
 	struct lv_info *lvi;
 	int status;
@@ -350,12 +350,14 @@
 	}
 
 	/* If it's suspended then resume it */
-	if (!lv_info_by_lvid(cmd, resource, &lvi, 0, 0))
+	// FIXME Set origin_only
+	if (!lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0))
 		goto error;
 
 	if (lvi.suspended) {
 		memlock_inc(cmd);
-		if (!lv_resume(cmd, resource)) {
+		// FIXME Set origin_only
+		if (!lv_resume(cmd, resource, 0)) {
 			memlock_dec(cmd);
 			goto error;
 		}
@@ -385,7 +387,8 @@
 		return 0;	/* We don't need to do anything */
 	}
 
-	if (!lv_resume_if_active(cmd, resource))
+	// FIXME Set origin_only
+	if (!lv_resume_if_active(cmd, resource, 0))
 		return EIO;
 
 	return 0;
@@ -405,14 +408,14 @@
 	}
 
 	/* Only suspend it if it exists */
-	if (!lv_info_by_lvid(cmd, resource, &lvi, 0, 0))
+	// FIXME Set origin_only
+	if (!lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0))
+		return EIO;
+
+	// FIXME Set origin_only
+	if (lvi.exists && !lv_suspend_if_active(cmd, resource, 0))
 		return EIO;
 
-	if (lvi.exists) {
-		if (!lv_suspend_if_active(cmd, resource)) {
-			return EIO;
-		}
-	}
 	return 0;
 }
 
@@ -571,7 +574,8 @@
 			struct lvinfo lvi;
 
 			pthread_mutex_lock(&lvm_lock);
-			status = lv_info_by_lvid(cmd, resource, &lvi, 0, 0);
+			// FIXME Set origin_only
+			status = lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0);
 			pthread_mutex_unlock(&lvm_lock);
 			if (!status)
 				return EIO;
@@ -579,10 +583,8 @@
 			if (lvi.exists) {
 				if (hold_lock(resource, LCK_READ, LCKF_CONVERT))
 					return errno;
-			} else {
-				if (hold_unlock(resource))
-					return errno;
-			}
+			} else if (hold_unlock(resource))
+				return errno;
 		}
 	}
 	return 0;
@@ -882,7 +884,7 @@
 }
 
 /* Called to initialise the LVM context of the daemon */
-int init_lvm(int using_gulm, char **argv)
+int init_clvm(int using_gulm, char **argv)
 {
 	if (!(cmd = create_toolcontext(1, NULL))) {
 		log_error("Failed to allocate command context");
--- LVM2/daemons/clvmd/lvm-functions.h	2010/04/20 14:07:38	1.13
+++ LVM2/daemons/clvmd/lvm-functions.h	2010/08/17 16:25:32	1.14
@@ -27,15 +27,14 @@
 			char *resource);
 extern int do_check_lvm1(const char *vgname);
 extern int do_refresh_cache(void);
-extern int init_lvm(int using_gulm, char **argv);
+extern int init_clvm(int using_gulm, char **argv);
 extern void destroy_lvm(void);
 extern void init_lvhash(void);
 extern void destroy_lvhash(void);
 extern void lvm_do_backup(const char *vgname);
-extern int hold_unlock(char *resource);
-extern int hold_lock(char *resource, int mode, int flags);
 extern char *get_last_lvm_error(void);
 extern void do_lock_vg(unsigned char command, unsigned char lock_flags,
 		      char *resource);
 extern struct dm_hash_node *get_next_excl_lock(struct dm_hash_node *v, char **name);
+
 #endif
--- LVM2/lib/activate/activate.c	2010/08/17 01:16:41	1.176
+++ LVM2/lib/activate/activate.c	2010/08/17 16:25:32	1.177
@@ -147,12 +147,13 @@
 {
 	return 0;
 }
-int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, struct lvinfo *info,
-	    int with_open_count, int with_read_ahead)
+int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, unsigned origin_only,
+	    struct lvinfo *info, int with_open_count, int with_read_ahead)
 {
 	return 0;
 }
 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
+		    unsigned origin_only,
 		    struct lvinfo *info, int with_open_count, int with_read_ahead)
 {
 	return 0;
@@ -176,10 +177,12 @@
 {
 	return 0;
 }
+/******
 int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
 {
 	return 1;
 }
+*******/
 int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
 {
 	return 1;
@@ -451,7 +454,7 @@
 /*
  * Returns 1 if info structure populated, else 0 on failure.
  */
-int lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
+int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, unsigned origin_only,
 	    struct lvinfo *info, int with_open_count, int with_read_ahead)
 {
 	struct dm_info dminfo;
@@ -459,7 +462,7 @@
 	if (!activation())
 		return 0;
 
-	if (!dev_manager_info(lv->vg->cmd->mem, lv, with_open_count,
+	if (!dev_manager_info(lv->vg->cmd->mem, lv, origin_only ? "real" : NULL, with_open_count,
 			      with_read_ahead, &dminfo, &info->read_ahead))
 		return_0;
 
@@ -476,6 +479,7 @@
 }
 
 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
+		    unsigned origin_only,
 		    struct lvinfo *info, int with_open_count, int with_read_ahead)
 {
 	int r;
@@ -484,7 +488,10 @@
 	if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
 		return 0;
 
-	r = lv_info(cmd, lv, info, with_open_count, with_read_ahead);
+	if (!lv_is_origin(lv))
+		origin_only = 0;
+
+	r = lv_info(cmd, lv, origin_only, info, with_open_count, with_read_ahead);
 	vg_release(lv->vg);
 
 	return r;
@@ -554,7 +561,7 @@
 	if (!activation())
 		return 0;
 
-	if (!lv_info(cmd, lv, &info, 0, 0))
+	if (!lv_info(cmd, lv, 0, &info, 0, 0))
 		return_0;
 
 	if (!info.exists)
@@ -576,7 +583,7 @@
 {
 	struct lvinfo info;
 
-	if (!lv_info(cmd, lv, &info, 0, 0)) {
+	if (!lv_info(cmd, lv, 0, &info, 0, 0)) {
 		stack;
 		return -1;
 	}
@@ -588,7 +595,7 @@
 {
 	struct lvinfo info;
 
-	if (!lv_info(cmd, lv, &info, 1, 0)) {
+	if (!lv_info(cmd, lv, 0, &info, 1, 0)) {
 		stack;
 		return -1;
 	}
@@ -596,7 +603,7 @@
 	return info.open_count;
 }
 
-static int _lv_activate_lv(struct logical_volume *lv)
+static int _lv_activate_lv(struct logical_volume *lv, unsigned origin_only)
 {
 	int r;
 	struct dev_manager *dm;
@@ -604,14 +611,14 @@
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_activate(dm, lv)))
+	if (!(r = dev_manager_activate(dm, lv, origin_only)))
 		stack;
 
 	dev_manager_destroy(dm);
 	return r;
 }
 
-static int _lv_preload(struct logical_volume *lv, int *flush_required)
+static int _lv_preload(struct logical_volume *lv, unsigned origin_only, int *flush_required)
 {
 	int r;
 	struct dev_manager *dm;
@@ -619,7 +626,7 @@
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_preload(dm, lv, flush_required)))
+	if (!(r = dev_manager_preload(dm, lv, origin_only, flush_required)))
 		stack;
 
 	dev_manager_destroy(dm);
@@ -641,7 +648,7 @@
 	return r;
 }
 
-static int _lv_suspend_lv(struct logical_volume *lv, int lockfs, int flush_required)
+static int _lv_suspend_lv(struct logical_volume *lv, unsigned origin_only, int lockfs, int flush_required)
 {
 	int r;
 	struct dev_manager *dm;
@@ -649,7 +656,7 @@
 	if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name)))
 		return_0;
 
-	if (!(r = dev_manager_suspend(dm, lv, lockfs, flush_required)))
+	if (!(r = dev_manager_suspend(dm, lv, origin_only, lockfs, flush_required)))
 		stack;
 
 	dev_manager_destroy(dm);
@@ -841,8 +848,8 @@
  * Returns 0 if an attempt to (un)monitor the device failed.
  * Returns 1 otherwise.
  */
-int monitor_dev_for_events(struct cmd_context *cmd,
-			    struct logical_volume *lv, int monitor)
+int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv,
+			   unsigned origin_only, int monitor)
 {
 #ifdef DMEVENTD
 	int i, pending = 0, monitored;
@@ -868,17 +875,17 @@
 	 * not the actual LV itself.
 	 */
 	if (lv_is_cow(lv) && !lv_is_merging_cow(lv))
-		return monitor_dev_for_events(cmd, lv->snapshot->lv, monitor);
+		return monitor_dev_for_events(cmd, lv->snapshot->lv, 0, monitor);
 
 	/*
 	 * In case this LV is a snapshot origin, we instead monitor
 	 * each of its respective snapshots.  The origin itself may
 	 * also need to be monitored if it is a mirror, for example.
 	 */
-	if (lv_is_origin(lv))
+	if (!origin_only && lv_is_origin(lv))
 		dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
 			if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh,
-				    struct lv_segment, origin_list)->cow, monitor))
+				    struct lv_segment, origin_list)->cow, 0, monitor))
 				r = 0;
 
 	/*
@@ -888,7 +895,7 @@
 	if ((seg = first_seg(lv)) != NULL && seg->log_lv != NULL &&
 	    (log_seg = first_seg(seg->log_lv)) != NULL &&
 	    seg_is_mirrored(log_seg))
-		if (!monitor_dev_for_events(cmd, seg->log_lv, monitor))
+		if (!monitor_dev_for_events(cmd, seg->log_lv, 0, monitor))
 			r = 0;
 
 	dm_list_iterate(tmp, &lv->segments) {
@@ -898,7 +905,7 @@
 		for (s = 0; s < seg->area_count; s++) {
 			if (seg_type(seg, s) != AREA_LV)
 				continue;
-			if (!monitor_dev_for_events(cmd, seg_lv(seg, s),
+			if (!monitor_dev_for_events(cmd, seg_lv(seg, s), 0,
 						    monitor)) {
 				log_error("Failed to %smonitor %s",
 					  monitor ? "" : "un",
@@ -979,7 +986,7 @@
 }
 
 static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
-		       int error_if_not_suspended)
+		       unsigned origin_only, int error_if_not_suspended)
 {
 	struct logical_volume *lv = NULL, *lv_pre = NULL;
 	struct lvinfo info;
@@ -995,13 +1002,17 @@
 	if (!(lv_pre = lv_from_lvid(cmd, lvid_s, 1)))
 		goto_out;
 
+	/* Ignore origin_only unless LV is origin in both old and new metadata */
+	if (!lv_is_origin(lv) || !lv_is_origin(lv_pre))
+		origin_only = 0;
+
 	if (test_mode()) {
-		_skip("Suspending '%s'.", lv->name);
+		_skip("Suspending %s%s.", lv->name, origin_only ? " origin without snapshots" : "");
 		r = 1;
 		goto out;
 	}
 
-	if (!lv_info(cmd, lv, &info, 0, 0))
+	if (!lv_info(cmd, lv, origin_only, &info, 0, 0))
 		goto_out;
 
 	if (!info.exists || info.suspended) {
@@ -1020,22 +1031,23 @@
 
 	/* If VG was precommitted, preload devices for the LV */
 	if ((lv_pre->vg->status & PRECOMMITTED)) {
-		if (!_lv_preload(lv_pre, &flush_required)) {
+		if (!_lv_preload(lv_pre, origin_only, &flush_required)) {
 			/* FIXME Revert preloading */
 			goto_out;
 		}
 	}
 
-	if (!monitor_dev_for_events(cmd, lv, 0))
+	if (!monitor_dev_for_events(cmd, lv, origin_only, 0))
 		/* FIXME Consider aborting here */
 		stack;
 
 	memlock_inc(cmd);
 
-	if (lv_is_origin(lv_pre) || lv_is_cow(lv_pre))
+	if (!origin_only &&
+	    (lv_is_origin(lv_pre) || lv_is_cow(lv_pre)))
 		lockfs = 1;
 
-	if (!_lv_suspend_lv(lv, lockfs, flush_required)) {
+	if (!_lv_suspend_lv(lv, origin_only, lockfs, flush_required)) {
 		memlock_dec(cmd);
 		fs_unlock();
 		goto out;
@@ -1054,17 +1066,21 @@
 }
 
 /* Returns success if the device is not active */
-int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
+int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
 {
-	return _lv_suspend(cmd, lvid_s, 0);
+	return _lv_suspend(cmd, lvid_s, origin_only, 0);
 }
 
+/* No longer used */
+/***********
 int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
 {
 	return _lv_suspend(cmd, lvid_s, 1);
 }
+***********/
 
 static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
+		      unsigned origin_only,
 		      int error_if_not_active)
 {
 	struct logical_volume *lv;
@@ -1077,13 +1093,16 @@
 	if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
 		goto_out;
 
+	if (!lv_is_origin(lv))
+		origin_only = 0;
+
 	if (test_mode()) {
-		_skip("Resuming '%s'.", lv->name);
+		_skip("Resuming %s%s.", lv->name, origin_only ? " without snapshots" : "");
 		r = 1;
 		goto out;
 	}
 
-	if (!lv_info(cmd, lv, &info, 0, 0))
+	if (!lv_info(cmd, lv, origin_only, &info, 0, 0))
 		goto_out;
 
 	if (!info.exists || !info.suspended) {
@@ -1093,13 +1112,13 @@
 		goto out;
 	}
 
-	if (!_lv_activate_lv(lv))
+	if (!_lv_activate_lv(lv, origin_only))
 		goto_out;
 
 	memlock_dec(cmd);
 	fs_unlock();
 
-	if (!monitor_dev_for_events(cmd, lv, 1))
+	if (!monitor_dev_for_events(cmd, lv, origin_only, 1))
 		stack;
 
 	r = 1;
@@ -1111,14 +1130,14 @@
 }
 
 /* Returns success if the device is not active */
-int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
+int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
 {
-	return _lv_resume(cmd, lvid_s, 0);
+	return _lv_resume(cmd, lvid_s, origin_only, 0);
 }
 
-int lv_resume(struct cmd_context *cmd, const char *lvid_s)
+int lv_resume(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only)
 {
-	return _lv_resume(cmd, lvid_s, 1);
+	return _lv_resume(cmd, lvid_s, origin_only, 1);
 }
 
 static int _lv_has_open_snapshots(struct logical_volume *lv)
@@ -1128,7 +1147,7 @@
 	int r = 0;
 
 	dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs, origin_list) {
-		if (!lv_info(lv->vg->cmd, snap_seg->cow, &info, 1, 0)) {
+		if (!lv_info(lv->vg->cmd, snap_seg->cow, 0, &info, 1, 0)) {
 			r = 1;
 			continue;
 		}
@@ -1162,7 +1181,7 @@
 		goto out;
 	}
 
-	if (!lv_info(cmd, lv, &info, 1, 0))
+	if (!lv_info(cmd, lv, 0, &info, 1, 0))
 		goto_out;
 
 	if (!info.exists) {
@@ -1185,7 +1204,7 @@
 
 	lv_calculate_readahead(lv, NULL);
 
-	if (!monitor_dev_for_events(cmd, lv, 0))
+	if (!monitor_dev_for_events(cmd, lv, 0, 0))
 		stack;
 
 	memlock_inc(cmd);
@@ -1193,7 +1212,7 @@
 	memlock_dec(cmd);
 	fs_unlock();
 
-	if (!lv_info(cmd, lv, &info, 1, 0) || info.exists)
+	if (!lv_info(cmd, lv, 0, &info, 1, 0) || info.exists)
 		r = 0;
 out:
 	if (lv) {
@@ -1270,7 +1289,7 @@
 		goto out;
 	}
 
-	if (!lv_info(cmd, lv, &info, 0, 0))
+	if (!lv_info(cmd, lv, 0, &info, 0, 0))
 		goto_out;
 
 	if (info.exists && !info.suspended && info.live_table) {
@@ -1287,12 +1306,12 @@
 		lv->status |= ACTIVATE_EXCL;
 
 	memlock_inc(cmd);
-	if (!(r = _lv_activate_lv(lv)))
+	if (!(r = _lv_activate_lv(lv, 0)))
 		stack;
 	memlock_dec(cmd);
 	fs_unlock();
 
-	if (r && !monitor_dev_for_events(cmd, lv, 1))
+	if (r && !monitor_dev_for_events(cmd, lv, 0, 1))
 		stack;
 
 out:
--- LVM2/lib/activate/activate.h	2010/08/17 01:16:41	1.70
+++ LVM2/lib/activate/activate.h	2010/08/17 16:25:32	1.71
@@ -53,10 +53,10 @@
 void activation_release(void);
 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);
-int lv_resume(struct cmd_context *cmd, const char *lvid_s);
-int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s);
+/* 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_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);
@@ -67,9 +67,10 @@
 /*
  * Returns 1 if info structure has been populated, else 0.
  */
-int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, struct lvinfo *info,
+int lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
+	    unsigned origin_only, struct lvinfo *info,
 	    int with_open_count, int with_read_ahead);
-int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
+int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, unsigned origin_only,
 		    struct lvinfo *info, int with_open_count, int with_read_ahead);
 
 /*
@@ -99,8 +100,8 @@
 int lv_has_target_type(struct dm_pool *mem, struct logical_volume *lv,
 		       const char *layer, const char *target_type);
 
-int monitor_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,
+			   unsigned origin_only, int do_reg);
 
 #ifdef DMEVENTD
 #  include "libdevmapper-event.h"
--- LVM2/lib/activate/dev_manager.c	2010/08/17 01:51:12	1.199
+++ LVM2/lib/activate/dev_manager.c	2010/08/17 16:25:33	1.200
@@ -222,19 +222,20 @@
 }
 
 int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
+		     const char *layer,
 		     int with_open_count, int with_read_ahead,
 		     struct dm_info *info, uint32_t *read_ahead)
 {
 	char *dlid, *name;
 	int r;
 
-	if (!(name = build_dm_name(mem, lv->vg->name, lv->name, NULL))) {
+	if (!(name = build_dm_name(mem, lv->vg->name, lv->name, layer))) {
 		log_error("name build failed for %s", lv->name);
 		return 0;
 	}
 
-	if (!(dlid = build_dm_uuid(mem, lv->lvid.s, NULL))) {
-		log_error("dlid build failed for %s", lv->name);
+	if (!(dlid = build_dm_uuid(mem, lv->lvid.s, layer))) {
+		log_error("dlid build failed for %s", name);
 		return 0;
 	}
 
@@ -559,11 +560,11 @@
 	char *type = NULL;
 	char *params = NULL;
 	char *dlid = NULL;
-	char *suffix = lv_is_origin(lv) ? "real" : NULL;
+	const char *layer = lv_is_origin(lv) ? "real" : NULL;
 	const struct dm_list *segh = &lv->segments;
 	struct lv_segment *seg = NULL;
 
-	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, suffix)))
+	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer)))
 		return_0;
 
 	if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0)))
@@ -714,17 +715,17 @@
 {
 	char *name;
 	const char *dlid;
-	const char *suffix = (lv_is_origin(lv)) ? "real" : NULL;
+	const char *layer = (lv_is_origin(lv)) ? "real" : NULL;
 
 	/*
 	 * Build a name for the top layer.
 	 */
-	if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, suffix)))
+	if (!(name = build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
 		return_0;
 
 	/* FIXME dm_pool_free ? */
 
-	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, suffix))) {
+	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, layer))) {
 		log_error("dlid build failed for %s", lv->name);
 		return 0;
 	}
@@ -1014,16 +1015,16 @@
 /*
  * Add LV and any known dependencies
  */
-static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv)
+static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv, unsigned origin_only)
 {
-	if (!_add_dev_to_dtree(dm, dtree, lv, NULL))
+	if (!origin_only && !_add_dev_to_dtree(dm, dtree, lv, NULL))
 		return_0;
 
 	/* FIXME Can we avoid doing this every time? */
 	if (!_add_dev_to_dtree(dm, dtree, lv, "real"))
 		return_0;
 
-	if (!_add_dev_to_dtree(dm, dtree, lv, "cow"))
+	if (!origin_only && !_add_dev_to_dtree(dm, dtree, lv, "cow"))
 		return_0;
 
 	if ((lv->status & MIRRORED) && first_seg(lv)->log_lv &&
@@ -1038,7 +1039,7 @@
 	return 1;
 }
 
-static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv)
+static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only)
 {
 	struct dm_tree *dtree;
 	struct dm_list *snh, *snht;
@@ -1050,19 +1051,20 @@
 		return NULL;
 	}
 
-	if (!_add_lv_to_dtree(dm, dtree, lv))
+	if (!_add_lv_to_dtree(dm, dtree, lv, origin_only))
 		goto_bad;
 
 	/* Add any snapshots of this LV */
-	dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
-		if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow))
-			goto_bad;
+	if (!origin_only)
+		dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
+			if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow, 0))
+				goto_bad;
 
 	/* Add any LVs used by segments in this LV */
 	dm_list_iterate_items(seg, &lv->segments)
 		for (s = 0; s < seg->area_count; s++)
 			if (seg_type(seg, s) == AREA_LV && seg_lv(seg, s)) {
-				if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, s)))
+				if (!_add_lv_to_dtree(dm, dtree, seg_lv(seg, s), 0))
 					goto_bad;
 			}
 
@@ -1622,14 +1624,15 @@
 	return 1;
 }
 
-static int _tree_action(struct dev_manager *dm, struct logical_volume *lv, action_t action)
+static int _tree_action(struct dev_manager *dm, struct logical_volume *lv,
+			unsigned origin_only, action_t action)
 {
 	struct dm_tree *dtree;
 	struct dm_tree_node *root;
 	char *dlid;
 	int r = 0;
 
-	if (!(dtree = _create_partial_dtree(dm, lv)))
+	if (!(dtree = _create_partial_dtree(dm, lv, origin_only)))
 		return_0;
 
 	if (!(root = dm_tree_find_node(dtree, 0, 0))) {
@@ -1637,7 +1640,7 @@
 		goto out;
 	}
 
-	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, NULL)))
+	if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, origin_only ? "real" : NULL)))
 		goto_out;
 
 	/* Only process nodes with uuid of "LVM-" plus VG id. */
@@ -1669,7 +1672,7 @@
 	case PRELOAD:
 	case ACTIVATE:
 		/* Add all required new devices to tree */
-		if (!_add_new_lv_to_dtree(dm, dtree, lv, NULL))
+		if (!_add_new_lv_to_dtree(dm, dtree, lv, origin_only ? "real" : NULL))
 			goto_out;
 
 		/* Preload any devices required before any suspensions */
@@ -1710,22 +1713,24 @@
 	return r;
 }
 
-int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv)
+/* origin_only may only be set if we are resuming (not activating) an origin LV */
+int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only)
 {
-	if (!_tree_action(dm, lv, ACTIVATE))
+	if (!_tree_action(dm, lv, origin_only, ACTIVATE))
 		return_0;
 
-	return _tree_action(dm, lv, CLEAN);
+	return _tree_action(dm, lv, origin_only, CLEAN);
 }
 
+/* origin_only may only be set if we are resuming (not activating) an origin LV */
 int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv,
-			int *flush_required)
+			unsigned origin_only, int *flush_required)
 {
 	/* FIXME Update the pvmove implementation! */
 	if ((lv->status & PVMOVE) || (lv->status & LOCKED))
 		return 1;
 
-	if (!_tree_action(dm, lv, PRELOAD))
+	if (!_tree_action(dm, lv, origin_only, PRELOAD))
 		return 0;
 
 	*flush_required = dm->flush_required;
@@ -1737,17 +1742,17 @@
 {
 	int r;
 
-	r = _tree_action(dm, lv, DEACTIVATE);
+	r = _tree_action(dm, lv, 0, DEACTIVATE);
 
 	return r;
 }
 
 int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
-			int lockfs, int flush_required)
+			unsigned origin_only, int lockfs, int flush_required)
 {
 	dm->flush_required = flush_required;
 
-	return _tree_action(dm, lv, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND);
+	return _tree_action(dm, lv, origin_only, lockfs ? SUSPEND_WITH_LOCKFS : SUSPEND);
 }
 
 /*
--- LVM2/lib/activate/dev_manager.h	2010/05/24 15:32:20	1.33
+++ LVM2/lib/activate/dev_manager.h	2010/08/17 16:25:33	1.34
@@ -41,6 +41,7 @@
  * unsuspended until the snapshot is also created.)
  */
 int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
+		     const char *layer,
 		     int with_open_count, int with_read_ahead,
 		     struct dm_info *info, uint32_t *read_ahead);
 int dev_manager_snapshot_percent(struct dev_manager *dm,
@@ -52,10 +53,10 @@
 			       float *percent, percent_range_t *percent_range,
 			       uint32_t *event_nr);
 int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv,
-			int lockfs, int flush_required);
-int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv);
+			unsigned origin_only, int lockfs, int flush_required);
+int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv, unsigned origin_only);
 int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv,
-			int *flush_required);
+			unsigned origin_only, int *flush_required);
 int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);
 int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv);
 
--- LVM2/lib/display/display.c	2010/07/09 15:34:42	1.111
+++ LVM2/lib/display/display.c	2010/08/17 16:25:33	1.112
@@ -452,7 +452,7 @@
 {
 	int inkernel;
 	struct lvinfo info;
-	inkernel = lv_info(lv->vg->cmd, lv, &info, 1, 0) && info.exists;
+	inkernel = lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) && info.exists;
 
 	log_print("%s%s/%s:%s:%" PRIu64 ":%d:-1:%d:%" PRIu64 ":%d:-1:%d:%d:%d:%d",
 		  lv->vg->cmd->dev_dir,
@@ -481,7 +481,7 @@
 	if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid)))
 		return_0;
 
-	inkernel = lv_info(cmd, lv, &info, 1, 1) && info.exists;
+	inkernel = lv_info(cmd, lv, 0, &info, 1, 1) && info.exists;
 
 	log_print("--- Logical volume ---");
 
--- LVM2/lib/locking/file_locking.c	2010/08/03 13:06:35	1.48
+++ LVM2/lib/locking/file_locking.c	2010/08/17 16:25:33	1.49
@@ -279,7 +279,8 @@
 		switch (flags & LCK_TYPE_MASK) {
 		case LCK_UNLOCK:
 			log_very_verbose("Unlocking LV %s", resource);
-			if (!lv_resume_if_active(cmd, resource))
+			// FIXME Set origin_only
+			if (!lv_resume_if_active(cmd, resource, 0))
 				return 0;
 			break;
 		case LCK_NULL:
@@ -297,7 +298,8 @@
 			break;
 		case LCK_WRITE:
 			log_very_verbose("Locking LV %s (W)", resource);
-			if (!lv_suspend_if_active(cmd, resource))
+			// FIXME Set origin_only
+			if (!lv_suspend_if_active(cmd, resource, 0))
 				return 0;
 			break;
 		case LCK_EXCL:
--- LVM2/lib/locking/no_locking.c	2010/07/09 15:34:45	1.22
+++ LVM2/lib/locking/no_locking.c	2010/08/17 16:25:33	1.23
@@ -44,11 +44,13 @@
 		case LCK_NULL:
 			return lv_deactivate(cmd, resource);
 		case LCK_UNLOCK:
-			return lv_resume_if_active(cmd, resource);
+			// FIXME Set origin_only
+			return lv_resume_if_active(cmd, resource, 0);
 		case LCK_READ:
 			return lv_activate_with_filter(cmd, resource, 0);
 		case LCK_WRITE:
-			return lv_suspend_if_active(cmd, resource);
+			// FIXME Set origin_only
+			return lv_suspend_if_active(cmd, resource, 0);
 		case LCK_EXCL:
 			return lv_activate_with_filter(cmd, resource, 1);
 		default:
--- LVM2/lib/metadata/lv_manip.c	2010/07/09 15:34:45	1.231
+++ LVM2/lib/metadata/lv_manip.c	2010/08/17 16:25:33	1.232
@@ -2237,7 +2237,7 @@
 
 	/* FIXME Ensure not referred to by another existing LVs */
 
-	if (lv_info(cmd, lv, &info, 1, 0)) {
+	if (lv_info(cmd, lv, 0, &info, 1, 0)) {
 		if (info.open_count) {
 			log_error("Can't remove open logical volume \"%s\"",
 				  lv->name);
@@ -3109,7 +3109,7 @@
 				return 0;
 			}
 
-			if (!lv_info(cmd, org, &info, 0, 0)) {
+			if (!lv_info(cmd, org, 0, &info, 0, 0)) {
 				log_error("Check for existence of snapshot "
 					  "origin '%s' failed.", org->name);
 				return 0;
--- LVM2/lib/metadata/mirror.c	2010/08/16 18:02:14	1.132
+++ LVM2/lib/metadata/mirror.c	2010/08/17 16:25:33	1.133
@@ -292,14 +292,14 @@
 	}
 
 	/* If the LV is active, deactivate it first. */
-	if (lv_info(cmd, log_lv, &info, 0, 0) && info.exists) {
+	if (lv_info(cmd, log_lv, 0, &info, 0, 0) && info.exists) {
 		(void)deactivate_lv(cmd, log_lv);
 		/*
 		 * FIXME: workaround to fail early
 		 * Ensure that log is really deactivated because deactivate_lv
 		 * on cluster do not fail if there is log_lv with different UUID.
 		 */
-		if (lv_info(cmd, log_lv, &info, 0, 0) && info.exists) {
+		if (lv_info(cmd, log_lv, 0, &info, 0, 0) && info.exists) {
 			log_error("Aborting. Unable to deactivate mirror log.");
 			goto revert_new_lv;
 		}
@@ -1587,7 +1587,7 @@
 	}
 
 	/* Had disk log, switch to core. */
-	if (lv_info(cmd, lv, &info, 0, 0) && info.exists) {
+	if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
 		if (!lv_mirror_percent(cmd, lv, 0, &sync_percent,
 				       &percent_range, NULL)) {
 			log_error("Unable to determine mirror sync status.");
@@ -1787,7 +1787,7 @@
 	 * on remote nodes (even though it is inactive on this node)
 	 */
 	if (vg_is_clustered(lv->vg) &&
-	    !(lv_info(cmd, lv, &info, 0, 0) && info.exists)) {
+	    !(lv_info(cmd, lv, 0, &info, 0, 0) && info.exists)) {
 		log_error("Unable to convert the log of inactive "
 			  "cluster mirror %s", lv->name);
 		return 0;
--- LVM2/lib/mirror/mirrored.c	2010/08/17 01:16:41	1.77
+++ LVM2/lib/mirror/mirrored.c	2010/08/17 16:25:35	1.78
@@ -296,7 +296,7 @@
 	if (!strcmp(log_args[0], "disk")) {
 		char buf[32];
 		log = first_seg(lv)->log_lv;
-		lv_info(lv->vg->cmd, log, &info, 0, 0);
+		lv_info(lv->vg->cmd, log, 0, &info, 0, 0);
 		log_debug("Found mirror log at %d:%d", info.major, info.minor);
 		sprintf(buf, "%d:%d", info.major, info.minor);
 		if (strcmp(buf, log_args[1])) {
@@ -316,7 +316,7 @@
 
 	for (i = 0; i < seg->area_count; ++i) {
 		char buf[32];
-		lv_info(lv->vg->cmd, seg_lv(seg, i), &info, 0, 0);
+		lv_info(lv->vg->cmd, seg_lv(seg, i), 0, &info, 0, 0);
 		log_debug("Found mirror leg at %d:%d", info.major, info.minor);
 		sprintf(buf, "%d:%d", info.major, info.minor);
 		for (j = 0; j < num_devs; ++j) {
--- LVM2/lib/report/report.c	2010/07/09 15:34:46	1.123
+++ LVM2/lib/report/report.c	2010/08/17 16:25:35	1.124
@@ -245,7 +245,7 @@
 	const struct logical_volume *lv = (const struct logical_volume *) data;
 	struct lvinfo info;
 
-	if (lv_info(lv->vg->cmd, lv, &info, 0, 0) && info.exists)
+	if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) && info.exists)
 		return dm_report_field_int(rh, field, &info.major);
 
 	return dm_report_field_int32(rh, field, &_minusone32);
@@ -258,7 +258,7 @@
 	const struct logical_volume *lv = (const struct logical_volume *) data;
 	struct lvinfo info;
 
-	if (lv_info(lv->vg->cmd, lv, &info, 0, 0) && info.exists)
+	if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) && info.exists)
 		return dm_report_field_int(rh, field, &info.minor);
 
 	return dm_report_field_int32(rh, field, &_minusone32);
@@ -351,7 +351,7 @@
 	else
 		repstr[3] = '-';
 
-	if (lv_info(lv->vg->cmd, lv, &info, 1, 0) && info.exists) {
+	if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) && info.exists) {
 		if (info.suspended)
 			repstr[4] = 's';	/* Suspended */
 		else if (info.live_table)
@@ -683,7 +683,7 @@
 	const struct logical_volume *lv = (const struct logical_volume *) data;
 	struct lvinfo info;
 
-	if (!lv_info(lv->vg->cmd, lv, &info, 0, 1) || !info.exists)
+	if (!lv_info(lv->vg->cmd, lv, 0, &info, 0, 1) || !info.exists)
 		return dm_report_field_int32(rh, field, &_minusone32);
 
 	return _size32_disp(rh, mem, field, &info.read_ahead, private);
@@ -1085,7 +1085,7 @@
 	}
 
 	if ((!lv_is_cow(lv) && !lv_is_merging_origin(lv)) ||
-	    !lv_info(lv->vg->cmd, lv, &info, 0, 0) || !info.exists) {
+	    !lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) || !info.exists) {
 		*sortval = UINT64_C(0);
 		dm_report_field_set_value(field, "", sortval);
 		return 1;
--- LVM2/liblvm/lvm_lv.c	2010/07/09 16:57:34	1.24
+++ LVM2/liblvm/lvm_lv.c	2010/08/17 16:25:35	1.25
@@ -57,7 +57,7 @@
 uint64_t lvm_lv_is_active(const lv_t lv)
 {
 	struct lvinfo info;
-	if (lv_info(lv->vg->cmd, lv, &info, 1, 0) &&
+	if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
 	    info.exists && info.live_table)
 		return 1;
 	return 0;
@@ -66,7 +66,7 @@
 uint64_t lvm_lv_is_suspended(const lv_t lv)
 {
 	struct lvinfo info;
-	if (lv_info(lv->vg->cmd, lv, &info, 1, 0) &&
+	if (lv_info(lv->vg->cmd, lv, 0, &info, 1, 0) &&
 	    info.exists && info.suspended)
 		return 1;
 	return 0;
--- LVM2/tools/lvchange.c	2010/08/16 22:54:37	1.123
+++ LVM2/tools/lvchange.c	2010/08/17 16:25:35	1.124
@@ -37,7 +37,7 @@
 	}
 
 	if ((lv->status & MIRRORED) && (vg_is_clustered(lv->vg)) &&
-	    lv_info(cmd, lv, &info, 0, 0) && info.exists) {
+	    lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
 		log_error("Cannot change permissions of mirror \"%s\" "
 			  "while active.", lv->name);
 		return 0;
@@ -86,7 +86,7 @@
 {
 	struct lvinfo info;
 
-	if (!lv_info(cmd, lv, &info, 0, 0) || !info.exists) {
+	if (!lv_info(cmd, lv, 0, &info, 0, 0) || !info.exists) {
 		log_error("Logical volume, %s, is not active", lv->name);
 		return 0;
 	}
@@ -96,7 +96,7 @@
 		return 1;
 
 	if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) &&
-	    !monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode()))
+	    !monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
 		return_0;
 
 	return 1;
@@ -107,7 +107,7 @@
 {
 	struct lvinfo info;
 
-	if (!lv_info(cmd, lv, &info, 0, 0) || !info.exists) {
+	if (!lv_info(cmd, lv, 0, &info, 0, 0) || !info.exists) {
 		log_error("Logical volume, %s, is not active", lv->name);
 		return 0;
 	}
@@ -189,7 +189,7 @@
 		return 0;
 	}
 
-	if (lv_info(cmd, lv, &info, 1, 0)) {
+	if (lv_info(cmd, lv, 0, &info, 1, 0)) {
 		if (info.open_count) {
 			log_error("Can't resync open logical volume \"%s\"",
 				  lv->name);
@@ -446,7 +446,7 @@
 			log_error("Major number must be specified with -My");
 			return 0;
 		}
-		if (lv_info(cmd, lv, &info, 0, 0) && info.exists)
+		if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists)
 			active = 1;
 		if (active && !arg_count(cmd, force_ARG) &&
 		    yes_no_prompt("Logical volume %s will be "
--- LVM2/tools/lvconvert.c	2010/08/06 15:38:32	1.145
+++ LVM2/tools/lvconvert.c	2010/08/17 16:25:35	1.146
@@ -1465,13 +1465,13 @@
 	 * constructor and DM should prevent appropriate devices from
 	 * being open.
 	 */
-	if (lv_info(cmd, origin, &info, 1, 0)) {
+	if (lv_info(cmd, origin, 0, &info, 1, 0)) {
 		if (info.open_count) {
 			log_error("Can't merge over open origin volume");
 			merge_on_activate = 1;
 		}
 	}
-	if (lv_info(cmd, lv, &info, 1, 0)) {
+	if (lv_info(cmd, lv, 0, &info, 1, 0)) {
 		if (info.open_count) {
 			log_print("Can't merge when snapshot is open");
 			merge_on_activate = 1;
@@ -1633,7 +1633,7 @@
 {
 	struct lvinfo info;
 
-	if (!lv_info(cmd, lv, &info, 1, 0) || !info.exists) {
+	if (!lv_info(cmd, lv, 0, &info, 1, 0) || !info.exists) {
 		log_print("Conversion starts after activation.");
 		return ECMD_PROCESSED;
 	}
--- LVM2/tools/lvresize.c	2010/04/29 01:38:14	1.122
+++ LVM2/tools/lvresize.c	2010/08/17 16:25:35	1.123
@@ -90,7 +90,7 @@
 
 	memset(&info, 0, sizeof(info));
 
-	if (!lv_info(cmd, lv, &info, 1, 0) && driver_version(NULL, 0)) {
+	if (!lv_info(cmd, lv, 0, &info, 1, 0) && driver_version(NULL, 0)) {
 		log_error("lv_info failed: aborting");
 		return 0;
 	}
@@ -572,7 +572,7 @@
 
 		memset(&info, 0, sizeof(info));
 
-		if (lv_info(cmd, lv, &info, 0, 0) && info.exists) {
+		if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
 			log_error("Snapshot origin volumes can be resized "
 				  "only while inactive: try lvchange -an");
 			return ECMD_FAILED;
--- LVM2/tools/lvscan.c	2010/07/09 15:34:48	1.41
+++ LVM2/tools/lvscan.c	2010/08/17 16:25:35	1.42
@@ -31,7 +31,7 @@
 	if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
 		return ECMD_PROCESSED;
 
-	inkernel = lv_info(cmd, lv, &info, 1, 0) && info.exists;
+	inkernel = lv_info(cmd, lv, 0, &info, 1, 0) && info.exists;
 	if (lv_is_origin(lv)) {
 		dm_list_iterate_items_gen(snap_seg, &lv->snapshot_segs,
 				       origin_list) {
--- LVM2/tools/vgchange.c	2010/08/17 01:16:41	1.112
+++ LVM2/tools/vgchange.c	2010/08/17 16:25:35	1.113
@@ -30,7 +30,7 @@
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		lv = lvl->lv;
 
-		if (!lv_info(cmd, lv, &info, 0, 0))
+		if (!lv_info(cmd, lv, 0, &info, 0, 0))
 			lv_active = 0;
 		else
 			lv_active = info.exists;
@@ -41,7 +41,7 @@
 		if ((lv->status & PVMOVE) || !lv_active)
 			continue;
 
-		if (!monitor_dev_for_events(cmd, lv, reg)) {
+		if (!monitor_dev_for_events(cmd, lv, 0, reg)) {
 			r = ECMD_FAILED;
 			continue;
 		} else
@@ -63,7 +63,7 @@
 	dm_list_iterate_items(lvl, &vg->lvs) {
 		lv = lvl->lv;
 
-		if (!lv_info(cmd, lv, &info, 0, 0))
+		if (!lv_info(cmd, lv, 0, &info, 0, 0))
 			lv_active = 0;
 		else
 			lv_active = info.exists;
--- LVM2/tools/vgconvert.c	2010/07/09 15:34:48	1.43
+++ LVM2/tools/vgconvert.c	2010/08/17 16:25:35	1.44
@@ -98,7 +98,7 @@
 				continue;
 			if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
 				continue;
-			if (lv_info(cmd, lv, &info, 0, 0) && info.exists) {
+			if (lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
 				log_error("Logical volume %s must be "
 					  "deactivated before conversion.",
 					   lv->name);
--- LVM2/tools/vgreduce.c	2010/07/09 15:34:48	1.103
+++ LVM2/tools/vgreduce.c	2010/08/17 16:25:35	1.104
@@ -108,7 +108,7 @@
 	 * the mirrored LV also should be cleaned up.
 	 * Clean-up is currently done by caller (_make_vg_consistent()).
 	 */
-	if ((lv_info(cmd, lv, &info, 0, 0) && info.exists) ||
+	if ((lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) ||
 	    find_mirror_seg(first_seg(lv))) {
 		if (!replace_lv_with_error_segment(lv))
 			return_0;


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2011-09-24 20:48 zkabelac
  0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2011-09-24 20:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-09-24 20:48:34

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c lvm-functions.c lvm-functions.h 
	man            : clvmd.8.in 

Log message:
	CLVMD bugfix support for args -S -E
	
	Bugfix:
	Add (most probably unfinished) support for -E arg with list of exclusive
	locks.  (During clvmd restart all exclusive locks would have been lost and
	in fact, if there would have been an exclusive lock, usage text would be
	printed and clvmd exits.)
	
	Instead of parsing list options multiple times every time some lock UUID is
	checked - put them straight into the hash table - make the code easier to
	understand as well.
	
	Remove  was_ex_lock() function (replaced with dm_hash_lookup()).
	
	Swap return value for get_initial_state() (1 means success).
	
	Update man pages and usage info for -E option.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2133&r2=1.2134
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.109&r2=1.110
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/clvmd.8.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7

--- LVM2/WHATS_NEW	2011/09/23 15:17:54	1.2133
+++ LVM2/WHATS_NEW	2011/09/24 20:48:34	1.2134
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix restart of clvmd (preserve exlusive locks). (2.02.64)
   Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE.
   Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV.
   Replace open_count check with holders/mounted_fs check on lvremove path.
--- LVM2/daemons/clvmd/clvmd.c	2011/09/16 14:40:07	1.109
+++ LVM2/daemons/clvmd/clvmd.c	2011/09/24 20:48:34	1.110
@@ -78,7 +78,7 @@
 };
 
 struct lvm_startup_params {
-	char **argv;
+	struct dm_hash_table *excl_uuid;
 };
 
 static debug_t debug = DEBUG_OFF;
@@ -149,6 +149,7 @@
 		"   -h       Show this help information\n"
 		"   -d[n]    Set debug logging (0:none, 1:stderr (implies -f option), 2:syslog)\n"
 		"   -f       Don't fork, run in the foreground\n"
+		"   -E<lockuuid> Take this lock uuid as exclusively locked resource (for restart)\n"
 		"   -R       Tell all running clvmds in the cluster to reload their device cache\n"
 		"   -S       Restart clvmd, preserving exclusive locks\n"
 		"   -C       Sets debug level (from -d) on all clvmd instances clusterwide\n"
@@ -348,6 +349,11 @@
 		{ NULL, 0, 0, 0 }
 	};
 
+	if (!(lvm_params.excl_uuid = dm_hash_create(128))) {
+		fprintf(stderr, "Failed to allocate hash table\n");
+		return 1;
+	}
+
 	/* Deal with command-line arguments */
 	opterr = 0;
 	optind = 0;
@@ -391,6 +397,12 @@
 		case 'I':
 			cluster_iface = parse_cluster_interface(optarg);
 			break;
+		case 'E':
+			if (!dm_hash_insert(lvm_params.excl_uuid, optarg, optarg)) {
+				fprintf(stderr, "Failed to allocate hash entry\n");
+				return 1;
+			}
+			break;
 		case 'T':
 			start_timeout = atoi(optarg);
 			if (start_timeout <= 0) {
@@ -565,7 +577,6 @@
 
 	/* Don't let anyone else to do work until we are started */
 	pthread_mutex_lock(&lvm_start_mutex);
-	lvm_params.argv = argv;
 	pthread_create(&lvm_thread, NULL, lvm_thread_fn, &lvm_params);
 
 	/* Tell the rest of the cluster our version number */
@@ -603,6 +614,8 @@
 		free(delfd);
 	}
 
+	dm_hash_destroy(lvm_params.excl_uuid);
+
 	return 0;
 }
 
@@ -1978,7 +1991,7 @@
 	pthread_sigmask(SIG_BLOCK, &ss, NULL);
 
 	/* Initialise the interface to liblvm */
-	init_clvm(lvm_params->argv);
+	init_clvm(lvm_params->excl_uuid);
 
 	/* Allow others to get moving */
 	pthread_mutex_unlock(&lvm_start_mutex);
--- LVM2/daemons/clvmd/lvm-functions.c	2011/08/10 20:25:29	1.122
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/09/24 20:48:34	1.123
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -694,34 +694,11 @@
 }
 
 /*
- * Compare the uuid with the list of exclusive locks that clvmd
- * held before it was restarted, so we can get the right kind
- * of lock now we are restarting.
- */
-static int was_ex_lock(char *uuid, char **argv)
-{
-	int optnum = 0;
-	char *opt = argv[optnum];
-
-	while (opt) {
-		if (strcmp(opt, "-E") == 0) {
-			opt = argv[++optnum];
-			if (opt && (strcmp(opt, uuid) == 0)) {
-				DEBUGLOG("Lock %s is exclusive\n", uuid);
-				return 1;
-			}
-		}
-		opt = argv[++optnum];
-	}
-	return 0;
-}
-
-/*
  * Ideally, clvmd should be started before any LVs are active
  * but this may not be the case...
  * I suppose this also comes in handy if clvmd crashes, not that it would!
  */
-static int get_initial_state(char **argv)
+static int get_initial_state(struct dm_hash_table *excl_uuid)
 {
 	int lock_mode;
 	char lv[64], vg[64], flags[25], vg_flags[25];
@@ -733,7 +710,7 @@
 	     "r");
 
 	if (!lvs)
-		return 1;
+		return 0;
 
 	while (fgets(line, sizeof(line), lvs)) {
 	        if (sscanf(line, "%s %s %s %s\n", vg, lv, flags, vg_flags) == 4) {
@@ -759,12 +736,10 @@
 				memcpy(&uuid[58], &lv[32], 6);
 				uuid[64] = '\0';
 
-				lock_mode = LCK_READ;
-
 				/* Look for this lock in the list of EX locks
 				   we were passed on the command-line */
-				if (was_ex_lock(uuid, argv))
-					lock_mode = LCK_EXCL;
+				lock_mode = (dm_hash_lookup(excl_uuid, uuid)) ?
+					LCK_EXCL : LCK_READ;
 
 				DEBUGLOG("getting initial lock for %s\n", uuid);
 				hold_lock(uuid, lock_mode, LCKF_NOQUEUE);
@@ -773,7 +748,8 @@
 	}
 	if (fclose(lvs))
 		DEBUGLOG("lvs fclose failed: %s\n", strerror(errno));
-	return 0;
+
+	return 1;
 }
 
 static void lvm2_log_fn(int level, const char *file, int line, int dm_errno,
@@ -880,14 +856,14 @@
 }
 
 /* Called to initialise the LVM context of the daemon */
-int init_clvm(char **argv)
+int init_clvm(struct dm_hash_table *excl_uuid)
 {
 	/* Use LOG_DAEMON for syslog messages instead of LOG_USER */
 	init_syslog(LOG_DAEMON);
 	openlog("clvmd", LOG_PID, LOG_DAEMON);
 
 	/* Initialise already held locks */
-	if (get_initial_state(argv))
+	if (!get_initial_state(excl_uuid))
 		log_error("Cannot load initial lock states.");
 
 	if (!(cmd = create_toolcontext(1, NULL, 0))) {
--- LVM2/daemons/clvmd/lvm-functions.h	2011/08/09 18:11:00	1.16
+++ LVM2/daemons/clvmd/lvm-functions.h	2011/09/24 20:48:34	1.17
@@ -27,7 +27,7 @@
 			char *resource);
 extern int do_check_lvm1(const char *vgname);
 extern int do_refresh_cache(void);
-extern int init_clvm(char **argv);
+extern int init_clvm(struct dm_hash_table *excl_uuid);
 extern void destroy_lvm(void);
 extern void init_lvhash(void);
 extern void destroy_lvhash(void);
--- LVM2/man/clvmd.8.in	2011/08/09 18:11:00	1.6
+++ LVM2/man/clvmd.8.in	2011/09/24 20:48:34	1.7
@@ -4,6 +4,7 @@
 .SH SYNOPSIS
 .B clvmd
 [\-d[<value>]] [\-C] [\-h]
+[\-E <lock uuid>]
 [\-R]
 [\-S]
 [\-t <timeout>]
@@ -69,6 +70,9 @@
 .br
 This timeout will be ignored if you start clvmd with the -d switch.
 .TP
+.I \-E <lock uuid>
+Pass lock uuid to be reacquired exclusively when clvmd is restarted.
+.TP
 .I \-R
 Tells all the running clvmds in the cluster to reload their device cache and
 re-read the lvm configuration file. This command should be run whenever the


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-29 20:30:09

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c lvm-functions.c 
	daemons/dmeventd: dmeventd.c 
	lib/activate   : dev_manager.c 
	lib/misc       : lvm-globals.c 

Log message:
	Fix -Wold-style-definition gcc warnings

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1958&r2=1.1959
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.215&r2=1.216
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10

--- LVM2/WHATS_NEW	2011/03/24 16:03:32	1.1958
+++ LVM2/WHATS_NEW	2011/03/29 20:30:05	1.1959
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fix -Wold-style-definition gcc warnings.
   Fixes for lvconvert (including --repair) of temporary mirror stacks.
   Mitigate annoying error warning from device is usable check if run as non-root.
   Add missing \0 for grown debug object in _bitset_with_random_bits().
--- LVM2/daemons/clvmd/clvmd.c	2011/03/08 22:48:50	1.100
+++ LVM2/daemons/clvmd/clvmd.c	2011/03/29 20:30:06	1.101
@@ -609,7 +609,7 @@
 
 /* Called when the GuLM cluster layer has completed initialisation.
    We send the version message */
-void clvmd_cluster_init_completed()
+void clvmd_cluster_init_completed(void)
 {
 	send_version_message();
 }
@@ -802,9 +802,10 @@
 /* This is where the real work happens */
 static void main_loop(int local_sock, int cmd_timeout)
 {
+	sigset_t ss;
+
 	DEBUGLOG("Using timeout of %d seconds\n", cmd_timeout);
 
-	sigset_t ss;
 	sigemptyset(&ss);
 	sigaddset(&ss, SIGINT);
 	sigaddset(&ss, SIGTERM);
@@ -1826,7 +1827,7 @@
 }
 
 /* Send our version number to the cluster */
-static void send_version_message()
+static void send_version_message(void)
 {
 	char message[sizeof(struct clvm_header) + sizeof(int) * 3];
 	struct clvm_header *msg = (struct clvm_header *) message;
@@ -2056,7 +2057,7 @@
 }
 
 /* Open the local socket, that's the one we talk to libclvm down */
-static int open_local_sock()
+static int open_local_sock(void)
 {
 	int local_socket = -1;
 	struct sockaddr_un sockaddr;
@@ -2218,7 +2219,7 @@
  * only called if the command-line option is not present, and if it fails
  * we still try the interfaces in order.
  */
-static if_type_t get_cluster_type()
+static if_type_t get_cluster_type(void)
 {
 #ifdef HAVE_COROSYNC_CONFDB_H
 	confdb_handle_t handle;
--- LVM2/daemons/clvmd/lvm-functions.c	2011/03/02 23:38:22	1.114
+++ LVM2/daemons/clvmd/lvm-functions.c	2011/03/29 20:30:06	1.115
@@ -147,7 +147,7 @@
 	return buf;
 }
 
-char *get_last_lvm_error()
+char *get_last_lvm_error(void)
 {
 	return last_error;
 }
@@ -194,7 +194,7 @@
 }
 
 
-void init_lvhash()
+void init_lvhash(void)
 {
 	/* Create hash table for keeping LV locks & status */
 	lv_hash = dm_hash_create(1024);
@@ -203,7 +203,7 @@
 }
 
 /* Called at shutdown to tidy the lockspace */
-void destroy_lvhash()
+void destroy_lvhash(void)
 {
 	struct dm_hash_node *v;
 	struct lv_info *lvi;
@@ -621,7 +621,7 @@
 	return status == 1 ? 0 : EBUSY;
 }
 
-int do_refresh_cache()
+int do_refresh_cache(void)
 {
 	DEBUGLOG("Refreshing context\n");
 	log_notice("Refreshing context");
--- LVM2/daemons/dmeventd/dmeventd.c	2011/03/02 14:20:48	1.77
+++ LVM2/daemons/dmeventd/dmeventd.c	2011/03/29 20:30:06	1.78
@@ -1225,6 +1225,7 @@
 static int _open_fifos(struct dm_event_fifos *fifos)
 {
 	int orig_errno;
+	struct stat st;
 
 	/* Create client fifo. */
 	(void) dm_prepare_selinux_context(fifos->client_path, S_IFIFO);
@@ -1248,8 +1249,6 @@
 
 	(void) dm_prepare_selinux_context(NULL, 0);
 
-	struct stat st;
-
 	/* Warn about wrong permissions if applicable */
 	if ((!stat(fifos->client_path, &st)) && (st.st_mode & 0777) != 0600)
 		syslog(LOG_WARNING, "Fixing wrong permissions on %s",
--- LVM2/lib/activate/dev_manager.c	2011/03/18 12:17:58	1.215
+++ LVM2/lib/activate/dev_manager.c	2011/03/29 20:30:08	1.216
@@ -1104,7 +1104,7 @@
 	char errid[32];
 	struct dm_tree_node *node;
 	struct lv_segment *seg_i;
-	int segno = -1, i = 0;;
+	int segno = -1, i = 0;
 	uint64_t size = seg->len * seg->lv->vg->extent_size;
 
 	dm_list_iterate_items(seg_i, &seg->lv->segments) {
--- LVM2/lib/misc/lvm-globals.c	2011/02/18 14:11:23	1.9
+++ LVM2/lib/misc/lvm-globals.c	2011/03/29 20:30:08	1.10
@@ -147,7 +147,7 @@
 	_sysfs_dir_path[sizeof(_sysfs_dir_path) - 1] = '\0';
 }
 
-const char *log_command_name()
+const char *log_command_name(void)
 {
 	if (!_log_cmd_name)
 		return "";
@@ -165,42 +165,42 @@
 	return _error_message_produced;
 }
 
-int test_mode()
+int test_mode(void)
 {
 	return _test;
 }
 
-int md_filtering()
+int md_filtering(void)
 {
 	return _md_filtering;
 }
 
-int pvmove_mode()
+int pvmove_mode(void)
 {
 	return _pvmove;
 }
 
-int full_scan_done()
+int full_scan_done(void)
 {
 	return _full_scan_done;
 }
 
-int trust_cache()
+int trust_cache(void)
 {
 	return _trust_cache;
 }
 
-int background_polling()
+int background_polling(void)
 {
 	return _background_polling;
 }
 
-int ignorelockingfailure()
+int ignorelockingfailure(void)
 {
 	return _ignorelockingfailure;
 }
 
-int security_level()
+int security_level(void)
 {
 	return _security_level;
 }
@@ -225,12 +225,12 @@
 	_debug_level = level;
 }
 
-int verbose_level()
+int verbose_level(void)
 {
 	return _verbose_level;
 }
 
-int debug_level()
+int debug_level(void)
 {
 	return _debug_level;
 }
@@ -245,7 +245,7 @@
 	return _udev_checking;
 }
 
-const char *sysfs_dir_path()
+const char *sysfs_dir_path(void)
 {
 	return _sysfs_dir_path;
 }


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

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

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

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c clvmd.h 
	lib/activate   : activate.c activate.h 
	lib/filters    : filter-regex.c 
	lib/metadata   : lv.h lv_manip.c metadata-exported.h metadata.c 
	                 mirror.c 
	lib/report     : properties.c report.c 
	lib/uuid       : uuid.c 
	liblvm         : lvm_vg.c 
	tools          : lvcreate.c reporter.c toollib.c toollib.h 
	                 vgcfgrestore.c vgcreate.c vgextend.c vgmerge.c 
	                 vgreduce.c vgrename.c vgsplit.c 

Log message:
	Const fixing
	
	Fixing some const warnings - with API change in:
	
	int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
	
	Change is needed - as lvm2api expects const behaviour here.
	So vg_extend() is doing local strdup for unescaping.
	
	skip_dev_dir return const char* from const char* vg_name.
	
	Rest of the patch is cleanup of related warnings.
	
	Also using dm_report_filed_string() API change to simplify
	casting in _string_disp and _lvname_disp.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1919&r2=1.1920
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.h.diff?cvsroot=lvm2&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.195&r2=1.196
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-regex.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.247&r2=1.248
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.175&r2=1.176
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.423&r2=1.424
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.142&r2=1.143
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/properties.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/uuid/uuid.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_vg.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.228&r2=1.229
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.219&r2=1.220
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.76&r2=1.77
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcfgrestore.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgextend.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.105&r2=1.106
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105

--- LVM2/WHATS_NEW	2011/02/18 14:34:41	1.1919
+++ LVM2/WHATS_NEW	2011/02/18 14:47:28	1.1920
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Fixing some const cast gcc warnings in the code.
   Use char* arithmetic in _text_write(), _text_read() & send_message().
   Fix compilation when devmapper is dissabled.
   Remove fs_unlock() from lv_suspend error path.
--- LVM2/daemons/clvmd/clvmd.c	2011/02/18 14:34:41	1.94
+++ LVM2/daemons/clvmd/clvmd.c	2011/02/18 14:47:29	1.95
@@ -2091,7 +2091,7 @@
 	return -1;
 }
 
-void process_message(struct local_client *client, const char *buf, int len,
+void process_message(struct local_client *client, char *buf, int len,
 		     const char *csid)
 {
 	struct clvm_header *inheader;
--- LVM2/daemons/clvmd/clvmd.h	2011/01/17 23:13:14	1.13
+++ LVM2/daemons/clvmd/clvmd.h	2011/02/18 14:47:29	1.14
@@ -112,7 +112,7 @@
 extern int add_client(struct local_client *new_client);
 
 extern void clvmd_cluster_init_completed(void);
-extern void process_message(struct local_client *client, const char *buf,
+extern void process_message(struct local_client *client, char *buf,
 			    int len, const char *csid);
 extern void debuglog(const char *fmt, ... )
   __attribute__ ((format(printf, 1, 2)));
--- LVM2/lib/activate/activate.c	2011/02/18 14:29:39	1.195
+++ LVM2/lib/activate/activate.c	2011/02/18 14:47:29	1.196
@@ -162,7 +162,7 @@
 {
 	return 0;
 }
-int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
+int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
 		      int wait, percent_t *percent, uint32_t *event_nr)
 {
 	return 0;
@@ -568,7 +568,7 @@
 }
 
 /* FIXME Merge with snapshot_percent */
-int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
+int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
 		      int wait, percent_t *percent, uint32_t *event_nr)
 {
 	int r;
--- LVM2/lib/activate/activate.h	2011/02/18 00:36:05	1.75
+++ LVM2/lib/activate/activate.h	2011/02/18 14:47:29	1.76
@@ -85,7 +85,7 @@
  * Returns 1 if percent has been set, else 0.
  */
 int lv_snapshot_percent(const struct logical_volume *lv, percent_t *percent);
-int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
+int lv_mirror_percent(struct cmd_context *cmd, const struct logical_volume *lv,
 		      int wait, percent_t *percent, uint32_t *event_nr);
 
 /*
--- LVM2/lib/filters/filter-regex.c	2010/12/20 13:45:40	1.30
+++ LVM2/lib/filters/filter-regex.c	2011/02/18 14:47:30	1.31
@@ -135,7 +135,7 @@
 	/*
 	 * build the matcher.
 	 */
-	if (!(rf->engine = dm_regex_create(rf->mem, (const char **) regex,
+	if (!(rf->engine = dm_regex_create(rf->mem, (const char * const*) regex,
 					   count)))
 		goto_out;
 	r = 1;
--- LVM2/lib/metadata/lv.h	2010/11/17 20:08:14	1.17
+++ LVM2/lib/metadata/lv.h	2011/02/18 14:47:30	1.18
@@ -23,7 +23,7 @@
 
 struct logical_volume {
 	union lvid lvid;
-	char *name;
+	const char *name;
 
 	struct volume_group *vg;
 
--- LVM2/lib/metadata/lv_manip.c	2011/02/04 20:30:18	1.247
+++ LVM2/lib/metadata/lv_manip.c	2011/02/18 14:47:30	1.248
@@ -1897,7 +1897,8 @@
 			  struct logical_volume *lv,
 			  const char *lv_name_old, const char *lv_name_new)
 {
-	char *suffix, *new_name;
+	const char *suffix;
+	char *new_name;
 	size_t len;
 
 	/*
--- LVM2/lib/metadata/metadata-exported.h	2011/02/18 14:11:23	1.175
+++ LVM2/lib/metadata/metadata-exported.h	2011/02/18 14:47:30	1.176
@@ -410,9 +410,9 @@
 int vg_remove(struct volume_group *vg);
 int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
 	      const char *new_name);
-int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
+int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
 	      struct pvcreate_params *pp);
-int vg_reduce(struct volume_group *vg, char *pv_name);
+int vg_reduce(struct volume_group *vg, const char *pv_name);
 int vg_change_tag(struct volume_group *vg, const char *tag, int add_tag);
 int vg_split_mdas(struct cmd_context *cmd, struct volume_group *vg_from,
 		  struct volume_group *vg_to);
@@ -698,7 +698,7 @@
 						  uint32_t lv_type);
 const char *get_pvmove_pvname_from_lv(struct logical_volume *lv);
 const char *get_pvmove_pvname_from_lv_mirr(struct logical_volume *lv_mirr);
-percent_t copy_percent(struct logical_volume *lv_mirr);
+percent_t copy_percent(const struct logical_volume *lv_mirr);
 struct dm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
 			  struct logical_volume *lv);
 
@@ -721,7 +721,7 @@
 int vg_has_unknown_segments(const struct volume_group *vg);
 
 struct vgcreate_params {
-	char *vg_name;
+	const char *vg_name;
 	uint32_t extent_size;
 	size_t max_pv;
 	size_t max_lv;
--- LVM2/lib/metadata/metadata.c	2011/02/18 14:16:12	1.423
+++ LVM2/lib/metadata/metadata.c	2011/02/18 14:47:30	1.424
@@ -662,33 +662,38 @@
  * - pp: parameters to pass to implicit pvcreate; if NULL, do not pvcreate
  *
  */
-int vg_extend(struct volume_group *vg, int pv_count, char **pv_names,
+int vg_extend(struct volume_group *vg, int pv_count, const char *const *pv_names,
 	      struct pvcreate_params *pp)
 {
 	int i;
+	char *pv_name;
 
 	if (_vg_bad_status_bits(vg, RESIZEABLE_VG))
 		return 0;
 
 	/* attach each pv */
 	for (i = 0; i < pv_count; i++) {
-		unescape_colons_and_at_signs(pv_names[i], NULL, NULL);
-		if (!vg_extend_single_pv(vg, pv_names[i], pp))
-			goto bad;
+		if (!(pv_name = dm_strdup(pv_names[i]))) {
+			log_error("Failed to duplicate pv name %s.", pv_names[i]);
+			return 0;
+		}
+		unescape_colons_and_at_signs(pv_name, NULL, NULL);
+		if (!vg_extend_single_pv(vg, pv_name, pp)) {
+			log_error("Unable to add physical volume '%s' to "
+				  "volume group '%s'.", pv_name, vg->name);
+			dm_free(pv_name);
+			return 0;
+		}
+		dm_free(pv_name);
 	}
 
 /* FIXME Decide whether to initialise and add new mdahs to format instance */
 
 	return 1;
-
-      bad:
-	log_error("Unable to add physical volume '%s' to "
-		  "volume group '%s'.", pv_names[i], vg->name);
-	return 0;
 }
 
 /* FIXME: use this inside vgreduce_single? */
-int vg_reduce(struct volume_group *vg, char *pv_name)
+int vg_reduce(struct volume_group *vg, const char *pv_name)
 {
 	struct physical_volume *pv;
 	struct pv_list *pvl;
@@ -1875,7 +1880,7 @@
 {
 	struct lv_list *lvl1, *lvl2;
 	struct pv_list *pvl;
-	char *name1, *name2;
+	const char *name1, *name2;
 
 	if (lvs_in_vg_activated(vg_from)) {
 		log_error("Logical volumes in \"%s\" must be inactive",
--- LVM2/lib/metadata/mirror.c	2011/02/18 14:16:12	1.142
+++ LVM2/lib/metadata/mirror.c	2011/02/18 14:47:30	1.143
@@ -1514,7 +1514,7 @@
 	return lvs;
 }
 
-percent_t copy_percent(struct logical_volume *lv_mirr)
+percent_t copy_percent(const struct logical_volume *lv_mirr)
 {
 	uint32_t numerator = 0u, denominator = 0u;
 	struct lv_segment *seg;
@@ -1727,8 +1727,8 @@
 						 int in_sync)
 {
 	struct logical_volume *log_lv;
-	const char *suffix, *c;
-	char *lv_name;
+	const char *suffix, *lv_name;
+	char *tmp_name;
 	size_t len;
 	struct lv_segment *seg;
 
@@ -1747,21 +1747,21 @@
 	    strstr(seg_lv(seg, 0)->name, MIRROR_SYNC_LAYER)) {
 		lv_name = lv->name;
 		suffix = "_mlogtmp_%d";
-	} else if ((c = strstr(lv->name, MIRROR_SYNC_LAYER))) {
-		len = c - lv->name + 1;
-		if (!(lv_name = alloca(len)) ||
-		    !dm_snprintf(lv_name, len, "%s", lv->name)) {
+	} else if ((lv_name = strstr(lv->name, MIRROR_SYNC_LAYER))) {
+		len = lv_name - lv->name + 1;
+		if (!(tmp_name = alloca(len)) ||
+		    !dm_snprintf(tmp_name, len, "%s", lv->name)) {
 			log_error("mirror log name allocation failed");
 			return 0;
 		}
+		lv_name = tmp_name;
 		suffix = "_mlog";
 	} else {
 		lv_name = lv->name;
 		suffix = "_mlog";
 	}
 
-	if (!(log_lv = _create_mirror_log(lv, ah, alloc,
-					  (const char *) lv_name, suffix))) {
+	if (!(log_lv = _create_mirror_log(lv, ah, alloc, lv_name, suffix))) {
 		log_error("Failed to create mirror log.");
 		return NULL;
 	}
--- LVM2/lib/report/properties.c	2011/01/05 12:33:52	1.28
+++ LVM2/lib/report/properties.c	2011/02/18 14:47:30	1.29
@@ -88,8 +88,7 @@
 
 static percent_t _copy_percent(const struct logical_volume *lv) {
 	percent_t perc;
-	if (!lv_mirror_percent(lv->vg->cmd, (struct logical_volume *) lv,
-			   0, &perc, NULL))
+	if (!lv_mirror_percent(lv->vg->cmd, lv, 0, &perc, NULL))
 		perc = PERCENT_INVALID;
 	return perc;
 }
--- LVM2/lib/report/report.c	2010/11/30 11:53:32	1.141
+++ LVM2/lib/report/report.c	2011/02/18 14:47:30	1.142
@@ -44,7 +44,7 @@
 			struct dm_report_field *field,
 			const void *data, void *private __attribute__((unused)))
 {
-	return dm_report_field_string(rh, field, (const char **) data);
+	return dm_report_field_string(rh, field, (const char * const *) data);
 }
 
 static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem __attribute__((unused)),
@@ -307,10 +307,8 @@
 	char *repstr, *lvname;
 	size_t len;
 
-	if (lv_is_visible(lv)) {
-		repstr = lv->name;
-		return dm_report_field_string(rh, field, (const char **) &repstr);
-	}
+	if (lv_is_visible(lv))
+		return dm_report_field_string(rh, field, &lv->name);
 
 	len = strlen(lv->name) + 3;
 	if (!(repstr = dm_pool_zalloc(mem, len))) {
@@ -615,7 +613,7 @@
 {
 	char *repstr = NULL;
 
-	if (!(repstr = id_format_and_copy(mem, (struct id *)data)))
+	if (!(repstr = id_format_and_copy(mem, data)))
 		return_0;
 
 	dm_report_field_set_value(field, repstr, NULL);
@@ -853,7 +851,7 @@
 			     struct dm_report_field *field,
 			     const void *data, void *private __attribute__((unused)))
 {
-	struct logical_volume *lv = (struct logical_volume *) data;
+	const struct logical_volume *lv = (const struct logical_volume *) data;
 	percent_t percent;
 	uint64_t *sortval;
 	char *repstr;
@@ -899,7 +897,7 @@
 
 static struct volume_group _dummy_vg = {
 	.fid = &_dummy_fid,
-	.name = (char *) "",
+	.name = "",
 	.system_id = (char *) "",
 	.pvs = { &(_dummy_vg.pvs), &(_dummy_vg.pvs) },
 	.lvs = { &(_dummy_vg.lvs), &(_dummy_vg.lvs) },
--- LVM2/lib/uuid/uuid.c	2011/01/28 10:14:09	1.32
+++ LVM2/lib/uuid/uuid.c	2011/02/18 14:47:30	1.33
@@ -158,7 +158,7 @@
 {
 	int i, tot;
 
-	static unsigned group_size[] = { 6, 4, 4, 4, 4, 4, 6 };
+	static const unsigned group_size[] = { 6, 4, 4, 4, 4, 4, 6 };
 
 	assert(ID_LEN == 32);
 
--- LVM2/liblvm/lvm_vg.c	2010/12/14 23:20:58	1.50
+++ LVM2/liblvm/lvm_vg.c	2011/02/18 14:47:30	1.51
@@ -79,7 +79,7 @@
 	}
 
 	pvcreate_params_set_defaults(&pp);
-	if (!vg_extend(vg, 1, (char **) &device, &pp)) {
+	if (!vg_extend(vg, 1, &device, &pp)) {
 		unlock_vg(vg->cmd, VG_ORPHANS);
 		return -1;
 	}
@@ -98,7 +98,7 @@
 	if (!vg_check_write_mode(vg))
 		return -1;
 
-	if (!vg_reduce(vg, (char *)device))
+	if (!vg_reduce(vg, device))
 		return -1;
 	return 0;
 }
--- LVM2/tools/lvcreate.c	2011/01/11 17:05:10	1.228
+++ LVM2/tools/lvcreate.c	2011/02/18 14:47:31	1.229
@@ -31,7 +31,7 @@
 {
 	int argc = *pargc;
 	char **argv = *pargv, *ptr;
-	char *vg_name;
+	const char *vg_name;
 
 	lp->lv_name = arg_str_value(cmd, name_ARG, NULL);
 
--- LVM2/tools/reporter.c	2010/12/08 20:50:51	1.64
+++ LVM2/tools/reporter.c	2011/02/18 14:47:31	1.65
@@ -61,7 +61,7 @@
 
 	struct volume_group _free_vg = {
 		.cmd = cmd,
-		.name = (char *)"",
+		.name = "",
 	};
 
         if (!(_free_vg.vgmem = dm_pool_create("_free_vg", 10240)))
@@ -69,7 +69,7 @@
 
 	struct logical_volume _free_logical_volume = {
 		.vg = vg ?: &_free_vg,
-		.name = (char *) "",
+		.name = "",
 		.snapshot = NULL,
 		.status = VISIBLE_LV,
 		.major = -1,
--- LVM2/tools/toollib.c	2011/01/24 13:38:32	1.219
+++ LVM2/tools/toollib.c	2011/02/18 14:47:31	1.220
@@ -28,7 +28,7 @@
 /*
  * Strip dev_dir if present
  */
-char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
+const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
 		   unsigned *dev_dir_found)
 {
 	const char *dmdir = dm_dir();
@@ -54,7 +54,7 @@
 		    *layer) {
 			log_error("skip_dev_dir: Couldn't split up device name %s",
 				  vg_name);
-			return (char *) vg_name;
+			return vg_name;
 		}
 		vglv_sz = strlen(vgname) + strlen(lvname) + 2;
 		if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
@@ -62,7 +62,7 @@
 				 *lvname ? "/" : "",
 				 lvname) < 0) {
 			log_error("vg/lv string alloc failed");
-			return (char *) vg_name;
+			return vg_name;
 		}
 		return vglv;
 	}
@@ -76,7 +76,7 @@
 	} else if (dev_dir_found)
 		*dev_dir_found = 0;
 
-	return (char *) vg_name;
+	return vg_name;
 }
 
 /*
@@ -898,7 +898,7 @@
  */
 char *default_vgname(struct cmd_context *cmd)
 {
-	char *vg_path;
+	const char *vg_path;
 
 	/* Take default VG from environment? */
 	vg_path = getenv("LVM_VG_NAME");
--- LVM2/tools/toollib.h	2011/01/24 13:38:32	1.76
+++ LVM2/tools/toollib.h	2011/02/18 14:47:31	1.77
@@ -84,8 +84,8 @@
 
 char *default_vgname(struct cmd_context *cmd);
 const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
-char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
-		   unsigned *dev_dir_found);
+const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
+			 unsigned *dev_dir_found);
 
 /*
  * Builds a list of pv's from the names in argv.  Used in
--- LVM2/tools/vgcfgrestore.c	2009/10/16 17:41:53	1.24
+++ LVM2/tools/vgcfgrestore.c	2011/02/18 14:47:31	1.25
@@ -17,7 +17,7 @@
 
 int vgcfgrestore(struct cmd_context *cmd, int argc, char **argv)
 {
-	char *vg_name = NULL;
+	const char *vg_name = NULL;
 
 	if (argc == 1) {
 		vg_name = skip_dev_dir(cmd, argv[0], NULL);
--- LVM2/tools/vgcreate.c	2010/12/08 20:50:51	1.82
+++ LVM2/tools/vgcreate.c	2011/02/18 14:47:31	1.83
@@ -74,7 +74,7 @@
 	}
 
 	/* attach the pv's */
-	if (!vg_extend(vg, argc, argv, &pp))
+	if (!vg_extend(vg, argc, (const char* const*)argv, &pp))
 		goto_bad;
 
 	if (vp_new.max_lv != vg->max_lv)
--- LVM2/tools/vgextend.c	2010/12/08 20:50:51	1.62
+++ LVM2/tools/vgextend.c	2011/02/18 14:47:31	1.63
@@ -40,7 +40,7 @@
 
 int vgextend(struct cmd_context *cmd, int argc, char **argv)
 {
-	char *vg_name;
+	const char *vg_name;
 	struct volume_group *vg = NULL;
 	int r = ECMD_FAILED;
 	struct pvcreate_params pp;
@@ -107,7 +107,7 @@
 		}
 
 		/* extend vg */
-		if (!vg_extend(vg, argc, argv, &pp))
+		if (!vg_extend(vg, argc, (const char* const*)argv, &pp))
 			goto_bad;
 
 		if (arg_count(cmd, metadataignore_ARG) &&
--- LVM2/tools/vgmerge.c	2010/12/14 17:51:10	1.71
+++ LVM2/tools/vgmerge.c	2011/02/18 14:47:31	1.72
@@ -163,7 +163,7 @@
 
 int vgmerge(struct cmd_context *cmd, int argc, char **argv)
 {
-	char *vg_name_to, *vg_name_from;
+	const char *vg_name_to, *vg_name_from;
 	int opt = 0;
 	int ret = 0, ret_max = 0;
 
--- LVM2/tools/vgreduce.c	2010/12/08 20:50:51	1.105
+++ LVM2/tools/vgreduce.c	2011/02/18 14:47:31	1.106
@@ -457,7 +457,7 @@
 int vgreduce(struct cmd_context *cmd, int argc, char **argv)
 {
 	struct volume_group *vg;
-	char *vg_name;
+	const char *vg_name;
 	int ret = ECMD_FAILED;
 	int fixed = 1;
 	int repairing = arg_count(cmd, removemissing_ARG);
--- LVM2/tools/vgrename.c	2010/12/22 15:36:42	1.74
+++ LVM2/tools/vgrename.c	2011/02/18 14:47:31	1.75
@@ -63,7 +63,7 @@
 	int found_id = 0;
 	struct dm_list *vgids;
 	struct str_list *sl;
-	char *vg_name_new;
+	const char *vg_name_new;
 	const char *vgid = NULL, *vg_name, *vg_name_old;
 	char old_path[NAME_LEN], new_path[NAME_LEN];
 	struct volume_group *vg = NULL;
--- LVM2/tools/vgsplit.c	2010/12/14 17:51:10	1.104
+++ LVM2/tools/vgsplit.c	2011/02/18 14:47:31	1.105
@@ -281,7 +281,7 @@
 {
 	struct vgcreate_params vp_new;
 	struct vgcreate_params vp_def;
-	char *vg_name_from, *vg_name_to;
+	const char *vg_name_from, *vg_name_to;
 	struct volume_group *vg_to = NULL, *vg_from = NULL;
 	int opt;
 	int existing_vg = 0;


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2010-04-13 19:54 zkabelac
  0 siblings, 0 replies; 11+ messages in thread
From: zkabelac @ 2010-04-13 19:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-04-13 19:54:17

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

Log message:
	Use C locales and use_mlockall for clvmd.
	
	Use same steps for clvmd as for dmeventd - using C locales to avoid reading
	large mmaps and use mlockall() for threaded version.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1514&r2=1.1515
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88

--- LVM2/WHATS_NEW	2010/04/13 18:18:54	1.1514
+++ LVM2/WHATS_NEW	2010/04/13 19:54:16	1.1515
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Use C locales and use_mlockall for clvmd.
   Refactor code related to vg->pvs list and add pv->vg link.
   Mask LCK_HOLD flag in cluster VG locks for compatibility reasons.
   Add activation/polling_interval to lvm.conf as --interval default.
--- LVM2/daemons/clvmd/clvmd.c	2010/04/06 15:29:30	1.65
+++ LVM2/daemons/clvmd/clvmd.c	2010/04/13 19:54:16	1.66
@@ -360,6 +360,13 @@
 		return debug_clvmd(debug, clusterwide_opt)==1?0:1;
 	}
 
+	/*
+	 * Switch to C locale to avoid reading large locale-archive file
+	 * used by some glibc (on some distributions it takes over 100MB).
+	 * Daemon currently needs to use mlockall().
+	 */
+	setenv("LANG", "C", 1);
+
 	/* Fork into the background (unless requested not to) */
 	if (debug != DEBUG_STDERR) {
 		be_daemon(start_timeout);
--- LVM2/daemons/clvmd/lvm-functions.c	2010/03/26 15:40:14	1.87
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/04/13 19:54:16	1.88
@@ -878,13 +878,16 @@
 
 	/* Trap log messages so we can pass them back to the user */
 	init_log_fn(lvm2_log_fn);
+	memlock_inc_daemon(cmd);
 
 	return 1;
 }
 
 void destroy_lvm(void)
 {
-	if (cmd)
+	if (cmd) {
+		memlock_dec_daemon(cmd);
 		destroy_toolcontext(cmd);
+	}
 	cmd = NULL;
 }


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-15 12:15:24

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

Log message:
	Destroy toolcontext on exit in clvmd (fixes memory pool leaks).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1149&r2=1.1150
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.h.diff?cvsroot=lvm2&r1=1.10&r2=1.11

--- LVM2/WHATS_NEW	2009/06/15 12:08:59	1.1149
+++ LVM2/WHATS_NEW	2009/06/15 12:15:23	1.1150
@@ -1,5 +1,6 @@
 Version 2.02.48 - 
 ===============================
+  Destroy toolcontext on exit in clvmd (fixes memory pool leaks).
   Fix lvconvert to not poll mirror if no conversion in progress.
   Fix memory leaks in toolcontext error path.
   Re-instate partial activation support in clustered mode. (2.02.40)
--- LVM2/daemons/clvmd/clvmd.c	2009/05/19 10:39:00	1.58
+++ LVM2/daemons/clvmd/clvmd.c	2009/06/15 12:15:23	1.59
@@ -481,6 +481,8 @@
 	/* Do some work */
 	main_loop(local_sock, cmd_timeout);
 
+	destroy_lvm();
+
 	return 0;
 }
 
--- LVM2/daemons/clvmd/lvm-functions.c	2009/06/12 08:30:19	1.62
+++ LVM2/daemons/clvmd/lvm-functions.c	2009/06/15 12:15:23	1.63
@@ -811,3 +811,10 @@
 
 	return 1;
 }
+
+void destroy_lvm(void)
+{
+	if (cmd)
+		destroy_toolcontext(cmd);
+	cmd = NULL;
+}
--- LVM2/daemons/clvmd/lvm-functions.h	2009/05/19 10:39:00	1.10
+++ LVM2/daemons/clvmd/lvm-functions.h	2009/06/15 12:15:23	1.11
@@ -28,6 +28,7 @@
 extern int do_check_lvm1(const char *vgname);
 extern int do_refresh_cache(void);
 extern int init_lvm(int using_gulm);
+extern void destroy_lvm(void);
 extern void init_lvhash(void);
 extern void destroy_lvhash(void);
 extern void lvm_do_backup(const char *vgname);


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2008-03-06  8:41 ccaulfield
  0 siblings, 0 replies; 11+ messages in thread
From: ccaulfield @ 2008-03-06  8:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-03-06 08:41:06

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c refresh_clvmd.c 

Log message:
	Include limits.h so it compiles with newer headers.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.799&r2=1.800
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/refresh_clvmd.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5

--- LVM2/WHATS_NEW	2008/03/05 18:15:02	1.799
+++ LVM2/WHATS_NEW	2008/03/06 08:41:05	1.800
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Include limits.h in clvmd so it compiles with newer headers.
   Add VirtIO disks (vd) to filters.
   Fix resetting of MIRROR_IMAGE and VISIBLE_LV after removal of LV. (2.02.30)
   Fix remove_layer_from_lv to empty the LV before removing it. (2.02.30)
--- LVM2/daemons/clvmd/clvmd.c	2008/02/15 14:12:32	1.42
+++ LVM2/daemons/clvmd/clvmd.c	2008/03/06 08:41:05	1.43
@@ -37,6 +37,7 @@
 #include <getopt.h>
 #include <syslog.h>
 #include <errno.h>
+#include <limits.h>
 #include <libdlm.h>
 
 #include "clvmd-comms.h"
--- LVM2/daemons/clvmd/refresh_clvmd.c	2007/08/17 11:51:23	1.4
+++ LVM2/daemons/clvmd/refresh_clvmd.c	2008/03/06 08:41:05	1.5
@@ -26,6 +26,7 @@
 #include <libdevmapper.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <limits.h>
 
 #include "clvm.h"
 #include "refresh_clvmd.h"


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2006-11-30 13:19:42

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c clvmd.h 

Log message:
	Always compile debug logging into clvmd as it's too useful to
	restrict to just developers.
	-d will switch it on and run the daemon in the foreground

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.509&r2=1.510
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.h.diff?cvsroot=lvm2&r1=1.7&r2=1.8

--- LVM2/WHATS_NEW	2006/11/30 10:16:47	1.509
+++ LVM2/WHATS_NEW	2006/11/30 13:19:42	1.510
@@ -1,6 +1,7 @@
 Version 2.02.16 -
 ====================================
-  Add startup timeout to RHEL4 clvmd startup script
+  Always compile debug logging into clvmd.
+  Add startup timeout to RHEL4 clvmd startup script.
   Add -T (startup timeout) switch to clvmd.
   Improve lvm_dump.sh robustness.
   Update lvm2create_initrd to support gentoo.
--- LVM2/daemons/clvmd/clvmd.c	2006/11/30 09:44:07	1.30
+++ LVM2/daemons/clvmd/clvmd.c	2006/11/30 13:19:42	1.31
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
+#include <stdarg.h>
 #include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -85,6 +86,7 @@
 	int msglen;
 	unsigned short xid;
 };
+static int debug = 0;
 static pthread_t lvm_thread;
 static pthread_mutex_t lvm_thread_mutex;
 static pthread_cond_t lvm_thread_cond;
@@ -163,13 +165,27 @@
 }
 
 
+void debuglog(const char *fmt, ...)
+{
+	time_t P;
+	va_list ap;
+
+	if (!debug)
+		return;
+
+	va_start(ap,fmt);
+	time(&P);
+ 	fprintf(stderr, "CLVMD[%x]: %.15s ", (int)pthread_self(), ctime(&P)+4 );
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+}
+
 int main(int argc, char *argv[])
 {
 	int local_sock;
 	struct local_client *newfd;
 	struct utsname nodeinfo;
 	signed char opt;
-	int debug = 0;
 	int cmd_timeout = DEFAULT_CMD_TIMEOUT;
 	int start_timeout = 0;
 	sigset_t ss;
--- LVM2/daemons/clvmd/clvmd.h	2005/04/13 13:50:07	1.7
+++ LVM2/daemons/clvmd/clvmd.h	2006/11/30 13:19:42	1.8
@@ -95,11 +95,7 @@
 	} bits;
 };
 
-#ifdef DEBUG
-#define DEBUGLOG(fmt, args...) {time_t P; time(&P); fprintf(stderr, "CLVMD[%x]: %.15s ", (int)pthread_self(), ctime(&P)+4 ); fprintf(stderr, fmt, ## args);}
-#else
-#define DEBUGLOG(fmt, args...)
-#endif
+#define DEBUGLOG(fmt, args...) debuglog(fmt, ## args);
 
 #ifndef max
 #define max(a,b) ((a)>(b)?(a):(b))
@@ -117,6 +113,7 @@
 
 extern void clvmd_cluster_init_completed(void);
 extern void process_message(struct local_client *client, char *buf, int len, char *csid);
+extern void debuglog(const char *fmt, ... );
 
 int sync_lock(const char *resource, int mode, int flags, int *lockid);
 int sync_unlock(const char *resource, int lockid);


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2005-06-13 10:16 pcaulfield
  0 siblings, 0 replies; 11+ messages in thread
From: pcaulfield @ 2005-06-13 10:16 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-06-13 10:16:21

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c tcp-comms.c 

Log message:
	Don't defer closing of FDs in clvmd as it can cause trouble.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.254&r2=1.255
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/tcp-comms.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2005-03-09 14:08 pcaulfield
  0 siblings, 0 replies; 11+ messages in thread
From: pcaulfield @ 2005-03-09 14:08 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-03-09 14:08:11

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c clvmd.h 

Log message:
	Don't take out the lvm_thread_lock at startup - it only protects the jobs list.
	DEBUGLOG() message now print threadid rather than PID which is more useful.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.199&r2=1.200
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons ...
@ 2005-02-18 15:31 pcaulfield
  0 siblings, 0 replies; 11+ messages in thread
From: pcaulfield @ 2005-02-18 15:31 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-02-18 15:31:32

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd.c tcp-comms.c 

Log message:
	Cope with more than one message arriving at the TCP socket, also
	fix some instances where the length in the message was wrong (cman
	code didn't notice this because it is packet-based comms anyway)

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.185&r2=1.186
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/tcp-comms.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6


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

end of thread, other threads:[~2011-09-24 20:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-17 16:25 LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c daemons agk
  -- strict thread matches above, loose matches on Subject: below --
2011-09-24 20:48 zkabelac
2011-03-29 20:30 zkabelac
2011-02-18 14:47 zkabelac
2010-04-13 19:54 zkabelac
2009-06-15 12:15 mbroz
2008-03-06  8:41 ccaulfield
2006-11-30 13:19 pcaulfield
2005-06-13 10:16 pcaulfield
2005-03-09 14:08 pcaulfield
2005-02-18 15:31 pcaulfield

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