From: Ronnie Sahlberg Date: Sun, 6 May 2007 00:38:44 +0000 (+1000) Subject: create a helper function for recovery to push all local databases out X-Git-Tag: tevent-0.9.20~348^2~2768^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ee83202da64e509a37667eab630f82033d4511bd;p=thirdparty%2Fsamba.git create a helper function for recovery to push all local databases out onto the remote nodes (This used to be ctdb commit 1ba76d374652cfa29e56fb77c7190349e42d3bcc) --- diff --git a/ctdb/direct/recoverd.c b/ctdb/direct/recoverd.c index bc0f614f1a6..6b8fc2eb042 100644 --- a/ctdb/direct/recoverd.c +++ b/ctdb/direct/recoverd.c @@ -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;inum;i++) { + for (j=0; jnum; 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;inum;i++) { - for (j=0; jnum; 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) {