[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH] dmeventd logging



Hi,

the attached patch makes dmeventd bridge the LVM log output to
syslog. If you run dmeventd as usual, only warnings and errors from LVM
will be sent to syslog, using appropriate syslog levels. If you pass -D
or -d to dmeventd (first will run it in daemon mode, second in
foreground), all LVM logging, up to notices (I believe this corresponds
to log_very_verbose, but I haven't checked), will be sent to syslog,
using the LOG_DEBUG level.

If we can get thusly patched dmeventd, with -D, running on Corey's test
cluster, this should bring some insight into the lvconvert --repair
failures we have been seeing on cmirror. Without -D, this should still
be helpful when diagnosing problems on customers' systems.

Yours,
   Petr.

Index: daemons/dmeventd/dmeventd.c
===================================================================
RCS file: /cvs/lvm2/LVM2/daemons/dmeventd/dmeventd.c,v
retrieving revision 1.54
diff -u -p -r1.54 dmeventd.c
--- daemons/dmeventd/dmeventd.c	4 Nov 2008 15:07:44 -0000	1.54
+++ daemons/dmeventd/dmeventd.c	13 Jan 2010 19:40:24 -0000
@@ -54,7 +54,7 @@
 
 static volatile sig_atomic_t _exit_now = 0;	/* set to '1' when signal is given to exit */
 static volatile sig_atomic_t _thread_registries_empty = 1;	/* registries are empty initially */
-static int _debug = 0;
+int _dmeventd_debug = 0;
 
 /* List (un)link macros. */
 #define	LINK(x, head)		dm_list_add(head, &(x)->list)
@@ -204,7 +204,7 @@ static void _debuglog(const char *fmt, .
         time_t P;
         va_list ap;
  
-        if (!_debug)
+        if (!_dmeventd_debug)
                 return;
  
         va_start(ap,fmt);
@@ -1679,7 +1679,7 @@ int main(int argc, char *argv[])
 	opterr = 0;
 	optind = 0;
 
-	while ((opt = getopt(argc, argv, "?hVd")) != EOF) {
+	while ((opt = getopt(argc, argv, "?hVdD")) != EOF) {
 		switch (opt) {
 		case 'h':
 			usage(argv[0], stdout);
@@ -1688,7 +1688,10 @@ int main(int argc, char *argv[])
 			usage(argv[0], stderr);
 			exit(0);
 		case 'd':
-			_debug++;
+			_dmeventd_debug = 2;
+			break;
+		case 'D':
+			_dmeventd_debug = 1;
 			break;
 		case 'V':
 			printf("dmeventd version: %s\n", DM_LIB_VERSION);
@@ -1697,7 +1700,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	if (!_debug)
+	if (_dmeventd_debug < 2)
 		_daemonize();
 
 	openlog("dmeventd", LOG_PID, LOG_DAEMON);
Index: daemons/dmeventd/plugins/mirror/dmeventd_mirror.c
===================================================================
RCS file: /cvs/lvm2/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c,v
retrieving revision 1.29
diff -u -p -r1.29 dmeventd_mirror.c
--- daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	6 Jan 2010 13:26:21 -0000	1.29
+++ daemons/dmeventd/plugins/mirror/dmeventd_mirror.c	13 Jan 2010 19:40:24 -0000
@@ -13,6 +13,7 @@
  */
 
 #include "lvm2cmd.h"
+#include "log.h"
 #include "errors.h"
 
 #include <libdevmapper.h>
@@ -155,16 +156,30 @@ out_parse:
 	return ME_IGNORE;
 }
 
-static void _temporary_log_fn(int level,
-			      const char *file __attribute((unused)),
-			      int line __attribute((unused)),
-			      int dm_errno __attribute((unused)),
-			      const char *format)
+extern int _dmeventd_debug;
+
+static void _log_fn(int level,
+		    const char *file __attribute((unused)),
+		    int line __attribute((unused)),
+		    int dm_errno __attribute((unused)),
+		    const char *message)
 {
-	if (!strncmp(format, "WARNING: ", 9) && (level < 5))
-		syslog(LOG_CRIT, "%s", format);
-	else
-		syslog(LOG_DEBUG, "%s", format);
+	switch (level) {
+	    case _LOG_DEBUG:
+	    case _LOG_INFO:
+	    case _LOG_NOTICE:
+		    if (_dmeventd_debug)
+			    syslog(LOG_DEBUG, "%s", message);
+		    break;
+	    case _LOG_WARN:
+		    syslog(LOG_WARNING, "%s", message);
+		    break;
+	    case _LOG_ERR:
+		    syslog(LOG_ERR, "%s", message);
+		    break;
+	    default:
+		    syslog(LOG_CRIT, "%s", message);
+	}
 }
 
 static int _remove_failed_devices(const char *device)
@@ -276,13 +291,12 @@ int register_device(const char *device,
 		goto out;
 
 	if (!_lvm_handle) {
-		lvm2_log_fn(_temporary_log_fn);
+		lvm2_log_fn(_log_fn);
 		if (!(_lvm_handle = lvm2_init())) {
 			dm_pool_destroy(_mem_pool);
 			_mem_pool = NULL;
 			goto out;
 		}
-		lvm2_log_level(_lvm_handle, LVM2_LOG_SUPPRESS);
 		/* FIXME Temporary: move to dmeventd core */
 		lvm2_run(_lvm_handle, "_memlock_inc");
 	}

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]