1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

change the way we pick/find a new node to takeover for a failed node

to keep a static that controls at which noide to start searching the 
list for takeover candidates next time we need to find a node.

each time we find a node to takeover, reset the start variable to point 
to the next node in the list

this makes the distribution of takeover nodes much more even

(This used to be ctdb commit e9800df5a21079ea478d16f7dd2fd4707de85650)
This commit is contained in:
Ronnie Sahlberg 2007-07-16 08:28:44 +10:00
parent 7e532f8f83
commit 49f98e79fd

View File

@ -452,20 +452,39 @@ static bool ctdb_same_subnet(const char *ip1, const char *ip2, uint8_t netmask_b
criterion given by the flags
*/
static void ctdb_takeover_find_node(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
int start_node, uint32_t mask_flags)
int node, uint32_t mask_flags)
{
static int start_node=0;
int j;
for (j=(start_node+1)%nodemap->num;
j != start_node;
j=(j+1)%nodemap->num) {
j=start_node;
while (1) {
if (!(nodemap->nodes[j].flags & mask_flags) &&
ctdb_same_subnet(ctdb->nodes[j]->public_address,
ctdb->nodes[start_node]->public_address,
ctdb->nodes[node]->public_address,
ctdb->nodes[j]->public_netmask_bits)) {
ctdb->nodes[start_node]->takeover_vnn = nodemap->nodes[j].vnn;
ctdb->nodes[node]->takeover_vnn = nodemap->nodes[j].vnn;
/* We found a node to take over
also update the startnode so that we start at a
different node next time we are called.
*/
start_node = (j+1)%nodemap->num;;
return;
}
/* Try the next node */
j=(j+1)%nodemap->num;
/* We tried all the nodes and got back to where we started,
there is no node that can take over
*/
if (j == start_node) {
break;
}
}
/* No takeover node found */
return;
}