public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2011-07-28 13:03 prajnoha
  0 siblings, 0 replies; 7+ messages in thread
From: prajnoha @ 2011-07-28 13:03 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-07-28 13:03:38

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Add support for new oom killer adjustment interface (oom_score_adj).
	
	The filename to adjust the oom score was changed in 2.6.36.
	We should use oom_score_adj instead of oom_adj (which is still
	there under /proc, but it's scheduled for removal in August 2012).
	
	New oom_score_adj uses a range from -1000 (OOM_SCORE_ADJ_MIN,
	disable oom killing) to 1000 (OOM_SCORE_ADJ_MAX).

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

--- LVM2/WHATS_NEW_DM	2011/07/28 12:54:28	1.483
+++ LVM2/WHATS_NEW_DM	2011/07/28 13:03:37	1.484
@@ -1,5 +1,6 @@
 Version 1.02.66 - 
 ===============================
+  Add support for new oom killer adjustment interface (oom_score_adj).
   Add systemd unit files for dmeventd.
   Fix read-only identical table reload supression.
 
--- LVM2/daemons/dmeventd/dmeventd.c	2011/04/04 16:11:09	1.80
+++ LVM2/daemons/dmeventd/dmeventd.c	2011/07/28 13:03:37	1.81
@@ -41,11 +41,19 @@
 #ifdef linux
 #  include <malloc.h>
 
-#  define OOM_ADJ_FILE "/proc/self/oom_adj"
+/*
+ * Kernel version 2.6.36 and higher has
+ * new OOM killer adjustment interface.
+ */
+#  define OOM_ADJ_FILE_OLD "/proc/self/oom_adj"
+#  define OOM_ADJ_FILE "/proc/self/oom_score_adj"
 
 /* From linux/oom.h */
+/* Old interface */
 #  define OOM_DISABLE (-17)
 #  define OOM_ADJUST_MIN (-16)
+/* New interface */
+#  define OOM_SCORE_ADJ_MIN (-1000)
 
 #endif
 
@@ -1594,33 +1602,48 @@
 }
 
 #ifdef linux
+static int _set_oom_adj(const char *oom_adj_path, int val)
+{
+	FILE *fp;
+
+	if (!(fp = fopen(oom_adj_path, "w"))) {
+		perror("oom_adj: fopen failed");
+		return 0;
+	}
+
+	fprintf(fp, "%i", val);
+
+	if (dm_fclose(fp))
+		perror("oom_adj: fclose failed");
+
+	return 1;
+}
+
 /*
  * Protection against OOM killer if kernel supports it
  */
-static int _set_oom_adj(int val)
+static int _protect_against_oom_killer()
 {
-	FILE *fp;
-
 	struct stat st;
 
 	if (stat(OOM_ADJ_FILE, &st) == -1) {
-		if (errno == ENOENT)
-			perror(OOM_ADJ_FILE " not found");
-		else
+		if (errno != ENOENT)
 			perror(OOM_ADJ_FILE ": stat failed");
-		return 1;
-	}
 
-	if (!(fp = fopen(OOM_ADJ_FILE, "w"))) {
-		perror(OOM_ADJ_FILE ": fopen failed");
-		return 0;
-	}
+		/* Try old oom_adj interface as a fallback */
+		if (stat(OOM_ADJ_FILE_OLD, &st) == -1) {
+			if (errno == ENOENT)
+				perror(OOM_ADJ_FILE_OLD " not found");
+			else
+				perror(OOM_ADJ_FILE_OLD ": stat failed");
+			return 1;
+		}
 
-	fprintf(fp, "%i", val);
-	if (dm_fclose(fp))
-		perror(OOM_ADJ_FILE ": fclose failed");
+		return _set_oom_adj(OOM_ADJ_FILE_OLD, OOM_DISABLE) ||
+		       _set_oom_adj(OOM_ADJ_FILE_OLD, OOM_ADJUST_MIN);
+	}
 
-	return 1;
+	return _set_oom_adj(OOM_ADJ_FILE, OOM_SCORE_ADJ_MIN);
 }
 #endif
 
@@ -1829,8 +1852,8 @@
 	signal(SIGQUIT, &_exit_handler);
 
 #ifdef linux
-	if (!_set_oom_adj(OOM_DISABLE) && !_set_oom_adj(OOM_ADJUST_MIN))
-		syslog(LOG_ERR, "Failed to set oom_adj to protect against OOM killer");
+	if (!_protect_against_oom_killer())
+		syslog(LOG_ERR, "Failed to protect against OOM killer");
 #endif
 
 	_init_thread_signals();


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2011-07-28 13:06 prajnoha
  0 siblings, 0 replies; 7+ messages in thread
From: prajnoha @ 2011-07-28 13:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2011-07-28 13:06:50

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Add support for systemd file descriptor handover in dmeventd.
	
	Systemd preloads file descriptors for us and passes them in for
	newly spawned daemon when using on-demand fifo (or socket)
	based activation.
	
	This patch adds checks for file descriptors preloaded by
	systemd and uses them instead of opening the FIFOs again
	to properly support on-demand FIFO-based activation.
	
	(We'll change FIFOs to sockets soon - but still this
	part of the code will stay almost the same.)

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

--- LVM2/WHATS_NEW_DM	2011/07/28 13:03:37	1.484
+++ LVM2/WHATS_NEW_DM	2011/07/28 13:06:50	1.485
@@ -1,5 +1,6 @@
 Version 1.02.66 - 
 ===============================
+  Add support for systemd file descriptor handover in dmeventd.
   Add support for new oom killer adjustment interface (oom_score_adj).
   Add systemd unit files for dmeventd.
   Fix read-only identical table reload supression.
--- LVM2/daemons/dmeventd/dmeventd.c	2011/07/28 13:03:37	1.81
+++ LVM2/daemons/dmeventd/dmeventd.c	2011/07/28 13:06:50	1.82
@@ -55,6 +55,13 @@
 /* New interface */
 #  define OOM_SCORE_ADJ_MIN (-1000)
 
+/* Systemd on-demand activation support */
+#  define SD_LISTEN_PID_ENV_VAR_NAME "LISTEN_PID"
+#  define SD_LISTEN_FDS_ENV_VAR_NAME "LISTEN_FDS"
+#  define SD_LISTEN_FDS_START 3
+#  define SD_FD_FIFO_SERVER SD_LISTEN_FDS_START
+#  define SD_FD_FIFO_CLIENT (SD_LISTEN_FDS_START + 1)
+
 #endif
 
 /* FIXME We use syslog for now, because multilog is not yet implemented */
@@ -104,6 +111,7 @@
 #define THREAD_STACK_SIZE (300*1024)
 
 int dmeventd_debug = 0;
+static int _systemd_activation = 0;
 static int _foreground = 0;
 static int _restart = 0;
 static char **_initial_registrations = 0;
@@ -1710,8 +1718,13 @@
 	else
 		fd = rlim.rlim_cur;
 
-	for (--fd; fd >= 0; fd--)
+	for (--fd; fd >= 0; fd--) {
+		/* Do not close fds preloaded by systemd! */
+		if (_systemd_activation &&
+		    (fd == SD_FD_FIFO_SERVER || fd == SD_FD_FIFO_CLIENT))
+			continue;
 		close(fd);
+	}
 
 	if ((open("/dev/null", O_RDONLY) < 0) ||
 	    (open("/dev/null", O_WRONLY) < 0) ||
@@ -1780,6 +1793,76 @@
 	fini_fifos(&fifos);
 }
 
+static int _handle_preloaded_fifo(int fd, const char *path)
+{
+	struct stat st_fd, st_path;
+	int flags;
+
+	if ((flags = fcntl(fd, F_GETFD)) < 0)
+		return 0;
+
+	if (flags & FD_CLOEXEC)
+		return 0;
+
+	if (fstat(fd, &st_fd) < 0 || !S_ISFIFO(st_fd.st_mode))
+		return 0;
+
+	if (stat(path, &st_path) < 0 ||
+	    st_path.st_dev != st_fd.st_dev ||
+	    st_path.st_ino != st_fd.st_ino)
+		return 0;
+
+	if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0)
+		return 0;
+
+	return 1;
+}
+
+static int _systemd_handover(struct dm_event_fifos *fifos)
+{
+	const char *e;
+	char *p;
+	unsigned long env_pid, env_listen_fds;
+	int r = 0;
+
+	memset(fifos, 0, sizeof(*fifos));
+
+	/* LISTEN_PID must be equal to our PID! */
+	if (!(e = getenv(SD_LISTEN_PID_ENV_VAR_NAME)))
+		goto out;
+
+	errno = 0;
+	env_pid = strtoul(e, &p, 10);
+	if (errno || !p || *p || env_pid <= 0 ||
+	    getpid() != (pid_t) env_pid)
+		goto out;
+
+	/* LISTEN_FDS must be 2 and the fds must be FIFOSs! */
+	if (!(e = getenv(SD_LISTEN_FDS_ENV_VAR_NAME)))
+		goto out;
+
+	errno = 0;
+	env_listen_fds = strtoul(e, &p, 10);
+	if (errno || !p || *p || env_listen_fds != 2)
+		goto out;
+
+	/* Check and handle the FIFOs passed in */
+	r = (_handle_preloaded_fifo(SD_FD_FIFO_SERVER, DM_EVENT_FIFO_SERVER) &&
+	     _handle_preloaded_fifo(SD_FD_FIFO_CLIENT, DM_EVENT_FIFO_CLIENT));
+
+	if (r) {
+		fifos->server = SD_FD_FIFO_SERVER;
+		fifos->server_path = DM_EVENT_FIFO_SERVER;
+		fifos->client = SD_FD_FIFO_CLIENT;
+		fifos->client_path = DM_EVENT_FIFO_CLIENT;
+	}
+
+out:
+	unsetenv(SD_LISTEN_PID_ENV_VAR_NAME);
+	unsetenv(SD_LISTEN_FDS_ENV_VAR_NAME);
+	return r;
+}
+
 static void usage(char *prog, FILE *file)
 {
 	fprintf(file, "Usage:\n"
@@ -1834,6 +1917,8 @@
 	if (_restart)
 		restart();
 
+	_systemd_activation = _systemd_handover(&fifos);
+
 	if (!_foreground)
 		_daemonize();
 
@@ -1852,7 +1937,8 @@
 	signal(SIGQUIT, &_exit_handler);
 
 #ifdef linux
-	if (!_protect_against_oom_killer())
+	/* Systemd has adjusted oom killer for us already */
+	if (!_systemd_activation && !_protect_against_oom_killer())
 		syslog(LOG_ERR, "Failed to protect against OOM killer");
 #endif
 
@@ -1863,11 +1949,12 @@
 	//multilog_init_verbose(std_syslog, _LOG_DEBUG);
 	//multilog_async(1);
 
-	_init_fifos(&fifos);
+	if (!_systemd_activation)
+		_init_fifos(&fifos);
 
 	pthread_mutex_init(&_global_mutex, NULL);
 
-	if (_open_fifos(&fifos))
+	if (!_systemd_activation && _open_fifos(&fifos))
 		exit(EXIT_FIFO_FAILURE);
 
 	/* Signal parent, letting them know we are ready to go. */


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2012-03-01  9:50 zkabelac
  0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2012-03-01  9:50 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 09:50:04

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Log fail of pthread_join
	
	Syslog error outside of mutex section.

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

--- LVM2/WHATS_NEW_DM	2012/02/28 17:47:24	1.576
+++ LVM2/WHATS_NEW_DM	2012/03/01 09:50:04	1.577
@@ -1,5 +1,6 @@
 Version 1.02.73 - 
 ====================================
+  Log failure of pthread_join when cleaning unused threads in dmeventd.
   Fix empty string warning logic in _find_config_str. (1.02.68)
   Fix dm_task_set_name to properly resolve path to dm name (1.02.71).
   Add dm_strncpy() function as a faster strncpy() replacement.
--- LVM2/daemons/dmeventd/dmeventd.c	2012/02/27 11:13:51	1.90
+++ LVM2/daemons/dmeventd/dmeventd.c	2012/03/01 09:50:04	1.91
@@ -1517,6 +1517,7 @@
 	int ret;
 	struct dm_list *l;
 	struct thread_status *thread;
+	int join_ret = 0;
 
 	_lock_mutex();
 	while ((l = dm_list_first(&_thread_registry_unused))) {
@@ -1556,12 +1557,15 @@
 
 		if (thread->status == DM_THREAD_DONE) {
 			dm_list_del(l);
-			pthread_join(thread->thread, NULL);
+			join_ret = pthread_join(thread->thread, NULL);
 			_free_thread_status(thread);
 		}
 	}
 
 	_unlock_mutex();
+
+	if (join_ret)
+		syslog(LOG_ERR, "Failed pthread_join: %s\n", strerror(join_ret));
 }
 
 static void _sig_alarm(int signum __attribute__((unused)))


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2012-03-01 22:06 zkabelac
  0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2012-03-01 22:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-01 22:06:19

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Improve logging
	
	Use %m for strerror.
	Switch to use 0 for fail return code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.579&r2=1.580
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93

--- LVM2/WHATS_NEW_DM	2012/03/01 21:56:44	1.579
+++ LVM2/WHATS_NEW_DM	2012/03/01 22:06:18	1.580
@@ -1,5 +1,6 @@
 Version 1.02.73 - 
 ====================================
+  Improve logging for fifo startup in dmeventd.
   Add few pointer validation in dmsetup.
   Support dm_task_get_driver_version() query without version string.
   Log failure of pthread_join when cleaning unused threads in dmeventd.
--- LVM2/daemons/dmeventd/dmeventd.c	2012/03/01 21:12:39	1.92
+++ LVM2/daemons/dmeventd/dmeventd.c	2012/03/01 22:06:18	1.93
@@ -1245,67 +1245,66 @@
 /* Open fifos used for client communication. */
 static int _open_fifos(struct dm_event_fifos *fifos)
 {
-	int orig_errno;
 	struct stat st;
 
 	/* Create client fifo. */
 	(void) dm_prepare_selinux_context(fifos->client_path, S_IFIFO);
 	if ((mkfifo(fifos->client_path, 0600) == -1) && errno != EEXIST) {
-		syslog(LOG_ERR, "%s: Failed to create client fifo.\n", __func__);
-		orig_errno = errno;
+		syslog(LOG_ERR, "%s: Failed to create client fifo %s: %m.\n",
+		       __func__, fifos->client_path);
 		(void) dm_prepare_selinux_context(NULL, 0);
-		stack;
-		return -orig_errno;
+		return 0;
 	}
 
 	/* Create server fifo. */
 	(void) dm_prepare_selinux_context(fifos->server_path, S_IFIFO);
 	if ((mkfifo(fifos->server_path, 0600) == -1) && errno != EEXIST) {
-		syslog(LOG_ERR, "%s: Failed to create server fifo.\n", __func__);
-		orig_errno = errno;
+		syslog(LOG_ERR, "%s: Failed to create server fifo %s: %m.\n",
+		       __func__, fifos->server_path);
 		(void) dm_prepare_selinux_context(NULL, 0);
-		stack;
-		return -orig_errno;
+		return 0;
 	}
 
 	(void) dm_prepare_selinux_context(NULL, 0);
 
 	/* Warn about wrong permissions if applicable */
 	if ((!stat(fifos->client_path, &st)) && (st.st_mode & 0777) != 0600)
-		syslog(LOG_WARNING, "Fixing wrong permissions on %s",
+		syslog(LOG_WARNING, "Fixing wrong permissions on %s: %m.\n",
 		       fifos->client_path);
 
 	if ((!stat(fifos->server_path, &st)) && (st.st_mode & 0777) != 0600)
-		syslog(LOG_WARNING, "Fixing wrong permissions on %s",
+		syslog(LOG_WARNING, "Fixing wrong permissions on %s: %m.\n",
 		       fifos->server_path);
 
 	/* If they were already there, make sure permissions are ok. */
 	if (chmod(fifos->client_path, 0600)) {
-		syslog(LOG_ERR, "Unable to set correct file permissions on %s",
+		syslog(LOG_ERR, "Unable to set correct file permissions on %s: %m.\n",
 		       fifos->client_path);
-		return -errno;
+		return 0;
 	}
 
 	if (chmod(fifos->server_path, 0600)) {
-		syslog(LOG_ERR, "Unable to set correct file permissions on %s",
+		syslog(LOG_ERR, "Unable to set correct file permissions on %s: %m.\n",
 		       fifos->server_path);
-		return -errno;
+		return 0;
 	}
 
 	/* Need to open read+write or we will block or fail */
 	if ((fifos->server = open(fifos->server_path, O_RDWR)) < 0) {
-		stack;
-		return -errno;
+		syslog(LOG_ERR, "Failed to open fifo server %s: %m.\n",
+		       fifos->server_path);
+		return 0;
 	}
 
 	/* Need to open read+write for select() to work. */
 	if ((fifos->client = open(fifos->client_path, O_RDWR)) < 0) {
-		stack;
-		close(fifos->server);
-		return -errno;
+		syslog(LOG_ERR, "Failed to open fifo client %s: %m", fifos->client_path);
+		if (close(fifos->server))
+			syslog(LOG_ERR, "Failed to close fifo server %s: %m", fifos->server_path);
+		return 0;
 	}
 
-	return 0;
+	return 1;
 }
 
 /*
@@ -1973,7 +1972,7 @@
 
 	pthread_mutex_init(&_global_mutex, NULL);
 
-	if (!_systemd_activation && _open_fifos(&fifos))
+	if (!_systemd_activation && !_open_fifos(&fifos))
 		exit(EXIT_FIFO_FAILURE);
 
 	/* Signal parent, letting them know we are ready to go. */


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2012-03-14 11:16 prajnoha
  0 siblings, 0 replies; 7+ messages in thread
From: prajnoha @ 2012-03-14 11:16 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-03-14 11:16:01

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Do not run a new dmeventd instance on restart if there's no existing one.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.592&r2=1.593
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97

--- LVM2/WHATS_NEW_DM	2012/03/12 14:46:53	1.592
+++ LVM2/WHATS_NEW_DM	2012/03/14 11:16:00	1.593
@@ -1,5 +1,6 @@
 Version 1.02.75 - 
 ================================
+  Do not run a new dmeventd instance on restart if there's no existing one.
   Make the time window for reading fifo longer 5sec (1.02.73).
 
 Version 1.02.74 - 6th March 2012
--- LVM2/daemons/dmeventd/dmeventd.c	2012/03/02 23:01:10	1.96
+++ LVM2/daemons/dmeventd/dmeventd.c	2012/03/14 11:16:01	1.97
@@ -1829,13 +1829,13 @@
 
 	if (!init_fifos(&fifos)) {
 		fprintf(stderr, "WARNING: Could not initiate communication with existing dmeventd.\n");
-		return;
+		exit(EXIT_FAILURE);
 	}
 
 	if (!dm_event_get_version(&fifos, &version)) {
 		fprintf(stderr, "WARNING: Could not communicate with existing dmeventd.\n");
 		fini_fifos(&fifos);
-		return;
+		exit(EXIT_FAILURE);
 	}
 
 	if (version < 1) {


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2012-03-15  8:45 prajnoha
  0 siblings, 0 replies; 7+ messages in thread
From: prajnoha @ 2012-03-15  8:45 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2012-03-15 08:45:56

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Remove dmeventd fifos on exit if they are not managed by systemd.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.594&r2=1.595
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.98&r2=1.99

--- LVM2/WHATS_NEW_DM	2012/03/14 15:51:51	1.594
+++ LVM2/WHATS_NEW_DM	2012/03/15 08:45:55	1.595
@@ -1,5 +1,6 @@
 Version 1.02.75 - 
 ================================
+  Remove dmeventd fifos on exit if they are not managed by systemd.
   Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
   Do not run a new dmeventd instance on restart if there's no existing one.
   Make the time window for reading fifo longer 5sec (1.02.73).
--- LVM2/daemons/dmeventd/dmeventd.c	2012/03/14 15:51:51	1.98
+++ LVM2/daemons/dmeventd/dmeventd.c	2012/03/15 08:45:55	1.99
@@ -1741,10 +1741,18 @@
 }
 #endif
 
-static void remove_lockfile(void)
+static void _remove_files_on_exit(void)
 {
 	if (unlink(DMEVENTD_PIDFILE))
 		perror(DMEVENTD_PIDFILE ": unlink failed");
+
+	if (!_systemd_activation) {
+		if (unlink(DM_EVENT_FIFO_CLIENT))
+			perror(DM_EVENT_FIFO_CLIENT " : unlink failed");
+
+		if (unlink(DM_EVENT_FIFO_SERVER))
+			perror(DM_EVENT_FIFO_SERVER " : unlink failed");
+	}
 }
 
 static void _daemonize(void)
@@ -1955,10 +1963,11 @@
 	if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
 		exit(EXIT_FAILURE);
 
-	atexit(remove_lockfile);
+	atexit(_remove_files_on_exit);
 	(void) dm_prepare_selinux_context(NULL, 0);
 
 	/* Set the rest of the signals to cause '_exit_now' to be set */
+	signal(SIGTERM, &_exit_handler);
 	signal(SIGINT, &_exit_handler);
 	signal(SIGHUP, &_exit_handler);
 	signal(SIGQUIT, &_exit_handler);


^ permalink raw reply	[flat|nested] 7+ messages in thread
* LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c
@ 2012-04-24 12:25 zkabelac
  0 siblings, 0 replies; 7+ messages in thread
From: zkabelac @ 2012-04-24 12:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-04-24 12:25:23

Modified files:
	.              : WHATS_NEW_DM 
	daemons/dmeventd: dmeventd.c 

Log message:
	Synchronize with self-destruction of dmeventd
	
	In some occasional case dmevent restart was experiencing problems
	with obtaining pid lockfile. So this patch tries to send several more kill
	message until daemon kills itself so there is would reponse.
	With this small loop the restart seems to work reliable,
	although the loopsize and usleep are just randomly picked for now.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.599&r2=1.600
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.99&r2=1.100

--- LVM2/WHATS_NEW_DM	2012/04/24 08:24:36	1.599
+++ LVM2/WHATS_NEW_DM	2012/04/24 12:25:12	1.600
@@ -1,5 +1,6 @@
 Version 1.02.75 - 
 ================================
+  Synchronize with dead of dmeventd.
   Rename (Blk)DevNames/DevNos dmsetup header to (Blk)DevNamesUsed/DevNosUsed.
   Add configure --with-veritysetup for independent veritysetup tool.
   Properly support passed in dmevent path in dm_event_register_handler().
--- LVM2/daemons/dmeventd/dmeventd.c	2012/03/15 08:45:55	1.99
+++ LVM2/daemons/dmeventd/dmeventd.c	2012/04/24 12:25:20	1.100
@@ -1893,6 +1893,13 @@
 		exit(EXIT_FAILURE);
 	}
 
+	/* Let's wait a bit till deamon dies - spaming him with messages meanwhile */
+	for (i = 0; i < 10; ++i) {
+		if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0))
+			break; /* yep, it's dead probably */
+		usleep(10);
+	}
+
 	fini_fifos(&fifos);
 }
 


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

end of thread, other threads:[~2012-04-24 12:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 13:03 LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd.c prajnoha
2011-07-28 13:06 prajnoha
2012-03-01  9:50 zkabelac
2012-03-01 22:06 zkabelac
2012-03-14 11:16 prajnoha
2012-03-15  8:45 prajnoha
2012-04-24 12:25 zkabelac

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