[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Sat Mar 22 23:21:04 MDT 2014


The branch, master has been updated
       via  20c7196 ctdb/daemon: Optimise deletion of IPs
       via  9b90753 ctdb/daemon: Make delete IP wait until the IP is released
       via  bafb915 ctdb-tests: Improve tickle tests
       via  058e14c ctdb-eventscripts: Fix regression in IP add/delete functions
       via  ecafbce ctdb-daemon: Do not disable monitoring when running eventscripts
       via  87d58fd ctdb-eventscripts: Attach to persistent ctdb.tdb in "startup" event
       via  4f79fa6 ctdb-daemon: Fix tickle updates to recently started nodes
       via  441e099 ctdb-tools-ctdb: Parse IP addresses when reading a list from a file
       via  fad2b6b ctdb-tools-ctdb: Remove redundant filtering of trailing empty lines
       via  555aa06 ctdb-tools-ctdb: Use DLIST_ADD_END() to avoid reversing the list
       via  91895b3 ctdb-tools-ctdb: Factor out function read_pnn_node_file()
       via  79d2800 ctdb-tests: Add "ctdb listnodes" and "ctdb xpnn" stub tests
       via  9bede49 ctdb-tools-ctdb: Read NAT gateway nodes from a separate function
       via  ba69742 ctdb-tools-ctdb: Add and use function filter_nodemap_by_natgw_nodes()
       via  e728a35 ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_flags()
       via  26c9a59 ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_capabilities()
       via  5fb7e38 ctdb-tools-ctdb: Fixes for "lvs" and "lvsmaster" commands
       via  33b1fcb ctdb-tools-ctdb: Generalise find_natgw() -> filter_nodemap_by_flags()
       via  798bd58 ctdb-tools-ctdb: Update natgwlist to filter nodes by NATGW capability
       via  7710053 ctdb-tests: New natgwlist tests where nodes capability not set
       via  75cf99b ctdb-tests: Update ctdb stub LVS tests and add some new ones
       via  3af858e ctdb-tests: Support fake capabilities in CTDB tool stub
       via  263e5ea ctdb-tests: Remove old, unused copy of a CTDB tool unit test
       via  a947cf6 ctdb-tools-ctdb: Don't close stderr when running without_daemon commands
      from  7fdb21c ctdb/pmda: Fix metric identifiers

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


- Log -----------------------------------------------------------------
commit 20c719677a28afa1d1b912b9fadbf384e9e65de7
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 22 17:01:19 2014 +1100

    ctdb/daemon: Optimise deletion of IPs
    
    Previous commits maintained the ordering between
    ctdb_remove_orphaned_ifaces() and ctdb_vnn_unassign_iface().  This
    meant that ctdb_remove_orphaned_ifaces() needed to steal the orphaned
    interfaces and they would be freed later.
    
    Unassign the interface first and things get simpler.
    ctdb_remove_orphaned_ifaces() is now self-contained.
    
    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): Sun Mar 23 06:20:43 CET 2014 on sn-devel-104

commit 9b907536fb657fa15c02858caf0ffff633ecd478
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 22 13:30:47 2014 +1100

    ctdb/daemon: Make delete IP wait until the IP is released
    
    reloadips really expects deleted IPs to be released before completing.
    Otherwise the recovery daemon starts failing the local IP check.  The
    races that follow can cause a node to be banned.
    
    To make the error handling simple, do the actual deletion in
    release_ip_callback().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit bafb9151ccb5722df36f9ba168716f4f4fa01cdc
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 28 15:54:05 2014 +1100

    ctdb-tests: Improve tickle tests
    
    It is hard to diagnose failures in the NFS tickle test because there's
    no way of telling if the test node doesn't have the tickle or if it
    didn't get propagated.
    
    Factor out check_tickles() into local.bash and give it some
    parameters.
    
    Have the NFS test call it first to ensure the tickle has been
    registered.  Then use new function check_tickles_all() to ensure the
    tickle has been propagated to all nodes.  Give this a bit of extra
    time (double the timeout) just in case we're racing with the update.
    
    Add a useful comment to the CIFS test so that I stop asking myself how
    the test could ever have worked reliably.  :-)
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 058e14cdb0b6eb2e999dca599961ae6734105f99
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 14 13:14:18 2014 +1100

    ctdb-eventscripts: Fix regression in IP add/delete functions
    
    Commit 176ae6c704528c021fcc34a41878584f43a00119 caused these functions
    to exit on failure.  This is incorrect and broke NAT gateway.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ecafbce1b1cf53ae8c3de9eb5201192f7fe1f67d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Mar 4 15:06:11 2014 +1100

    ctdb-daemon: Do not disable monitoring when running eventscripts
    
    This is racy and cbffbb7c2f406fc1d8ebad3c531cc2757232690e makes it
    unnecessary.
    
    The eventscript code still knows that monitor events are special
    compared to other events.  However, the general concept of monitoring
    is no longer tangled up with running scripts.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 87d58fd07b1294688b8fc6dbdf3dbb6cb12d3a80
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 05:50:14 2014 +1100

    ctdb-eventscripts: Attach to persistent ctdb.tdb in "startup" event
    
    "statd-callout notify" currently complains until an add-client or
    del-client is done.
    
    Given that we might use ctdb.tdb for something else in the future it
    makes sense attach to it in the "startup" event.  This could be done
    in the background but it should be so lightweight that a timeout will
    indicate serious problems.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 4f79fa6c7c843502fcdaa2dead534ea3719b9f69
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 13 16:53:15 2014 +1100

    ctdb-daemon: Fix tickle updates to recently started nodes
    
    Commit 0723fedcedd4a97870f7b1224945f1587363c9bf added a cheap
    implemention of ctdb_control_startup() that simply flags the recipient
    node as needing to send updates for each IP when the tickle update
    loop next fires.  Commit 026996550d726836091ff5ebd1ebf925bf237bb0
    ensures that a node only sends tickle updates once being flagged to do
    so.
    
    CTDB_CONTROL_STARTUP is broadcast to all nodes, so this is a good
    start.  However, the tickle updates are only broadcast to connected
    nodes.  A recently started node may not yet be considered to be
    connected because the keepalive monitoring loop may not yet have
    marked the node as connected.  This means that the tickle update loop
    races with the keepalive monitoring loop.  If the tickle update loop
    wins then updates will not be sent to the recently started node.
    
    The simplest improvement is to stop the tickle update from depending
    on whether a node is connected or not.  So instead of broadcasting
    tickle updates to connected nodes, they are broadcast to all nodes.
    Since no reply is expected, this should work just fine.
    
    While looking at this code, ctdb_ctrl_set_tcp_tickles() is named like
    a client function.  It isn't a client function.  Also, 2 of the
    arguments are ignored.  So rename this function to
    ctdb_send_set_tcp_tickles_for_ip() and remove the ignored arguments.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>

commit 441e0998370bfd7b0de5dd9aed7e2abbcf64cf73
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 13:20:06 2014 +1100

    ctdb-tools-ctdb: Parse IP addresses when reading a list from a file
    
    This way this logic is centralised.  It also means that the IP address
    comparisons in the NAT gateway code are IPv6 safe.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit fad2b6b074495eb1dc036cce293456857985f8f5
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 16:23:42 2014 +1100

    ctdb-tools-ctdb: Remove redundant filtering of trailing empty lines
    
    There is a check for empty lines in the loop just below.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 555aa06c41e7f77bf241e04ccf771009645e9c27
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 13:04:25 2014 +1100

    ctdb-tools-ctdb: Use DLIST_ADD_END() to avoid reversing the list
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 91895b33c52c0a81904c3ea36042d4574422f5fd
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 12:57:30 2014 +1100

    ctdb-tools-ctdb: Factor out function read_pnn_node_file()
    
    Factor it from read_nodes_file().  Use it there and in
    read_natgw_nodes_file().
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 79d28000043bd463beecaeac47855d3a4970eaf2
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 17 13:42:35 2014 +1100

    ctdb-tests: Add "ctdb listnodes" and "ctdb xpnn" stub tests
    
    Tests for xpnn need to implement a stub for ctdb_sys_have_ip().  The
    cheapest way of doing this is to read a fake nodemap using the
    existing code and check if the IP of the "current" node is the one
    being asked about.  However, the fake state initialisation isn't
    currently available to without_daemon commands because it is meant to
    represent daemon state.  However, it can be made available by moving
    the relevant code into a new stub for tevent_context_init().  The stub
    still needs to initialise a tevent context - this can be done by
    calling a lower level function.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 9bede494743f0ce13493fe718ed8f0c3c5f2959c
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 12:45:23 2014 +1100

    ctdb-tools-ctdb: Read NAT gateway nodes from a separate function
    
    Now it gets easier to refactor.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit ba69742ccd822562ca2135d2466e09bf1216644b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 3 11:41:32 2014 +1100

    ctdb-tools-ctdb: Add and use function filter_nodemap_by_natgw_nodes()
    
    Add another filter function, like the ones for capabilities and flags
    to, for filtering by NAT gateway nodes.  This makes the main
    natgw_list function more readable.
    
    Note that this drops the early filtering of disconnected nodes, so
    they will now be listed in a NAT gateway group.  This makes sense.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit e728a35dc19c397cb17e1bf434401df25c35f337
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Feb 19 18:45:18 2014 +1100

    ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_flags()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 26c9a591e539e33dd0896ec1e2958192b3e4efd4
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Feb 19 17:12:08 2014 +1100

    ctdb-tools-ctdb: Update LVS commands to use filter_nodemap_by_capabilities()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 5fb7e386ac4452786512d077a00b4907ef39cb51
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 28 20:16:34 2014 +1100

    ctdb-tools-ctdb: Fixes for "lvs" and "lvsmaster" commands
    
    The index of the nodes array in nodemap isn't the PNN.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 33b1fcbd7083668cfd58b1cfb1172b6134cd07ca
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 17:11:53 2014 +1100

    ctdb-tools-ctdb: Generalise find_natgw() -> filter_nodemap_by_flags()
    
    Instead of just finding the first node that doesn't have any flags in
    flag_mask set, change it into a function that filters a nodemap to
    exclude nodes with the given flags.
    
    This makes the NATGW code simpler but also provides a function that
    can be used in other code.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 798bd58370f6ea7bc70db96edd23ae86caf6bf79
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 15:52:37 2014 +1100

    ctdb-tools-ctdb: Update natgwlist to filter nodes by NATGW capability
    
    Check capabilities once to build a filtered node list instead of
    repeatedly checking capabilities
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 771005386403acf15a81be5de2a3798384a37d8a
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 12:29:44 2014 +1100

    ctdb-tests: New natgwlist tests where nodes capability not set
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 75cf99b9da1677fa83197d111d757e14041dae05
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 12:12:06 2014 +1100

    ctdb-tests: Update ctdb stub LVS tests and add some new ones
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 3af858e6f4990599c23b54d05c42187400fd1426
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 11:34:11 2014 +1100

    ctdb-tests: Support fake capabilities in CTDB tool stub
    
    ... and add a test to make sure it works.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 263e5eabf8d55c7f53db597b8fcede831c211e45
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Feb 18 11:02:49 2014 +1100

    ctdb-tests: Remove old, unused copy of a CTDB tool unit test
    
    This looks to have got left behind a long time ago when things got
    moved around...
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit a947cf6c0c3e1453ec833033dcd2edaa9490a55b
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Mar 17 13:28:14 2014 +1100

    ctdb-tools-ctdb: Don't close stderr when running without_daemon commands
    
    It looks like the original without_daemon code still tried to
    establish a client connection to the daemon.  Closing stderr looks to
    be a cheap way of hiding the errors when this failed.
    
    However, later cleanups avoid the client connection altogether, so do
    not close stderr.  Now debug output from without_daemon commands
    actually appears.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/config/events.d/00.ctdb                       |    3 +-
 ctdb/config/functions                              |   12 +-
 ctdb/include/ctdb_private.h                        |    9 +-
 ctdb/server/ctdb_control.c                         |    3 +-
 ctdb/server/ctdb_takeover.c                        |  150 ++++--
 ctdb/server/eventscript.c                          |    5 -
 ctdb/tests/complex/31_nfs_tickle.sh                |   24 +-
 ctdb/tests/complex/32_cifs_tickle.sh               |   12 +-
 ctdb/tests/complex/scripts/local.bash              |   29 ++
 ctdb/tests/src/ctdb_test.c                         |    8 +
 ctdb/tests/src/ctdb_test_stubs.c                   |   60 +++-
 ctdb/tests/tool/scripts/local.sh                   |   11 +
 ctdb/tests/tool/stubby.getcapabilities.004.sh      |   57 +++
 ctdb/tests/tool/stubby.listnodes.001.sh            |   20 +
 ctdb/tests/tool/stubby.listnodes.002.sh            |   20 +
 ctdb/tests/tool/stubby.lvs.001.sh                  |    3 +-
 ctdb/tests/tool/stubby.lvs.002.sh                  |   29 ++
 ctdb/tests/tool/stubby.lvs.003.sh                  |   28 ++
 ctdb/tests/tool/stubby.lvsmaster.001.sh            |    3 +-
 ctdb/tests/tool/stubby.lvsmaster.002.sh            |    1 -
 ctdb/tests/tool/stubby.lvsmaster.003.sh            |   27 ++
 ctdb/tests/tool/stubby.lvsmaster.004.sh            |   27 ++
 ctdb/tests/tool/stubby.lvsmaster.005.sh            |   27 ++
 ctdb/tests/tool/stubby.lvsmaster.006.sh            |   27 ++
 ctdb/tests/tool/stubby.lvsmaster.007.sh            |   27 ++
 ctdb/tests/tool/stubby.natgwlist.006.sh            |   37 ++
 ctdb/tests/tool/stubby.natgwlist.007.sh            |   37 ++
 ctdb/tests/tool/stubby.xpnn.001.sh                 |   20 +
 ctdb/tests/tool/stubby.xpnn.002.sh                 |   20 +
 ctdb/tests/tool/stubby.xpnn.003.sh                 |   24 +
 ctdb/tests/tool/testcases/stubby.nodestatus.005.sh |   34 --
 ctdb/tools/ctdb.c                                  |  493 ++++++++++----------
 32 files changed, 916 insertions(+), 371 deletions(-)
 create mode 100755 ctdb/tests/tool/stubby.getcapabilities.004.sh
 create mode 100755 ctdb/tests/tool/stubby.listnodes.001.sh
 create mode 100755 ctdb/tests/tool/stubby.listnodes.002.sh
 create mode 100755 ctdb/tests/tool/stubby.lvs.002.sh
 create mode 100755 ctdb/tests/tool/stubby.lvs.003.sh
 create mode 100755 ctdb/tests/tool/stubby.lvsmaster.003.sh
 create mode 100755 ctdb/tests/tool/stubby.lvsmaster.004.sh
 create mode 100755 ctdb/tests/tool/stubby.lvsmaster.005.sh
 create mode 100755 ctdb/tests/tool/stubby.lvsmaster.006.sh
 create mode 100755 ctdb/tests/tool/stubby.lvsmaster.007.sh
 create mode 100755 ctdb/tests/tool/stubby.natgwlist.006.sh
 create mode 100755 ctdb/tests/tool/stubby.natgwlist.007.sh
 create mode 100755 ctdb/tests/tool/stubby.xpnn.001.sh
 create mode 100755 ctdb/tests/tool/stubby.xpnn.002.sh
 create mode 100755 ctdb/tests/tool/stubby.xpnn.003.sh
 delete mode 100755 ctdb/tests/tool/testcases/stubby.nodestatus.005.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 719bee8..a0f4102 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -196,12 +196,13 @@ case "$1" in
 	fi
 	;;
 
-     setup)
+    setup)
 	# Set any tunables from the config file
 	set_ctdb_variables || die "Failed to set CTDB tunables"
 	;;
 
     startup)
+	ctdb attach ctdb.tdb persistent
 	update_config_from_tdb &
 	;;
     monitor)
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 6efe60f..6bc0312 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -832,8 +832,10 @@ add_ip_to_iface ()
     ip link set "$_iface" up || \
 	die "Failed to bringup interface $_iface"
 
-    ip addr add "$_ip/$_maskbits" brd + dev "$_iface" || \
-	die "Failed to add $_ip/$_maskbits on dev $_iface"
+    ip addr add "$_ip/$_maskbits" brd + dev "$_iface" || {
+	echo "Failed to add $_ip/$_maskbits on dev $_iface"
+	return 1
+    }
 }
 
 delete_ip_from_iface()
@@ -849,8 +851,10 @@ delete_ip_from_iface()
     # remembering and re-adding secondaries.
     set_proc "sys/net/ipv4/conf/${_iface}/promote_secondaries" 1
 
-    ip addr del "$_ip/$_maskbits" dev "$_iface" || \
-	die "Failed to del $_ip on dev $_iface"
+    ip addr del "$_ip/$_maskbits" dev "$_iface" || {
+	echo "Failed to del $_ip on dev $_iface"
+	return 1
+    }
 }
 
 # If the given IP is hosted then print 2 items: maskbits and iface 
diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h
index b95b2c7..8ed867d 100644
--- a/ctdb/include/ctdb_private.h
+++ b/ctdb/include/ctdb_private.h
@@ -212,6 +212,11 @@ struct ctdb_vnn {
 	/* Set to true any time an update to this VNN is in flight.
 	   This helps to avoid races. */
 	bool update_in_flight;
+
+	/* If CTDB_CONTROL_DEL_PUBLIC_IP is received for this IP
+	 * address then this flag is set.  It will be deleted in the
+	 * release IP callback. */
+	bool delete_pending;
 };
 
 /*
@@ -1264,7 +1269,9 @@ int32_t ctdb_control_list_tunables(struct ctdb_context *ctdb, TDB_DATA *outdata)
 int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
 int32_t ctdb_control_receive_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
 int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
-int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata);
+int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
+					struct ctdb_req_control *c,
+					TDB_DATA recdata, bool *async_reply);
 
 void ctdb_tunables_set_defaults(struct ctdb_context *ctdb);
 
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c
index 581c478..b407a1f 100644
--- a/ctdb/server/ctdb_control.c
+++ b/ctdb/server/ctdb_control.c
@@ -481,7 +481,8 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 		return ctdb_control_add_public_address(ctdb, indata);
 
 	case CTDB_CONTROL_DEL_PUBLIC_IP:
-		return ctdb_control_del_public_address(ctdb, indata);
+		return ctdb_control_del_public_address(ctdb, c, indata,
+						       async_reply);
 
 	case CTDB_CONTROL_GET_CAPABILITIES:
 		return ctdb_control_get_capabilities(ctdb, outdata);
diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c
index 34b210e..bbb0226 100644
--- a/ctdb/server/ctdb_takeover.c
+++ b/ctdb/server/ctdb_takeover.c
@@ -118,19 +118,20 @@ static bool vnn_has_interface_with_name(struct ctdb_vnn *vnn,
  * causes problems...  :-)
  */
 static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
-					struct ctdb_vnn *vnn,
-					TALLOC_CTX *mem_ctx)
+					struct ctdb_vnn *vnn)
 {
 	struct ctdb_iface *i;
 
 	/* For each interface, check if there's an IP using it. */
-	for(i=ctdb->ifaces; i; i=i->next) {
+	i = ctdb->ifaces;
+	while (i != NULL) {
 		struct ctdb_vnn *tv;
 		bool found;
+		struct ctdb_iface *next = i->next;
 
 		/* Only consider interfaces named in the given VNN. */
 		if (!vnn_has_interface_with_name(vnn, i->name)) {
-			continue;
+			goto next;
 		}
 
 		/* Is the "single IP" on this interface? */
@@ -138,7 +139,7 @@ static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
 		    (ctdb->single_ip_vnn->ifaces[0] != NULL) &&
 		    (strcmp(i->name, ctdb->single_ip_vnn->ifaces[0]) == 0)) {
 			/* Found, next interface please... */
-			continue;
+			goto next;
 		}
 		/* Search for a vnn with this interface. */
 		found = false;
@@ -152,9 +153,11 @@ static void ctdb_remove_orphaned_ifaces(struct ctdb_context *ctdb,
 		if (!found) {
 			/* None of the VNNs are using this interface. */
 			DLIST_REMOVE(ctdb->ifaces, i);
-			/* Caller will free mem_ctx when convenient. */
-			talloc_steal(mem_ctx, i);
+			talloc_free(i);
 		}
+
+	next:
+		i = next;
 	}
 }
 
@@ -260,6 +263,10 @@ static bool ctdb_vnn_available(struct ctdb_context *ctdb,
 {
 	int i;
 
+	if (vnn->delete_pending) {
+		return false;
+	}
+
 	if (vnn->iface && vnn->iface->link_up) {
 		return true;
 	}
@@ -865,6 +872,14 @@ static void release_kill_clients(struct ctdb_context *ctdb, ctdb_sock_addr *addr
 	}
 }
 
+static void do_delete_ip(struct ctdb_context *ctdb, struct ctdb_vnn *vnn)
+{
+	DLIST_REMOVE(ctdb->vnn, vnn);
+	ctdb_vnn_unassign_iface(ctdb, vnn);
+	ctdb_remove_orphaned_ifaces(ctdb, vnn);
+	talloc_free(vnn);
+}
+
 /*
   called when releaseip event finishes
  */
@@ -903,6 +918,12 @@ static void release_ip_callback(struct ctdb_context *ctdb, int status,
 
 	ctdb_vnn_unassign_iface(ctdb, state->vnn);
 
+	/* Process the IP if it has been marked for deletion */
+	if (state->vnn->delete_pending) {
+		do_delete_ip(ctdb, state->vnn);
+		state->vnn = NULL;
+	}
+
 	/* the control succeeded */
 	ctdb_request_control_reply(ctdb, state->c, NULL, 0, NULL);
 	talloc_free(state);
@@ -910,7 +931,9 @@ static void release_ip_callback(struct ctdb_context *ctdb, int status,
 
 static int ctdb_releaseip_destructor(struct takeover_callback_state *state)
 {
-	state->vnn->update_in_flight = false;
+	if (state->vnn != NULL) {
+		state->vnn->update_in_flight = false;
+	}
 	return 0;
 }
 
@@ -3959,10 +3982,9 @@ int32_t ctdb_control_get_tcp_tickle_list(struct ctdb_context *ctdb, TDB_DATA ind
 /*
   set the list of all tcp tickles for a public address
  */
-static int ctdb_ctrl_set_tcp_tickles(struct ctdb_context *ctdb, 
-			      struct timeval timeout, uint32_t destnode, 
-			      ctdb_sock_addr *addr,
-			      struct ctdb_tcp_array *tcparray)
+static int ctdb_send_set_tcp_tickles_for_ip(struct ctdb_context *ctdb,
+					    ctdb_sock_addr *addr,
+					    struct ctdb_tcp_array *tcparray)
 {
 	int ret, num;
 	TDB_DATA data;
@@ -3987,7 +4009,7 @@ static int ctdb_ctrl_set_tcp_tickles(struct ctdb_context *ctdb,
 		memcpy(&list->tickles.connections[0], tcparray->connections, sizeof(struct ctdb_tcp_connection) * num);
 	}
 
-	ret = ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_CONNECTED, 0, 
+	ret = ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
 				       CTDB_CONTROL_SET_TCP_TICKLE_LIST,
 				       0, CTDB_CTRL_FLAG_NOREPLY, data, NULL, NULL);
 	if (ret != 0) {
@@ -4023,11 +4045,9 @@ static void ctdb_update_tcp_tickles(struct event_context *ev,
 		if (!vnn->tcp_update_needed) {
 			continue;
 		}
-		ret = ctdb_ctrl_set_tcp_tickles(ctdb, 
-				TAKEOVER_TIMEOUT(),
-				CTDB_BROADCAST_CONNECTED,
-				&vnn->public_address,
-				vnn->tcp_array);
+		ret = ctdb_send_set_tcp_tickles_for_ip(ctdb,
+						       &vnn->public_address,
+						       vnn->tcp_array);
 		if (ret != 0) {
 			DEBUG(DEBUG_ERR,("Failed to send the tickle update for public address %s\n",
 				ctdb_addr_to_str(&vnn->public_address)));
@@ -4168,20 +4188,32 @@ int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA inda
 	return 0;
 }
 
+struct delete_ip_callback_state {
+	struct ctdb_req_control *c;
+};
+
 /*
   called when releaseip event finishes for del_public_address
  */
-static void delete_ip_callback(struct ctdb_context *ctdb, int status, 
-				void *private_data)
+static void delete_ip_callback(struct ctdb_context *ctdb,
+			       int32_t status, TDB_DATA data,
+			       const char *errormsg,
+			       void *private_data)
 {
+	struct delete_ip_callback_state *state =
+		talloc_get_type(private_data, struct delete_ip_callback_state);
+
+	/* If release failed then fail. */
+	ctdb_request_control_reply(ctdb, state->c, NULL, status, errormsg);
 	talloc_free(private_data);
 }
 
-int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata)
+int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb,
+					struct ctdb_req_control *c,
+					TDB_DATA indata, bool *async_reply)
 {
 	struct ctdb_control_ip_iface *pub = (struct ctdb_control_ip_iface *)indata.dptr;
 	struct ctdb_vnn *vnn;
-	int ret;
 
 	/* verify the size of indata */
 	if (indata.dsize < offsetof(struct ctdb_control_ip_iface, iface)) {
@@ -4204,37 +4236,63 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
 	/* walk over all public addresses until we find a match */
 	for (vnn=ctdb->vnn;vnn;vnn=vnn->next) {
 		if (ctdb_same_ip(&vnn->public_address, &pub->addr)) {
-			TALLOC_CTX *mem_ctx = talloc_new(ctdb);
-
-			DLIST_REMOVE(ctdb->vnn, vnn);
-			talloc_steal(mem_ctx, vnn);
-			ctdb_remove_orphaned_ifaces(ctdb, vnn, mem_ctx);
-			if (vnn->pnn != ctdb->pnn) {
-				if (vnn->iface != NULL) {
-					ctdb_vnn_unassign_iface(ctdb, vnn);
+			if (vnn->pnn == ctdb->pnn) {
+				struct delete_ip_callback_state *state;
+				struct ctdb_public_ip *ip;
+				TDB_DATA data;
+				int ret;
+
+				vnn->delete_pending = true;
+
+				state = talloc(ctdb,
+					       struct delete_ip_callback_state);
+				CTDB_NO_MEMORY(ctdb, state);
+				state->c = c;
+
+				ip = talloc(state, struct ctdb_public_ip);
+				if (ip == NULL) {
+					DEBUG(DEBUG_ERR,
+					      (__location__ " Out of memory\n"));
+					talloc_free(state);
+					return -1;
+				}
+				ip->pnn = -1;
+				ip->addr = pub->addr;
+
+				data.dsize = sizeof(struct ctdb_public_ip);
+				data.dptr = (unsigned char *)ip;
+
+				ret = ctdb_daemon_send_control(ctdb,
+							       ctdb_get_pnn(ctdb),
+							       0,
+							       CTDB_CONTROL_RELEASE_IP,
+							       0, 0,
+							       data,
+							       delete_ip_callback,
+							       state);
+				if (ret == -1) {
+					DEBUG(DEBUG_ERR,
+					      (__location__ "Unable to send "
+					       "CTDB_CONTROL_RELEASE_IP\n"));
+					talloc_free(state);
+					return -1;
 				}
-				talloc_free(mem_ctx);
-				return 0;
-			}
-			vnn->pnn = -1;
 
-			ret = ctdb_event_script_callback(ctdb, 
-					 mem_ctx, delete_ip_callback, mem_ctx,
-					 CTDB_EVENT_RELEASE_IP,
-					 "%s %s %u",
-					 ctdb_vnn_iface_string(vnn),
-					 ctdb_addr_to_str(&vnn->public_address),
-					 vnn->public_netmask_bits);
-			if (vnn->iface != NULL) {
-				ctdb_vnn_unassign_iface(ctdb, vnn);
-			}
-			if (ret != 0) {
-				return -1;
+				state->c = talloc_steal(state, c);
+				*async_reply = true;
+			} else {
+				/* This IP is not hosted on the
+				 * current node so just delete it
+				 * now. */
+				do_delete_ip(ctdb, vnn);
 			}
+
 			return 0;
 		}
 	}
 
+	DEBUG(DEBUG_ERR,("Delete IP of unknown public IP address %s\n",
+			 ctdb_addr_to_str(&pub->addr)));
 	return -1;
 }
 
diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c
index ed20124..bf95b21 100644
--- a/ctdb/server/eventscript.c
+++ b/ctdb/server/eventscript.c
@@ -901,8 +901,6 @@ static void run_eventscripts_callback(struct ctdb_context *ctdb, int status,
 	struct eventscript_callback_state *state = 
 		talloc_get_type(private_data, struct eventscript_callback_state);
 
-	ctdb_enable_monitoring(ctdb);
-
 	if (status != 0) {
 		DEBUG(DEBUG_ERR,(__location__ " Failed to run eventscripts\n"));
 	}
@@ -966,14 +964,11 @@ int32_t ctdb_run_eventscripts(struct ctdb_context *ctdb,
 
 	DEBUG(DEBUG_NOTICE,("Running eventscripts with arguments %s\n", indata.dptr));
 
-	ctdb_disable_monitoring(ctdb);
-
 	ret = ctdb_event_script_callback(ctdb, 
 			 state, run_eventscripts_callback, state,
 			 call, "%s", options);
 
 	if (ret != 0) {
-		ctdb_enable_monitoring(ctdb);
 		DEBUG(DEBUG_ERR,(__location__ " Failed to run eventscripts with arguments %s\n", indata.dptr));
 		talloc_free(state);
 		return -1;
diff --git a/ctdb/tests/complex/31_nfs_tickle.sh b/ctdb/tests/complex/31_nfs_tickle.sh
index b5ed47e..5aeb870 100755
--- a/ctdb/tests/complex/31_nfs_tickle.sh
+++ b/ctdb/tests/complex/31_nfs_tickle.sh
@@ -34,8 +34,8 @@ Steps:
 
 Expected results:
 
-* CTDB should correctly record the socket in the nfs-tickles directory
-  and should send a reset packet when the node is disabled.
+* CTDB should correctly record the socket and should send a reset
+  packet when the node is disabled.
 EOF
 }
 
@@ -58,6 +58,8 @@ monitor_interval="${out#*= }"
 #echo "Monitor interval on node $test_node is $monitor_interval seconds."
 
 select_test_node_and_ips
+try_command_on_node $test_node "$CTDB listnodes | wc -l"
+numnodes="$out"
 
 test_port=2049
 
@@ -73,18 +75,16 @@ echo "Source socket is $src_socket"
 
 wait_for_monitor_event $test_node
 
-echo "Sleeping until tickles are synchronised across nodes..."
-try_command_on_node $test_node $CTDB getvar TickleUpdateInterval
-sleep_for "${out#*= }"
+echo "Wait until NFS connection is tracked by CTDB on test node ..."
+wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
 
-try_command_on_node -v any "ctdb -Y gettickles $test_ip $test_port"
+echo "Getting TicklesUpdateInterval..."
+try_command_on_node $test_node $CTDB getvar TickleUpdateInterval
+update_interval="$out"
 
-if [ "${out/${src_socket}/}" != "$out" ] ; then
-    echo "GOOD: NFS connection tracked OK."
-else
-    echo "BAD: Socket not tracked in NFS tickles."
-    testfailures=1
-fi
+echo "Wait until NFS connection is tracked by CTDB on all nodes..."
+wait_until $(($update_interval * 2)) \
+    check_tickles_all $numnodes  $test_ip $test_port $src_socket
 
 tcptickle_sniff_start $src_socket "${test_ip}:${test_port}"
 
diff --git a/ctdb/tests/complex/32_cifs_tickle.sh b/ctdb/tests/complex/32_cifs_tickle.sh
index 93634e7..70ce93f 100755
--- a/ctdb/tests/complex/32_cifs_tickle.sh
+++ b/ctdb/tests/complex/32_cifs_tickle.sh
@@ -72,15 +72,8 @@ echo "Source socket is $src_socket"
 
 # This should happen as soon as connection is up... but unless we wait
 # we sometimes beat the registration.
-check_tickles ()
-{
-    try_command_on_node 0 ctdb gettickles $test_ip -n $test_node
-    # SRC: 10.0.2.45:49091   DST: 10.0.2.143:445
-    [ "${out/SRC: ${src_socket} /}" != "$out" ]
-}
-
 echo "Checking if CIFS connection is tracked by CTDB..."
-wait_until 10 check_tickles
+wait_until 10 check_tickles $test_node $test_ip $test_port $src_socket
 echo "$out"
 
 if [ "${out/SRC: ${src_socket} /}" != "$out" ] ; then
@@ -92,6 +85,9 @@ fi
 
 tcptickle_sniff_start $src_socket "${test_ip}:${test_port}"
 
+# The test node is only being disabled so the tickling is done from
+# the test node.  We don't need to wait until the tickles are
+# transferred to another node.
 echo "Disabling node $test_node"
 try_command_on_node 1 $CTDB disable -n $test_node
 wait_until_node_has_status $test_node disabled
diff --git a/ctdb/tests/complex/scripts/local.bash b/ctdb/tests/complex/scripts/local.bash
index eb4c41c..6fbc1ae 100644
--- a/ctdb/tests/complex/scripts/local.bash
+++ b/ctdb/tests/complex/scripts/local.bash
@@ -29,6 +29,35 @@ wait_until_get_src_socket ()
 
 #######################################
 
+check_tickles ()
+{
+    local node="$1"
+    local test_ip="$2"
+    local test_port="$3"
+    local src_socket="$4"
+    try_command_on_node $node ctdb gettickles $test_ip $test_port
+    # SRC: 10.0.2.45:49091   DST: 10.0.2.143:445
+    [ "${out/SRC: ${src_socket} /}" != "$out" ]
+}
+
+check_tickles_all ()
+{
+    local numnodes="$1"
+    local test_ip="$2"
+    local test_port="$3"
+    local src_socket="$4"
+
+    try_command_on_node all ctdb gettickles $test_ip $test_port
+    # SRC: 10.0.2.45:49091   DST: 10.0.2.143:445
+    local t="${src_socket//./\\.}"
+    local count=$(grep -E -c "SRC: ${t} " <<<"$out" || true)
+    [ $count -eq $numnodes ]
+}
+
+
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list