From: Ronnie Sahlberg Date: Sun, 6 May 2007 00:22:13 +0000 (+1000) Subject: break the code that repoints dmaster for all local and remote records X-Git-Tag: tevent-0.9.20~348^2~2768^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9281cb192c43f2260d9453c877ffb4f7a9fec1e7;p=thirdparty%2Fsamba.git break the code that repoints dmaster for all local and remote records into a separate helper function (This used to be ctdb commit d5ab30d0ac21e736eb34eaa19bccfee5f0ce7cfb) --- diff --git a/ctdb/direct/recoverd.c b/ctdb/direct/recoverd.c index 158163a067d..0e4d88ba944 100644 --- a/ctdb/direct/recoverd.c +++ b/ctdb/direct/recoverd.c @@ -210,6 +210,28 @@ static int pull_all_remote_databases(struct ctdb_context *ctdb, struct ctdb_node +static int update_dmaster_on_all_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; + + /* update dmaster to point to this node for all databases/nodes */ + for (i=0;inum;i++) { + for (j=0; jnum; j++) { + /* dont repoint nodes that are unavailable */ + if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) { + continue; + } + ret = ctdb_ctrl_setdmaster(ctdb, timeval_current_ofs(1, 0), nodemap->nodes[j].vnn, ctdb, dbmap->dbids[i], vnn); + if (ret != 0) { + printf("Unable to set dmaster for node %u db:0x%08x\n", nodemap->nodes[j].vnn, dbmap->dbids[i]); + 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) @@ -295,22 +317,18 @@ static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev, - /* update dmaster to point to this node for all databases/nodes */ - for (i=0;inum;i++) { - for (j=0; jnum; j++) { - /* dont repoint nodes that are unavailable */ - if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) { - continue; - } - ret = ctdb_ctrl_setdmaster(ctdb, timeval_current_ofs(1, 0), nodemap->nodes[j].vnn, ctdb, dbmap->dbids[i], vnn); - if (ret != 0) { - printf("Unable to set dmaster for node %u db:0x%08x\n", nodemap->nodes[j].vnn, dbmap->dbids[i]); - return -1; - } - } + /* repoint all local and remote database records to the local + node as being dmaster + */ + ret = update_dmaster_on_all_databases(ctdb, nodemap, vnn, dbmap, mem_ctx); + if (ret != 0) { + printf("Unable to update dmaster on all databases\n"); + return -1; } + + /* push all records out to the nodes again */ for (i=0;inum;i++) { for (j=0; jnum; j++) {