[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-38-g2dc145d



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=2dc145de13f47a5307d633a23634afab8fd24cf4

The branch, master has been updated
       via  2dc145de13f47a5307d633a23634afab8fd24cf4 (commit)
      from  b962b9ef98c1e3676af2da95486c13b3aed9e672 (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 2dc145de13f47a5307d633a23634afab8fd24cf4
Author: David Teigland <teigland redhat com>
Date:   Mon Jul 21 11:56:39 2008 -0500

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

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

Summary of changes:
 group/gfs_controld/Makefile      |    5 ++-
 group/gfs_controld/config.c      |   59 ++++++++++++++++++++++++++++++--------
 group/gfs_controld/config.h      |    3 ++
 group/gfs_controld/gfs_daemon.h  |   37 +++++++++++++++++------
 group/gfs_controld/group.c       |    1 +
 group/gfs_controld/main.c        |   23 +++++++++++++--
 group/gfs_controld/member_cman.c |    1 +
 group/gfs_controld/util.c        |    1 +
 8 files changed, 103 insertions(+), 27 deletions(-)

diff --git a/group/gfs_controld/Makefile b/group/gfs_controld/Makefile
index 266ba75..ff1dfc3 100644
--- a/group/gfs_controld/Makefile
+++ b/group/gfs_controld/Makefile
@@ -18,7 +18,8 @@ OBJS= 	main.o \
 	cpg-old.o \
 	group.o \
 	util.o \
-	plock.o
+	plock.o \
+	logging.o
 
 CFLAGS += -I${ccsincdir} -I${cmanincdir}
 CFLAGS += -I${dlmcontrolincdir} -I${openaisincdir}
@@ -30,7 +31,7 @@ CFLAGS += -I${incdir}
 LDFLAGS += -L${ccslibdir} -lccs -L${cmanlibdir} -lcman
 LDFLAGS += -L${dlmcontrollibdir} -ldlmcontrol -L${openaislibdir} -lcpg -lSaCkpt
 LDFLAGS += -L../../fence/libfenced/ -lfenced
-LDFLAGS += -L../lib -lgroup
+LDFLAGS += -L../lib -lgroup -llogsys
 
 ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
diff --git a/group/gfs_controld/config.c b/group/gfs_controld/config.c
index 37d352d..a4195be 100644
--- a/group/gfs_controld/config.c
+++ b/group/gfs_controld/config.c
@@ -27,10 +27,10 @@
 
 static int ccs_handle;
 
-/* was a config value set on command line?, 0 or 1.
-   optk is a kernel option, optd is a daemon option */
+/* was a config value set on command line?, 0 or 1. */
 
 int optd_groupd_compat;
+int optd_debug_logsys;
 int optd_enable_withdraw;
 int optd_enable_plock;
 int optd_plock_debug;
@@ -40,10 +40,10 @@ int optd_drop_resources_time;
 int optd_drop_resources_count;
 int optd_drop_resources_age;
 
-/* actual config value from command line, cluster.conf, or default.
-   cfgk is a kernel config value, cfgd is a daemon config value */
+/* actual config value from command line, cluster.conf, or default. */
 
 int cfgd_groupd_compat		= DEFAULT_GROUPD_COMPAT;
+int cfgd_debug_logsys		= DEFAULT_DEBUG_LOGSYS;
 int cfgd_enable_withdraw	= DEFAULT_ENABLE_WITHDRAW;
 int cfgd_enable_plock		= DEFAULT_ENABLE_PLOCK;
 int cfgd_plock_debug		= DEFAULT_PLOCK_DEBUG;
@@ -53,7 +53,42 @@ int cfgd_drop_resources_time	= DEFAULT_DROP_RESOURCES_TIME;
 int cfgd_drop_resources_count	= DEFAULT_DROP_RESOURCES_COUNT;
 int cfgd_drop_resources_age	= DEFAULT_DROP_RESOURCES_AGE;
 
-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;
@@ -118,14 +153,14 @@ int setup_ccs(void)
 {
 	int i = 0, cd;
 
-        while ((cd = ccs_connect()) < 0) {
-                sleep(1);
-                if (++i > 9 && !(i % 10))
-                        log_error("connect to ccs error %d, "
-                                  "check cluster status", cd);
-        }
+	while ((cd = ccs_connect()) < 0) {
+		sleep(1);
+		if (++i > 9 && !(i % 10))
+			log_error("connect to ccs error %d, "
+				  "check cluster status", cd);
+	}
 
-        ccs_handle = cd;
+	ccs_handle = cd;
 
 	/* These config values are set from cluster.conf only if they haven't
 	   already been set on the command line. */
diff --git a/group/gfs_controld/config.h b/group/gfs_controld/config.h
index 621d8f9..c1b619c 100644
--- a/group/gfs_controld/config.h
+++ b/group/gfs_controld/config.h
@@ -2,6 +2,7 @@
 #define __CONFIG_DOT_H__
 
 #define DEFAULT_GROUPD_COMPAT 1
+#define DEFAULT_DEBUG_LOGSYS 0
 #define DEFAULT_ENABLE_WITHDRAW 1
 #define DEFAULT_ENABLE_PLOCK 1
 #define DEFAULT_PLOCK_DEBUG 0
@@ -12,6 +13,7 @@
 #define DEFAULT_DROP_RESOURCES_AGE 10000 /* 10 sec */
 
 extern int optd_groupd_compat;
+extern int optd_debug_logsys;
 extern int optd_enable_withdraw;
 extern int optd_enable_plock;
 extern int optd_plock_debug;
@@ -22,6 +24,7 @@ extern int optd_drop_resources_count;
 extern int optd_drop_resources_age;
 
 extern int cfgd_groupd_compat;
+extern int cfgd_debug_logsys;
 extern int cfgd_enable_withdraw;
 extern int cfgd_enable_plock;
 extern int cfgd_plock_debug;
diff --git a/group/gfs_controld/gfs_daemon.h b/group/gfs_controld/gfs_daemon.h
index e90c983..3c6c0df 100644
--- a/group/gfs_controld/gfs_daemon.h
+++ b/group/gfs_controld/gfs_daemon.h
@@ -34,8 +34,9 @@
 #include <openais/saAis.h>
 #include <openais/saCkpt.h>
 #include <openais/cpg.h>
-#include <linux/dlmconstants.h>
+#include <openais/service/logsys.h>
 
+#include <linux/dlmconstants.h>
 #include "libgfscontrol.h"
 #include "gfs_controld.h"
 #include "list.h"
@@ -81,29 +82,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(g, fmt, args...) \
 do { \
 	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(); \
+	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_plock(g, fmt, args...) \
+#define log_error(fmt, args...) \
 do { \
-	snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
-		 (g)->name, ##args); \
-	if (cfgd_plock_debug) fprintf(stderr, "%s", daemon_debug_buf); \
+	log_debug(fmt, ##args); \
+	log_printf(LOG_ERR, fmt, ##args); \
 } while (0)
 
-#define log_error(fmt, args...) \
+#define log_plock(g, fmt, args...) \
 do { \
-	log_debug(fmt, ##args); \
-	syslog(LOG_ERR, fmt, ##args); \
+	snprintf(daemon_debug_buf, 255, "%ld %s " fmt "\n", time(NULL), \
+		 (g)->name, ##args); \
+	if (daemon_debug_opt && cfgd_plock_debug) \
+		fprintf(stderr, "%s", daemon_debug_buf); \
 } while (0)
 
 struct mountgroup {
@@ -198,6 +206,9 @@ struct mountgroup {
 /* config.c */
 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);
 void read_ccs_nodir(struct mountgroup *mg, char *buf);
 
 /* cpg-new.c */
@@ -293,4 +304,10 @@ int run_dmsetup_suspend(struct mountgroup *mg, char *dev);
 void update_dmsetup_wait(void);
 void update_flow_control_status(void);
 
+/* logging.c */
+
+void init_logging(void);
+void setup_logging();
+void close_logging(void);
+
 #endif
diff --git a/group/gfs_controld/group.c b/group/gfs_controld/group.c
index 3baeb39..72e142a 100644
--- a/group/gfs_controld/group.c
+++ b/group/gfs_controld/group.c
@@ -1,4 +1,5 @@
 #include "gfs_daemon.h"
+#include "config.h"
 #include "cpg-old.h"
 #include "libgroup.h"
 
diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index f1a6094..145d8f6 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -1,6 +1,8 @@
 #include "gfs_daemon.h"
 #include "config.h"
 #include <pthread.h>
+#include "copyright.cf"
+
 #include <linux/netlink.h>
 
 #define LOCKFILE_NAME	"/var/run/gfs_controld.pid"
@@ -1038,6 +1040,8 @@ static void loop(void)
 	if (rv < 0)
 		goto out;
 
+	setup_logging();
+
 	rv = setup_uevent();
 	if (rv < 0)
 		goto out;
@@ -1160,6 +1164,7 @@ static void loop(void)
  out:
 	if (cfgd_groupd_compat)
 		close_groupd();
+	close_logging();
 	close_ccs();
 	close_cman();
 
@@ -1218,6 +1223,7 @@ static void print_usage(void)
 	printf("Options:\n");
 	printf("\n");
 	printf("  -D           Enable debugging code and don't fork\n");
+	printf("  -L <num>     Enable (1) or disable (0) debugging to logsys (default %d)\n", DEFAULT_DEBUG_LOGSYS);
 	printf("  -g <num>     groupd compatibility, 0 off, 1 on\n");
 	printf("               on: use libgroup, compat with cluster2/stable2/rhel5\n");
 	printf("               off: use libcpg, no backward compatability\n");
@@ -1242,7 +1248,7 @@ static void print_usage(void)
 	printf("  -V           Print program version information, then exit\n");
 }
 
-#define OPTION_STRING "DKg:w:f:q:d:p:Pl:o:t:c:a:hV"
+#define OPTION_STRING "L:DKg:w:f:q:d:p:Pl:o:t:c:a:hV"
 
 static void read_arguments(int argc, char **argv)
 {
@@ -1258,6 +1264,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);
@@ -1311,7 +1322,7 @@ static void read_arguments(int argc, char **argv)
 		case 'V':
 			printf("gfs_controld %s (built %s %s)\n",
 				RELEASE_VERSION, __DATE__, __TIME__);
-			/* printf("%s\n", REDHAT_COPYRIGHT); */
+			printf("%s\n", REDHAT_COPYRIGHT);
 			exit(EXIT_SUCCESS);
 			break;
 
@@ -1331,6 +1342,11 @@ static void read_arguments(int argc, char **argv)
 			break;
 		};
 	}
+
+	if (!optd_debug_logsys && getenv("GFS_CONTROLD_DEBUG")) {
+		optd_debug_logsys = 1;
+		cfgd_debug_logsys = atoi(getenv("GFS_CONTROLD_DEBUG"));
+	}
 }
 
 static void set_oom_adj(int val)
@@ -1367,6 +1383,8 @@ int main(int argc, char **argv)
 {
 	INIT_LIST_HEAD(&mountgroups);
 
+	init_logging();
+
 	read_arguments(argc, argv);
 
 	lockfile();
@@ -1377,7 +1395,6 @@ int main(int argc, char **argv)
 			exit(EXIT_FAILURE);
 		}
 	}
-	openlog("gfs_controld", LOG_PID, LOG_DAEMON);
 	signal(SIGTERM, sigterm_handler);
 
 	set_scheduler();
diff --git a/group/gfs_controld/member_cman.c b/group/gfs_controld/member_cman.c
index ccda450..f8570c1 100644
--- a/group/gfs_controld/member_cman.c
+++ b/group/gfs_controld/member_cman.c
@@ -1,4 +1,5 @@
 #include "gfs_daemon.h"
+#include "config.h"
 #include <libcman.h>
 
 static cman_handle_t ch;
diff --git a/group/gfs_controld/util.c b/group/gfs_controld/util.c
index 7c93934..a0ac39c 100644
--- a/group/gfs_controld/util.c
+++ b/group/gfs_controld/util.c
@@ -1,4 +1,5 @@
 #include "gfs_daemon.h"
+#include "config.h"
 #include "libfenced.h"
 
 void update_flow_control_status(void)


hooks/post-receive
--
Cluster Project


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