[SCM] CTDB repository - branch master updated - ctdb-2.4-131-gc7450f9

Amitay Isaacs amitay at samba.org
Sun Oct 27 18:13:55 MDT 2013


The branch, master has been updated
       via  c7450f9e22133333bf82c88a17ac25990ebc77ab (commit)
       via  b63f6fd2d295c8e18cbf3420ab05fce07b727f31 (commit)
       via  dc67a4e24af9d07aead2a1710eeaf5d6cc409201 (commit)
       via  2c09aac71188f43cd592572b10ea30b7a2969678 (commit)
       via  1fe82f3d7b610547ff4945887f15dd6c5798a49b (commit)
       via  d73d84346488a2ed54e6a86f9d7ec641c8e33ace (commit)
       via  7b971df79b0b63f83555205eacf48d49ca3a273a (commit)
       via  afe2145d91725daf1399f0a24f1cddcf65f0ec31 (commit)
       via  b9b9f6738fba5c32e87cb9c36b358355b444fb9b (commit)
      from  6a5469a63547029f4fc704a4d4075543e06c36d1 (commit)

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


- Log -----------------------------------------------------------------
commit c7450f9e22133333bf82c88a17ac25990ebc77ab
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Oct 23 15:37:41 2013 +1100

    packaging: Create runtime directories for CTDB
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit b63f6fd2d295c8e18cbf3420ab05fce07b727f31
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Oct 23 11:28:26 2013 +1100

    initscript: Update systemd configuration to put PID file in /run/ctdb
    
    Elsewhere we're moving the socket to /var/run/ctdb.  We might end up
    with PID files and sockets for other daemons later, so let's call the
    directory "ctdb" instead of "ctdbd".
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit dc67a4e24af9d07aead2a1710eeaf5d6cc409201
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Oct 3 15:19:05 2013 +1000

    build: Move the default CTDB socket from /tmp to /var/run/ctdb
    
    Use /var/run/ctdb/ctdbd.socket because there might be other daemons
    that need sockets in the future.
    
    The local daemons test code to create a link for the default
    convenience socket has to be removed because the link can't be created
    as a regular user in the new location.  This should be OK since all
    calls to the ctdb tool in the test code should be wrapped in onnode.
    When debugging tests, a developer will have to set CTDB_SOCKET by
    hand.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-with: Martin Schwenke <martin at meltin.net>

commit 2c09aac71188f43cd592572b10ea30b7a2969678
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Oct 3 15:47:30 2013 +1000

    packaging: Move ctdb/ directory from /var to /var/lib
    
    Introduce CTDB_VARDIR variable that points to /var/lib/ctdb by default.
    This makes CTDB_VARDIR consistent across C code and scripts.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit 1fe82f3d7b610547ff4945887f15dd6c5798a49b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:36:36 2013 +1100

    ctdbd: Simplify database directory setting logic
    
    No need to check if the options are set.  The options are always set
    via static defaults.
    
    No need to talloc_strdup() the values via wrapper functions.  The
    options aren't going away.  Remove now unused ctdb_set_tdb_dir() and
    similar functions.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit d73d84346488a2ed54e6a86f9d7ec641c8e33ace
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:36:36 2013 +1100

    ctdbd: Remove duplicate database directory setting logic
    
    Defaults for ctdb->db_directory and similar variables are currently
    set in 2 places.
    
    Change this to set them in only 1 place and make the directories at
    initialisation time instead of waiting until later.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 7b971df79b0b63f83555205eacf48d49ca3a273a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:29:39 2013 +1100

    common: New function ctdb_mkdir_p_or_die()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit afe2145d91725daf1399f0a24f1cddcf65f0ec31
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Oct 21 19:08:52 2013 +1100

    common: New function mkdir_p()
    
    Behaves like mkdir -p.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit b9b9f6738fba5c32e87cb9c36b358355b444fb9b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Oct 3 15:13:41 2013 +1000

    tcp: Create socket lock in /var/run/ctdb instead of /tmp
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-with: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 Makefile.in                    |    4 ++++
 common/ctdb_util.c             |   14 ++++++++++++++
 common/system_common.c         |   28 ++++++++++++++++++++++++++++
 config/ctdb.service            |    6 +++---
 config/ctdb.sysconfig          |    4 ++--
 configure.ac                   |    4 ++--
 include/ctdb_client.h          |    7 -------
 include/ctdb_private.h         |    3 +++
 include/ctdb_protocol.h        |    2 +-
 server/ctdb_ltdb_server.c      |   34 ----------------------------------
 server/ctdb_server.c           |   36 ------------------------------------
 server/ctdbd.c                 |   35 +++++++++++------------------------
 tcp/tcp_connect.c              |    2 +-
 tests/scripts/integration.bash |    8 --------
 14 files changed, 69 insertions(+), 118 deletions(-)


Changeset truncated at 500 lines:

diff --git a/Makefile.in b/Makefile.in
index 0ae22e5..55b21b7 100755
--- a/Makefile.in
+++ b/Makefile.in
@@ -65,6 +65,7 @@ endif
 CFLAGS=@CPPFLAGS@ -g -I$(srcdir)/include -Iinclude -Ilib -Ilib/util -I$(srcdir) \
        $(TALLOC_CFLAGS) $(TEVENT_CFLAGS) $(TDB_CFLAGS) -I at libreplacedir@ \
 	-DVARDIR=\"$(localstatedir)\" -DETCDIR=\"$(etcdir)\" \
+	-DCTDB_VARDIR=\"$(localstatedir)/lib/ctdb\" \
 	-DLOGDIR=\"$(logdir)\" -DBINDIR=\"$(bindir)\" \
 	-DSOCKPATH=\"$(sockpath)\" \
 	-DUSE_MMAP=1 @CFLAGS@ $(POPT_CFLAGS) \
@@ -321,6 +322,9 @@ install: all manpages $(PMDA_INSTALL)
 	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)$(localstatedir)/lib/ctdb
+	mkdir -p $(DESTDIR)$(localstatedir)/run/ctdb
+	mkdir -p $(DESTDIR)$(logdir)
 	${INSTALLCMD} -m 644 ctdb.pc $(DESTDIR)$(libdir)/pkgconfig
 	${INSTALLCMD} -m 755 bin/ctdb $(DESTDIR)$(bindir)
 	${INSTALLCMD} -m 755 bin/ctdbd $(DESTDIR)$(sbindir)
diff --git a/common/ctdb_util.c b/common/ctdb_util.c
index d4f8541..7a70fea 100644
--- a/common/ctdb_util.c
+++ b/common/ctdb_util.c
@@ -811,3 +811,17 @@ void ctdb_set_runstate(struct ctdb_context *ctdb, enum ctdb_runstate runstate)
 			    runstate_to_string(runstate), runstate));
 	ctdb->runstate = runstate;
 }
+
+void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode)
+{
+	int ret;
+
+	ret = mkdir_p(dir, mode);
+	if (ret != 0) {
+		DEBUG(DEBUG_ALERT,
+		      ("ctdb exiting with error: "
+		       "failed to create directory \"%s\" (%s)\n",
+		       dir, strerror(ret)));
+		exit(1);
+	}
+}
diff --git a/common/system_common.c b/common/system_common.c
index 01ac2bf..7563ff3 100644
--- a/common/system_common.c
+++ b/common/system_common.c
@@ -20,6 +20,8 @@
 
 #include "includes.h"
 #include "system/network.h"
+#include "system/filesys.h"
+#include <libgen.h>
 
 /*
   uint16 checksum for n bytes
@@ -157,3 +159,29 @@ char *ctdb_sys_find_ifname(ctdb_sock_addr *addr)
 
 	return NULL;
 }
+
+int mkdir_p(const char *dir, int mode)
+{
+	char * t;
+	int ret;
+
+	if (strcmp(dir, "/") == 0) {
+		return 0;
+	}
+
+	t = talloc_strdup(NULL, dir);
+	if (t == NULL) {
+		return ENOMEM;
+	}
+	ret = mkdir_p(dirname(t), mode);
+	talloc_free(t);
+
+	if (ret == 0) {
+		ret = mkdir(dir, mode);
+		if ((ret == -1) &&  (errno == EEXIST)) {
+			ret = 0;
+		}
+	}
+
+	return ret;
+}
diff --git a/config/ctdb.service b/config/ctdb.service
index 4ad03a8..ea37c30 100644
--- a/config/ctdb.service
+++ b/config/ctdb.service
@@ -5,9 +5,9 @@ After=network.target
 [Service]
 Type=forking
 LimitCORE=infinity
-PIDFile=/run/ctdbd/ctdbd.pid
-ExecStart=/usr/sbin/ctdbd_wrapper /run/ctdbd/ctdbd.pid start
-ExecStop=/usr/sbin/ctdbd_wrapper /run/ctdbd/ctdbd.pid stop
+PIDFile=/run/ctdb/ctdbd.pid
+ExecStart=/usr/sbin/ctdbd_wrapper /run/ctdb/ctdbd.pid start
+ExecStop=/usr/sbin/ctdbd_wrapper /run/ctdb/ctdbd.pid stop
 KillMode=control-group
 Restart=no
 
diff --git a/config/ctdb.sysconfig b/config/ctdb.sysconfig
index 8233f27..35bf5f8 100644
--- a/config/ctdb.sysconfig
+++ b/config/ctdb.sysconfig
@@ -108,8 +108,8 @@ CTDB_RECOVERY_LOCK="/some/place/on/shared/storage"
 # CTDB_EVENT_SCRIPT_DIR=/etc/ctdb/events.d
 
 # the location of the local ctdb socket
-# defaults to /tmp/ctdb.socket
-# CTDB_SOCKET=/tmp/ctdb.socket
+# defaults to /var/run/ctdb/ctdbd.socket
+# CTDB_SOCKET=/var/run/ctdb/ctdbd.socket
 
 # what transport to use. Only tcp is currently supported
 # defaults to tcp
diff --git a/configure.ac b/configure.ac
index f3d2033..9621f42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -72,9 +72,9 @@ if test ! -z "$LOGDIR"; then
 fi
 AC_SUBST(LOGDIR)
 
-SOCKPATH='/tmp/ctdb.socket'
+SOCKPATH='${localstatedir}/run/ctdb/ctdbd.socket'
 AC_ARG_WITH([socketpath],
-	[  --with-socketpath=FILE       path to CTDB daemon socket [[/tmp/ctdb.socket]]],
+	[  --with-socketpath=FILE       path to CTDB daemon socket [[LOCALSTATEDIR/run/ctdb/ctdbd.socket]]],
 	SOCKPATH=$withval)
 if test ! -z "$SOCKPATH"; then
   if test "$SOCKPATH" = "yes" -o "$SOCKPATH" = "no"; then
diff --git a/include/ctdb_client.h b/include/ctdb_client.h
index c270783..53b0829 100644
--- a/include/ctdb_client.h
+++ b/include/ctdb_client.h
@@ -65,13 +65,6 @@ struct ctdb_context *ctdb_init(struct tevent_context *ev);
 int ctdb_set_transport(struct ctdb_context *ctdb, const char *transport);
 
 /*
-  set the directory for the local databases
-*/
-int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
-int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir);
-int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir);
-
-/*
   set some flags
 */
 void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index f261867..e961b93 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1588,4 +1588,7 @@ struct lock_request *ctdb_lock_alldb(struct ctdb_context *ctdb,
 				     void (*callback)(void *, bool),
 				     void *private_data);
 
+int mkdir_p(const char *dir, int mode);
+void ctdb_mkdir_p_or_die(struct ctdb_context *ctdb, const char *dir, int mode);
+
 #endif
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index 9c0d981..15c87be 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -24,7 +24,7 @@
 #ifdef SOCKPATH
 #define CTDB_PATH 	SOCKPATH
 #else
-#define CTDB_PATH 	"/tmp/ctdb.socket"
+#define CTDB_PATH 	"/var/run/ctdb/ctdbd.socket"
 #endif
 
 /* default ctdb port number */
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index db9bc01..234ecac 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -1235,40 +1235,6 @@ int ctdb_attach_databases(struct ctdb_context *ctdb)
 	char *unhealthy_reason = NULL;
 	bool first_try = true;
 
-	if (ctdb->db_directory == NULL) {
-		ctdb->db_directory = VARDIR "/ctdb";
-	}
-	if (ctdb->db_directory_persistent == NULL) {
-		ctdb->db_directory_persistent = VARDIR "/ctdb/persistent";
-	}
-	if (ctdb->db_directory_state == NULL) {
-		ctdb->db_directory_state = VARDIR "/ctdb/state";
-	}
-
-	/* make sure the db directory exists */
-	ret = mkdir(ctdb->db_directory, 0700);
-	if (ret == -1 && errno != EEXIST) {
-		DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb directory '%s'\n",
-			 ctdb->db_directory));
-		return -1;
-	}
-
-	/* make sure the persistent db directory exists */
-	ret = mkdir(ctdb->db_directory_persistent, 0700);
-	if (ret == -1 && errno != EEXIST) {
-		DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb persistent directory '%s'\n",
-			 ctdb->db_directory_persistent));
-		return -1;
-	}
-
-	/* make sure the internal state db directory exists */
-	ret = mkdir(ctdb->db_directory_state, 0700);
-	if (ret == -1 && errno != EEXIST) {
-		DEBUG(DEBUG_CRIT,(__location__ " Unable to create ctdb state directory '%s'\n",
-			 ctdb->db_directory_state));
-		return -1;
-	}
-
 	persistent_health_path = talloc_asprintf(ctdb, "%s/%s.%u",
 						 ctdb->db_directory_state,
 						 PERSISTENT_HEALTH_TDB,
diff --git a/server/ctdb_server.c b/server/ctdb_server.c
index 1c0fa4c..41cc881 100644
--- a/server/ctdb_server.c
+++ b/server/ctdb_server.c
@@ -78,42 +78,6 @@ int ctdb_set_recovery_lock_file(struct ctdb_context *ctdb, const char *file)
 }
 
 /*
-  set the directory for the local databases
-*/
-int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir)
-{
-	ctdb->db_directory = talloc_strdup(ctdb, dir);
-	if (ctdb->db_directory == NULL) {
-		return -1;
-	}
-	return 0;
-}
-
-/*
-  set the directory for the persistent databases
-*/
-int ctdb_set_tdb_dir_persistent(struct ctdb_context *ctdb, const char *dir)
-{
-	ctdb->db_directory_persistent = talloc_strdup(ctdb, dir);
-	if (ctdb->db_directory_persistent == NULL) {
-		return -1;
-	}
-	return 0;
-}
-
-/*
-  set the directory for internal state databases
-*/
-int ctdb_set_tdb_dir_state(struct ctdb_context *ctdb, const char *dir)
-{
-	ctdb->db_directory_state = talloc_strdup(ctdb, dir);
-	if (ctdb->db_directory_state == NULL) {
-		return -1;
-	}
-	return 0;
-}
-
-/*
   add a node to the list of nodes
 */
 static int ctdb_add_node(struct ctdb_context *ctdb, char *nstr)
diff --git a/server/ctdbd.c b/server/ctdbd.c
index f3cb9d3..5bf48a1 100644
--- a/server/ctdbd.c
+++ b/server/ctdbd.c
@@ -57,9 +57,9 @@ static struct {
 	.transport = "tcp",
 	.event_script_dir = NULL,
 	.logfile = LOGDIR "/log.ctdb",
-	.db_dir = VARDIR "/ctdb",
-	.db_dir_persistent = VARDIR "/ctdb/persistent",
-	.db_dir_state = VARDIR "/ctdb/state",
+	.db_dir = CTDB_VARDIR,
+	.db_dir_persistent = CTDB_VARDIR "/persistent",
+	.db_dir_state = CTDB_VARDIR "/state",
 	.script_log_level = DEBUG_ERR,
 };
 
@@ -256,27 +256,14 @@ int main(int argc, const char *argv[])
 	}
 	ctdb_load_nodes_file(ctdb);
 
-	if (options.db_dir) {
-		ret = ctdb_set_tdb_dir(ctdb, options.db_dir);
-		if (ret == -1) {
-			DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir failed - %s\n", ctdb_errstr(ctdb)));
-			exit(1);
-		}
-	}
-	if (options.db_dir_persistent) {
-		ret = ctdb_set_tdb_dir_persistent(ctdb, options.db_dir_persistent);
-		if (ret == -1) {
-			DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir_persistent failed - %s\n", ctdb_errstr(ctdb)));
-			exit(1);
-		}
-	}
-	if (options.db_dir_state) {
-		ret = ctdb_set_tdb_dir_state(ctdb, options.db_dir_state);
-		if (ret == -1) {
-			DEBUG(DEBUG_ALERT,("ctdb_set_tdb_dir_state failed - %s\n", ctdb_errstr(ctdb)));
-			exit(1);
-		}
-	}
+	ctdb->db_directory = options.db_dir;
+	ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory, 0700);
+
+	ctdb->db_directory_persistent = options.db_dir_persistent;
+	ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory_persistent, 0700);
+
+	ctdb->db_directory_state = options.db_dir_state;
+	ctdb_mkdir_p_or_die(ctdb, ctdb->db_directory_state, 0700);
 
 	if (options.public_interface) {
 		ctdb->default_public_interface = talloc_strdup(ctdb, options.public_interface);
diff --git a/tcp/tcp_connect.c b/tcp/tcp_connect.c
index 383d726..9df3300 100644
--- a/tcp/tcp_connect.c
+++ b/tcp/tcp_connect.c
@@ -284,7 +284,7 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
 						struct ctdb_tcp);
         ctdb_sock_addr sock;
 	int lock_fd, i;
-	const char *lock_path = "/tmp/.ctdb_socket_lock";
+	const char *lock_path = VARDIR "/run/ctdb/.socket_lock";
 	struct flock lock;
 	int one = 1;
 	int sock_size;
diff --git a/tests/scripts/integration.bash b/tests/scripts/integration.bash
index e5f1972..040a360 100644
--- a/tests/scripts/integration.bash
+++ b/tests/scripts/integration.bash
@@ -594,10 +594,6 @@ daemons_start_1 ()
 	ctdb_options="$ctdb_options --public-addresses=$public_addresses_mine"
     fi
 
-    if [ -n "$VALGRIND" ] ; then
-	ctdb_options="$ctdb_options --valgrinding"
-    fi
-
     # We'll use "pkill -f" to kill the daemons with
     # "--socket=.* --nlist .* --nopublicipcheck" as context.
     $VALGRIND ctdbd --socket="${TEST_VAR_DIR}/sock.$pnn" $ctdb_options "$@" ||return 1
@@ -612,10 +608,6 @@ daemons_start ()
     for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
 	daemons_start_1 $i "$@"
     done
-
-    if [ -L /tmp/ctdb.socket -o ! -S /tmp/ctdb.socket ] ; then 
-	ln -sf "${TEST_VAR_DIR}/sock.0" /tmp/ctdb.socket || return 1
-    fi
 }
 
 #######################################


-- 
CTDB repository


More information about the samba-cvs mailing list