2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
11 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 #export PDSH="pdsh -S -Rssh -w"
18 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
22 if [ -z "${!name}" ]; then
23 echo "$0: $name must be set"
27 [ $failed ] && exit 1 || true
31 echo "usage: $0 [-r] [-f cfgfile]"
38 export LUSTRE=`absolute_path $LUSTRE`
39 export TESTSUITE=`basename $0 .sh`
40 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
42 [ -d /r ] && export ROOT=${ROOT:-/r}
43 export TMP=${TMP:-$ROOT/tmp}
44 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
46 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
47 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
48 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
49 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
50 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
51 [ ! -f "$LFS" ] && export LFS=$(which lfs)
52 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
53 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
54 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
55 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
56 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
57 export FSYTPE=${FSTYPE:-"ldiskfs"}
58 export NAME=${NAME:-local}
59 export LPROC=/proc/fs/lustre
60 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
61 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
62 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
65 if [ "$ACCEPTOR_PORT" ]; then
66 export PORT_OPT="--port $ACCEPTOR_PORT"
71 echo "Using GSS/krb5 ptlrpc security flavor"
77 # Paths on remote nodes, if different
78 export RLUSTRE=${RLUSTRE:-$LUSTRE}
79 export RPWD=${RPWD:-$PWD}
80 export I_MOUNTED=${I_MOUNTED:-"no"}
84 while getopts "rvf:" opt $*; do
87 r) REFORMAT=--reformat;;
96 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
104 BASE=`basename $module $EXT`
105 lsmod | grep -q ${BASE} || \
106 if [ -f ${LUSTRE}/${module}${EXT} ]; then
107 insmod ${LUSTRE}/${module}${EXT} $@
109 # must be testing a "make install" or "rpm" installation
110 # note failed to load ptlrpc_gss is considered not fatal
111 if [ "$BASE" == "ptlrpc_gss" ]; then
112 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
120 if [ -n "$MODPROBE" ]; then
124 if [ "$HAVE_MODULES" = true ]; then
130 echo Loading modules from $LUSTRE
131 load_module ../lnet/libcfs/libcfs
132 [ -z "$LNETOPTS" ] && \
133 LNETOPTS=$(awk '/^options lnet/ { print $0}' /etc/modprobe.conf | sed 's/^options lnet //g')
134 echo "lnet options: '$LNETOPTS'"
135 # note that insmod will ignore anything in modprobe.conf
136 load_module ../lnet/lnet/lnet $LNETOPTS
137 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
138 load_module ../lnet/klnds/$LNETLND
139 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
140 load_module lvfs/lvfs
141 load_module obdclass/obdclass
142 load_module lvfs/fsfilt_$FSTYPE
143 load_module ptlrpc/ptlrpc
144 load_module ptlrpc/gss/ptlrpc_gss
145 # Now, some modules depend on lquota without USE_QUOTA check,
146 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
147 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
148 load_module quota/lquota
161 load_module obdfilter/obdfilter
162 load_module llite/lustre
165 rm -f $TMP/ogdb-`hostname`
166 $LCTL modules > $TMP/ogdb-`hostname`
167 # 'mount' doesn't look in $PATH, just sbin
168 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
172 if [ `uname -r | cut -c 3` -eq 4 ]; then
180 MODULES=$($LCTL modules | awk '{ print $2 }')
181 while [ -n "$MODULES" ]; do
183 $RMMOD $MODULES > /dev/null 2>&1 || true
184 MODULES=$($LCTL modules | awk '{ print $2 }')
185 if [ -z "$MODULES" ]; then
189 echo "waiting, $((MAX - WAIT)) secs left"
191 if [ $WAIT -eq $MAX ]; then
192 echo "LNET modules $MODULES will not unload"
200 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
201 local MODULES=$($LCTL modules | awk '{ print $2 }')
202 $RMMOD $MODULES > /dev/null 2>&1 || true
203 # do it again, in case we tried to unload ksocklnd too early
204 MODULES=$($LCTL modules | awk '{ print $2 }')
205 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
206 MODULES=$($LCTL modules | awk '{ print $2 }')
207 if [ -n "$MODULES" ]; then
208 echo "Modules still loaded: "
210 if [ -e $LPROC ]; then
211 echo "Lustre still loaded"
212 cat $LPROC/devices || true
216 echo "Lustre stopped but LNET is still loaded, waiting..."
217 wait_for_lnet || return 3
222 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
223 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
224 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
225 echo "$LEAK_LUSTRE" 1>&2
226 echo "$LEAK_PORTALS" 1>&2
227 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
228 echo "Memory leaks detected"
231 echo "modules unloaded."
235 check_gss_daemon_facet() {
239 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
240 if [ $num -ne 1 ]; then
241 echo "$num instance of $dname on $facet"
250 do_facet $facet "killall -2 $@ 2>/dev/null || true"
253 start_gss_daemons() {
255 for num in `seq $MDSCOUNT`; do
256 do_facet mds$num "$LSVCGSSD -v"
258 do_facet mds$num "$LGSSD -v"
262 for num in `seq $OSTCOUNT`; do
263 do_facet ost$num "$LSVCGSSD -v"
266 # FIXME: is "client" the right facet name?
268 do_facet client "$LGSSD -v"
271 # wait daemons entering "stable" status
275 # check daemons are running
277 for num in `seq $MDSCOUNT`; do
278 check_gss_daemon_facet mds$num lsvcgssd
280 check_gss_daemon_facet mds$num lgssd
283 for num in `seq $OSTCOUNT`; do
284 check_gss_daemon_facet ost$num lsvcgssd
287 check_gss_daemon_facet client lgssd
292 for num in `seq $MDSCOUNT`; do
293 send_sigint mds$num lsvcgssd lgssd
295 for num in `seq $OSTCOUNT`; do
296 send_sigint ost$num lsvcgssd
298 send_sigint client lgssd
302 if [ ! -z $SEC ]; then
303 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
304 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
315 # maybe cleanup credential cache?
321 local device=`mdsdevname $num`
322 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
328 local device=`ostdevname $num`
329 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
334 # start facet device options
340 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
341 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
342 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
344 if [ $RC -ne 0 ]; then
345 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
346 echo Start of ${device} on ${facet} failed ${RC}
348 do_facet ${facet} sync
349 label=$(do_facet ${facet} "e2label ${device}")
350 [ -z "$label" ] && echo no label for ${device} && exit 1
351 eval export ${facet}_svc=${label}
352 eval export ${facet}_dev=${device}
353 eval export ${facet}_opt=\"$@\"
354 echo Started ${label}
363 HOST=`facet_active_host $facet`
364 [ -z $HOST ] && echo stop: no host for $facet && return 0
366 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
367 if [ ${running} -ne 0 ]; then
368 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
369 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
372 # umount should block, but we should wait for unrelated obd's
373 # like the MGS or MGC to also stop.
376 # conf-sanity 31 takes a long time cleanup
377 while [ $WAIT -lt 300 ]; do
378 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
379 if [ -z "${running}" ]; then
382 echo "waited $WAIT for${running}"
383 if [ $INTERVAL -lt 64 ]; then
384 INTERVAL=$((INTERVAL + INTERVAL))
387 WAIT=$((WAIT + INTERVAL))
389 echo "service didn't stop after $WAIT seconds. Still running:"
398 # Only supply -o to mount if we have options
399 if [ -n "$MOUNTOPT" ]; then
400 OPTIONS="-o $MOUNTOPT"
402 local device=$MGSNID:/$FSNAME
403 if [ -z "$mnt" -o -z "$FSNAME" ]; then
404 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
408 echo "Starting client: $OPTIONS $device $mnt"
409 do_node $client mkdir -p $mnt
410 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
412 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
413 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
421 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
422 if [ $running -ne 0 ]; then
423 echo "Stopping client $mnt (opts:$force)"
424 do_node $client umount $force $mnt
430 if [ "$FAILURE_MODE" = HARD ]; then
431 $POWER_DOWN `facet_active_host $facet`
433 elif [ "$FAILURE_MODE" = SOFT ]; then
440 if [ "$FAILURE_MODE" = HARD ]; then
441 $POWER_UP `facet_active_host $facet`
447 # verify that lustre actually cleaned up properly
449 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
450 error "LBUG/LASSERT detected"
451 BUSY=`dmesg | grep -i destruct || true`
454 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
457 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
458 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
459 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
460 echo "$0: $LEAK_LUSTRE" 1>&2
461 echo "$0: $LEAK_PORTALS" 1>&2
462 echo "$0: Memory leak(s) detected..." 1>&2
463 mv $TMP/debug $TMP/debug-leak.`date +%s`
467 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
468 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
470 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
471 echo "$0: modules still loaded..." 1>&2
480 check_network "$HOST" 900
481 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
486 HOST=`facet_active_host $facet`
491 # not every config has many clients
492 if [ ! -z "$CLIENTS" ]; then
493 $PDSH $CLIENTS "df $MOUNT" > /dev/null
498 uname -n >> $MOUNT/recon
499 if [ ! -z "$CLIENTS" ]; then
500 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
502 echo Connected clients:
504 ls -l $MOUNT/recon > /dev/null
510 echo "Failing $facet on node `facet_active_host $facet`"
511 shutdown_facet $facet
515 echo "df pid is $DFPID"
517 TO=`facet_active_host $facet`
518 echo "Failover $facet to $TO"
520 local dev=${facet}_dev
521 local opt=${facet}_opt
522 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
533 local svc=${facet}_svc
534 do_facet $facet $LCTL --device %${!svc} readonly
535 do_facet $facet $LCTL --device %${!svc} notransno
536 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
537 $LCTL mark "local REPLAY BARRIER on ${!svc}"
540 replay_barrier_nodf() {
541 local facet=$1 echo running=${running}
543 local svc=${facet}_svc
544 echo Replay barrier on ${!svc}
545 do_facet $facet $LCTL --device %${!svc} readonly
546 do_facet $facet $LCTL --device %${!svc} notransno
547 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
548 $LCTL mark "local REPLAY BARRIER on ${!svc}"
552 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
553 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
557 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
558 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
562 facet_failover $* || error "failover: $?"
563 df $MOUNT || error "post-failover df: $?"
570 local svc=${facet}_svc
571 local dev=${facet}_dev
572 local opt=${facet}_opt
573 start $facet ${!dev} ${!opt}
574 do_facet $facet lctl --device %${!svc} abort_recovery
575 df $MOUNT || echo "first df failed: $?"
577 df $MOUNT || error "post-failover df: $?"
581 echo There is no lmc. This is mountconf, baby.
586 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
587 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
593 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
599 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
600 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
601 if [ -z "$ID" ]; then
602 echo "Could not get a ptl id for $1..."
611 h2name_or_ip "$1" "tcp"
616 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
617 if type __h2elan >/dev/null 2>&1; then
620 ID=`echo $1 | sed 's/[^0-9]*//g'`
628 h2name_or_ip "$1" "openib"
633 h2name_or_ip "$1" "o2ib"
639 varname=${facet}_HOST
640 if [ -z "${!varname}" ]; then
641 if [ "${facet:0:3}" == "ost" ]; then
642 eval ${facet}_HOST=${ost_HOST}
650 local activevar=${facet}active
652 if [ -f ./${facet}active ] ; then
653 source ./${facet}active
657 if [ -z "$active" ] ; then
664 facet_active_host() {
666 local active=`facet_active $facet`
667 if [ "$facet" == client ]; then
670 echo `facet_host $active`
676 failover=${facet}failover
677 host=`facet_host $failover`
678 [ -z "$host" ] && return
679 curactive=`facet_active $facet`
680 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
681 eval export ${facet}active=$facet
683 eval export ${facet}active=$failover
685 # save the active host for this facet
686 activevar=${facet}active
687 echo "$activevar=${!activevar}" > ./$activevar
694 if [ "$HOST" = "$(hostname)" ]; then
698 echo "CMD: $HOST $@" >&2
699 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
701 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
702 return ${PIPESTATUS[0]}
708 HOST=`facet_active_host $facet`
709 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
716 # make sure its not already running
719 do_facet ${facet} $MKFS $*
725 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
726 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
733 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
734 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
742 # make sure we are using the primary server, so test-framework will
743 # be able to clean up properly.
744 activemds=`facet_active mds1`
745 if [ $activemds != "mds1" ]; then
749 # assume client mount is local
750 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
751 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
752 for num in `seq $MDSCOUNT`; do
755 for num in `seq $OSTCOUNT`; do
770 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
774 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
777 # We need ldiskfs here, may as well load them all
779 [ "$CLIENTONLY" ] && return
780 echo "Formatting mdts, osts"
781 for num in `seq $MDSCOUNT`; do
782 echo "Format mds$num: $(mdsdevname $num)"
784 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
786 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
790 for num in `seq $OSTCOUNT`; do
791 echo "Format ost$num: $(ostdevname $num)"
793 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
795 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
801 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
807 if [ -z "$CLIENTONLY" ]; then
808 echo "Setup mdts, osts"
809 for num in `seq $MDSCOUNT`; do
810 DEVNAME=$(mdsdevname $num)
811 echo $REFORMAT | grep -q "reformat" \
812 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
813 start mds$num $DEVNAME $MDS_MOUNT_OPTS
815 for num in `seq $OSTCOUNT`; do
816 DEVNAME=$(ostdevname $num)
817 start ost$num $DEVNAME $OST_MOUNT_OPTS
820 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
822 if [ "$MOUNT_2" ]; then
828 mounted_lustre_filesystems() {
829 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
832 check_and_setup_lustre() {
833 MOUNTED="`mounted_lustre_filesystems`"
834 if [ -z "$MOUNTED" ]; then
835 [ "$REFORMAT" ] && formatall
837 MOUNTED="`mounted_lustre_filesystems`"
838 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
841 if [ "$ONLY" == "setup" ]; then
846 cleanup_and_setup_lustre() {
847 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
848 sysctl -w lnet.debug=0 || true
850 if [ "$ONLY" == "cleanup" ]; then
854 check_and_setup_lustre
857 check_and_cleanup_lustre() {
858 if [ "`mount | grep $MOUNT`" ]; then
859 rm -rf $DIR/[Rdfs][1-9]*
861 if [ "$I_MOUNTED" = "yes" ]; then
862 cleanupall -f || error "cleanup failed"
874 while [ $NETWORK -eq 0 ]; do
875 ping -c 1 -w 3 $1 > /dev/null
876 if [ $? -eq 0 ]; then
880 echo "waiting for $1, $((MAX - WAIT)) secs left"
883 if [ $WAIT -gt $MAX ]; then
884 echo "Network not available"
890 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
901 # the sed converts spaces to commas, but leaves the last space
902 # alone, so the line doesn't end with a comma.
903 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
907 (cd `dirname $1`; echo $PWD/`basename $1`)
910 ##################################
914 # OBD_FAIL_MDS_ALL_REQUEST_NET
916 do_facet mds sysctl -w lustre.fail_loc=0x123
917 do_facet client "$1" || RC=$?
918 do_facet mds sysctl -w lustre.fail_loc=0
923 # OBD_FAIL_MDS_ALL_REPLY_NET
925 do_facet mds sysctl -w lustre.fail_loc=0x122
926 do_facet client "$@" || RC=$?
927 do_facet mds sysctl -w lustre.fail_loc=0
932 # OBD_FAIL_MDS_REINT_NET_REP
934 do_facet mds sysctl -w lustre.fail_loc=0x119
935 do_facet client "$@" || RC=$?
936 do_facet mds sysctl -w lustre.fail_loc=0
941 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
943 do_facet ost1 sysctl -w lustre.fail_loc=0x214
944 do_facet client "$1" || RC=$?
945 do_facet client "sync"
946 do_facet ost1 sysctl -w lustre.fail_loc=0
951 #define OBD_FAIL_LDLM_CANCEL 0x304
953 do_facet client sysctl -w lustre.fail_loc=0x304
954 do_facet client "$@" || RC=$?
955 do_facet client sysctl -w lustre.fail_loc=0
960 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
962 do_facet client sysctl -w lustre.fail_loc=0x305
963 do_facet client "$@" || RC=$?
964 do_facet client sysctl -w lustre.fail_loc=0
969 #define OBD_FAIL_LDLM_REPLY 0x30c
971 do_facet mds sysctl -w lustre.fail_loc=0x30c
972 do_facet client "$@" || RC=$?
973 do_facet mds sysctl -w lustre.fail_loc=0
981 echo "clearing fail_loc on $facet"
982 do_facet $facet "sysctl -w lustre.fail_loc=0"
986 $LCTL mark "cancel_lru_locks $1 start"
987 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
988 [ -f $d/lru_size ] && echo clear > $d/lru_size
989 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
991 $LCTL mark "cancel_lru_locks $1 stop"
996 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
997 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
998 echo there is still data in page cache $a ?
1007 DEBUGSAVE="$(sysctl -n lnet.debug)"
1011 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1016 ##################################
1020 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1021 log "${TESTSUITE} ${TESTNAME}: **** FAIL:" $@
1022 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1023 echo "Dumping lctl log to $ERRLOG"
1024 # We need to dump the logs on all nodes
1026 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1027 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1029 [ "$TESTSUITELOG" ] && echo "$0: FAIL: $TESTNAME $@" >> $TESTSUITELOG
1030 if $FAIL_ON_ERROR; then
1036 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1037 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1040 build_test_filter() {
1041 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1045 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1046 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1047 for E in $EXCEPT $ALWAYS_EXCEPT; do
1048 eval EXCEPT_${E}=true
1050 for G in $GRANT_CHECK_LIST; do
1051 eval GCHECK_ONLY_${G}=true
1060 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1064 export base=`basetest $1`
1065 if [ ! -z "$ONLY" ]; then
1067 if [ ${!testname}x != x ]; then
1072 if [ ${!testname}x != x ]; then
1080 if [ ${!testname}x != x ]; then
1081 TESTNAME=test_$1 skip "skipping excluded test $1"
1084 testname=EXCEPT_$base
1085 if [ ${!testname}x != x ]; then
1086 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1094 EQUALS="======================================================================"
1098 local suffixlen=$((${#EQUALS} - ${#msg}))
1099 [ $suffixlen -lt 5 ] && suffixlen=5
1100 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1105 lsmod | grep lnet > /dev/null || load_modules
1106 $LCTL mark "$*" 2> /dev/null || true
1111 strace -o $TMP/$1.strace -ttt $*
1113 log "FINISHED: $*: rc $RC"
1122 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1123 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1124 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1131 export tdir=d${base}
1134 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1136 export TESTNAME=test_$testnum
1137 test_${testnum} || error "test_$testnum failed with $?"
1139 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1140 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1141 error "LBUG/LASSERT detected"
1142 pass "($((`date +%s` - $BEFORE))s)"
1150 (cd `dirname $1`; echo $PWD/`basename $1`)
1154 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1155 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1160 export base=`basetest $1`
1161 [ "$CHECK_GRANT" == "no" ] && return 0
1163 testname=GCHECK_ONLY_${base}
1164 [ ${!testname}x == x ] && return 0
1166 echo -n "checking grant......"
1168 # write some data to sync client lost_grant
1169 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1170 for i in `seq $OSTCOUNT`; do
1171 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1172 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1173 count=1 > /dev/null 2>&1
1175 # sync all the data and make sure no pending data on server
1178 #get client grant and server grant
1180 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1181 client_grant=$((client_grant + `cat $d`))
1184 for d in ${LPROC}/obdfilter/*/tot_granted; do
1185 server_grant=$((server_grant + `cat $d`))
1188 # cleanup the check_grant file
1189 for i in `seq $OSTCOUNT`; do
1190 rm $DIR1/${tfile}_check_grant_$i
1193 #check whether client grant == server grant
1194 if [ $client_grant != $server_grant ]; then
1195 echo "failed: client:${client_grant} server: ${server_grant}"
1202 ########################
1208 ost=`echo $1 | awk -F_ '{print $3}'`
1209 if [ -z $ost ]; then
1210 ost=`echo $1 | sed 's/-osc.*//'`
1217 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1222 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1227 grep -q patchless $LPROC/version