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

[Cluster-devel] cluster/group/gfs_controld lock_dlm.h main.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland sourceware org	2006-07-14 18:56:10

Modified files:
	group/gfs_controld: lock_dlm.h main.c 

Log message:
	keep a 1MB circular buffer of debug messages, they can be dumped out
	by running 'group_tool dump gfs'

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/lock_dlm.h.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.4&r2=1.5

--- cluster/group/gfs_controld/lock_dlm.h	2006/07/13 21:28:45	1.4
+++ cluster/group/gfs_controld/lock_dlm.h	2006/07/14 18:56:10	1.5
@@ -43,6 +43,7 @@
 #define MAX_CLIENTS		8
 #define MAX_MSGLEN		2048
 #define MAX_OPTIONS_LEN		1024
+#define DUMP_SIZE		(1024 * 1024)
 
 #define LOCK_DLM_GROUP_LEVEL	2
 #define LOCK_DLM_GROUP_NAME	"gfs"
@@ -67,11 +68,17 @@
 extern char *prog_name;
 extern int daemon_debug_opt;
 extern char daemon_debug_buf[256];
+extern char dump_buf[DUMP_SIZE];
+extern int dump_point;
+extern int dump_wrap;
+
+extern void daemon_dump_save(void);
 
 #define log_debug(fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld " fmt "\n", time(NULL), ##args); \
 	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
+	daemon_dump_save(); \
 } while (0)
 
 #define log_group(g, fmt, args...) \
@@ -79,6 +86,7 @@
 	snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
 		 (g)->name, ##args); \
 	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
+	daemon_dump_save(); \
 } while (0)
 
 #define log_error(fmt, args...) \
--- cluster/group/gfs_controld/main.c	2006/07/13 21:28:45	1.4
+++ cluster/group/gfs_controld/main.c	2006/07/14 18:56:10	1.5
@@ -125,6 +125,24 @@
 	return write(client[ci].fd, buf, len);
 }
 
+static int do_dump(int ci)
+{
+	int rv, len;
+
+	if (dump_wrap) {
+		len = DUMP_SIZE - dump_point;
+		rv = write(client[ci].fd, dump_buf + dump_point, len);
+		if (rv != len)
+			log_debug("write error %d errno %d", rv, errno);
+	}
+	len = dump_point;
+
+	rv = write(client[ci].fd, dump_buf, len);
+	if (rv != len)
+		log_debug("write error %d errno %d", rv, errno);
+	return 0;
+}
+
 static int process_client(int ci)
 {
 	char *cmd, *dir, *type, *proto, *table, *extra;
@@ -163,7 +181,10 @@
 		rv = do_unmount(ci, dir);
 	else if (!strcmp(cmd, "remount"))
 		rv = do_remount(ci, dir, argv[3]);
-	else
+	else if (!strcmp(cmd, "dump")) {
+		do_dump(ci);
+		return 0;
+	} else
 		rv = -EINVAL;
 
 	sprintf(out, "%d", rv);
@@ -492,7 +513,26 @@
 	return loop();
 }
 
+void daemon_dump_save(void)
+{
+	int len, i;
+
+	len = strlen(daemon_debug_buf);
+
+	for (i = 0; i < len; i++) {
+		dump_buf[dump_point++] = daemon_debug_buf[i];
+
+		if (dump_point == DUMP_SIZE) {
+			dump_point = 0;
+			dump_wrap = 1;
+		}
+	}
+}
+
 char *prog_name;
 int daemon_debug_opt;
 char daemon_debug_buf[256];
+char dump_buf[DUMP_SIZE];
+int dump_point;
+int dump_wrap;
 


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