summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-02-07 14:28:54 +1100
committerAmitay Isaacs <amitay@gmail.com>2014-02-19 12:04:47 +1100
commit9e5ef44f32fad6606bd95e619f0720a72344e441 (patch)
tree8e19226cecf173a1df94b69ff3c984ede7ad61c8
parent2532149f8f9bbe6d3c8f5ac6e5e4bc2ad1681e27 (diff)
downloadsamba-9e5ef44f32fad6606bd95e619f0720a72344e441.tar.gz
samba-9e5ef44f32fad6606bd95e619f0720a72344e441.tar.xz
samba-9e5ef44f32fad6606bd95e619f0720a72344e441.zip
ctdb-recoverd: Optimise check for rebalance candidates in LCP2
Currently this can be checked many times. However, there's no point calling the rebalance/failback code at all if there are no rebalance candidates. Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
-rw-r--r--ctdb/server/ctdb_takeover.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index d3a6e25aa3..bdf45603e4 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -1998,28 +1998,13 @@ static void lcp2_failback(struct ctdb_context *ctdb,
uint32_t *lcp2_imbalances,
bool *rebalance_candidates)
{
- int i, num_rebalance_candidates, numnodes;
+ int i, numnodes;
struct lcp2_imbalance_pnn * lips;
bool again;
numnodes = talloc_array_length(ipflags);
try_again:
-
- /* It is only worth continuing if we have suitable target
- * nodes to transfer IPs to. This check is much cheaper than
- * continuing on...
- */
- num_rebalance_candidates = 0;
- for (i=0; i<numnodes; i++) {
- if (rebalance_candidates[i]) {
- num_rebalance_candidates++;
- }
- }
- if (num_rebalance_candidates == 0) {
- return;
- }
-
/* Put the imbalances and nodes into an array, sort them and
* iterate through candidates. Usually the 1st one will be
* used, so this doesn't cost much...
@@ -2153,6 +2138,7 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
{
uint32_t *lcp2_imbalances;
bool *rebalance_candidates;
+ int numnodes, num_rebalance_candidates, i;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
@@ -2168,6 +2154,21 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
goto finished;
}
+ /* It is only worth continuing if we have suitable target
+ * nodes to transfer IPs to. This check is much cheaper than
+ * continuing on...
+ */
+ numnodes = talloc_array_length(ipflags);
+ num_rebalance_candidates = 0;
+ for (i=0; i<numnodes; i++) {
+ if (rebalance_candidates[i]) {
+ num_rebalance_candidates++;
+ }
+ }
+ if (num_rebalance_candidates == 0) {
+ goto finished;
+ }
+
/* Now, try to make sure the ip adresses are evenly distributed
across the nodes.
*/