* README.attrcache: document test-attrcache script.
authorErez Zadok <ezk@cs.sunysb.edu>
Fri, 30 Sep 2005 02:50:26 +0000 (02:50 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 30 Sep 2005 02:50:26 +0000 (02:50 +0000)
* scripts/Makefile.am (noinst_SCRIPTS): build test-attrcache
script.

* configure.in: build scripts/test-attrcache script and chmod it
so it can be executed in place.

* scripts/test-attrcache.in: script to test the NFS attribute
cache using Amd.

ChangeLog
NEWS
README.attrcache
configure.in
scripts/Makefile.am
scripts/test-attrcache.in [new file with mode: 0755]

index b879d968c315310a33732e83239557e2f897bc35..83fcc43980ff87331c41eeb024b1f6ec5d1d26ac 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-09-29  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * README.attrcache: document test-attrcache script.
+
+       * scripts/Makefile.am (noinst_SCRIPTS): build test-attrcache
+       script.
+
+       * configure.in: build scripts/test-attrcache script and chmod it
+       so it can be executed in place.
+
+       * scripts/test-attrcache.in: script to test the NFS attribute
+       cache using Amd.
+
 2005-09-26  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * hlfsd/stubs.c (nfsproc_getattr_2_svc, nfsproc_lookup_2_svc,
diff --git a/NEWS b/NEWS
index 486ae730685683361e1c6d270a5a92584183b348..d4db1cd134abd316f11c642ab94d7ec6795ebe13 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,9 @@ NFS attribute cache entirely.  This means that Amd cannot work fully
 reliability on these systems, not under heavy load.  This is documented in
 detail in the README.attrcache file included with this distribution.
 
+Include test-attrcache script to test the NFS attribute cache behavior using
+Amd.
+
 - minor new ports:
        i386-pc-linux-deb3.1
        powerpc-apple-darwin8.2.0
index d5291be09beaa1b634d3a2d6fba0df107eab0049..e8522d226ebeadd8b145c8a506c922fa36458bc9 100644 (file)
@@ -111,5 +111,19 @@ After applying this patch and rebuilding your kernel, reboot with the new
 kernel.  Then copy the new nfs.h and nfsmount.h from /sys/nfs/ to
 /usr/include/nfs/, and finally rebuild am-utils from scratch.
 
+** Testing
+
+When you build am-utils, a script named scripts/test-attrcache is built,
+which can be used to test the NFS attribute cache behavior of the current
+OS.  You can run this script as root as follows:
+
+# make install
+# cd scripts
+# sh test-attrcache
+
+If you run this script on an OS whose status is known (and not listed
+above), please report it to am-utils@am-utils.org, so we can record it in
+this file.
+
 Sincerely,
 Erez.
index df416cce9f1c811a5c7d6e07b796299f6b447ffa..5536b77f46d074913406f239e64a7c6f92aa404c 100644 (file)
@@ -55,7 +55,7 @@ AH_BOTTOM([
 dnl
 dnl AC_CONFIG_AUX_DIR(m4)
 AC_PREREQ(2.52)
-AC_REVISION($Revision: 1.115 $)
+AC_REVISION($Revision: 1.116 $)
 AC_COPYRIGHT([Copyright (c) 1997-2005 Erez Zadok])
 dnl find out system type
 AC_MSG_NOTICE(*** SYSTEM TYPES ***)
@@ -1298,14 +1298,17 @@ AC_CONFIG_FILES(                        \
        scripts/ctl-amd                 \
        scripts/ctl-hlfsd               \
        scripts/expn                    \
-       scripts/fixrmtab                \
        scripts/fix-amd-map             \
+       scripts/fixrmtab                \
        scripts/lostaltmail             \
        scripts/redhat-ctl-amd          \
+       scripts/test-attrcache          \
        scripts/wait4amd                \
        scripts/wait4amd2die            \
        )
 AC_OUTPUT
+# chmod some scripts that are built but not installed
+test -f scripts/test-attrcache && chmod +x scripts/test-attrcache
 dnl ======================================================================
 
 dnl ######################################################################
index 4bfe69daa83e83593f203936a3f008970fbf39de..2fcfabc85e0452cd2a49630605b3a192ffe11d8d 100644 (file)
@@ -18,7 +18,8 @@ sbin_SCRIPTS =                \
        wait4amd2die
 
 noinst_SCRIPTS =       \
-       redhat-ctl-amd
+       redhat-ctl-amd  \
+       test-attrcache
 
 bin_SCRIPTS = expn
 
diff --git a/scripts/test-attrcache.in b/scripts/test-attrcache.in
new file mode 100755 (executable)
index 0000000..061308b
--- /dev/null
@@ -0,0 +1,135 @@
+#!/bin/sh
+# Script to test the attribute cache behavior of the local OS client.
+# If this script fails, it means that Amd cannot turn off the attrcache
+# reliably on this host, and Amd therefore may not run reliably.  See
+# the README.attrcache file distributed with this am-utils.
+#      -Erez Zadok, September 29, 2005
+
+# set PATH (must install am-utils first)
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH}
+export PATH
+
+# test if amd is running
+amq -p > /dev/null 2>&1
+if test $? = 0
+then
+       echo "### Amd already running... please shutdown Amd first"
+       exit 1
+fi
+
+mapfile="/tmp/amd.testmap.$$"
+logfile="/var/log/amd"
+delay=1
+a=/a
+
+CreateMap1 () {
+       echo "### Creating correct map"
+       cat - >$mapfile <<EOF
+a      type:=link;fs:=/tmp/a
+EOF
+}
+
+CreateMap2 () {
+       echo "### Creating weird map"
+       cat - >$mapfile <<EOF
+a      type:=link;fs:=/tmp/b
+EOF
+}
+
+StopAMD () {
+       ctl-amd stop
+# do not delete files we may need to use to debug Amd
+#      rm -f /tmp/a /tmp/b $mapfile $logfile
+}
+
+touch /tmp/a
+touch /tmp/b
+
+CreateMap1
+echo amd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync
+amd -x all -D all -r -l $logfile $a $mapfile -cache:=mapdefault,sync
+sleep 3                                # give amd chance to start properly
+amq
+inode_a=`ls -lLi /tmp/a | awk '{print $1}'`
+inode_b=`ls -lLi /tmp/b | awk '{print $1}'`
+ls -lLi $a/a
+ls -lLi $a/b
+ls -l $mapfile
+
+# how many times to try until we call it a success...
+maxtry=10
+while test $maxtry -gt 0
+do
+       echo "$maxtry tries left ..."
+       let maxtry=maxtry-1
+       amq
+       CreateMap1
+       sleep $delay
+
+       ls -l $mapfile
+       echo "### looking at a... should get a"
+       ino=`ls -lLi $a/a | awk '{print $1}'`
+       if test -z "$ino"
+       then
+               ls -li $a/a
+               amq
+               amq -m
+               stat $a
+               echo "a link does not exist!"
+               StopAMD
+               exit 1
+       fi
+       if test $ino -ne $inode_a
+       then
+               ls -li $a/a
+               amq
+               amq -m
+               stat $a
+               echo "a link does not point to A!"
+               StopAMD
+               exit 1
+       fi
+
+# Here is the main trick we try: force amd to flush one entry, then
+# change the amd map on disk, and then see if the kernel will have
+# flushed the attribute cache; if it did, then Amd will see the
+# correctly changed map entry.
+
+       amq -u $a/a
+       sleep $delay
+       stat $a
+
+       CreateMap2
+       sleep $delay
+
+       ls -l $mapfile
+       echo "### looking at a... should get b"
+       ino=`ls -lLi $a/a | awk '{print $1}'`
+       if test -z "$ino"
+       then
+               ls -li $a/a
+               amq
+               amq -m
+               stat $a
+               echo "a link does not exist!"
+               StopAMD
+               exit 1
+       fi
+       if test $ino -ne $inode_b
+       then
+               ls -li $a/a
+               amq
+               amq -m
+               stat $a
+               echo "a link does not point to B!"
+               StopAMD
+               exit 1
+       fi
+
+       amq -u $a/a
+       sleep $delay
+       stat $a
+done
+StopAMD