[SCM] CTDB repository - branch master updated - ctdb-2.2-110-g9ffcd6a

Amitay Isaacs amitay at samba.org
Wed Jul 10 20:49:55 MDT 2013


The branch, master has been updated
       via  9ffcd6a91287d86bae7b0c73aa129c81126e08e7 (commit)
       via  14141b02b61d2783b750ee5b30f9520253e88f09 (commit)
       via  e43a4b7b69a21c4cec2453dcac436b64bf5d7f06 (commit)
       via  30a0040fbb7c4d97d107f0e55c600295c2603a68 (commit)
       via  b6bbfb4c464c39e322830cbbebcc51c225508584 (commit)
       via  e3abc7eebab5cceddc4ce7817890dd5db9be3450 (commit)
       via  c6fded59fa4da67f738a90fdacb51900e41801f9 (commit)
       via  846109169ee5e3d03135156e45c8dac93aa2e95b (commit)
       via  2493f57ce268d6fe7e4c40a87852c347fd60d29e (commit)
       via  fc3689c977f48d7988eed0654fb8e5ce4b8bfc8b (commit)
       via  dc834d5e78c3fb97ae15cddf1139b3c4a4051a7c (commit)
       via  1a74192aa7d51ed99553e7292860027f06b6ef37 (commit)
       via  faabce1b99fb3de9ff03bf54d303e7656538fee3 (commit)
       via  8225b3e77e140db34b52571a95d553d1e59e3f1e (commit)
       via  2211cd94bea266547d3e6f167d3160a6b23bec88 (commit)
       via  a415a1986900135f889efc25ecaf2761b1dae81a (commit)
       via  c711ff4702c5f95b75e4bf030665fc2afffc2f9e (commit)
       via  2bfb8499366d530f16515b08928056bbda40f781 (commit)
       via  6fc36a7036933237d09151a0baf4d8ccd2bc2c99 (commit)
       via  dcc42a75b4638b3aa40c44ed9e0aaae26483e2b0 (commit)
       via  594c421f90ce132c75fbd985872114e4967f92b5 (commit)
       via  26a4653df594d351ca0dc1bd5f5b2f5b0eb0a9a5 (commit)
       via  545a46437dfb2b755bb2fddb11dea8c4ccce3ed7 (commit)
      from  41182623891d74a7e9e9c453183411a161201e67 (commit)

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


- Log -----------------------------------------------------------------
commit 9ffcd6a91287d86bae7b0c73aa129c81126e08e7
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 11 11:34:46 2013 +1000

    Tests: Correct the arguments to memset
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 14141b02b61d2783b750ee5b30f9520253e88f09
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 10 14:44:56 2013 +1000

    doc: Update NEWS
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-with: Martin Schwenke <martin at meltin.net>

commit e43a4b7b69a21c4cec2453dcac436b64bf5d7f06
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 10 17:19:55 2013 +1000

    packaging: Add systemd support
    
    Based on an original patch by Sumit Bose <sbose at redhat.com>.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 30a0040fbb7c4d97d107f0e55c600295c2603a68
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 10 16:35:53 2013 +1000

    build: Turn off all deprecation warnings
    
    The "‘tevent_loop_allow_nesting’ is deprecated" warnings will be
    around for a while and are annoying.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit b6bbfb4c464c39e322830cbbebcc51c225508584
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jul 10 16:30:29 2013 +1000

    build: Remove -DTEVENT_DEPRECATED_QUIET=1 from CFLAGS
    
    This reverts the last part of 788cdbddbc902a5b076d23473450065b551d274d
    - the rest of this has been implicitly reverted via tevent syncs.
    This is just leftover noise.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit e3abc7eebab5cceddc4ce7817890dd5db9be3450
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 9 15:22:07 2013 +1000

    initscript: Simpify initscript and control CTDB via new ctdbd_wrapper
    
    Currently the initscript is very complex.  This makes it hard to read
    and hard to add support for new init systems, such as systemd.
    
    Create a wrapper called ctdbd_wrapper to be installed alongside ctdbd.
    This is called by the initscript to start and stop ctdbd.  It does the
    ctdbd option construct and waits until ctdbd is properly initialised
    before it exits.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit c6fded59fa4da67f738a90fdacb51900e41801f9
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jul 8 12:45:31 2013 +1000

    recoverd: Recovery daemon should use ctdb_get_pnn, which can't fail
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 846109169ee5e3d03135156e45c8dac93aa2e95b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 10 12:23:30 2013 +1000

    ctdbd: Print tdb flags when logging attached to database message
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 2493f57ce268d6fe7e4c40a87852c347fd60d29e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 9 12:32:53 2013 +1000

    ctdbd: Set process names for child processes
    
    This helps distinguish processes in process list in top, perf, etc.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit fc3689c977f48d7988eed0654fb8e5ce4b8bfc8b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jul 9 12:24:59 2013 +1000

    common/system: Add ctdb_set_process_name() function
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit dc834d5e78c3fb97ae15cddf1139b3c4a4051a7c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jun 6 16:29:04 2013 +1000

    traverse: Remove unused start_time field
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 1a74192aa7d51ed99553e7292860027f06b6ef37
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jun 6 16:26:25 2013 +1000

    traverse: Send records directly from traverse child to srcnode
    
    Currently CTDB daemon reads records from a child process and then sends them to
    srcnode via TRAVERSE_DATA control.  This ties up main CTDB daemon and also
    requires an extra copy of the record in the CTDB daemon.  Instead send records
    directly from traverse child process.
    
    The control from child process still goes via local CTDB daemon as there
    is no infrastructure currently to open a TCP socket to the srcnode.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit faabce1b99fb3de9ff03bf54d303e7656538fee3
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jun 6 16:12:07 2013 +1000

    traverse: Pass reqid and srcnode information to local database traverse
    
    So that traverse child process can directly send the TRAVERSE_DATA control to
    the srcnode without first sending it to local node.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 8225b3e77e140db34b52571a95d553d1e59e3f1e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jul 8 16:14:59 2013 +1000

    packaging: When building with system libraries, add dependency for them
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 2211cd94bea266547d3e6f167d3160a6b23bec88
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jul 8 15:49:58 2013 +1000

    ctdbd: No need for DeadlockTimeout tunable
    
    The code for deadlock detection and killing smbd process causing deadlock
    has been removed and replaced with external debug script.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit a415a1986900135f889efc25ecaf2761b1dae81a
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jul 8 15:57:22 2013 +1000

    initscript: Export CTDB_DEBUG_LOCKS variable
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit c711ff4702c5f95b75e4bf030665fc2afffc2f9e
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jul 8 15:56:30 2013 +1000

    scripts: Add an example debug_locks.sh script to debug locking issue
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 2bfb8499366d530f16515b08928056bbda40f781
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Jul 8 15:46:53 2013 +1000

    locking: Use external script to debug locking issues
    
    Use an external script to parse /proc/locks and log useful debugging
    information about locks rather than doing that in C code.
    
    To use this feature, add configuration variable to /etc/sysconfig/ctdb:
    
      CTDB_DEBUG_LOCKS=/etc/ctdb/debug_locks.sh
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 6fc36a7036933237d09151a0baf4d8ccd2bc2c99
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 3 11:01:21 2013 +1000

    locking: Update locking bucket intervals
    
     0   < 1 ms
     1   < 10 ms
     2   < 100 ms
     3   < 1 s
     4   < 2 s
     5   < 4 s
     6   < 8 s
     7   < 16 s
     8   < 32 s
     9   < 64 s
    10   >= 64 s
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit dcc42a75b4638b3aa40c44ed9e0aaae26483e2b0
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Jul 3 11:46:53 2013 +1000

    locking: Update locks latency in CTDB statistics only for RECORD or DB locks
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 594c421f90ce132c75fbd985872114e4967f92b5
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 25 15:36:13 2013 +1000

    tools/ctdb: Fix the format of DB statistics output
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 26a4653df594d351ca0dc1bd5f5b2f5b0eb0a9a5
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Tue Jun 25 15:25:16 2013 +1000

    ctdbd: Remove incomplete ctdb_db_statistics_wire structure
    
    Send the ctdb_db_statistics directly instead of first copying it to
    duplicate ctdb_db_statistics_wire structure.  This simplifies the
    implementation of the control to get database statistics.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 545a46437dfb2b755bb2fddb11dea8c4ccce3ed7
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Jul 4 09:04:49 2013 +1000

    ctdbd: Update debug messages for setting readonly property on database
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 Makefile.in                               |    5 +-
 NEWS                                      |   35 ++++
 common/ctdb_logging.c                     |    1 +
 common/system_aix.c                       |    6 +
 common/system_freebsd.c                   |    6 +
 common/system_gnu.c                       |    6 +
 common/system_kfreebsd.c                  |    6 +
 common/system_linux.c                     |   11 +
 config/ctdb.init                          |  288 ++++++----------------------
 config/ctdb.service                       |   15 ++
 config/ctdbd_wrapper                      |  267 ++++++++++++++++++++++++++
 config/debug_locks.sh                     |   45 +++++
 doc/ctdbd.1.xml                           |   16 --
 include/ctdb_private.h                    |    6 +-
 include/ctdb_protocol.h                   |    7 -
 libctdb/control.c                         |   33 +---
 packaging/RPM/ctdb.spec.in                |   25 +++-
 server/ctdb_call.c                        |    1 +
 server/ctdb_control.c                     |   15 ++-
 server/ctdb_lock.c                        |  203 ++++----------------
 server/ctdb_logging.c                     |    1 +
 server/ctdb_ltdb_server.c                 |   62 +------
 server/ctdb_monitor.c                     |    1 +
 server/ctdb_recover.c                     |    1 +
 server/ctdb_recoverd.c                    |    9 +-
 server/ctdb_takeover.c                    |    1 +
 server/ctdb_traverse.c                    |   90 +++++----
 server/ctdb_tunables.c                    |    1 -
 server/ctdb_update_record.c               |    1 +
 server/ctdb_vacuum.c                      |    2 +-
 server/eventscript.c                      |    2 +
 tests/src/ctdb_update_record_persistent.c |    2 +-
 tools/ctdb.c                              |   23 ++-
 33 files changed, 628 insertions(+), 565 deletions(-)
 create mode 100644 config/ctdb.service
 create mode 100755 config/ctdbd_wrapper
 create mode 100644 config/debug_locks.sh


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 6030241..678141f 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -59,7 +59,7 @@ WRAPPER=
 endif
 
 ifeq ($(CC),gcc)
-EXTRA_CFLAGS=-Wno-format-zero-length -fPIC
+EXTRA_CFLAGS=-Wno-format-zero-length -Wno-deprecated-declarations -fPIC
 endif
 
 CFLAGS=@CPPFLAGS@ -g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir) \
@@ -67,7 +67,7 @@ CFLAGS=@CPPFLAGS@ -g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir)
 	-DVARDIR=\"$(localstatedir)\" -DETCDIR=\"$(etcdir)\" \
 	-DLOGDIR=\"$(logdir)\" -DBINDIR=\"$(bindir)\" \
 	-DSOCKPATH=\"$(sockpath)\" \
-	-DUSE_MMAP=1 -DTEVENT_DEPRECATED_QUIET=1 @CFLAGS@ $(POPT_CFLAGS) \
+	-DUSE_MMAP=1 @CFLAGS@ $(POPT_CFLAGS) \
 	$(EXTRA_CFLAGS)
 
 LDSHFLAGS=-fPIC -shared
@@ -357,6 +357,7 @@ install: all manpages $(PMDA_INSTALL)
 	${INSTALLCMD} -m 440 config/ctdb.sudoers $(DESTDIR)$(etcdir)/sudoers.d/ctdb
 	${INSTALLCMD} -m 644 config/functions $(DESTDIR)$(etcdir)/ctdb
 	${INSTALLCMD} -m 755 config/statd-callout $(DESTDIR)$(etcdir)/ctdb
+	${INSTALLCMD} -m 755 config/ctdbd_wrapper $(DESTDIR)$(sbindir)
 	${INSTALLCMD} -m 755 config/events.d/00.ctdb $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/01.reclock $(DESTDIR)$(etcdir)/ctdb/events.d
 	${INSTALLCMD} -m 755 config/events.d/10.interface $(DESTDIR)$(etcdir)/ctdb/events.d
diff --git a/NEWS b/NEWS
index b589e4e..bde89d6 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,21 @@ User-visible changes
 
   See ctdb.sysconfig for details.
 
+* Removed DeadlockTimeout tunable.  To enable debug of locking issues set
+
+   CTDB_DEBUG_LOCKS=/etc/ctdb/debug_locks.sh
+
+* In overall statistics and database statistics, lock buckets have been
+  updated to use following timings:
+
+   < 1ms, < 10ms, < 100ms, < 1s, < 2s, < 4s, < 8s, < 16s, < 32s, < 64s, >= 64s
+
+* Initscript is now simplified with most CTDB-specific functionality
+  split out to ctdbd_wrapper, which is used to start and stop ctdbd.
+
+* CTDB subprocesses are now given informative names to allow them to
+  be easily distinguished when using programs like "top" or "perf".
+
 Important bug fixes
 -------------------
 
@@ -24,12 +39,32 @@ Important bug fixes
 * The recovery daemon will not ban other nodes if the current node
   is banned.
 
+* ctdb dbstatistics command now correctly outputs database statistics.
+
+* Fixed a panic with overlapping shutdowns (regression in 2.2).
+
+* Fixed 60.ganesha "monitor" event (regression in 2.2).
+
+* Fixed a buffer overflow in the "reloadips" implementation.
+
+* Fixed segmentation faults in ping_pong (called with incorrect
+  argument) and test binaries (called when ctdbd not running).
+
 Important internal changes
 --------------------------
 
 * The recovery daemon on stopped or banned node will stop participating in any
   cluster activity.
 
+* Improve cluster wide database traverse by sending the records directly from
+  traverse child process to requesting node.
+
+* TDB checking and dropping of all IPs moved from initscript to "init"
+  event in 00.ctdb.
+
+* To avoid "rogue IPs" the release IP callback now fails if the
+  released IP is still present on an interface.
+
 
 Changes in CTDB 2.2
 ===================
diff --git a/common/ctdb_logging.c b/common/ctdb_logging.c
index 9b69b38..990a6b5 100644
--- a/common/ctdb_logging.c
+++ b/common/ctdb_logging.c
@@ -166,6 +166,7 @@ int32_t ctdb_control_get_log(struct ctdb_context *ctdb, TDB_DATA addr)
 	}
 
 	if (child == 0) {
+		ctdb_set_process_name("ctdb_log_collector");
 		if (switch_from_server_to_client(ctdb, "log-collector") != 0) {
 			DEBUG(DEBUG_CRIT, (__location__ "ERROR: failed to switch log collector child into client mode.\n"));
 			_exit(1);
diff --git a/common/system_aix.c b/common/system_aix.c
index 35363d3..41f61ae 100644
--- a/common/system_aix.c
+++ b/common/system_aix.c
@@ -380,6 +380,12 @@ char *ctdb_get_process_name(pid_t pid)
 	return NULL;
 }
 
+int ctdb_set_process_name(const char *name)
+{
+	/* FIXME AIX: set_process_name not implemented */
+	return -ENOSYS;
+}
+
 bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
 {
 	/* FIXME AIX: get_lock_info not implemented */
diff --git a/common/system_freebsd.c b/common/system_freebsd.c
index 641e77a..9597a7a 100644
--- a/common/system_freebsd.c
+++ b/common/system_freebsd.c
@@ -390,6 +390,12 @@ char *ctdb_get_process_name(pid_t pid)
 	return NULL;
 }
 
+int ctdb_set_process_name(const char *name)
+{
+	/* FIXME FreeBSD: set_process_name not implemented */
+	return -ENOSYS;
+}
+
 bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
 {
 	/* FIXME FreeBSD: get_lock_info not implemented */
diff --git a/common/system_gnu.c b/common/system_gnu.c
index 0d79ab5..2ab1399 100644
--- a/common/system_gnu.c
+++ b/common/system_gnu.c
@@ -369,6 +369,12 @@ char *ctdb_get_process_name(pid_t pid)
 	return NULL;
 }
 
+int ctdb_set_process_name(const char *name)
+{
+	/* FIXME GNU/Hurd: set_process_name not implemented */
+	return -ENOSYS;
+}
+
 bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
 {
 	/* FIXME GNU/Hurd: get_lock_info not implemented */
diff --git a/common/system_kfreebsd.c b/common/system_kfreebsd.c
index 2c05c9e..41aa4d6 100644
--- a/common/system_kfreebsd.c
+++ b/common/system_kfreebsd.c
@@ -382,6 +382,12 @@ char *ctdb_get_process_name(pid_t pid)
 	return strdup(ptr);
 }
 
+int ctdb_set_process_name(const char *name)
+{
+	/* FIXME kFreeBSD: set_process_name not implemented */
+	return -ENOSYS;
+}
+
 bool ctdb_get_lock_info(pid_t req_pid, struct ctdb_lock_info *lock_info)
 {
 	/* FIXME kFreeBSD: get_lock_info not implemented */
diff --git a/common/system_linux.c b/common/system_linux.c
index 9d4d4ec..9bda6d5 100644
--- a/common/system_linux.c
+++ b/common/system_linux.c
@@ -28,6 +28,7 @@
 #include <netinet/icmp6.h>
 #include <net/if_arp.h>
 #include <netpacket/packet.h>
+#include <sys/prctl.h>
 
 #ifndef ETHERTYPE_IP6
 #define ETHERTYPE_IP6 0x86dd
@@ -596,6 +597,16 @@ char *ctdb_get_process_name(pid_t pid)
 	return strdup(ptr);
 }
 
+/*
+ * Set process name
+ */
+int ctdb_set_process_name(const char *name)
+{
+	char procname[16];
+
+	strncpy(procname, name, 15);
+	return prctl(PR_SET_NAME, (unsigned long)procname, 0, 0, 0);
+}
 
 /*
  * Parsing a line from /proc/locks,
diff --git a/config/ctdb.init b/config/ctdb.init
index b5ecd69..e761fec 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -1,294 +1,133 @@
 #!/bin/sh
+
+# Start and stop CTDB (Clustered TDB daemon)
 #
-##############################
-# ctdb:                        Starts the clustered tdb daemon
-#
-# chkconfig:           - 90 01
-#
-# description:                 Starts and stops the clustered tdb daemon
-# pidfile:             /var/run/ctdb/ctdbd.pid
+# chkconfig: - 90 01
 #
+# description: Starts and stops CTDB
+# pidfile: /var/run/ctdb/ctdbd.pid
+# config: /etc/sysconfig/ctdb
 
 ### BEGIN INIT INFO
 # Provides:            ctdb
-# Required-Start:      $network
-# Required-Stop:       $network
-# Default-Stop:
-# Default-Start:       3 5
+# Required-Start:      $local_fs $syslog $network
+# Required-Stop:       $local_fs $syslog $network
+# Default-Start:       2 3 4 5
+# Default-Stop:        0 1 6
 # Short-Description:   start and stop ctdb service
-# Description:         initscript for the ctdb service
+# Description:         Start and stop CTDB (Clustered TDB daemon)
 ### END INIT INFO
 
 # Source function library.
 if [ -f /etc/init.d/functions ] ; then
+    # Red Hat
     . /etc/init.d/functions
 elif [ -f /etc/rc.d/init.d/functions ] ; then
+    # Red Hat
     . /etc/rc.d/init.d/functions
-fi
-
-[ -f /etc/rc.status ] && {
+elif [ -f /etc/rc.status ] ; then
+    # SUSE
     . /etc/rc.status
     rc_reset
     LC_ALL=en_US.UTF-8
-}
-
-if [ -f /lib/lsb/init-functions ] ; then
+elif [ -f /lib/lsb/init-functions ] ; then
+    # Debian
     . /lib/lsb/init-functions
 fi
 
 # Avoid using root's TMPDIR
 unset TMPDIR
 
-[ -z "$CTDB_BASE" ] && {
-    export CTDB_BASE="/etc/ctdb"
-}
+[ -n "$CTDB_BASE" ] || export CTDB_BASE="/etc/ctdb"
 
-. $CTDB_BASE/functions
-loadconfig network
-loadconfig ctdb
+. "${CTDB_BASE}/functions"
+loadconfig "network"
+loadconfig "ctdb"
 
 # check networking is up (for redhat)
-[ "$NETWORKING" = "no" ] && exit 0
+if [ "$NETWORKING" = "no" ] ; then
+    exit 0
+fi
 
 detect_init_style
 export CTDB_INIT_STYLE
 
-ctdbd=${CTDBD:-/usr/sbin/ctdbd}
-pidfile="/var/run/ctdb/ctdbd.pid"
+ctdbd="${CTDBD:-/usr/sbin/ctdbd}"
+ctdbd_wrapper="${CTDBD_WRAPPER:-/usr/sbin/ctdbd_wrapper}"
+pidfile="${CTDB_PIDFILE:-/var/run/ctdb/ctdbd.pid}"
 
-if [ "$CTDB_VALGRIND" = "yes" ]; then
-    init_style="valgrind"
-else
-    init_style="$CTDB_INIT_STYLE"
-fi
-
-build_ctdb_options () {
-
-    maybe_set () {
-	# If the 2nd arg is null then return - don't set anything.
-	# Else if the 3rd arg is set and it doesn't match the 2nd arg
-	# then return
-	[ -z "$2" -o \( -n "$3" -a "$3" != "$2" \) ] && return
-
-	val="'$2'"
-	case "$1" in
-	    --*) sep="=" ;;
-	    -*)  sep=" " ;;
-	esac
-	# For these options we're only passing a value-less flag.
-	[ -n "$3" ] && {
-	    val=""
-	    sep=""
-	}
-
-	CTDB_OPTIONS="${CTDB_OPTIONS}${CTDB_OPTIONS:+ }${1}${sep}${val}"
-    }
-
-    [ -z "$CTDB_RECOVERY_LOCK" ] && {
-        echo "No recovery lock specified. Starting CTDB without split brain prevention"
-    }
-    maybe_set "--reclock"                "$CTDB_RECOVERY_LOCK"
-
-    mkdir -p $(dirname "$pidfile")
-    maybe_set "--pidfile"                "$pidfile"
-
-    # build up CTDB_OPTIONS variable from optional parameters
-    maybe_set "--logfile"                "$CTDB_LOGFILE"
-    maybe_set "--nlist"                  "$CTDB_NODES"
-    maybe_set "--socket"                 "$CTDB_SOCKET"
-    maybe_set "--public-addresses"       "$CTDB_PUBLIC_ADDRESSES"
-    maybe_set "--public-interface"       "$CTDB_PUBLIC_INTERFACE"
-    maybe_set "--dbdir"                  "$CTDB_DBDIR"
-    maybe_set "--dbdir-persistent"       "$CTDB_DBDIR_PERSISTENT"
-    maybe_set "--event-script-dir"       "$CTDB_EVENT_SCRIPT_DIR"
-    maybe_set "--transport"              "$CTDB_TRANSPORT"
-    maybe_set "-d"                       "$CTDB_DEBUGLEVEL"
-    maybe_set "--notification-script"    "$CTDB_NOTIFY_SCRIPT"
-    maybe_set "--start-as-disabled"      "$CTDB_START_AS_DISABLED"    "yes"
-    maybe_set "--start-as-stopped "      "$CTDB_START_AS_STOPPED"     "yes"
-    maybe_set "--no-recmaster"           "$CTDB_CAPABILITY_RECMASTER" "no"
-    maybe_set "--no-lmaster"             "$CTDB_CAPABILITY_LMASTER"   "no"
-    maybe_set "--lvs --single-public-ip" "$CTDB_LVS_PUBLIC_IP"
-    maybe_set "--script-log-level"       "$CTDB_SCRIPT_LOG_LEVEL"
-    maybe_set "--log-ringbuf-size"       "$CTDB_LOG_RINGBUF_SIZE"
-    maybe_set "--syslog"                 "$CTDB_SYSLOG"               "yes"
-    maybe_set "--max-persistent-check-errors" "$CTDB_MAX_PERSISTENT_CHECK_ERRORS"
-}
+############################################################
 
-export_debug_variables ()
+start()
 {
-    export CTDB_DEBUG_HUNG_SCRIPT CTDB_EXTERNAL_TRACE
-}
-
-set_retval() {
-    return $1
-}
-
-wait_until_ready () {
-    _timeout="${1:-10}" # default is 10 seconds
-
-    _count=0
-    while ! ctdb runstate first_recovery startup running >/dev/null 2>&1 ; do
-	if [ $_count -ge $_timeout ] ; then
-	    return 1
-	fi
-	sleep 1
-	_count=$(($_count + 1))
-    done
-}
-
-start() {
-    echo -n $"Starting ctdbd service: "
-
-    ctdb ping >/dev/null 2>&1 && {
-	echo $"CTDB is already running"
-	return 0
-    }
+    echo -n "Starting ctdbd service: "
 
-    # About to start new $ctdbd.  The ping above has failed and any
-    # new $ctdbd will destroy the Unix domain socket, so any processes
-    # that aren't yet completely useless soon will be...  so kill
-    # them.
-    pkill -9 -f "$ctdbd"
-
-    build_ctdb_options
-
-    export_debug_variables
-
-    if [ "$CTDB_SUPPRESS_COREFILE" = "yes" ]; then
-	ulimit -c 0
-    else
-	ulimit -c unlimited
-    fi
-
-    case $init_style in
-	valgrind)
-	    eval valgrind -q --log-file=/var/log/ctdb_valgrind \
-		$ctdbd --valgrinding "$CTDB_OPTIONS"
-	    RETVAL=$?
-	    echo
-	    ;;
+    case "$CTDB_INIT_STYLE" in
 	suse)
-	    eval startproc $ctdbd "$CTDB_OPTIONS"
-	    RETVAL=$?
+	    startproc \
+		"$ctdbd_wrapper" "$pidfile" "start"
+	    rc_status -v
 	    ;;
 	redhat)
-	    eval $ctdbd "$CTDB_OPTIONS"
+	    daemon --pidfile "$pidfile" \
+		"$ctdbd_wrapper" "$pidfile" "start"
 	    RETVAL=$?
+	    echo
 	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ctdb || RETVAL=1
+	    return $RETVAL
 	    ;;
 	debian)
-	    eval start-stop-daemon --start --quiet --background \
-		--exec $ctdbd -- "$CTDB_OPTIONS"
-	    RETVAL=$?
+	    eval start-stop-daemon --start --quiet --background --exec \
+		"$ctdbd_wrapper" "$pidfile" "start"
 	    ;;
     esac
-
-    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
-
-    case $init_style in
-	suse)
-	    set_retval $RETVAL
-	    rc_status -v
-	    ;;
-	redhat)
-	    [ $RETVAL -eq 0 ] && success || failure
-	    echo
-	    ;;
-    esac
-
-    return $RETVAL
 }
 
-stop() {
-    echo -n $"Shutting down ctdbd service: "
-    pkill -0 -f $ctdbd || {
-	echo -n "  Warning: ctdbd not running ! "
-	case $init_style in
-	    suse)
-		rc_status -v
-		;;
-	    redhat)
-		echo ""
-		;;
-	esac
-	return 0
-    }
-    ctdb shutdown >/dev/null 2>&1
-    RETVAL=$?
-    count=0
-    while pkill -0 -f $ctdbd ; do
-	sleep 1
-	count=$(($count + 1))
-	[ $count -gt 30 ] && {
-	    echo -n $"killing ctdbd "
-	    pkill -9 -f $ctdbd
-	    pkill -9 -f $CTDB_BASE/events.d/
-	}
-    done
-    # make sure all ips are dropped, pfkill -9 might leave them hanging around
-    drop_all_public_ips >/dev/null 2>&1
-
-    rm -f "$pidfile"
+stop()
+{
+    echo -n "Shutting down ctdbd service: "
 
-    case $init_style in
+    case "$CTDB_INIT_STYLE" in
 	suse)
-	    # re-set the return code to the recorded RETVAL in order
-	    # to print the correct status message
-	    set_retval $RETVAL
+	    "$ctdbd_wrapper" "$pidfile" "stop"
 	    rc_status -v
 	    ;;
 	redhat)
+	    "$ctdbd_wrapper" "$pidfile" "stop"
+	    RETVAL=$?
             [ $RETVAL -eq 0 ] && success || failure
-	    [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ctdb
 	    echo ""


-- 
CTDB repository


More information about the samba-cvs mailing list