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
163 load_module llite/llite_lloop
166 rm -f $TMP/ogdb-`hostname`
167 $LCTL modules > $TMP/ogdb-`hostname`
168 # 'mount' doesn't look in $PATH, just sbin
169 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
173 if [ `uname -r | cut -c 3` -eq 4 ]; then
181 MODULES=$($LCTL modules | awk '{ print $2 }')
182 while [ -n "$MODULES" ]; do
184 $RMMOD $MODULES > /dev/null 2>&1 || true
185 MODULES=$($LCTL modules | awk '{ print $2 }')
186 if [ -z "$MODULES" ]; then
190 echo "waiting, $((MAX - WAIT)) secs left"
192 if [ $WAIT -eq $MAX ]; then
193 echo "LNET modules $MODULES will not unload"
201 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
202 local MODULES=$($LCTL modules | awk '{ print $2 }')
203 $RMMOD $MODULES > /dev/null 2>&1 || true
204 # do it again, in case we tried to unload ksocklnd too early
205 MODULES=$($LCTL modules | awk '{ print $2 }')
206 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
207 MODULES=$($LCTL modules | awk '{ print $2 }')
208 if [ -n "$MODULES" ]; then
209 echo "Modules still loaded: "
211 if [ -e $LPROC ]; then
212 echo "Lustre still loaded"
213 cat $LPROC/devices || true
217 echo "Lustre stopped but LNET is still loaded, waiting..."
218 wait_for_lnet || return 3
223 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
224 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
225 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
226 echo "$LEAK_LUSTRE" 1>&2
227 echo "$LEAK_PORTALS" 1>&2
228 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
229 echo "Memory leaks detected"
230 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
233 echo "modules unloaded."
237 check_gss_daemon_facet() {
241 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
242 if [ $num -ne 1 ]; then
243 echo "$num instance of $dname on $facet"
252 do_facet $facet "killall -2 $@ 2>/dev/null || true"
255 start_gss_daemons() {
257 for num in `seq $MDSCOUNT`; do
258 do_facet mds$num "$LSVCGSSD -v"
260 do_facet mds$num "$LGSSD -v"
264 for num in `seq $OSTCOUNT`; do
265 do_facet ost$num "$LSVCGSSD -v"
268 # FIXME: is "client" the right facet name?
270 do_facet client "$LGSSD -v"
273 # wait daemons entering "stable" status
277 # check daemons are running
279 for num in `seq $MDSCOUNT`; do
280 check_gss_daemon_facet mds$num lsvcgssd
282 check_gss_daemon_facet mds$num lgssd
285 for num in `seq $OSTCOUNT`; do
286 check_gss_daemon_facet ost$num lsvcgssd
289 check_gss_daemon_facet client lgssd
294 for num in `seq $MDSCOUNT`; do
295 send_sigint mds$num lsvcgssd lgssd
297 for num in `seq $OSTCOUNT`; do
298 send_sigint ost$num lsvcgssd
300 send_sigint client lgssd
304 if [ ! -z $SEC ]; then
305 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
306 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
317 # maybe cleanup credential cache?
323 local device=`mdsdevname $num`
324 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
330 local device=`ostdevname $num`
331 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
336 # start facet device options
342 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
343 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
344 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
346 if [ $RC -ne 0 ]; then
347 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
348 echo Start of ${device} on ${facet} failed ${RC}
350 do_facet ${facet} sync
351 label=$(do_facet ${facet} "e2label ${device}")
352 [ -z "$label" ] && echo no label for ${device} && exit 1
353 eval export ${facet}_svc=${label}
354 eval export ${facet}_dev=${device}
355 eval export ${facet}_opt=\"$@\"
356 echo Started ${label}
365 HOST=`facet_active_host $facet`
366 [ -z $HOST ] && echo stop: no host for $facet && return 0
368 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
369 if [ ${running} -ne 0 ]; then
370 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
371 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
374 # umount should block, but we should wait for unrelated obd's
375 # like the MGS or MGC to also stop.
378 # conf-sanity 31 takes a long time cleanup
379 while [ $WAIT -lt 300 ]; do
380 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
381 if [ -z "${running}" ]; then
384 echo "waited $WAIT for${running}"
385 if [ $INTERVAL -lt 64 ]; then
386 INTERVAL=$((INTERVAL + INTERVAL))
389 WAIT=$((WAIT + INTERVAL))
391 echo "service didn't stop after $WAIT seconds. Still running:"
400 # Only supply -o to mount if we have options
401 if [ -n "$MOUNTOPT" ]; then
402 OPTIONS="-o $MOUNTOPT"
404 local device=$MGSNID:/$FSNAME
405 if [ -z "$mnt" -o -z "$FSNAME" ]; then
406 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
410 echo "Starting client: $OPTIONS $device $mnt"
411 do_node $client mkdir -p $mnt
412 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
414 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
415 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
423 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
424 if [ $running -ne 0 ]; then
425 echo "Stopping client $mnt (opts:$force)"
426 do_node $client umount $force $mnt
432 if [ "$FAILURE_MODE" = HARD ]; then
433 $POWER_DOWN `facet_active_host $facet`
435 elif [ "$FAILURE_MODE" = SOFT ]; then
442 if [ "$FAILURE_MODE" = HARD ]; then
443 $POWER_UP `facet_active_host $facet`
449 # verify that lustre actually cleaned up properly
451 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
452 error "LBUG/LASSERT detected"
453 BUSY=`dmesg | grep -i destruct || true`
456 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
459 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
460 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
461 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
462 echo "$0: $LEAK_LUSTRE" 1>&2
463 echo "$0: $LEAK_PORTALS" 1>&2
464 echo "$0: Memory leak(s) detected..." 1>&2
465 mv $TMP/debug $TMP/debug-leak.`date +%s`
469 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
470 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
472 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
473 echo "$0: modules still loaded..." 1>&2
480 wait_delete_completed () {
481 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
482 $LPROC/osc/*/kbytesavail`
486 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
488 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
489 $LPROC/osc/*/kbytesavail`
490 [ "$TOTAL" -eq "$TOTALPREV" ] && break
491 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
495 echo "Delete completed."
500 check_network "$HOST" 900
501 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
506 HOST=`facet_active_host $facet`
510 wait_mds_recovery_done () {
511 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
512 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
513 # as we are in process of changing obd_timeout in different ways
514 # let's set MAX longer than that
515 MAX=$(( timeout * 4 ))
517 while [ $WAIT -lt $MAX ]; do
518 STATUS=`do_facet mds grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
519 echo $STATUS | grep COMPLETE && return 0
522 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
524 echo "MDS recovery not done in $MAX sec"
529 # not every config has many clients
530 if [ ! -z "$CLIENTS" ]; then
531 $PDSH $CLIENTS "df $MOUNT" > /dev/null
536 uname -n >> $MOUNT/recon
537 if [ ! -z "$CLIENTS" ]; then
538 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
540 echo Connected clients:
542 ls -l $MOUNT/recon > /dev/null
548 echo "Failing $facet on node `facet_active_host $facet`"
549 shutdown_facet $facet
553 echo "df pid is $DFPID"
555 TO=`facet_active_host $facet`
556 echo "Failover $facet to $TO"
558 local dev=${facet}_dev
559 local opt=${facet}_opt
560 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
571 local svc=${facet}_svc
572 do_facet $facet $LCTL --device %${!svc} readonly
573 do_facet $facet $LCTL --device %${!svc} notransno
574 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
575 $LCTL mark "local REPLAY BARRIER on ${!svc}"
578 replay_barrier_nodf() {
579 local facet=$1 echo running=${running}
581 local svc=${facet}_svc
582 echo Replay barrier on ${!svc}
583 do_facet $facet $LCTL --device %${!svc} readonly
584 do_facet $facet $LCTL --device %${!svc} notransno
585 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
586 $LCTL mark "local REPLAY BARRIER on ${!svc}"
590 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
591 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
595 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
596 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
600 facet_failover $* || error "failover: $?"
601 df $MOUNT || error "post-failover df: $?"
608 local svc=${facet}_svc
609 local dev=${facet}_dev
610 local opt=${facet}_opt
611 start $facet ${!dev} ${!opt}
612 do_facet $facet lctl --device %${!svc} abort_recovery
613 df $MOUNT || echo "first df failed: $?"
615 df $MOUNT || error "post-failover df: $?"
619 echo There is no lmc. This is mountconf, baby.
624 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
625 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
631 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
637 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
638 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
639 if [ -z "$ID" ]; then
640 echo "Could not get a ptl id for $1..."
649 h2name_or_ip "$1" "tcp"
654 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
655 if type __h2elan >/dev/null 2>&1; then
658 ID=`echo $1 | sed 's/[^0-9]*//g'`
666 h2name_or_ip "$1" "openib"
671 h2name_or_ip "$1" "o2ib"
677 varname=${facet}_HOST
678 if [ -z "${!varname}" ]; then
679 if [ "${facet:0:3}" == "ost" ]; then
680 eval ${facet}_HOST=${ost_HOST}
688 local activevar=${facet}active
690 if [ -f ./${facet}active ] ; then
691 source ./${facet}active
695 if [ -z "$active" ] ; then
702 facet_active_host() {
704 local active=`facet_active $facet`
705 if [ "$facet" == client ]; then
708 echo `facet_host $active`
714 failover=${facet}failover
715 host=`facet_host $failover`
716 [ -z "$host" ] && return
717 curactive=`facet_active $facet`
718 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
719 eval export ${facet}active=$facet
721 eval export ${facet}active=$failover
723 # save the active host for this facet
724 activevar=${facet}active
725 echo "$activevar=${!activevar}" > ./$activevar
732 if [ "$HOST" = "$(hostname)" ]; then
736 echo "CMD: $HOST $@" >&2
737 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
739 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
740 return ${PIPESTATUS[0]}
746 HOST=`facet_active_host $facet`
747 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
754 # make sure its not already running
757 do_facet ${facet} $MKFS $*
763 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
764 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
771 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
772 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
780 # make sure we are using the primary server, so test-framework will
781 # be able to clean up properly.
782 activemds=`facet_active mds1`
783 if [ $activemds != "mds1" ]; then
787 # assume client mount is local
788 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
789 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
790 for num in `seq $MDSCOUNT`; do
793 for num in `seq $OSTCOUNT`; do
808 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
812 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
815 # We need ldiskfs here, may as well load them all
817 [ "$CLIENTONLY" ] && return
818 echo "Formatting mdts, osts"
819 for num in `seq $MDSCOUNT`; do
820 echo "Format mds$num: $(mdsdevname $num)"
822 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
824 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
828 for num in `seq $OSTCOUNT`; do
829 echo "Format ost$num: $(ostdevname $num)"
831 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
833 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
839 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
845 if [ -z "$CLIENTONLY" ]; then
846 echo "Setup mdts, osts"
847 for num in `seq $MDSCOUNT`; do
848 DEVNAME=$(mdsdevname $num)
849 echo $REFORMAT | grep -q "reformat" \
850 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
851 start mds$num $DEVNAME $MDS_MOUNT_OPTS
853 for num in `seq $OSTCOUNT`; do
854 DEVNAME=$(ostdevname $num)
855 start ost$num $DEVNAME $OST_MOUNT_OPTS
858 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
860 if [ "$MOUNT_2" ]; then
866 mounted_lustre_filesystems() {
867 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
870 check_and_setup_lustre() {
871 MOUNTED="`mounted_lustre_filesystems`"
872 if [ -z "$MOUNTED" ]; then
873 [ "$REFORMAT" ] && formatall
875 MOUNTED="`mounted_lustre_filesystems`"
876 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
879 if [ "$ONLY" == "setup" ]; then
884 cleanup_and_setup_lustre() {
885 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
886 sysctl -w lnet.debug=0 || true
888 if [ "$ONLY" == "cleanup" ]; then
892 check_and_setup_lustre
895 check_and_cleanup_lustre() {
896 if [ "`mount | grep $MOUNT`" ]; then
897 rm -rf $DIR/[Rdfs][1-9]*
899 if [ "$I_MOUNTED" = "yes" ]; then
900 cleanupall -f || error "cleanup failed"
912 while [ $NETWORK -eq 0 ]; do
913 ping -c 1 -w 3 $1 > /dev/null
914 if [ $? -eq 0 ]; then
918 echo "waiting for $1, $((MAX - WAIT)) secs left"
921 if [ $WAIT -gt $MAX ]; then
922 echo "Network not available"
928 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
939 # the sed converts spaces to commas, but leaves the last space
940 # alone, so the line doesn't end with a comma.
941 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
945 (cd `dirname $1`; echo $PWD/`basename $1`)
948 ##################################
952 # OBD_FAIL_MDS_ALL_REQUEST_NET
954 do_facet mds sysctl -w lustre.fail_loc=0x123
955 do_facet client "$1" || RC=$?
956 do_facet mds sysctl -w lustre.fail_loc=0
961 # OBD_FAIL_MDS_ALL_REPLY_NET
963 do_facet mds sysctl -w lustre.fail_loc=0x122
964 do_facet client "$@" || RC=$?
965 do_facet mds sysctl -w lustre.fail_loc=0
970 # OBD_FAIL_MDS_REINT_NET_REP
972 do_facet mds sysctl -w lustre.fail_loc=0x119
973 do_facet client "$@" || RC=$?
974 do_facet mds sysctl -w lustre.fail_loc=0
979 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
981 do_facet ost1 sysctl -w lustre.fail_loc=0x214
982 do_facet client "$1" || RC=$?
983 do_facet client "sync"
984 do_facet ost1 sysctl -w lustre.fail_loc=0
989 #define OBD_FAIL_LDLM_CANCEL 0x304
991 do_facet client sysctl -w lustre.fail_loc=0x304
992 do_facet client "$@" || RC=$?
993 do_facet client sysctl -w lustre.fail_loc=0
998 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1000 do_facet client sysctl -w lustre.fail_loc=0x305
1001 do_facet client "$@" || RC=$?
1002 do_facet client sysctl -w lustre.fail_loc=0
1007 #define OBD_FAIL_LDLM_REPLY 0x30c
1009 do_facet mds sysctl -w lustre.fail_loc=0x30c
1010 do_facet client "$@" || RC=$?
1011 do_facet mds sysctl -w lustre.fail_loc=0
1019 echo "clearing fail_loc on $facet"
1020 do_facet $facet "sysctl -w lustre.fail_loc=0"
1023 cancel_lru_locks() {
1024 $LCTL mark "cancel_lru_locks $1 start"
1025 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1026 [ -f $d/lru_size ] && echo clear > $d/lru_size
1027 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1029 $LCTL mark "cancel_lru_locks $1 stop"
1034 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1035 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1036 echo there is still data in page cache $a ?
1045 DEBUGSAVE="$(sysctl -n lnet.debug)"
1049 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1053 ##################################
1055 ##################################
1058 local FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
1059 local TYPE=${TYPE:-"FAIL"}
1061 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1062 log "${TESTSUITE} ${TESTNAME}: **** ${TYPE}:" $@
1063 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1064 echo "Dumping lctl log to $ERRLOG"
1065 # We need to dump the logs on all nodes
1067 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1068 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1070 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1071 if $FAIL_ON_ERROR; then
1076 # use only if we are ignoring failures for this test, bugno required.
1077 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1078 # e.g. error_ignore 5494 "your message"
1080 FAIL_ON_ERROR=false TYPE="IGNORE (bz$1)" error $2
1084 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1085 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1088 build_test_filter() {
1089 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1093 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1094 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1095 for E in $EXCEPT $ALWAYS_EXCEPT; do
1096 eval EXCEPT_${E}=true
1098 for G in $GRANT_CHECK_LIST; do
1099 eval GCHECK_ONLY_${G}=true
1108 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1112 export base=`basetest $1`
1113 if [ ! -z "$ONLY" ]; then
1115 if [ ${!testname}x != x ]; then
1120 if [ ${!testname}x != x ]; then
1128 if [ ${!testname}x != x ]; then
1129 TESTNAME=test_$1 skip "skipping excluded test $1"
1132 testname=EXCEPT_$base
1133 if [ ${!testname}x != x ]; then
1134 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1142 EQUALS="======================================================================"
1146 local suffixlen=$((${#EQUALS} - ${#msg}))
1147 [ $suffixlen -lt 5 ] && suffixlen=5
1148 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1153 lsmod | grep lnet > /dev/null || load_modules
1154 $LCTL mark "$*" 2> /dev/null || true
1159 strace -o $TMP/$1.strace -ttt $*
1161 log "FINISHED: $*: rc $RC"
1170 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1171 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1172 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1179 export tdir=d${base}
1182 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1184 export TESTNAME=test_$testnum
1185 test_${testnum} || error "test_$testnum failed with $?"
1187 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1188 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1189 error "LBUG/LASSERT detected"
1190 pass "($((`date +%s` - $BEFORE))s)"
1198 (cd `dirname $1`; echo $PWD/`basename $1`)
1202 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1203 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1208 export base=`basetest $1`
1209 [ "$CHECK_GRANT" == "no" ] && return 0
1211 testname=GCHECK_ONLY_${base}
1212 [ ${!testname}x == x ] && return 0
1214 echo -n "checking grant......"
1216 # write some data to sync client lost_grant
1217 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1218 for i in `seq $OSTCOUNT`; do
1219 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1220 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1221 count=1 > /dev/null 2>&1
1223 # sync all the data and make sure no pending data on server
1226 #get client grant and server grant
1228 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1229 client_grant=$((client_grant + `cat $d`))
1232 for d in ${LPROC}/obdfilter/*/tot_granted; do
1233 server_grant=$((server_grant + `cat $d`))
1236 # cleanup the check_grant file
1237 for i in `seq $OSTCOUNT`; do
1238 rm $DIR1/${tfile}_check_grant_$i
1241 #check whether client grant == server grant
1242 if [ $client_grant != $server_grant ]; then
1243 echo "failed: client:${client_grant} server: ${server_grant}"
1250 ########################
1256 ost=`echo $1 | awk -F_ '{print $3}'`
1257 if [ -z $ost ]; then
1258 ost=`echo $1 | sed 's/-osc.*//'`
1265 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1270 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1275 grep -q patchless $LPROC/version