]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
create a helper function for recovery to push all local databases out
authorRonnie Sahlberg <sahlberg@ronnie>
Sun, 6 May 2007 00:38:44 +0000 (10:38 +1000)
committerRonnie Sahlberg <sahlberg@ronnie>
Sun, 6 May 2007 00:38:44 +0000 (10:38 +1000)
onto the remote nodes

(This used to be ctdb commit 1ba76d374652cfa29e56fb77c7190349e42d3bcc)

ctdb/direct/recoverd.c

index bc0f614f1a663f50cb51f1039981b5423e251fab..6b8fc2eb04295f98ad73038a274a668a2c21b364 100644 (file)
@@ -233,6 +233,33 @@ static int update_dmaster_on_all_databases(struct ctdb_context *ctdb, struct ctd
 }
 
 
+static int push_all_local_databases(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t vnn, struct ctdb_dbid_map *dbmap, TALLOC_CTX *mem_ctx)
+{
+       int i, j, ret;
+
+       /* push all records out to the nodes again */
+       for (i=0;i<dbmap->num;i++) {
+               for (j=0; j<nodemap->num; j++) {
+                       /* we dont need to push to ourselves */
+                       if (nodemap->nodes[j].vnn == vnn) {
+                               continue;
+                       }
+                       /* dont push to nodes that are unavailable */
+                       if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) {
+                               continue;
+                       }
+                       ret = ctdb_ctrl_copydb(ctdb, timeval_current_ofs(1, 0), vnn, nodemap->nodes[j].vnn, dbmap->dbids[i], CTDB_LMASTER_ANY, mem_ctx);
+                       if (ret != 0) {
+                               printf("Unable to copy db from node %u to node %u\n", vnn, nodemap->nodes[j].vnn);
+                               return -1;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+
 static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev,
        TALLOC_CTX *mem_ctx, uint32_t vnn, uint32_t num_active,
        struct ctdb_node_map *nodemap, struct ctdb_vnn_map *vnnmap)
@@ -317,7 +344,6 @@ static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev,
 
 
 
-
        /* repoint all local and remote database records to the local
           node as being dmaster
         */
@@ -329,26 +355,15 @@ static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev,
 
 
 
-
-       /* push all records out to the nodes again */
-       for (i=0;i<dbmap->num;i++) {
-               for (j=0; j<nodemap->num; j++) {
-                       /* we dont need to push to ourselves */
-                       if (nodemap->nodes[j].vnn == vnn) {
-                               continue;
-                       }
-                       /* dont push to nodes that are unavailable */
-                       if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) {
-                               continue;
-                       }
-                       ret = ctdb_ctrl_copydb(ctdb, timeval_current_ofs(1, 0), vnn, nodemap->nodes[j].vnn, dbmap->dbids[i], CTDB_LMASTER_ANY, mem_ctx);
-                       if (ret != 0) {
-                               printf("Unable to copy db from node %u to node %u\n", vnn, nodemap->nodes[j].vnn);
-                               return -1;
-                       }
-               }
+       /* push all local databases to the remote nodes */
+       ret = push_all_local_databases(ctdb, nodemap, vnn, dbmap, mem_ctx);
+       if (ret != 0) {
+               printf("Unable to push local databases\n");
+               return -1;
        }
 
+
+
        /* build a new vnn map */
        vnnmap = talloc_zero_size(mem_ctx, offsetof(struct ctdb_vnn_map, map) + 4*num_active);
        if (vnnmap == NULL) {