[SCM] CTDB repository - branch master updated - ctdb-2.1-29-g4f71dca

Amitay Isaacs amitay at samba.org
Tue Feb 19 21:01:25 MST 2013


The branch, master has been updated
       via  4f71dca8df19a63f198e2d6d59e605b49ec5e803 (commit)
       via  f505020a5720faa4ecc6414e0bfaa6b3c0e47291 (commit)
       via  a73bb56991b8c07ed0e9517ffcf0dc264be30487 (commit)
      from  d788bc8f7212b7dc1587ae592242dc8c876f4053 (commit)

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


- Log -----------------------------------------------------------------
commit 4f71dca8df19a63f198e2d6d59e605b49ec5e803
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 18 16:39:00 2013 +1100

    recoverd: update_capabilities() should use connected nodes
    
    ... as the comment says... not just active nodes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit f505020a5720faa4ecc6414e0bfaa6b3c0e47291
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 19 14:30:50 2013 +1100

    client: Refactor node listing functions to use list_of_nodes()
    
    This reduces repetition.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit a73bb56991b8c07ed0e9517ffcf0dc264be30487
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 19 14:29:06 2013 +1100

    client: New generic node listing function list_of_nodes()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 client/ctdb_client.c   |   86 +++++++++++++----------------------------------
 include/ctdb_client.h  |    5 +++
 server/ctdb_recoverd.c |    2 +-
 3 files changed, 30 insertions(+), 63 deletions(-)


Changeset truncated at 500 lines:

diff --git a/client/ctdb_client.c b/client/ctdb_client.c
index d7c3031..d2cf0f6 100644
--- a/client/ctdb_client.c
+++ b/client/ctdb_client.c
@@ -3451,19 +3451,23 @@ uint32_t *list_of_vnnmap_nodes(struct ctdb_context *ctdb,
 	return nodes;
 }
 
-uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
-				struct ctdb_node_map *node_map,
-				TALLOC_CTX *mem_ctx,
-				bool include_self)
+/* Get list of nodes not including those with flags specified by mask.
+ * If exclude_pnn is not -1 then exclude that pnn from the list.
+ */
+uint32_t *list_of_nodes(struct ctdb_context *ctdb,
+			struct ctdb_node_map *node_map,
+			TALLOC_CTX *mem_ctx,
+			uint32_t mask,
+			int exclude_pnn)
 {
 	int i, j, num_nodes;
 	uint32_t *nodes;
 
 	for (i=num_nodes=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_INACTIVE) {
+		if (node_map->nodes[i].flags & mask) {
 			continue;
 		}
-		if (node_map->nodes[i].pnn == ctdb->pnn && !include_self) {
+		if (node_map->nodes[i].pnn == exclude_pnn) {
 			continue;
 		}
 		num_nodes++;
@@ -3473,10 +3477,10 @@ uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
 	CTDB_NO_MEMORY_FATAL(ctdb, nodes);
 
 	for (i=j=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_INACTIVE) {
+		if (node_map->nodes[i].flags & mask) {
 			continue;
 		}
-		if (node_map->nodes[i].pnn == ctdb->pnn && !include_self) {
+		if (node_map->nodes[i].pnn == exclude_pnn) {
 			continue;
 		}
 		nodes[j++] = node_map->nodes[i].pnn;
@@ -3485,38 +3489,21 @@ uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
 	return nodes;
 }
 
+uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
+				struct ctdb_node_map *node_map,
+				TALLOC_CTX *mem_ctx,
+				bool include_self)
+{
+	return list_of_nodes(ctdb, node_map, mem_ctx, NODE_FLAGS_INACTIVE,
+			     include_self ? -1 : ctdb->pnn);
+}
+
 uint32_t *list_of_active_nodes_except_pnn(struct ctdb_context *ctdb,
 				struct ctdb_node_map *node_map,
 				TALLOC_CTX *mem_ctx,
 				uint32_t pnn)
 {
-	int i, j, num_nodes;
-	uint32_t *nodes;
-
-	for (i=num_nodes=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_INACTIVE) {
-			continue;
-		}
-		if (node_map->nodes[i].pnn == pnn) {
-			continue;
-		}
-		num_nodes++;
-	} 
-
-	nodes = talloc_array(mem_ctx, uint32_t, num_nodes);
-	CTDB_NO_MEMORY_FATAL(ctdb, nodes);
-
-	for (i=j=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_INACTIVE) {
-			continue;
-		}
-		if (node_map->nodes[i].pnn == pnn) {
-			continue;
-		}
-		nodes[j++] = node_map->nodes[i].pnn;
-	} 
-
-	return nodes;
+	return list_of_nodes(ctdb, node_map, mem_ctx, NODE_FLAGS_INACTIVE, pnn);
 }
 
 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
@@ -3524,33 +3511,8 @@ uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
 				TALLOC_CTX *mem_ctx,
 				bool include_self)
 {
-	int i, j, num_nodes;
-	uint32_t *nodes;
-
-	for (i=num_nodes=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
-			continue;
-		}
-		if (node_map->nodes[i].pnn == ctdb->pnn && !include_self) {
-			continue;
-		}
-		num_nodes++;
-	} 
-
-	nodes = talloc_array(mem_ctx, uint32_t, num_nodes);
-	CTDB_NO_MEMORY_FATAL(ctdb, nodes);
-
-	for (i=j=0;i<node_map->num;i++) {
-		if (node_map->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
-			continue;
-		}
-		if (node_map->nodes[i].pnn == ctdb->pnn && !include_self) {
-			continue;
-		}
-		nodes[j++] = node_map->nodes[i].pnn;
-	} 
-
-	return nodes;
+	return list_of_nodes(ctdb, node_map, mem_ctx, NODE_FLAGS_DISCONNECTED,
+			     include_self ? -1 : ctdb->pnn);
 }
 
 /* 
diff --git a/include/ctdb_client.h b/include/ctdb_client.h
index 9f0589f..1b90ffb 100644
--- a/include/ctdb_client.h
+++ b/include/ctdb_client.h
@@ -507,6 +507,11 @@ int ctdb_ctrl_setreclock(struct ctdb_context *ctdb,
 	const char *reclock);
 
 
+uint32_t *list_of_nodes(struct ctdb_context *ctdb,
+			struct ctdb_node_map *node_map,
+			TALLOC_CTX *mem_ctx,
+			uint32_t mask,
+			int exclude_pnn);
 uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
 				struct ctdb_node_map *node_map,
 				TALLOC_CTX *mem_ctx,
diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c
index 95172a1..1f2a772 100644
--- a/server/ctdb_recoverd.c
+++ b/server/ctdb_recoverd.c
@@ -254,7 +254,7 @@ static int update_capabilities(struct ctdb_context *ctdb, struct ctdb_node_map *
 	tmp_ctx = talloc_new(ctdb);
 	CTDB_NO_MEMORY(ctdb, tmp_ctx);
 
-	nodes = list_of_active_nodes(ctdb, nodemap, tmp_ctx, true);
+	nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
 	if (ctdb_client_async_control(ctdb, CTDB_CONTROL_GET_CAPABILITIES,
 					nodes, 0,
 					CONTROL_TIMEOUT(),


-- 
CTDB repository


More information about the samba-cvs mailing list