[SCM] Samba Shared Repository - branch v4-11-test updated

Karolin Seeger kseeger at samba.org
Tue Aug 25 15:14:05 UTC 2020


The branch, v4-11-test has been updated
       via  3d7572b4032 ctdb-recoverd: Rename update_local_flags() -> update_flags()
       via  c348d7a5878 ctdb-recoverd: Change update_local_flags() to use already retrieved nodemaps
       via  7723e7d23d7 ctdb-recoverd: Get remote nodemaps earlier
       via  1956ee1f6b8 ctdb-recoverd: Do not fetch the nodemap from the recovery master
       via  8faae66a253 ctdb-recoverd: Change get_remote_nodemaps() to use connected nodes
       via  238564c7495 ctdb-recoverd: Fix node_pnn check and assignment of nodemap into array
       via  d1f01ff312b ctdb-recoverd: Add fail callback to assign banning credits
       via  90c0609df4c ctdb-recoverd: Add an intermediate state struct for nodemap fetching
       via  b0d4ae271de ctdb-recoverd: Move memory allocation into get_remote_nodemaps()
       via  942db2b3d27 ctdb-recoverd: Change signature of get_remote_nodemaps()
       via  9e52bb0c5c6 ctdb-recoverd: Fix a local memory leak
       via  55216cda607 ctdb-recoverd: Basic cleanups for get_remote_nodemaps()
       via  660f584477a ctdb-recoverd: Simplify calculation of new flags
       via  d8e6304a2bd ctdb-recoverd: Correctly find nodemap entry for pnn
       via  94a9842af6c ctdb-recoverd: Do not retrieve nodemap from recovery master
       via  c33e8703c10 ctdb-recoverd: Flatten update_flags_on_all_nodes()
       via  94416b40b7e ctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c
       via  d1b1da94eb1 ctdb-recoverd: Improve a call to update_flags_on_all_nodes()
       via  6419e3de633 ctdb-recoverd: Use update_flags_on_all_nodes()
       via  fffe852285b ctdb-recoverd: Introduce some local variables to improve readability
       via  34bc583a7f1 ctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument
       via  cea37c849ce ctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()
       via  051a9021d50 lib/util: do not install /usr/bin/test_util
      from  7cfb6f6db61 VERSION: Bump version up to 4.11.13...

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-11-test


- Log -----------------------------------------------------------------
commit 3d7572b40324f0ca0f72a799a2fc94e0077e1fd3
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 24 10:21:37 2018 +1100

    ctdb-recoverd: Rename update_local_flags() -> update_flags()
    
    This also updates remote flags so the name is misleading.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 4aa8e72d60e92951b35190d2ffcfdb1bfb756609)
    
    Autobuild-User(v4-11-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-11-test): Tue Aug 25 15:13:03 UTC 2020 on sn-devel-184

commit c348d7a58786f34d03737ff89be0d26538a15452
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 20:35:55 2018 +1100

    ctdb-recoverd: Change update_local_flags() to use already retrieved nodemaps
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 702c7c4934e79a9161fdc59df70df30ae492d89f)

commit 7723e7d23d7d02d281584b9ca74c966a6e3dc4e1
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 14 03:51:01 2019 +1000

    ctdb-recoverd: Get remote nodemaps earlier
    
    update_local_flags() will be changed to use these nodemaps.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 910a0b3b747a987ba69b6a0b6256e964b7d85dfe)

commit 1956ee1f6b8d03aad37300e318af7b5aea5e11ff
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Jun 14 00:23:22 2019 +1000

    ctdb-recoverd: Do not fetch the nodemap from the recovery master
    
    The nodemap has already been fetched from the local node and is
    actually passed to this function.  Care must be taken to avoid
    referencing the "remote" nodemap for the recovery master.  It also
    isn't useful to do so, since it would be the same nodemap.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d50919b0cb28f299c9b6985271b29d4f27c5f619)

commit 8faae66a253840e403cd3f66c8fff2ae7aec680c
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 20:02:42 2018 +1100

    ctdb-recoverd: Change get_remote_nodemaps() to use connected nodes
    
    The plan here is to use the nodemaps retrieved by get_remote_nodes()
    in update_local_flags().  This will improve efficiency, since
    get_remote_nodes() fetches flags from nodes in parallel.  It also
    means that get_remote_nodes() can be used exactly once early on in
    main_loop() to retrieve remote nodemaps.  Retrieving nodemaps multiple
    times is unnecessary and racy - a single monitoring iteration should
    not fetch flags multiple times and compare them.
    
    This introduces a temporary behaviour change but it will be of no
    consequence when the above changes are made.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 762d1d8a9605f97973a2c1176de5d29fcc61d15a)

commit 238564c74957f5488ebdbc5d779726e83e41b1c7
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jul 30 11:57:51 2020 +1000

    ctdb-recoverd: Fix node_pnn check and assignment of nodemap into array
    
    This array is indexed by the same index as nodemap, not the PNN.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 368c83bfe3bbfff568d14f65e7b1ffa41d5349ac)

commit d1f01ff312b74f28975910d6ef936b2ecacb8ff9
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 19:58:15 2018 +1100

    ctdb-recoverd: Add fail callback to assign banning credits
    
    Also drop error handling in main_loop() that is replaced by this
    change.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 10ce0dbf1c11eaaab7b28b6bbd014235a36d1962)

commit 90c0609df4ced66ae4dcc9d486c25d1f30a1efc9
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 19:52:22 2018 +1100

    ctdb-recoverd: Add an intermediate state struct for nodemap fetching
    
    This will allow an error callback to be added.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit a079ee31690cf7110f46b41989ffcfb83b7626d6)

commit b0d4ae271decb51485a5e6f82d9004341bf4ba0e
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 16:31:39 2018 +1100

    ctdb-recoverd: Move memory allocation into get_remote_nodemaps()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 2eaa0af6160588b6e3364b181d0976477d12b51b)

commit 942db2b3d27236506c3a98ce2cc8f4975e01aed2
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 16:41:19 2018 +1100

    ctdb-recoverd: Change signature of get_remote_nodemaps()
    
    Change 1st argument to a rec context, since this will be needed later.
    Drop the nodemap argument and access it via rec->nodemap instead.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 3324dd272c7dafa92cd9c3fd0af8f50084bcdaaa)

commit 9e52bb0c5c613b5e4b141b8268f1e10fe66a9c18
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Aug 17 20:27:18 2020 +1000

    ctdb-recoverd: Fix a local memory leak
    
    The memory is allocated off the memory context used by the current
    iteration of main loop.  It is freed when main loop completes the fix
    doesn't require backporting to stable branches.  However, it is sloppy
    so it is worth fixing.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d2d90f250214582d7124b8137aa2cf5032b2f285)

commit 55216cda60719012109856f0e2d71de510c552c2
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 16:19:36 2018 +1100

    ctdb-recoverd: Basic cleanups for get_remote_nodemaps()
    
    Don't log an error on failure - let the caller can do this.  Apart
    from this: fix up coding style and modernise the remaining error
    message.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14466
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 52f520d39cd92e1cf2413fd7e0dd362debd6f463)

commit 660f584477adb523a5f4849fe23610d816b63a54
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 14 14:29:09 2020 +1000

    ctdb-recoverd: Simplify calculation of new flags
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Martin Schwenke <martins at samba.org>
    Autobuild-Date(master): Fri Jul 24 06:03:23 UTC 2020 on sn-devel-184
    
    (cherry picked from commit 5ce6133a75107abdcb9fcfd93bc7594812dc5055)

commit d8e6304a2bda438194b685411fa0896f26c4b896
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 14 14:22:15 2020 +1000

    ctdb-recoverd: Correctly find nodemap entry for pnn
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 3654e416770cc7521dcc3c15976daeba37023304)

commit 94a9842af6c65c360053f21680c9da862f8338c5
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 5 23:49:05 2020 +1000

    ctdb-recoverd: Do not retrieve nodemap from recovery master
    
    It is already in rec->nodemap.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 9475ab044161e687b9ced3a477746393565b49b1)

commit c33e8703c1088c8e04e9088185300eaeebe13d54
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Sep 28 10:46:17 2018 +1000

    ctdb-recoverd: Flatten update_flags_on_all_nodes()
    
    The logic currently in ctdb_ctrl_modflags() will be optimised so that
    it no longer matches the pattern for a control function.  So, remove
    this function and squash its functionality into the only caller.
    
    Although there are some superficial changes, the behaviour is
    unchanged.
    
    Flattening the 2 functions produces some seriously weird logic for
    setting the new flags, to the point where using ctdb_ctrl_modflags()
    for this purpose now looks very strange.  The weirdness will be
    cleaned up in a subsequent commit.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 0c6a7db3ba84b8355359b0a8c52690b234bb866d)

commit 94416b40b7ece54608abc8aa2e2b6ae0b8fc038d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 5 23:37:57 2020 +1000

    ctdb-recoverd: Move ctdb_ctrl_modflags() to ctdb_recoverd.c
    
    This file is the only user of this function.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit a88c10c5a9afcf0a3dcadef07dd95af498bfa47a)

commit d1b1da94eb14640c73a8947d2755af75d5ad870d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue Jul 14 14:43:04 2020 +1000

    ctdb-recoverd: Improve a call to update_flags_on_all_nodes()
    
    This should take a PNN, not an array index.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit b1e631ff929fd87392a80895d1c8d265d9df42dc)

commit 6419e3de633a137c66d0100b3a088fba96ebeddd
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Jun 15 07:20:19 2019 +1000

    ctdb-recoverd: Use update_flags_on_all_nodes()
    
    This is clearer than using the MODFLAGS control directly.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 915d24ac12d27c21649d9e64d201d9df9d583129)

commit fffe852285b75bae6ae06049d025a002876ace50
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Jun 15 07:19:26 2019 +1000

    ctdb-recoverd: Introduce some local variables to improve readability
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit f681c0e947741151f8fb95d88edddfd732166dc1)

commit 34bc583a7f16668ebfa96364bd0f2c664274b228
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 5 23:45:15 2020 +1000

    ctdb-recoverd: Change update_flags_on_all_nodes() to take rec argument
    
    This makes fields such as recmaster and nodemap easily available if
    required.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit cb3a3147b7a3a29d7806733791e1fa6ba2e46680)

commit cea37c849ce60698245290021db5e19d1811ccae
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 18 20:25:07 2018 +1100

    ctdb-recoverd: Drop unused nodemap argument from update_flags_on_all_nodes()
    
    An unused argument needlessly extends the length of function calls.  A
    subsequent change will allow rec->nodemap to be used if necessary.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 6982fcb3e6c940d0047aac3b6bfbc9dfdc8d7214)

commit 051a9021d50a1303bf6757811622cf83390ad339
Author: Günther Deschner <gd at samba.org>
Date:   Tue Aug 25 10:37:18 2020 +0200

    lib/util: do not install /usr/bin/test_util
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14166
    
    Guenther
    
    Signed-off-by: Guenther Deschner <gd at samba.org>

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

Summary of changes:
 ctdb/include/ctdb_client.h  |   5 -
 ctdb/server/ctdb_client.c   |  65 -----------
 ctdb/server/ctdb_recoverd.c | 264 ++++++++++++++++++++++++++++++--------------
 lib/util/wscript_build      |   3 +-
 4 files changed, 184 insertions(+), 153 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h
index 198a8a38dbb..b89c4e49b2f 100644
--- a/ctdb/include/ctdb_client.h
+++ b/ctdb/include/ctdb_client.h
@@ -195,11 +195,6 @@ int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
 			 TALLOC_CTX *mem_ctx,
 			 struct ctdb_iface_list_old **ifaces);
 
-int ctdb_ctrl_modflags(struct ctdb_context *ctdb,
-		       struct timeval timeout,
-		       uint32_t destnode,
-		       uint32_t set, uint32_t clear);
-
 int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
 			       struct timeval timeout, uint32_t destnode,
 			       struct ctdb_tunable_list *tunables);
diff --git a/ctdb/server/ctdb_client.c b/ctdb/server/ctdb_client.c
index 67455745ede..566b59903ba 100644
--- a/ctdb/server/ctdb_client.c
+++ b/ctdb/server/ctdb_client.c
@@ -1243,71 +1243,6 @@ int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
 	return 0;
 }
 
-/*
-  set/clear the permanent disabled bit on a remote node
- */
-int ctdb_ctrl_modflags(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
-		       uint32_t set, uint32_t clear)
-{
-	int ret;
-	TDB_DATA data;
-	struct ctdb_node_map_old *nodemap=NULL;
-	struct ctdb_node_flag_change c;
-	TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-	uint32_t recmaster;
-	uint32_t *nodes;
-
-
-	/* find the recovery master */
-	ret = ctdb_ctrl_getrecmaster(ctdb, tmp_ctx, timeout, CTDB_CURRENT_NODE, &recmaster);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to get recmaster from local node\n"));
-		talloc_free(tmp_ctx);
-		return ret;
-	}
-
-
-	/* read the node flags from the recmaster */
-	ret = ctdb_ctrl_getnodemap(ctdb, timeout, recmaster, tmp_ctx, &nodemap);
-	if (ret != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from node %u\n", destnode));
-		talloc_free(tmp_ctx);
-		return -1;
-	}
-	if (destnode >= nodemap->num) {
-		DEBUG(DEBUG_ERR,(__location__ " Nodemap from recmaster does not contain node %d\n", destnode));
-		talloc_free(tmp_ctx);
-		return -1;
-	}
-
-	c.pnn       = destnode;
-	c.old_flags = nodemap->nodes[destnode].flags;
-	c.new_flags = c.old_flags;
-	c.new_flags |= set;
-	c.new_flags &= ~clear;
-
-	data.dsize = sizeof(c);
-	data.dptr = (unsigned char *)&c;
-
-	/* send the flags update to all connected nodes */
-	nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
-
-	if (ctdb_client_async_control(ctdb, CTDB_CONTROL_MODIFY_FLAGS,
-					nodes, 0,
-					timeout, false, data,
-					NULL, NULL,
-					NULL) != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
-
-		talloc_free(tmp_ctx);
-		return -1;
-	}
-
-	talloc_free(tmp_ctx);
-	return 0;
-}
-
-
 /*
   get all tunables
  */
diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c
index 2c029256c02..7c53335604a 100644
--- a/ctdb/server/ctdb_recoverd.c
+++ b/ctdb/server/ctdb_recoverd.c
@@ -425,18 +425,62 @@ static int set_recovery_mode(struct ctdb_context *ctdb,
 }
 
 /*
-  update flags on all active nodes
+ * Update flags on all connected nodes
  */
-static int update_flags_on_all_nodes(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap, uint32_t pnn, uint32_t flags)
+static int update_flags_on_all_nodes(struct ctdb_recoverd *rec,
+				     uint32_t pnn,
+				     uint32_t flags)
 {
+	struct ctdb_context *ctdb = rec->ctdb;
+	struct timeval timeout = CONTROL_TIMEOUT();
+	TDB_DATA data;
+	struct ctdb_node_map_old *nodemap=NULL;
+	struct ctdb_node_flag_change c;
+	TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+	uint32_t *nodes;
+	uint32_t i;
 	int ret;
 
-	ret = ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(), pnn, flags, ~flags);
-		if (ret != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
+	nodemap = rec->nodemap;
+
+	for (i = 0; i < nodemap->num; i++) {
+		if (pnn == nodemap->nodes[i].pnn) {
+			break;
+		}
+	}
+	if (i >= nodemap->num) {
+		DBG_ERR("Nodemap does not contain node %d\n", pnn);
+		talloc_free(tmp_ctx);
 		return -1;
 	}
 
+	c.pnn       = pnn;
+	c.old_flags = nodemap->nodes[i].flags;
+	c.new_flags = flags;
+
+	data.dsize = sizeof(c);
+	data.dptr = (unsigned char *)&c;
+
+	/* send the flags update to all connected nodes */
+	nodes = list_of_connected_nodes(ctdb, nodemap, tmp_ctx, true);
+
+	ret = ctdb_client_async_control(ctdb,
+					CTDB_CONTROL_MODIFY_FLAGS,
+					nodes,
+					0,
+					timeout,
+					false,
+					data,
+					NULL,
+					NULL,
+					NULL);
+	if (ret != 0) {
+		DBG_ERR("Unable to update flags on remote nodes\n");
+		talloc_free(tmp_ctx);
+		return -1;
+	}
+
+	talloc_free(tmp_ctx);
 	return 0;
 }
 
@@ -493,60 +537,57 @@ static void ctdb_wait_election(struct ctdb_recoverd *rec)
 }
 
 /*
-  Update our local flags from all remote connected nodes. 
-  This is only run when we are or we belive we are the recovery master
+ * Update local flags from all remote connected nodes and push out
+ * flags changes to all nodes.  This is only run by the recovery
+ * master.
  */
-static int update_local_flags(struct ctdb_recoverd *rec, struct ctdb_node_map_old *nodemap)
+static int update_flags(struct ctdb_recoverd *rec,
+			struct ctdb_node_map_old *nodemap,
+			struct ctdb_node_map_old **remote_nodemaps)
 {
 	unsigned int j;
 	struct ctdb_context *ctdb = rec->ctdb;
 	TALLOC_CTX *mem_ctx = talloc_new(ctdb);
 
-	/* get the nodemap for all active remote nodes and verify
-	   they are the same as for this node
-	 */
+	/* Check flags from remote nodes */
 	for (j=0; j<nodemap->num; j++) {
 		struct ctdb_node_map_old *remote_nodemap=NULL;
+		uint32_t local_flags = nodemap->nodes[j].flags;
+		uint32_t remote_flags;
 		int ret;
 
-		if (nodemap->nodes[j].flags & NODE_FLAGS_DISCONNECTED) {
+		if (local_flags & NODE_FLAGS_DISCONNECTED) {
 			continue;
 		}
 		if (nodemap->nodes[j].pnn == ctdb->pnn) {
 			continue;
 		}
 
-		ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, 
-					   mem_ctx, &remote_nodemap);
-		if (ret != 0) {
-			DEBUG(DEBUG_ERR, (__location__ " Unable to get nodemap from remote node %u\n", 
-				  nodemap->nodes[j].pnn));
-			ctdb_set_culprit(rec, nodemap->nodes[j].pnn);
-			talloc_free(mem_ctx);
-			return -1;
-		}
-		if (nodemap->nodes[j].flags != remote_nodemap->nodes[j].flags) {
-			/* We should tell our daemon about this so it
-			   updates its flags or else we will log the same 
-			   message again in the next iteration of recovery.
-			   Since we are the recovery master we can just as
-			   well update the flags on all nodes.
-			*/
-			ret = ctdb_ctrl_modflags(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, remote_nodemap->nodes[j].flags, ~remote_nodemap->nodes[j].flags);
+		remote_nodemap = remote_nodemaps[j];
+		remote_flags = remote_nodemap->nodes[j].flags;
+
+		if (local_flags != remote_flags) {
+			ret = update_flags_on_all_nodes(rec,
+							nodemap->nodes[j].pnn,
+							remote_flags);
 			if (ret != 0) {
-				DEBUG(DEBUG_ERR, (__location__ " Unable to update nodeflags on remote nodes\n"));
+				DBG_ERR(
+				    "Unable to update flags on remote nodes\n");
+				talloc_free(mem_ctx);
 				return -1;
 			}
 
-			/* Update our local copy of the flags in the recovery
-			   daemon.
-			*/
-			DEBUG(DEBUG_NOTICE,("Remote node %u had flags 0x%x, local had 0x%x - updating local\n",
-				 nodemap->nodes[j].pnn, remote_nodemap->nodes[j].flags,
-				 nodemap->nodes[j].flags));
-			nodemap->nodes[j].flags = remote_nodemap->nodes[j].flags;
+			/*
+			 * Update the local copy of the flags in the
+			 * recovery daemon.
+			 */
+			D_NOTICE("Remote node %u had flags 0x%x, "
+				 "local had 0x%x - updating local\n",
+				 nodemap->nodes[j].pnn,
+				 remote_flags,
+				 local_flags);
+			nodemap->nodes[j].flags = remote_flags;
 		}
-		talloc_free(remote_nodemap);
 	}
 	talloc_free(mem_ctx);
 	return 0;
@@ -1125,7 +1166,9 @@ static int do_recovery(struct ctdb_recoverd *rec,
 			continue;
 		}
 
-		ret = update_flags_on_all_nodes(ctdb, nodemap, i, nodemap->nodes[i].flags);
+		ret = update_flags_on_all_nodes(rec,
+						nodemap->nodes[i].pnn,
+						nodemap->nodes[i].flags);
 		if (ret != 0) {
 			if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
 				DEBUG(DEBUG_WARNING, (__location__ "Unable to update flags on inactive node %d\n", i));
@@ -2172,37 +2215,94 @@ done:
 }
 
 
-static void async_getnodemap_callback(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data)
+struct remote_nodemaps_state {
+	struct ctdb_node_map_old **remote_nodemaps;
+	struct ctdb_recoverd *rec;
+};
+
+static void async_getnodemap_callback(struct ctdb_context *ctdb,
+				      uint32_t node_pnn,
+				      int32_t res,
+				      TDB_DATA outdata,
+				      void *callback_data)
 {
-	struct ctdb_node_map_old **remote_nodemaps = callback_data;
+	struct remote_nodemaps_state *state =
+		(struct remote_nodemaps_state *)callback_data;
+	struct ctdb_node_map_old **remote_nodemaps = state->remote_nodemaps;
+	struct ctdb_node_map_old *nodemap = state->rec->nodemap;
+	size_t i;
 
-	if (node_pnn >= ctdb->num_nodes) {
-		DEBUG(DEBUG_ERR,(__location__ " pnn from invalid node\n"));
+	for (i = 0; i < nodemap->num; i++) {
+		if (nodemap->nodes[i].pnn == node_pnn) {
+			break;
+		}
+	}
+
+	if (i >= nodemap->num) {
+		DBG_ERR("Invalid PNN %"PRIu32"\n", node_pnn);
 		return;
 	}
 
-	remote_nodemaps[node_pnn] = (struct ctdb_node_map_old *)talloc_steal(remote_nodemaps, outdata.dptr);
+	remote_nodemaps[i] = (struct ctdb_node_map_old *)talloc_steal(
+					remote_nodemaps, outdata.dptr);
+
+}
+
+static void async_getnodemap_error(struct ctdb_context *ctdb,
+				   uint32_t node_pnn,
+				   int32_t res,
+				   TDB_DATA outdata,
+				   void *callback_data)
+{
+	struct remote_nodemaps_state *state =
+		(struct remote_nodemaps_state *)callback_data;
+	struct ctdb_recoverd *rec = state->rec;
 
+	DBG_ERR("Failed to retrieve nodemap from node %u\n", node_pnn);
+	ctdb_set_culprit(rec, node_pnn);
 }
 
-static int get_remote_nodemaps(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx,
-	struct ctdb_node_map_old *nodemap,
-	struct ctdb_node_map_old **remote_nodemaps)
+static int get_remote_nodemaps(struct ctdb_recoverd *rec,
+			       TALLOC_CTX *mem_ctx,
+			       struct ctdb_node_map_old ***remote_nodemaps)
 {
+	struct ctdb_context *ctdb = rec->ctdb;
+	struct ctdb_node_map_old **t;
 	uint32_t *nodes;
+	struct remote_nodemaps_state state;
+	int ret;
 
-	nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
-	if (ctdb_client_async_control(ctdb, CTDB_CONTROL_GET_NODEMAP,
-					nodes, 0,
-					CONTROL_TIMEOUT(), false, tdb_null,
+	t = talloc_zero_array(mem_ctx,
+			      struct ctdb_node_map_old *,
+			      rec->nodemap->num);
+	if (t == NULL) {
+		DBG_ERR("Memory allocation error\n");
+		return -1;
+	}
+
+	nodes = list_of_connected_nodes(ctdb, rec->nodemap, mem_ctx, false);
+
+	state.remote_nodemaps = t;
+	state.rec = rec;
+
+	ret = ctdb_client_async_control(ctdb,
+					CTDB_CONTROL_GET_NODEMAP,
+					nodes,
+					0,
+					CONTROL_TIMEOUT(),
+					false,
+					tdb_null,
 					async_getnodemap_callback,
-					NULL,
-					remote_nodemaps) != 0) {
-		DEBUG(DEBUG_ERR, (__location__ " Unable to pull all remote nodemaps\n"));
+					async_getnodemap_error,
+					&state);
+	talloc_free(nodes);
 
-		return -1;
+	if (ret != 0) {
+		talloc_free(t);
+		return ret;
 	}
 
+	*remote_nodemaps = t;
 	return 0;
 }
 
@@ -2447,10 +2547,17 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 	}
 
 
-	/* ensure our local copies of flags are right */
-	ret = update_local_flags(rec, nodemap);
+	/* Get the nodemaps for all connected remote nodes */
+	ret = get_remote_nodemaps(rec, mem_ctx, &remote_nodemaps);
 	if (ret != 0) {
-		DEBUG(DEBUG_ERR,("Unable to update local flags\n"));
+		DBG_ERR("Failed to read remote nodemaps\n");
+		return;
+	}
+
+	/* Ensure our local and remote flags are correct */
+	ret = update_flags(rec, nodemap, remote_nodemaps);
+	if (ret != 0) {
+		D_ERR("Unable to update flags\n");
 		return;
 	}
 
@@ -2523,33 +2630,14 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 		goto takeover_run_checks;
 	}
 
-	/* get the nodemap for all active remote nodes
-	 */
-	remote_nodemaps = talloc_array(mem_ctx, struct ctdb_node_map_old *, nodemap->num);
-	if (remote_nodemaps == NULL) {
-		DEBUG(DEBUG_ERR, (__location__ " failed to allocate remote nodemap array\n"));
-		return;
-	}
-	for(i=0; i<nodemap->num; i++) {
-		remote_nodemaps[i] = NULL;
-	}
-	if (get_remote_nodemaps(ctdb, mem_ctx, nodemap, remote_nodemaps) != 0) {
-		DEBUG(DEBUG_ERR,(__location__ " Failed to read remote nodemaps\n"));
-		return;
-	} 
-
 	/* verify that all other nodes have the same nodemap as we have
 	*/
 	for (j=0; j<nodemap->num; j++) {
-		if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
+		if (nodemap->nodes[j].pnn == ctdb->pnn) {
 			continue;
 		}
-
-		if (remote_nodemaps[j] == NULL) {
-			DEBUG(DEBUG_ERR,(__location__ " Did not get a remote nodemap for node %d, restarting monitoring\n", j));
-			ctdb_set_culprit(rec, j);
-
-			return;
+		if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
+			continue;
 		}
 
  		/* if the nodes disagree on how many nodes there are
@@ -2584,6 +2672,9 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 	 * up-to-date information for all the nodes.
 	 */
 	for (j=0; j<nodemap->num; j++) {
+		if (nodemap->nodes[j].pnn == ctdb->pnn) {
+			continue;
+		}
 		if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
 			continue;
 		}
@@ -2591,6 +2682,9 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 	}
 
 	for (j=0; j<nodemap->num; j++) {
+		if (nodemap->nodes[j].pnn == ctdb->pnn) {
+			continue;
+		}
 		if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
 			continue;
 		}
@@ -2610,14 +2704,20 @@ static void main_loop(struct ctdb_context *ctdb, struct ctdb_recoverd *rec,
 				  nodemap->nodes[i].flags));
 				if (i == j) {
 					DEBUG(DEBUG_ERR,("Use flags 0x%02x from remote node %d for cluster update of its own flags\n", remote_nodemaps[j]->nodes[i].flags, j));
-					update_flags_on_all_nodes(ctdb, nodemap, nodemap->nodes[i].pnn, remote_nodemaps[j]->nodes[i].flags);
+					update_flags_on_all_nodes(
+					    rec,
+					    nodemap->nodes[i].pnn,
+					    remote_nodemaps[j]->nodes[i].flags);
 					ctdb_set_culprit(rec, nodemap->nodes[j].pnn);
 					do_recovery(rec, mem_ctx, pnn, nodemap, 
 						    vnnmap);
 					return;
 				} else {
 					DEBUG(DEBUG_ERR,("Use flags 0x%02x from local recmaster node for cluster update of node %d flags\n", nodemap->nodes[i].flags, i));
-					update_flags_on_all_nodes(ctdb, nodemap, nodemap->nodes[i].pnn, nodemap->nodes[i].flags);
+					update_flags_on_all_nodes(
+						rec,
+						nodemap->nodes[i].pnn,
+						nodemap->nodes[i].flags);
 					ctdb_set_culprit(rec, nodemap->nodes[j].pnn);
 					do_recovery(rec, mem_ctx, pnn, nodemap, 
 						    vnnmap);
diff --git a/lib/util/wscript_build b/lib/util/wscript_build
index 4ac0a9cc064..e04752cb130 100644
--- a/lib/util/wscript_build
+++ b/lib/util/wscript_build
@@ -291,4 +291,5 @@ else:
     bld.SAMBA_BINARY('test_util',
                      source='tests/test_util.c',
                      deps='cmocka replace talloc samba-util',
-                     local_include=False)
+                     local_include=False,
+                     install=False)


-- 
Samba Shared Repository



More information about the samba-cvs mailing list