Cluster Project branch, master, updated. gfs-kernel_0_1_22-202-g03781f0

fabbione@sourceware.org fabbione@sourceware.org
Thu Apr 24 07:48:00 GMT 2008


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=03781f0e840d268cbc5fffc9a36548fca28a3d76

The branch, master has been updated
       via  03781f0e840d268cbc5fffc9a36548fca28a3d76 (commit)
      from  96078c8382cb000b85424d5826f6ac83d49ce2ee (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 03781f0e840d268cbc5fffc9a36548fca28a3d76
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Thu Apr 24 09:47:51 2008 +0200

    [CMAN] Convert qdiskd to use logsys
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

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

Summary of changes:
 cman/qdisk/Makefile      |    6 +-
 cman/qdisk/clulog.c      |  291 ----------------------------------------------
 cman/qdisk/clulog.h      |  161 -------------------------
 cman/qdisk/daemon_init.c |    8 +-
 cman/qdisk/disk.c        |   80 ++++++-------
 cman/qdisk/disk_util.c   |    6 +-
 cman/qdisk/main.c        |  156 ++++++++++++++-----------
 cman/qdisk/mkqdisk.c     |   22 +++-
 cman/qdisk/proc.c        |   42 ++++---
 cman/qdisk/score.c       |   23 ++--
 10 files changed, 187 insertions(+), 608 deletions(-)
 delete mode 100644 cman/qdisk/clulog.c
 delete mode 100644 cman/qdisk/clulog.h

diff --git a/cman/qdisk/Makefile b/cman/qdisk/Makefile
index 0751601..dfc6022 100644
--- a/cman/qdisk/Makefile
+++ b/cman/qdisk/Makefile
@@ -25,17 +25,17 @@ include $(OBJDIR)/make/uninstall.mk
 
 CFLAGS += -D_GNU_SOURCE
 CFLAGS += -Werror -Wstrict-prototypes -Wshadow
-CFLAGS += -I${ccsincdir} -I${cmanincdir}
+CFLAGS += -I${ccsincdir} -I${cmanincdir} -L${openaisincdir}
 CFLAGS += -I$(S)
 CFLAGS += -I${incdir}
 
+LDFLAGS += -L${openaislibdir} -llogsys -lpthread
+
 EXTRA_LDFLAGS += -L${cmanlibdir} -L${ccslibdir} -lcman -lccs
-EXTRA_LDFLAGS += -lpthread
 
 OBJS1=	main.o \
 	score.o \
 	bitmap.o \
-	clulog.o \
 	gettid.o \
 	daemon_init.o
 
diff --git a/cman/qdisk/clulog.c b/cman/qdisk/clulog.c
deleted file mode 100644
index 6b998f1..0000000
--- a/cman/qdisk/clulog.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
-  Copyright Red Hat, Inc. 2002
-  Copyright Mission Critical Linux, 2000
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by the
-  Free Software Foundation; either version 2, or (at your option) any
-  later version.
-
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
-  MA 02139, USA.
-*/
-/** @file
- * Library routines for communicating with the logging daemon.
- *
- *  Author: Jeff Moyer <moyer@missioncriticallinux.com>
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <malloc.h>
-#include <dirent.h>
-#include <signal.h>
-#include <sys/errno.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <ccs.h>
-#define SYSLOG_NAMES
-#include <sys/syslog.h>
-#undef SYSLOG_NAMES
-
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <linux/unistd.h>
-#include <pthread.h>
-#include <gettid.h>
-#include <clulog.h>
-#include <string.h>
-
-
-#ifdef DEBUG
-#include <assert.h>
-#define Dprintf(fmt,args...) printf(fmt,##args)
-#define DBG_ASSERT(x)  assert(x)
-#else
-#define Dprintf(fmt,args...)
-#define DBG_ASSERT(x)
-#endif
-
-/*
- * Globals
- */
-static int   log_is_open = 0;
-static int   useconsole = 0;
-static int   loglevel = LOGLEVEL_DFLT;
-static int   syslog_facility = LOG_DAEMON;
-static char  *daemon_name = NULL;
-static pid_t daemon_pid = -1;
-static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-CODE logger_prioritynames[] = 
-{ {"emerg", LOG_EMERG},
-  {"alert", LOG_ALERT},
-  {"crit", LOG_CRIT},
-  {"err", LOG_ERR},
-  {"warning", LOG_WARNING},
-  {"notice", LOG_NOTICE},
-  {"info", LOG_INFO},
-  {"debug", LOG_DEBUG}
-};
-
-/*
- *  Exported Functions.
- */
-
-/**
- * @return The current cluster log level.
- */
-int
-clu_get_loglevel(void)
-{
-	return loglevel;
-}
-
-
-/**
- * Set the cluster log level.
- *
- * @param severity	New log level.
- * @return 		Old log level, or -1 if 'severity' is an invalid log
- *			level.
- */
-int
-clu_set_loglevel(int severity)
-{
-	int ret = loglevel;
-
-	if (severity > 0) {
-		loglevel = severity;
-		return ret;
-	}
-
-	return -1;
-}
-
-
-/**
- * @return The current cluster log facility.
- */
-char *
-clu_get_facility(void)
-{
-	int x = 0;
-
-	pthread_mutex_lock(&log_mutex);
-	for (; facilitynames[x].c_name; x++) {
-		if (syslog_facility == facilitynames[x].c_val) {
-			pthread_mutex_unlock(&log_mutex);
-			return facilitynames[x].c_name;
-		}
-	}
-	
-	pthread_mutex_unlock(&log_mutex);
-	return "daemon";
-}
-
-
-/**
- * Set the cluster log facility.
- *
- * @param facilityname  New log facility (see /usr/include/sys/syslog.h).
- * @return 		0
- */
-int
-clu_set_facility(char *facilityname)
-{
-	int x = 0, old;
-
-	pthread_mutex_lock(&log_mutex);
-	old = syslog_facility;
-
-	for (; facilitynames[x].c_name; x++) {
-		if (strcmp(facilityname, facilitynames[x].c_name))
-			continue;
-		syslog_facility = facilitynames[x].c_val;
-		break;
-	}
-
-	if (syslog_facility == old) {
-		pthread_mutex_unlock(&log_mutex);
-		return 0;
-	}
-
-	closelog();
-	log_is_open = 0;
-	pthread_mutex_unlock(&log_mutex);
-	return 0;
-}
-
-
-/**
- * Set the console logging mode.  Does not work for daemons.
- *
- * @param onoff		0 = off, otherwise on.
- * @return		Old log-to-console state.
- */
-int
-clu_log_console(int onoff)
-{
-	int ret = useconsole;
-
-	useconsole = !!onoff;
-	return ret;
-}
-
-
-/**
- * Cluster logging function.  Talks to syslog and writes to the
- * console, if necessary.
- */
-int
-do_clulog(int        severity,
-	  int        write_to_cons,
-	  pid_t      pid,
-	  char       *prog,
-	  const char *fmt, ...)
-{
-	va_list      args;
-	char         logmsg[MAX_LOGMSG_LEN];	/* message to go to the log */
-	char         printmsg[MAX_LOGMSG_LEN];	/* message to go to stdout */
-	int          syslog_flags = LOG_NDELAY;
-
-	pthread_mutex_lock(&log_mutex);
-	if (severity > loglevel) {
-		pthread_mutex_unlock(&log_mutex);
-		return 0;
-	}
-
-	memset(logmsg, 0, MAX_LOGMSG_LEN);
-	memset(printmsg, 0, MAX_LOGMSG_LEN);
-
-	/*
-	 * Check to see if the caller has forked.
-	 */
-	if (!pid) {
-
-		/* Use thread IDs */
-		if (daemon_pid != gettid()) {
-
-			daemon_pid = gettid();
-			log_is_open = 0;
-		}
-
-		syslog_flags |= LOG_PID;
-
-	} else {
-
-		daemon_pid = pid;
-		closelog();
-		log_is_open = 0;
-		snprintf(logmsg, MAX_LOGMSG_LEN, "[%d]: ", pid);
-	}
-
-	if (prog) {
-
-		if (daemon_name) {
-
-			free(daemon_name);
-			daemon_name = NULL;
-		}
-
-		daemon_name = strdup(prog);
-	}
-
-	if (!log_is_open) {
-
-		openlog(daemon_name, syslog_flags, syslog_facility);
-		log_is_open = 1;
-	}
-	/*
-	 * Note: This can be called in the context of a CGI program, in which
-	 * case anything printed to stdout goes to the web page.  This can
-	 * cause problems if we have our standard <warning> strings b/c
-	 * the web client will try to interpret this as an html tag.
-	 */
-	snprintf(logmsg + strlen(logmsg), MAX_LOGMSG_LEN - strlen(logmsg), 
-		 "<%s> ", logger_prioritynames[severity].c_name);
-
-	va_start(args, fmt);
-	vsnprintf(logmsg + strlen(logmsg), MAX_LOGMSG_LEN - strlen(logmsg), 
-		  fmt, args);
-	va_end(args);
-
-	if (write_to_cons || useconsole) {
-		snprintf(printmsg, MAX_LOGMSG_LEN, "[%d] %s: ", daemon_pid,
-			 logger_prioritynames[severity].c_name);
-
-		va_start(args, fmt);
-		vsnprintf(printmsg + strlen(printmsg),
-			  MAX_LOGMSG_LEN - strlen(printmsg), fmt, args);
-		va_end(args);
-
-		fprintf(stdout, "%s", printmsg);
-	}
-
-	syslog(severity, "%s", logmsg);
-
-	pthread_mutex_unlock(&log_mutex);
-
-	return 0;
-}
-
-
-/**
- * Stop the cluster logging facility.
- */
-void
-clulog_close(void)
-{
-	closelog();
-}
diff --git a/cman/qdisk/clulog.h b/cman/qdisk/clulog.h
deleted file mode 100644
index 856d83c..0000000
--- a/cman/qdisk/clulog.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-  Copyright Red Hat, Inc. 2002
-  Copyright Mission Critical Linux, 2000
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by the
-  Free Software Foundation; either version 2, or (at your option) any
-  later version.
-
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; see the file COPYING.  If not, write to the
-  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
-  MA 02139, USA.
-*/
-/** @file
- * Header for clulog.c
- */
-/*
- *  author: Jeff Moyer <moyer@missioncriticallinux.com>
- */
-
-#ifndef __CLUSTER_LOG_H
-#define __CLUSTER_LOG_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <syslog.h>
-#include <sys/types.h>
-
-#define LOGLEVEL_DFLT         LOG_INFO
-#define MAX_LOGMSG_LEN        512
-
-/*
- * int clu_set_loglevel(int severity)
- *
- * DESCRIPTION
- *   Set the logging level for this daemon.  This is not a 
- *   system-wide setting.
- *
- * ARGUMENTS
- *   severity  Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- *
- * RETURN VALUES
- *   On success, the previous loglevel is returned.  On error -1 is returned.
- *
- * NOTES
- *   The only way of generating errors for this call is to give a negative
- *   value for severity.  Currently, syslog lists severities up to 8, but
- *   I see no reason for this restriction if, in the future, we decided to
- *   add more levels.  Thus, any number up to MAXINT will be supported.
- */
-int clu_set_loglevel(int severity);
-int clu_set_facility(char *facility);
-int clu_log_console(int onoff);
-
-/*
- * int clu_get_loglevel(void)
- *
- * DESCRIPTION
- *   Get the current logging level.
- *
- * ARGUMENTS
- *   none
- *
- * RETURN VALUES
- *   The current logging level is returned.
- */
-int clu_get_loglevel(void);
-
-/*
- * DESCRIPTION
- *   Cluster logging facility.  This is the actual function that does the
- *   logging.  No one should call this, you should call the wrappers provided.
- *   i.e. clulog and clulog_and_print.
- */
-int do_clulog(int severity, int write_to_cons, pid_t pid,
-	      char *prog, const char *fmt, ...);
-/*
- * int clulog(int severity, const char *fmt, ...)
- *
- * DESCRIPTION
- *   Cluster logging facility.  This is a library routine which sends the 
- *   supplied parameters to the syslog daemon.  If the supplied severity is 
- *   numerically larger than the current loglevel, the message is never sent 
- *   to the log.
- *
- * ARGUMENTS
- *   severity  Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- *   fmt       Format string as used with printf.
- *
- * RETURN VALUES
- *   On success, 0 is returned.  On error, -1 is returned.
- *
- * NOTES
- *   Inability to contact the logging daemon is the only source of error
- *   for this function.  Thus, it would behoove you to try a clulog before
- *   daemonizing your process.  If it fails, print a message to stderr
- *   explaining that the cluster logging daemon should probably be started.
- *   If you really want your message to be heard by someone, use
- *   clulog_and_print().
- */
-#define clulog(x,fmt,args...)              do_clulog(x,0,0,NULL,fmt,##args)
-#define clulog_pid(x,pid,prog,fmt,args...) do_clulog(x,0,pid,prog,fmt,##args)
-
-/*
- * int clulog_and_print(int severity, int write_to_cons, const char *fmt, ...)
- *
- * DESCRIPTION
- *   Cluster logging facility.  This is a library routine which sends the 
- *   supplied parameters to the syslog daemon.  If the supplied severity is 
- *   numerically larger than the current loglevel, the message is never sent 
- *   to the log.  This version also prints the given message to the terminal.
- *
- * ARGUMENTS
- *   severity       Severity as documented in sys/syslog.h (i.e. LOG_ERR)
- *   fmt            Format string as used with printf.
- *
- * RETURN VALUES
- *   On success, 0 is returned.  On error, -1 is returned.
- */
-#define clulog_and_print(x,fmt,args...)   do_clulog(x,1,0,NULL,fmt,##args)
-
-
-/*
- * void clulog_close(void)
- *
- * DESCRIPTION
- *   This is an optional call to close the logfile.  This translates into a
- *   closelog() call.
- *
- * ARGUMENTS
- *   none
- *
- * RETURN VALUES
- *   This function does not return anything.
- */
-void clulog_close(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-#endif				/* __CLUSTER_LOG_H */
-/*
- * Local variables:
- *  c-basic-offset: 8
- *  c-indent-level: 8
- *  tab-width: 8
- * End:
- */
diff --git a/cman/qdisk/daemon_init.c b/cman/qdisk/daemon_init.c
index 4fd0309..21aebf2 100644
--- a/cman/qdisk/daemon_init.c
+++ b/cman/qdisk/daemon_init.c
@@ -42,6 +42,7 @@
 #include <sys/errno.h>
 #include <libgen.h>
 #include <signal.h>
+#include <openais/service/logsys.h>
 
 /*
  * This should ultimately go in a header file.
@@ -56,6 +57,7 @@ int check_process_running(char *prog, pid_t * pid);
 static void update_pidfile(char *prog);
 static int setup_sigmask(void);
 
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 int
 check_pid_valid(pid_t pid, char *prog)
@@ -216,19 +218,19 @@ daemon_init(char *prog)
 
 	uid = getuid();
 	if (uid) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 			"daemon_init: Sorry, only root wants to run this.\n");
 		exit(1);
 	}
 
 	if (check_process_running(prog, &pid) && (pid != getpid())) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 			"daemon_init: Process \"%s\" already running.\n",
 			prog);
 		exit(1);
 	}
 	if (setup_sigmask() < 0) {
-		fprintf(stderr, "daemon_init: Unable to set signal mask.\n");
+		log_printf(LOG_ERR, "daemon_init: Unable to set signal mask.\n");
 		exit(1);
 	}
 
diff --git a/cman/qdisk/disk.c b/cman/qdisk/disk.c
index f3222ed..042c5cb 100644
--- a/cman/qdisk/disk.c
+++ b/cman/qdisk/disk.c
@@ -44,10 +44,12 @@
 #include <unistd.h>
 #include <time.h>
 #include <linux/fs.h>
+#include <openais/service/logsys.h>
 
 static int diskRawRead(target_info_t *disk, char *buf, int len);
 uint32_t clu_crc32(const char *data, size_t count);
 
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 /**
  * Swap the bytes of a shared header so that it's always in big-endian form
@@ -119,7 +121,7 @@ header_generate(shared_header_t *hdr, const char *data, size_t count)
 		hdr->h_length = (uint32_t)count;
 
 		if (hdr->h_dcrc == 0) {
-			fprintf(stderr, "Invalid CRC32 generated on data!\n");
+			log_printf(LOG_ERR, "Invalid CRC32 generated on data!\n");
 			return -1;
 		}
 	}
@@ -128,7 +130,7 @@ header_generate(shared_header_t *hdr, const char *data, size_t count)
 
 	hdr->h_hcrc = clu_crc32((char *)hdr, sizeof(*hdr));
 	if (hdr->h_hcrc == 0) {
-		fprintf(stderr, "Invalid CRC32 generated on header!\n");
+		log_printf(LOG_ERR, "Invalid CRC32 generated on header!\n");
 		return -1;
 	}
 
@@ -165,10 +167,8 @@ header_verify(shared_header_t *hdr, const char *data, size_t count)
 	crc = clu_crc32((char *)hdr, sizeof(*hdr));
 	hdr->h_hcrc = bkupcrc;
 	if (bkupcrc != crc) {
-#if 0
-		fprintf(stderr, "Header CRC32 mismatch; Exp: 0x%08x "
+		log_printf(LOG_DEBUG, "Header CRC32 mismatch; Exp: 0x%08x "
 			"Got: 0x%08x\n", bkupcrc, crc);
-#endif
 		return -1;
 	}
 
@@ -176,10 +176,8 @@ header_verify(shared_header_t *hdr, const char *data, size_t count)
 	 * Verify the magic number.
 	 */
 	if (hdr->h_magic != SHARED_HEADER_MAGIC) {
-#if 0
-		fprintf(stderr, "Magic mismatch; Exp: 0x%08x "
+		log_printf(LOG_DEBUG, "Magic mismatch; Exp: 0x%08x "
 			"Got: 0x%08x\n", SHARED_HEADER_MAGIC, hdr->h_magic);
-#endif
 		return -1;
 	}
 
@@ -194,10 +192,8 @@ header_verify(shared_header_t *hdr, const char *data, size_t count)
 			hdr->h_length : count);
 
 	if (hdr->h_dcrc != crc) {
-#if 0
-		fprintf(stderr, "Data CRC32 mismatch; Exp: 0x%08x "
+		log_printf(LOG_DEBUG, "Data CRC32 mismatch; Exp: 0x%08x "
 			"Got: 0x%08x\n", hdr->h_dcrc, crc);
-#endif
 		return -1;
 	}
 
@@ -227,7 +223,7 @@ qdisk_open(char *name, target_info_t *disk)
 
 	ret = ioctl(disk->d_fd, BLKSSZGET, &ssz);
 	if (ret < 0) {
-		perror("qdisk_open: ioctl(BLKSSZGET)");
+		log_printf(LOG_ERR, "qdisk_open: ioctl(BLKSSZGET)");
 		return -1;
 	}
 
@@ -237,12 +233,12 @@ qdisk_open(char *name, target_info_t *disk)
 	/* Check to verify that the partition is large enough.*/
 	ret = lseek(disk->d_fd, END_OF_DISK(disk->d_blksz), SEEK_SET);
 	if (ret < 0) {
-		perror("open_partition: seek");
+		log_printf(LOG_DEBUG, "open_partition: seek");
 		return -1;
 	}
 
 	if (ret < END_OF_DISK(disk->d_blksz)) {
-		fprintf(stderr, "Partition %s too small\n", name);
+		log_printf(LOG_ERR, "Partition %s too small\n", name);
 		errno = EINVAL;
 		return -1;
 	}
@@ -250,14 +246,14 @@ qdisk_open(char *name, target_info_t *disk)
 	/* Set close-on-exec bit */
         ret = fcntl(disk->d_fd, F_GETFD, 0);
         if (ret < 0) {
-		perror("open_partition: fcntl(F_GETFD)");
+		log_printf(LOG_ERR, "open_partition: fcntl(F_GETFD)");
                 close(disk->d_fd);
                 return -1;
         }
 
         ret |= FD_CLOEXEC;
         if (fcntl(disk->d_fd, F_SETFD, ret) < 0) {
-		perror("open_partition: fcntl(F_SETFD)");
+		log_printf(LOG_ERR, "open_partition: fcntl(F_SETFD)");
                 close(disk->d_fd);
                 return -1;
         }
@@ -301,7 +297,7 @@ qdisk_validate(char *name)
 	stat_ptr = &stat_st;
 
 	if (stat(name, stat_ptr) < 0) {
-		perror("stat");
+		log_printf(LOG_ERR, "stat");
 		return -1;
 	}
 	/*
@@ -312,7 +308,7 @@ qdisk_validate(char *name)
 		errno = EINVAL;
 		return -1;
 */
-		fprintf(stderr, "Warning: %s is not a block device\n",
+		log_printf(LOG_WARNING, "Warning: %s is not a block device\n",
 		        name);
 	}
 
@@ -320,7 +316,7 @@ qdisk_validate(char *name)
 	 * Verify read/write permission.
 	 */
 	if (qdisk_open(name, &disk) < 0) {
-		fprintf(stderr, "%s: open of %s for RDWR failed: %s\n",
+		log_printf(LOG_DEBUG, "%s: open of %s for RDWR failed: %s\n",
 			__FUNCTION__, name, strerror(errno));
 		return -1;
 	}
@@ -339,21 +335,17 @@ diskRawReadShadow(target_info_t *disk, off_t readOffset, char *buf, int len)
 
 	ret = lseek(disk->d_fd, readOffset, SEEK_SET);
 	if (ret != readOffset) {
-#if 0
-		fprintf(stderr,
+		log_printf(LOG_DEBUG,
 		       "diskRawReadShadow: can't seek to offset %d.\n",
 		       (int) readOffset);
-#endif
 		errno = ENODATA;
 		return -1;
 	}
 
 	ret = diskRawRead(disk, buf, len);
 	if (ret != len) {
-#if 0
-		fprintf(stderr, "diskRawReadShadow: aligned read "
+		log_printf(LOG_DEBUG, "diskRawReadShadow: aligned read "
 		       "returned %d, not %d.\n", ret, len);
-#endif
 		errno = ENODATA;
 		return -1;
 	}
@@ -365,11 +357,9 @@ diskRawReadShadow(target_info_t *disk, off_t readOffset, char *buf, int len)
 	datalen = hdrp->h_length;
 
 	if (header_verify(hdrp, data, len)) {
-#if 0
-		fprintf(stderr, "diskRawReadShadow: bad CRC32, "
-		       "fd = %d offset = %d len = %d\n", fd,
+		log_printf(LOG_DEBUG, "diskRawReadShadow: bad CRC32, "
+		       "offset = %d len = %d\n",
 		       (int) readOffset, len);
-#endif
 		errno = EPROTO;
 		return -1;
 	}
@@ -406,7 +396,7 @@ diskRawRead(target_info_t *disk, char *buf, int len)
 	}
 
 	if (len > disk->d_blksz) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 			"diskRawRead: not setup for reads larger than %d.\n",
 		       (int)disk->d_blksz);
 		return (-1);
@@ -443,7 +433,7 @@ diskRawRead(target_info_t *disk, char *buf, int len)
 
 	free(alignedBuf);
 	if (readret != len) {
-		fprintf(stderr, "diskRawRead: read err, len=%d, readret=%d\n",
+		log_printf(LOG_ERR, "diskRawRead: read err, len=%d, readret=%d\n",
 			len, readret);
 	}
 
@@ -478,7 +468,7 @@ diskRawWrite(target_info_t *disk, char *buf, int len)
 	}
 
 	if (len > disk->d_blksz) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 			"diskRawRead: not setup for reads larger than %d.\n",
 		       (int)disk->d_blksz);
 		return (-1);
@@ -504,7 +494,7 @@ diskRawWrite(target_info_t *disk, char *buf, int len)
 	}
 
 	if (len > disk->d_blksz) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 		       "diskRawWrite: not setup for larger than %d.\n",
 		       (int)disk->d_blksz);
 		return (-1);
@@ -518,7 +508,7 @@ diskRawWrite(target_info_t *disk, char *buf, int len)
 
 	free(alignedBuf);
 	if (ret != len) {
-		fprintf(stderr, "diskRawWrite: write err, len=%d, ret=%dn",
+		log_printf(LOG_ERR, "diskRawWrite: write err, len=%d, ret=%dn",
 		       len, ret);
 	}
 
@@ -533,7 +523,7 @@ diskRawWriteShadow(target_info_t *disk, __off64_t writeOffset, char *buf, int le
 	ssize_t retval_write;
 
 	if ((writeOffset < 0) || (len < 0)) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 		       "diskRawWriteShadow: writeOffset=%08x, "
 		       "len=%08x.\n", (int)writeOffset, len);
 		return (-1);
@@ -541,7 +531,7 @@ diskRawWriteShadow(target_info_t *disk, __off64_t writeOffset, char *buf, int le
 
 	retval_seek = lseek(disk->d_fd, writeOffset, SEEK_SET);
 	if (retval_seek != writeOffset) {
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 		       "diskRawWriteShadow: can't seek to offset %d\n",
 		       (int) writeOffset);
 		return (-1);
@@ -550,10 +540,10 @@ diskRawWriteShadow(target_info_t *disk, __off64_t writeOffset, char *buf, int le
 	retval_write = diskRawWrite(disk, buf, len);
 	if (retval_write != len) {
 		if (retval_write == -1) {
-			fprintf(stderr, "%s: %s\n", __FUNCTION__,
+			log_printf(LOG_ERR, "%s: %s\n", __FUNCTION__,
 			       strerror(errno));
 		}
-		fprintf(stderr,
+		log_printf(LOG_ERR,
 		       "diskRawWriteShadow: aligned write returned %d"
 		       ", not %d\n", (int)retval_write, (int)len);
 		return (-1);
@@ -626,7 +616,7 @@ qdisk_write(target_info_t *disk, __off64_t offset, const void *buf, int count)
 
 	maxsize = psz - (sizeof(shared_header_t));
 	if (count >= (maxsize + sizeof(shared_header_t))) {
-		printf("error: count %d >= (%d + %d)\n", (int)count,
+		log_printf(LOG_ERR, "error: count %d >= (%d + %d)\n", (int)count,
 		       (int)maxsize, (int)sizeof(shared_header_t));
 		errno = ENOSPC;
 		return -1;
@@ -646,7 +636,7 @@ qdisk_write(target_info_t *disk, __off64_t offset, const void *buf, int count)
 	ptr = NULL;
 	rv = posix_memalign((void **)&ptr, disk->d_pagesz, total);
 	if (rv < 0) {
-		perror("posix_memalign");
+		log_printf(LOG_ERR, "posix_memalign");
 		return -1;
 	}
 
@@ -671,7 +661,7 @@ qdisk_write(target_info_t *disk, __off64_t offset, const void *buf, int count)
 		rv = diskRawWriteShadow(disk, offset, (char *)hdrp, psz);
 
 	if (rv == -1)
-		perror("diskRawWriteShadow");
+		log_printf(LOG_ERR, "diskRawWriteShadow");
 	
 	free((char *)hdrp);
 	if (rv == -1)
@@ -697,7 +687,7 @@ header_init(target_info_t *disk, char *label)
 	}
 
 	if (gethostname(qh.qh_updatehost, sizeof(qh.qh_updatehost)) < 0) {
-		perror("gethostname");
+		log_printf(LOG_ERR, "gethostname");
 		return -1;
 	}
 
@@ -706,7 +696,7 @@ header_init(target_info_t *disk, char *label)
 
 	qh.qh_version = VERSION_MAGIC_V2;
 	if ((qh.qh_timestamp = (uint64_t)time(NULL)) <= 0) {
-		perror("time");
+		log_printf(LOG_ERR, "time");
 		return -1;
 	}
 
@@ -733,13 +723,13 @@ qdisk_init(char *partname, char *label)
 
 	ret = qdisk_validate(partname);
 	if (ret < 0) {
-		perror("qdisk_verify");
+		log_printf(LOG_DEBUG, "qdisk_verify");
 		return -1;
 	}
 
 	ret = qdisk_open(partname, &disk);
 	if (ret < 0) {
-		perror("qdisk_open");
+		log_printf(LOG_ERR, "qdisk_open");
 		return -1;
 	}
 
diff --git a/cman/qdisk/disk_util.c b/cman/qdisk/disk_util.c
index f5539c0..040b978 100644
--- a/cman/qdisk/disk_util.c
+++ b/cman/qdisk/disk_util.c
@@ -35,7 +35,9 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <time.h>
+#include <openais/service/logsys.h>
 
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 inline void
 _diff_tv(struct timeval *dest, struct timeval *start, struct timeval *end)
@@ -204,7 +206,7 @@ qd_write_status(qd_ctx *ctx, int nid, disk_node_state_t state,
 	if (qdisk_write(&ctx->qc_disk,
 			qdisk_nodeid_offset(nid, ctx->qc_disk.d_blksz),
 			&ps, sizeof(ps)) < 0) {
-		printf("Error writing node ID block %d\n", nid);
+		log_printf(LOG_ERR, "Error writing node ID block %d\n", nid);
 		return -1;
 	}
 	if (utime_ok && (get_time(&end, ctx->qc_flags&RF_UPTIME) < 0))
@@ -278,7 +280,7 @@ qd_read_print_status(target_info_t *disk, int nid)
 
 	if (qdisk_read(disk, qdisk_nodeid_offset(nid, disk->d_blksz), &ps,
 			sizeof(ps)) < 0) {
-		printf("Error reading node ID block %d\n", nid);
+		log_printf(LOG_ERR, "Error reading node ID block %d\n", nid);
 		return -1;
 	}
 	swab_status_block_t(&ps);
diff --git a/cman/qdisk/main.c b/cman/qdisk/main.c
index b953367..6f6ee1c 100644
--- a/cman/qdisk/main.c
+++ b/cman/qdisk/main.c
@@ -41,8 +41,8 @@
 #include <sched.h>
 #include <signal.h>
 #include <ccs.h>
+#include <openais/service/logsys.h>
 #include "score.h"
-#include "clulog.h"
 #if (!defined(LIBCMAN_VERSION) || \
      (defined(LIBCMAN_VERSION) && LIBCMAN_VERSION < 2))
 #include <cluster/cnxman-socket.h>
@@ -72,6 +72,13 @@ void update_local_status(qd_ctx *ctx, node_info_t *ni, int max, int score,
 		    	 int score_req, int score_max);
 
 
+LOGSYS_DECLARE_SYSTEM (NULL,
+        LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_DISPLAY_DEBUG | LOG_MODE_BUFFER_BEFORE_CONFIG,
+        LOGDIR "/qdisk.log",
+        SYSLOGFACILITY);
+
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
+
 static void
 int_handler(int sig)
 {
@@ -127,7 +134,7 @@ check_self(qd_ctx *ctx, status_block_t *sb)
 		/* Someone told us to die. */
 		reboot(RB_AUTOBOOT);
 	default:
-		clulog(LOG_EMERG, "Unhandled state: %d\n", sb->ps_state);
+		log_printf(LOG_EMERG, "Unhandled state: %d\n", sb->ps_state);
 		raise(SIGSTOP);
 	}
 }
@@ -151,7 +158,7 @@ read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
 		if (qdisk_read(&ctx->qc_disk,
 			       qdisk_nodeid_offset(x+1, ctx->qc_disk.d_blksz),
 			       sb, sizeof(*sb)) < 0) {
-			clulog(LOG_WARNING,"Error reading node ID block %d\n",
+			log_printf(LOG_WARNING,"Error reading node ID block %d\n",
 			       x+1);
 			continue;
 		}
@@ -176,7 +183,7 @@ read_node_blocks(qd_ctx *ctx, node_info_t *ni, int max)
 			/* XXX check for average + allow grace */
 			ni[x].ni_misses++;
 			if (ni[x].ni_misses > 1) {
-				clulog(LOG_DEBUG,
+				log_printf(LOG_DEBUG,
 					"Node %d missed an update (%d/%d)\n",
 					x+1, ni[x].ni_misses, ctx->qc_tko);
 			}
@@ -219,11 +226,11 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 		       ni[x].ni_status.ps_incarnation))) {
 
 			if (ni[x].ni_status.ps_state == S_EVICT) {
-				clulog(LOG_NOTICE, "Node %d evicted\n",
+				log_printf(LOG_NOTICE, "Node %d evicted\n",
 				       ni[x].ni_status.ps_nodeid);
 			} else {
 				/* State == S_NONE or incarnation change */
-				clulog(LOG_INFO, "Node %d shutdown\n",
+				log_printf(LOG_INFO, "Node %d shutdown\n",
 				       ni[x].ni_status.ps_nodeid);
 				ni[x].ni_evil_incarnation = 0;
 			}
@@ -257,13 +264,13 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 			   Write eviction notice if we're the master.
 			 */
 			if (ctx->qc_status == S_MASTER) {
-				clulog(LOG_NOTICE,
+				log_printf(LOG_NOTICE,
 				       "Writing eviction notice for node %d\n",
 				       ni[x].ni_status.ps_nodeid);
 				qd_write_status(ctx, ni[x].ni_status.ps_nodeid,
 						S_EVICT, NULL, NULL, NULL);
 				if (ctx->qc_flags & RF_ALLOW_KILL) {
-					clulog(LOG_DEBUG, "Telling CMAN to "
+					log_printf(LOG_DEBUG, "Telling CMAN to "
 						"kill the node\n");
 					cman_kill_node(ctx->qc_ch,
 						ni[x].ni_status.ps_nodeid);
@@ -277,7 +284,7 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 			 */
 			if (ni[x].ni_status.ps_state >= S_RUN &&
 			    ni[x].ni_seen) {
-				clulog(LOG_DEBUG, "Node %d DOWN\n",
+				log_printf(LOG_DEBUG, "Node %d DOWN\n",
 				       ni[x].ni_status.ps_nodeid);
 				ni[x].ni_seen = 0;	
 			}
@@ -304,10 +311,10 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 		if (ni[x].ni_evil_incarnation &&
                     (ni[x].ni_evil_incarnation == 
 		     ni[x].ni_status.ps_incarnation)) {
-			clulog(LOG_CRIT, "Node %d is undead.\n",
+			log_printf(LOG_CRIT, "Node %d is undead.\n",
 			       ni[x].ni_status.ps_nodeid);
 
-			clulog(LOG_ALERT,
+			log_printf(LOG_ALERT,
 			       "Writing eviction notice for node %d\n",
 			       ni[x].ni_status.ps_nodeid);
 			qd_write_status(ctx, ni[x].ni_status.ps_nodeid,
@@ -316,7 +323,7 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 
 			/* XXX Need to fence it again */
 			if (ctx->qc_flags & RF_ALLOW_KILL) {
-				clulog(LOG_DEBUG, "Telling CMAN to "
+				log_printf(LOG_DEBUG, "Telling CMAN to "
 					"kill the node\n");
 				cman_kill_node(ctx->qc_ch,
 					ni[x].ni_status.ps_nodeid);
@@ -339,7 +346,7 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 			   right now.
 			 */
 			ni[x].ni_state = S_RUN;
-			clulog(LOG_DEBUG, "Node %d is UP\n",
+			log_printf(LOG_DEBUG, "Node %d is UP\n",
 			       ni[x].ni_status.ps_nodeid);
 			ni[x].ni_incarnation =
 			    ni[x].ni_status.ps_incarnation;
@@ -356,7 +363,7 @@ check_transitions(qd_ctx *ctx, node_info_t *ni, int max, memb_mask_t mask)
 		 */
 		if (ni[x].ni_state == S_RUN &&
 		    ni[x].ni_status.ps_state == S_MASTER) {
-			clulog(LOG_INFO, "Node %d is the master\n",
+			log_printf(LOG_INFO, "Node %d is the master\n",
 			       ni[x].ni_status.ps_nodeid);
 			ni[x].ni_state = S_MASTER;
 			if (mask)
@@ -417,7 +424,7 @@ master_exists(qd_ctx *ctx, node_info_t *ni, int max, int *low_id, int *count)
 		/* Look for dead master */
 		if (ni[x].ni_state < S_RUN &&
 		    ni[x].ni_status.ps_state == S_MASTER) {
-			clulog(LOG_DEBUG,
+			log_printf(LOG_DEBUG,
 			       "Node %d is marked master, but is dead.\n",
 			       ni[x].ni_status.ps_nodeid);
 			continue;
@@ -455,28 +462,28 @@ quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh)
 {
 	int x = 0, score, maxscore, score_req;
 
-	clulog(LOG_INFO, "Quorum Daemon Initializing\n");
+	log_printf(LOG_INFO, "Quorum Daemon Initializing\n");
 	
 	if (mlockall(MCL_CURRENT|MCL_FUTURE) != 0) {
-		clulog(LOG_ERR, "Unable to mlockall()\n");
+		log_printf(LOG_ERR, "Unable to mlockall()\n");
 	}
 
 	if (qdisk_validate(ctx->qc_device) < 0)
 		return -1;
 
 	if (qdisk_open(ctx->qc_device, &ctx->qc_disk) < 0) {
-		clulog(LOG_CRIT, "Failed to open %s: %s\n", ctx->qc_device,
+		log_printf(LOG_CRIT, "Failed to open %s: %s\n", ctx->qc_device,
 		       strerror(errno));
 		return -1;
 	}
 
-	clulog(LOG_DEBUG, "I/O Size: %d  Page Size: %d\n",
+	log_printf(LOG_DEBUG, "I/O Size: %lu  Page Size: %lu\n",
 	       ctx->qc_disk.d_blksz, ctx->qc_disk.d_pagesz);
 	
 	if (h && maxh) {
 		start_score_thread(ctx, h, maxh);
 	} else {
-		clulog(LOG_DEBUG, "Permanently setting score to 1/1\n");
+		log_printf(LOG_DEBUG, "Permanently setting score to 1/1\n");
 		fudge_scoring();
 	}
 
@@ -484,7 +491,7 @@ quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh)
 	ctx->qc_status = S_INIT;
 	if (qd_write_status(ctx, ctx->qc_my_id,
 			    S_INIT, NULL, NULL, NULL) != 0) {
-		clulog(LOG_CRIT, "Could not initialize status block!\n");
+		log_printf(LOG_CRIT, "Could not initialize status block!\n");
 		return -1;
 	}
 
@@ -494,7 +501,7 @@ quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh)
 
 		if (qd_write_status(ctx, ctx->qc_my_id,
 				    S_INIT, NULL, NULL, NULL) != 0) {
-			clulog(LOG_CRIT, "Initialization failed\n");
+			log_printf(LOG_CRIT, "Initialization failed\n");
 			return -1;
 		}
 
@@ -508,8 +515,8 @@ quorum_init(qd_ctx *ctx, node_info_t *ni, int max, struct h_data *h, int maxh)
 	}
 
 	get_my_score(&score, &maxscore);
-	clulog(LOG_INFO, "Initial score %d/%d\n", score, maxscore);
-	clulog(LOG_INFO, "Initialization complete\n");
+	log_printf(LOG_INFO, "Initial score %d/%d\n", score, maxscore);
+	log_printf(LOG_INFO, "Initialization complete\n");
 
 	return 0;
 }
@@ -807,7 +814,7 @@ set_priority(int queue, int prio)
 	}
 	
 	if (ret < 0 && errno) {
-		clulog(LOG_WARNING, "set_priority [%s] failed: %s\n", func,
+		log_printf(LOG_WARNING, "set_priority [%s] failed: %s\n", func,
 		       strerror(errno));
 	}
 }
@@ -852,7 +859,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 	
 	get_my_score(&score, &score_max);
 	if (score_max < ctx->qc_scoremin) {
-		clulog(LOG_WARNING, "Minimum score (%d) is impossible to "
+		log_printf(LOG_WARNING, "Minimum score (%d) is impossible to "
 		       "achieve (heuristic total = %d)\n",
 		       ctx->qc_scoremin, score_max);
 	}
@@ -882,7 +889,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		if (score < score_req) {
 			clear_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
 			if (ctx->qc_status > S_NONE) {
-				clulog(LOG_NOTICE,
+				log_printf(LOG_NOTICE,
 				       "Score insufficient for master "
 				       "operation (%d/%d; required=%d); "
 				       "downgrading\n",
@@ -892,7 +899,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 				++msg.m_seq;
 				bid_pending = 0;
 				if (cman_alive(ctx->qc_ch) < 0) {
-					clulog(LOG_ERR, "cman: %s\n",
+					log_printf(LOG_ERR, "cman: %s\n",
 					       strerror(errno));
 				} else {
 					cman_poll_quorum_device(ctx->qc_ch, 0);
@@ -903,7 +910,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		}  else {
 			set_bit(mask, (ctx->qc_my_id-1), sizeof(mask));
 			if (ctx->qc_status == S_NONE) {
-				clulog(LOG_NOTICE,
+				log_printf(LOG_NOTICE,
 				       "Score sufficient for master "
 				       "operation (%d/%d; required=%d); "
 				       "upgrading\n",
@@ -922,7 +929,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		/* Resolve master conflict, if one exists */
 		if (count >= 1 && ctx->qc_status == S_MASTER &&
 		    ctx->qc_master != ctx->qc_my_id) {
-			clulog(LOG_WARNING, "Master conflict: abdicating\n");
+			log_printf(LOG_WARNING, "Master conflict: abdicating\n");
 
 			/* Handle just like a recent upgrade */
 			ctx->qc_status = S_RUN;
@@ -945,7 +952,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 			   upgraded.
 			 */
 
-			clulog(LOG_DEBUG,"Making bid for master\n");
+			log_printf(LOG_DEBUG,"Making bid for master\n");
 			msg.m_msg = M_BID;
 			++msg.m_seq;
 			bid_pending = 1;
@@ -972,7 +979,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 				if (bid_pending < (ctx->qc_master_wait))
 					break;
 				
-				clulog(LOG_INFO,
+				log_printf(LOG_INFO,
 				       "Assuming master role\n");
 				ctx->qc_status = S_MASTER;
 			case 2:
@@ -988,7 +995,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 			/* We think we're master, but someone else claims
 			   that they are master. */
 
-			clulog(LOG_CRIT,
+			log_printf(LOG_CRIT,
 			       "A master exists, but it's not me?!\n");
 			/* XXX Handle this how? Should not happen*/
 			/* reboot(RB_AUTOBOOT); */
@@ -1000,9 +1007,9 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 			   We can't be the master unless we score high
 			   enough on our heuristics. */
 			if (cman_alive(ctx->qc_ch) < 0) {
-				clulog(LOG_ERR, "cman_dispatch: %s\n",
+				log_printf(LOG_ERR, "cman_dispatch: %s\n",
 				       strerror(errno));
-				clulog(LOG_ERR,
+				log_printf(LOG_ERR,
 				       "Halting qdisk operations\n");
 				return -1;
 			}
@@ -1020,9 +1027,9 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 				       ctx->qc_my_id-1,
 				       sizeof(memb_mask_t))) {
 				if (cman_alive(ctx->qc_ch) < 0) {
-					clulog(LOG_ERR, "cman_dispatch: %s\n",
+					log_printf(LOG_ERR, "cman_dispatch: %s\n",
 						strerror(errno));
-					clulog(LOG_ERR,
+					log_printf(LOG_ERR,
 						"Halting qdisk operations\n");
 					return -1;
 				}
@@ -1033,7 +1040,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		/* Write out our status */
 		if (qd_write_status(ctx, ctx->qc_my_id, ctx->qc_status,
 				    &msg, mask, master_mask) != 0) {
-			clulog(LOG_ERR, "Error writing to quorum disk\n");
+			log_printf(LOG_ERR, "Error writing to quorum disk\n");
 		}
 
 		/* write out our local status */
@@ -1049,7 +1056,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		 */
 		if (_cmp_tv(&maxtime, &diff) == 1 &&
 		    ctx->qc_flags & RF_PARANOID) {
-			clulog(LOG_EMERG, "Failed to complete a cycle within "
+			log_printf(LOG_EMERG, "Failed to complete a cycle within "
 			       "%d second%s (%d.%06d) - REBOOTING\n",
 			       (int)maxtime.tv_sec,
 			       maxtime.tv_sec==1?"":"s",
@@ -1068,7 +1075,7 @@ quorum_loop(qd_ctx *ctx, node_info_t *ni, int max)
 		if (_cmp_tv(&diff, &interval) == 1) {
 			_diff_tv(&sleeptime, &diff, &interval);
 		} else {
-			clulog(LOG_WARNING, "qdisk cycle took more "
+			log_printf(LOG_WARNING, "qdisk cycle took more "
 			       "than %d second%s to complete (%d.%06d)\n",
 			       ctx->qc_interval, ctx->qc_interval==1?"":"s",
 			       (int)diff.tv_sec, (int)diff.tv_usec);
@@ -1093,7 +1100,7 @@ quorum_logout(qd_ctx *ctx)
 	/* Write out our status */
 	if (qd_write_status(ctx, ctx->qc_my_id, S_NONE,
 			    NULL, NULL, NULL) != 0) {
-		clulog(LOG_WARNING,
+		log_printf(LOG_WARNING,
 		       "Error writing to quorum disk during logout\n");
 	}
 	return 0;
@@ -1111,11 +1118,11 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
 	char query[256];
 	char *val;
 
-	clulog(LOG_DEBUG, "Loading configuration information\n");
+	log_printf(LOG_DEBUG, "Loading configuration information\n");
 
 	ccsfd = ccs_force_connect(cluster_name, 1);
 	if (ccsfd < 0) {
-		clulog(LOG_CRIT, "Connection to CCSD failed; cannot start\n");
+		log_printf(LOG_CRIT, "Connection to CCSD failed; cannot start\n");
 		return -1;
 	}
 
@@ -1126,14 +1133,21 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
 			/* | RF_STOP_CMAN;*/
 	if (debug)
 		ctx->qc_flags |= RF_DEBUG;
+
 	ctx->qc_sched = SCHED_RR;
 	ctx->qc_sched_prio = 1;
 
 	/* Get log log_facility */
 	snprintf(query, sizeof(query), "/cluster/quorumd/@log_facility");
 	if (ccs_get(ccsfd, query, &val) == 0) {
-		clu_set_facility(val);
-		clulog(LOG_DEBUG, "Log facility: %s\n", val);
+		int facility;
+
+		facility = logsys_facility_id_get (val);
+		if (facility < 0)
+			facility = SYSLOGFACILITY;
+
+		logsys_config_facility_set ("QDISK", facility);
+		log_printf(LOG_DEBUG, "Log facility: %s (%d)\n", val, facility);
 		free(val);
 	}
 
@@ -1143,10 +1157,10 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
 		loglevel = atoi(val);
 		free(val);
 		if (loglevel < 0)
-			loglevel = 4;
+			loglevel = LOG_LEVEL_INFO;
 
 		if (!debug)
-			clu_set_loglevel(loglevel);
+			logsys_config_priority_set (loglevel);
 	}
 
 	/* Get interval */
@@ -1258,7 +1272,7 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
 			ctx->qc_sched = SCHED_OTHER;
 			break;
 		default:
-			clulog(LOG_WARNING, "Invalid scheduling queue '%s'\n",
+			log_printf(LOG_WARNING, "Invalid scheduling queue '%s'\n",
 			       val);
 			break;
 		}
@@ -1350,10 +1364,10 @@ get_config_data(char *cluster_name, qd_ctx *ctx, struct h_data *h, int maxh,
 
 	*cfh = configure_heuristics(ccsfd, h, maxh);
 
-	clulog(LOG_DEBUG,
+	log_printf(LOG_DEBUG,
 	       "Quorum Daemon: %d heuristics, %d interval, %d tko, %d votes\n",
 	       *cfh, ctx->qc_interval, ctx->qc_tko, ctx->qc_votes);
-	clulog(LOG_DEBUG, "Run Flags: %08x\n", ctx->qc_flags);
+	log_printf(LOG_DEBUG, "Run Flags: %08x\n", ctx->qc_flags);
 
 	ccs_disconnect(ccsfd);
 
@@ -1367,7 +1381,7 @@ check_stop_cman(qd_ctx *ctx)
 	if (!(ctx->qc_flags & RF_STOP_CMAN))
 		return;
 	
-	clulog(LOG_WARNING, "Telling CMAN to leave the cluster; qdisk is not"
+	log_printf(LOG_WARNING, "Telling CMAN to leave the cluster; qdisk is not"
 		" available\n");
 #if (defined(LIBCMAN_VERSION) && LIBCMAN_VERSION >= 2)
 	if (cman_shutdown(ctx->qc_ch, 0) < 0) {
@@ -1375,7 +1389,7 @@ check_stop_cman(qd_ctx *ctx)
 	int x = 0;
 	if (ioctl(cman_get_fd(ctx->qc_ch), SIOCCLUSTER_LEAVE_CLUSTER, &x) < 0) {
 #endif
-		clulog(LOG_CRIT, "Could not leave the cluster - rebooting\n");
+		log_printf(LOG_CRIT, "Could not leave the cluster - rebooting\n");
 		sleep(5);
 		if (ctx->qc_flags & RF_DEBUG)
 			return;
@@ -1398,11 +1412,13 @@ main(int argc, char **argv)
 	pid_t pid;
 	quorum_header_t qh;
 
+	logsys_config_mode_set (LOG_MODE_OUTPUT_STDERR | LOG_MODE_OUTPUT_SYSLOG_THREADED | LOG_MODE_OUTPUT_FILE | LOG_MODE_DISPLAY_DEBUG | LOG_MODE_FLUSH_AFTER_CONFIG);
+
 	if (check_process_running(argv[0], &pid) && pid !=getpid()) {
-		printf("QDisk services already running\n");
+		log_printf(LOG_INFO, "QDisk services already running\n");
 		return 0;
 	}
-	
+
 	while ((rv = getopt(argc, argv, "fdQs")) != EOF) {
 		switch (rv) {
 		case 'd':
@@ -1410,7 +1426,6 @@ main(int argc, char **argv)
 			break;
 		case 'f':
 			foreground = 1;
-			clu_log_console(1);
 			break;
 		case 'Q':
 			/* Make qdisk very quiet */
@@ -1428,6 +1443,11 @@ main(int argc, char **argv)
 		}
 	}
 
+	if(debug || getenv("QDISK_DEBUGLOG")) {
+		debug = 1;
+		logsys_config_priority_set (LOG_LEVEL_DEBUG);
+	}
+
 #if (defined(LIBCMAN_VERSION) && LIBCMAN_VERSION >= 2)
 	ch = cman_admin_init(NULL);
 #else
@@ -1441,7 +1461,7 @@ main(int argc, char **argv)
 				forked = 1;
 		}
 		
-		clulog(LOG_INFO, "Waiting for CMAN to start\n");
+		log_printf(LOG_INFO, "Waiting for CMAN to start\n");
 		
 		do {
 			sleep(5);
@@ -1469,21 +1489,19 @@ main(int argc, char **argv)
 	signal(SIGINT, int_handler);
 	signal(SIGTERM, int_handler);
 
-        if (debug) {
-                clu_set_loglevel(LOG_DEBUG);
+        if (debug)
                 ctx.qc_flags |= RF_DEBUG;
-        }
-		
+
 	if (get_config_data(NULL, &ctx, h, 10, &cfh, debug) < 0) {
-		clulog_and_print(LOG_CRIT, "Configuration failed\n");
+		log_printf(LOG_CRIT, "Configuration failed\n");
 		check_stop_cman(&ctx);
 		goto out;
 	}
-	
+
 	if (ctx.qc_label) {
 		ret = find_partitions(ctx.qc_label, device, sizeof(device), 0);
 		if (ret < 0) {
-			clulog_and_print(LOG_CRIT, "Unable to match label"
+			log_printf(LOG_CRIT, "Unable to match label"
 					 " '%s' to any device\n",
 					 ctx.qc_label);
 			check_stop_cman(&ctx);
@@ -1496,11 +1514,11 @@ main(int argc, char **argv)
 
 		ctx.qc_device = strdup(device);
 
-		clulog(LOG_INFO, "Quorum Partition: %s Label: %s\n",
+		log_printf(LOG_INFO, "Quorum Partition: %s Label: %s\n",
 		       ctx.qc_device, ctx.qc_label);
 	} else if (ctx.qc_device) {
 		if (check_device(ctx.qc_device, NULL, &qh, 0) != 0) {
-			clulog(LOG_CRIT,
+			log_printf(LOG_CRIT,
 			       "Specified partition %s does not have a "
 			       "qdisk label\n", ctx.qc_device);
 			check_stop_cman(&ctx);
@@ -1509,9 +1527,9 @@ main(int argc, char **argv)
 
 		if (qh.qh_version == VERSION_MAGIC_V2 &&
                     qh.qh_blksz != rv) {
-			clulog(LOG_CRIT,
+			log_printf(LOG_CRIT,
 			       "Specified device %s does match kernel's "
-			       "reported sector size (%d != %d)\n",
+			       "reported sector size (%lu != %d)\n",
 			       ctx.qc_device,
 			       ctx.qc_disk.d_blksz, rv);
 			check_stop_cman(&ctx);
@@ -1527,7 +1545,7 @@ main(int argc, char **argv)
 	set_priority(ctx.qc_sched, ctx.qc_sched_prio);
 
 	if (quorum_init(&ctx, ni, MAX_NODES_DISK, h, cfh) < 0) {
-		clulog_and_print(LOG_CRIT, "Initialization failed\n");
+		log_printf(LOG_CRIT, "Initialization failed\n");
 		check_stop_cman(&ctx);
 		goto out;
 	}
@@ -1547,7 +1565,7 @@ main(int argc, char **argv)
 		
 	if ((rv = cman_register_quorum_device(ctx.qc_ch, ctx.qc_device,
 					      ctx.qc_votes)) < 0) {
-		clulog_and_print(LOG_CRIT,
+		log_printf(LOG_CRIT,
 				 "Could not register %s with CMAN; "
 				 "return = %d; error = %s\n",
 				 ctx.qc_device, rv, strerror(errno));
diff --git a/cman/qdisk/mkqdisk.c b/cman/qdisk/mkqdisk.c
index 19cb5e2..b4ffcbb 100644
--- a/cman/qdisk/mkqdisk.c
+++ b/cman/qdisk/mkqdisk.c
@@ -30,7 +30,11 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <openais/service/logsys.h>
 
+LOGSYS_DECLARE_SYSTEM (NULL, LOG_MODE_OUTPUT_STDERR | LOG_MODE_DISPLAY_DEBUG, NULL, SYSLOGFACILITY);
+
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 int
 main(int argc, char **argv)
@@ -41,18 +45,30 @@ main(int argc, char **argv)
 
 	printf("mkqdisk v" RELEASE_VERSION "\n\n");
 
+	/* XXX this is horrible but we need to prioritize options as long as
+	 * we can't queue messages properly
+	 */
 	while ((rv = getopt(argc, argv, "Ldf:c:l:h")) != EOF) {
 		switch (rv) {
 		case 'd':
 			++verbose_level;
+			logsys_config_priority_set (LOG_LEVEL_DEBUG);
+			break;
+		}
+	}
+
+	/* reset the option index to reparse */
+	optind = 0;
+
+	while ((rv = getopt(argc, argv, "Ldf:c:l:h")) != EOF) {
+		switch (rv) {
+		case 'd':
+			/* processed above, needs to be here for compat */
 			break;
 		case 'L':
 			/* List */
-			close(2);
 			return find_partitions(NULL, NULL, 0, verbose_level);
-			break;
 		case 'f':
-			close(2);
 			return find_partitions( optarg, device,
 					       sizeof(device), verbose_level);
 		case 'c':
diff --git a/cman/qdisk/proc.c b/cman/qdisk/proc.c
index 5623e7e..eab1cc7 100644
--- a/cman/qdisk/proc.c
+++ b/cman/qdisk/proc.c
@@ -29,6 +29,7 @@
 #include <platform.h>
 #include <stdlib.h>
 #include <string.h>
+#include <openais/service/logsys.h>
 #include "scandisk.h"
 
 struct device_args {
@@ -40,6 +41,7 @@ struct device_args {
 	int pad;
 };
 
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 int
 check_device(char *device, char *label, quorum_header_t *qh,
@@ -54,13 +56,13 @@ check_device(char *device, char *label, quorum_header_t *qh,
 
 	ret = qdisk_validate(device);
 	if (ret < 0) {
-		perror("qdisk_verify");
+		log_printf(LOG_DEBUG, "qdisk_verify");
 		return -1;
 	}
 
 	ret = qdisk_open(device, &disk);
 	if (ret < 0) {
-		perror("qdisk_open");
+		log_printf(LOG_ERR, "qdisk_open");
 		return -1;
 	}
 
@@ -150,17 +152,17 @@ print_status_block(status_block_t *sb)
 
 	if (sb->ps_state == S_NONE)
 		return;
-	printf("Status block for node %d\n", sb->ps_nodeid);
-	printf("\tLast updated by node %d\n", sb->ps_updatenode);
-	printf("\tLast updated on %s", ctime((time_t *)&timestamp));
-	printf("\tState: %s\n", state_str(sb->ps_state));
-	printf("\tFlags: %04x\n", sb->ps_flags);
-	printf("\tScore: %d/%d\n", sb->ps_score, sb->ps_scoremax);
-	printf("\tAverage Cycle speed: %d.%06d seconds\n", 
+	log_printf(LOG_INFO, "Status block for node %d\n", sb->ps_nodeid);
+	log_printf(LOG_INFO, "\tLast updated by node %d\n", sb->ps_updatenode);
+	log_printf(LOG_INFO, "\tLast updated on %s", ctime((time_t *)&timestamp));
+	log_printf(LOG_INFO, "\tState: %s\n", state_str(sb->ps_state));
+	log_printf(LOG_INFO, "\tFlags: %04x\n", sb->ps_flags);
+	log_printf(LOG_INFO, "\tScore: %d/%d\n", sb->ps_score, sb->ps_scoremax);
+	log_printf(LOG_INFO, "\tAverage Cycle speed: %d.%06d seconds\n", 
 		sb->ps_ca_sec, sb->ps_ca_usec);
-	printf("\tLast Cycle speed: %d.%06d seconds\n", 
+	log_printf(LOG_INFO, "\tLast Cycle speed: %d.%06d seconds\n", 
 		sb->ps_lc_sec, sb->ps_lc_usec);
-	printf("\tIncarnation: %08x%08x\n",
+	log_printf(LOG_INFO, "\tIncarnation: %08x%08x\n",
 		(int)(sb->ps_incarnation>>32&0xffffffff),
 		(int)(sb->ps_incarnation&0xffffffff));
 
@@ -175,7 +177,7 @@ read_info(char *dev)
 	status_block_t sb;
 
 	if (qdisk_open(dev, &ti) < 0) {
-		printf("Could not read from %s: %s\n",
+		log_printf(LOG_ERR, "Could not read from %s: %s\n",
 		       dev, strerror(errno));
 		return;
 	}
@@ -185,7 +187,7 @@ read_info(char *dev)
 		if (qdisk_read(&ti,
 			       qdisk_nodeid_offset(x+1, ti.d_blksz),
 			       &sb, sizeof(sb)) < 0) {
-			printf("Error reading node ID block %d\n",
+			log_printf(LOG_ERR, "Error reading node ID block %d\n",
 			       x+1);
 			continue;
 		}
@@ -205,14 +207,14 @@ print_qdisk_info(struct devnode *dn)
 	time_t timestamp = (time_t)qh->qh_timestamp;
 
 	for (dp = dn->devpath; dp; dp = dp->next)
-		printf("%s:\n", dp->path);
-	printf("\tMagic:                %08x\n", qh->qh_magic);
-	printf("\tLabel:                %s\n", qh->qh_cluster);
-	printf("\tCreated:              %s", ctime(&timestamp));
-	printf("\tHost:                 %s\n", qh->qh_updatehost);
-	printf("\tKernel Sector Size:   %d\n", qh->qh_kernsz);
+		log_printf(LOG_INFO, "%s:\n", dp->path);
+	log_printf(LOG_INFO, "\tMagic:                %08x\n", qh->qh_magic);
+	log_printf(LOG_INFO, "\tLabel:                %s\n", qh->qh_cluster);
+	log_printf(LOG_INFO, "\tCreated:              %s", ctime(&timestamp));
+	log_printf(LOG_INFO, "\tHost:                 %s\n", qh->qh_updatehost);
+	log_printf(LOG_INFO, "\tKernel Sector Size:   %d\n", qh->qh_kernsz);
 	if (qh->qh_version == VERSION_MAGIC_V2) {
-		printf("\tRecorded Sector Size: %d\n\n", (int)qh->qh_blksz);
+		log_printf(LOG_INFO, "\tRecorded Sector Size: %d\n\n", (int)qh->qh_blksz);
 	}
 }
 
diff --git a/cman/qdisk/score.c b/cman/qdisk/score.c
index 3f508a2..a2a69fb 100644
--- a/cman/qdisk/score.c
+++ b/cman/qdisk/score.c
@@ -31,7 +31,7 @@
 #include <pthread.h>
 #include <string.h>
 #include <ccs.h>
-#include <clulog.h>
+#include <openais/service/logsys.h>
 #include <sched.h>
 #include <sys/mman.h>
 #include "disk.h"
@@ -49,6 +49,7 @@ struct h_arg {
 	int count;
 };
 
+LOGSYS_DECLARE_SUBSYS ("QDISK", LOG_LEVEL_INFO);
 
 /*
   XXX Messy, but works for now... 
@@ -146,7 +147,7 @@ fork_heuristic(struct h_data *h)
 
 	execv("/bin/sh", argv);
 
-	printf("Execv failed\n");
+	log_printf(LOG_ERR, "Execv failed\n");
 	return 0;
 }
 
@@ -162,7 +163,7 @@ total_score(struct h_data *h, int max, int *score, int *maxscore)
 	*score = 0;
 	*maxscore = 0;
 	
-	//printf("max = %d\n", max);
+	log_printf(LOG_DEBUG, "max = %d\n", max);
 	/* Allow operation w/o any heuristics */
 	if (!max) {
 		*score = *maxscore = 1;
@@ -211,7 +212,7 @@ check_heuristic(struct h_data *h, int block)
 	/* Returned 0 and was not killed */
 	if (!h->available) {
 		h->available = 1;
-		clulog(LOG_INFO, "Heuristic: '%s' UP\n", h->program);
+		log_printf(LOG_INFO, "Heuristic: '%s' UP\n", h->program);
 	}
 	h->misses = 0;
 	return 0;
@@ -220,12 +221,12 @@ miss:
 	if (h->available) {
 		h->misses++;
 		if (h->misses >= h->tko) {
-			clulog(LOG_INFO,
+			log_printf(LOG_INFO,
 				"Heuristic: '%s' DOWN (%d/%d)\n",
 				h->program, h->misses, h->tko);
 			h->available = 0;
 		} else {
-			clulog(LOG_DEBUG,
+			log_printf(LOG_DEBUG,
 				"Heuristic: '%s' missed (%d/%d)\n",
 				h->program, h->misses, h->tko);
 		}
@@ -324,13 +325,13 @@ configure_heuristics(int ccsfd, struct h_data *h, int max)
 				h[x].tko = 1;
 		}
 
-		clulog(LOG_DEBUG,
+		log_printf(LOG_DEBUG,
 		       "Heuristic: '%s' score=%d interval=%d tko=%d\n",
 		       h[x].program, h[x].score, h[x].interval, h[x].tko);
 
 	} while (++x < max);
 
-	clulog(LOG_DEBUG, "%d heuristics loaded\n", x);
+	log_printf(LOG_DEBUG, "%d heuristics loaded\n", x);
 		
 	return x;
 }
@@ -392,7 +393,7 @@ score_thread_main(void *arg)
 
 	free(args->h);
 	free(args);
-	printf("Score thread going away\n");
+	log_printf(LOG_INFO, "Score thread going away\n");
 	return (NULL);
 }
 
@@ -475,14 +476,14 @@ main(int argc, char **argv)
 	max = 0;
 	while (max < 10) {
 		get_my_score(&score,&maxscore);
-		printf("current %d/%d\n", score, maxscore);
+		log_printf(LOG_INFO, "current %d/%d\n", score, maxscore);
 		sleep(1);
 		++max;
 	}
 	stop_score_thread();
 
 	get_my_score(&score,&maxscore);
-	printf("final! %d/%d\n", score, maxscore);
+	log_printf(LOG_INFO, "final! %d/%d\n", score, maxscore);
 
 	return 0;
 }


hooks/post-receive
--
Cluster Project



More information about the Cluster-cvs mailing list