[SCM] CTDB repository - branch master updated - ctdb-2.1-145-gd0a3822

Amitay Isaacs amitay at samba.org
Wed May 8 05:20:52 MDT 2013


The branch, master has been updated
       via  d0a3822573db296e73cc897835f783c8abc084b3 (commit)
       via  65e0ea6c2c0629e19349ba4b9affa221fde2b070 (commit)
       via  107e656bbe24f9d21fbaf886a3e9417da4effe5a (commit)
       via  7cf63722873a6a7baafd77aa3d8a1989b221dee9 (commit)
       via  1308a51f73f2e29ba4dbebb6111d9309a89732cc (commit)
       via  12aef10e9889760d98f58c8d916f19d069fa381a (commit)
       via  a1addd89fd9c0390912604097acd028cc24d3483 (commit)
       via  1fb5352d2b6918fcc6f630db49275d25a3eebe8d (commit)
       via  9721aae001b3023e9c8b4af2b143c0db3442d623 (commit)
       via  91405282ba4abad4ad8e8c5f7ee4c83c75f38280 (commit)
      from  0eb351ff4c7ee096de7c5e0a59561067091fa32e (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit d0a3822573db296e73cc897835f783c8abc084b3
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 20:46:15 2013 +1000

    recoverd: Remove unused mask argument and initial mask calculation
    
    This has been replaced by set_ipflags() and associated functionality.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 65e0ea6c2c0629e19349ba4b9affa221fde2b070
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 20:41:32 2013 +1000

    recoverd: When calculating rebalance candidates don't consider flags
    
    This is really a check to see if a node is already hosting IPs.  If
    so, we assume it was previously healthy so it isn't considered as a
    rebalance candidate.  There's no need to limit this to healthy node,
    since this is checked elsewhere.
    
    Due to this the variable newly_healthy is renamed everywhere to
    rebalance_candidates.
    
    The mask argument is now completely unused.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 107e656bbe24f9d21fbaf886a3e9417da4effe5a
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 20:13:40 2013 +1000

    recoverd: Remove unused mask argument from IP allocation functions
    
    This is a no-op and is in a separate commit to make the previous
    commit less cumbersome.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 7cf63722873a6a7baafd77aa3d8a1989b221dee9
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 15:57:21 2013 +1000

    tests/takeover: Add takeover tests, mostly for NoIPHostOnAllDisabled
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 1308a51f73f2e29ba4dbebb6111d9309a89732cc
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 16:59:20 2013 +1000

    recoverd: Fix tunable NoIPTakeoverOnDisabled, rename to NoIPHostOnAllDisabled
    
    This really needs to be per-node.  The rename is because nodes with
    this tunable switched on should drop IPs if they become unhealthy (or
    disabled in some other way).
    
    * Add new flag NODE_FLAGS_NOIPHOST, only used in recovery daemon.
    
    * Enhance set_ipflags_internal() and set_ipflags() to setup
      NODE_FLAGS_NOIPHOST depending on setting of NoIPHostOnAllDisabled
      and/or whether nodes are disabled/inactive.
    
    * Replace can_node_servce_ip() with functions can_node_host_ip() and
      can_node_takeover_ip().  These functions are the only ones that need
      to look at NODE_FLAGS_NOIPTAKEOVER and NODE_FLAGS_NOIPHOST.  They
      can make the decision without looking at any other flags due to
      previous setup.
    
    * Remove explicit flag checking in IP allocation functions (including
      unassign_unsuitable_ips()) and just call can_node_host_ip() and
      can_node_takeover_ip() as appropriate.
    
    * Update test code to handle CTDB_SET_NoIPHostOnAllDisabled.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 12aef10e9889760d98f58c8d916f19d069fa381a
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 16:56:24 2013 +1000

    recoverd: Factor out new function all_nodes_are_disabled()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit a1addd89fd9c0390912604097acd028cc24d3483
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 15:55:01 2013 +1000

    tests/takeover: Allow per-node tunable settings
    
    Implemented for CTDB_SET_NoIPTakeover.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 1fb5352d2b6918fcc6f630db49275d25a3eebe8d
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 16:21:16 2013 +1000

    recoverd: Refactor code to get NoIPTakeover tunable from all nodes
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 9721aae001b3023e9c8b4af2b143c0db3442d623
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 15:53:13 2013 +1000

    tests: Unit test diff output should use filtered output
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 91405282ba4abad4ad8e8c5f7ee4c83c75f38280
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri May 3 15:41:26 2013 +1000

    recoverd: Add debug message when dropping IPs in IP allocation
    
    Update tests accordingly.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 doc/ctdbd.1.xml                             |    9 +-
 include/ctdb_private.h                      |    2 +-
 include/ctdb_protocol.h                     |    4 +-
 server/ctdb_takeover.c                      |  390 ++++++++++++++++-----------
 server/ctdb_tunables.c                      |    2 +-
 tests/scripts/unit.sh                       |    2 +-
 tests/src/ctdb_takeover_tests.c             |   78 ++++--
 tests/takeover/det.001.sh                   |    6 +
 tests/takeover/det.002.sh                   |    3 +
 tests/takeover/lcp2.012.sh                  |    4 +-
 tests/takeover/lcp2.013.sh                  |    4 +-
 tests/takeover/lcp2.017.sh                  |    4 +-
 tests/takeover/lcp2.018.sh                  |    4 +-
 tests/takeover/lcp2.019.sh                  |    4 +-
 tests/takeover/{lcp2.016.sh => lcp2.020.sh} |   16 +-
 tests/takeover/{lcp2.016.sh => lcp2.021.sh} |   16 +-
 tests/takeover/{lcp2.016.sh => lcp2.022.sh} |   14 +-
 tests/takeover/lcp2.023.sh                  |   77 ++++++
 tests/takeover/nondet.001.sh                |    6 +
 tests/takeover/nondet.002.sh                |    3 +
 tests/takeover/scripts/local.sh             |    5 +-
 21 files changed, 433 insertions(+), 220 deletions(-)
 copy tests/takeover/{lcp2.016.sh => lcp2.020.sh} (59%)
 copy tests/takeover/{lcp2.016.sh => lcp2.021.sh} (58%)
 copy tests/takeover/{lcp2.016.sh => lcp2.022.sh} (56%)
 create mode 100755 tests/takeover/lcp2.023.sh


Changeset truncated at 500 lines:

diff --git a/doc/ctdbd.1.xml b/doc/ctdbd.1.xml
index 18fddc2..9516164 100644
--- a/doc/ctdbd.1.xml
+++ b/doc/ctdbd.1.xml
@@ -862,15 +862,16 @@
     </para>
     </refsect2>
 
-    <refsect2><title>NoIPTakeoverOnDisabled</title>
+    <refsect2><title>NoIPHostOnAllDisabled</title>
     <para>Default: 0</para>
     <para>
     If no nodes are healthy then by default ctdb will happily host
     public IPs on disabled (unhealthy or administratively disabled)
     nodes.  This can cause problems, for example if the underlying
-    cluster filesystem is not mounted.  When set to 1 this behaviour
-    is switched off and disabled nodes will not be able to takeover
-    IPs.
+    cluster filesystem is not mounted.  When set to 1 on a node and
+    that node is disabled it, any IPs hosted by this node will be
+    released and the node will not takeover any IPs until it is no
+    longer disabled.
     </para>
     </refsect2>
 
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index e6cfa7f..813a5a6 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -135,7 +135,7 @@ struct ctdb_tunable {
 	uint32_t db_record_size_warn;
 	uint32_t db_size_warn;
 	uint32_t pulldb_preallocation_size;
-	uint32_t no_ip_takeover_on_disabled;
+	uint32_t no_ip_host_on_all_disabled;
 	uint32_t deadlock_timeout;
 	uint32_t samba3_hack;
 };
diff --git a/include/ctdb_protocol.h b/include/ctdb_protocol.h
index f3234ed..3133b4e 100644
--- a/include/ctdb_protocol.h
+++ b/include/ctdb_protocol.h
@@ -584,7 +584,9 @@ struct ctdb_node_map {
 #define NODE_FLAGS_DISABLED		(NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED)
 #define NODE_FLAGS_INACTIVE		(NODE_FLAGS_DELETED|NODE_FLAGS_DISCONNECTED|NODE_FLAGS_BANNED|NODE_FLAGS_STOPPED)
 
-#define NODE_FLAGS_NOIPTAKEOVER		0x01000000 /* this node can takeover any new ip addresses, this flag is ONLY valid within the recovery daemon */
+/* These flags are ONLY valid within the recovery daemon */
+#define NODE_FLAGS_NOIPTAKEOVER		0x01000000 /* can not takeover additional IPs */
+#define NODE_FLAGS_NOIPHOST		0x02000000 /* can not host IPs */
 
 
 /*
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 44393a7..3ba7dc3 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -1299,38 +1299,53 @@ static int node_ip_coverage(struct ctdb_context *ctdb,
 }
 
 
-/* Check if this is a public ip known to the node, i.e. can that
-   node takeover this ip ?
+/* Can the given node host the given IP: is the public IP known to the
+ * node and is NOIPHOST unset?
 */
-static int can_node_serve_ip(struct ctdb_context *ctdb, int32_t pnn, 
-		struct ctdb_public_ip_list *ip)
+static bool can_node_host_ip(struct ctdb_context *ctdb, int32_t pnn, 
+			     struct ctdb_node_map *nodemap,
+			     struct ctdb_public_ip_list *ip)
 {
 	struct ctdb_all_public_ips *public_ips;
 	int i;
 
+	if (nodemap->nodes[pnn].flags & NODE_FLAGS_NOIPHOST) {
+		return false;
+	}
+
 	public_ips = ctdb->nodes[pnn]->available_public_ips;
 
 	if (public_ips == NULL) {
-		return -1;
+		return false;
 	}
 
 	for (i=0;i<public_ips->num;i++) {
 		if (ctdb_same_ip(&ip->addr, &public_ips->ips[i].addr)) {
 			/* yes, this node can serve this public ip */
-			return 0;
+			return true;
 		}
 	}
 
-	return -1;
+	return false;
 }
 
+static bool can_node_takeover_ip(struct ctdb_context *ctdb, int32_t pnn, 
+				 struct ctdb_node_map *nodemap,
+				 struct ctdb_public_ip_list *ip)
+{
+	if (nodemap->nodes[pnn].flags & NODE_FLAGS_NOIPTAKEOVER) {
+		return false;
+	}
+
+	return can_node_host_ip(ctdb, pnn, nodemap, ip);
+}
 
 /* search the node lists list for a node to takeover this ip.
    pick the node that currently are serving the least number of ips
    so that the ips get spread out evenly.
 */
 static int find_takeover_node(struct ctdb_context *ctdb, 
-		struct ctdb_node_map *nodemap, uint32_t mask, 
+		struct ctdb_node_map *nodemap,
 		struct ctdb_public_ip_list *ip,
 		struct ctdb_public_ip_list *all_ips)
 {
@@ -1339,21 +1354,8 @@ static int find_takeover_node(struct ctdb_context *ctdb,
 
 	pnn    = -1;
 	for (i=0;i<nodemap->num;i++) {
-		if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPTAKEOVER) {
-			/* This node is not allowed to takeover any addresses
-			*/
-			continue;
-		}
-
-		if (nodemap->nodes[i].flags & mask) {
-			/* This node is not healty and can not be used to serve
-			   a public address 
-			*/
-			continue;
-		}
-
 		/* verify that this node can serve this ip */
-		if (can_node_serve_ip(ctdb, i, ip)) {
+		if (!can_node_takeover_ip(ctdb, i, nodemap, ip)) {
 			/* no it couldnt   so skip to the next node */
 			continue;
 		}
@@ -1590,7 +1592,6 @@ static uint32_t lcp2_imbalance(struct ctdb_public_ip_list * all_ips, int pnn)
  */
 static void basic_allocate_unassigned(struct ctdb_context *ctdb,
 				      struct ctdb_node_map *nodemap,
-				      uint32_t mask,
 				      struct ctdb_public_ip_list *all_ips)
 {
 	struct ctdb_public_ip_list *tmp_ip;
@@ -1600,7 +1601,7 @@ static void basic_allocate_unassigned(struct ctdb_context *ctdb,
 	*/
 	for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) {
 		if (tmp_ip->pnn == -1) {
-			if (find_takeover_node(ctdb, nodemap, mask, tmp_ip, all_ips)) {
+			if (find_takeover_node(ctdb, nodemap, tmp_ip, all_ips)) {
 				DEBUG(DEBUG_WARNING,("Failed to find node to cover ip %s\n",
 					ctdb_addr_to_str(&tmp_ip->addr)));
 			}
@@ -1612,7 +1613,6 @@ static void basic_allocate_unassigned(struct ctdb_context *ctdb,
  */
 static void basic_failback(struct ctdb_context *ctdb,
 			   struct ctdb_node_map *nodemap,
-			   uint32_t mask,
 			   struct ctdb_public_ip_list *all_ips,
 			   int num_ips)
 {
@@ -1642,17 +1642,8 @@ try_again:
 		maxnode = -1;
 		minnode = -1;
 		for (i=0;i<nodemap->num;i++) {
-			if (nodemap->nodes[i].flags & mask) {
-				continue;
-			}
-
-			/* Only check nodes that are allowed to takeover an ip */
-			if (nodemap->nodes[i].flags & NODE_FLAGS_NOIPTAKEOVER) {
-				continue;
-			}
-
 			/* only check nodes that can actually serve this ip */
-			if (can_node_serve_ip(ctdb, i, tmp_ip)) {
+			if (!can_node_takeover_ip(ctdb, i, nodemap, tmp_ip)) {
 				/* no it couldnt   so skip to the next node */
 				continue;
 			}
@@ -1697,7 +1688,7 @@ try_again:
 			/* Reassign one of maxnode's VNNs */
 			for (tmp=all_ips;tmp;tmp=tmp->next) {
 				if (tmp->pnn == maxnode) {
-					(void)find_takeover_node(ctdb, nodemap, mask, tmp, all_ips);
+					(void)find_takeover_node(ctdb, nodemap, tmp, all_ips);
 					retries++;
 					goto try_again;;
 				}
@@ -1737,30 +1728,34 @@ void lcp2_forcerebalance(struct ctdb_context *ctdb, uint32_t pnn)
  */
 static void lcp2_init(struct ctdb_context * tmp_ctx,
 	       struct ctdb_node_map * nodemap,
-	       uint32_t mask,
 	       struct ctdb_public_ip_list *all_ips,
 	       uint32_t **lcp2_imbalances,
-	       bool **newly_healthy)
+	       bool **rebalance_candidates)
 {
 	int i;
 	struct ctdb_public_ip_list *tmp_ip;
 
-	*newly_healthy = talloc_array(tmp_ctx, bool, nodemap->num);
-	CTDB_NO_MEMORY_FATAL(tmp_ctx, *newly_healthy);
+	*rebalance_candidates = talloc_array(tmp_ctx, bool, nodemap->num);
+	CTDB_NO_MEMORY_FATAL(tmp_ctx, *rebalance_candidates);
 	*lcp2_imbalances = talloc_array(tmp_ctx, uint32_t, nodemap->num);
 	CTDB_NO_MEMORY_FATAL(tmp_ctx, *lcp2_imbalances);
 
 	for (i=0;i<nodemap->num;i++) {
 		(*lcp2_imbalances)[i] = lcp2_imbalance(all_ips, i);
-		/* First step: is the node "healthy"? */
-		(*newly_healthy)[i] = ! (bool)(nodemap->nodes[i].flags & mask);
+		/* First step: assume all nodes are candidates */
+		(*rebalance_candidates)[i] = true;
 	}
 
-	/* 2nd step: if a ndoe has IPs assigned then it must have been
-	 * healthy before, so we remove it from consideration... */
+	/* 2nd step: if a node has IPs assigned then it must have been
+	 * healthy before, so we remove it from consideration.  This
+	 * is overkill but is all we have because we don't maintain
+	 * state between takeover runs.  An alternative would be to
+	 * keep state and invalidate it every time the recovery master
+	 * changes.
+	 */
 	for (tmp_ip=all_ips;tmp_ip;tmp_ip=tmp_ip->next) {
 		if (tmp_ip->pnn != -1) {
-			(*newly_healthy)[tmp_ip->pnn] = false;
+			(*rebalance_candidates)[tmp_ip->pnn] = false;
 		}
 	}
 
@@ -1770,7 +1765,7 @@ static void lcp2_init(struct ctdb_context * tmp_ctx,
 		struct ctdb_rebalancenodes *next = force_rebalance_list->next;
 
 		if (force_rebalance_list->pnn <= nodemap->num) {
-			(*newly_healthy)[force_rebalance_list->pnn] = true;
+			(*rebalance_candidates)[force_rebalance_list->pnn] = true;
 		}
 
 		DEBUG(DEBUG_ERR,("During ipreallocation, forced rebalance of node %d\n", force_rebalance_list->pnn));
@@ -1783,10 +1778,9 @@ static void lcp2_init(struct ctdb_context * tmp_ctx,
  * the IP/node combination that will cost the least.
  */
 static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
-			      struct ctdb_node_map *nodemap,
-			      uint32_t mask,
-			      struct ctdb_public_ip_list *all_ips,
-			      uint32_t *lcp2_imbalances)
+				     struct ctdb_node_map *nodemap,
+				     struct ctdb_public_ip_list *all_ips,
+				     uint32_t *lcp2_imbalances)
 {
 	struct ctdb_public_ip_list *tmp_ip;
 	int dstnode;
@@ -1815,19 +1809,12 @@ static void lcp2_allocate_unassigned(struct ctdb_context *ctdb,
 			}
 
 			for (dstnode=0; dstnode < nodemap->num; dstnode++) {
-				/* Only check nodes that are allowed to takeover an ip */
-				if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPTAKEOVER) {
-					continue;
-				}
-
-				/* only check nodes that can actually serve this ip */
-				if (can_node_serve_ip(ctdb, dstnode, tmp_ip)) {
+				/* only check nodes that can actually takeover this ip */
+				if (!can_node_takeover_ip(ctdb, dstnode,
+							  nodemap, tmp_ip)) {
 					/* no it couldnt   so skip to the next node */
 					continue;
 				}
-				if (nodemap->nodes[dstnode].flags & mask) {
-					continue;
-				}
 
 				dstdsum = ip_distance_2_sum(&(tmp_ip->addr), all_ips, dstnode);
 				dstimbl = lcp2_imbalances[dstnode] + dstdsum;
@@ -1891,7 +1878,7 @@ static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
 				    int srcnode,
 				    uint32_t candimbl,
 				    uint32_t *lcp2_imbalances,
-				    bool *newly_healthy)
+				    bool *rebalance_candidates)
 {
 	int dstnode, mindstnode;
 	uint32_t srcimbl, srcdsum, dstimbl, dstdsum;
@@ -1925,17 +1912,13 @@ static bool lcp2_failback_candidate(struct ctdb_context *ctdb,
 		 * balance improvements.
 		 */
 		for (dstnode=0; dstnode < nodemap->num; dstnode++) {
-			if (! newly_healthy[dstnode]) {
-				continue;
-			}
-
-			/* Only check nodes that are allowed to takeover an ip */
-			if (nodemap->nodes[dstnode].flags & NODE_FLAGS_NOIPTAKEOVER) {
+			if (!rebalance_candidates[dstnode]) {
 				continue;
 			}
 
-			/* only check nodes that can actually serve this ip */
-			if (can_node_serve_ip(ctdb, dstnode, tmp_ip)) {
+			/* only check nodes that can actually takeover this ip */
+			if (!can_node_takeover_ip(ctdb, dstnode,
+						  nodemap, tmp_ip)) {
 				/* no it couldnt   so skip to the next node */
 				continue;
 			}
@@ -2004,12 +1987,11 @@ static int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
  */
 static void lcp2_failback(struct ctdb_context *ctdb,
 			  struct ctdb_node_map *nodemap,
-			  uint32_t mask,
 			  struct ctdb_public_ip_list *all_ips,
 			  uint32_t *lcp2_imbalances,
-			  bool *newly_healthy)
+			  bool *rebalance_candidates)
 {
-	int i, num_newly_healthy;
+	int i, num_rebalance_candidates;
 	struct lcp2_imbalance_pnn * lips;
 	bool again;
 
@@ -2019,13 +2001,13 @@ try_again:
 	 * nodes to transfer IPs to.  This check is much cheaper than
 	 * continuing on...
 	 */
-	num_newly_healthy = 0;
+	num_rebalance_candidates = 0;
 	for (i = 0; i < nodemap->num; i++) {
-		if (newly_healthy[i]) {
-			num_newly_healthy++;
+		if (rebalance_candidates[i]) {
+			num_rebalance_candidates++;
 		}
 	}
-	if (num_newly_healthy == 0) {
+	if (num_rebalance_candidates == 0) {
 		return;
 	}
 
@@ -2056,7 +2038,7 @@ try_again:
 					    lips[i].pnn,
 					    lips[i].imbalance,
 					    lcp2_imbalances,
-					    newly_healthy)) {
+					    rebalance_candidates)) {
 			again = true;
 			break;
 		}
@@ -2070,23 +2052,10 @@ 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 *all_ips)
 {
 	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
 	*/
@@ -2094,8 +2063,12 @@ static void unassign_unsuitable_ips(struct ctdb_context *ctdb,
 		if (tmp_ip->pnn == -1) {
 			continue;
 		}
-		if (can_node_serve_ip(ctdb, tmp_ip->pnn, tmp_ip) != 0) {
+		if (!can_node_host_ip(ctdb, tmp_ip->pnn,
+				      nodemap, tmp_ip) != 0) {
 			/* this node can not serve this ip. */
+			DEBUG(DEBUG_DEBUG,("Unassign IP: %s from %d\n",
+					   ctdb_addr_to_str(&(tmp_ip->addr)),
+					   tmp_ip->pnn));
 			tmp_ip->pnn = -1;
 		}
 	}
@@ -2103,8 +2076,7 @@ static void unassign_unsuitable_ips(struct ctdb_context *ctdb,
 
 static void ip_alloc_deterministic_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 *all_ips)
 {
 	struct ctdb_public_ip_list *tmp_ip;
 	int i;
@@ -2127,17 +2099,16 @@ static void ip_alloc_deterministic_ips(struct ctdb_context *ctdb,
 		DEBUG(DEBUG_WARNING, ("WARNING: 'NoIPFailback' set but ignored - incompatible with 'DeterministicIPs\n"));
 	}
 
-	unassign_unsuitable_ips(ctdb, nodemap, all_ips, mask);
+	unassign_unsuitable_ips(ctdb, nodemap, all_ips);
 
-	basic_allocate_unassigned(ctdb, nodemap, mask, all_ips);
+	basic_allocate_unassigned(ctdb, nodemap, all_ips);
 
 	/* No failback here! */
 }
 
 static void ip_alloc_nondeterministic_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 *all_ips)
 {
 	/* This should be pushed down into basic_failback. */
 	struct ctdb_public_ip_list *tmp_ip;
@@ -2146,9 +2117,9 @@ static void ip_alloc_nondeterministic_ips(struct ctdb_context *ctdb,
 		num_ips++;
 	}
 
-	unassign_unsuitable_ips(ctdb, nodemap, all_ips, mask);
+	unassign_unsuitable_ips(ctdb, nodemap, all_ips);
 
-	basic_allocate_unassigned(ctdb, nodemap, mask, all_ips);
+	basic_allocate_unassigned(ctdb, nodemap, all_ips);
 
 	/* If we don't want IPs to fail back then don't rebalance IPs. */
 	if (1 == ctdb->tunable.no_ip_failback) {
@@ -2158,24 +2129,24 @@ static void ip_alloc_nondeterministic_ips(struct ctdb_context *ctdb,
 	/* Now, try to make sure the ip adresses are evenly distributed
 	   across the nodes.
 	*/
-	basic_failback(ctdb, nodemap, mask, all_ips, num_ips);
+	basic_failback(ctdb, nodemap, all_ips, num_ips);
 }
 
 static void ip_alloc_lcp2(struct ctdb_context *ctdb,
 			  struct ctdb_node_map *nodemap,
-			  struct ctdb_public_ip_list *all_ips,
-			  uint32_t mask)
+			  struct ctdb_public_ip_list *all_ips)
 {
 	uint32_t *lcp2_imbalances;
-	bool *newly_healthy;
+	bool *rebalance_candidates;
 
 	TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
 
-	unassign_unsuitable_ips(ctdb, nodemap, all_ips, mask);
+	unassign_unsuitable_ips(ctdb, nodemap, all_ips);
 
-	lcp2_init(tmp_ctx, nodemap, mask, all_ips, &lcp2_imbalances, &newly_healthy);
+	lcp2_init(tmp_ctx, nodemap, all_ips,
+		  &lcp2_imbalances, &rebalance_candidates);
 
-	lcp2_allocate_unassigned(ctdb, nodemap, mask, all_ips, lcp2_imbalances);
+	lcp2_allocate_unassigned(ctdb, nodemap, all_ips, lcp2_imbalances);
 
 	/* If we don't want IPs to fail back then don't rebalance IPs. */
 	if (1 == ctdb->tunable.no_ip_failback) {
@@ -2185,19 +2156,16 @@ static void ip_alloc_lcp2(struct ctdb_context *ctdb,
 	/* Now, try to make sure the ip adresses are evenly distributed
 	   across the nodes.
 	*/
-	lcp2_failback(ctdb, nodemap, mask, all_ips, lcp2_imbalances, newly_healthy);
+	lcp2_failback(ctdb, nodemap, all_ips,
+		      lcp2_imbalances, rebalance_candidates);
 
 finished:
 	talloc_free(tmp_ctx);
 }
 
-/* The calculation part of the IP allocation algorithm. */
-static void ctdb_takeover_run_core(struct ctdb_context *ctdb,
-				   struct ctdb_node_map *nodemap,
-				   struct ctdb_public_ip_list **all_ips_p)
+static bool all_nodes_are_disabled(struct ctdb_node_map *nodemap)
 {
 	int i, num_healthy;
-	uint32_t mask;
 
 	/* Count how many completely healthy nodes we have */
 	num_healthy = 0;
@@ -2207,18 +2175,14 @@ static void ctdb_takeover_run_core(struct ctdb_context *ctdb,
 		}
 	}
 
-	/* If we have healthy nodes then we will only consider them


-- 
CTDB repository


More information about the samba-cvs mailing list