[SCM] CTDB repository - branch master updated - 49330f97c78ca0669615297ac3d8498651831214

Andrew Tridgell tridge at samba.org
Thu Apr 10 05:26:44 GMT 2008


The branch, master has been updated
       via  49330f97c78ca0669615297ac3d8498651831214 (commit)
       via  0ad22de1a614dc2d1926546027be5f5eea3381ed (commit)
       via  f6409b19972fa94257af9aa51def539f639bc226 (commit)
       via  2ac9e29c13e9ce5903d26bcc3b845e3b05a53edc (commit)
       via  ac6a362fc2fc4a56b4c310478a96eb12daace176 (commit)
       via  a5b7dd97e3faf0c4f289240307d0e22a67cf2353 (commit)
       via  401fb01f8cb06886e2c5c277a9a70512a9b68579 (commit)
       via  10e585413c217d9b9c32ff3d2fb3d8f24183c458 (commit)
       via  4c006c675d577d4a45f4db2929af6d50bc28dd9e (commit)
       via  794ed5852c09deaffd1817f8a443b4711ed4d06f (commit)
       via  118a16e763d8332c6ce4d8b8e194775fb874c8c8 (commit)
       via  0d9314302d0b988b6ab5d533deef40c5b343c249 (commit)
       via  d23950be7406cf288f48b660c0f57a9b8d7bdd05 (commit)
       via  890832ba37d92c7996b38735451f93592c37ff79 (commit)
       via  b76400e282cab60ac6b6039dbb33d93bb1350199 (commit)
       via  983490556bc12fe03de4c22b5fdc12d15c11d43c (commit)
      from  c1130e58296e63be3787ec59690941b2677a3378 (commit)

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


- Log -----------------------------------------------------------------
commit 49330f97c78ca0669615297ac3d8498651831214
Author: Andrew Tridgell <tridge at samba.org>
Date:   Thu Apr 10 15:25:48 2008 +1000

    - accept an optional set of tdb_flags from clients on open a database,
      thus allowing the client to pass through the TDB_NOSYNC flag
    
    - ensure that tdb_store() operations on persistent databases that don't
      have TDB_NOSYNC set happen inside a transaction wrapper, thus making
      them crash safe

commit 0ad22de1a614dc2d1926546027be5f5eea3381ed
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 10 09:56:49 2008 +1000

    fix compiler warning during a fatal error failing to lock down the socket

commit f6409b19972fa94257af9aa51def539f639bc226
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 10 07:01:22 2008 +1000

    shell scripts need extra spaces sometime

commit 2ac9e29c13e9ce5903d26bcc3b845e3b05a53edc
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 10 06:55:31 2008 +1000

    update to version .33

commit ac6a362fc2fc4a56b4c310478a96eb12daace176
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 10 06:51:53 2008 +1000

    From Chris Cowan
    secure the domain socket and set permissions properly

commit a5b7dd97e3faf0c4f289240307d0e22a67cf2353
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 10 06:50:12 2008 +1000

    add possibility to provide site local modifications to the event system
    through a /etc/ctdb/rc.local script that is sources by /etc/ctdb/functions

commit 401fb01f8cb06886e2c5c277a9a70512a9b68579
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 3 17:07:00 2008 +1100

    add a ctdb command to print the ctdb version

commit 10e585413c217d9b9c32ff3d2fb3d8f24183c458
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 3 16:35:23 2008 +1100

    we allocated one byte too little in the blob we need to send as the control to the server.

commit 4c006c675d577d4a45f4db2929af6d50bc28dd9e
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Thu Apr 3 10:58:51 2008 +1100

    From Chris Cowan
    
    Add support in AIX to track the PID of a client that connects to the unix domain socket

commit 794ed5852c09deaffd1817f8a443b4711ed4d06f
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Wed Apr 2 12:09:27 2008 +1100

    bump version to .32

commit 118a16e763d8332c6ce4d8b8e194775fb874c8c8
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Wed Apr 2 11:13:30 2008 +1100

    add a mechanism to force a node to run the eventscripts with arbitrary arguments
    
    ctdb eventscript "command argument argument ..."

commit 0d9314302d0b988b6ab5d533deef40c5b343c249
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Tue Apr 1 17:17:21 2008 +1100

    decorate the memdump output with a nice field for ctdb_client structures to show the pid of the client that attached

commit d23950be7406cf288f48b660c0f57a9b8d7bdd05
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Tue Apr 1 15:34:54 2008 +1100

    add improvements to tracking memory usage in ctdbd adn the recovery daemon
    
    and a ctdb command to pull the talloc memory map from a recovery daemon
    ctdb rddumpmemory

commit 890832ba37d92c7996b38735451f93592c37ff79
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Tue Apr 1 11:31:42 2008 +1100

    from tridge: decorate dumpmemory output so that packets that are queued show up with a little more information to make memory leak debugging easier

commit b76400e282cab60ac6b6039dbb33d93bb1350199
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Mon Mar 31 12:58:20 2008 +1100

    return 0 if iscsi is disabled

commit 983490556bc12fe03de4c22b5fdc12d15c11d43c
Author: Ronnie Sahlberg <sahlberg at samba.org>
Date:   Mon Mar 31 12:49:39 2008 +1100

    make sure the iface string is nullterminated in the addip control packet

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

Summary of changes:
 common/ctdb_io.c          |   23 ++++++++++
 common/ctdb_ltdb.c        |   20 ++++++++-
 config/events.d/70.iscsi  |    2 +-
 config/functions          |    8 ++++
 include/ctdb.h            |    6 +++
 include/ctdb_private.h    |   17 +++++++-
 packaging/RPM/ctdb.spec   |   23 +++++++++-
 server/ctdb_control.c     |    9 +++-
 server/ctdb_daemon.c      |   35 +++++++++++-----
 server/ctdb_ltdb_server.c |   13 +++++-
 server/ctdb_monitor.c     |    1 +
 server/ctdb_recoverd.c    |   44 +++++++++++++++++++
 server/ctdb_tunables.c    |    1 +
 server/eventscript.c      |   74 ++++++++++++++++++++++++++++++++
 tools/ctdb.c              |  102 +++++++++++++++++++++++++++++++++++++++++++-
 15 files changed, 355 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_io.c b/common/ctdb_io.c
index a46c6df..3377aa1 100644
--- a/common/ctdb_io.c
+++ b/common/ctdb_io.c
@@ -277,6 +277,29 @@ int ctdb_queue_send(struct ctdb_queue *queue, uint8_t *data, uint32_t length)
 
 	DLIST_ADD_END(queue->out_queue, pkt, struct ctdb_queue_pkt *);
 
+	if (queue->ctdb->tunable.verbose_memory_names != 0) {
+		struct ctdb_req_header *hdr = (struct ctdb_req_header *)pkt->data;
+		switch (hdr->operation) {
+		case CTDB_REQ_CONTROL: {
+			struct ctdb_req_control *c = (struct ctdb_req_control *)hdr;
+			talloc_set_name(pkt, "ctdb_queue_pkt: control opcode=%u srvid=%llu datalen=%u",
+					(unsigned)c->opcode, (unsigned long long)c->srvid, (unsigned)c->datalen);
+			break;
+		}
+		case CTDB_REQ_MESSAGE: {
+			struct ctdb_req_message *m = (struct ctdb_req_message *)hdr;
+			talloc_set_name(pkt, "ctdb_queue_pkt: message srvid=%llu datalen=%u",
+					(unsigned long long)m->srvid, (unsigned)m->datalen);
+			break;
+		}
+		default:
+			talloc_set_name(pkt, "ctdb_queue_pkt: operation=%u length=%u src=%u dest=%u",
+					(unsigned)hdr->operation, (unsigned)hdr->length, 
+					(unsigned)hdr->srcnode, (unsigned)hdr->destnode);
+			break;
+		}
+	}
+
 	return 0;
 }
 
diff --git a/common/ctdb_ltdb.c b/common/ctdb_ltdb.c
index e8a334a..d9e4f2a 100644
--- a/common/ctdb_ltdb.c
+++ b/common/ctdb_ltdb.c
@@ -150,7 +150,25 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
 	memcpy(rec.dptr, header, sizeof(*header));
 	memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);
 
-	ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);
+	/* if this is a persistent database without NOSYNC then we
+	   will do this via a transaction */
+	if (ctdb_db->persistent && !(ctdb_db->client_tdb_flags & TDB_NOSYNC)) {
+		ret = tdb_transaction_start(ctdb_db->ltdb->tdb);
+		if (ret != 0) {
+			DEBUG(DEBUG_CRIT, ("Failed to start local transaction\n"));
+			goto failed;
+		}
+		ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);
+		if (ret != 0) {
+			tdb_transaction_cancel(ctdb_db->ltdb->tdb);
+			goto failed;
+		}
+		ret = tdb_transaction_commit(ctdb_db->ltdb->tdb);
+	} else {
+		ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);
+	}
+
+failed:
 	talloc_free(rec.dptr);
 
 	return ret;
diff --git a/config/events.d/70.iscsi b/config/events.d/70.iscsi
index 0c05bdc..cd43553 100755
--- a/config/events.d/70.iscsi
+++ b/config/events.d/70.iscsi
@@ -13,7 +13,7 @@ shift
 
 [ -z "$CTDB_START_ISCSI_SCRIPTS" ] && {
 	echo "No iscsi start script directory found"
-	exit 1
+	exit 0
 }
 
 case $cmd in 
diff --git a/config/functions b/config/functions
index 9b33422..13bba6f 100644
--- a/config/functions
+++ b/config/functions
@@ -323,3 +323,11 @@ startstop_nfslock() {
 		;;
 	esac
 }
+
+########################################################
+# load a site local config file
+########################################################
+
+[ -x $CTDB_BASE/rc.local ] && {
+	. $CTDB_BASE/rc.local
+}
diff --git a/include/ctdb.h b/include/ctdb.h
index 821ac8a..bfba37e 100644
--- a/include/ctdb.h
+++ b/include/ctdb.h
@@ -90,6 +90,12 @@ struct ctdb_call_info {
  */
 #define CTDB_SRVID_VACUUM_FETCH 0xF700000000000000LL
 
+/*
+  a message to tell the recovery daemon to write a talloc memdump
+  to the log
+ */
+#define CTDB_SRVID_MEM_DUMP 0xF800000000000000LL
+
 
 /* used on the domain socket, send a pdu to the local daemon */
 #define CTDB_CURRENT_NODE     0xF0000001
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index fcb3120..d51e2f7 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -39,6 +39,14 @@
 
 
 /*
+  recovery daemon memdump reply address
+ */
+struct rd_memdump_reply {
+	uint32_t pnn;
+	uint64_t srvid;
+};
+
+/*
   a tcp connection description
  */
 struct ctdb_tcp_connection {
@@ -93,6 +101,7 @@ struct ctdb_tunable {
 	uint32_t disable_when_unhealthy;
 	uint32_t reclock_ping_period;
 	uint32_t no_ip_failback;
+	uint32_t verbose_memory_names;
 };
 
 /*
@@ -377,6 +386,7 @@ struct ctdb_context {
 	struct ctdb_monitor_state *monitor;
 	struct ctdb_log_state *log;
 	int start_as_disabled;
+	TALLOC_CTX *eventscripts_ctx; /* a context to hold data for the RUN_EVENTSCRIPTS control */
 };
 
 struct ctdb_db_context {
@@ -390,6 +400,7 @@ struct ctdb_db_context {
 	struct ctdb_registered_call *calls; /* list of registered calls */
 	uint32_t seqnum;
 	struct timed_event *te;
+	uint32_t client_tdb_flags;
 };
 
 
@@ -502,6 +513,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_DISABLE_MONITOR         = 76,
 		    CTDB_CONTROL_ADD_PUBLIC_IP           = 77,
 		    CTDB_CONTROL_DEL_PUBLIC_IP           = 78,
+		    CTDB_CONTROL_RUN_EVENTSCRIPTS        = 79,
 };	
 
 /*
@@ -899,7 +911,7 @@ int ctdb_daemon_send_control(struct ctdb_context *ctdb, uint32_t destnode,
 			     void *private_data);
 
 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata, 
-			       TDB_DATA *outdata, bool persistent);
+			       TDB_DATA *outdata, uint64_t tdb_flags, bool persistent);
 
 int ctdb_daemon_set_call(struct ctdb_context *ctdb, uint32_t db_id,
 			 ctdb_fn_t fn, int id);
@@ -1083,6 +1095,8 @@ void ctdb_start_tcp_tickle_update(struct ctdb_context *ctdb);
 void ctdb_send_keepalive(struct ctdb_context *ctdb, uint32_t destnode);
 void ctdb_start_keepalive(struct ctdb_context *ctdb);
 void ctdb_stop_keepalive(struct ctdb_context *ctdb);
+int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb, struct ctdb_req_control *c, TDB_DATA data, bool *async_reply);
+
 
 void ctdb_daemon_cancel_controls(struct ctdb_context *ctdb, struct ctdb_node *node);
 void ctdb_call_resend_all(struct ctdb_context *ctdb);
@@ -1275,5 +1289,6 @@ void ctdb_load_nodes_file(struct ctdb_context *ctdb);
 
 int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode);
 
+int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata);
 
 #endif
diff --git a/packaging/RPM/ctdb.spec b/packaging/RPM/ctdb.spec
index 104b852..6974739 100644
--- a/packaging/RPM/ctdb.spec
+++ b/packaging/RPM/ctdb.spec
@@ -5,7 +5,7 @@ Vendor: Samba Team
 Packager: Samba Team <samba at samba.org>
 Name: ctdb
 Version: 1.0
-Release: 31
+Release: 33
 Epoch: 0
 License: GNU GPL version 3
 Group: System Environment/Daemons
@@ -39,7 +39,7 @@ CC="gcc"
 ## always run autogen.sh
 ./autogen.sh
 
-CFLAGS="$RPM_OPT_FLAGS $EXTRA -O0 -D_GNU_SOURCE" ./configure \
+CFLAGS="$RPM_OPT_FLAGS $EXTRA -O0 -D_GNU_SOURCE -DCTDB_VERS=\"%{version}-%{release}\"" ./configure \
 	--prefix=%{_prefix} \
 	--sysconfdir=%{_sysconfdir} \
 	--mandir=%{_mandir} \
@@ -120,6 +120,25 @@ fi
 %{_includedir}/ctdb_private.h
 
 %changelog
+* Thu Apr 10 2008 : Version 1.0.33
+ - Add facilities to include site local adaptations to the eventscript
+   by /etc/ctdb/rc.local which will be read by all eventscripts.
+ - Add a "ctdb version" command.
+ - Secure the domain socket with proper permissions from Chris Cowan
+ - Bugfixes for AIX from Chris Cowan
+* Wed Apr 02 2008 : Version 1.0.32
+ - Add a control to have a node execute the eventscripts with arbitrary
+   command line arguments.
+ - Add a control "rddumpmemory" that will dump the talloc memory allocations
+   for the recovery daemon.
+ - Decorate the talloc memdump to produce better and easier memory leak
+   tracking. 
+ - Update the RHEL5 iscsi tgtd scripts to allow one iscsi target for each
+   public address.
+ - Add two new controls "addip/delip" that can be used to add/remove public
+   addresses to a node at runtime. After using these controls a "ctdb recover"
+   ir required to make the changes take.
+ - Fix a couple of slow memory leaks.
 * Tue Mar 25 2008 : Version 1.0.31
  - Add back controls to disable/enable monitoring on a node.
  - Fix a memory leak where we used to attach CALL data to the ctdb structure
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 522e11b..4de2730 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -39,7 +39,7 @@ struct ctdb_control_state {
 /*
   dump talloc memory hierarchy, returning it as a blob to the client
  */
-static int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata)
+int32_t ctdb_dump_memory(struct ctdb_context *ctdb, TDB_DATA *outdata)
 {
 	/* dump to a file, then send the file as a blob */
 	FILE *f;
@@ -206,10 +206,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 	}
 
 	case CTDB_CONTROL_DB_ATTACH:
-		return ctdb_control_db_attach(ctdb, indata, outdata, false);
+		return ctdb_control_db_attach(ctdb, indata, outdata, srvid, false);
 
 	case CTDB_CONTROL_DB_ATTACH_PERSISTENT:
-		return ctdb_control_db_attach(ctdb, indata, outdata, true);
+		return ctdb_control_db_attach(ctdb, indata, outdata, srvid, true);
 
 	case CTDB_CONTROL_SET_CALL: {
 		struct ctdb_control_set_call *sc = 
@@ -263,6 +263,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 		ctdb_enable_monitoring(ctdb);
 		return 0;
 	
+	case CTDB_CONTROL_RUN_EVENTSCRIPTS: 
+		return ctdb_run_eventscripts(ctdb, c, indata, async_reply);
+
 	case CTDB_CONTROL_DISABLE_MONITOR: 
 		CHECK_CONTROL_DATA_SIZE(0);
 		ctdb_disable_monitoring(ctdb);
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index b9f0e07..93af56c 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -27,6 +27,7 @@
 #include "system/wait.h"
 #include "../include/ctdb.h"
 #include "../include/ctdb_private.h"
+#include <sys/socket.h>
 
 static void daemon_incoming_packet(void *, struct ctdb_req_header *);
 
@@ -528,6 +529,13 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
 	int fd;
 	struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
 	struct ctdb_client *client;
+#ifdef _AIX
+	struct peercred_struct cr;
+	socklen_t crl = sizeof(struct peercred_struct);
+#else
+	struct ucred cr;
+	socklen_t crl = sizeof(struct ucred);
+#endif
 
 	memset(&addr, 0, sizeof(addr));
 	len = sizeof(addr);
@@ -540,6 +548,14 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
 	set_close_on_exec(fd);
 
 	client = talloc_zero(ctdb, struct ctdb_client);
+#ifdef _AIX
+	if (getsockopt(fd, SOL_SOCKET, SO_PEERID, &cr, &crl) == 0) {
+#else
+	if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cr, &crl) == 0) {
+#endif
+		talloc_asprintf(client, "struct ctdb_client: pid:%u", (unsigned)cr.pid);
+	}
+
 	client->ctdb = ctdb;
 	client->fd = fd;
 	client->client_id = ctdb_reqid_new(ctdb, client);
@@ -566,18 +582,7 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
 		return -1;
 	}
 
-	set_nonblocking(ctdb->daemon.sd);
 	set_close_on_exec(ctdb->daemon.sd);
-
-#if 0
-	/* AIX doesn't like this :( */
-	if (fchown(ctdb->daemon.sd, geteuid(), getegid()) != 0 ||
-	    fchmod(ctdb->daemon.sd, 0700) != 0) {
-		DEBUG(DEBUG_CRIT,("Unable to secure ctdb socket '%s', ctdb->daemon.name\n"));
-		goto failed;
-	}
-#endif
-
 	set_nonblocking(ctdb->daemon.sd);
 
 	memset(&addr, 0, sizeof(addr));
@@ -588,6 +593,14 @@ static int ux_socket_bind(struct ctdb_context *ctdb)
 		DEBUG(DEBUG_CRIT,("Unable to bind on ctdb socket '%s'\n", ctdb->daemon.name));
 		goto failed;
 	}	
+
+	if (chown(ctdb->daemon.name, geteuid(), getegid()) != 0 ||
+	    chmod(ctdb->daemon.name, 0700) != 0) {
+		DEBUG(DEBUG_CRIT,("Unable to secure ctdb socket '%s', ctdb->daemon.name\n", ctdb->daemon.name));
+		goto failed;
+	} 
+
+
 	if (listen(ctdb->daemon.sd, 10) != 0) {
 		DEBUG(DEBUG_CRIT,("Unable to listen on ctdb socket '%s'\n", ctdb->daemon.name));
 		goto failed;
diff --git a/server/ctdb_ltdb_server.c b/server/ctdb_ltdb_server.c
index e900f7b..5146ed8 100644
--- a/server/ctdb_ltdb_server.c
+++ b/server/ctdb_ltdb_server.c
@@ -296,12 +296,19 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name, boo
   a client has asked to attach a new database
  */
 int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
-			       TDB_DATA *outdata, bool persistent)
+			       TDB_DATA *outdata, uint64_t tdb_flags, 
+			       bool persistent)
 {
 	const char *db_name = (const char *)indata.dptr;
 	struct ctdb_db_context *db;
 	struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
 
+	/* the client can optionally pass additional tdb flags, but we
+	   only allow a subset of those on the database in ctdb. Note
+	   that tdb_flags is passed in via the (otherwise unused)
+	   srvid to the attach control */
+	tdb_flags &= TDB_NOSYNC;
+
 	/* If the node is inactive it is not part of the cluster
 	   and we should not allow clients to attach to any
 	   databases
@@ -317,6 +324,7 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
 	if (db) {
 		outdata->dptr  = (uint8_t *)&db->db_id;
 		outdata->dsize = sizeof(db->db_id);
+		db->client_tdb_flags |= tdb_flags;
 		return 0;
 	}
 
@@ -330,6 +338,9 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
 		return -1;
 	}
 
+	/* remember the flags the client has specified */
+	db->client_tdb_flags = tdb_flags;
+
 	outdata->dptr  = (uint8_t *)&db->db_id;
 	outdata->dsize = sizeof(db->db_id);
 
diff --git a/server/ctdb_monitor.c b/server/ctdb_monitor.c
index 523d0ec..05e6643 100644
--- a/server/ctdb_monitor.c
+++ b/server/ctdb_monitor.c
@@ -268,3 +268,4 @@ int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb)
 	}
 	return ctdb->monitor->monitoring_mode;
 }
+
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index 43dddd5..0d1ef02 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -1600,6 +1600,47 @@ static void election_send_request(struct event_context *ev, struct timed_event *
 }
 
 /*
+  handler for memory dumps
+*/
+static void mem_dump_handler(struct ctdb_context *ctdb, uint64_t srvid, 
+			     TDB_DATA data, void *private_data)
+{
+	TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+	TDB_DATA *dump;
+	int ret;
+	struct rd_memdump_reply *rd;
+
+	if (data.dsize != sizeof(struct rd_memdump_reply)) {
+		DEBUG(DEBUG_ERR, (__location__ " Wrong size of return address.\n"));
+		return;
+	}
+	rd = (struct rd_memdump_reply *)data.dptr;
+
+	dump = talloc_zero(tmp_ctx, TDB_DATA);
+	if (dump == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " Failed to allocate memory for memdump\n"));
+		talloc_free(tmp_ctx);
+		return;
+	}
+	ret = ctdb_dump_memory(ctdb, dump);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR, (__location__ " ctdb_dump_memory() failed\n"));
+		talloc_free(tmp_ctx);
+		return;
+	}
+
+DEBUG(DEBUG_ERR, ("recovery master memory dump\n"));		
+
+	ret = ctdb_send_message(ctdb, rd->pnn, rd->srvid, *dump);
+	if (ret != 0) {
+		DEBUG(DEBUG_ERR,("Failed to send rd memdump reply message\n"));
+		return;
+	}
+
+	talloc_free(tmp_ctx);
+}
+
+/*
   handler for recovery master elections
 */
 static void election_handler(struct ctdb_context *ctdb, uint64_t srvid, 
@@ -2122,6 +2163,9 @@ static void monitor_cluster(struct ctdb_context *ctdb)
 	rec->rec_file_fd = -1;
 	ctdb_recoverd_get_pnn_lock(rec);
 
+	/* register a message port for sending memory dumps */
+	ctdb_set_message_handler(ctdb, CTDB_SRVID_MEM_DUMP, mem_dump_handler, rec);
+
 	/* register a message port for recovery elections */
 	ctdb_set_message_handler(ctdb, CTDB_SRVID_RECOVERY, election_handler, rec);
 
diff --git a/server/ctdb_tunables.c b/server/ctdb_tunables.c
index 4e36970..9518b22 100644
--- a/server/ctdb_tunables.c
+++ b/server/ctdb_tunables.c
@@ -48,6 +48,7 @@ static const struct {
 	{ "DisableWhenUnhealthy", 0,  offsetof(struct ctdb_tunable, disable_when_unhealthy) },
 	{ "ReclockPingPeriod",   60,  offsetof(struct ctdb_tunable,  reclock_ping_period) },
 	{ "NoIPFailback",         0,  offsetof(struct ctdb_tunable, no_ip_failback) },
+	{ "VerboseMemoryNames",   0,  offsetof(struct ctdb_tunable, verbose_memory_names) },
 };
 
 /*
diff --git a/server/eventscript.c b/server/eventscript.c
index 705cb4b..f6afd47 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -367,3 +367,77 @@ int ctdb_event_script(struct ctdb_context *ctdb, const char *fmt, ...)
 
 	return status.status;
 }
+
+
+struct eventscript_callback_state {
+	struct ctdb_req_control *c;
+};
+
+/*
+  called when takeip event finishes
+ */
+static void run_eventscripts_callback(struct ctdb_context *ctdb, int status, 
+				 void *private_data)
+{
+	struct eventscript_callback_state *state = 
+		talloc_get_type(private_data, struct eventscript_callback_state);
+
+	ctdb_enable_monitoring(ctdb);
+
+	if (status != 0) {
+		DEBUG(DEBUG_ERR,(__location__ " Failed to forcibly run eventscripts\n"));
+		ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);


-- 
CTDB repository


More information about the samba-cvs mailing list