diff options
| author | Martin Schwenke <martin@meltin.net> | 2012-12-13 13:23:32 +1100 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2013-01-08 10:16:11 +1100 |
| commit | 2e8df435614bee970ead862e91d294d06ebc41da (patch) | |
| tree | aba2fc5e39f0ae196c70f995b47e9c0f9690e764 | |
| parent | bcefb768841ed226cbaf72b96ce80bd2d5f0a024 (diff) | |
| download | samba-2e8df435614bee970ead862e91d294d06ebc41da.tar.gz samba-2e8df435614bee970ead862e91d294d06ebc41da.tar.xz samba-2e8df435614bee970ead862e91d294d06ebc41da.zip | |
recoverd: New function unassign_unsuitable_ips()
Move the code into a new function so it can be called from a number of
places.
Signed-off-by: Martin Schwenke <martin@meltin.net>
(This used to be ctdb commit 8adb255e62dbe60d1e983047acd7b9c941231d11)
| -rw-r--r-- | ctdb/server/ctdb_takeover.c | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 6171019e20..7ef2e1fd89 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2062,6 +2062,39 @@ try_again: } } +static void unassign_unsuitable_ips(struct ctdb_context *ctdb, + struct ctdb_node_map *nodemap, + struct ctdb_public_ip_list *all_ips, + uint32_t mask) +{ + struct ctdb_public_ip_list *tmp_ip; + + /* mark all public addresses with a masked node as being served by + node -1 + */ + for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) { + if (tmp_ip->pnn == -1) { + continue; + } + if (nodemap->nodes[tmp_ip->pnn].flags & mask) { + tmp_ip->pnn = -1; + } + } + + /* verify that the assigned nodes can serve that public ip + and set it to -1 if not + */ + for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) { + if (tmp_ip->pnn == -1) { + continue; + } + if (can_node_serve_ip(ctdb, tmp_ip->pnn, tmp_ip) != 0) { + /* this node can not serve this ip. */ + tmp_ip->pnn = -1; + } + } +} + /* The calculation part of the IP allocation algorithm. */ static void ctdb_takeover_run_core(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, @@ -2131,31 +2164,7 @@ static void ctdb_takeover_run_core(struct ctdb_context *ctdb, } } - - /* mark all public addresses with a masked node as being served by - node -1 - */ - for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) { - if (tmp_ip->pnn == -1) { - continue; - } - if (nodemap->nodes[tmp_ip->pnn].flags & mask) { - tmp_ip->pnn = -1; - } - } - - /* verify that the assigned nodes can serve that public ip - and set it to -1 if not - */ - for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) { - if (tmp_ip->pnn == -1) { - continue; - } - if (can_node_serve_ip(ctdb, tmp_ip->pnn, tmp_ip) != 0) { - /* this node can not serve this ip. */ - tmp_ip->pnn = -1; - } - } + unassign_unsuitable_ips(ctdb, nodemap, all_ips, mask); if (1 == ctdb->tunable.lcp2_public_ip_assignment) { lcp2_init(tmp_ctx, nodemap, mask, all_ips, &lcp2_imbalances, &newly_healthy); |
