[SCM] CTDB repository - branch master updated - ctdb-2.1-162-g0577ce3

Amitay Isaacs amitay at samba.org
Thu May 23 03:11:11 MDT 2013


The branch, master has been updated
       via  0577ce3c68e4febf49a1ef5093e918db9d5ec636 (commit)
       via  9d4524d13cbba21bfaf61bd35667984359b379b3 (commit)
       via  d18fcfff674e876abde8d51afec92d9c4a090d2f (commit)
       via  939d12b96a0cbebbe6269fa2b14f584058dd6174 (commit)
       via  14bd0b6961ef1294e9cba74ce875386b7dfbf446 (commit)
       via  a8605f7e06076e7edf84e0cc160fd3d9ab5c4b64 (commit)
       via  3105f9e291d0792199ac9e689f6d0e0a47ee4b0d (commit)
       via  d29e9a420b133088bf23a847c8d1dbce56c25eb0 (commit)
       via  1f96ea08f9a39dfe537c9b957ac512c84dc76f91 (commit)
       via  3c3df1d6afec7e3e721f9bcd4e8b8e008fd6e50b (commit)
       via  4a8d90d0812a3242f58a2a0e2aa0f528f60f7013 (commit)
       via  f1619a36c1beba11533052dc5728fa3adaa08870 (commit)
       via  e6b6b793f61556c21e8daf34abf89ee7b388ecfb (commit)
      from  0c0752515b66661ffae24be5f138bd2fab4dec5c (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0577ce3c68e4febf49a1ef5093e918db9d5ec636
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu May 23 13:04:06 2013 +1000

    tools/ctdb: Fix racy ipreallocate code
    
    This code tried to find the recovery master and send an ipreallocate
    request to that node.  When a node is stopped, this code asked the
    stopped node for recovery master.  Stopped node does not have up-to-date
    information on the current recovery master.  So ipreallocate requests
    were sent to the wrong node and ignored by that node which is not the
    recovery master.
    
    Send ipreallocate request to all active nodes.  That way we guarantee
    that the current recovery master will see it and respond to it.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-Programmed-With: Martin Schwenke <martin at meltin.net>

commit 9d4524d13cbba21bfaf61bd35667984359b379b3
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed May 22 15:37:46 2013 +1000

    ctdbd: Print version string in the daemon startup
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit d18fcfff674e876abde8d51afec92d9c4a090d2f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed May 22 14:23:17 2013 +1000

    build: Rename version.h to ctdb_version.h
    
    This avoids clash with version.h from Samba tree.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 939d12b96a0cbebbe6269fa2b14f584058dd6174
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu May 9 15:43:10 2013 +1000

    logging: Fix a bug in ringbuffer
    
    When ringbuffer is full, it does not return any entries.  Simplify
    ringbuffer logic by keeping track of number of log entries rather than
    last entry.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-Programmed-With: Martin Schwenke <martin at meltin.net>

commit 14bd0b6961ef1294e9cba74ce875386b7dfbf446
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 13 15:27:04 2013 +1000

    recoverd: takeover_run_core() should not use modified node flags
    
    Modifying the node flags with IP-allocation-only flags is not
    necessary.  It causes breakage if the flags are not cleared after use.
    ctdb_takeover_run() no longer needs the general node flags - it only
    needs the IP flags.
    
    Instead of modifying the node flags in nodemap, construct a custom IP
    flags list and have takeover_run_core() use that instead of node
    flags.  As well as being safer, this makes the IP allocation code more
    self contained and a little bit clearer.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit a8605f7e06076e7edf84e0cc160fd3d9ab5c4b64
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 20 10:47:07 2013 +1000

    ctdbd: Update confusing log message
    
    Inactive can also mean stopped.  To add information, just print the
    flags instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 3105f9e291d0792199ac9e689f6d0e0a47ee4b0d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 17 16:46:41 2013 +1000

    Packaging: maketarball.sh should be a bash script due to pushd use
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d29e9a420b133088bf23a847c8d1dbce56c25eb0
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 17 16:42:25 2013 +1000

    scripts: Rework notify.sh to use notify.d/ directory
    
    This makes it easier to add notification handlers.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 1f96ea08f9a39dfe537c9b957ac512c84dc76f91
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 14 16:20:32 2013 +1000

    ctdbd: Log a message when recovery master changes
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-Programmed-With: Amitay Isaacs <amitay at gmail.com>

commit 3c3df1d6afec7e3e721f9bcd4e8b8e008fd6e50b
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 14 15:38:08 2013 +1000

    ctdbd: Log add and delete of IPs
    
    At the moment, when someone deletes all the IPs on a node, all we see
    are the release IP messages and we have to guess why.
    
    Some would argue that add/release are more significant than
    take/release so they should be logged.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 4a8d90d0812a3242f58a2a0e2aa0f528f60f7013
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 14 15:30:53 2013 +1000

    ctdbd: Removed bogus comment in ctdb_find_iface()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit f1619a36c1beba11533052dc5728fa3adaa08870
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 14 14:56:26 2013 +1000

    eventscripts: Fix regression in _loadconfig()
    
    fff88940f71058e4eefd65f50a6701389c005c17 introduced a regression.
    Without $service_name set by default, the CTDB configuration is no
    longer loaded when loadconfig() is called without any arguments.
    That's bad.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit e6b6b793f61556c21e8daf34abf89ee7b388ecfb
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu May 9 20:44:11 2013 +1000

    initscript: If CTDB doesn't become ready, print a message before killing
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 Makefile.in                     |    4 +-
 common/ctdb_logging.c           |   62 +++++-------
 config/ctdb.init                |    1 +
 config/functions                |    9 ++-
 config/notify.d.README          |   44 ++++++++
 config/notify.sh                |   66 ++++--------
 packaging/RPM/ctdb.spec.in      |    2 +
 packaging/RPM/makerpms.sh       |    2 +-
 packaging/maketarball.sh        |    4 +-
 packaging/mkversion.sh          |    2 +-
 server/ctdb_daemon.c            |    4 +-
 server/ctdb_ltdb_server.c       |    2 +-
 server/ctdb_recover.c           |   15 +++-
 server/ctdb_takeover.c          |  215 +++++++++++++++++++++------------------
 tests/src/ctdb_takeover_tests.c |   45 +++++----
 tools/ctdb.c                    |   87 ++++------------
 16 files changed, 291 insertions(+), 273 deletions(-)
 create mode 100755 config/notify.d.README


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 86b4870..9f94aee 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -63,7 +63,7 @@ SHLD=${CC} ${CFLAGS} ${LDSHFLAGS} -o $@
 LIB_FLAGS=@LDFLAGS@ -Llib @LIBS@ $(POPT_LIBS) $(TALLOC_LIBS) $(TEVENT_LIBS) $(TDB_LIBS) \
 		  @INFINIBAND_LIBS@ @CTDB_PCAP_LDFLAGS@
 
-CTDB_VERSION_H = include/version.h
+CTDB_VERSION_H = include/ctdb_version.h
 
 UTIL_OBJ = lib/util/idtree.o lib/util/db_wrap.o lib/util/strlist.o lib/util/util.o \
 	lib/util/util_time.o lib/util/util_file.o lib/util/fault.o lib/util/substitute.o \
@@ -319,6 +319,7 @@ install: all manpages $(PMDA_INSTALL)
 	mkdir -p $(DESTDIR)$(etcdir)/ctdb/events.d
 	mkdir -p $(DESTDIR)$(etcdir)/ctdb/nfs-rpc-checks.d
 	mkdir -p $(DESTDIR)$(etcdir)/sudoers.d/
+	mkdir -p $(DESTDIR)$(etcdir)/ctdb/notify.d
 	mkdir -p $(DESTDIR)$(docdir)/ctdb
 	${INSTALLCMD} -m 644 ctdb.pc $(DESTDIR)$(libdir)/pkgconfig
 	${INSTALLCMD} -m 755 bin/ctdb $(DESTDIR)$(bindir)
@@ -376,6 +377,7 @@ install: all manpages $(PMDA_INSTALL)
 	if [ -f doc/ltdbtool.1.html ];then ${INSTALLCMD} -m 644 doc/ltdbtool.1.html $(DESTDIR)$(docdir)/ctdb; fi
 	if [ -f doc/ping_pong.1.html ];then ${INSTALLCMD} -m 644 doc/ping_pong.1.html $(DESTDIR)$(docdir)/ctdb; fi
 	if [ ! -f $(DESTDIR)$(etcdir)/ctdb/notify.sh ];then ${INSTALLCMD} -m 755 config/notify.sh $(DESTDIR)$(etcdir)/ctdb; fi
+	if [ ! -f $(DESTDIR)$(etcdir)/ctdb/notify.d/README ];then ${INSTALLCMD} -m 755 config/notify.d.README $(DESTDIR)$(etcdir)/ctdb/notify.d/README ; fi
 	${INSTALLCMD} -m 755 config/debug-hung-script.sh $(DESTDIR)$(etcdir)/ctdb
 	if [ ! -f $(DESTDIR)$(etcdir)/ctdb/ctdb-crash-cleanup.sh ];then ${INSTALLCMD} -m 755 config/ctdb-crash-cleanup.sh $(DESTDIR)$(etcdir)/ctdb; fi
 	if [ ! -f $(DESTDIR)$(etcdir)/ctdb/gcore_trace.sh ];then ${INSTALLCMD} -m 755 config/gcore_trace.sh $(DESTDIR)$(etcdir)/ctdb; fi
diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index de5ca6e..339198b 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -27,8 +27,8 @@ int log_ringbuf_size;
 
 #define MAX_LOG_SIZE 128
 
-static int first_entry;
-static int last_entry;
+static int first_entry = 0;
+static int ringbuf_count = 0;
 
 struct ctdb_log_entry {
 	int32_t level;
@@ -45,6 +45,7 @@ static struct ctdb_log_entry *log_entries;
 static void log_ringbuffer_v(const char *format, va_list ap)
 {
 	int ret;
+	int next_entry;
 
 	if (log_entries == NULL && log_ringbuf_size != 0) {
 		/* Hope this works. We cant log anything if it doesnt anyway */
@@ -54,25 +55,24 @@ static void log_ringbuffer_v(const char *format, va_list ap)
 		return;
 	}
 
-	log_entries[last_entry].message[0] = '\0';
+	next_entry = (first_entry + ringbuf_count) % log_ringbuf_size;
 
-	ret = vsnprintf(&log_entries[last_entry].message[0], MAX_LOG_SIZE, format, ap);
+	if (ringbuf_count > 0 && first_entry == next_entry) {
+		first_entry = (first_entry + 1) % log_ringbuf_size;
+	}
+
+	log_entries[next_entry].message[0] = '\0';
+
+	ret = vsnprintf(&log_entries[next_entry].message[0], MAX_LOG_SIZE, format, ap);
 	if (ret == -1) {
 		return;
 	}
 
-	log_entries[last_entry].level = this_log_level;
-	log_entries[last_entry].t = timeval_current();
+	log_entries[next_entry].level = this_log_level;
+	log_entries[next_entry].t = timeval_current();
 
-	last_entry++;
-	if (last_entry >= log_ringbuf_size) {
-		last_entry = 0;
-	}
-	if (first_entry == last_entry) {
-		first_entry++;
-	}
-	if (first_entry >= log_ringbuf_size) {
-		first_entry = 0;
+	if (ringbuf_count < log_ringbuf_size) {
+		ringbuf_count++;
 	}
 }
 
@@ -100,8 +100,11 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
 	FILE *f;
 	long fsize;
 	int tmp_entry;
-	int count = 0;
-	DEBUG(DEBUG_ERR,("Marshalling log entries  first:%d last:%d\n", first_entry, last_entry));
+	struct tm *tm;
+	char tbuf[100];
+	int i;
+
+	DEBUG(DEBUG_ERR,("Marshalling %d log entries\n", ringbuf_count));
 
 	/* dump to a file, then send the file as a blob */
 	f = tmpfile();
@@ -110,20 +113,10 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
 		return;
 	}
 
-	tmp_entry = first_entry;
-	while (tmp_entry != last_entry) {
-		struct tm *tm;
-		char tbuf[100];
-
-		if (log_entries == NULL) {
-			break;
-		}
+	for (i=0; i<ringbuf_count; i++) {
+		tmp_entry = (first_entry + i) % log_ringbuf_size;
 
 		if (log_entries[tmp_entry].level > log_addr->level) {
-			tmp_entry++;
-			if (tmp_entry >= log_ringbuf_size) {
-				tmp_entry = 0;
-			}
 		 	continue;
 		}
 
@@ -131,12 +124,9 @@ void ctdb_collect_log(struct ctdb_context *ctdb, struct ctdb_get_log_addr *log_a
 		strftime(tbuf, sizeof(tbuf)-1,"%Y/%m/%d %H:%M:%S", tm);
 
 		if (log_entries[tmp_entry].message) {
-			count += fprintf(f, "%s:%s %s", tbuf, get_debug_by_level(log_entries[tmp_entry].level), log_entries[tmp_entry].message);
-		}
-
-		tmp_entry++;
-		if (tmp_entry >= log_ringbuf_size) {
-			tmp_entry = 0;
+			fprintf(f, "%s:%s %s", tbuf,
+				get_debug_by_level(log_entries[tmp_entry].level),
+				log_entries[tmp_entry].message);
 		}
 	}
 
@@ -184,7 +174,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
 void ctdb_clear_log(struct ctdb_context *ctdb)
 {
 	first_entry = 0;
-	last_entry  = 0;
+	ringbuf_count  = 0;
 }
 
 int32_t ctdb_control_clear_log(struct ctdb_context *ctdb)
diff --git a/config/ctdb.init b/config/ctdb.init
index 013e1ae..6c4e16d 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -288,6 +288,7 @@ start() {
     if [ $RETVAL -eq 0 ] ; then
 	if ! wait_until_ready ; then
 	    RETVAL=1
+	    echo "Timed out waiting for initialisation - killing CTDB"
 	    pkill -9 -f $ctdbd >/dev/null 2>&1
 	fi
     fi
diff --git a/config/functions b/config/functions
index 4f31d84..5778420 100755
--- a/config/functions
+++ b/config/functions
@@ -23,11 +23,18 @@ _loadconfig() {
 	foo="${service_config:-${service_name}}"
 	if [ -n "$foo" ] ; then
 	    loadconfig "$foo"
+	    return
 	fi
-    elif [ "$1" != "ctdb" ] ; then
+    fi
+
+    if [ "$1" != "ctdb" ] ; then
 	loadconfig "ctdb"
     fi
 
+    if [ -z "$1" ] ; then
+	return
+    fi
+
     if [ -f $CTDB_ETCDIR/sysconfig/$1 ]; then
 	. $CTDB_ETCDIR/sysconfig/$1
     elif [ -f $CTDB_ETCDIR/default/$1 ]; then
diff --git a/config/notify.d.README b/config/notify.d.README
new file mode 100755
index 0000000..ffce7fa
--- /dev/null
+++ b/config/notify.d.README
@@ -0,0 +1,44 @@
+This directory should contain executable programs to handle CTDB event
+notifications.  The first and only argument passed to each program is
+the event, which is one of:
+
+  init, setup, startup, unhealthy, healthy
+
+To use notifications with this directory then you need to set:
+
+  CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
+
+in your CTDB configuration file.
+
+An example script that sends SNMP traps for unhealthy/healthy might
+look like this:
+
+  #!/bin/sh
+
+  case "$1" in
+      unhealthy)
+          # Send an SNMP trap saying that the node is unhealthy:
+          snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb \
+              $(hostname) 0 0 $(date +"%s") ctdb.nodeHealth.0 i 1
+          ;;
+      healthy)
+          # Send an SNMP trap saying that the node is healthy again:
+          snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb \
+	      $(hostname) 0 0 $(date +"%s") ctdb.nodeHealth.0 i 0
+	  ;;
+  esac
+
+Alternatively, email could be sent:
+
+  #!/bin/sh
+
+  case "$1" in
+      unhealthy)
+          mail -s "$(hostname) is UNHEALTHY" foo at example.com </dev/null >/dev/null 2>&1
+          ;;
+      healthy)
+          mail -s "$(hostname) is HEALTHY" foo at example.com </dev/null >/dev/null 2>&1
+          ;;
+  esac
+
+When adding programs please note the exclusion patterns in notify.sh.
diff --git a/config/notify.sh b/config/notify.sh
index 8d3eb87..dfcb81a 100755
--- a/config/notify.sh
+++ b/config/notify.sh
@@ -3,47 +3,25 @@
 # This script is activated by setting CTDB_NOTIFY_SCRIPT=/etc/ctdb/notify.sh
 # in /etc/sysconfig/ctdb
 
-# This is script is invoked from ctdb when node UNHEALTHY flag changes.
-# and can be used to send SNMPtraps, email, etc
-# when the status of a node changes
-
-
-event="$1"
-shift
-
-case $event in
-	unhealthy)
-#
-#               Send an snmptrap that the node is unhealthy :
-#		snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 1
-#
-#               or send an email :
-#               mail foo at bar -s "`hostname` is UNHEALTHY"   ...
-#
-#               or do something else ...
-		;;
-	healthy)
-#
-#               Send an snmptrap that the node is healthy again :
-#		snmptrap -m ALL -v 1 -c public 10.1.1.105 ctdb `hostname` 0 0 `date +"%s"` ctdb.nodeHealth.0 i 0
-#
-#               or send an email :
-#               mail foo at bar -s "`hostname` is HEALTHY"   ...
-#
-#               or do something else ...
-		;;
-	startup)
-	#		do some extra magic when ctdb has finished the initial
-	#		recovery?
-		;;
-
-	setup)
-	#		do some extra magic when ctdb has setup itself?
-		;;
-
-	init)
-	#		do some extra magic when ctdb has started?
-		;;
-esac
-
-exit 0
+# This is script is invoked from ctdb when certain events happen.  See
+# /etc/ctdb/notify.d/README for more details.
+
+d=$(dirname $0)
+nd="${d}/notify.d"
+
+ok=true
+
+for i in "${nd}/"* ; do
+    # Don't run files matching basename
+    case "${i##*/}" in
+	*~|*,|*.rpm*|*.swp|README) continue ;;
+    esac
+
+    # Files must be executable
+    [ -x "$i" ] || continue
+
+    # Flag failures
+    "$i" "$1" || ok=false
+done
+
+$ok
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 83261c5..910b59a 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -127,6 +127,7 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %{_sysconfdir}/ctdb/gcore_trace.sh
 %config(noreplace) %{_sysconfdir}/ctdb/functions
 %attr(755,root,root) %{initdir}/ctdb
+%attr(755,root,root) %{_sysconfdir}/ctdb/notify.d
 
 %{_docdir}/ctdb/README
 %{_docdir}/ctdb/COPYING
@@ -162,6 +163,7 @@ rm -rf $RPM_BUILD_ROOT
 %config(noreplace) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/40.mountd.check
 %config(noreplace) %{_sysconfdir}/ctdb/nfs-rpc-checks.d/50.rquotad.check
 %{_sysconfdir}/ctdb/statd-callout
+%{_sysconfdir}/ctdb/notify.d/README
 %{_sbindir}/ctdbd
 %{_bindir}/ctdb
 %{_bindir}/smnotify
diff --git a/packaging/RPM/makerpms.sh b/packaging/RPM/makerpms.sh
index c216185..d3bda52 100755
--- a/packaging/RPM/makerpms.sh
+++ b/packaging/RPM/makerpms.sh
@@ -52,7 +52,7 @@ mkdir -p `rpm --eval %_rpmdir`/noarch
 mkdir -p `rpm --eval %_rpmdir`/i386
 mkdir -p `rpm --eval %_rpmdir`/x86_64
 
-VERSION=$(${TOPDIR}/packaging/mkversion.sh ${TOPDIR}/include/version.h)
+VERSION=$(${TOPDIR}/packaging/mkversion.sh ${TOPDIR}/include/ctdb_version.h)
 if [ -z "$VERSION" ]; then
     exit 1
 fi
diff --git a/packaging/maketarball.sh b/packaging/maketarball.sh
index 221fede..be19869 100755
--- a/packaging/maketarball.sh
+++ b/packaging/maketarball.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 #
 # maketarball.sh - create a tarball from the git branch HEAD
 #
@@ -35,7 +35,7 @@ fi
 TAR_PREFIX_TMP="ctdb-tmp"
 SPECFILE=/tmp/${TAR_PREFIX_TMP}/packaging/RPM/ctdb.spec
 SPECFILE_IN=${SPECFILE}.in
-VERSION_H=/tmp/${TAR_PREFIX_TMP}/include/version.h
+VERSION_H=/tmp/${TAR_PREFIX_TMP}/include/ctdb_version.h
 
 if echo | gzip -c --rsyncable - > /dev/null 2>&1 ; then
 	GZIP="gzip -9 --rsyncable"
diff --git a/packaging/mkversion.sh b/packaging/mkversion.sh
index 18b432a..4a80b25 100755
--- a/packaging/mkversion.sh
+++ b/packaging/mkversion.sh
@@ -25,7 +25,7 @@
 OUTPUT=$1
 
 if [ -z "$OUTPUT" ]; then
-    OUTPUT="include/version.h"
+    OUTPUT="include/ctdb_version.h"
 fi
 
 # We use tags and determine the version, as follows:
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index d8edcee..d2df115 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -24,6 +24,7 @@
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/wait.h"
+#include "../include/ctdb_version.h"
 #include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
@@ -1174,7 +1175,8 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog,
 
 	ctdbd_pid = getpid();
 	ctdb->ctdbd_pid = ctdbd_pid;
-	DEBUG(DEBUG_ERR, ("Starting CTDBD as PID: %u\n", ctdbd_pid));
+	DEBUG(DEBUG_ERR, ("Starting CTDBD (Version %s) as PID: %u\n",
+			  CTDB_VERSION_STRING, ctdbd_pid));
 	ctdb_create_pidfile(ctdb->ctdbd_pid);
 
 	if (ctdb->do_setsched) {
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index 4f77934..8b06703 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -1082,7 +1082,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
 		   databases
 		*/
 		if (node->flags & NODE_FLAGS_INACTIVE) {
-			DEBUG(DEBUG_ERR,("DB Attach to database %s refused since node is inactive (disconnected or banned)\n", db_name));
+			DEBUG(DEBUG_ERR,("DB Attach to database %s refused since node is inactive (flags=0x%x)\n", db_name, node->flags));
 			return -1;
 		}
 
diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c
index 2e9408f..7fd0ac3 100644
--- a/server/ctdb_recover.c
+++ b/server/ctdb_recover.c
@@ -1350,9 +1350,22 @@ int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb)
 
 int32_t ctdb_control_set_recmaster(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata)
 {
+	uint32_t new_recmaster;
+
 	CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
+	new_recmaster = ((uint32_t *)(&indata.dptr[0]))[0];
+
+	if (ctdb->pnn != new_recmaster && ctdb->recovery_master == ctdb->pnn) {
+		DEBUG(DEBUG_NOTICE,
+		      ("This node (%u) is no longer the recovery master\n", ctdb->pnn));
+	}
+
+	if (ctdb->pnn == new_recmaster && ctdb->recovery_master != new_recmaster) {
+		DEBUG(DEBUG_NOTICE,
+		      ("This node (%u) is now the recovery master\n", ctdb->pnn));
+	}
 
-	ctdb->recovery_master = ((uint32_t *)(&indata.dptr[0]))[0];
+	ctdb->recovery_master = new_recmaster;
 	return 0;
 }
 
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 24c6298..3d78205 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -33,11 +33,11 @@
 #define CTDB_ARP_INTERVAL 1
 #define CTDB_ARP_REPEAT   3
 
-/* These flags are ONLY valid within IP allocation code and must be
- * cleared to avoid confusing other recovery daemon functions
- */
-#define NODE_FLAGS_NOIPTAKEOVER		0x01000000 /* can not takeover additional IPs */
-#define NODE_FLAGS_NOIPHOST		0x02000000 /* can not host IPs */
+/* Flags used in IP allocation algorithms. */
+struct ctdb_ipflags {
+	bool noiptakeover;
+	bool noiphost;
+};
 
 struct ctdb_iface {
 	struct ctdb_iface *prev, *next;
@@ -164,7 +164,6 @@ static struct ctdb_iface *ctdb_find_iface(struct ctdb_context *ctdb,
 {
 	struct ctdb_iface *i;
 
-	/* Verify that we dont have an entry for this ip yet */
 	for (i=ctdb->ifaces;i;i=i->next) {
 		if (strcmp(i->name, iface) == 0) {
 			return i;
@@ -1309,13 +1308,13 @@ static int node_ip_coverage(struct ctdb_context *ctdb,
  * node and is NOIPHOST unset?
 */
 static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn, 
-			     struct ctdb_node_map *nodemap,
+			     struct ctdb_ipflags ipflags,
 			     struct ctdb_public_ip_list *ip)
 {
 	struct ctdb_all_public_ips *public_ips;
 	int i;
 
-	if (nodemap->nodes[pnn].flags & NODE_FLAGS_NOIPHOST) {
+	if (ipflags.noiphost) {
 		return false;
 	}
 
@@ -1336,14 +1335,14 @@ static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn,
 }
 
 static bool can_node_takeover_ip(struct ctdb_context *ctdb, int32_t pnn, 
-				 struct ctdb_node_map *nodemap,
+				 struct ctdb_ipflags ipflags,
 				 struct ctdb_public_ip_list *ip)
 {
-	if (nodemap->nodes[pnn].flags & NODE_FLAGS_NOIPTAKEOVER) {
+	if (ipflags.noiptakeover) {
 		return false;
 	}
 
-	return can_node_host_ip(ctdb, pnn, nodemap, ip);
+	return can_node_host_ip(ctdb, pnn, ipflags, ip);


-- 
CTDB repository


More information about the samba-cvs mailing list