public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2004-10-06 12:36 pcaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: pcaulfield @ 2004-10-06 12:36 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2004-10-06 12:36:47

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

Log message:
	Make clvmd -V display the lvm version number too rather than just
	the protocol version (which is not that useful and doesn't change very often).

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.101&r2=1.102
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-28 11:06:56

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

Log message:
	Ensure clvmd message is always \0 terminated
	
	Drop whole buffer clearing (most messages at <100 bytes).
	Just make sure we have always \0 terminated string for strlen() operations.
	(before for PIPE_BUF sized messages this was not set).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2322&r2=1.2323
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.128&r2=1.129

--- LVM2/WHATS_NEW	2012/02/28 11:03:24	1.2322
+++ LVM2/WHATS_NEW	2012/02/28 11:06:56	1.2323
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Ensure clvmd message is always \0 terminated after read.
   Better detection of missing dmeventd fifo connection (2.02.93).
   Add some close() and dev_close() error path backtraces.
   For polling daemon reopen stdin,stdout,stderr to /dev/null.
--- LVM2/daemons/clvmd/clvmd.c	2012/02/28 10:42:20	1.128
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/28 11:06:56	1.129
@@ -1087,10 +1087,9 @@
 	int len;
 	int argslen;
 	int missing_len;
-	char buffer[PIPE_BUF];
+	char buffer[PIPE_BUF + 1];
 
-	memset(buffer, 0, PIPE_BUF);
-	len = read(thisfd->fd, buffer, sizeof(buffer));
+	len = read(thisfd->fd, buffer, sizeof(buffer) - 1);
 	if (len == -1 && errno == EINTR)
 		return 1;
 
@@ -1180,6 +1179,7 @@
 		struct clvm_header *inheader;
 		int status;
 
+		buffer[len] = 0; /* Ensure \0 terminated */
 		inheader = (struct clvm_header *) buffer;
 
 		/* Fill in the client ID */


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2012-02-28  9:58 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2012-02-28  9:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-28 09:58:20

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

Log message:
	Limit max size of clvmd message
	
	This could be seen as some sort of simple validation - it's not easy to
	recognize a valid message for now - but we definitely do not want to
	allocate a lot of megabytes in  clvmd memory locked daemon when broken
	message gets in.
	
	Size of 8000 is just selected for now - possibly there could be much
	lower value put in.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2319&r2=1.2320
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126

--- LVM2/WHATS_NEW	2012/02/28 09:53:55	1.2319
+++ LVM2/WHATS_NEW	2012/02/28 09:58:19	1.2320
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Limit the max size of processed clvmd message to ~8KB.
   Do not send uninitilised bytes in cluster error reply messages.
   Use unsigned type for bitmask instead of enum type for lvm properties.
   Add missing cleanup of excl_uuid hash on some exit paths of clvmd.
--- LVM2/daemons/clvmd/clvmd.c	2012/02/28 09:53:55	1.125
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/28 09:58:20	1.126
@@ -49,6 +49,7 @@
 #endif
 
 #define MAX_RETRIES 4
+#define MAX_MISSING_LEN = 8000 /* Max supported clvmd message size ? */
 
 #define ISLOCAL_CSID(c) (memcmp(c, our_csid, max_csid_len) == 0)
 
@@ -1204,7 +1205,8 @@
 			missing_len = 0;
 
 		/* We need at least sizeof(struct clvm_header) bytes in buffer */
-		if (len < sizeof(struct clvm_header) || argslen < 0) {
+		if (len < sizeof(struct clvm_header) || argslen < 0 ||
+		    missing_len > MAX_MISSING_LEN) {
 			struct clvm_header reply = {
 				.cmd = CLVMD_CMD_REPLY,
 				.status = EINVAL


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2012-02-28  9:53 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2012-02-28  9:53 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-28 09:53:55

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

Log message:
	Do not send uninitilised bytes
	
	Use struct initalizers to fill struct members and at the same time have
	all unspecified members set to 0.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2318&r2=1.2319
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125

--- LVM2/WHATS_NEW	2012/02/27 11:45:05	1.2318
+++ LVM2/WHATS_NEW	2012/02/28 09:53:55	1.2319
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Do not send uninitilised bytes in cluster error reply messages.
   Use unsigned type for bitmask instead of enum type for lvm properties.
   Add missing cleanup of excl_uuid hash on some exit paths of clvmd.
   Check for existance of vg_name in _format1/_pool_vg_read().
--- LVM2/daemons/clvmd/clvmd.c	2012/02/27 11:28:47	1.124
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/28 09:53:55	1.125
@@ -1185,11 +1185,10 @@
 
 		/* If we are already busy then return an error */
 		if (thisfd->bits.localsock.in_progress) {
-			struct clvm_header reply;
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = EBUSY;
-			reply.arglen = 0;
-			reply.flags = 0;
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = EBUSY
+			};
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending EBUSY reply to local user");
@@ -1206,11 +1205,10 @@
 
 		/* We need at least sizeof(struct clvm_header) bytes in buffer */
 		if (len < sizeof(struct clvm_header) || argslen < 0) {
-			struct clvm_header reply;
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = EINVAL;
-			reply.arglen = 0;
-			reply.flags = 0;
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = EINVAL
+			};
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending EINVAL reply to local user");
@@ -1224,11 +1222,10 @@
 		thisfd->bits.localsock.cmd = malloc(len + missing_len);
 
 		if (!thisfd->bits.localsock.cmd) {
-			struct clvm_header reply;
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = ENOMEM;
-			reply.arglen = 0;
-			reply.flags = 0;
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = ENOMEM
+			};
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending ENOMEM reply to local user");
@@ -1283,13 +1280,12 @@
 		/* Check the node name for validity */
 		if (inheader->node[0] && clops->csid_from_name(csid, inheader->node)) {
 			/* Error, node is not in the cluster */
-			struct clvm_header reply;
-			DEBUGLOG("Unknown node: '%s'\n", inheader->node);
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = ENOENT
+			};
 
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = ENOENT;
-			reply.flags = 0;
-			reply.arglen = 0;
+			DEBUGLOG("Unknown node: '%s'\n", inheader->node);
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending ENOENT reply to local user");
@@ -1311,12 +1307,12 @@
 
 		/* Create a pipe and add the reading end to our FD list */
 		if (pipe(comms_pipe)) {
-			struct clvm_header reply;
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = EBUSY
+			};
+
 			DEBUGLOG("creating pipe failed: %s\n", strerror(errno));
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = EBUSY;
-			reply.arglen = 0;
-			reply.flags = 0;
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending EBUSY reply to local user");
@@ -1325,14 +1321,14 @@
 
 		newfd = malloc(sizeof(struct local_client));
 		if (!newfd) {
-			struct clvm_header reply;
+			struct clvm_header reply = {
+				.cmd = CLVMD_CMD_REPLY,
+				.status = ENOMEM
+			};
+
 			close(comms_pipe[0]);
 			close(comms_pipe[1]);
 
-			reply.cmd = CLVMD_CMD_REPLY;
-			reply.status = ENOMEM;
-			reply.arglen = 0;
-			reply.flags = 0;
 			send_message(&reply, sizeof(reply), our_csid,
 				     thisfd->fd,
 				     "Error sending ENOMEM reply to local user");


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-27 11:26:26

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

Log message:
	Nicer cleanup of excl_uuid hash
	
	Since it on exit path, it's not a big difference,
	but makes less noise in analyzer and valgrind.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2316&r2=1.2317
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.122&r2=1.123

--- LVM2/WHATS_NEW	2012/02/27 11:23:15	1.2316
+++ LVM2/WHATS_NEW	2012/02/27 11:26:25	1.2317
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Add missing cleanup of excl_uuid hash on some exit paths of clvmd.
   Check for existance of vg_name in _format1/_pool_vg_read().
   Fix missing break in _format_pvsegs (2.02.92).
   Test seg pointer for non-null it in raid_target_percent error path.
--- LVM2/daemons/clvmd/clvmd.c	2012/02/27 10:17:06	1.122
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/27 11:26:25	1.123
@@ -345,6 +345,7 @@
 	debug_t debug_arg = DEBUG_OFF;
 	int clusterwide_opt = 0;
 	mode_t old_mask;
+	int ret = 1;
 
 	struct option longopts[] = {
 		{ "help", 0, 0, 'h' },
@@ -372,7 +373,8 @@
 
 		case 'S':
 			check_permissions();
-			return restart_clvmd(clusterwide_opt)==1?0:1;
+			ret = (restart_clvmd(clusterwide_opt) == 1) ? 0 : 1;
+			goto out;
 
 		case 'C':
 			clusterwide_opt = 1;
@@ -402,7 +404,7 @@
 		case 'E':
 			if (!dm_hash_insert(lvm_params.excl_uuid, optarg, optarg)) {
 				fprintf(stderr, "Failed to allocate hash entry\n");
-				return 1;
+				goto out;
 			}
 			break;
 		case 'T':
@@ -624,9 +626,11 @@
 		free(delfd);
 	}
 
+	ret = 0;
+out:
 	dm_hash_destroy(lvm_params.excl_uuid);
 
-	return 0;
+	return ret;
 }
 
 /* Called when the cluster layer has completed initialisation.


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2012-02-27  9:58 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2012-02-27  9:58 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-27 09:58:19

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

Log message:
	Drop uname call, it's not used from gulm era.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2310&r2=1.2311
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121

--- LVM2/WHATS_NEW	2012/02/27 09:56:27	1.2310
+++ LVM2/WHATS_NEW	2012/02/27 09:58:18	1.2311
@@ -1,5 +1,6 @@
 Version 2.02.94 - 
 ====================================
+  Drop unused call to uname() during clvmd initia.lization.
   Test allocation result in sysfs filter creation.
   Limit sscanf parameters with buffer size in clvmd get_initial_state().
   Use const lv pointer for lv_is_active...() functions. 
--- LVM2/daemons/clvmd/clvmd.c	2012/02/08 13:03:40	1.120
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/27 09:58:19	1.121
@@ -335,7 +335,6 @@
 {
 	int local_sock;
 	struct local_client *newfd, *delfd;
-	struct utsname nodeinfo;
 	struct lvm_startup_params lvm_params;
 	int opt;
 	int cmd_timeout = DEFAULT_CMD_TIMEOUT;
@@ -559,7 +558,6 @@
 	DEBUGLOG("Cluster ready, doing some more initialisation\n");
 
 	/* Save our CSID */
-	uname(&nodeinfo);
 	clops->get_our_csid(our_csid);
 
 	/* Initialise the FD list head */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-11 09:54:39

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

Log message:
	Simplify worker loop
	
	Do not reacquire mutex several times without a real reason.
	Code readability is also better.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2159&r2=1.2160
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.113&r2=1.114

--- LVM2/WHATS_NEW	2011/10/11 09:26:04	1.2159
+++ LVM2/WHATS_NEW	2011/10/11 09:54:39	1.2160
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Simplify code for lvm worker thread in clvmd.
   Use pthread_barrier to synchronize clvmd threads at startup.
   Limit clvmd's thread size to 128KiB.
   Reduce default preallocated stack size to 64KiB.
--- LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:26:04	1.113
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:54:39	1.114
@@ -1988,6 +1988,7 @@
 	struct dm_list *cmdl, *tmp;
 	sigset_t ss;
 	struct lvm_startup_params *lvm_params = arg;
+	struct lvm_thread_cmd *cmd;
 
 	DEBUGLOG("LVM thread function started\n");
 
@@ -2005,18 +2006,15 @@
 	DEBUGLOG("Sub thread ready for work.\n");
 
 	/* Now wait for some actual work */
-	while (!quit) {
-		DEBUGLOG("LVM thread waiting for work\n");
+	pthread_mutex_lock(&lvm_thread_mutex);
 
-		pthread_mutex_lock(&lvm_thread_mutex);
-		if (dm_list_empty(&lvm_cmd_head))
+	while (!quit) {
+		if (dm_list_empty(&lvm_cmd_head)) {
+			DEBUGLOG("LVM thread waiting for work\n");
 			pthread_cond_wait(&lvm_thread_cond, &lvm_thread_mutex);
-
-		dm_list_iterate_safe(cmdl, tmp, &lvm_cmd_head) {
-			struct lvm_thread_cmd *cmd;
-
-			cmd =
-			    dm_list_struct_base(cmdl, struct lvm_thread_cmd, list);
+		} else {
+			cmd = dm_list_item(dm_list_first(&lvm_cmd_head),
+					   struct lvm_thread_cmd);
 			dm_list_del(&cmd->list);
 			pthread_mutex_unlock(&lvm_thread_mutex);
 
@@ -2026,9 +2024,10 @@
 
 			pthread_mutex_lock(&lvm_thread_mutex);
 		}
-		pthread_mutex_unlock(&lvm_thread_mutex);
 	}
 
+	pthread_mutex_unlock(&lvm_thread_mutex);
+
 	pthread_exit(NULL);
 }
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-11 09:26:04

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

Log message:
	Use barrier instead of mutex
	
	Barrier is supposed to be used in situation like this
	and replace tricky mutex usage, where mutex has been unlocked
	by a different thread than the locking thread.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2158&r2=1.2159
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.112&r2=1.113

--- LVM2/WHATS_NEW	2011/10/11 09:20:17	1.2158
+++ LVM2/WHATS_NEW	2011/10/11 09:26:04	1.2159
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Use pthread_barrier to synchronize clvmd threads at startup.
   Limit clvmd's thread size to 128KiB.
   Reduce default preallocated stack size to 64KiB.
   Add check for access through NULL pointer when refresh_filter() fails.
--- LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:23:48	1.112
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:26:04	1.113
@@ -89,7 +89,7 @@
 static pthread_attr_t stack_attr;
 static pthread_mutex_t lvm_thread_mutex;
 static pthread_cond_t lvm_thread_cond;
-static pthread_mutex_t lvm_start_mutex;
+static pthread_barrier_t lvm_start_barrier;
 static struct dm_list lvm_cmd_head;
 static volatile sig_atomic_t quit = 0;
 static volatile sig_atomic_t reread_config = 0;
@@ -505,7 +505,7 @@
 	}
 	pthread_mutex_init(&lvm_thread_mutex, NULL);
 	pthread_cond_init(&lvm_thread_cond, NULL);
-	pthread_mutex_init(&lvm_start_mutex, NULL);
+	pthread_barrier_init(&lvm_start_barrier, NULL, 2);
 	init_lvhash();
 
 	/* Start the cluster interface */
@@ -584,9 +584,11 @@
 	DEBUGLOG("starting LVM thread\n");
 
 	/* Don't let anyone else to do work until we are started */
-	pthread_mutex_lock(&lvm_start_mutex);
 	pthread_create(&lvm_thread, &stack_attr, lvm_thread_fn, &lvm_params);
 
+	/* Don't start until the LVM thread is ready */
+	pthread_barrier_wait(&lvm_start_barrier);
+
 	/* Tell the rest of the cluster our version number */
 	if (clops->cluster_init_completed)
 		clops->cluster_init_completed();
@@ -1633,11 +1635,6 @@
 	DEBUGLOG("in sub thread: client = %p\n", client);
 	pthread_mutex_lock(&client->bits.localsock.mutex);
 
-	/* Don't start until the LVM thread is ready */
-	pthread_mutex_lock(&lvm_start_mutex);
-	pthread_mutex_unlock(&lvm_start_mutex);
-	DEBUGLOG("Sub thread ready for work.\n");
-
 	/* Ignore SIGUSR1 (handled by master process) but enable
 	   SIGUSR2 (kills subthreads) */
 	sigemptyset(&ss);
@@ -2004,7 +2001,8 @@
 	init_clvm(lvm_params->excl_uuid);
 
 	/* Allow others to get moving */
-	pthread_mutex_unlock(&lvm_start_mutex);
+	pthread_barrier_wait(&lvm_start_barrier);
+	DEBUGLOG("Sub thread ready for work.\n");
 
 	/* Now wait for some actual work */
 	while (!quit) {


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2011-09-16 14:40 mbroz
  0 siblings, 0 replies; 38+ messages in thread
From: mbroz @ 2011-09-16 14:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-09-16 14:40:07

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

Log message:
	Fix clvmd processing of invalid request on local socket. (rommer)
	
	Code now detects small packet and wrong arglen and reply with
	error intead of infinite loop.
	
	https://bugzilla.redhat.com/show_bug.cgi?id=738484

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2115&r2=1.2116
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.108&r2=1.109

--- LVM2/WHATS_NEW	2011/09/16 12:10:02	1.2115
+++ LVM2/WHATS_NEW	2011/09/16 14:40:06	1.2116
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Fix clvmd processing of invalid request on local socket.
   Fix command line option decoding.
   Reset LV status when unlinking LV from VG.
   Fix overly strict extent-count divisibility requirements for striped mirrors.
--- LVM2/daemons/clvmd/clvmd.c	2011/08/12 02:16:46	1.108
+++ LVM2/daemons/clvmd/clvmd.c	2011/09/16 14:40:07	1.109
@@ -1061,6 +1061,7 @@
 	int missing_len;
 	char buffer[PIPE_BUF];
 
+	memset(buffer, 0, PIPE_BUF);
 	len = read(thisfd->fd, buffer, sizeof(buffer));
 	if (len == -1 && errno == EINTR)
 		return 1;
@@ -1169,9 +1170,6 @@
 			return len;
 		}
 
-		/* Free any old buffer space */
-		free(thisfd->bits.localsock.cmd);
-
 		/* See if we have the whole message */
 		argslen =
 		    len - strlen(inheader->node) - sizeof(struct clvm_header);
@@ -1180,6 +1178,22 @@
 		if (missing_len < 0)
 			missing_len = 0;
 
+		/* We need at least sizeof(struct clvm_header) bytes in buffer */
+		if (len < sizeof(struct clvm_header) || argslen < 0) {
+			struct clvm_header reply;
+			reply.cmd = CLVMD_CMD_REPLY;
+			reply.status = EINVAL;
+			reply.arglen = 0;
+			reply.flags = 0;
+			send_message(&reply, sizeof(reply), our_csid,
+				     thisfd->fd,
+				     "Error sending EINVAL reply to local user");
+			return 0;
+		}
+
+		/* Free any old buffer space */
+		free(thisfd->bits.localsock.cmd);
+
 		/* Save the message */
 		thisfd->bits.localsock.cmd = malloc(len + missing_len);
 
@@ -1203,15 +1217,23 @@
 			char *argptr =
 			    inheader->node + strlen(inheader->node) + 1;
 
-			while (missing_len > 0 && len >= 0) {
+			while (missing_len > 0) {
 				DEBUGLOG
 				    ("got %d bytes, need another %d (total %d)\n",
 				     argslen, missing_len, inheader->arglen);
 				len = read(thisfd->fd, argptr + argslen,
 					   missing_len);
-				if (len >= 0) {
+				if (len == -1 && errno == EINTR)
+					continue;
+				if (len > 0) {
 					missing_len -= len;
 					argslen += len;
+				} else {
+					/* EOF or error on socket */
+					DEBUGLOG("EOF on local socket\n");
+					free(thisfd->bits.localsock.cmd);
+					thisfd->bits.localsock.cmd = NULL;
+					return 0;
 				}
 			}
 		}


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-08-11 12:57:11

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

Log message:
	Never ever use uninitialised descriptors if pipe() fails
	(because of maximum open count fd exceeded or so).
	
	Better return busy message, so even clients fail in more controlled way.
	
	Without patch,  clvmd crashes with various strange backtraces
	if under heavy load of connection requests.
	
	https://bugzilla.redhat.com/show_bug.cgi?id=698393
	https://bugzilla.redhat.com/show_bug.cgi?id=697945
	
	(It still can OOM but that's different issue.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2061&r2=1.2062
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107

--- LVM2/WHATS_NEW	2011/08/11 05:00:20	1.2061
+++ LVM2/WHATS_NEW	2011/08/11 12:57:10	1.2062
@@ -1,5 +1,6 @@
 Version 2.02.87 - 
 ===============================
+  If pipe in clvmd fails, return busy instead of using uninitialised descriptors.
   Add dmeventd monitoring shared library for RAID.
   Add RAID metadata devices to considered devices in _add_lv_to_dtree.
   Fix renaming of RAID logical volumes.
--- LVM2/daemons/clvmd/clvmd.c	2011/08/09 18:11:00	1.106
+++ LVM2/daemons/clvmd/clvmd.c	2011/08/11 12:57:11	1.107
@@ -1263,9 +1263,19 @@
 		}
 
 		/* Create a pipe and add the reading end to our FD list */
-		if (pipe(comms_pipe))
+		if (pipe(comms_pipe)) {
+			struct clvm_header reply;
 			DEBUGLOG("creating pipe failed: %s\n", strerror(errno));
-		
+			reply.cmd = CLVMD_CMD_REPLY;
+			reply.status = EBUSY;
+			reply.arglen = 0;
+			reply.flags = 0;
+			send_message(&reply, sizeof(reply), our_csid,
+				     thisfd->fd,
+				     "Error sending EBUSY reply to local user");
+			return len;
+		}
+
 		newfd = malloc(sizeof(struct local_client));
 		if (!newfd) {
 			struct clvm_header reply;


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2011-06-28 13:42 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2011-06-28 13:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-06-28 13:42:15

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

Log message:
	Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2028&r2=1.2029
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105

--- LVM2/WHATS_NEW	2011/06/28 00:23:06	1.2028
+++ LVM2/WHATS_NEW	2011/06/28 13:42:15	1.2029
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Annotate CLVMD_CMD_SYNC_NAMES in decode_cmd.
   Remove enforcement of udev verification when using non-standard /dev location.
   Fix to preserve exclusive activation of mirror while up-converting.
   Reject allocation if number of extents is not divisible by area count.
--- LVM2/daemons/clvmd/clvmd.c	2011/04/08 14:40:18	1.104
+++ LVM2/daemons/clvmd/clvmd.c	2011/06/28 13:42:15	1.105
@@ -295,6 +295,9 @@
 	case CLVMD_CMD_RESTART:
 		command = "RESTART";
 		break;
+	case CLVMD_CMD_SYNC_NAMES:
+		command = "SYNC_NAMES";
+		break;
 	default:
 		command = "unknown";
 		break;


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

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

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

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

Log message:
	Better shutdown for clvmd
	
	'a small step' towards cleaner shutdown sequence.
	Normally clvmd doens't care about unreleased memory on exit -
	but for valgrind testing it's better to have them cleaned all.
	
	So - few things are left on exit path - this patch starts to remove
	just some of them.
	
	1. lvm_thread_fs is made as a thread which could be joined on exit()
	2. memory allocated to local_clien_head list is released.
	(this part is somewhat more complex if the proper reaction is
	needed - and as it requires some heavier code moving - it will
	be resolved later.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1963&r2=1.1964
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102

--- LVM2/WHATS_NEW	2011/03/30 12:30:39	1.1963
+++ LVM2/WHATS_NEW	2011/03/30 12:36:19	1.1964
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Support regular quit of the lvm_thread_fn function in clvmd.
   Fix reading of unallocated memory in lvm1 format import function.
   Replace several strncmp() calls with id_equal().
   Fix lvmcache_info transfer to orphan_vginfo in _lvmcache_update_vgname().
--- LVM2/daemons/clvmd/clvmd.c	2011/03/29 20:30:06	1.101
+++ LVM2/daemons/clvmd/clvmd.c	2011/03/30 12:36:20	1.102
@@ -103,8 +103,6 @@
 
 typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC, IF_SINGLENODE} if_type_t;
 
-typedef void *(lvm_pthread_fn_t)(void*);
-
 /* Prototypes for code further down */
 static void sigusr2_handler(int sig);
 static void sighup_handler(int sig);
@@ -134,7 +132,7 @@
 static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
 				     int len, const char *csid,
 				     struct local_client **new_client);
-static void lvm_thread_fn(void *) __attribute__ ((noreturn));
+static void *lvm_thread_fn(void *);
 static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
 			   int msglen, const char *csid);
 static int distribute_command(struct local_client *thisfd);
@@ -333,7 +331,7 @@
 int main(int argc, char *argv[])
 {
 	int local_sock;
-	struct local_client *newfd;
+	struct local_client *newfd, *delfd;
 	struct utsname nodeinfo;
 	struct lvm_startup_params lvm_params;
 	int opt;
@@ -581,8 +579,7 @@
 	pthread_mutex_lock(&lvm_start_mutex);
 	lvm_params.using_gulm = using_gulm;
 	lvm_params.argv = argv;
-	pthread_create(&lvm_thread, NULL, (lvm_pthread_fn_t*)lvm_thread_fn,
-			(void *)&lvm_params);
+	pthread_create(&lvm_thread, NULL, lvm_thread_fn, &lvm_params);
 
 	/* Tell the rest of the cluster our version number */
 	/* CMAN can do this immediately, gulm needs to wait until
@@ -601,9 +598,27 @@
 	/* Do some work */
 	main_loop(local_sock, cmd_timeout);
 
+	pthread_mutex_lock(&lvm_thread_mutex);
+	pthread_cond_signal(&lvm_thread_cond);
+	pthread_mutex_unlock(&lvm_thread_mutex);
+	if ((errno = pthread_join(lvm_thread, NULL)))
+		log_sys_error("pthread_join", "");
+
 	close_local_sock(local_sock);
 	destroy_lvm();
 
+	for (newfd = local_client_head.next; newfd != NULL;) {
+		delfd = newfd;
+		newfd = newfd->next;
+		/*
+		 * FIXME:
+		 * needs cleanup code from read_from_local_sock() for now
+		 * break of 'clvmd' may access already free memory here.
+		 */
+		safe_close(&(delfd->fd));
+		free(delfd);
+	}
+
 	return 0;
 }
 
@@ -1932,7 +1947,7 @@
 /*
  * Routine that runs in the "LVM thread".
  */
-static void lvm_thread_fn(void *arg)
+static void *lvm_thread_fn(void *arg)
 {
 	struct dm_list *cmdl, *tmp;
 	sigset_t ss;
@@ -1953,7 +1968,7 @@
 	pthread_mutex_unlock(&lvm_start_mutex);
 
 	/* Now wait for some actual work */
-	for (;;) {
+	while (!quit) {
 		DEBUGLOG("LVM thread waiting for work\n");
 
 		pthread_mutex_lock(&lvm_thread_mutex);
@@ -1976,6 +1991,8 @@
 		}
 		pthread_mutex_unlock(&lvm_thread_mutex);
 	}
+
+	pthread_exit(NULL);
 }
 
 /* Pass down some work to the LVM thread */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-03-08 22:48:50

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

Log message:
	Do not send random bytes in message
	
	Fixing few issues:
	
	struct clvm_header  contains  'char args[1]' - so adding '+ 1' here
	for message length calculation is 1 byte off.
	Message with last byte uninitialized is then passed to write function.
	Update also related arglen.
	
	Initialise xid and clintid to 0.
	
	Memory allocation is checked for NULL

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1937&r2=1.1938
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/WHATS_NEW	2011/03/08 13:27:39	1.1937
+++ LVM2/WHATS_NEW	2011/03/08 22:48:50	1.1938
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Send 1 byte shorted fully initialised local clvmd messages.
   Support --help option for clvmd and return error for unknown option.
   Use system page size and not hardcoded value in locking code check.
   Fix reading of released memory for printing segment type.
--- LVM2/daemons/clvmd/clvmd.c	2011/03/08 13:27:40	1.99
+++ LVM2/daemons/clvmd/clvmd.c	2011/03/08 22:48:50	1.100
@@ -1749,13 +1749,18 @@
 	}
 
 	/* Add in the size of our header */
-	message_len = message_len + sizeof(struct clvm_header) + 1;
-	replybuf = malloc(message_len);
+	message_len = message_len + sizeof(struct clvm_header);
+	if (!(replybuf = malloc(message_len))) {
+		DEBUGLOG("Memory allocation fails\n");
+		return;
+	}
 
 	clientreply = (struct clvm_header *) replybuf;
 	clientreply->status = status;
 	clientreply->cmd = CLVMD_CMD_REPLY;
 	clientreply->node[0] = '\0';
+	clientreply->xid = 0;
+	clientreply->clientid = 0;
 	clientreply->flags = 0;
 
 	ptr = clientreply->args;
@@ -1790,7 +1795,7 @@
 	/* Terminate with an empty node name */
 	*ptr = '\0';
 
-	clientreply->arglen = ptr - clientreply->args + 1;
+	clientreply->arglen = ptr - clientreply->args;
 
 	/* And send it */
 	send_message(replybuf, message_len, our_csid, fd,


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2011-03-08 13:27 mbroz
  0 siblings, 0 replies; 38+ messages in thread
From: mbroz @ 2011-03-08 13:27 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2011-03-08 13:27:40

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

Log message:
	Fix clvmd return code for bad options.
	
	We should return exit code 2 for unknown option.
	
	Patch also adds standard --help option instead.
	
	Fixes https://bugzilla.redhat.com/show_bug.cgi?id=666991

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1936&r2=1.1937
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW	2011/03/06 16:47:43	1.1936
+++ LVM2/WHATS_NEW	2011/03/08 13:27:39	1.1937
@@ -1,5 +1,6 @@
 Version 2.02.85 - 
 ===================================
+  Support --help option for clvmd and return error for unknown option.
   Use system page size and not hardcoded value in locking code check.
   Fix reading of released memory for printing segment type.
   Fix syslog initialisation in clvmd to respect lvm.conf setting.
--- LVM2/daemons/clvmd/clvmd.c	2011/03/03 13:05:40	1.98
+++ LVM2/daemons/clvmd/clvmd.c	2011/03/08 13:27:40	1.99
@@ -20,6 +20,7 @@
 #include "clvmd-common.h"
 
 #include <pthread.h>
+#include <getopt.h>
 
 #include "clvmd-comms.h"
 #include "clvm.h"
@@ -335,7 +336,7 @@
 	struct local_client *newfd;
 	struct utsname nodeinfo;
 	struct lvm_startup_params lvm_params;
-	signed char opt;
+	int opt;
 	int cmd_timeout = DEFAULT_CMD_TIMEOUT;
 	int start_timeout = 0;
 	if_type_t cluster_iface = IF_AUTO;
@@ -346,19 +347,21 @@
 	int clusterwide_opt = 0;
 	mode_t old_mask;
 
+	struct option longopts[] = {
+		{ "help", 0, 0, 'h' },
+		{ NULL, 0, 0, 0 }
+	};
+
 	/* Deal with command-line arguments */
 	opterr = 0;
 	optind = 0;
-	while ((opt = getopt(argc, argv, "?vVhfd::t:RST:CI:E:")) != EOF) {
+	while ((opt = getopt_long(argc, argv, "vVhfd::t:RST:CI:E:",
+				  longopts, NULL)) != -1) {
 		switch (opt) {
 		case 'h':
 			usage(argv[0], stdout);
 			exit(0);
 
-		case '?':
-			usage(argv[0], stderr);
-			exit(0);
-
 		case 'R':
 			check_permissions();
 			return refresh_clvmd(1)==1?0:1;
@@ -409,6 +412,9 @@
 			exit(0);
 			break;
 
+		default:
+			usage(argv[0], stderr);
+			exit(2);
 		}
 	}
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2010-12-13 10:49 prajnoha
  0 siblings, 0 replies; 38+ messages in thread
From: prajnoha @ 2010-12-13 10:49 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2010-12-13 10:49:03

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

Log message:
	Create /var/run/lvm directory during clvmd initialisation if missing.
	
	We need to be sure that /var/run and /var/lock is always there.
	(E.g. these two directories could be using tmpfs which then loose
	all the content after reboot.)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1836&r2=1.1837
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88

--- LVM2/WHATS_NEW	2010/12/13 10:43:56	1.1836
+++ LVM2/WHATS_NEW	2010/12/13 10:49:02	1.1837
@@ -1,5 +1,6 @@
 Version 2.02.79 -  
 ===================================
+  Create /var/run/lvm directory during clvmd initialisation if missing.
   Use new dm_prepare_selinux_context instead of dm_set_selinux_context.
   Avoid revalidating the label cache immediately after scanning.
   Support scanning for a single VG in independent mdas.
--- LVM2/daemons/clvmd/clvmd.c	2010/12/13 10:43:56	1.87
+++ LVM2/daemons/clvmd/clvmd.c	2010/12/13 10:49:03	1.88
@@ -324,6 +324,7 @@
 	int using_gulm = 0;
 	int debug_opt = 0;
 	int clusterwide_opt = 0;
+	mode_t old_mask;
 
 	/* Deal with command-line arguments */
 	opterr = 0;
@@ -413,6 +414,16 @@
 		be_daemon(start_timeout);
 	}
 
+        dm_prepare_selinux_context(DEFAULT_RUN_DIR, S_IFDIR);
+        old_mask = umask(0077);
+        if (dm_create_dir(DEFAULT_RUN_DIR) == 0) {
+                DEBUGLOG("clvmd: unable to create %s directory\n",
+                          DEFAULT_RUN_DIR);
+                umask(old_mask);
+                exit(1);
+        }
+        umask(old_mask);
+
 	/* Create pidfile */
 	(void) dm_prepare_selinux_context(CLVMD_PIDFILE, S_IFREG);
 	if (dm_create_lockfile(CLVMD_PIDFILE) == 0) {


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2010-12-01 12:41 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2010-12-01 12:41 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-01 12:41:49

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

Log message:
	Log error from unlink failure

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1822&r2=1.1823
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86

--- LVM2/WHATS_NEW	2010/12/01 10:46:20	1.1822
+++ LVM2/WHATS_NEW	2010/12/01 12:41:49	1.1823
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Add logging for unlink() error in clvmd remove_lockfile().
   Add logging for pipe write() and close() error in clvmd child_init_signal().
   Add test for existance of orphan vginfo in _lvmcache_update_vgname().
   Do a full rescan if some device is missing in read_pvs_in_vg().
--- LVM2/daemons/clvmd/clvmd.c	2010/12/01 10:46:20	1.85
+++ LVM2/daemons/clvmd/clvmd.c	2010/12/01 12:41:49	1.86
@@ -289,7 +289,8 @@
 
 static void remove_lockfile(void)
 {
-	unlink(CLVMD_PIDFILE);
+	if (unlink(CLVMD_PIDFILE))
+		log_sys_error("unlink", CLVMD_PIDFILE);
 }
 
 /*


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2010-12-01 10:46 zkabelac
  0 siblings, 0 replies; 38+ messages in thread
From: zkabelac @ 2010-12-01 10:46 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-01 10:46:21

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

Log message:
	Add logging for pipe write() and close() error
	
	Check values from write() and close() system calls.
	
	FIXME: Missing wrapper around 'write()'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1821&r2=1.1822
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.84&r2=1.85

--- LVM2/WHATS_NEW	2010/12/01 10:39:28	1.1821
+++ LVM2/WHATS_NEW	2010/12/01 10:46:20	1.1822
@@ -1,5 +1,6 @@
 Version 2.02.78 - 
 ====================================
+  Add logging for pipe write() and close() error in clvmd child_init_signal().
   Add test for existance of orphan vginfo in _lvmcache_update_vgname().
   Do a full rescan if some device is missing in read_pvs_in_vg().
   Avoid misleading warnings in vgextend --restoremissing in certain cases.
--- LVM2/daemons/clvmd/clvmd.c	2010/11/29 12:44:52	1.84
+++ LVM2/daemons/clvmd/clvmd.c	2010/12/01 10:46:20	1.85
@@ -180,9 +180,12 @@
 /* Called to signal the parent how well we got on during initialisation */
 static void child_init_signal(int status)
 {
-        if (child_pipe[1]) {
-	        write(child_pipe[1], &status, sizeof(status));
-		close(child_pipe[1]);
+	if (child_pipe[1]) {
+		/* FIXME Use a proper wrapper around write */
+		if (write(child_pipe[1], &status, sizeof(status)) < 0)
+			log_sys_error("write", "child_pipe");
+		if (close(child_pipe[1]))
+			log_sys_error("close", "child_pipe");
 	}
 }
 


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2010-04-06 15:29 ccaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: ccaulfield @ 2010-04-06 15:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2010-04-06 15:29:31

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

Log message:
	Fix a thread race in clvmd that could cause lockups on very busy systems

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1502&r2=1.1503
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65

--- LVM2/WHATS_NEW	2010/04/06 14:07:11	1.1502
+++ LVM2/WHATS_NEW	2010/04/06 15:29:30	1.1503
@@ -1,5 +1,6 @@
 Version 2.02.63 -  
 ================================
+  Fix another thread race in clvmd.
   Refactor management of vg->pvs list.
   Fix lcov rules and generate better coverage report.
   Improve vg_validate to detect some loops in lists.
--- LVM2/daemons/clvmd/clvmd.c	2010/03/18 09:19:31	1.64
+++ LVM2/daemons/clvmd/clvmd.c	2010/04/06 15:29:30	1.65
@@ -1516,7 +1516,8 @@
 		DEBUGLOG("Waiting to do post command - state = %d\n",
 			 client->bits.localsock.state);
 
-		if (client->bits.localsock.state != POST_COMMAND) {
+		if (client->bits.localsock.state != POST_COMMAND &&
+		    !client->bits.localsock.finished) {
 			pthread_cond_wait(&client->bits.localsock.cond,
 					  &client->bits.localsock.mutex);
 		}


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2010-02-02  8:54 ccaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: ccaulfield @ 2010-02-02  8:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2010-02-02 08:54:29

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

Log message:
	Make clvmd -V return zero status rather than 1.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1413&r2=1.1414
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63

--- LVM2/WHATS_NEW	2010/01/27 22:28:05	1.1413
+++ LVM2/WHATS_NEW	2010/02/02 08:54:29	1.1414
@@ -1,3 +1,8 @@
+Version 2.02.60 - 
+===================================
+  Make clvmd -V return zero status.
+
+
 Version 2.02.60 - 23rd January 2010
 ===================================
   Fix lvconvert issue with cluster mirrors due to un'_safe' list processing
--- LVM2/daemons/clvmd/clvmd.c	2009/10/12 08:33:30	1.62
+++ LVM2/daemons/clvmd/clvmd.c	2010/02/02 08:54:29	1.63
@@ -342,7 +342,7 @@
 			printf("Protocol version:           %d.%d.%d\n",
 			       CLVMD_MAJOR_VERSION, CLVMD_MINOR_VERSION,
 			       CLVMD_PATCH_VERSION);
-			exit(1);
+			exit(0);
 			break;
 
 		}


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-10-12 08:33:30

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

Log message:
	Make clvmd return 0 on success rather than 1.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1292&r2=1.1293
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62

--- LVM2/WHATS_NEW	2009/10/05 20:55:56	1.1292
+++ LVM2/WHATS_NEW	2009/10/12 08:33:30	1.1293
@@ -1,5 +1,6 @@
 Version 2.02.54 -
 =====================================
+  Make clvmd return 0 on success rather than 1.
   Add --pvmetadatacopies for pvcreate, vgcreate, vgextend, vgconvert.
   Add implict pvcreate support to vgcreate and vgextend.
   Correct example.conf to indicate that lvm2 not lvm1 is the default format.
--- LVM2/daemons/clvmd/clvmd.c	2009/09/01 09:48:01	1.61
+++ LVM2/daemons/clvmd/clvmd.c	2009/10/12 08:33:30	1.62
@@ -303,7 +303,7 @@
 			exit(0);
 
 		case 'R':
-			return refresh_clvmd();
+			return refresh_clvmd()==1?0:1;
 
 		case 'C':
 			clusterwide_opt = 1;
@@ -354,7 +354,7 @@
 		/* Sending to stderr makes no sense for a detached daemon */
 		if (debug == DEBUG_STDERR)
 			debug = DEBUG_SYSLOG;
-		return debug_clvmd(debug, clusterwide_opt);
+		return debug_clvmd(debug, clusterwide_opt)==1?0:1;
 	}
 
 	/* Fork into the background (unless requested not to) */


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2009-09-01  9:48 ccaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: ccaulfield @ 2009-09-01  9:48 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-09-01 09:48:01

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

Log message:
	Add some code to clvmd to look in the corosync confdb to see what cluster
	interface it should be using, it can still be overriden with -I.
	
	If corosync isn't running or there is no information then the usual
	checking will happen.
	
	This code only builds if corosync is available.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1246&r2=1.1247
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61

--- LVM2/WHATS_NEW	2009/08/28 20:51:40	1.1246
+++ LVM2/WHATS_NEW	2009/09/01 09:48:01	1.1247
@@ -1,5 +1,6 @@
 Version 2.02.52 -
 =================================
+  Make clvmd check corosync to see what cluster interface it should use.
   Rewrite clvmd configuration code to cope with all combinations of libs.
   Fix global locking in PV reporting commands (2.02.49).
   Fix pvcreate string termination in duplicate uuid warning message.
--- LVM2/daemons/clvmd/clvmd.c	2009/08/13 10:39:41	1.60
+++ LVM2/daemons/clvmd/clvmd.c	2009/09/01 09:48:01	1.61
@@ -44,7 +44,9 @@
 #include <syslog.h>
 #include <errno.h>
 #include <limits.h>
-#include <libdlm.h>
+#ifdef HAVE_COROSYNC_CONFDB_H
+#include <corosync/confdb.h>
+#endif
 
 #include "clvmd-comms.h"
 #include "lvm-functions.h"
@@ -149,6 +151,7 @@
 static void add_reply_to_list(struct local_client *client, int status,
 			      const char *csid, const char *buf, int len);
 static if_type_t parse_cluster_interface(char *ifname);
+static if_type_t get_cluster_type(void);
 
 static void usage(char *prog, FILE *file)
 {
@@ -392,6 +395,9 @@
 	init_lvhash();
 
 	/* Start the cluster interface */
+	if (cluster_iface == IF_AUTO)
+		cluster_iface = get_cluster_type();
+
 #ifdef USE_CMAN
 	if ((cluster_iface == IF_AUTO || cluster_iface == IF_CMAN) && (clops = init_cman_cluster())) {
 		max_csid_len = CMAN_MAX_CSID_LEN;
@@ -2060,3 +2066,59 @@
 
 	return iface;
 }
+
+/*
+ * Try and find a cluster system in corosync's objdb, if it is running. This is
+ * 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()
+{
+#ifdef HAVE_COROSYNC_CONFDB_H
+	confdb_handle_t handle;
+	if_type_t type = IF_AUTO;
+	int result;
+	char buf[255];
+	size_t namelen = sizeof(buf);
+	hdb_handle_t cluster_handle;
+	hdb_handle_t clvmd_handle;
+	confdb_callbacks_t callbacks = {
+		.confdb_key_change_notify_fn = NULL,
+		.confdb_object_create_change_notify_fn = NULL,
+		.confdb_object_delete_change_notify_fn = NULL
+	};
+
+	result = confdb_initialize (&handle, &callbacks);
+        if (result != CS_OK)
+		return type;
+
+        result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
+	if (result != CS_OK)
+		goto out;
+
+        result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, (void *)"cluster", strlen("cluster"), &cluster_handle);
+        if (result != CS_OK)
+		goto out;
+
+        result = confdb_object_find_start(handle, cluster_handle);
+	if (result != CS_OK)
+		goto out;
+
+        result = confdb_object_find(handle, cluster_handle, (void *)"clvmd", strlen("clvmd"), &clvmd_handle);
+        if (result != CS_OK)
+		goto out;
+
+        result = confdb_key_get(handle, clvmd_handle, (void *)"interface", strlen("interface"), buf, &namelen);
+        if (result != CS_OK)
+		goto out;
+
+	buf[namelen] = '\0';
+	type = parse_cluster_interface(buf);
+	DEBUGLOG("got interface type '%s' from confdb\n", buf);
+out:
+	confdb_finalize(handle);
+	return type;
+#else
+	return IF_AUTO;
+#endif
+}


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2009-08-13 10:39 ccaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: ccaulfield @ 2009-08-13 10:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-08-13 10:39:42

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

Log message:
	Fix compilation warning in clvmd.c

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1234&r2=1.1235
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60

--- LVM2/WHATS_NEW	2009/08/06 19:32:26	1.1234
+++ LVM2/WHATS_NEW	2009/08/13 10:39:41	1.1235
@@ -1,5 +1,6 @@
 Version 2.02.52 -
 =================================
+  Fix compile warning in clvmd.
 
 Version 2.02.51 - 6th August 2009
 =================================
--- LVM2/daemons/clvmd/clvmd.c	2009/06/15 12:15:23	1.59
+++ LVM2/daemons/clvmd/clvmd.c	2009/08/13 10:39:41	1.60
@@ -110,6 +110,8 @@
 
 typedef enum {IF_AUTO, IF_CMAN, IF_GULM, IF_OPENAIS, IF_COROSYNC} if_type_t;
 
+typedef void *(lvm_pthread_fn_t)(void*);
+
 /* Prototypes for code further down */
 static void sigusr2_handler(int sig);
 static void sighup_handler(int sig);
@@ -138,7 +140,7 @@
 static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
 				     int len, const char *csid,
 				     struct local_client **new_client);
-static void *lvm_thread_fn(void *);
+static void lvm_thread_fn(void *) __attribute__ ((noreturn));
 static int add_to_lvmqueue(struct local_client *client, struct clvm_header *msg,
 			   int msglen, const char *csid);
 static int distribute_command(struct local_client *thisfd);
@@ -461,7 +463,7 @@
 
 	/* Don't let anyone else to do work until we are started */
 	pthread_mutex_lock(&lvm_start_mutex);
-	pthread_create(&lvm_thread, NULL, lvm_thread_fn,
+	pthread_create(&lvm_thread, NULL, (lvm_pthread_fn_t*)lvm_thread_fn,
 			(void *)(long)using_gulm);
 
 	/* Tell the rest of the cluster our version number */
@@ -1797,7 +1799,7 @@
 /*
  * Routine that runs in the "LVM thread".
  */
-static __attribute__ ((noreturn)) void *lvm_thread_fn(void *arg)
+static void lvm_thread_fn(void *arg)
 {
 	struct dm_list *cmdl, *tmp;
 	sigset_t ss;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2009-03-24 11:49:16

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

Log message:
	Block SIGINT & SIGTERM in clvmd subthreads so they don't delay shutdown.
	Patch from Xinwei Hu, Thanks

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1071&r2=1.1072
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56

--- LVM2/WHATS_NEW	2009/03/23 22:57:27	1.1071
+++ LVM2/WHATS_NEW	2009/03/24 11:49:15	1.1072
@@ -1,5 +1,6 @@
 Version 2.02.46 - 
 ================================
+  Block SIGTERM & SIGINT in clvmd subthreads.
   Detect and conditionally wipe swapspace signatures in pvcreate.
   Fix maximal volume count check for snapshots if max_lv set for volume group.
   Fix lvcreate to remove cow volume if the snapshot creation fails.
--- LVM2/daemons/clvmd/clvmd.c	2009/02/22 22:11:58	1.55
+++ LVM2/daemons/clvmd/clvmd.c	2009/03/24 11:49:15	1.56
@@ -372,9 +372,11 @@
 	signal(SIGHUP,  sighup_handler);
 	signal(SIGPIPE, SIG_IGN);
 
-	/* Block SIGUSR2 in the main process */
+	/* Block SIGUSR2/SIGINT/SIGTERM in process */
 	sigemptyset(&ss);
 	sigaddset(&ss, SIGUSR2);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
 	sigprocmask(SIG_BLOCK, &ss, NULL);
 
 	/* Initialise the LVM thread variables */
@@ -669,6 +671,11 @@
 {
 	DEBUGLOG("Using timeout of %d seconds\n", cmd_timeout);
 
+	sigset_t ss;
+	sigemptyset(&ss);
+	sigaddset(&ss, SIGINT);
+	sigaddset(&ss, SIGTERM);
+	pthread_sigmask(SIG_UNBLOCK, &ss, NULL);
 	/* Main loop */
 	while (!quit) {
 		fd_set in;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-11-21 13:48:00

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

Log message:
	Fix a starup race in clvmd that could result in huge waits for the first command to be processed.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.998&r2=1.999
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52

--- LVM2/WHATS_NEW	2008/11/19 19:33:25	1.998
+++ LVM2/WHATS_NEW	2008/11/21 13:48:00	1.999
@@ -1,5 +1,6 @@
 Version 2.02.44 - 
 ====================================
+  Fix startup race in clvmd.
   Generate Red Hat clvmd startup script at configuration time with correct paths.
   Fix clvmd & dmeventd builds after tree restructuring.
   Cope with snapshot dependencies when removing a whole VG with lvremove.
--- LVM2/daemons/clvmd/clvmd.c	2008/11/04 16:41:47	1.51
+++ LVM2/daemons/clvmd/clvmd.c	2008/11/21 13:48:00	1.52
@@ -423,6 +423,9 @@
 	/* This needs to be started after cluster initialisation
 	   as it may need to take out locks */
 	DEBUGLOG("starting LVM thread\n");
+
+	/* Don't let anyone else to do work until we are started */
+	pthread_mutex_lock(&lvm_start_mutex);
 	pthread_create(&lvm_thread, NULL, lvm_thread_fn,
 			(void *)(long)using_gulm);
 
@@ -1758,9 +1761,6 @@
 	sigset_t ss;
 	int using_gulm = (int)(long)arg;
 
-	/* Don't let anyone else to do work until we are started */
-	pthread_mutex_lock(&lvm_start_mutex);
-
 	DEBUGLOG("LVM thread function started\n");
 
 	/* Ignore SIGUSR1 & 2 */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-06-13 07:44:15

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

Log message:
	Don't call openlog for every invocation of debuglog.
	Patch from Masatake YAMATO

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.901&r2=1.902
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48

--- LVM2/WHATS_NEW	2008/06/12 13:24:02	1.901
+++ LVM2/WHATS_NEW	2008/06/13 07:44:14	1.902
@@ -1,5 +1,6 @@
 Version 2.02.39 -
 ================================
+  Don't call openlog for every debug line output by clvmd.
   Add --force to lvextend and lvresize.
   Fix vgchange to not activate mirror leg and log volumes directly.
   Fix test directory clean up in make distclean.
--- LVM2/daemons/clvmd/clvmd.c	2008/06/05 14:24:28	1.47
+++ LVM2/daemons/clvmd/clvmd.c	2008/06/13 07:44:14	1.48
@@ -182,8 +182,10 @@
 		va_end(ap);
 	}
 	if (debug == DEBUG_SYSLOG) {
-		if (!syslog_init)
+		if (!syslog_init) {
 			openlog("clvmd", LOG_PID, LOG_DAEMON);
+			syslog_init = 1;
+		}
 
 		va_start(ap,fmt);
 		vsyslog(LOG_DEBUG, fmt, ap);


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2008-05-09  9:59 ccaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: ccaulfield @ 2008-05-09  9:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-05-09 09:59:39

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

Log message:
	Fix uninitialised mutex in clvmd if all daemons are not running at startup.
	
	Thanks to Mark Hlawatschek for pointing this out.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.871&r2=1.872
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46

--- LVM2/WHATS_NEW	2008/05/09 07:20:04	1.871
+++ LVM2/WHATS_NEW	2008/05/09 09:59:39	1.872
@@ -1,5 +1,6 @@
 Version 2.02.38 - 
 =================================
+  Fix uninitialised mutex in clvmd if all daemons are not running at startup.
   Make clvmd-cman use a hash rather than an array for node updown info.
   Check lv_count in vg_validate.
   Add --prefixes to reporting tools for field name prefix output format.
--- LVM2/daemons/clvmd/clvmd.c	2008/03/28 12:58:09	1.45
+++ LVM2/daemons/clvmd/clvmd.c	2008/05/09 09:59:39	1.46
@@ -530,7 +530,7 @@
 		char nodename[max_cluster_member_name_len];
 
 		clops->name_from_csid(csid, nodename);
-		DEBUGLOG("PJC: checking for a reply from %s\n", nodename);
+		DEBUGLOG("Checking for a reply from %s\n", nodename);
 		pthread_mutex_lock(&client->bits.localsock.reply_mutex);
 
 		reply = client->bits.localsock.replies;
@@ -541,7 +541,7 @@
 		pthread_mutex_unlock(&client->bits.localsock.reply_mutex);
 
 		if (!reply) {
-			DEBUGLOG("PJC: node %s timed-out\n", nodename);
+			DEBUGLOG("Node %s timed-out\n", nodename);
 			add_reply_to_list(client, ETIMEDOUT, csid,
 					  "Command timed out", 18);
 		}
@@ -985,6 +985,14 @@
 			}
 		}
 
+		/* Initialise and lock the mutex so the subthread will wait after
+		   finishing the PRE routine */
+		if (!thisfd->bits.localsock.threadid) {
+			pthread_mutex_init(&thisfd->bits.localsock.mutex, NULL);
+			pthread_cond_init(&thisfd->bits.localsock.cond, NULL);
+			pthread_mutex_init(&thisfd->bits.localsock.reply_mutex, NULL);
+		}
+
 		/* Only run the command if all the cluster nodes are running CLVMD */
 		if (((inheader->flags & CLVMD_FLAG_LOCAL) == 0) &&
 		    (check_all_clvmds_running(thisfd) == -1)) {
@@ -1056,12 +1064,6 @@
 
 		thisfd->bits.localsock.pipe = comms_pipe[1];
 
-		/* Initialise and lock the mutex so the subthread will wait after
-		   finishing the PRE routine */
-		pthread_mutex_init(&thisfd->bits.localsock.mutex, NULL);
-		pthread_cond_init(&thisfd->bits.localsock.cond, NULL);
-		pthread_mutex_init(&thisfd->bits.localsock.reply_mutex, NULL);
-
 		/* Make sure the thread has a copy of it's own ID */
 		newfd->bits.pipe.threadid = thisfd->bits.localsock.threadid;
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-03-28 12:58:10

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

Log message:
	Fix a couple of uninitialised variables. The newfd one could cause
	some obscure hangs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.810&r2=1.811
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45

--- LVM2/WHATS_NEW	2008/03/26 18:03:35	1.810
+++ LVM2/WHATS_NEW	2008/03/28 12:58:08	1.811
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Fix uninitialised variable in clvmd that could cause odd hangs.
   Add vgmerge tests.
   Add pvseg_is_allocated() for identifying a PV segment allocated to a LV.
   Add list_move() for moving elements from one list to another.
--- LVM2/daemons/clvmd/clvmd.c	2008/03/17 09:37:47	1.44
+++ LVM2/daemons/clvmd/clvmd.c	2008/03/28 12:58:09	1.45
@@ -633,7 +633,7 @@
 				}
 
 				if (FD_ISSET(thisfd->fd, &in)) {
-					struct local_client *newfd;
+					struct local_client *newfd = NULL;
 					int ret;
 
 					/* Do callback */
@@ -1613,7 +1613,7 @@
 static int send_message(void *buf, int msglen, const char *csid, int fd,
 			const char *errtext)
 {
-	int len;
+	int len = 0;
 	int saved_errno = 0;
 	struct timespec delay;
 	struct timespec remtime;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield@sourceware.org	2008-03-17 09:37:47

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

Log message:
	Fix potential thread deadlock.
	Also make local sockets non-blocking.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.803&r2=1.804
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44

--- LVM2/WHATS_NEW	2008/03/13 12:33:21	1.803
+++ LVM2/WHATS_NEW	2008/03/17 09:37:47	1.804
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Fix potential deadlock in clvmd thread handling.
   Refactor text format initialisation into _init_text_import.
   Escape double quotes and backslashes in external metadata and config data.
   Add functions for escaping double quotes in strings.
--- LVM2/daemons/clvmd/clvmd.c	2008/03/06 08:41:05	1.43
+++ LVM2/daemons/clvmd/clvmd.c	2008/03/17 09:37:47	1.44
@@ -1416,7 +1416,8 @@
 		DEBUGLOG("Waiting for next pre command\n");
 
 		pthread_mutex_lock(&client->bits.localsock.mutex);
-		if (client->bits.localsock.state != PRE_COMMAND) {
+		if (client->bits.localsock.state != PRE_COMMAND &&
+		    !client->bits.localsock.finished) {
 			pthread_cond_wait(&client->bits.localsock.cond,
 					  &client->bits.localsock.mutex);
 		}
@@ -1822,8 +1823,9 @@
 		log_error("Can't create local socket: %m");
 		return -1;
 	}
-	/* Set Close-on-exec */
+	/* Set Close-on-exec & non-blocking */
 	fcntl(local_socket, F_SETFD, 1);
+	fcntl(local_socket, F_SETFL, fcntl(local_socket, F_GETFL, 0) | O_NONBLOCK);
 
 	memset(&sockaddr, 0, sizeof(sockaddr));
 	memcpy(sockaddr.sun_path, CLVMD_SOCKNAME, sizeof(CLVMD_SOCKNAME));


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2008-02-15 14:12 meyering
  0 siblings, 0 replies; 38+ messages in thread
From: meyering @ 2008-02-15 14:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	meyering@sourceware.org	2008-02-15 14:12:33

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

Log message:
	Remove redundant if-before-free tests in clvmd.c.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.794&r2=1.795
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42

--- LVM2/WHATS_NEW	2008/02/13 20:01:48	1.794
+++ LVM2/WHATS_NEW	2008/02/15 14:12:32	1.795
@@ -1,5 +1,6 @@
 Version 2.02.34 -
 ===================================
+  Remove redundant if-before-free tests in clvmd.c.
   Avoid a compiler warning: make is_orphan's parameter "const".
   Fix lvconvert detection of mirror conversion in progress. (2.02.30)
   Avoid automatic lvconvert polldaemon invocation when -R specified. (2.02.30)
--- LVM2/daemons/clvmd/clvmd.c	2008/02/05 09:38:04	1.41
+++ LVM2/daemons/clvmd/clvmd.c	2008/02/15 14:12:32	1.42
@@ -903,8 +903,7 @@
 		}
 
 		/* Free the command buffer */
-		if (thisfd->bits.localsock.cmd)
-			free(thisfd->bits.localsock.cmd);
+		free(thisfd->bits.localsock.cmd);
 
 		/* Clear out the cross-link */
 		if (thisfd->bits.localsock.pipe_client != NULL)
@@ -939,8 +938,7 @@
 		}
 
 		/* Free any old buffer space */
-		if (thisfd->bits.localsock.cmd)
-			free(thisfd->bits.localsock.cmd);
+		free(thisfd->bits.localsock.cmd);
 
 		/* See if we have the whole message */
 		argslen =
@@ -1547,8 +1545,7 @@
 		}
 		thisreply = thisreply->next;
 
-		if (tempreply->replymsg)
-			free(tempreply->replymsg);
+		free(tempreply->replymsg);
 		free(tempreply);
 	}
 
@@ -1579,8 +1576,7 @@
 
 		thisreply = thisreply->next;
 
-		if (tempreply->replymsg)
-			free(tempreply->replymsg);
+		free(tempreply->replymsg);
 		free(tempreply);
 	}
 	client->bits.localsock.replies = NULL;
@@ -1732,8 +1728,7 @@
 			pthread_mutex_unlock(&lvm_thread_mutex);
 
 			process_work_item(cmd);
-			if (cmd->msg)
-				free(cmd->msg);
+			free(cmd->msg);
 			free(cmd);
 
 			pthread_mutex_lock(&lvm_thread_mutex);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2007-11-15 10:16:14

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

Log message:
	If the pre_command fails then go back and wait patiently for the next
	pre function rather than retrying it until we get stuck!

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.736&r2=1.737
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40

--- LVM2/WHATS_NEW	2007/11/15 02:20:03	1.736
+++ LVM2/WHATS_NEW	2007/11/15 10:16:14	1.737
@@ -1,5 +1,6 @@
 Version 2.02.29 -
 ==================================
+  Stop clvmd going haywire if a pre_function fails.
   Convert some vg_reads into vg_lock_and_reads.
   Avoid nested vg_reads when processing PVs in VGs and fix associated locking.
   Accept sizes with --readahead argument.
--- LVM2/daemons/clvmd/clvmd.c	2007/08/17 11:51:23	1.39
+++ LVM2/daemons/clvmd/clvmd.c	2007/11/15 10:16:14	1.40
@@ -1379,8 +1379,10 @@
 			break;
 		} while(1);
 
-		if (status)
-			continue; /* Wait for another PRE command */
+		if (status) {
+			client->bits.localsock.state = POST_COMMAND;
+			goto next_pre;
+		}
 
 		/* We may need to wait for the condition variable before running the post command */
 		pthread_mutex_lock(&client->bits.localsock.mutex);
@@ -1409,7 +1411,7 @@
 			log_error("Error sending to pipe: %m\n");
 			break;
 		} while(1);
-
+next_pre:
 		DEBUGLOG("Waiting for next pre command\n");
 
 		pthread_mutex_lock(&client->bits.localsock.mutex);


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

* LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c
@ 2007-03-29 13:59 pcaulfield
  0 siblings, 0 replies; 38+ messages in thread
From: pcaulfield @ 2007-03-29 13:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2007-03-29 14:59:33

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

Log message:
	Add some extra error checking & robustness.
	Thanks to the Crosswalk engineering team:
	Leonard Maiorani
	Henry Harris
	Scott Cannata

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.593&r2=1.594
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34

--- LVM2/WHATS_NEW	2007/03/27 13:35:33	1.593
+++ LVM2/WHATS_NEW	2007/03/29 13:59:32	1.594
@@ -5,6 +5,7 @@
   Fix creation and conversion of mirrors with tags.
   Fix vgsplit for lvm1 format (set and validate VG name in PVs metadata).
   Split metadata areas in vgsplit properly.
+  Add extra internal error checking to clvmd
 
 Version 2.02.24 - 19th March 2007
 =================================
--- LVM2/daemons/clvmd/clvmd.c	2006/12/11 13:48:41	1.33
+++ LVM2/daemons/clvmd/clvmd.c	2007/03/29 13:59:33	1.34
@@ -56,6 +56,8 @@
 #define FALSE 0
 #endif
 
+#define MAX_RETRIES 4
+
 /* The maximum size of a message that will fit into a packet. Anything bigger
    than this is sent via the system LV */
 #define MAX_INLINE_MESSAGE (max_cluster_message-sizeof(struct clvm_header))
@@ -325,7 +327,7 @@
 	/* This needs to be started after cluster initialisation
 	   as it may need to take out locks */
 	DEBUGLOG("starting LVM thread\n");
-	pthread_create(&lvm_thread, NULL, lvm_thread_fn, 
+	pthread_create(&lvm_thread, NULL, lvm_thread_fn,
 			(void *)(long)using_gulm);
 
 	/* Tell the rest of the cluster our version number */
@@ -375,6 +377,9 @@
 	socklen_t sl = sizeof(socka);
 	int client_fd = accept(thisfd->fd, (struct sockaddr *) &socka, &sl);
 
+	if (client_fd == -1 && errno == EINTR)
+		return 1;
+
 	if (client_fd >= 0) {
 		newfd = malloc(sizeof(struct local_client));
 		if (!newfd) {
@@ -412,6 +417,8 @@
 	int status = -1;	/* in error by default */
 
 	len = read(thisfd->fd, buffer, sizeof(int));
+	if (len == -1 && errno == EINTR)
+		return 1;
 
 	if (len == sizeof(int)) {
 		memcpy(&status, buffer, sizeof(int));
@@ -786,6 +793,8 @@
 	char buffer[PIPE_BUF];
 
 	len = read(thisfd->fd, buffer, sizeof(buffer));
+	if (len == -1 && errno == EINTR)
+		return 1;
 
 	DEBUGLOG("Read on local socket %d, len = %d\n", thisfd->fd, len);
 
@@ -901,8 +910,12 @@
 		    len - strlen(inheader->node) - sizeof(struct clvm_header);
 		missing_len = inheader->arglen - argslen;
 
+		if (missing_len < 0)
+			missing_len = 0;
+
 		/* Save the message */
 		thisfd->bits.localsock.cmd = malloc(len + missing_len);
+
 		if (!thisfd->bits.localsock.cmd) {
 			struct clvm_header reply;
 			reply.cmd = CLVMD_CMD_REPLY;
@@ -927,9 +940,8 @@
 				DEBUGLOG
 				    ("got %d bytes, need another %d (total %d)\n",
 				     argslen, missing_len, inheader->arglen);
-				len =
-				    read(thisfd->fd, argptr + argslen,
-					 missing_len);
+				len = read(thisfd->fd, argptr + argslen,
+					   missing_len);
 				if (len >= 0) {
 					missing_len -= len;
 					argslen += len;
@@ -1215,7 +1227,7 @@
 	/* Version check is internal - don't bother exposing it in
 	   clvmd-command.c */
 	if (msg->cmd == CLVMD_CMD_VERSION) {
-		int version_nums[3]; 
+		int version_nums[3];
 		char node[256];
 
 		memcpy(version_nums, msg->args, sizeof(version_nums));
@@ -1395,6 +1407,7 @@
 {
 	struct local_client *client = (struct local_client *) arg;
 	int status;
+	int write_status;
 	sigset_t ss;
 	int pipe_fd = client->bits.localsock.pipe;
 
@@ -1424,8 +1437,19 @@
 			client->bits.localsock.all_success = 0;
 
 		DEBUGLOG("Writing status %d down pipe %d\n", status, pipe_fd);
+
 		/* Tell the parent process we have finished this bit */
-		write(pipe_fd, &status, sizeof(int));
+		do {
+			write_status = write(pipe_fd, &status, sizeof(int));
+			if (write_status == sizeof(int))
+				break;
+			if (write_status < 0 &&
+			    (errno == EINTR || errno == EAGAIN))
+				continue;
+			log_error("Error sending to pipe: %m\n");
+			break;
+		} while(1);
+
 		if (status)
 			continue; /* Wait for another PRE command */
 
@@ -1446,7 +1470,16 @@
 		status = 0;
 		do_post_command(client);
 
-		write(pipe_fd, &status, sizeof(int));
+		do {
+			write_status = write(pipe_fd, &status, sizeof(int));
+			if (write_status == sizeof(int))
+				break;
+			if (write_status < 0 &&
+			    (errno == EINTR || errno == EAGAIN))
+				continue;
+			log_error("Error sending to pipe: %m\n");
+			break;
+		} while(1);
 
 		DEBUGLOG("Waiting for next pre command\n");
 
@@ -1650,6 +1683,11 @@
 			const char *errtext)
 {
 	int len;
+	int saved_errno = 0;
+	struct timespec delay;
+	struct timespec remtime;
+
+	int retry_cnt = 0;
 
 	/* Send remote messages down the cluster socket */
 	if (csid == NULL || !ISLOCAL_CSID(csid)) {
@@ -1660,14 +1698,38 @@
 
 		/* Make sure it all goes */
 		do {
+			if (retry_cnt > MAX_RETRIES)
+			{
+				errno = saved_errno;
+				log_error(errtext);
+				errno = saved_errno;
+				break;
+			}
+
 			len = write(fd, buf + ptr, msglen - ptr);
 
 			if (len <= 0) {
+				if (errno == EINTR)
+					continue;
+				if (errno == EAGAIN ||
+				    errno == EIO ||
+				    errno == ENOSPC) {
+					saved_errno = errno;
+					retry_cnt++;
+
+					delay.tv_sec = 0;
+					delay.tv_nsec = 100000;
+					remtime.tv_sec = 0;
+					remtime.tv_nsec = 0;
+					(void) nanosleep (&delay, &remtime);
+
+					continue;
+				}
 				log_error(errtext);
 				break;
 			}
 			ptr += len;
-		} while (len < msglen);
+		} while (ptr < msglen);
 	}
 	return len;
 }


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2006-12-11 13:48:41

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

Log message:
	Fix hang in clvmd if a pre-command failed. The pre/post thread was getting
	out of sync in this instance and would not quit.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.515&r2=1.516
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33

--- LVM2/WHATS_NEW	2006/12/01 23:29:54	1.515
+++ LVM2/WHATS_NEW	2006/12/11 13:48:41	1.516
@@ -1,5 +1,6 @@
 Version 2.02.17 -
 ===================================
+  Fix hang in clvmd if a pre-command failed.
 
 Version 2.02.16 - 1st December 2006
 ===================================
--- LVM2/daemons/clvmd/clvmd.c	2006/12/01 23:10:25	1.32
+++ LVM2/daemons/clvmd/clvmd.c	2006/12/11 13:48:41	1.33
@@ -1426,6 +1426,8 @@
 		DEBUGLOG("Writing status %d down pipe %d\n", status, pipe_fd);
 		/* Tell the parent process we have finished this bit */
 		write(pipe_fd, &status, sizeof(int));
+		if (status)
+			continue; /* Wait for another PRE command */
 
 		/* We may need to wait for the condition variable before running the post command */
 		pthread_mutex_lock(&client->bits.localsock.mutex);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2006-11-30 09:44:07

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

Log message:
	Add -T (startup timeout) switch to clvmd

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.507&r2=1.508
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30

--- LVM2/WHATS_NEW	2006/11/23 17:23:14	1.507
+++ LVM2/WHATS_NEW	2006/11/30 09:44:06	1.508
@@ -1,5 +1,6 @@
 Version 2.02.16 -
 ====================================
+  Add -T (startup timeout) switch to clvmd.
   Improve lvm_dump.sh robustness.
   Update lvm2create_initrd to support gentoo.
 
--- LVM2/daemons/clvmd/clvmd.c	2006/10/09 14:11:57	1.29
+++ LVM2/daemons/clvmd/clvmd.c	2006/11/30 09:44:07	1.30
@@ -99,6 +99,7 @@
 #define DFAIL_LOCAL_SOCK 2
 #define DFAIL_CLUSTER_IF 3
 #define DFAIL_MALLOC     4
+#define DFAIL_TIMEOUT    5
 #define SUCCESS          0
 
 /* Prototypes for code further down */
@@ -122,7 +123,7 @@
 static int open_local_sock(void);
 static struct local_client *find_client(int clientid);
 static void main_loop(int local_sock, int cmd_timeout);
-static void be_daemon(void);
+static void be_daemon(int start_timeout);
 static int check_all_clvmds_running(struct local_client *client);
 static int local_rendezvous_callback(struct local_client *thisfd, char *buf,
 				     int len, char *csid,
@@ -146,6 +147,7 @@
 	fprintf(file, "   -d       Don't fork, run in the foreground\n");
 	fprintf(file, "   -R       Tell all running clvmds in the cluster to reload their device cache\n");
 	fprintf(file, "   -t<secs> Command timeout (default 60 seconds)\n");
+	fprintf(file, "   -T<secs> Startup timeout (default none)\n");
 	fprintf(file, "\n");
 }
 
@@ -169,13 +171,14 @@
 	signed char opt;
 	int debug = 0;
 	int cmd_timeout = DEFAULT_CMD_TIMEOUT;
+	int start_timeout = 0;
 	sigset_t ss;
 	int using_gulm = 0;
 
 	/* Deal with command-line arguments */
 	opterr = 0;
 	optind = 0;
-	while ((opt = getopt(argc, argv, "?vVhdt:R")) != EOF) {
+	while ((opt = getopt(argc, argv, "?vVhdt:RT:")) != EOF) {
 		switch (opt) {
 		case 'h':
 			usage(argv[0], stdout);
@@ -200,6 +203,14 @@
 				exit(1);
 			}
 			break;
+		case 'T':
+			start_timeout = atoi(optarg);
+			if (start_timeout <= 0) {
+				fprintf(stderr, "startup timeout is invalid\n");
+				usage(argv[0], stderr);
+				exit(1);
+			}
+			break;
 
 		case 'V':
 		        printf("Cluster LVM daemon version: %s\n", LVM_VERSION);
@@ -214,7 +225,7 @@
 
 	/* Fork into the background (unless requested not to) */
 	if (!debug) {
-		be_daemon();
+		be_daemon(start_timeout);
 	}
 
 	DEBUGLOG("CLVMD started\n");
@@ -647,16 +658,66 @@
 	close(local_sock);
 }
 
+static void wait_for_child(int c_pipe, int timeout)
+{
+	int child_status;
+	int sstat;
+	fd_set fds;
+	struct timeval tv = {timeout, 0};
+
+	FD_ZERO(&fds);
+	FD_SET(c_pipe, &fds);
+
+	sstat = select(c_pipe+1, &fds, NULL, NULL, timeout? &tv: NULL);
+	if (sstat == 0) {
+		fprintf(stderr, "clvmd startup timed out\n");
+		exit(DFAIL_TIMEOUT);
+	}
+	if (sstat == 1) {
+		if (read(c_pipe, &child_status, sizeof(child_status)) !=
+		    sizeof(child_status)) {
+
+			fprintf(stderr, "clvmd failed in initialisation\n");
+			exit(DFAIL_INIT);
+		}
+		else {
+			switch (child_status) {
+			case SUCCESS:
+				break;
+			case DFAIL_INIT:
+				fprintf(stderr, "clvmd failed in initialisation\n");
+				break;
+			case DFAIL_LOCAL_SOCK:
+				fprintf(stderr, "clvmd could not create local socket\n");
+				fprintf(stderr, "Another clvmd is probably already running\n");
+				break;
+			case DFAIL_CLUSTER_IF:
+				fprintf(stderr, "clvmd could not connect to cluster manager\n");
+				fprintf(stderr, "Consult syslog for more information\n");
+				break;
+			case DFAIL_MALLOC:
+				fprintf(stderr, "clvmd failed, not enough memory\n");
+				break;
+			default:
+				fprintf(stderr, "clvmd failed, error was %d\n", child_status);
+				break;
+			}
+			exit(child_status);
+		}
+	}
+	fprintf(stderr, "clvmd startup, select failed: %s\n", strerror(errno));
+	exit(DFAIL_INIT);
+}
+
 /*
  * Fork into the background and detach from our parent process.
  * In the interests of user-friendliness we wait for the daemon
  * to complete initialisation before returning its status
  * the the user.
  */
-static void be_daemon()
+static void be_daemon(int timeout)
 {
         pid_t pid;
-	int child_status;
 	int devnull = open("/dev/null", O_RDWR);
 	if (devnull == -1) {
 		perror("Can't open /dev/null");
@@ -676,36 +737,7 @@
 
 	default:       /* Parent */
 		close(child_pipe[1]);
-		if (read(child_pipe[0], &child_status, sizeof(child_status)) !=
-		    sizeof(child_status)) {
-
-		        fprintf(stderr, "clvmd failed in initialisation\n");
-		        exit(DFAIL_INIT);
-		}
-		else {
-		        switch (child_status) {
-			case SUCCESS:
-			        break;
-			case DFAIL_INIT:
-			        fprintf(stderr, "clvmd failed in initialisation\n");
-				break;
-			case DFAIL_LOCAL_SOCK:
-			        fprintf(stderr, "clvmd could not create local socket\n");
-				fprintf(stderr, "Another clvmd is probably already running\n");
-				break;
-			case DFAIL_CLUSTER_IF:
-			        fprintf(stderr, "clvmd could not connect to cluster manager\n");
-				fprintf(stderr, "Consult syslog for more information\n");
-				break;
-			case DFAIL_MALLOC:
-			        fprintf(stderr, "clvmd failed, not enough memory\n");
-				break;
-			default:
-			        fprintf(stderr, "clvmd failed, error was %d\n", child_status);
-				break;
-			}
-			exit(child_status);
-		}
+		wait_for_child(child_pipe[0], timeout);
 	}
 
 	/* Detach ourself from the calling environment */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-04-01 13:01:02

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

Log message:
	Don't allow user operations to start until the lvm thread is fully up.
	Hopefully finally nails bz#146056

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.213&r2=1.214
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-02-08 09:05:59

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

Log message:
	Fix thread shutdown race which could cause clvmd to hang in pthread_join.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.181&r2=1.182
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-01-24 15:31:13

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

Log message:
	Make clvmd announce it's startup and cluster connection in syslog.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.167&r2=1.168
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-01-05 14:41:54

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

Log message:
	Improve clvmd failure message if it's already running.
	Allow user to kill clvmd during initialisation.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.144&r2=1.145
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2004-10-06 10:12:34

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

Log message:
	Revert the fork back to where it was as it seems to confuse pthreads.
	Instead, the parent now waits for the daemon to signal that it has
	completed successfully (or not) so it can return status to the user.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5


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

end of thread, other threads:[~2012-02-28 11:06 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-06 12:36 LVM2 ./WHATS_NEW daemons/clvmd/clvmd.c pcaulfield
  -- strict thread matches above, loose matches on Subject: below --
2012-02-28 11:06 zkabelac
2012-02-28  9:58 zkabelac
2012-02-28  9:53 zkabelac
2012-02-27 11:26 zkabelac
2012-02-27  9:58 zkabelac
2011-10-11  9:54 zkabelac
2011-10-11  9:26 zkabelac
2011-09-16 14:40 mbroz
2011-08-11 12:57 mbroz
2011-06-28 13:42 zkabelac
2011-03-30 12:36 zkabelac
2011-03-08 22:48 zkabelac
2011-03-08 13:27 mbroz
2010-12-13 10:49 prajnoha
2010-12-01 12:41 zkabelac
2010-12-01 10:46 zkabelac
2010-04-06 15:29 ccaulfield
2010-02-02  8:54 ccaulfield
2009-10-12  8:33 ccaulfield
2009-09-01  9:48 ccaulfield
2009-08-13 10:39 ccaulfield
2009-03-24 11:49 ccaulfield
2008-11-21 13:48 ccaulfield
2008-06-13  7:44 ccaulfield
2008-05-09  9:59 ccaulfield
2008-03-28 12:58 ccaulfield
2008-03-17  9:37 ccaulfield
2008-02-15 14:12 meyering
2007-11-15 10:16 pcaulfield
2007-03-29 13:59 pcaulfield
2006-12-11 13:48 pcaulfield
2006-11-30  9:44 pcaulfield
2005-04-01 13:01 pcaulfield
2005-02-08  9:05 pcaulfield
2005-01-24 15:31 pcaulfield
2005-01-05 14:41 pcaulfield
2004-10-06 10:12 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).