[SCM] CTDB repository - branch master updated - ctdb-2.1-51-g5808f07

Michael Adam obnox at samba.org
Wed Apr 17 04:40:48 MDT 2013


The branch, master has been updated
       via  5808f0778b39b79ab7a5c7f53ad27947131386ec (commit)
       via  e691df43d20871468142c8fb83f7c7303c4ec307 (commit)
      from  043e18a8324ccb2c8ddd7b323ebedb5b0de1298d (commit)

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


- Log -----------------------------------------------------------------
commit 5808f0778b39b79ab7a5c7f53ad27947131386ec
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Apr 11 13:20:09 2013 +1000

    traverse: Ensure backward compatibility for CTDB_CONTROL_TRAVERSE_ALL
    
    This makes sure that CTDB_CONTROL TRAVERSE_ALL is compatible with older versions
    of CTDB (i.e. 1.2.39 and 1.2.40 branches).
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e691df43d20871468142c8fb83f7c7303c4ec307
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Apr 11 13:18:36 2013 +1000

    traverse: Add CTDB_CONTROL_TRAVERSE_ALL_EXT to support withemptyrecords
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 include/ctdb_private.h  |    1 +
 include/ctdb_protocol.h |    1 +
 server/ctdb_control.c   |    3 +
 server/ctdb_traverse.c  |  101 +++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 94 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index 7e46603..ecdf257 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1015,6 +1015,7 @@ int32_t ctdb_control_traverse_start_ext(struct ctdb_context *ctdb,
 int32_t ctdb_control_traverse_start(struct ctdb_context *ctdb, TDB_DATA indata, 
 				    TDB_DATA *outdata, uint32_t srcnode, uint32_t client_id);
 int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
+int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
 int32_t ctdb_control_traverse_data(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata);
 int32_t ctdb_control_traverse_kill(struct ctdb_context *ctdb, TDB_DATA indata, 
 				    TDB_DATA *outdata, uint32_t srcnode);
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index cc3ea3f..9302c7b 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -402,6 +402,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS          = 0,
 		    CTDB_CONTROL_GET_DB_STATISTICS	 = 132,
 		    CTDB_CONTROL_SET_DB_STICKY		 = 133,
 		    CTDB_CONTROL_RELOAD_PUBLIC_IPS	 = 134,
+		    CTDB_CONTROL_TRAVERSE_ALL_EXT	 = 135,
 };
 
 /*
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 9708acd..b567865 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -264,6 +264,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 	case CTDB_CONTROL_TRAVERSE_ALL:
 		return ctdb_control_traverse_all(ctdb, indata, outdata);
 
+	case CTDB_CONTROL_TRAVERSE_ALL_EXT:
+		return ctdb_control_traverse_all_ext(ctdb, indata, outdata);
+
 	case CTDB_CONTROL_TRAVERSE_DATA:
 		return ctdb_control_traverse_data(ctdb, indata, outdata);
 
diff --git a/server/ctdb_traverse.c b/server/ctdb_traverse.c
index df0afb0..d9aed2b 100644
--- a/server/ctdb_traverse.c
+++ b/server/ctdb_traverse.c
@@ -232,6 +232,14 @@ struct ctdb_traverse_all {
 	uint32_t pnn;
 	uint32_t client_reqid;
 	uint64_t srvid;
+};
+
+struct ctdb_traverse_all_ext {
+	uint32_t db_id;
+	uint32_t reqid;
+	uint32_t pnn;
+	uint32_t client_reqid;
+	uint64_t srvid;
 	bool withemptyrecords;
 };
 
@@ -277,6 +285,7 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
 	int ret;
 	TDB_DATA data;
 	struct ctdb_traverse_all r;
+	struct ctdb_traverse_all_ext r_ext;
 	uint32_t destination;
 
 	state = talloc(start_state, struct ctdb_traverse_all_handle);
@@ -294,15 +303,26 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
 	
 	talloc_set_destructor(state, ctdb_traverse_all_destructor);
 
-	r.db_id = ctdb_db->db_id;
-	r.reqid = state->reqid;
-	r.pnn   = ctdb->pnn;
-	r.client_reqid = start_state->reqid;
-	r.srvid = start_state->srvid;
-	r.withemptyrecords = start_state->withemptyrecords;
+	if (start_state->withemptyrecords) {
+		r_ext.db_id = ctdb_db->db_id;
+		r_ext.reqid = state->reqid;
+		r_ext.pnn   = ctdb->pnn;
+		r_ext.client_reqid = start_state->reqid;
+		r_ext.srvid = start_state->srvid;
+		r_ext.withemptyrecords = start_state->withemptyrecords;
 
-	data.dptr = (uint8_t *)&r;
-	data.dsize = sizeof(r);
+		data.dptr = (uint8_t *)&r_ext;
+		data.dsize = sizeof(r_ext);
+	} else {
+		r.db_id = ctdb_db->db_id;
+		r.reqid = state->reqid;
+		r.pnn   = ctdb->pnn;
+		r.client_reqid = start_state->reqid;
+		r.srvid = start_state->srvid;
+
+		data.dptr = (uint8_t *)&r;
+		data.dsize = sizeof(r);
+	}
 
 	if (ctdb_db->persistent == 0) {
 		/* normal database, traverse all nodes */	  
@@ -331,9 +351,16 @@ static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_
 	 * node, or if it is a persistent database, just tell the local
 	 * node
 	 */
-	ret = ctdb_daemon_send_control(ctdb, destination, 0, 
-			       CTDB_CONTROL_TRAVERSE_ALL,
-			       0, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL);
+
+	if (start_state->withemptyrecords) {
+		ret = ctdb_daemon_send_control(ctdb, destination, 0,
+				       CTDB_CONTROL_TRAVERSE_ALL_EXT,
+				       0, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL);
+	} else {
+		ret = ctdb_daemon_send_control(ctdb, destination, 0,
+				       CTDB_CONTROL_TRAVERSE_ALL,
+				       0, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL);
+	}
 
 	if (ret != 0) {
 		talloc_free(state);
@@ -381,6 +408,56 @@ static void traverse_all_callback(void *p, TDB_DATA key, TDB_DATA data)
 }
 
 /*
+ * extended version to take the "withemptyrecords" parameter"
+ */
+int32_t ctdb_control_traverse_all_ext(struct ctdb_context *ctdb, TDB_DATA data, TDB_DATA *outdata)
+{
+	struct ctdb_traverse_all_ext *c = (struct ctdb_traverse_all_ext *)data.dptr;
+	struct traverse_all_state *state;
+	struct ctdb_db_context *ctdb_db;
+
+	if (data.dsize != sizeof(struct ctdb_traverse_all_ext)) {
+		DEBUG(DEBUG_ERR,(__location__ " Invalid size in ctdb_control_traverse_all_ext\n"));
+		return -1;
+	}
+
+	ctdb_db = find_ctdb_db(ctdb, c->db_id);
+	if (ctdb_db == NULL) {
+		return -1;
+	}
+
+	if (ctdb_db->unhealthy_reason) {
+		if (ctdb->tunable.allow_unhealthy_db_read == 0) {
+			DEBUG(DEBUG_ERR,("db(%s) unhealty in ctdb_control_traverse_all: %s\n",
+					ctdb_db->db_name, ctdb_db->unhealthy_reason));
+			return -1;
+		}
+		DEBUG(DEBUG_WARNING,("warn: db(%s) unhealty in ctdb_control_traverse_all: %s\n",
+				     ctdb_db->db_name, ctdb_db->unhealthy_reason));
+	}
+
+	state = talloc(ctdb_db, struct traverse_all_state);
+	if (state == NULL) {
+		return -1;
+	}
+
+	state->reqid = c->reqid;
+	state->srcnode = c->pnn;
+	state->ctdb = ctdb;
+	state->client_reqid = c->client_reqid;
+	state->srvid = c->srvid;
+	state->withemptyrecords = c->withemptyrecords;
+
+	state->h = ctdb_traverse_local(ctdb_db, traverse_all_callback, state);
+	if (state->h == NULL) {
+		talloc_free(state);
+		return -1;
+	}
+
+	return 0;
+}
+
+/*
   called when a CTDB_CONTROL_TRAVERSE_ALL control comes in. We then
   setup a traverse of our local ltdb, sending the records as
   CTDB_CONTROL_TRAVERSE_DATA records back to the originator
@@ -421,7 +498,7 @@ int32_t ctdb_control_traverse_all(struct ctdb_context *ctdb, TDB_DATA data, TDB_
 	state->ctdb = ctdb;
 	state->client_reqid = c->client_reqid;
 	state->srvid = c->srvid;
-	state->withemptyrecords = c->withemptyrecords;
+	state->withemptyrecords = false;
 
 	state->h = ctdb_traverse_local(ctdb_db, traverse_all_callback, state);
 	if (state->h == NULL) {


-- 
CTDB repository


More information about the samba-cvs mailing list