public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/daemons/clvmd clvmd.c
@ 2012-02-28 10:42 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2012-02-28 10:42 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

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

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Missed to properly merge patch for definition of MAX_MISSING_LEN
	
	(fix previous commit)

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

--- LVM2/daemons/clvmd/clvmd.c	2012/02/28 10:14:06	1.127
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/28 10:42:20	1.128
@@ -49,7 +49,7 @@
 #endif
 
 #define MAX_RETRIES 4
-#define MAX_MISSING_LEN = 8000 /* Max supported clvmd message size ? */
+#define MAX_MISSING_LEN 8000 /* Max supported clvmd message size ? */
 
 #define ISLOCAL_CSID(c) (memcmp(c, our_csid, max_csid_len) == 0)
 


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

* LVM2/daemons/clvmd clvmd.c
@ 2012-03-27 16:59 mbroz
  0 siblings, 0 replies; 25+ messages in thread
From: mbroz @ 2012-03-27 16:59 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2012-03-27 16:59:29

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Avoid closing clvmd socket twice.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133

--- LVM2/daemons/clvmd/clvmd.c	2012/03/23 09:43:44	1.132
+++ LVM2/daemons/clvmd/clvmd.c	2012/03/27 16:59:28	1.133
@@ -619,6 +619,8 @@
 	for (newfd = local_client_head.next; newfd != NULL;) {
 		delfd = newfd;
 		newfd = newfd->next;
+		if (delfd->fd == local_sock)
+			delfd->fd = -1;
 		/*
 		 * FIXME:
 		 * needs cleanup code from read_from_local_sock() for now


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

* LVM2/daemons/clvmd clvmd.c
@ 2012-03-23  9:43 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2012-03-23  9:43 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-23 09:43:44

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Make sure namelen fits into buffer allocated on stack

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132

--- LVM2/daemons/clvmd/clvmd.c	2012/03/01 21:14:43	1.131
+++ LVM2/daemons/clvmd/clvmd.c	2012/03/23 09:43:44	1.132
@@ -2323,6 +2323,9 @@
         if (result != CS_OK)
 		goto out;
 
+	if (namelen >= sizeof(buf))
+		namelen = sizeof(buf) - 1;
+
 	buf[namelen] = '\0';
 	type = parse_cluster_interface(buf);
 	DEBUGLOG("got interface type '%s' from confdb\n", buf);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-27 10:17:06

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	A bit more safe version of sprintf
	
	Use just buffer size limit (it's used for debug only)

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

--- LVM2/daemons/clvmd/clvmd.c	2012/02/27 09:58:19	1.121
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/27 10:17:06	1.122
@@ -303,7 +303,7 @@
 		break;
 	}
 
-	sprintf(buf, "%s (0x%x)", command, cmdl);
+	snprintf(buf, sizeof(buf), "%s (0x%x)", command, cmdl);
 
 	return buf;
 }


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

* LVM2/daemons/clvmd clvmd.c
@ 2012-02-08 13:03 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2012-02-08 13:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-08 13:03:40

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	A bit more readable code
	
	Just a minor readability conversion.

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

--- LVM2/daemons/clvmd/clvmd.c	2012/01/26 17:55:55	1.119
+++ LVM2/daemons/clvmd/clvmd.c	2012/02/08 13:03:40	1.120
@@ -741,8 +741,7 @@
 			 status, sock_client);
 		/* But has the client gone away ?? */
 		if (sock_client == NULL) {
-			DEBUGLOG
-			    ("Got PIPE response for dead client, ignoring it\n");
+			DEBUGLOG("Got PIPE response for dead client, ignoring it\n");
 		} else {
 			/* If error then just return that code */
 			if (status)
@@ -751,21 +750,16 @@
 			else {
 				/* FIXME: closer inspect this code since state is write thread protected */
 				pthread_mutex_lock(&sock_client->bits.localsock.mutex);
-				if (sock_client->bits.localsock.state ==
-				    POST_COMMAND) {
+				if (sock_client->bits.localsock.state == POST_COMMAND) {
 					pthread_mutex_unlock(&sock_client->bits.localsock.mutex);
 					send_local_reply(sock_client, 0,
 							 sock_client->fd);
-				} else	// PRE_COMMAND finished.
-				{
+				} else {
+					/* PRE_COMMAND finished. */
 					pthread_mutex_unlock(&sock_client->bits.localsock.mutex);
-					if (
-					    (status =
-					     distribute_command(sock_client)) !=
-					    0) send_local_reply(sock_client,
-								EFBIG,
-								sock_client->
-								fd);
+					if ((status = distribute_command(sock_client)))
+						send_local_reply(sock_client, EFBIG,
+								 sock_client->fd);
 				}
 			}
 		}
@@ -1247,9 +1241,8 @@
 			    inheader->node + strlen(inheader->node) + 1;
 
 			while (missing_len > 0) {
-				DEBUGLOG
-				    ("got %d bytes, need another %d (total %d)\n",
-				     argslen, missing_len, inheader->arglen);
+				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 == -1 && errno == EINTR)


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

* LVM2/daemons/clvmd clvmd.c
@ 2012-01-26 17:55 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2012-01-26 17:55 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-26 17:55:56

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Oops missed braces in previous commit
	
	This has disabled clvmd for being executed.
	(FIXME improve testing part to catch this fault)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119

--- LVM2/daemons/clvmd/clvmd.c	2012/01/25 22:36:33	1.118
+++ LVM2/daemons/clvmd/clvmd.c	2012/01/26 17:55:55	1.119
@@ -440,9 +440,10 @@
 		perror("Cannot set LANG to C");
 
 	/* Setting debug options on an existing clvmd */
-	if (debug_opt && !check_local_clvmd())
+	if (debug_opt && !check_local_clvmd()) {
 		dm_hash_destroy(lvm_params.excl_uuid);
 		return debug_clvmd(debug_arg, clusterwide_opt)==1?0:1;
+	}
 
 	clvmd_set_debug(debug_opt);
 


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

* LVM2/daemons/clvmd clvmd.c
@ 2012-01-25 22:36 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2012-01-25 22:36 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-01-25 22:36:33

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Fix leak of hash table
	
	Minor leak on command initialization.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118

--- LVM2/daemons/clvmd/clvmd.c	2012/01/21 05:31:54	1.117
+++ LVM2/daemons/clvmd/clvmd.c	2012/01/25 22:36:33	1.118
@@ -441,6 +441,7 @@
 
 	/* Setting debug options on an existing clvmd */
 	if (debug_opt && !check_local_clvmd())
+		dm_hash_destroy(lvm_params.excl_uuid);
 		return debug_clvmd(debug_arg, clusterwide_opt)==1?0:1;
 
 	clvmd_set_debug(debug_opt);


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-10-11 10:06:57

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Remove unused variables

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116

--- LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:56:44	1.115
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 10:06:57	1.116
@@ -1989,7 +1989,6 @@
  */
 static void *lvm_thread_fn(void *arg)
 {
-	struct dm_list *cmdl, *tmp;
 	sigset_t ss;
 	struct lvm_startup_params *lvm_params = arg;
 	struct lvm_thread_cmd *cmd;


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

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

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

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Add some fixme locking
	
	Code here is using thread write protected variable without locking.
	So add locking, for proper synchronization and a FIXME, since the
	code needs closer look.

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

--- LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:54:39	1.114
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:56:44	1.115
@@ -747,12 +747,16 @@
 				send_local_reply(sock_client, status,
 						 sock_client->fd);
 			else {
+				/* FIXME: closer inspect this code since state is write thread protected */
+				pthread_mutex_lock(&sock_client->bits.localsock.mutex);
 				if (sock_client->bits.localsock.state ==
 				    POST_COMMAND) {
+					pthread_mutex_unlock(&sock_client->bits.localsock.mutex);
 					send_local_reply(sock_client, 0,
 							 sock_client->fd);
 				} else	// PRE_COMMAND finished.
 				{
+					pthread_mutex_unlock(&sock_client->bits.localsock.mutex);
 					if (
 					    (status =
 					     distribute_command(sock_client)) !=


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

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

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

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Add FIXMEs for init_test
	
	Usage of thread unprotected init_test is not correct and needs probably lvm lock
	since it part of lvm library. Current implementation may probably fail with
	test mode and actually create something unexpectedly (and vice versa).

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

--- LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:18:49	1.111
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:23:48	1.112
@@ -1514,9 +1514,9 @@
 
 	if (replyargs != NULL) {
 		/* Run the command */
-		status =
-		    do_command(NULL, msg, msglen, &replyargs, buflen,
-			       &replylen);
+		/* FIXME: usage of init_test() is unprotected */
+		status = do_command(NULL, msg, msglen, &replyargs,
+				    buflen, &replylen);
 	} else {
 		status = ENOMEM;
 	}
@@ -1651,6 +1651,7 @@
 	/* Loop around doing PRE and POST functions until the client goes away */
 	while (!client->bits.localsock.finished) {
 		/* Execute the code */
+		/* FIXME: usage of init_test() is unprotected as in do_command() */
 		status = do_pre_command(client);
 
 		if (status)
@@ -1733,6 +1734,7 @@
 	if (replybuf == NULL)
 		return -1;
 
+	/* FIXME: usage of init_test() is unprotected */
 	status = do_command(client, msg, msglen, &replybuf, buflen, &replylen);
 
 	if (status)


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

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

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

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Limit thread stack
	
	Since default thread stack size is around 8MB and clvmd creates for now thread
	for message, clvmd may easily reach multi GB size of in-memory locked pages
	(runs with mlockall()).
	
	This patch significantly reduces memory usage to just tens of MB,
	and now different reasons are the cause of server overloading.
	Now we are running out of free file descriptors mostly.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.110&r2=1.111

--- LVM2/daemons/clvmd/clvmd.c	2011/09/24 20:48:34	1.110
+++ LVM2/daemons/clvmd/clvmd.c	2011/10/11 09:18:49	1.111
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -84,6 +84,9 @@
 static debug_t debug = DEBUG_OFF;
 static int foreground_mode = 0;
 static pthread_t lvm_thread;
+/* Stack size 128KiB for thread, must be bigger then DEFAULT_RESERVED_STACK */
+static const size_t STACK_SIZE = 128 * 1024;
+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;
@@ -495,6 +498,11 @@
 
 	/* Initialise the LVM thread variables */
 	dm_list_init(&lvm_cmd_head);
+	if (pthread_attr_init(&stack_attr) ||
+	    pthread_attr_setstacksize(&stack_attr, STACK_SIZE)) {
+		log_sys_error("pthread_attr_init", "");
+		exit(1);
+	}
 	pthread_mutex_init(&lvm_thread_mutex, NULL);
 	pthread_cond_init(&lvm_thread_cond, NULL);
 	pthread_mutex_init(&lvm_start_mutex, NULL);
@@ -577,7 +585,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, &lvm_params);
+	pthread_create(&lvm_thread, &stack_attr, lvm_thread_fn, &lvm_params);
 
 	/* Tell the rest of the cluster our version number */
 	if (clops->cluster_init_completed)
@@ -1355,8 +1363,8 @@
 		thisfd->bits.localsock.in_progress = TRUE;
 		thisfd->bits.localsock.state = PRE_COMMAND;
 		DEBUGLOG("Creating pre&post thread\n");
-		status = pthread_create(&thisfd->bits.localsock.threadid, NULL,
-			       pre_and_post_thread, thisfd);
+		status = pthread_create(&thisfd->bits.localsock.threadid,
+					&stack_attr, pre_and_post_thread, thisfd);
 		DEBUGLOG("Created pre&post thread, state = %d\n", status);
 	}
 	return len;


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

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

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

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Keep noreturn attribute for lvm_thread_fn
	
	Even thought my gcc seems to not need it, as it's deduced from pthread_exit(),
	keep it here for older compiler to avoid getting warnings.

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

--- LVM2/daemons/clvmd/clvmd.c	2011/03/30 12:36:20	1.102
+++ LVM2/daemons/clvmd/clvmd.c	2011/03/30 12:48:16	1.103
@@ -132,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 *);
+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);


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

* LVM2/daemons/clvmd clvmd.c
@ 2011-02-28 19:50 zkabelac
  0 siblings, 0 replies; 25+ messages in thread
From: zkabelac @ 2011-02-28 19:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-02-28 19:50:15

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Remove dead code
	
	Remove code which is no longer used.
	Code which has been using msg_malloced was removed in 2007.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96

--- LVM2/daemons/clvmd/clvmd.c	2011/02/18 14:47:29	1.95
+++ LVM2/daemons/clvmd/clvmd.c	2011/02/28 19:50:15	1.96
@@ -1392,7 +1392,6 @@
 	int replylen = 0;
 	int buflen = max_cluster_message - sizeof(struct clvm_header) - 1;
 	int status;
-	int msg_malloced = 0;
 
 	/* Get the node name as we /may/ need it later */
 	clops->name_from_csid(csid, nodename);
@@ -1501,10 +1500,6 @@
 		}
 	}
 
-	/* Free buffer if it was malloced */
-	if (msg_malloced) {
-		free(msg);
-	}
 	free(replyargs);
 }
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-01-05 12:17:20

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Remove dead assignment to thisfd
	
	Value of 'thisfd' is not read again after its assigment

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92

--- LVM2/daemons/clvmd/clvmd.c	2010/12/22 14:00:28	1.91
+++ LVM2/daemons/clvmd/clvmd.c	2011/01/05 12:17:19	1.92
@@ -830,7 +830,6 @@
 					struct local_client *free_fd;
 					lastfd->next = thisfd->next;
 					free_fd = thisfd;
-					thisfd = lastfd;
 
 					DEBUGLOG("removeme set for fd %d\n", free_fd->fd);
 
@@ -866,7 +865,6 @@
 							 ret, errno);
 						lastfd->next = thisfd->next;
 						free_fd = thisfd;
-						thisfd = lastfd;
 						safe_close(&(free_fd->fd));
 
 						/* Queue cleanup, this also frees the client struct */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-22 14:00:30

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Fix last pthread_join fix commit
	
	Call for pthread_join() does not set errno value even though return values
	looks like that. For now assign errno from return value and still use
	strerror() to print some error message as this seems to be commonly used.
	
	Add also log_sys_error() message for error close of local pipe.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91

--- LVM2/daemons/clvmd/clvmd.c	2010/12/22 12:10:56	1.90
+++ LVM2/daemons/clvmd/clvmd.c	2010/12/22 14:00:28	1.91
@@ -667,7 +667,8 @@
 	/* EOF on pipe or an error, close it */
 	if (len <= 0) {
 		void *ret = &status;
-		close(thisfd->fd);
+		if (close(thisfd->fd))
+			log_sys_error("close", "local_pipe");
 
 		/* Clear out the cross-link */
 		if (thisfd->bits.pipe.client != NULL)
@@ -676,7 +677,8 @@
 
 		/* Reap child thread */
 		if (thisfd->bits.pipe.threadid) {
-			if (pthread_join(thisfd->bits.pipe.threadid, &ret))
+			if ((errno = pthread_join(thisfd->bits.pipe.threadid,
+						  &ret)))
 				log_sys_error("pthread_join", "");
 
 			thisfd->bits.pipe.threadid = 0;
@@ -1068,8 +1070,8 @@
 			pthread_cond_signal(&thisfd->bits.localsock.cond);
 			pthread_mutex_unlock(&thisfd->bits.localsock.mutex);
 
-			if (pthread_join(thisfd->bits.localsock.threadid,
-					 (void **) &status))
+			if ((errno = pthread_join(thisfd->bits.localsock.threadid,
+						  (void **) &status)))
 				log_sys_error("pthread_join", "");
 
 			DEBUGLOG("Joined child thread\n");


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-12-20 13:48:28

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Replace multiple fprintf calls with one large string parameter

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

--- LVM2/daemons/clvmd/clvmd.c	2010/12/13 10:49:03	1.88
+++ LVM2/daemons/clvmd/clvmd.c	2010/12/20 13:48:28	1.89
@@ -143,38 +143,37 @@
 static if_type_t parse_cluster_interface(char *ifname);
 static if_type_t get_cluster_type(void);
 
-static void usage(char *prog, FILE *file)
+static void usage(const char *prog, FILE *file)
 {
-	fprintf(file, "Usage:\n");
-	fprintf(file, "%s [Vhd]\n", prog);
-	fprintf(file, "\n");
-	fprintf(file, "   -V       Show version of clvmd\n");
-	fprintf(file, "   -h       Show this help information\n");
-	fprintf(file, "   -d       Set debug level\n");
-	fprintf(file, "            If starting clvmd then 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, "   -S       Restart clvmd, preserving exclusive locks\n");
-	fprintf(file, "   -C       Sets debug level (from -d) on all clvmd instances clusterwide\n");
-	fprintf(file, "   -t<secs> Command timeout (default 60 seconds)\n");
-	fprintf(file, "   -T<secs> Startup timeout (default none)\n");
-	fprintf(file, "   -I<cmgr> Cluster manager (default: auto)\n");
-	fprintf(file, "            Available cluster managers: ");
+	fprintf(file, "Usage:\n"
+		"%s [Vhd]\n\n"
+		"   -V       Show version of clvmd\n"
+		"   -h       Show this help information\n"
+		"   -d       Set debug level\n"
+		"            If starting clvmd then don't fork, run in the foreground\n"
+		"   -R       Tell all running clvmds in the cluster to reload their device cache\n"
+		"   -S       Restart clvmd, preserving exclusive locks\n"
+		"   -C       Sets debug level (from -d) on all clvmd instances clusterwide\n"
+		"   -t<secs> Command timeout (default 60 seconds)\n"
+		"   -T<secs> Startup timeout (default none)\n"
+		"   -I<cmgr> Cluster manager (default: auto)\n"
+		"            Available cluster managers: "
 #ifdef USE_COROSYNC
-	fprintf(file, "corosync ");
+		"corosync "
 #endif
 #ifdef USE_CMAN
-	fprintf(file, "cman ");
+		"cman "
 #endif
 #ifdef USE_OPENAIS
-	fprintf(file, "openais ");
+		"openais "
 #endif
 #ifdef USE_GULM
-	fprintf(file, "gulm ");
+		"gulm "
 #endif
 #ifdef USE_SINGLENODE
-	fprintf(file, "singlenode");
+		"singlenode "
 #endif
-	fprintf(file, "\n");
+		"\n", prog);
 }
 
 /* Called to signal the parent how well we got on during initialisation */


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-11-29 12:44:52

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Remove dead assignment in wait_for_child
	
	'pid' is not used anywhere - remove it.

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

--- LVM2/daemons/clvmd/clvmd.c	2010/11/08 19:37:41	1.83
+++ LVM2/daemons/clvmd/clvmd.c	2010/11/29 12:44:52	1.84
@@ -965,7 +965,6 @@
  */
 static void be_daemon(int timeout)
 {
-        pid_t pid;
 	int devnull = open("/dev/null", O_RDWR);
 	if (devnull == -1) {
 		perror("Can't open /dev/null");
@@ -974,7 +973,7 @@
 
 	pipe(child_pipe);
 
-	switch (pid = fork()) {
+	switch (fork()) {
 	case -1:
 		perror("clvmd: can't fork");
 		exit(2);


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

* LVM2/daemons/clvmd clvmd.c
@ 2010-10-27 11:40 mornfall
  0 siblings, 0 replies; 25+ messages in thread
From: mornfall @ 2010-10-27 11:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-10-27 11:40:15

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Alasdair correctly pointed out that if the two closes are concurrent (I haven't
	checked, so they *might*), there is still a race possibility with the last
	fix. This patch fixes that.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82

--- LVM2/daemons/clvmd/clvmd.c	2010/10/27 09:13:37	1.81
+++ LVM2/daemons/clvmd/clvmd.c	2010/10/27 11:40:14	1.82
@@ -188,6 +188,14 @@
 	        exit(status);
 }
 
+static void safe_close(int *fd)
+{
+	if (*fd >= 0) {
+		int to_close = *fd;
+		*fd = -1;
+		close(to_close);
+	}
+}
 
 void debuglog(const char *fmt, ...)
 {
@@ -838,10 +846,7 @@
 						lastfd->next = thisfd->next;
 						free_fd = thisfd;
 						thisfd = lastfd;
-						if (free_fd->fd >= 0) {
-							close(free_fd->fd);
-							free_fd->fd = -1;
-						}
+						safe_close(&(free_fd->fd));
 
 						/* Queue cleanup, this also frees the client struct */
 						add_to_lvmqueue(free_fd, NULL, 0, NULL);
@@ -1091,10 +1096,7 @@
 			thisfd->bits.localsock.pipe_client->bits.pipe.client =
 			    NULL;
 
-		if (thisfd->fd >= 0) {
-			close(thisfd->fd);
-			thisfd->fd = -1;
-		}
+		safe_close(&(thisfd->fd));
 		return 0;
 	} else {
 		int comms_pipe[2];


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

* LVM2/daemons/clvmd clvmd.c
@ 2010-10-27  9:13 mornfall
  0 siblings, 0 replies; 25+ messages in thread
From: mornfall @ 2010-10-27  9:13 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mornfall@sourceware.org	2010-10-27 09:13:37

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Fix a double close in clvmd.
	
	The management threads (main_loop, the socket thread) could close a single fd
	twice in a row sometimes. At least one other thread can be running at the same
	time as the threads doing the double close. That one running thread also
	happens to do some IO (namely, open /proc/devices, read from it, close it). If
	there was enough "demand" for the local socket, this could happen:
	
	- a connection to clvmd is about to finish, let's say the fd is 13 (it often
	happens to be in my test script, don't ask why)
	- the local_sock thread calls close(13)
	- the lvm thread calls open("/proc/devices"...) and gets 13
	- the main_loop thread calls close(13) [OOPS!]
	- new connection arrives, and is accept'd by a (new) local_sock thread
	- the accept gives an fd of 13 (since it's the lowest free fd at this point)
	- the lvm thread gets around to read from it's /proc/devices handle... 13,
	again
	- the lvm thread hangs forever trying to read from the socket instead of
	/proc/devices
	
	Signed-off-by: Petr Rockai <prockai@redhat.com>
	Reviewed-by: Milan Broz <mbroz@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81

--- LVM2/daemons/clvmd/clvmd.c	2010/10/26 09:57:03	1.80
+++ LVM2/daemons/clvmd/clvmd.c	2010/10/27 09:13:37	1.81
@@ -838,7 +838,10 @@
 						lastfd->next = thisfd->next;
 						free_fd = thisfd;
 						thisfd = lastfd;
-						close(free_fd->fd);
+						if (free_fd->fd >= 0) {
+							close(free_fd->fd);
+							free_fd->fd = -1;
+						}
 
 						/* Queue cleanup, this also frees the client struct */
 						add_to_lvmqueue(free_fd, NULL, 0, NULL);
@@ -1088,7 +1091,10 @@
 			thisfd->bits.localsock.pipe_client->bits.pipe.client =
 			    NULL;
 
-		close(thisfd->fd);
+		if (thisfd->fd >= 0) {
+			close(thisfd->fd);
+			thisfd->fd = -1;
+		}
 		return 0;
 	} else {
 		int comms_pipe[2];


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-26 09:57:03

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Hotfix usage of __builtin_unreachable()
	
	It's quite new feature which is not supported by older compilers.
	So until some better macros are introduced into LVM code - hotfix current
	compilation problems and compile this code only for __clang__ defining compilers.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80

--- LVM2/daemons/clvmd/clvmd.c	2010/10/26 09:01:47	1.79
+++ LVM2/daemons/clvmd/clvmd.c	2010/10/26 09:57:03	1.80
@@ -491,7 +491,9 @@
 		DEBUGLOG("Can't initialise cluster interface\n");
 		log_error("Can't initialise cluster interface\n");
 		child_init_signal(DFAIL_CLUSTER_IF);
+#ifdef __clang__
 		__builtin_unreachable();
+#endif
 	}
 	DEBUGLOG("Cluster ready, doing some more initialisation\n");
 
@@ -508,7 +510,9 @@
 	newfd = malloc(sizeof(struct local_client));
 	if (!newfd) {
 		child_init_signal(DFAIL_MALLOC);
+#ifdef __clang__
 		__builtin_unreachable();
+#endif
 	}
 
 	newfd->fd = local_sock;


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-26 09:01:47

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Instrument compiler about code unreachability
	
	Clang needs some instrumentation help for static code analysis.
	It helps gcc and human reader as well.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79

--- LVM2/daemons/clvmd/clvmd.c	2010/10/20 14:46:45	1.78
+++ LVM2/daemons/clvmd/clvmd.c	2010/10/26 09:01:47	1.79
@@ -491,6 +491,7 @@
 		DEBUGLOG("Can't initialise cluster interface\n");
 		log_error("Can't initialise cluster interface\n");
 		child_init_signal(DFAIL_CLUSTER_IF);
+		__builtin_unreachable();
 	}
 	DEBUGLOG("Cluster ready, doing some more initialisation\n");
 
@@ -505,8 +506,10 @@
 
 	/* Add the local socket to the list */
 	newfd = malloc(sizeof(struct local_client));
-	if (!newfd)
-	        child_init_signal(DFAIL_MALLOC);
+	if (!newfd) {
+		child_init_signal(DFAIL_MALLOC);
+		__builtin_unreachable();
+	}
 
 	newfd->fd = local_sock;
 	newfd->removeme = 0;


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

* LVM2/daemons/clvmd clvmd.c
@ 2009-04-22 10:38 mbroz
  0 siblings, 0 replies; 25+ messages in thread
From: mbroz @ 2009-04-22 10:38 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-04-22 10:38:20

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Clean a lot of extra extra whitespaces.

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

--- LVM2/daemons/clvmd/clvmd.c	2009/03/24 11:49:15	1.56
+++ LVM2/daemons/clvmd/clvmd.c	2009/04/22 10:38:16	1.57
@@ -221,44 +221,44 @@
 	const char *command;
 
 	switch (cmdl) {
-	case CLVMD_CMD_TEST:		
-		command = "TEST";	
+	case CLVMD_CMD_TEST:
+		command = "TEST";
 		break;
-	case CLVMD_CMD_LOCK_VG:		
-		command = "LOCK_VG";	
+	case CLVMD_CMD_LOCK_VG:
+		command = "LOCK_VG";
 		break;
-	case CLVMD_CMD_LOCK_LV:		
-		command = "LOCK_LV";	
+	case CLVMD_CMD_LOCK_LV:
+		command = "LOCK_LV";
 		break;
-	case CLVMD_CMD_REFRESH:		
-		command = "REFRESH";	
+	case CLVMD_CMD_REFRESH:
+		command = "REFRESH";
 		break;
-	case CLVMD_CMD_SET_DEBUG:	
-		command = "SET_DEBUG";	
+	case CLVMD_CMD_SET_DEBUG:
+		command = "SET_DEBUG";
 		break;
-	case CLVMD_CMD_GET_CLUSTERNAME:	
+	case CLVMD_CMD_GET_CLUSTERNAME:
 		command = "GET_CLUSTERNAME";
 		break;
-	case CLVMD_CMD_VG_BACKUP:	
-		command = "VG_BACKUP";	
+	case CLVMD_CMD_VG_BACKUP:
+		command = "VG_BACKUP";
 		break;
-	case CLVMD_CMD_REPLY:		
-		command = "REPLY";	
+	case CLVMD_CMD_REPLY:
+		command = "REPLY";
 		break;
-	case CLVMD_CMD_VERSION:		
-		command = "VERSION";	
+	case CLVMD_CMD_VERSION:
+		command = "VERSION";
 		break;
-	case CLVMD_CMD_GOAWAY:		
-		command = "GOAWAY";	
+	case CLVMD_CMD_GOAWAY:
+		command = "GOAWAY";
 		break;
-	case CLVMD_CMD_LOCK:		
-		command = "LOCK";	
+	case CLVMD_CMD_LOCK:
+		command = "LOCK";
 		break;
-	case CLVMD_CMD_UNLOCK:		
-		command = "UNLOCK";	
+	case CLVMD_CMD_UNLOCK:
+		command = "UNLOCK";
 		break;
-	default:			
-		command = "unknown";    
+	default:
+		command = "unknown";
 		break;
 	}
 


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

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

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2005-08-09 10:39:57

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Don't send a signal to kill threads that are idling nicely as it upsets them.
	This seems to cure bz#159727 on SMP systems.
	
	Alasdair, can you include this patch in the lvm2-cluster package please ?

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25


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

* LVM2/daemons/clvmd clvmd.c
@ 2004-09-30 14:16 pcaulfield
  0 siblings, 0 replies; 25+ messages in thread
From: pcaulfield @ 2004-09-30 14:16 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2004-09-30 14:16:28

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Fork a little later in the startup sequence so that we can return
	an error code if the cluster infrastructure isn't there.

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


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

* LVM2/daemons/clvmd clvmd.c
@ 2004-09-23 12:51 pcaulfield
  0 siblings, 0 replies; 25+ messages in thread
From: pcaulfield @ 2004-09-23 12:51 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	pcaulfield@sourceware.org	2004-09-23 12:51:57

Modified files:
	daemons/clvmd  : clvmd.c 

Log message:
	Make the thread handling a little less cavalier. In particular, calling
	pthread_exit in a signal handler was a /really/ bad idea.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2


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

end of thread, other threads:[~2012-03-27 16:59 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-28 10:42 LVM2/daemons/clvmd clvmd.c zkabelac
  -- strict thread matches above, loose matches on Subject: below --
2012-03-27 16:59 mbroz
2012-03-23  9:43 zkabelac
2012-02-27 10:17 zkabelac
2012-02-08 13:03 zkabelac
2012-01-26 17:55 zkabelac
2012-01-25 22:36 zkabelac
2011-10-11 10:06 zkabelac
2011-10-11  9:56 zkabelac
2011-10-11  9:23 zkabelac
2011-10-11  9:18 zkabelac
2011-03-30 12:48 zkabelac
2011-02-28 19:50 zkabelac
2011-01-05 12:17 zkabelac
2010-12-22 14:00 zkabelac
2010-12-20 13:48 zkabelac
2010-11-29 12:44 zkabelac
2010-10-27 11:40 mornfall
2010-10-27  9:13 mornfall
2010-10-26  9:57 zkabelac
2010-10-26  9:01 zkabelac
2009-04-22 10:38 mbroz
2005-08-09 10:39 pcaulfield
2004-09-30 14:16 pcaulfield
2004-09-23 12:51 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).