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

Karolin Seeger kseeger at samba.org
Mon Apr 27 18:21:07 MDT 2015


The branch, v4-2-test has been updated
       via  f330a2e Add DCERPC flag to call unbind hooks without destroying the connection itself upon termination of a connection with outstanding pending calls.
       via  69d632d Add multiplex state to dcerpc flags and control over multiplex PFC flag in bind_ack and and dcesrv_alter replies
       via  967679c Make sure we initialize conn to NULL, because a routine we call may give an error and not touch conn, and then we get an error when trying to TALLOC_FREE it.
       via  b5ff650 s3:smbd: update comment to correctly reflect MS-SMB2
       via  9423985 s3:smbd: missing tevent_req_nterror
       via  8478c00 ctdb-build: Specify absolute path to libsocket-wrapper.so
       via  e9c498b vfs_fruit: also map characters below 0x20
       via  8e034d4 ctdb-scripts: Add a 'rm' stub so statd-callout tests work correctly
       via  189ed91 ctdb-scripts: Remove unused function nfs_statd_update()
       via  fa53179 ctdb-scripts: Change statd-callout to be more scalable
       via  bb6497e ctdb-scripts: Fix a regression in statd-callout
       via  bc1e3a8 ctdb-tests: Unit tests for statd-callout
       via  c955fe8 ctdb-tests: Make setup of public addresses more obvious
       via  cb5cd84 ctdb-tests: Extend eventscript unit test infrastructure for other scripts
       via  59f2aef ctdb-tests: Support testing scripts that change directory
       via  cb1e82d ctdb-tests: Extend ctdb stub to support "ip" with and without -X
       via  3d74950 ctdb-tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"
      from  6135c95 lib/util: Include DEBUG macro in internal header files before samba_util.h

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


- Log -----------------------------------------------------------------
commit f330a2eb1ed842ac5abd18f3f9842177b65ddb10
Author: Julien Kerihuel <j.kerihuel at openchange.org>
Date:   Mon Apr 6 11:26:58 2015 +0200

    Add DCERPC flag to call unbind hooks without destroying the connection itself upon termination of a connection with outstanding pending calls.
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Jelmer Vernooij <jelmer at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Apr 14 20:39:34 CEST 2015 on sn-devel-104
    
    (cherry picked from commit fd90d270c7e97a639f42a96b674a674d1b51aa0d)
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11226
    Fix terminate connection behavior for asynchronous endpoint with PUSH
    notification flavors
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Tue Apr 28 02:20:32 CEST 2015 on sn-devel-104

commit 69d632d8d4ce623a08fd117d27dccf503b1af81b
Author: Julien Kerihuel <j.kerihuel at openchange.org>
Date:   Tue Mar 24 21:06:03 2015 -0700

    Add multiplex state to dcerpc flags and control over multiplex PFC flag in bind_ack and and dcesrv_alter replies
    
    Signed-off-by: Julien Kerihuel <j.kerihuel at openchange.org>
    Reviewed-by: "Stefan (metze) Metzmacher" <metze at samba.org>
    Reviewed-by: Jelmer Vernooij <jelmer at samba.org>
    (cherry picked from commit caaf89e899c2a3926fb9e54d1c86f1a9cd5d7618)
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11225
    multiplexed RPC connections are not handled by DCERPC server

commit 967679ceb5788d181e1768db32d0d689c8d0a113
Author: Richard Sharpe <rsharpe at nutanix.com>
Date:   Thu Apr 23 12:36:28 2015 -0700

    Make sure we initialize conn to NULL, because a routine we call may give an error and not touch conn, and then we get an error when trying to TALLOC_FREE it.
    
    https://bugzilla.samba.org/show_bug.cgi?id=11234
    
    Signed-off-by: Richard Sharpe <rsharpe at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 471744a32d37f187c87f9bfa6f860b69446b9afe)

commit b5ff65091e8709817236ac3d1663fe20bb2b8161
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Apr 17 09:12:59 2015 +0200

    s3:smbd: update comment to correctly reflect MS-SMB2
    
    https://bugzilla.samba.org/show_bug.cgi?id=11224
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Wed Apr 22 01:04:02 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 64b038da31c7674410ef770f9c40a5402159fb57)

commit 94239853d78aeb111053539dca73e1cffb694f9c
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Apr 16 22:28:25 2015 +0200

    s3:smbd: missing tevent_req_nterror
    
    The error code path in case fsp == NULL misses a call
    tevent_req_nterror().
    
    https://bugzilla.samba.org/show_bug.cgi?id=11224
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit ad52dcdf5de6f5f2c2ee156d93ebbb343f39e526)

commit 8478c00764b359d5e5ec078885dc5142cee1c579
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Mar 4 15:55:15 2015 +1100

    ctdb-build: Specify absolute path to libsocket-wrapper.so
    
    Specifying a relative path to LD_PRELOAD can fail if any of the test
    scripts uses cd to change directory and execute commands.
    
    Adding statd-callout tests breaks autotest since statd-callout does "cd".
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11204
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Mar  4 13:11:53 CET 2015 on sn-devel-104
    (cherry picked from commit 7a10e077706efd3b5d2ce024084b7ed97d4cd36c)

commit e9c498b36db2758957f29740130a035d367a12e2
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Apr 15 21:48:27 2015 +0200

    vfs_fruit: also map characters below 0x20
    
    we need to map 0x01-0x1F to 0xF001-0xF01F as 0x01-0x1F are win32 illegal
    characters.
    
    see https://support.microsoft.com/en-us/kb/kbview/117258
    
    Even if the MS KB article writes "invalid ntfs characters" they are actually
    not illegal in ntfs, just in the win32 API.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=11221
    
    Signed-off-by: Bjoern Jacke <bj at sernet.de>
    Reviewed-by: Ralf Böhme <slow at samba.org>
    
    Autobuild-User(master): Björn Jacke <bj at sernet.de>
    Autobuild-Date(master): Fri Apr 17 20:00:48 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 60fbfc5563ada64ea145e93ceaee791165d78e64)

commit 8e034d4e1a4a46dc4f0a7a393eb4ab0de979af0f
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Mar 5 13:10:32 2015 +1100

    ctdb-scripts: Add a 'rm' stub so statd-callout tests work correctly
    
    statd-callout tries to remove global files from /var/lib/nfs/statd and
    this causes errors in tests.  Add an rm stub that ignores attempts to
    remove these files but invokes /bin/rm for anything else.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>
    Pair-programmed-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Martin Schwenke <martin at meltin.net>
    (cherry picked from commit 956e51707d7ddcff060352f54d11ff42bdcc51ef)
    
    The last 10 patches address
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11204
    
    CTDB statd-callout does not scale.

commit 189ed91edc0e22b56a1689fbbe57b744d8afc711
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 13 15:42:20 2015 +1100

    ctdb-scripts: Remove unused function nfs_statd_update()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 50ddc2c35643389c2f249c6ad4496ab73a1bfc99)

commit fa531793f34eb8bb9bef98d6090cd419b6952c32
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 13 20:55:43 2015 +1100

    ctdb-scripts: Change statd-callout to be more scalable
    
    Updating ctdb.tdb on each add-client, del-client and each delete
    during notify was too ambitious.  Persistent transactions do not
    perform well enough to do this.
    
    Revert to having add-client and del-client create touch files.  Each
    monitor event calls "statd-callout update" to convert touch files into
    ctdb.tdb records.
    
    Update testcases to do the "update" and add an extra test.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 500c6e194babe06b6aead7a053a9442c94db6e38)

commit bb6497e8f370c927363dfa4dbd4c3fce274736e8
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Feb 26 15:34:51 2015 +1100

    ctdb-scripts: Fix a regression in statd-callout
    
    Commit 4638010abb116aed0c180207aaa11475277aecb7 changed from using
    gensub() to gsub() in awk.  However, it didn't halve the number of
    backslashes in the target strings.  This is necessary because
    backslash is used in gensub() target strings to allow substitution of
    text matching parenthesised subexpressions.  This is not the case with
    gsub().
    
    So, halve the number of backslashes in the target string where gsub()
    is used in statd-callout.  This is the only target string broken by
    changes made by the above commit
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 032441d9a2974584cde455e4dbd5cc33fe6a23c2)

commit bc1e3a83441d4b50ddb97d120b535ee9db6a902f
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Mar 4 11:51:20 2015 +1100

    ctdb-tests: Unit tests for statd-callout
    
    With improvements to unit test infrastructure to support.  This
    includes linking the real statd-callout into etc-ctdb/ in place of the
    placeholder script.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 22602f76bc1ec91e807a8f1cd45ba6fb4c05e622)

commit c955fe856b92a7e4ac327ce94cd295f3b696239c
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:20:56 2015 +1100

    ctdb-tests: Make setup of public addresses more obvious
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d98c7ba382189161c5b8cbbebbdfbe36f1456572)

commit cb5cd84c836aba5be64a496d8f278c70dbdae150
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:19:04 2015 +1100

    ctdb-tests: Extend eventscript unit test infrastructure for other scripts
    
    There's so much infrastructure here that it would be a shame not to
    use it for testing things like statd-callout.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 7e7c24ca7a422f2258962216b0184eda8d49827f)

commit 59f2aefa1191ce4aae0824ac2be0f7dad1ef1329
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:17:30 2015 +1100

    ctdb-tests: Support testing scripts that change directory
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 9317d82c19a0eb51ff6293d00328a5c36b063a2c)

commit cb1e82debec45f53351098be5b44bb6fe762ad3e
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:15:18 2015 +1100

    ctdb-tests: Extend ctdb stub to support "ip" with and without -X
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 2aeb518637af29da03984470d874b94dfb18e34e)

commit 3d74950159937f625f57056525ee8dbd16c526fa
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Feb 27 15:13:23 2015 +1100

    ctdb-tests: Extend ctdb stub to support "ptrans", "pdelete", "catdb"
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit d057ca04a9eec0f2aa3d792da0a4648e3716685a)
    
    Conflicts:
    	ctdb/tests/eventscripts/stubs/ctdb

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

Summary of changes:
 ctdb/config/events.d/60.ganesha                    |   1 +
 ctdb/config/events.d/60.nfs                        |   1 +
 ctdb/config/functions                              |  27 ++--
 ctdb/config/statd-callout                          | 142 ++++++++++++--------
 ctdb/tests/eventscripts/etc-ctdb/statd-callout     |   6 +-
 ctdb/tests/eventscripts/scripts/local.sh           | 148 +++++++++++++++++----
 ctdb/tests/eventscripts/statd-callout.001.sh       |  15 +++
 ctdb/tests/eventscripts/statd-callout.002.sh       |  16 +++
 ctdb/tests/eventscripts/statd-callout.003.sh       |  18 +++
 ctdb/tests/eventscripts/statd-callout.004.sh       |  19 +++
 ctdb/tests/eventscripts/statd-callout.005.sh       |  27 ++++
 ctdb/tests/eventscripts/statd-callout.006.sh       |  29 ++++
 ctdb/tests/eventscripts/statd-callout.007.sh       |  16 +++
 ctdb/tests/eventscripts/stubs/ctdb                 | 130 +++++++++++++++---
 ctdb/tests/eventscripts/stubs/id                   |   3 +
 ctdb/tests/eventscripts/stubs/rm                   |   6 +
 .../stubs/ssh => eventscripts/stubs/smnotify}      |   1 +
 ctdb/tests/scripts/common.sh                       |   4 +
 ctdb/wscript                                       |   6 +-
 source3/modules/vfs_fruit.c                        |   8 ++
 source3/smbd/aio.c                                 |  12 +-
 source3/smbd/smb2_server.c                         |  11 +-
 source3/utils/net_dns.c                            |   2 +-
 source4/rpc_server/dcerpc_server.c                 |  36 ++++-
 source4/rpc_server/dcerpc_server.h                 |   2 +
 25 files changed, 544 insertions(+), 142 deletions(-)
 mode change 100755 => 120000 ctdb/tests/eventscripts/etc-ctdb/statd-callout
 create mode 100755 ctdb/tests/eventscripts/statd-callout.001.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.002.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.003.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.004.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.005.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.006.sh
 create mode 100755 ctdb/tests/eventscripts/statd-callout.007.sh
 create mode 100755 ctdb/tests/eventscripts/stubs/id
 create mode 100755 ctdb/tests/eventscripts/stubs/rm
 copy ctdb/tests/{onnode/stubs/ssh => eventscripts/stubs/smnotify} (62%)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/events.d/60.ganesha b/ctdb/config/events.d/60.ganesha
index df0912d..46edb0a 100755
--- a/ctdb/config/events.d/60.ganesha
+++ b/ctdb/config/events.d/60.ganesha
@@ -221,6 +221,7 @@ case "$1" in
 	} || exit $?
 
 	update_tickles 2049
+	nfs_update_lock_info
 
 	# check that statd responds to rpc requests
 	# if statd is not running we try to restart it
diff --git a/ctdb/config/events.d/60.nfs b/ctdb/config/events.d/60.nfs
index c4e798e..d570cd7 100755
--- a/ctdb/config/events.d/60.nfs
+++ b/ctdb/config/events.d/60.nfs
@@ -91,6 +91,7 @@ case "$1" in
 	} || exit $?
 
 	update_tickles 2049
+	nfs_update_lock_info
 
 	nfs_check_rpc_services
 
diff --git a/ctdb/config/functions b/ctdb/config/functions
index d40c0d6..e0270a3 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -656,6 +656,16 @@ get_tcp_connections_for_ip ()
 	 {print $4" "$5}'
 }
 
+##################################################################
+# use statd-callout to update NFS lock info
+##################################################################
+nfs_update_lock_info ()
+{
+    if [ -x "$CTDB_BASE/statd-callout" ] ; then
+	"$CTDB_BASE/statd-callout" update
+    fi
+}
+
 ########################################################
 # start/stop the Ganesha nfs service
 ########################################################
@@ -807,23 +817,6 @@ startstop_nfslock() {
 	esac
 }
 
-# Periodically update the statd database
-nfs_statd_update ()
-{
-    _update_period="$1"
-
-    _statd_update_trigger="$service_state_dir/update-trigger"
-    [ -f "$_statd_update_trigger" ] || touch "$_statd_update_trigger"
-
-    _last_update=$(stat --printf="%Y" "$_statd_update_trigger")
-    _current_time=$(date +"%s")
-    if [ $(( $_current_time - $_last_update)) -ge $_update_period ] ; then
-	touch "$_statd_update_trigger"
-	$CTDB_BASE/statd-callout updatelocal &
-	$CTDB_BASE/statd-callout updateremote &
-    fi
-}
-
 ########################################################
 
 add_ip_to_iface ()
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index e2a955e..4a331ac 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -30,7 +30,19 @@ loadconfig nfs
 nl="
 "
 
+ctdb_setup_service_state_dir "statd-callout"
+
+cd "$service_state_dir" || \
+    die "Failed to change directory to \"${service_state_dir}\""
+
 case "$1" in
+    # Keep a single file to keep track of the last "add-client" or
+    # "del-client'.  These get pushed to ctdb.tdb during "update",
+    # which will generally be run once each "monitor" cycle.  In this
+    # way we avoid scalability problems with flood of persistent
+    # transactions after a "notify" when all the clients re-take their
+    # locks.
+
     add-client)
 	# statd does not tell us to which IP the client connected so
 	# we must add it to all the IPs that we serve
@@ -38,42 +50,47 @@ case "$1" in
 	pnn=$(ctdb xpnn | sed -e 's/.*://')
 	date=$(date '+%s')
 	ctdb ip -X |
-	tail -n +2 | {
-	    # This all needs to be in the end of the pipe so it
-	    # doesn't get lost
-	    items=""
-	    while IFS="|" read x sip node x ; do
-		[ "$node" = "$pnn" ] || continue # not us
-		key="statd-state@${sip}@${cip}"
-		item="\"${key}\" \"${date}\""
-		items="${items}${items:+${nl}}${item}"
-	    done
-	    if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then
-		die "Failed to add clients"
-	    fi
-	}
+	tail -n +2 |
+	while IFS="|" read x sip node x ; do
+	    [ "$node" = "$pnn" ] || continue # not us
+	    key="statd-state@${sip}@${cip}"
+	    echo "\"${key}\" \"${date}\"" >"$key"
+	done
 	;;
-  del-client)
+
+    del-client)
 	# statd does not tell us from which IP the client disconnected
 	# so we must add it to all the IPs that we serve
 	cip="$2"
 	pnn=$(ctdb xpnn | sed -e 's/.*://')
 	ctdb ip -X |
-	tail -n +2 | {
-	    # This all needs to be in the end of the pipe so it
-	    # doesn't get lost
-	    items=""
-	    while IFS="|" read x sip node x ; do
-		[ "$node" = "$pnn" ] || continue # not us
-		key="statd-state@${sip}@${cip}"
-		item="\"${key}\" \"\""
-		items="${items}${items:+${nl}}${item}"
-	    done
-	    if ! echo "$items" | ctdb ptrans "ctdb.tdb" ; then
-		die "Failed to delete clients"
-	    fi
-	}
+	tail -n +2 |
+	while IFS="|" read x sip node x ; do
+	    [ "$node" = "$pnn" ] || continue # not us
+	    key="statd-state@${sip}@${cip}"
+	    echo "\"${key}\" \"\"" >"$key"
+	done
 	;;
+
+    update)
+        files=$(echo statd-state@*)
+	if [ "$files" = "statd-state@*" ] ; then
+	    # No files!
+	    exit 0
+	fi
+	# Filter out lines for any IP addresses that are not currently
+	# hosted public IP addresses.
+	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_ips=$(ctdb ip | tail -n +2)
+	sed_expr=$(echo "$ctdb_ips" |
+	    awk -v pnn=$pnn 'pnn == $2 { \
+                ip = $1; gsub(/\./, "\\.", ip); \
+                printf "/statd-state@%s@/p\n", ip }')
+        if cat $files | sed -n "$sed_expr" | ctdb ptrans "ctdb.tdb" ; then
+            rm $files
+	fi
+        ;;
+
     notify)
 	# we must restart the lockmanager (on all nodes) so that we get
 	# a clusterwide grace period (so other clients dont take out
@@ -144,42 +161,51 @@ case "$1" in
 	# Construct a sed expression to take catdb output and produce pairs of:
 	#   server-IP client-IP
 	# but only for the server-IPs that are hosted on this node.
-	sed_expr=$(ctdb ip | tail -n +2 |
+	ctdb_all_ips=$(ctdb ip -n all | tail -n +2)
+	sed_expr=$(echo "$ctdb_all_ips" |
 	    awk -v pnn=$pnn 'pnn == $2 { \
-                ip = $1; gsub(/\./, "\\\\.", ip); \
+                ip = $1; gsub(/\./, "\\.", ip); \
                 printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')
 
 	statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort)
 	[ -n "$statd_state" ] || exit 0
 
-	# The following is dangerous if this script times out before
-	# all of the smnotify commands are run.  Revert to individual
-	# pdelete commands for now and consider optimising smnotify to
-	# read all the data from stdin and then run it in the
-	# background.
-	#
-	# Delete all the items from the TDB
-	#if ! echo "$statd_state" | \
-	#    awk '{ printf "\"statd-state@%s@%s\" \"\"\n", $1, $2 }') | \
-	#    ctdb ptrans ctdb.tdb ; then
+	prev=""
+	echo "$statd_state" | {
+	    # This all needs to be in the same command group at the
+	    # end of the pipe so it doesn't get lost when the loop
+	    # completes.
+	    items=""
+	    while read sip cip ; do
+		# Collect item to delete from the DB
+		key="statd-state@${sip}@${cip}"
+		item="\"${key}\" \"\""
+		items="${items}${items:+${nl}}${item}"
 
-	#    die "Yikes!"
-	#fi
+		# NOTE: Consider optimising smnotify to read all the
+		# data from stdin and then run it in the background.
+
+		# Reset stateval for each serverip
+		[ "$sip" = "$prev" ] || stateval="$state_even"
+		# Send notifies for server shutdown
+		smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
+		smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
+		# Send notifies for server startup
+		stateval=$(($stateval + 1))
+		smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
+		smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
+	    done
 
-	prev=""
-	echo "$statd_state" |
-	while read sip cip ; do
-	    # Delete the entry from the DB
-	    ctdb pdelete ctdb.tdb "statd-state@${sip}@${cip}"
-	    # Reset stateval for each serverip
-	    [ "$sip" = "$prev" ] || stateval="$state_even"
-	    # Send notifies for server shutdown
-	    smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
-	    smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
-	    # Send notifies for server startup
-	    stateval=$(($stateval + 1))
-	    smnotify --client=$cip --ip=$sip --server=$sip --stateval=$stateval
-	    smnotify --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
-	done
+	    echo "$items" | ctdb ptrans "ctdb.tdb"
+	}
+
+	# Remove any stale touch files (i.e. for IPs not currently
+	# hosted on this node and created since the last "update").
+	# There's nothing else we can do with them at this stage.
+	echo "$ctdb_all_ips" |
+	    awk -v pnn=$pnn 'pnn != $2 { print $1 }' |
+	    while read sip ; do
+		rm -f "statd-state@${sip}@"*
+	    done
 	;;
 esac
diff --git a/ctdb/tests/eventscripts/etc-ctdb/statd-callout b/ctdb/tests/eventscripts/etc-ctdb/statd-callout
deleted file mode 100755
index 51779bd..0000000
--- a/ctdb/tests/eventscripts/etc-ctdb/statd-callout
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/sh
-
-# For now, always succeed.
-
-exit 0
diff --git a/ctdb/tests/eventscripts/etc-ctdb/statd-callout b/ctdb/tests/eventscripts/etc-ctdb/statd-callout
new file mode 120000
index 0000000..dbd3c98
--- /dev/null
+++ b/ctdb/tests/eventscripts/etc-ctdb/statd-callout
@@ -0,0 +1 @@
+../../../config/statd-callout
\ No newline at end of file
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index c4e86d9..c00fda1 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -9,6 +9,10 @@ EVENTSCRIPTS_PATH=""
 
 if [ -d "${TEST_SUBDIR}/stubs" ] ; then
     EVENTSCRIPTS_PATH="${TEST_SUBDIR}/stubs"
+    case "$EVENTSCRIPTS_PATH" in
+	/*) : ;;
+	*) EVENTSCRIPTS_PATH="${PWD}/${EVENTSCRIPTS_PATH}" ;;
+    esac
 fi
 
 export EVENTSCRIPTS_PATH
@@ -271,6 +275,33 @@ ctdb_set_output ()
     eventscripts_test_add_cleanup "rm -f $_out $_rc"
 }
 
+# For now this creates the same public addresses each time.  However,
+# it could be made more flexible.
+setup_public_addresses ()
+{
+    if [ -f "$CTDB_PUBLIC_ADDRESSES" -a \
+	    "${CTDB_PUBLIC_ADDRESSES%/*}" = "$EVENTSCRIPTS_TESTS_VAR_DIR" ] ; then
+	rm "$CTDB_PUBLIC_ADDRESSES"
+    fi
+
+    export CTDB_PUBLIC_ADDRESSES=$(mktemp \
+				       --tmpdir="$EVENTSCRIPTS_TESTS_VAR_DIR" \
+				       "public-addresses-XXXXXXXX")
+
+    echo "Setting up CTDB_PUBLIC_ADDRESSES=${CTDB_PUBLIC_ADDRESSES}"
+    cat >"$CTDB_PUBLIC_ADDRESSES" <<EOF
+10.0.0.1/24 dev123
+10.0.0.2/24 dev123
+10.0.0.3/24 dev123
+10.0.0.4/24 dev123
+10.0.0.5/24 dev123
+10.0.0.6/24 dev123
+10.0.1.1/24 dev456
+10.0.1.2/24 dev456
+10.0.1.3/24 dev456
+EOF
+}
+
 setup_ctdb ()
 {
     setup_generic
@@ -281,17 +312,7 @@ setup_ctdb ()
     export FAKE_CTDB_PNN="${2:-0}"
     echo "Setting up CTDB with PNN ${FAKE_CTDB_PNN}"
 
-    export CTDB_PUBLIC_ADDRESSES="${CTDB_BASE}/public_addresses"
-    if [ -n "$3" ] ; then
-	echo "Setting up CTDB_PUBLIC_ADDRESSES: $3"
-	CTDB_PUBLIC_ADDRESSES=$(mktemp)
-	for _i in $3 ; do
-	    _ip="${_i%@*}"
-	    _ifaces="${_i#*@}"
-	    echo "${_ip} ${_ifaces}" >>"$CTDB_PUBLIC_ADDRESSES"
-	done
-	eventscripts_test_add_cleanup "rm -f $CTDB_PUBLIC_ADDRESSES"
-    fi
+    setup_public_addresses
 
     export FAKE_CTDB_STATE="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb"
 
@@ -505,6 +526,65 @@ EOF
 
 ######################################################################
 
+ctdb_catdb_format_pairs ()
+{
+    _count=0
+
+    while read _k _v ; do
+	_kn=$(echo -n "$_k" | wc -c)
+	_vn=$(echo -n "$_v" | wc -c)
+	cat <<EOF
+key(${_kn}) = "${_k}"
+dmaster: 0
+rsn: 1
+data(${_vn}) = "${_v}"
+
+EOF
+	_count=$(($_count + 1))
+    done
+
+    echo "Dumped ${_count} records"
+}
+
+check_ctdb_tdb_statd_state ()
+{
+    ctdb_get_my_public_addresses |
+    while read _x _sip _x ; do
+	for _cip ; do
+	    echo "statd-state@${_sip}@${_cip}" "$FAKE_DATE_OUTPUT"
+	done
+    done |
+    ctdb_catdb_format_pairs | {
+	ok
+	simple_test_command ctdb catdb ctdb.tdb
+    }
+}
+
+check_statd_callout_smnotify ()
+{
+    _state_even=$(( $(date '+%s') / 2 * 2))
+    _state_odd=$(($_state_even + 1))
+
+    nfs_load_config
+
+    ctdb_get_my_public_addresses |
+    while read _x _sip _x ; do
+	for _cip ; do
+	    cat <<EOF
+--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_even}
+--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_even}
+--client=${_cip} --ip=${_sip} --server=${_sip} --stateval=${_state_odd}
+--client=${_cip} --ip=${_sip} --server=${NFS_HOSTNAME} --stateval=${_state_odd}
+EOF
+	done
+    done | {
+	ok
+	simple_test_event "notify"
+    }
+}
+
+######################################################################
+
 setup_ctdb_natgw ()
 {
     debug "Setting up NAT gateway"
@@ -777,6 +857,19 @@ rpc_services_up ()
     done
 }
 
+
+nfs_load_config ()
+{
+    _etc="$CTDB_ETCDIR" # shortcut for readability
+    for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs" ; do
+	if [ -r "$_c" ] ; then
+	    . "$_c"
+	    break
+	fi
+    done
+}
+
+
 # Set the required result for a particular RPC program having failed
 # for a certain number of iterations.  This is probably still a work
 # in progress.  Note that we could hook aggressively
@@ -793,13 +886,7 @@ rpc_set_service_failure_response ()
     # the flexibility to set the number of failures.
     _numfails="${2:-${iteration}}"
 
-    _etc="$CTDB_ETCDIR" # shortcut for readability
-    for _c in "$_etc/sysconfig/nfs" "$_etc/default/nfs" "$_etc/ctdb/sysconfig/nfs" ; do
-	if [ -r "$_c" ] ; then
-	    . "$_c"
-	    break
-	fi
-    done
+    nfs_load_config
 
     # A handy newline.  :-)
     _nl="
@@ -969,19 +1056,32 @@ define_test ()
     # Remaining format should be NN.service.event.NNN or NN.service.NNN:
     _num="${_f##*.}"
     _f="${_f%.*}"
+
     case "$_f" in
-	*.*.*)
+	[0-9][0-9].*.*)
 	    script="${_f%.*}"
 	    event="${_f##*.}"
+	    script_dir="${CTDB_BASE}/events.d"
 	    ;;
-	*.*)
+	[0-9][0-9].*)
 	    script="$_f"
 	    unset event
+	    script_dir="${CTDB_BASE}/events.d"
+	    ;;
+	*.*)
+	    script="${_f%.*}"
+	    event="${_f##*.}"
+	    script_dir="${CTDB_BASE}"
 	    ;;
 	*)
-	    die "Internal error - unknown testcase filename format"
+	    script="${_f%.*}"
+	    unset event
+	    script_dir="${CTDB_BASE}"
     esac
 
+    [ -x "${script_dir}/${script}" ] || \
+	die "Internal error - unable to find script \"${script_dir}/${script}\""
+
     printf "%-17s %-10s %-4s - %s\n\n" "$script" "$event" "$_num" "$desc"
 }
 
@@ -1006,14 +1106,14 @@ simple_test ()
 
     _extra_header=$(_extra_header)
 
-    echo "Running eventscript \"$script $event${1:+ }$*\""
+    echo "Running script \"$script $event${1:+ }$*\""
     _shell=""
     if $TEST_COMMAND_TRACE ; then
 	_shell="sh -x"
     else
 	_shell="sh"
     fi
-    _out=$($_shell "${CTDB_BASE}/events.d/$script" "$event" "$@" 2>&1)
+    _out=$($_shell "${script_dir}/${script}" "$event" "$@" 2>&1)
 
     result_check "$_extra_header"
 }
@@ -1112,7 +1212,7 @@ iterate_test ()
 	else
 	    _shell="sh"
 	fi
-	_out=$($_shell "${CTDB_BASE}/events.d/$script" "$event" $args 2>&1)
+	_out=$($_shell "${script_dir}/${script}" "$event" $args 2>&1)
 	_rc=$?
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list