From mboxrd@z Thu Jan 1 00:00:00 1970 From: pcaulfield@sourceware.org Date: 17 Sep 2007 13:48:16 -0000 Subject: [Cluster-devel] cluster/cman cman_tool/main.c daemon/cnxman-so ... Message-ID: <20070917134816.3301.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Branch: RHEL5 Changes by: pcaulfield at sourceware.org 2007-09-17 13:48:15 Modified files: cman/cman_tool : main.c cman/daemon : cnxman-socket.h commands.c logging.c logging.h cman/lib : libcman.c libcman.h Log message: Add option to set the cman debug level. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/cman_tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.51.2.2&r2=1.51.2.3 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/cnxman-socket.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.17.2.1&r2=1.17.2.2 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/commands.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.55.2.11&r2=1.55.2.12 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.12&r2=1.12.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/daemon/logging.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.5&r2=1.5.2.1 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/lib/libcman.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.30.2.4&r2=1.30.2.5 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/lib/libcman.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.29.2.1&r2=1.29.2.2 --- cluster/cman/cman_tool/main.c 2007/09/17 13:22:30 1.51.2.2 +++ cluster/cman/cman_tool/main.c 2007/09/17 13:48:15 1.51.2.3 @@ -31,13 +31,14 @@ #define OP_STATUS 8 #define OP_NODES 9 #define OP_SERVICES 10 +#define OP_DEBUG 11 static void print_usage(int subcmd) { printf("Usage:\n"); printf("\n"); - printf("%s [options]\n", + printf("%s [options]\n", prog_name); printf("\n"); printf("Options:\n"); @@ -289,7 +290,7 @@ printf("\n"); } } - + cman_finish(h); } static int node_compare(const void *va, const void *vb) @@ -415,6 +416,8 @@ } } free(nodes); + free(dis_nodes); + cman_finish(h); } static void show_services(void) @@ -589,6 +592,18 @@ cman_finish(h); } +static void set_debuglog(commandline_t *comline) +{ + cman_handle_t h; + + h = open_cman_handle(1); + + if (cman_set_debuglog(h, comline->verbose)) + perror("setting debuglog failed"); + + cman_finish(h); +} + static int get_int_arg(char argopt, char *arg) { @@ -772,7 +787,10 @@ } else if (strcmp(argv[optind], "services") == 0) { if (comline->operation) die("can't specify two operations"); - comline->operation = OP_SERVICES; + } else if (strcmp(argv[optind], "debug") == 0) { + if (comline->operation) + die("can't specify two operations"); + comline->operation = OP_DEBUG; } else if (strcmp(argv[optind], "remove") == 0) { comline->remove = TRUE; } else if (strcmp(argv[optind], "force") == 0) { @@ -887,6 +905,10 @@ case OP_SERVICES: show_services(); break; + + case OP_DEBUG: + set_debuglog(&comline); + break; } exit(EXIT_SUCCESS); --- cluster/cman/daemon/cnxman-socket.h 2007/09/17 13:22:31 1.17.2.1 +++ cluster/cman/daemon/cnxman-socket.h 2007/09/17 13:48:15 1.17.2.2 @@ -53,6 +53,7 @@ #define CMAN_CMD_START_CONFCHG 0x000000c0 #define CMAN_CMD_STOP_CONFCHG 0x000000c1 #define CMAN_CMD_SET_DIRTY 0x800000c2 +#define CMAN_CMD_SET_DEBUGLOG 0x800000c3 #define CMAN_CMD_DATA 0x00000100 #define CMAN_CMD_BIND 0x00000101 --- cluster/cman/daemon/commands.c 2007/09/17 13:35:35 1.55.2.11 +++ cluster/cman/daemon/commands.c 2007/09/17 13:48:15 1.55.2.12 @@ -1188,6 +1188,7 @@ int err = -EINVAL; struct cl_version cnxman_version; char *outbuf = *retbuf; + int value; P_MEMB("command to process is %x\n", cmd); @@ -1210,8 +1211,15 @@ case CMAN_CMD_SET_DIRTY: us->flags |= NODE_FLAGS_DIRTY; + err = 0; break; + case CMAN_CMD_SET_DEBUGLOG: + memcpy(&value, cmdbuf, sizeof(int)); + set_debuglog(value); + err = 0; + break; + case CMAN_CMD_START_CONFCHG: con->confchg = 1; err = 0; --- cluster/cman/daemon/logging.c 2006/06/30 13:00:27 1.12 +++ cluster/cman/daemon/logging.c 2007/09/17 13:48:15 1.12.2.1 @@ -50,6 +50,11 @@ subsys_mask = subsystems; } +void set_debuglog(int subsystems) +{ + subsys_mask = subsystems; +} + #ifdef DEBUG void log_debug(int subsys, int stamp, const char *fmt, ...) { --- cluster/cman/daemon/logging.h 2006/04/21 10:13:40 1.5 +++ cluster/cman/daemon/logging.h 2007/09/17 13:48:15 1.5.2.1 @@ -12,6 +12,7 @@ extern void log_msg(int priority, char *fmt, ...); extern void init_debug(int subsystems); +void set_debuglog(int subsystems); /* Debug macros */ #ifdef DEBUG --- cluster/cman/lib/libcman.c 2007/09/17 13:22:31 1.30.2.4 +++ cluster/cman/lib/libcman.c 2007/09/17 13:48:15 1.30.2.5 @@ -986,6 +986,14 @@ return info_call(h, CMAN_CMD_SET_DIRTY, NULL, 0, NULL, 0); } +int cman_set_debuglog(cman_handle_t handle, int subsystems) +{ + struct cman_handle *h = (struct cman_handle *)handle; + VALIDATE_HANDLE(h); + + return info_call(h, CMAN_CMD_SET_DEBUGLOG, &subsystems, sizeof(int), NULL, 0); +} + int cman_replyto_shutdown(cman_handle_t handle, int yesno) { struct cman_handle *h = (struct cman_handle *)handle; --- cluster/cman/lib/libcman.h 2007/09/17 13:22:31 1.29.2.1 +++ cluster/cman/lib/libcman.h 2007/09/17 13:48:15 1.29.2.2 @@ -393,8 +393,21 @@ * Sets the dirty bit inside cman. This indicates that the node has * some internal 'state' (eg in a daemon, filesystem or lock manager) * and cannot merge with another cluster that already has state. - * This cannot be reset. + * This needs an admin socket. It cannot be reset. */ int cman_set_dirty(cman_handle_t handle); + +/* + * Changes the debug logging level inside cman. + * subsystems is a bitmask of: + */ +#define CMAN_DEBUGLOG_NONE 0 +#define CMAN_DEBUGLOG_BARRIER 2 +#define CMAN_DEBUGLOG_MEMBERSHIP 4 +#define CMAN_DEBUGLOG_DAEMON 8 +#define CMAN_DEBUGLOG_AIS 16 + +int cman_set_debuglog(cman_handle_t handle, int subsystems); + #endif