public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/clvmd/clvmd-singlenod ...
@ 2010-08-19 23:26 mbroz
  0 siblings, 0 replies; 3+ messages in thread
From: mbroz @ 2010-08-19 23:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2010-08-19 23:26:32

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd-singlenode.c 
	lib/metadata   : metadata.c 

Log message:
	Fix wrong use of LCK_WRITE
	
	In all top vg read functions only LCK_VG_READ/WRITE can be used.
	All other vg lock definitions are low-level backend machinery.
	
	Moreover, LCK_WRITE cannot be tested through bitmask.
	This patch fixes these mistakes.
	
	For _recover_vg() we do not need lock_flags, it can be only
	two of above and we always upgrading to LCK_VG_WRITE lock there.
	(N.B. that code is racy)
	
	There is no functional change in code (despite wrong masking
	it produces correct bits:-)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1716&r2=1.1717
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-singlenode.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.393&r2=1.394

--- LVM2/WHATS_NEW	2010/08/19 23:08:18	1.1716
+++ LVM2/WHATS_NEW	2010/08/19 23:26:31	1.1717
@@ -4,6 +4,7 @@
   Remove assumption that --yes must be used only in --force mode.
   Fix file descriptor leak in swap signature detection error path.
   Detect and allow abort in pvcreate if LUKS signature is detected.
+  Use proper locks mask when checking for LCK_WRITE.
 
 Version 2.02.73 - 18th August 2010
 ==================================
--- LVM2/daemons/clvmd/clvmd-singlenode.c	2010/08/17 19:25:05	1.7
+++ LVM2/daemons/clvmd/clvmd-singlenode.c	2010/08/19 23:26:31	1.8
@@ -155,11 +155,13 @@
 		if (!_resources[i])
 			break;
 		if (!strcmp(_resources[i], resource)) {
-			if ((_locks[i] & LCK_WRITE) || (_locks[i] & LCK_EXCL)) {
+			if ((_locks[i] & LCK_TYPE_MASK) == LCK_WRITE ||
+			    (_locks[i] & LCK_TYPE_MASK) == LCK_EXCL) {
 				DEBUGLOG("%s already write/exclusively locked...\n", resource);
 				goto maybe_retry;
 			}
-			if ((mode & LCK_WRITE) || (mode & LCK_EXCL)) {
+			if ((mode & LCK_TYPE_MASK) == LCK_WRITE ||
+			    (mode & LCK_TYPE_MASK) == LCK_EXCL) {
 				DEBUGLOG("%s already locked and WRITE/EXCL lock requested...\n",
 					 resource);
 				goto maybe_retry;
--- LVM2/lib/metadata/metadata.c	2010/08/19 23:08:18	1.393
+++ LVM2/lib/metadata/metadata.c	2010/08/19 23:26:32	1.394
@@ -3834,20 +3834,16 @@
 }
 
 static struct volume_group *_recover_vg(struct cmd_context *cmd,
-			 const char *vg_name, const char *vgid,
-			 uint32_t lock_flags)
+			 const char *vg_name, const char *vgid)
 {
 	int consistent = 1;
 	struct volume_group *vg;
 
-	lock_flags &= ~LCK_TYPE_MASK;
-	lock_flags |= LCK_WRITE;
-
 	unlock_vg(cmd, vg_name);
 
 	dev_close_all();
 
-	if (!lock_vol(cmd, vg_name, lock_flags))
+	if (!lock_vol(cmd, vg_name, LCK_VG_WRITE))
 		return_NULL;
 
 	if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
@@ -3882,7 +3878,7 @@
 	uint32_t failure = 0;
 	int already_locked;
 
-	if (misc_flags & READ_ALLOW_INCONSISTENT || !(lock_flags & LCK_WRITE))
+	if (misc_flags & READ_ALLOW_INCONSISTENT || lock_flags != LCK_VG_WRITE)
 		consistent = 0;
 
 	if (!validate_name(vg_name) && !is_orphan_vg(vg_name)) {
@@ -3927,7 +3923,7 @@
 	/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
 	if (!consistent && !failure) {
 		vg_release(vg);
-		if (!(vg = _recover_vg(cmd, vg_name, vgid, lock_flags))) {
+		if (!(vg = _recover_vg(cmd, vg_name, vgid))) {
 			log_error("Recovery of volume group \"%s\" failed.",
 				  vg_name);
 			failure |= FAILED_INCONSISTENT;
@@ -3941,7 +3937,7 @@
 	 */
 
 	if (!cmd->handles_missing_pvs && vg_missing_pv_count(vg) &&
-	    (lock_flags & LCK_WRITE)) {
+	    lock_flags == LCK_VG_WRITE) {
 		log_error("Cannot change VG %s while PVs are missing.", vg->name);
 		log_error("Consider vgreduce --removemissing.");
 		failure |= FAILED_INCONSISTENT; /* FIXME new failure code here? */
@@ -3949,7 +3945,7 @@
 	}
 
 	if (!cmd->handles_unknown_segments && vg_has_unknown_segments(vg) &&
-	    (lock_flags & LCK_WRITE)) {
+	    lock_flags == LCK_VG_WRITE) {
 		log_error("Cannot change VG %s with unknown segments in it!",
 			  vg->name);
 		failure |= FAILED_INCONSISTENT; /* FIXME new failure code here? */


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd-singlenod ...
@ 2010-08-17 19:25 agk
  0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2010-08-17 19:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd-singlenode.c lvm-functions.c 
	lib/activate   : dev_manager.c 
	lib/locking    : cluster_locking.c file_locking.c locking.h 
	                 no_locking.c 
	lib/metadata   : mirror.c 
	tools          : lvchange.c 

Log message:
	Use 'SINGLENODE' instead of 'dead' in clvmd singlenode messages.
	Ignore snapshots when performing mirror recovery beneath an origin.
	Pass LCK_ORIGIN_ONLY flag around cluster.
	Add suspend_lv_origin and resume_lv_origin using LCK_ORIGIN_ONLY.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1708&r2=1.1709
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-singlenode.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.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.23&r2=1.24
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125

--- LVM2/WHATS_NEW	2010/08/17 16:25:32	1.1708
+++ LVM2/WHATS_NEW	2010/08/17 19:25:05	1.1709
@@ -1,5 +1,9 @@
 Version 2.02.73 - 
 ================================
+  Use 'SINGLENODE' instead of 'dead' in clvmd singlenode messages.
+  Ignore snapshots when performing mirror recovery beneath an origin.
+  Pass LCK_ORIGIN_ONLY flag around cluster.
+  Add suspend_lv_origin and resume_lv_origin using LCK_ORIGIN_ONLY.
   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.
--- LVM2/daemons/clvmd/clvmd-singlenode.c	2010/08/03 13:06:35	1.6
+++ LVM2/daemons/clvmd/clvmd-singlenode.c	2010/08/17 19:25:05	1.7
@@ -108,7 +108,7 @@
 
 static int _name_from_csid(const char *csid, char *name)
 {
-	sprintf(name, "%x", 0xdead);
+	sprintf(name, "SINGLENODE");
 	return 0;
 }
 
--- LVM2/daemons/clvmd/lvm-functions.c	2010/08/17 16:25:32	1.98
+++ LVM2/daemons/clvmd/lvm-functions.c	2010/08/17 19:25:05	1.99
@@ -122,12 +122,19 @@
 static const char *decode_flags(unsigned char flags)
 {
 	static char buf[128];
+	int len;
 
-	sprintf(buf, "0x%x (%s%s%s%s)", flags,
-		flags & LCK_PARTIAL_MODE	  ? "PARTIAL_MODE " : "",
-		flags & LCK_MIRROR_NOSYNC_MODE	  ? "MIRROR_NOSYNC " : "",
-		flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR " : "",
-		flags & LCK_CONVERT ? "CONVERT " : "");
+	len = sprintf(buf, "0x%x ( %s%s%s%s%s)", flags,
+		flags & LCK_PARTIAL_MODE	  ? "PARTIAL_MODE|" : "",
+		flags & LCK_MIRROR_NOSYNC_MODE	  ? "MIRROR_NOSYNC|" : "",
+		flags & LCK_DMEVENTD_MONITOR_MODE ? "DMEVENTD_MONITOR|" : "",
+		flags & LCK_ORIGIN_ONLY_MODE ? "ORIGIN_ONLY|" : "",
+		flags & LCK_CONVERT ? "CONVERT|" : "");
+
+	if (len > 1)
+		buf[len - 2] = ' ';
+	else
+		buf[0] = '\0';
 
 	return buf;
 }
@@ -350,13 +357,11 @@
 	}
 
 	/* If it's suspended then resume it */
-	// FIXME Set origin_only
 	if (!lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0))
 		goto error;
 
 	if (lvi.suspended) {
 		memlock_inc(cmd);
-		// FIXME Set origin_only
 		if (!lv_resume(cmd, resource, 0)) {
 			memlock_dec(cmd);
 			goto error;
@@ -387,8 +392,7 @@
 		return 0;	/* We don't need to do anything */
 	}
 
-	// FIXME Set origin_only
-	if (!lv_resume_if_active(cmd, resource, 0))
+	if (!lv_resume_if_active(cmd, resource, (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0))
 		return EIO;
 
 	return 0;
@@ -399,6 +403,7 @@
 {
 	int oldmode;
 	struct lvinfo lvi;
+	unsigned origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
 
 	/* Is it open ? */
 	oldmode = get_current_lock(resource);
@@ -408,12 +413,10 @@
 	}
 
 	/* Only suspend it if it exists */
-	// FIXME Set origin_only
-	if (!lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0))
+	if (!lv_info_by_lvid(cmd, resource, origin_only, &lvi, 0, 0))
 		return EIO;
 
-	// FIXME Set origin_only
-	if (lvi.exists && !lv_suspend_if_active(cmd, resource, 0))
+	if (lvi.exists && !lv_suspend_if_active(cmd, resource, origin_only))
 		return EIO;
 
 	return 0;
@@ -558,6 +561,7 @@
 		 char *resource)
 {
 	int status;
+	unsigned origin_only = (lock_flags & LCK_ORIGIN_ONLY_MODE) ? 1 : 0;
 
 	/* Opposite of above, done on resume after a metadata update */
 	if ((command & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME &&
@@ -574,8 +578,7 @@
 			struct lvinfo lvi;
 
 			pthread_mutex_lock(&lvm_lock);
-			// FIXME Set origin_only
-			status = lv_info_by_lvid(cmd, resource, 0, &lvi, 0, 0);
+			status = lv_info_by_lvid(cmd, resource, origin_only, &lvi, 0, 0);
 			pthread_mutex_unlock(&lvm_lock);
 			if (!status)
 				return EIO;
--- LVM2/lib/activate/dev_manager.c	2010/08/17 16:25:33	1.200
+++ LVM2/lib/activate/dev_manager.c	2010/08/17 19:25:05	1.201
@@ -1588,7 +1588,7 @@
 	return r;
 }
 
-static int _clean_tree(struct dev_manager *dm, struct dm_tree_node *root)
+static int _clean_tree(struct dev_manager *dm, struct dm_tree_node *root, char *non_toplevel_tree_dlid)
 {
 	void *handle = NULL;
 	struct dm_tree_node *child;
@@ -1612,6 +1612,10 @@
 		if (!*layer)
 			continue;
 
+		/* If operation was performed on a partial tree, don't remove it */
+		if (non_toplevel_tree_dlid && !strcmp(non_toplevel_tree_dlid, uuid))
+			continue;
+
 		dm_tree_set_cookie(root, 0);
 		r = dm_tree_deactivate_children(root, uuid, strlen(uuid));
 		if (!dm_udev_wait(dm_tree_get_cookie(root)))
@@ -1647,7 +1651,7 @@
 	switch(action) {
 	case CLEAN:
 		/* Deactivate any unused non-toplevel nodes */
-		if (!_clean_tree(dm, root))
+		if (!_clean_tree(dm, root, origin_only ? dlid : NULL))
 			goto_out;
 		break;
 	case DEACTIVATE:
--- LVM2/lib/locking/cluster_locking.c	2010/07/09 15:34:45	1.45
+++ LVM2/lib/locking/cluster_locking.c	2010/08/17 19:25:05	1.46
@@ -318,10 +318,13 @@
 	args = alloca(len);
 	strcpy(args + 2, name);
 
-	/* Maskoff lock flags */
+	/* Mask off lock flags */
 	args[0] = flags & (LCK_SCOPE_MASK | LCK_TYPE_MASK | LCK_NONBLOCK | LCK_HOLD); 
 	args[1] = flags & (LCK_LOCAL | LCK_CLUSTER_VG);
 
+	if (flags & LCK_ORIGIN_ONLY)
+		args[1] |= LCK_ORIGIN_ONLY_MODE;
+
 	if (mirror_in_sync())
 		args[1] |= LCK_MIRROR_NOSYNC_MODE;
 
@@ -462,13 +465,14 @@
 		return 0;
 	}
 
-	log_very_verbose("Locking %s %s %s (%s%s%s%s%s%s) (0x%x)", lock_scope, lockname,
+	log_very_verbose("Locking %s %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 & LCK_ORIGIN_ONLY ? "|ORIGIN_ONLY" : "",
 			 flags);
 
 	/* Send a message to the cluster manager */
--- LVM2/lib/locking/file_locking.c	2010/08/17 16:25:33	1.49
+++ LVM2/lib/locking/file_locking.c	2010/08/17 19:25:05	1.50
@@ -254,6 +254,7 @@
 			       uint32_t flags)
 {
 	char lockfile[PATH_MAX];
+	unsigned origin_only = (flags & LCK_ORIGIN_ONLY) ? 1 : 0;
 
 	switch (flags & LCK_SCOPE_MASK) {
 	case LCK_VG:
@@ -278,9 +279,8 @@
 	case LCK_LV:
 		switch (flags & LCK_TYPE_MASK) {
 		case LCK_UNLOCK:
-			log_very_verbose("Unlocking LV %s", resource);
-			// FIXME Set origin_only
-			if (!lv_resume_if_active(cmd, resource, 0))
+			log_very_verbose("Unlocking LV %s%s", resource, origin_only ? " without snapshots" : "");
+			if (!lv_resume_if_active(cmd, resource, origin_only))
 				return 0;
 			break;
 		case LCK_NULL:
@@ -297,9 +297,8 @@
 			log_very_verbose("Locking LV %s (PR) - ignored", resource);
 			break;
 		case LCK_WRITE:
-			log_very_verbose("Locking LV %s (W)", resource);
-			// FIXME Set origin_only
-			if (!lv_suspend_if_active(cmd, resource, 0))
+			log_very_verbose("Locking LV %s (W)%s", resource, origin_only ? " without snapshots" : "");
+			if (!lv_suspend_if_active(cmd, resource, origin_only))
 				return 0;
 			break;
 		case LCK_EXCL:
--- LVM2/lib/locking/locking.h	2010/06/17 12:48:55	1.57
+++ LVM2/lib/locking/locking.h	2010/08/17 19:25:05	1.58
@@ -93,14 +93,16 @@
 #define LCK_LOCAL	0x00000040U	/* Don't propagate to other nodes */
 #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 */
 
 /*
- * Additional lock bits for cluster communication
+ * Additional lock bits for cluster communication via args[1]
  */
-#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 */
-#define LCK_CONVERT		0x00000008U	/* Convert existing lock */
+#define LCK_PARTIAL_MODE        	0x01	/* Partial activation? */
+#define LCK_MIRROR_NOSYNC_MODE		0x02	/* Mirrors don't require sync */
+#define LCK_DMEVENTD_MONITOR_MODE	0x04	/* Register with dmeventd */
+#define LCK_CONVERT			0x08	/* Convert existing lock */
+#define LCK_ORIGIN_ONLY_MODE		0x20	/* Same as above */
 
 /*
  * Special cases of VG locks.
@@ -148,7 +150,9 @@
 	} while (0)
 
 #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 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)
 #define activate_lv(cmd, lv)	lock_lv_vol(cmd, lv, LCK_LV_ACTIVATE | LCK_HOLD)
 #define activate_lv_excl(cmd, lv)	\
--- LVM2/lib/locking/no_locking.c	2010/08/17 16:25:33	1.23
+++ LVM2/lib/locking/no_locking.c	2010/08/17 19:25:05	1.24
@@ -44,13 +44,11 @@
 		case LCK_NULL:
 			return lv_deactivate(cmd, resource);
 		case LCK_UNLOCK:
-			// FIXME Set origin_only
-			return lv_resume_if_active(cmd, resource, 0);
+			return lv_resume_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1: 0);
 		case LCK_READ:
 			return lv_activate_with_filter(cmd, resource, 0);
 		case LCK_WRITE:
-			// FIXME Set origin_only
-			return lv_suspend_if_active(cmd, resource, 0);
+			return lv_suspend_if_active(cmd, resource, (flags & LCK_ORIGIN_ONLY) ? 1 : 0);
 		case LCK_EXCL:
 			return lv_activate_with_filter(cmd, resource, 1);
 		default:
--- LVM2/lib/metadata/mirror.c	2010/08/17 16:25:33	1.133
+++ LVM2/lib/metadata/mirror.c	2010/08/17 19:25:05	1.134
@@ -934,7 +934,7 @@
 		return 0;
 	}
 
-	if (!suspend_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
+	if (!suspend_lv_origin(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
 		log_error("Failed to lock %s", mirrored_seg->lv->name);
 		vg_revert(mirrored_seg->lv->vg);
 		return 0;
@@ -969,7 +969,7 @@
 		return 0;
 	}
 
-	if (!resume_lv(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
+	if (!resume_lv_origin(mirrored_seg->lv->vg->cmd, mirrored_seg->lv)) {
 		log_error("Problem reactivating %s", mirrored_seg->lv->name);
 		return 0;
 	}
--- LVM2/tools/lvchange.c	2010/08/17 16:25:35	1.124
+++ LVM2/tools/lvchange.c	2010/08/17 19:25:05	1.125
@@ -162,6 +162,7 @@
 static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
 {
 	log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name);
+
 	return lv_refresh(cmd, lv);
 }
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd-singlenod ...
@ 2010-07-28 14:01 agk
  0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2010-07-28 14:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2010-07-28 14:01:41

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd-singlenode.c clvmd.c 

Log message:
	Never use clvmd singlenode unless explicitly requested with -Isinglenode.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1675&r2=1.1676
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-singlenode.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75

--- LVM2/WHATS_NEW	2010/07/28 13:55:42	1.1675
+++ LVM2/WHATS_NEW	2010/07/28 14:01:40	1.1676
@@ -3,6 +3,7 @@
   Change clvmd to communicate with lvm2 via a socket in /var/run/lvm.
   Return controlled error if clvmd is run by non-root user.
   Add configure --default-run-dir for /var/run/lvm.
+  Never use clvmd singlenode unless explicitly requested with -Isinglenode.
 
 Version 2.02.71 - 28th July 2010
 ================================
--- LVM2/daemons/clvmd/clvmd-singlenode.c	2010/06/21 15:56:58	1.4
+++ LVM2/daemons/clvmd/clvmd-singlenode.c	2010/07/28 14:01:41	1.5
@@ -26,17 +26,29 @@
 #include <sys/socket.h>
 #include <fcntl.h>
 
-static const char SINGLENODE_CLVMD_SOCKNAME[] = "\0singlenode_clvmd";
+static const char SINGLENODE_CLVMD_SOCKNAME[] = DEFAULT_RUN_DIR "/clvmd_singlenode.sock";
 static int listen_fd = -1;
 
+static void close_comms()
+{
+	if (listen_fd != -1 && close(listen_fd))
+		stack;
+	(void)unlink(SINGLENODE_CLVMD_SOCKNAME);
+	listen_fd = -1;
+}
+
 static int init_comms()
 {
 	struct sockaddr_un addr;
+	mode_t old_mask;
+
+	close_comms();
+	old_mask = umask(0077);
 
 	listen_fd = socket(PF_UNIX, SOCK_STREAM, 0);
 	if (listen_fd < 0) {
 		DEBUGLOG("Can't create local socket: %s\n", strerror(errno));
-		return -1;
+		goto error;
 	}
 	/* Set Close-on-exec */
 	fcntl(listen_fd, F_SETFD, 1);
@@ -48,16 +60,19 @@
 
 	if (bind(listen_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
 		DEBUGLOG("Can't bind local socket: %s\n", strerror(errno));
-		close(listen_fd);
-		return -1;
+		goto error;
 	}
 	if (listen(listen_fd, 10) < 0) {
 		DEBUGLOG("Can't listen local socket: %s\n", strerror(errno));
-		close(listen_fd);
-		return -1;
+		goto error;
 	}
 
+	umask(old_mask);
 	return 0;
+error:
+	umask(old_mask);
+	close_comms();
+	return -1;
 }
 
 static int _init_cluster(void)
@@ -74,7 +89,7 @@
 
 static void _cluster_closedown(void)
 {
-	close(listen_fd);
+	close_comms();
 
 	DEBUGLOG("cluster_closedown\n");
 	destroy_lvhash();
--- LVM2/daemons/clvmd/clvmd.c	2010/07/28 13:55:43	1.74
+++ LVM2/daemons/clvmd/clvmd.c	2010/07/28 14:01:41	1.75
@@ -479,7 +479,7 @@
 #endif
 #ifdef USE_SINGLENODE
 	if (!clops)
-		if ((cluster_iface == IF_AUTO || cluster_iface == IF_SINGLENODE) && (clops = init_singlenode_cluster())) {
+		if (cluster_iface == IF_SINGLENODE && (clops = init_singlenode_cluster())) {
 			max_csid_len = SINGLENODE_CSID_LEN;
 			max_cluster_message = SINGLENODE_MAX_CLUSTER_MESSAGE;
 			max_cluster_member_name_len = MAX_CLUSTER_MEMBER_NAME_LEN;


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

end of thread, other threads:[~2010-08-19 23:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-19 23:26 LVM2 ./WHATS_NEW daemons/clvmd/clvmd-singlenod mbroz
  -- strict thread matches above, loose matches on Subject: below --
2010-08-17 19:25 agk
2010-07-28 14:01 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).