ctdb-common: Move ctdb_node_list_to_map() to utilities
authorMartin Schwenke <martin@meltin.net>
Fri, 20 Feb 2015 01:34:25 +0000 (12:34 +1100)
committerAmitay Isaacs <amitay@samba.org>
Tue, 7 Apr 2015 05:43:13 +0000 (07:43 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/common/ctdb_util.c
ctdb/include/ctdb_private.h
ctdb/server/ctdb_recover.c

index 76fb06d56067d9260685149b4e7e9734cd68873d..8e2e430da71857608ed3bb93f8636c47f14ed2c2 100644 (file)
@@ -579,6 +579,33 @@ struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
        return ret;
 }
 
+struct ctdb_node_map *
+ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes,
+                     TALLOC_CTX *mem_ctx)
+{
+       uint32_t i;
+       size_t size;
+       struct ctdb_node_map *node_map;
+
+       size = offsetof(struct ctdb_node_map, nodes) +
+               num_nodes * sizeof(struct ctdb_node_and_flags);
+       node_map  = (struct ctdb_node_map *)talloc_zero_size(mem_ctx, size);
+       if (node_map == NULL) {
+               DEBUG(DEBUG_ERR,
+                     (__location__ " Failed to allocate nodemap array\n"));
+               return NULL;
+       }
+
+       node_map->num = num_nodes;
+       for (i=0; i<num_nodes; i++) {
+               node_map->nodes[i].addr  = nodes[i]->address;
+               node_map->nodes[i].pnn   = nodes[i]->pnn;
+               node_map->nodes[i].flags = nodes[i]->flags;
+       }
+
+       return node_map;
+}
+
 const char *ctdb_eventscript_call_names[] = {
        "init",
        "setup",
index b37d5bbd333348ab137ff400239d681fcc051445..532f85958697b9398293bed2cbe2c2604ec5dcab 100644 (file)
@@ -1388,6 +1388,9 @@ int ctdb_client_async_control(struct ctdb_context *ctdb,
                                client_async_callback fail_callback,
                                void *callback_data);
 
+struct ctdb_node_map *
+ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes,
+                     TALLOC_CTX *mem_ctx);
 struct ctdb_node_map *ctdb_read_nodes_file(TALLOC_CTX *mem_ctx,
                                           const char *nlist);
 void ctdb_load_nodes_file(struct ctdb_context *ctdb);
index 90211be8267fd422b2dc610e341d824768127170..7a684d55320903690af1832dae6bb5c482b33ef8 100644 (file)
@@ -118,33 +118,6 @@ ctdb_control_getdbmap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indat
        return 0;
 }
 
-static struct ctdb_node_map *
-ctdb_node_list_to_map(struct ctdb_node **nodes, uint32_t num_nodes,
-                     TALLOC_CTX *mem_ctx)
-{
-       uint32_t i;
-       size_t size;
-       struct ctdb_node_map *node_map;
-
-       size = offsetof(struct ctdb_node_map, nodes) + num_nodes*sizeof(struct ctdb_node_and_flags);
-       node_map  = (struct ctdb_node_map *)talloc_zero_size(mem_ctx, size);
-       if (node_map == NULL) {
-               DEBUG(DEBUG_ERR, (__location__ " Failed to allocate nodemap array\n"));
-               return NULL;
-       }
-
-       node_map->num = num_nodes;
-       for (i=0; i<num_nodes; i++) {
-               node_map->nodes[i].addr  = nodes[i]->address;
-               node_map->nodes[i].pnn   = nodes[i]->pnn;
-               node_map->nodes[i].flags = nodes[i]->flags;
-       }
-
-       return node_map;
-}
-
-
-
 int
 ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, TDB_DATA indata, TDB_DATA *outdata)
 {