The branch, master has been updated
       via  7275e0c ctdb-tests: Use a separate directory for each local daemon
       via  429377a ctdb-ipalloc: Optimise check to see if IP is available on a 
node
       via  24db438 ctdb-daemon: Exit early if there are trailing command-line 
arguments
       via  df2d651 ctdb-daemon: Don't call ctdb_local_node_got_banned() on 
flag changes
      from  943c6ee s3-libads: Fix canonicalization support with MIT Kerberos

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


- Log -----------------------------------------------------------------
commit 7275e0ceff8e1d85aed22b69b31b5269e1ec5d03
Author: Martin Schwenke <mar...@meltin.net>
Date:   Thu Nov 24 16:37:26 2016 +1100

    ctdb-tests: Use a separate directory for each local daemon
    
    Separate directory contains configuration file, PID file, public
    addresses file, socket, databases and log file.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <ami...@samba.org>
    Autobuild-Date(master): Fri Dec  2 04:19:18 CET 2016 on sn-devel-144

commit 429377a2426fdfc8c3f7d8854fa2189ad36ff78c
Author: Martin Schwenke <mar...@meltin.net>
Date:   Fri Nov 18 16:08:13 2016 +1100

    ctdb-ipalloc: Optimise check to see if IP is available on a node
    
    Use a "bitmap" of available IPs for each IP address instead of walking
    the list of available IP addresses.
    
    For ctdb/tests/takeover/lcp2.030.sh, this improves the time taken on
    my laptop from:
    
      real      0m11.997s
      user      0m11.960s
      sys       0m0.000s
    
    to
    
      real      0m8.571s
      user      0m8.544s
      sys       0m0.000s
    
    So, when assigning all 900 IP addresses the improvement is about 25%.
    
    For the no-op case (where all IPs are already assigned to nodes), the
    extra setup adds a small fraction of a second for 900 IPs.
    Intermediate cases result in intermediate improvements.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>

commit 24db43839f8a17c4498454d4bbd24411f647defa
Author: Martin Schwenke <mar...@meltin.net>
Date:   Mon Nov 28 09:51:48 2016 +1100

    ctdb-daemon: Exit early if there are trailing command-line arguments
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>

commit df2d6518e7cb715e6eadb712f1ee79759254b27f
Author: Martin Schwenke <mar...@meltin.net>
Date:   Tue Nov 8 16:37:24 2016 +1100

    ctdb-daemon: Don't call ctdb_local_node_got_banned() on flag changes
    
    This function is currently called twice each time a node is banned.
    
    ctdb_local_node_got_banned() is already called from the banning code,
    either due to a received banning control or a node banning itself.
    Given that other nodes can't set a node's BANNED flag, a node can only
    be banned via the above mechanisms, so drop the redundant call.
    
    Signed-off-by: Martin Schwenke <mar...@meltin.net>
    Reviewed-by: Amitay Isaacs <ami...@gmail.com>

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

Summary of changes:
 ctdb/server/ctdb_monitor.c                   |  5 --
 ctdb/server/ctdbd.c                          |  8 +--
 ctdb/server/ipalloc.c                        | 37 +++++++++++++
 ctdb/server/ipalloc.h                        |  1 +
 ctdb/server/ipalloc_common.c                 | 17 +-----
 ctdb/tests/simple/scripts/local_daemons.bash | 77 +++++++++++++++++++++-------
 6 files changed, 102 insertions(+), 43 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c
index 00f6524..f0a427b 100644
--- a/ctdb/server/ctdb_monitor.c
+++ b/ctdb/server/ctdb_monitor.c
@@ -529,11 +529,6 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, 
TDB_DATA indata)
        ctdb_daemon_send_message(ctdb, ctdb->pnn,
                                 CTDB_SRVID_SET_NODE_FLAGS, indata);
 
-       /* if we have become banned, we should go into recovery mode */
-       if ((node->flags & NODE_FLAGS_BANNED) && !(c->old_flags & 
NODE_FLAGS_BANNED) && (node->pnn == ctdb->pnn)) {
-               ctdb_local_node_got_banned(ctdb);
-       }
-       
        return 0;
 }
 
diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c
index 99bb715..b0cbc8c 100644
--- a/ctdb/server/ctdbd.c
+++ b/ctdb/server/ctdbd.c
@@ -152,7 +152,6 @@ int main(int argc, const char *argv[])
        };
        int opt, ret;
        const char **extra_argv;
-       int extra_argc = 0;
        poptContext pc;
        struct tevent_context *ev;
        enum debug_level log_level;
@@ -168,11 +167,14 @@ int main(int argc, const char *argv[])
                }
        }
 
-       /* setup the remaining options for the main program to use */
+       /* If there are extra arguments then exit with usage message */
        extra_argv = poptGetArgs(pc);
        if (extra_argv) {
                extra_argv++;
-               while (extra_argv[extra_argc]) extra_argc++;
+               if (extra_argv[0])  {
+                       poptPrintHelp(pc, stdout, 0);
+                       exit(1);
+               }
        }
 
        talloc_enable_null_tracking();
diff --git a/ctdb/server/ipalloc.c b/ctdb/server/ipalloc.c
index 37804ea..819add1 100644
--- a/ctdb/server/ipalloc.c
+++ b/ctdb/server/ipalloc.c
@@ -29,6 +29,8 @@
 #include "common/logging.h"
 #include "common/rb_tree.h"
 
+#include "protocol/protocol_api.h"
+
 #include "server/ipalloc_private.h"
 
 /* Initialise main ipalloc state and sub-structures */
@@ -160,6 +162,37 @@ create_merged_ip_list(struct ipalloc_state *ipalloc_state)
        return ip_list;
 }
 
+static bool populate_bitmap(struct ipalloc_state *ipalloc_state)
+{
+       struct public_ip_list *ip = NULL;
+       int i, j;
+
+       for (ip = ipalloc_state->all_ips; ip != NULL; ip = ip->next) {
+
+               ip->available_on = talloc_zero_array(ip, bool,
+                                                    ipalloc_state->num);
+               if (ip->available_on == NULL) {
+                       return false;
+               }
+
+               for (i = 0; i < ipalloc_state->num; i++) {
+                       struct ctdb_public_ip_list *avail =
+                               &ipalloc_state->available_public_ips[i];
+
+                       /* Check to see if "ip" is available on node "i" */
+                       for (j = 0; j < avail->num; j++) {
+                               if (ctdb_sock_addr_same_ip(
+                                           &ip->addr, &avail->ip[j].addr)) {
+                                       ip->available_on[i] = true;
+                                       break;
+                               }
+                       }
+               }
+       }
+
+       return true;
+}
+
 static bool all_nodes_are_disabled(struct ctdb_node_map *nodemap)
 {
        int i;
@@ -283,6 +316,10 @@ struct public_ip_list *ipalloc(struct ipalloc_state 
*ipalloc_state)
                return NULL;
        }
 
+       if (!populate_bitmap(ipalloc_state)) {
+               return NULL;
+       }
+
        switch (ipalloc_state->algorithm) {
        case IPALLOC_LCP2:
                ret = ipalloc_lcp2(ipalloc_state);
diff --git a/ctdb/server/ipalloc.h b/ctdb/server/ipalloc.h
index d116426..4413b2a 100644
--- a/ctdb/server/ipalloc.h
+++ b/ctdb/server/ipalloc.h
@@ -31,6 +31,7 @@ struct public_ip_list {
        struct public_ip_list *next;
        uint32_t pnn;
        ctdb_sock_addr addr;
+       bool *available_on;
 };
 
 #define IP_KEYLEN      4
diff --git a/ctdb/server/ipalloc_common.c b/ctdb/server/ipalloc_common.c
index 1a52ff3..9ccba71 100644
--- a/ctdb/server/ipalloc_common.c
+++ b/ctdb/server/ipalloc_common.c
@@ -61,26 +61,11 @@ static bool can_node_host_ip(struct ipalloc_state 
*ipalloc_state,
                             int32_t pnn,
                             struct public_ip_list *ip)
 {
-       struct ctdb_public_ip_list *public_ips;
-       int i;
-
        if (ipalloc_state->noiphost[pnn]) {
                return false;
        }
-       if (ipalloc_state->available_public_ips == NULL) {
-               return false;
-       }
-
-       public_ips = &ipalloc_state->available_public_ips[pnn];
-
-       for (i=0; i<public_ips->num; i++) {
-               if (ctdb_sock_addr_same(&ip->addr, &public_ips->ip[i].addr)) {
-                       /* yes, this node can serve this public ip */
-                       return true;
-               }
-       }
 
-       return false;
+       return ip->available_on[pnn];
 }
 
 bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
diff --git a/ctdb/tests/simple/scripts/local_daemons.bash 
b/ctdb/tests/simple/scripts/local_daemons.bash
index 8624cb9..ef93bd9 100644
--- a/ctdb/tests/simple/scripts/local_daemons.bash
+++ b/ctdb/tests/simple/scripts/local_daemons.bash
@@ -1,11 +1,6 @@
 # If we're not running on a real cluster then we need a local copy of
 # ctdb (and other stuff) in $PATH and we will use local daemons.
 
-export CTDB_NODES_SOCKETS=""
-for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-    CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ 
}${TEST_VAR_DIR}/sock.${i}"
-done
-
 # Use in-tree binaries if running against local daemons.
 # Otherwise CTDB need to be installed on all nodes.
 if [ -n "$ctdb_dir" -a -d "${ctdb_dir}/bin" ] ; then
@@ -46,10 +41,39 @@ have_ip ()
        [ -n "$t" ]
 }
 
-setup_ctdb ()
+node_dir ()
+{
+       local pnn="$1"
+
+       echo "${TEST_VAR_DIR}/node.${pnn}"
+}
+
+node_conf ()
+{
+       local pnn="$1"
+
+       local node_dir=$(node_dir "$pnn")
+       echo "${node_dir}/ctdbd.conf"
+}
+
+node_pidfile ()
+{
+       local pnn="$1"
+
+       local node_dir=$(node_dir "$pnn")
+       echo "${node_dir}/ctdbd.pid"
+}
+
+node_socket ()
 {
-    mkdir -p "${TEST_VAR_DIR}/test.db/persistent"
+       local pnn="$1"
 
+       local node_dir=$(node_dir "$pnn")
+       echo "${node_dir}/ctdbd.socket"
+}
+
+setup_ctdb ()
+{
     local public_addresses_all="${TEST_VAR_DIR}/public_addresses_all"
     rm -f $CTDB_NODES $public_addresses_all
 
@@ -103,7 +127,10 @@ setup_ctdb ()
 
     local pnn
     for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-       local public_addresses_mine="${TEST_VAR_DIR}/public_addresses.${pnn}"
+       local node_dir=$(node_dir "$pnn")
+       mkdir -p "$node_dir"
+
+       local public_addresses_mine="${node_dir}/public_addresses"
        local public_addresses
 
        if  [ "$no_public_ips" = $pnn ] ; then
@@ -116,20 +143,24 @@ setup_ctdb ()
 
        local node_ip=$(sed -n -e "$(($pnn + 1))p" "$CTDB_NODES")
 
-       local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
-       local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
+       local conf=$(node_conf "$pnn")
+       local socket=$(node_socket "$pnn")
+
+       local db_dir="${node_dir}/db"
+       mkdir -p "${db_dir}/persistent"
+
        cat >"$conf" <<EOF
 CTDB_RECOVERY_LOCK="${TEST_VAR_DIR}/rec.lock"
 CTDB_NODES="$CTDB_NODES"
 CTDB_NODE_ADDRESS="${node_ip}"
 CTDB_EVENT_SCRIPT_DIR="${TEST_VAR_DIR}/events.d"
-CTDB_LOGGING="file:${TEST_VAR_DIR}/daemon.${pnn}.log"
+CTDB_LOGGING="file:${node_dir}/log.ctdb"
 CTDB_DEBUGLEVEL=3
-CTDB_DBDIR="${TEST_VAR_DIR}/test.db"
-CTDB_DBDIR_PERSISTENT="${TEST_VAR_DIR}/test.db/persistent"
-CTDB_DBDIR_STATE="${TEST_VAR_DIR}/test.db/state"
+CTDB_DBDIR="${db_dir}"
+CTDB_DBDIR_PERSISTENT="${db_dir}/persistent"
+CTDB_DBDIR_STATE="${db_dir}/state"
 CTDB_PUBLIC_ADDRESSES="${public_addresses}"
-CTDB_SOCKET="${TEST_VAR_DIR}/sock.$pnn"
+CTDB_SOCKET="${socket}"
 CTDB_NOSETSCHED=yes
 EOF
 
@@ -145,8 +176,8 @@ daemons_start ()
 
     local pnn
     for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-       local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
-       local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
+       local pidfile=$(node_pidfile "$pnn")
+       local conf=$(node_conf "$pnn")
 
        # If there is any CTDB configuration in the environment then
        # append it to the regular configuration in a temporary
@@ -176,8 +207,8 @@ daemons_stop ()
 
     local pnn
     for pnn in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
-       local pidfile="${TEST_VAR_DIR}/ctdbd.${pnn}.pid"
-       local conf="${TEST_VAR_DIR}/ctdbd.${pnn}.conf"
+       local pidfile=$(node_pidfile "$pnn")
+       local conf=$(node_conf "$pnn")
 
        CTDBD_CONF="$conf" \
             ctdbd_wrapper "$pidfile" stop
@@ -208,3 +239,11 @@ ps_ctdbd ()
        ps -p $(pgrep -f '\<ctdbd\>' | xargs | sed -e 's| |,|g') -o args ww
        echo
 }
+
+# onnode will use CTDB_NODES_SOCKETS to help the ctdb tool connection
+# to each daemon
+export CTDB_NODES_SOCKETS=""
+for i in $(seq 0 $(($TEST_LOCAL_DAEMONS - 1))) ; do
+    socket=$(node_socket "$i")
+    CTDB_NODES_SOCKETS="${CTDB_NODES_SOCKETS}${CTDB_NODES_SOCKETS:+ }${socket}"
+done


-- 
Samba Shared Repository

Reply via email to