[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Mon Jul 4 17:30:03 UTC 2016


The branch, master has been updated
       via  5a0d1b7 ctdb-tests: Link to ctdb-ipalloc instead of using ctdbd_test.c
       via  a2124a1 ctdb-ipalloc: Drop implicit dependency on ctdb-common
       via  7d5a81e ctdb-tests: Allow takeover tests to be run under valgrind
       via  ed2988c ctdb-tests: Drop use of CTDB context from takeover test
       via  445860b ctdb-ipalloc: IP allocation state is now an opaque structure
       via  41a14e7 ctdb-ipalloc: ipalloc() returns public IP list
       via  21adcd3 ctdb-ipalloc: Move set_ipflags_internal() to ipalloc
       via  2eb0b9e ctdb-ipalloc: Switch set_ipflags_internal() to use a new-style node map
       via  ee7fc25 ctdb-ipalloc: Move ipalloc state initialisation to ipalloc.c
       via  38f4616 ctdb-ipalloc: Pass extra data to IP allocation state initialisation
       via  64361d9 ctdb-ipalloc: Make no_ip_failback a boolean
       via  86f7c4d ctdb-ipalloc: Fix buggy short-circuit when no IPs are available
       via  c5d85a0 ctdb-ipalloc: New function ipalloc_can_host_ips()
       via  695da51 ctdb-ipalloc: Drop known public IPs from IP allocation state
       via  e8ff433 ctdb-ipalloc: Move create_merged_ip_list() into ipalloc
       via  5c47c35 ctdb-ipalloc: New function ipalloc_set_public_ips()
       via  1f5c4db ctdb-ipalloc: Remove function ctdb_reload_remote_public_ips()
       via  303ef82 ctdb-ipalloc: Clean up reloading of remote public IPs
       via  c09cf57 ctdb-ipalloc: Don't build a global IP tree
       via  55f13b7 ctdb-ipalloc: Drop code to update IP assignment tree
       via  58ada07 ctdb-tools: Don't bother sending CTDB_SRVID_RECD_UPDATE_IP
       via  a26d39e ctdb-recoverd: Drop code to change the IP assignment tree
       via  35644d0 ctdb-ipalloc: Drop remote IP verification
       via  c86066c ctdb-ipalloc: Drop a use of CTDB_NO_MEMORY_NULL()
       via  1ec7de6 ctdb-ipalloc: Do not use node count or PNNs from CTDB context
       via  c92aa61 ctdb-ipalloc: Drop an unnecessary check
       via  03b300e ctdb-ipalloc: Move if-statement with broken condition
       via  27a2608 ctdb-tests: Drop CTDB_TEST_MAX_NODES
       via  5f95240 ctdb-tests: Build a node map instead of a hacky node flags array
       via  5d148ce ctdb-tests: Assign known and available arrays via pointers.
       via  cd5ed37 ctdb-tests: read_ctdb_public_ip_info() reads all test input
       via  067a611 ctdb-tests: Drop CTDB_TEST_MAX_IPS
       via  09924d9 ctdb-tests: Drop all_ips argument from read_ctdb_public_ip_info()
       via  4d20bab ctdb-tests: Don't bother setting all_ips
       via  fcc373e ctdb-tests: Simplify read_ctdb_public_ip_info() using new function add_ip()
       via  2d7ba83 ctdb-tests: Remove unused tests from IP takeover test harness
      from  7700ee8 tdb: avoid many fcntl calls when incrementing seqnum

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5a0d1b7cc5769e3f4236f81cb45d8533339a3cfd
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu May 26 16:26:51 2016 +1000

    ctdb-tests: Link to ctdb-ipalloc instead of using ctdbd_test.c
    
    Less code, quicker build time, smaller binary...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Mon Jul  4 19:29:08 CEST 2016 on sn-devel-144

commit a2124a1cd8719d2aab4a16cb791b533ddc744a95
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu May 26 15:31:47 2016 +1000

    ctdb-ipalloc: Drop implicit dependency on ctdb-common
    
    Use new functions from protocol API instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 7d5a81e561d2d5485fc806d0aa9ac67619a8d032
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu May 26 15:03:51 2016 +1000

    ctdb-tests: Allow takeover tests to be run under valgrind
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ed2988cf9f6c4a7e46972aecb38ecd7c12c6b77d
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 20:43:46 2016 +1000

    ctdb-tests: Drop use of CTDB context from takeover test
    
    The ipalloc code doesn't need a CTDB context so neither should the
    code that tests it.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 445860bf84c5588406325d7601588c3a8b2ff3f2
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 14:23:38 2016 +1000

    ctdb-ipalloc: IP allocation state is now an opaque structure
    
    It is private to the IP allocation module.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 41a14e72b5944d8a92f91e4583c2826da497dc00
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 14:22:02 2016 +1000

    ctdb-ipalloc: ipalloc() returns public IP list
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 21adcd32bd96b26f361d7f5b0b6818d7d395ce42
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 13:18:04 2016 +1000

    ctdb-ipalloc: Move set_ipflags_internal() to ipalloc
    
    Rename it ipalloc_set_node_flags().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2eb0b9e98ad4de4a2c9f376ff98558cd855fab53
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 11:37:52 2016 +1000

    ctdb-ipalloc: Switch set_ipflags_internal() to use a new-style node map
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ee7fc252c879fc8e490a8073118713fc9ad41a59
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 14:28:33 2016 +1000

    ctdb-ipalloc: Move ipalloc state initialisation to ipalloc.c
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 38f4616bdd7377ef9c1e0b4d319363fda7789308
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 14:16:47 2016 +1000

    ctdb-ipalloc: Pass extra data to IP allocation state initialisation
    
    No longer require CTDB context but pass in number of nodes, algorithm,
    no_ip_failback and force_rebalance_nodes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 64361d9778ffbb971b149fbf619452201a2e9c17
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 16:34:44 2016 +1000

    ctdb-ipalloc: Make no_ip_failback a boolean
    
    No need to expose tunable values that far down.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 86f7c4d7f360457cdd41e456aafbf90291f5bfbb
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 29 16:36:28 2016 +1000

    ctdb-ipalloc: Fix buggy short-circuit when no IPs are available
    
    At the moment IP is short-circuited when there are no available IP
    addresses.  However, if some IP addresses are already allocated then
    "no available IP addresses" means that all the addresses should
    (probably) be released.  The current short-circuit means that no
    already hosted IP addresses will be released.
    
    The short-circuit exists to avoid lots of messages saying that all IP
    addresses can not be assigned at startup time.  So, add a check to
    ipalloc_can_host_ips() so that it succeeds if IP addresses are already
    allocated to nodes.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c5d85a071b33ac8a80ae8f6ddaf26f9fa7bc67a6
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 21:16:27 2016 +1000

    ctdb-ipalloc: New function ipalloc_can_host_ips()
    
    Abstracts out code involving internals of IP allocation state.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 695da518de20c6fa44f198e20dbe85aa62cde914
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 21:09:39 2016 +1000

    ctdb-ipalloc: Drop known public IPs from IP allocation state
    
    This is never used in the allocation algorithms.  It is only used when
    building the merged IP list.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e8ff433c4666c75d099e7e5eab0f569ff6285c5e
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 20:23:18 2016 +1000

    ctdb-ipalloc: Move create_merged_ip_list() into ipalloc
    
    How the existing IP layout is constructed and how the merged IP list is
    sorted are important aspects of the IP allocation algorithm.  Construct the
    merged IP list when known and available IPs are assigned.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5c47c35c5a69ebb1020a0c4538fa2f8de4b59e87
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 20:23:18 2016 +1000

    ctdb-ipalloc: New function ipalloc_set_public_ips()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1f5c4dbac913abd6f84dc0cbce7eea35940ecb33
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 20:46:50 2016 +1000

    ctdb-ipalloc: Remove function ctdb_reload_remote_public_ips()
    
    Use ctdb_fetch_remote_public_ips() inline to fetch each list.  Assign
    them into the IP allocation state separately.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 303ef82a27771ae1eda01e03d420c165bc4aaa88
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 20 21:27:40 2016 +1000

    ctdb-ipalloc: Clean up reloading of remote public IPs
    
    Factor out new function ctdb_fetch_remote_public_ips() to fetch known
    or available public IP addresses, according to flags.
    
    This also drops the hack where the array from a
    ctdb_public_ip_list_old was assigned to a pointer in a
    ctdb_public_ip_list.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c09cf571b7a9a4584be079d7989575f21b1fb915
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 20 20:53:58 2016 +1000

    ctdb-ipalloc: Don't build a global IP tree
    
    It isn't used outside this function, so just use a local variable.
    
    This makes create_merged_ip_list() independent of the CTDB context.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 55f13b74bf4ee460b153d062acbdd758ce58ed1a
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 20 20:47:17 2016 +1000

    ctdb-ipalloc: Drop code to update IP assignment tree
    
    This code is not used.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 58ada0757f29111b6ff180f95c1c0c51ed323c0f
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 06:25:17 2016 +1000

    ctdb-tools: Don't bother sending CTDB_SRVID_RECD_UPDATE_IP
    
    Nothing is listening.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a26d39e5cec6f41164cb26dad9641fdef1c67e20
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 20 20:45:28 2016 +1000

    ctdb-recoverd: Drop code to change the IP assignment tree
    
    The tree is no longer used in verification.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 35644d0d82da0f2c1341dcdf9bb7472c09a8c99d
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Jun 20 20:41:05 2016 +1000

    ctdb-ipalloc: Drop remote IP verification
    
    It is only run during a takeover run and only logs errors.  It doesn't
    actually do anything to fix potential errors.  The takeover run should
    fix any inconsistencies anyway.
    
    Instead, leave a comment in the recovery daemon's monitoring loop to
    add proper remote IP verification later.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c86066cdc0af4af970c797bdd64db5c5a0c1cfc8
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 16:44:05 2016 +1000

    ctdb-ipalloc: Drop a use of CTDB_NO_MEMORY_NULL()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1ec7de66e9680864147b232d797c627b4a7da63f
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 14:50:14 2016 +1000

    ctdb-ipalloc: Do not use node count or PNNs from CTDB context
    
    This is unnecessary.  IP allocation state already has a node count and
    "i" is already a PNN.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit c92aa6105a7854782a61ba4bdcc63d179aafd42f
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 14:46:18 2016 +1000

    ctdb-ipalloc: Drop an unnecessary check
    
    Deleted (and other inactive) nodes will have an empty list of known
    IP addresses.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 03b300e0522eea97e8f894dc65240f0ed6e007f0
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 14:41:43 2016 +1000

    ctdb-ipalloc: Move if-statement with broken condition
    
    This pointer is for an array that is always allocated.  The check is
    meant to skip a node that has no IP addresses.  However, when there
    are no IP addresses the loop below will not do anything anyway.
    
    Add this as a check at the beginning of the function instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 27a26087e11c1154a750d2f8c2e3b46b8304a8d6
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 11:02:36 2016 +1000

    ctdb-tests: Drop CTDB_TEST_MAX_NODES
    
    The node map is dynamically constructed.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5f95240653305ea8480f64e58efd84e88b83dcff
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jun 22 11:00:43 2016 +1000

    ctdb-tests: Build a node map instead of a hacky node flags array
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5d148ce99c6e939b50295c0aaa4e19198e43aa91
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 15:26:05 2016 +1000

    ctdb-tests: Assign known and available arrays via pointers.
    
    No need to allocate these and iterate as
    read_ctdb_public_ip_info_node() now returns a usable array.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit cd5ed374bc93dc75e17a5e0c2c30f27c37917d50
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 15:14:33 2016 +1000

    ctdb-tests: read_ctdb_public_ip_info() reads all test input
    
    If there is per-node data then each chunk is read in a separate call
    and is cherry-picked out into known_public_ips[] for each node.  This
    is confusing.
    
    Instead, a single call now reads all data for multiple nodes and
    returns complete arrays of known and available IP addresses.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 067a611c7d469c45d4a7a756945921c8d2deb107
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 14:49:28 2016 +1000

    ctdb-tests: Drop CTDB_TEST_MAX_IPS
    
    Arrays are now dynamically reallocated.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 09924d9c94932d7f48c6c1babfe58e993eff1597
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 14:37:53 2016 +1000

    ctdb-tests: Drop all_ips argument from read_ctdb_public_ip_info()
    
    Nothing uses the result.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4d20babddf169eca35ebde912bdd34920c4cec80
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 14:29:25 2016 +1000

    ctdb-tests: Don't bother setting all_ips
    
    It isn't used outside this function.  Instead, update k directly.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit fcc373e3c3041715092adbcf69986d0ae683837c
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jun 21 12:27:55 2016 +1000

    ctdb-tests: Simplify read_ctdb_public_ip_info() using new function add_ip()
    
    Known public IPs array is now dynamically allocated instead of
    allocated once with artificial size limit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2d7ba8335bbad229d481ae7c994585838e194f81
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun May 22 01:51:44 2016 +1000

    ctdb-tests: Remove unused tests from IP takeover test harness
    
    These tests aren't run anywhere.  They were used to test internal
    functions during development.
    
    The aim is to simplify this test program so that it can be linked with
    the ipalloc subsystem, allowing removal of ctdbd_test.c and all of its
    complications.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/include/ctdb_private.h            |   7 -
 ctdb/server/ctdb_recoverd.c            |  30 +-
 ctdb/server/ctdb_takeover.c            | 484 +++++++-----------------------
 ctdb/server/ipalloc.c                  | 240 ++++++++++++++-
 ctdb/server/ipalloc.h                  |  32 +-
 ctdb/server/ipalloc_common.c           |  13 +-
 ctdb/server/ipalloc_deterministic.c    |   2 +-
 ctdb/server/ipalloc_lcp2.c             |   2 +-
 ctdb/server/ipalloc_nondeterministic.c |   7 +-
 ctdb/server/ipalloc_private.h          |  14 +
 ctdb/tests/src/ctdb_takeover_tests.c   | 526 ++++++++-------------------------
 ctdb/tests/src/ctdbd_test.c            |  87 ------
 ctdb/tests/takeover/scripts/local.sh   |   2 +-
 ctdb/tools/ctdb.c                      |   9 -
 ctdb/wscript                           |   3 +-
 15 files changed, 527 insertions(+), 931 deletions(-)
 delete mode 100644 ctdb/tests/src/ctdbd_test.c


Changeset truncated at 500 lines:

diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index f4f5b67..f7982de 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -364,9 +364,6 @@ struct ctdb_context {
 	/* mapping from pid to ctdb_client * */
 	struct ctdb_client_pid_list *client_pids;
 
-	/* used in the recovery daemon to remember the ip allocation */
-	struct trbt_tree *ip_tree;
-
 	/* Used to defer db attach requests while in recovery mode */
 	struct ctdb_deferred_attach_context *deferred_attach;
 
@@ -1015,10 +1012,6 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
 					struct ctdb_req_control_old *c,
 					TDB_DATA recdata, bool *async_reply);
 
-int update_ip_assignment_tree(struct ctdb_context *ctdb,
-				struct ctdb_public_ip *ip);
-void clear_ip_assignment_tree(struct ctdb_context *ctdb);
-
 int32_t ctdb_control_reload_public_ips(struct ctdb_context *ctdb,
 				       struct ctdb_req_control_old *c,
 				       bool *async_reply);
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 01807b4..e5b9454 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -2510,28 +2510,6 @@ static void recd_node_rebalance_handler(uint64_t srvid, TDB_DATA data,
 
 
 
-static void recd_update_ip_handler(uint64_t srvid, TDB_DATA data,
-				   void *private_data)
-{
-	struct ctdb_recoverd *rec = talloc_get_type(
-		private_data, struct ctdb_recoverd);
-	struct ctdb_public_ip *ip;
-
-	if (rec->recmaster != rec->ctdb->pnn) {
-		DEBUG(DEBUG_INFO,("Not recmaster, ignore update ip message\n"));
-		return;
-	}
-
-	if (data.dsize != sizeof(struct ctdb_public_ip)) {
-		DEBUG(DEBUG_ERR,(__location__ " Incorrect size of recd update ip message. Was %zd but expected %zd bytes\n", data.dsize, sizeof(struct ctdb_public_ip)));
-		return;
-	}
-
-	ip = (struct ctdb_public_ip *)data.dptr;
-
-	update_ip_assignment_tree(rec->ctdb, ip);
-}
-
 static void srvid_disable_and_reply(struct ctdb_context *ctdb,
 				    TDB_DATA data,
 				    struct ctdb_op_state *op_state)
@@ -2732,8 +2710,6 @@ static void election_handler(uint64_t srvid, TDB_DATA data, void *private_data)
 		ctdb_recovery_unlock(rec);
 	}
 
-	clear_ip_assignment_tree(ctdb);
-
 	/* ok, let that guy become recmaster then */
 	ret = ctdb_ctrl_setrecmaster(ctdb, CONTROL_TIMEOUT(),
 				     CTDB_CURRENT_NODE, em->pnn);
@@ -3807,6 +3783,9 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 		}
 	}
 
+	/* FIXME: Add remote public IP checking to ensure that nodes
+	 * have the IP addresses that are allocated to them. */
+
 takeover_run_checks:
 
 	/* If there are IP takeover runs requested or the previous one
@@ -3891,9 +3870,6 @@ static void monitor_cluster(struct ctdb_context *ctdb)
 	/* register a message port for disabling the ip check for a short while */
 	ctdb_client_set_message_handler(ctdb, CTDB_SRVID_DISABLE_IP_CHECK, disable_ip_check_handler, rec);
 
-	/* register a message port for updating the recovery daemons node assignment for an ip */
-	ctdb_client_set_message_handler(ctdb, CTDB_SRVID_RECD_UPDATE_IP, recd_update_ip_handler, rec);
-
 	/* register a message port for forcing a rebalance of a node next
 	   reallocation */
 	ctdb_client_set_message_handler(ctdb, CTDB_SRVID_REBALANCE_NODE, recd_node_rebalance_handler, rec);
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index cb431b3..04c474e 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -1129,170 +1129,60 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses)
 	return 0;
 }
 
-static void *add_ip_callback(void *parm, void *data)
+static struct ctdb_public_ip_list *
+ctdb_fetch_remote_public_ips(struct ctdb_context *ctdb,
+			     TALLOC_CTX *mem_ctx,
+			     struct ctdb_node_map_old *nodemap,
+			     uint32_t public_ip_flags)
 {
-	struct public_ip_list *this_ip = parm;
-	struct public_ip_list *prev_ip = data;
-
-	if (prev_ip == NULL) {
-		return parm;
-	}
-	if (this_ip->pnn == -1) {
-		this_ip->pnn = prev_ip->pnn;
-	}
-
-	return parm;
-}
-
-static int getips_count_callback(void *param, void *data)
-{
-	struct public_ip_list **ip_list = (struct public_ip_list **)param;
-	struct public_ip_list *new_ip = (struct public_ip_list *)data;
-
-	new_ip->next = *ip_list;
-	*ip_list     = new_ip;
-	return 0;
-}
-
-static int verify_remote_ip_allocation(struct ctdb_context *ctdb,
-				       struct ctdb_public_ip_list *ips,
-				       uint32_t pnn);
-
-static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb,
-					 struct ipalloc_state *ipalloc_state,
-					 struct ctdb_node_map_old *nodemap)
-{
-	int j;
-	int ret;
+	int j, ret;
 	struct ctdb_public_ip_list_old *ip_list;
+	struct ctdb_public_ip_list *public_ips;
 
-	if (ipalloc_state->num != nodemap->num) {
-		DEBUG(DEBUG_ERR,
-		      (__location__
-		       " ipalloc_state->num (%d) != nodemap->num (%d) invalid param\n",
-		       ipalloc_state->num, nodemap->num));
-		return -1;
+	public_ips = talloc_zero_array(mem_ctx,
+				       struct ctdb_public_ip_list,
+				       nodemap->num);
+	if (public_ips == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		return NULL;
 	}
 
-	for (j=0; j<nodemap->num; j++) {
+	for (j = 0; j < nodemap->num; j++) {
 		if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
 			continue;
 		}
 
-		/* Retrieve the list of known public IPs from the node */
-		ret = ctdb_ctrl_get_public_ips_flags(ctdb,
-					TAKEOVER_TIMEOUT(),
-					j,
-					ipalloc_state->known_public_ips,
-					0,
-					&ip_list);
+		/* Retrieve the list of public IPs from the
+		 * node. Flags says whether it is known or
+		 * available. */
+		ret = ctdb_ctrl_get_public_ips_flags(
+			ctdb, TAKEOVER_TIMEOUT(), j, public_ips,
+			public_ip_flags, &ip_list);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,
-			      ("Failed to read known public IPs from node: %u\n",
-			       j));
-			return -1;
-		}
-		ipalloc_state->known_public_ips[j].num = ip_list->num;
-		/* This could be copied and freed.  However, ip_list
-		 * is allocated off ipalloc_state->known_public_ips,
-		 * so this is a safe hack.  This will go away in a
-		 * while anyway... */
-		ipalloc_state->known_public_ips[j].ip = &ip_list->ips[0];
-
-		if (ctdb->do_checkpublicip) {
-			verify_remote_ip_allocation(
-				ctdb,
-				&ipalloc_state->known_public_ips[j],
-				j);
-		}
-
-		/* Retrieve the list of available public IPs from the node */
-		ret = ctdb_ctrl_get_public_ips_flags(ctdb,
-					TAKEOVER_TIMEOUT(),
-					j,
-					ipalloc_state->available_public_ips,
-					CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE,
-					&ip_list);
-		if (ret != 0) {
-			DEBUG(DEBUG_ERR,
-			      ("Failed to read available public IPs from node: %u\n",
-			       j));
-			return -1;
+			      ("Failed to read public IPs from node: %u\n", j));
+			talloc_free(public_ips);
+			return NULL;
 		}
-		ipalloc_state->available_public_ips[j].num = ip_list->num;
-		/* This could be copied and freed.  However, ip_list
-		 * is allocated off ipalloc_state->available_public_ips,
-		 * so this is a safe hack.  This will go away in a
-		 * while anyway... */
-		ipalloc_state->available_public_ips[j].ip = &ip_list->ips[0];
-	}
-
-	return 0;
-}
-
-static struct public_ip_list *
-create_merged_ip_list(struct ctdb_context *ctdb, struct ipalloc_state *ipalloc_state)
-{
-	int i, j;
-	struct public_ip_list *ip_list;
-	struct ctdb_public_ip_list *public_ips;
-
-	TALLOC_FREE(ctdb->ip_tree);
-	ctdb->ip_tree = trbt_create(ctdb, 0);
-
-	for (i=0; i < ctdb->num_nodes; i++) {
-
-		if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
+		public_ips[j].num = ip_list->num;
+		if (ip_list->num == 0) {
+			talloc_free(ip_list);
 			continue;
 		}
-
-		/* there were no public ips for this node */
-		if (ipalloc_state->known_public_ips == NULL) {
-			continue;
-		}
-
-		public_ips = &ipalloc_state->known_public_ips[i];
-
-		for (j=0; j < public_ips->num; j++) {
-			struct public_ip_list *tmp_ip;
-
-			tmp_ip = talloc_zero(ctdb->ip_tree, struct public_ip_list);
-			CTDB_NO_MEMORY_NULL(ctdb, tmp_ip);
-			/* Do not use information about IP addresses hosted
-			 * on other nodes, it may not be accurate */
-			if (public_ips->ip[j].pnn == ctdb->nodes[i]->pnn) {
-				tmp_ip->pnn = public_ips->ip[j].pnn;
-			} else {
-				tmp_ip->pnn = -1;
-			}
-			tmp_ip->addr = public_ips->ip[j].addr;
-			tmp_ip->next = NULL;
-
-			trbt_insertarray32_callback(ctdb->ip_tree,
-				IP_KEYLEN, ip_key(&public_ips->ip[j].addr),
-				add_ip_callback,
-				tmp_ip);
-		}
-	}
-
-	ip_list = NULL;
-	trbt_traversearray32(ctdb->ip_tree, IP_KEYLEN, getips_count_callback, &ip_list);
-
-	return ip_list;
-}
-
-static bool all_nodes_are_disabled(struct ctdb_node_map_old *nodemap)
-{
-	int i;
-
-	for (i=0;i<nodemap->num;i++) {
-		if (!(nodemap->nodes[i].flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED))) {
-			/* Found one completely healthy node */
-			return false;
+		public_ips[j].ip = talloc_zero_array(public_ips,
+						     struct ctdb_public_ip,
+						     ip_list->num);
+		if (public_ips[j].ip == NULL) {
+			DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+			talloc_free(public_ips);
+			return NULL;
 		}
+		memcpy(public_ips[j].ip, &ip_list->ips[0],
+		       sizeof(struct ctdb_public_ip) * ip_list->num);
+		talloc_free(ip_list);
 	}
 
-	return true;
+	return public_ips;
 }
 
 struct get_tunable_callback_data {
@@ -1407,61 +1297,34 @@ static uint32_t *get_tunable_from_nodes(struct ctdb_context *ctdb,
 	return tvals;
 }
 
-/* Set internal flags for IP allocation:
- *   Clear ip flags
- *   Set NOIPTAKOVER ip flags from per-node NoIPTakeover tunable
- *   Set NOIPHOST ip flag for each INACTIVE node
- *   if all nodes are disabled:
- *     Set NOIPHOST ip flags from per-node NoIPHostOnAllDisabled tunable
- *   else
- *     Set NOIPHOST ip flags for disabled nodes
- */
-static void set_ipflags_internal(struct ipalloc_state *ipalloc_state,
-				 struct ctdb_node_map_old *nodemap,
-				 uint32_t *tval_noiptakeover,
-				 uint32_t *tval_noiphostonalldisabled)
+static struct ctdb_node_map *
+ctdb_node_map_old_to_new(TALLOC_CTX *mem_ctx,
+			 const struct ctdb_node_map_old *old)
 {
-	int i;
-
-	for (i=0;i<nodemap->num;i++) {
-		/* Can not take IPs on node with NoIPTakeover set */
-		if (tval_noiptakeover[i] != 0) {
-			ipalloc_state->noiptakeover[i] = true;
-		}
+	struct ctdb_node_map *new;
 
-		/* Can not host IPs on INACTIVE node */
-		if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
-			ipalloc_state->noiphost[i] = true;
-		}
+	new = talloc(mem_ctx, struct ctdb_node_map);
+	if (new == NULL) {
+		DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+		return NULL;
 	}
+	new->num = old->num;
+	new->node = talloc_zero_array(new,
+				      struct ctdb_node_and_flags, new->num);
+	memcpy(new->node, &old->nodes[0],
+	       sizeof(struct ctdb_node_and_flags) * new->num);
 
-	if (all_nodes_are_disabled(nodemap)) {
-		/* If all nodes are disabled, can not host IPs on node
-		 * with NoIPHostOnAllDisabled set
-		 */
-		for (i=0;i<nodemap->num;i++) {
-			if (tval_noiphostonalldisabled[i] != 0) {
-				ipalloc_state->noiphost[i] = true;
-			}
-		}
-	} else {
-		/* If some nodes are not disabled, then can not host
-		 * IPs on DISABLED node
-		 */
-		for (i=0;i<nodemap->num;i++) {
-			if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
-				ipalloc_state->noiphost[i] = true;
-			}
-		}
-	}
+	return new;
 }
 
+
 static bool set_ipflags(struct ctdb_context *ctdb,
 			struct ipalloc_state *ipalloc_state,
 			struct ctdb_node_map_old *nodemap)
 {
 	uint32_t *tval_noiptakeover;
 	uint32_t *tval_noiphostonalldisabled;
+	struct ctdb_node_map *new;
 
 	tval_noiptakeover = get_tunable_from_nodes(ctdb, ipalloc_state, nodemap,
 						   "NoIPTakeover", 0);
@@ -1477,76 +1340,32 @@ static bool set_ipflags(struct ctdb_context *ctdb,
 		return false;
 	}
 
-	set_ipflags_internal(ipalloc_state, nodemap,
+	new = ctdb_node_map_old_to_new(ipalloc_state, nodemap);
+	if (new == NULL) {
+		return false;
+	}
+
+	ipalloc_set_node_flags(ipalloc_state, new,
 			     tval_noiptakeover,
 			     tval_noiphostonalldisabled);
 
 	talloc_free(tval_noiptakeover);
 	talloc_free(tval_noiphostonalldisabled);
+	talloc_free(new);
 
 	return true;
 }
 
-static struct ipalloc_state * ipalloc_state_init(struct ctdb_context *ctdb,
-						 TALLOC_CTX *mem_ctx)
+static enum ipalloc_algorithm
+determine_algorithm(const struct ctdb_tunable_list *tunables)
 {
-	struct ipalloc_state *ipalloc_state =
-		talloc_zero(mem_ctx, struct ipalloc_state);
-	if (ipalloc_state == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		return NULL;
-	}
-
-	ipalloc_state->num = ctdb->num_nodes;
-
-	ipalloc_state->known_public_ips =
-		talloc_zero_array(ipalloc_state,
-				  struct ctdb_public_ip_list,
-				  ipalloc_state->num);
-	if (ipalloc_state->known_public_ips == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		goto fail;
-	}
-
-	ipalloc_state->available_public_ips =
-		talloc_zero_array(ipalloc_state,
-				  struct ctdb_public_ip_list,
-				  ipalloc_state->num);
-	if (ipalloc_state->available_public_ips == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		goto fail;
-	}
-	ipalloc_state->noiptakeover =
-		talloc_zero_array(ipalloc_state,
-				  bool,
-				  ipalloc_state->num);
-	if (ipalloc_state->noiptakeover == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		goto fail;
-	}
-	ipalloc_state->noiphost =
-		talloc_zero_array(ipalloc_state,
-				  bool,
-				  ipalloc_state->num);
-	if (ipalloc_state->noiphost == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " Out of memory\n"));
-		goto fail;
-	}
-
-	if (1 == ctdb->tunable.lcp2_public_ip_assignment) {
-		ipalloc_state->algorithm = IPALLOC_LCP2;
-	} else if (1 == ctdb->tunable.deterministic_public_ips) {
-		ipalloc_state->algorithm = IPALLOC_DETERMINISTIC;
+	if (1 == tunables->lcp2_public_ip_assignment) {
+		return IPALLOC_LCP2;
+	} else if (1 == tunables->deterministic_public_ips) {
+		return IPALLOC_DETERMINISTIC;
 	} else {
-		ipalloc_state->algorithm = IPALLOC_NONDETERMINISTIC;
+		return IPALLOC_NONDETERMINISTIC;
 	}
-
-	ipalloc_state->no_ip_failback = ctdb->tunable.no_ip_failback;
-
-	return ipalloc_state;
-fail:
-	talloc_free(ipalloc_state);
-	return NULL;
 }
 
 struct takeover_callback_data {
@@ -1640,25 +1459,23 @@ static void takeover_run_process_failures(struct ctdb_context *ctdb,
  * Recalculate the allocation of public IPs to nodes and have the
  * nodes host their allocated addresses.
  *
- * - Allocate memory for IP allocation state, including per node
- *   arrays
- * - Populate IP allocation algorithm in IP allocation state
- * - Populate local value of tunable NoIPFailback in IP allocation
-     state - this is really a cluster-wide configuration variable and
-     only the value form the master node is used
- * - Retrieve tunables NoIPTakeover and NoIPHostOnAllDisabled from all
- *   connected nodes - this is done separately so tunable values can
- *   be faked in unit testing
- * - Populate NoIPTakover tunable in IP allocation state
- * - Populate NoIPHost in IP allocation state, derived from node flags
- *   and NoIPHostOnAllDisabled tunable
- * - Retrieve and populate known and available IP lists in IP
- *   allocation state
- * - If no available IP addresses then early exit
- * - Build list of (known IPs, currently assigned node)
- * - Populate list of nodes to force rebalance - internal structure,
- *   currently no way to fetch, only used by LCP2 for nodes that have
- *   had new IP addresses added
+ * - Initialise IP allocation state.  Pass:
+     + algorithm to be used;
+     + whether IP rebalancing ("failback") should be done (this uses a
+       cluster-wide configuration variable and only the value form the
+       master node is used); and
+ *   + list of nodes to force rebalance (internal structure, currently
+ *     no way to fetch, only used by LCP2 for nodes that have had new
+ *     IP addresses added).
+ * - Set IP flags for IP allocation based on node map and tunables


-- 
Samba Shared Repository



More information about the samba-cvs mailing list