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

[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.06-37-gb962b9e



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=b962b9ef98c1e3676af2da95486c13b3aed9e672

The branch, master has been updated
       via  b962b9ef98c1e3676af2da95486c13b3aed9e672 (commit)
      from  de5709272c1393b55d1a01468978e393437c3f9f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b962b9ef98c1e3676af2da95486c13b3aed9e672
Author: David Teigland <teigland redhat com>
Date:   Mon Jul 21 11:35:13 2008 -0500

    dlm_controld: use logsys
    
    Add logsys usage and configuration, following fenced pattern.
    
    Signed-off-by: David Teigland <teigland redhat com>

-----------------------------------------------------------------------

Summary of changes:
 group/dlm_controld/Makefile      |    5 ++-
 group/dlm_controld/config.c      |   39 +++++++++++++++++++++++++++++++++++++-
 group/dlm_controld/config.h      |    3 ++
 group/dlm_controld/dlm_daemon.h  |   27 +++++++++++++++++++++----
 group/dlm_controld/group.c       |    1 +
 group/dlm_controld/main.c        |   23 +++++++++++++++++++--
 group/dlm_controld/member_cman.c |    3 +-
 7 files changed, 89 insertions(+), 12 deletions(-)

diff --git a/group/dlm_controld/Makefile b/group/dlm_controld/Makefile
index 73d3925..175e44b 100644
--- a/group/dlm_controld/Makefile
+++ b/group/dlm_controld/Makefile
@@ -19,7 +19,8 @@ OBJS=	action.o \
 	member_cman.o \
 	netlink.o \
 	plock.o \
-	group.o
+	group.o \
+	logging.o
 
 CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${dlmcontrolincdir}
 CFLAGS += -I${openaisincdir}
@@ -32,7 +33,7 @@ LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
 LDFLAGS += -L${dlmlibdir} -ldlm 
 LDFLAGS += -L${openaislibdir} -lcpg -lSaCkpt
 LDFLAGS += -L../../fence/libfenced/ -lfenced
-LDFLAGS += -L../lib -lgroup -lpthread
+LDFLAGS += -L../lib -lgroup -lpthread -llogsys
 
 
 ${TARGET}: ${OBJS}
diff --git a/group/dlm_controld/config.c b/group/dlm_controld/config.c
index c31c94f..372028f 100644
--- a/group/dlm_controld/config.c
+++ b/group/dlm_controld/config.c
@@ -37,6 +37,7 @@ int optk_debug;
 int optk_timewarn;
 int optk_protocol;
 int optd_groupd_compat;
+int optd_debug_logsys;
 int optd_enable_fencing;
 int optd_enable_quorum;
 int optd_enable_deadlk;
@@ -55,6 +56,7 @@ int cfgk_debug			= -1;
 int cfgk_timewarn		= -1;
 int cfgk_protocol		= -1;
 int cfgd_groupd_compat		= DEFAULT_GROUPD_COMPAT;
+int cfgd_debug_logsys		= DEFAULT_DEBUG_LOGSYS;
 int cfgd_enable_fencing		= DEFAULT_ENABLE_FENCING;
 int cfgd_enable_quorum		= DEFAULT_ENABLE_QUORUM;
 int cfgd_enable_deadlk		= DEFAULT_ENABLE_DEADLK;
@@ -163,7 +165,42 @@ int get_weight(int nodeid, char *lockspace)
 	return w;
 }
 
-static void read_ccs_int(char *path, int *config_val)
+void read_ccs_name(char *path, char *name)
+{
+	char *str;
+	int error;
+
+	error = ccs_get(ccs_handle, path, &str);
+	if (error || !str)
+		return;
+
+	strcpy(name, str);
+
+	free(str);
+}
+
+void read_ccs_yesno(char *path, int *yes, int *no)
+{
+	char *str;
+	int error;
+
+	*yes = 0;
+	*no = 0;
+
+	error = ccs_get(ccs_handle, path, &str);
+	if (error || !str)
+		return;
+
+	if (!strcmp(str, "yes"))
+		*yes = 1;
+
+	else if (!strcmp(str, "no"))
+		*no = 1;
+
+	free(str);
+}
+
+void read_ccs_int(char *path, int *config_val)
 {
 	char *str;
 	int val;
diff --git a/group/dlm_controld/config.h b/group/dlm_controld/config.h
index fe4d5b5..4e4f33c 100644
--- a/group/dlm_controld/config.h
+++ b/group/dlm_controld/config.h
@@ -5,6 +5,7 @@
    we only change them if new values are given on command line or in ccs */
 
 #define DEFAULT_GROUPD_COMPAT 1
+#define DEFAULT_DEBUG_LOGSYS 0
 #define DEFAULT_ENABLE_FENCING 1
 #define DEFAULT_ENABLE_QUORUM 1
 #define DEFAULT_ENABLE_DEADLK 0
@@ -20,6 +21,7 @@ extern int optk_debug;
 extern int optk_timewarn;
 extern int optk_protocol;
 extern int optd_groupd_compat;
+extern int optd_debug_logsys;
 extern int optd_enable_fencing;
 extern int optd_enable_quorum;
 extern int optd_enable_deadlk;
@@ -35,6 +37,7 @@ extern int cfgk_debug;
 extern int cfgk_timewarn;
 extern int cfgk_protocol;
 extern int cfgd_groupd_compat;
+extern int cfgd_debug_logsys;
 extern int cfgd_enable_fencing;
 extern int cfgd_enable_quorum;
 extern int cfgd_enable_deadlk;
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index 8c473ab..5fef0a3 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -33,6 +33,7 @@
 #include <openais/saAis.h>
 #include <openais/saCkpt.h>
 #include <openais/cpg.h>
+#include <openais/service/logsys.h>
 
 #include <linux/dlmconstants.h>
 #include "libdlmcontrol.h"
@@ -82,29 +83,36 @@ 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(); \
+	if (daemon_debug_opt) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
+	if (cfgd_debug_logsys) \
+		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
 } while (0)
 
 #define log_group(ls, fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
 		 (ls)->name, ##args); \
-	if (daemon_debug_opt) fprintf(stderr, "%s", daemon_debug_buf); \
 	daemon_dump_save(); \
+	if (daemon_debug_opt) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
+	if (cfgd_debug_logsys) \
+		log_printf(LOG_DEBUG, "%s", daemon_debug_buf); \
 } while (0)
 
 #define log_error(fmt, args...) \
 do { \
 	log_debug(fmt, ##args); \
-	syslog(LOG_ERR, fmt, ##args); \
+	log_printf(LOG_ERR, fmt, ##args); \
 } while (0)
 
 #define log_plock(ls, fmt, args...) \
 do { \
 	snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
 		 (ls)->name, ##args); \
-	if (daemon_debug_opt && cfgd_plock_debug) fprintf(stderr, "%s", daemon_debug_buf); \
+	if (daemon_debug_opt && cfgd_plock_debug) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
 } while (0)
 
 /* dlm_header types */
@@ -200,9 +208,12 @@ void clear_configfs(void);
 int setup_configfs(void);
 
 /* config.c */
-int get_weight(int nodeid, char *lockspace);
 int setup_ccs(void);
 void close_ccs(void);
+void read_ccs_name(char *path, char *name);
+void read_ccs_yesno(char *path, int *yes, int *no);
+void read_ccs_int(char *path, int *config_val);
+int get_weight(int nodeid, char *lockspace);
 
 /* cpg.c */
 int setup_cpg(void);
@@ -282,5 +293,11 @@ int set_lockspaces_group(int *count, struct dlmc_lockspace **lss_out);
 int set_lockspace_nodes_group(struct lockspace *ls, int option, int *node_count,
 			struct dlmc_node **nodes);
 
+/* logging.c */
+
+void init_logging(void);
+void setup_logging();
+void close_logging(void);
+
 #endif
 
diff --git a/group/dlm_controld/group.c b/group/dlm_controld/group.c
index 88399df..06530cb 100644
--- a/group/dlm_controld/group.c
+++ b/group/dlm_controld/group.c
@@ -1,4 +1,5 @@
 #include "dlm_daemon.h"
+#include "config.h"
 #include "libgroup.h"
 
 #define DO_STOP 1
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index ad359e1..ac79818 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -1,6 +1,8 @@
 #include "dlm_daemon.h"
 #include "config.h"
 #include <pthread.h>
+#include "copyright.cf"
+
 #include <linux/dlmconstants.h>
 #include <linux/netlink.h>
 #include <linux/genetlink.h>
@@ -820,6 +822,8 @@ static void loop(void)
 	if (rv < 0)
 		goto out;
 
+	setup_logging();
+
 	rv = setup_configfs();
 	if (rv < 0)
 		goto out;
@@ -939,6 +943,7 @@ static void loop(void)
 	if (cfgd_groupd_compat)
 		close_groupd();
 	clear_configfs();
+	close_logging();
 	close_ccs();
 	close_cman();
 
@@ -997,6 +1002,7 @@ static void print_usage(void)
 	printf("Options:\n");
 	printf("\n");
 	printf("  -D		Enable daemon debugging and don't fork\n");
+	printf("  -L <num>	Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS);
 	printf("  -K		Enable kernel dlm debugging messages\n");
 	printf("  -g <num>	groupd compatibility, 0 off, 1 on\n");
 	printf("		on: use libgroup, compat with cluster2/stable2/rhel5\n");
@@ -1025,7 +1031,7 @@ static void print_usage(void)
 	printf("  -V		Print program version information, then exit\n");
 }
 
-#define OPTION_STRING			"DKg:f:q:d:p:Pl:o:t:c:a:hV"
+#define OPTION_STRING "L:DKg:f:q:d:p:Pl:o:t:c:a:hV"
 
 static void read_arguments(int argc, char **argv)
 {
@@ -1045,6 +1051,11 @@ static void read_arguments(int argc, char **argv)
 			daemon_debug_opt = 1;
 			break;
 
+		case 'L':
+			optd_debug_logsys = 1;
+			cfgd_debug_logsys = atoi(optarg);
+			break;
+
 		case 'g':
 			optd_groupd_compat = 1;
 			cfgd_groupd_compat = atoi(optarg);
@@ -1113,7 +1124,7 @@ static void read_arguments(int argc, char **argv)
 		case 'V':
 			printf("dlm_controld %s (built %s %s)\n",
 				RELEASE_VERSION, __DATE__, __TIME__);
-			/* printf("%s\n", REDHAT_COPYRIGHT); */
+			printf("%s\n", REDHAT_COPYRIGHT);
 			exit(EXIT_SUCCESS);
 			break;
 
@@ -1133,6 +1144,11 @@ static void read_arguments(int argc, char **argv)
 			break;
 		};
 	}
+
+	if (!optd_debug_logsys && getenv("DLM_CONTROLD_DEBUG")) {
+		optd_debug_logsys = 1;
+		cfgd_debug_logsys = atoi(getenv("DLM_CONTROLD_DEBUG"));
+	}
 }
 
 static void set_oom_adj(int val)
@@ -1169,6 +1185,8 @@ int main(int argc, char **argv)
 {
 	INIT_LIST_HEAD(&lockspaces);
 
+	init_logging();
+
 	read_arguments(argc, argv);
 
 	lockfile();
@@ -1179,7 +1197,6 @@ int main(int argc, char **argv)
 			exit(EXIT_FAILURE);
 		}
 	}
-	openlog("dlm_controld", LOG_PID, LOG_DAEMON);
 	signal(SIGTERM, sigterm_handler);
 
 	set_scheduler();
diff --git a/group/dlm_controld/member_cman.c b/group/dlm_controld/member_cman.c
index c191556..ee25d4d 100644
--- a/group/dlm_controld/member_cman.c
+++ b/group/dlm_controld/member_cman.c
@@ -1,5 +1,6 @@
-#include <libcman.h>
 #include "dlm_daemon.h"
+#include "config.h"
+#include <libcman.h>
 
 static cman_handle_t	ch;
 static cman_node_t      old_nodes[MAX_NODES];


hooks/post-receive
--
Cluster Project


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