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}
13 #export PDSH="pdsh -S -Rssh -w"
15 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
19 if [ -z "${!name}" ]; then
20 echo "$0: $name must be set"
24 [ $failed ] && exit 1 || true
28 echo "usage: $0 [-r] [-f cfgfile]"
35 export LUSTRE=`absolute_path $LUSTRE`
36 export TESTSUITE=`basename $0 .sh`
37 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
39 [ -d /r ] && export ROOT=${ROOT:-/r}
40 export TMP=${TMP:-$ROOT/tmp}
41 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
43 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
44 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
45 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
46 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
47 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
48 [ ! -f "$LFS" ] && export LFS=$(which lfs)
49 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
50 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
51 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
52 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
53 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
54 export FSYTPE=${FSTYPE:-"ldiskfs"}
55 export NAME=${NAME:-local}
56 export LPROC=/proc/fs/lustre
57 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
58 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
59 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
62 if [ "$ACCEPTOR_PORT" ]; then
63 export PORT_OPT="--port $ACCEPTOR_PORT"
68 echo "Using GSS/krb5 ptlrpc security flavor"
73 # Paths on remote nodes, if different
74 export RLUSTRE=${RLUSTRE:-$LUSTRE}
75 export RPWD=${RPWD:-$PWD}
76 export I_MOUNTED=${I_MOUNTED:-"no"}
80 while getopts "rvf:" opt $*; do
83 r) REFORMAT=--reformat;;
92 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
100 BASE=`basename $module $EXT`
101 lsmod | grep -q ${BASE} || \
102 if [ -f ${LUSTRE}/${module}${EXT} ]; then
103 insmod ${LUSTRE}/${module}${EXT} $@
105 # must be testing a "make install" or "rpm" installation
106 # note failed to load ptlrpc_gss is considered not fatal
107 if [ "$BASE" == "ptlrpc_gss" ]; then
108 modprobe $BASE $@ || echo "gss/krb5 is not supported"
116 if [ -n "$MODPROBE" ]; then
120 if [ "$HAVE_MODULES" = true ]; then
126 echo Loading modules from $LUSTRE
127 load_module ../lnet/libcfs/libcfs
128 [ -z "$LNETOPTS" ] && \
129 LNETOPTS=$(awk '/^options lnet/ { print $0}' /etc/modprobe.conf | sed 's/^options lnet //g')
130 echo "lnet options: '$LNETOPTS'"
131 # note that insmod will ignore anything in modprobe.conf
132 load_module ../lnet/lnet/lnet $LNETOPTS
133 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
134 load_module ../lnet/klnds/$LNETLND
135 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
136 load_module lvfs/lvfs
137 load_module obdclass/obdclass
138 load_module lvfs/fsfilt_$FSTYPE
139 load_module ptlrpc/ptlrpc
140 load_module ptlrpc/gss/ptlrpc_gss
141 # Now, some modules depend on lquota without USE_QUOTA check,
142 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
143 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
144 load_module quota/lquota
157 load_module obdfilter/obdfilter
158 load_module llite/lustre
161 rm -f $TMP/ogdb-`hostname`
162 $LCTL modules > $TMP/ogdb-`hostname`
163 # 'mount' doesn't look in $PATH, just sbin
164 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
168 if [ `uname -r | cut -c 3` -eq 4 ]; then
176 MODULES=$($LCTL modules | awk '{ print $2 }')
177 while [ -n "$MODULES" ]; do
179 $RMMOD $MODULES > /dev/null 2>&1 || true
180 MODULES=$($LCTL modules | awk '{ print $2 }')
181 if [ -z "$MODULES" ]; then
185 echo "waiting, $((MAX - WAIT)) secs left"
187 if [ $WAIT -eq $MAX ]; then
188 echo "LNET modules $MODULES will not unload"
196 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
197 local MODULES=$($LCTL modules | awk '{ print $2 }')
198 $RMMOD $MODULES > /dev/null 2>&1 || true
199 # do it again, in case we tried to unload ksocklnd too early
200 MODULES=$($LCTL modules | awk '{ print $2 }')
201 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
202 MODULES=$($LCTL modules | awk '{ print $2 }')
203 if [ -n "$MODULES" ]; then
204 echo "Modules still loaded: "
206 if [ -e $LPROC ]; then
207 echo "Lustre still loaded"
208 cat $LPROC/devices || true
212 echo "Lustre stopped but LNET is still loaded, waiting..."
213 wait_for_lnet || return 3
218 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
219 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
220 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
221 echo "$LEAK_LUSTRE" 1>&2
222 echo "$LEAK_PORTALS" 1>&2
223 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
224 echo "Memory leaks detected"
227 echo "modules unloaded."
231 check_gss_daemon_facet() {
235 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
236 if [ $num -ne 1 ]; then
237 echo "$num instance of $dname on $facet"
246 do_facet $facet "killall -2 $@ 2>/dev/null || true"
249 start_gss_daemons() {
251 for num in `seq $MDSCOUNT`; do
252 do_facet mds$num "$LSVCGSSD -v"
253 if [ "x$GSS_PIPEFS" == "xy" ]; then
254 do_facet mds$num "$LGSSD -v"
258 for num in `seq $OSTCOUNT`; do
259 do_facet ost$num "$LSVCGSSD -v"
262 # FIXME: is "client" the right facet name?
263 if [ "x$GSS_PIPEFS" == "xy" ]; then
264 do_facet client "$LGSSD -v"
267 # wait daemons entering "stable" status
271 # check daemons are running
273 for num in `seq $MDSCOUNT`; do
274 check_gss_daemon_facet mds$num lsvcgssd
275 if [ "x$GSS_PIPEFS" == "xy" ]; then
276 check_gss_daemon_facet mds$num lgssd
279 for num in `seq $OSTCOUNT`; do
280 check_gss_daemon_facet ost$num lsvcgssd
282 if [ "x$GSS_PIPEFS" == "xy" ]; then
283 check_gss_daemon_facet client lgssd
288 for num in `seq $MDSCOUNT`; do
289 send_sigint mds$num lsvcgssd lgssd
291 for num in `seq $OSTCOUNT`; do
292 send_sigint ost$num lsvcgssd
294 send_sigint client lgssd
298 if [ ! -z $SEC ]; then
299 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
300 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
303 if [ ! -z $USING_KRB5 ]; then
309 if [ ! -z $USING_KRB5 ]; then
311 # maybe cleanup credential cache?
317 local device=`mdsdevname $num`
318 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
324 local device=`ostdevname $num`
325 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
330 # start facet device options
336 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
337 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
338 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
340 if [ $RC -ne 0 ]; then
341 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
342 echo Start of ${device} on ${facet} failed ${RC}
344 do_facet ${facet} sync
345 label=$(do_facet ${facet} "e2label ${device}")
346 [ -z "$label" ] && echo no label for ${device} && exit 1
347 eval export ${facet}_svc=${label}
348 eval export ${facet}_dev=${device}
349 eval export ${facet}_opt=\"$@\"
350 echo Started ${label}
359 HOST=`facet_active_host $facet`
360 [ -z $HOST ] && echo stop: no host for $facet && return 0
362 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
363 if [ ${running} -ne 0 ]; then
364 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
365 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
368 # umount should block, but we should wait for unrelated obd's
369 # like the MGS or MGC to also stop.
372 # conf-sanity 31 takes a long time cleanup
373 while [ $WAIT -lt 300 ]; do
374 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
375 if [ -z "${running}" ]; then
378 echo "waited $WAIT for${running}"
379 if [ $INTERVAL -lt 64 ]; then
380 INTERVAL=$((INTERVAL + INTERVAL))
383 WAIT=$((WAIT + INTERVAL))
385 echo "service didn't stop after $WAIT seconds. Still running:"
394 # Only supply -o to mount if we have options
395 if [ -n "$MOUNTOPT" ]; then
396 OPTIONS="-o $MOUNTOPT"
398 local device=$MGSNID:/$FSNAME
399 if [ -z "$mnt" -o -z "$FSNAME" ]; then
400 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
404 echo "Starting client: $OPTIONS $device $mnt"
405 do_node $client mkdir -p $mnt
406 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
408 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
409 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
417 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
418 if [ $running -ne 0 ]; then
419 echo "Stopping client $mnt (opts:$force)"
420 do_node $client umount $force $mnt
426 if [ "$FAILURE_MODE" = HARD ]; then
427 $POWER_DOWN `facet_active_host $facet`
429 elif [ "$FAILURE_MODE" = SOFT ]; then
436 if [ "$FAILURE_MODE" = HARD ]; then
437 $POWER_UP `facet_active_host $facet`
443 # verify that lustre actually cleaned up properly
445 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
446 error "LBUG/LASSERT detected"
447 BUSY=`dmesg | grep -i destruct || true`
450 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
453 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
454 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
455 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
456 echo "$0: $LEAK_LUSTRE" 1>&2
457 echo "$0: $LEAK_PORTALS" 1>&2
458 echo "$0: Memory leak(s) detected..." 1>&2
459 mv $TMP/debug $TMP/debug-leak.`date +%s`
463 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
464 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
466 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
467 echo "$0: modules still loaded..." 1>&2
476 check_network "$HOST" 900
477 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
482 HOST=`facet_active_host $facet`
487 # not every config has many clients
488 if [ ! -z "$CLIENTS" ]; then
489 $PDSH $CLIENTS "df $MOUNT" > /dev/null
494 uname -n >> $MOUNT/recon
495 if [ ! -z "$CLIENTS" ]; then
496 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
498 echo Connected clients:
500 ls -l $MOUNT/recon > /dev/null
506 echo "Failing $facet on node `facet_active_host $facet`"
507 shutdown_facet $facet
511 echo "df pid is $DFPID"
513 TO=`facet_active_host $facet`
514 echo "Failover $facet to $TO"
516 local dev=${facet}_dev
517 local opt=${facet}_opt
518 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
529 local svc=${facet}_svc
530 do_facet $facet $LCTL --device %${!svc} readonly
531 do_facet $facet $LCTL --device %${!svc} notransno
532 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
533 $LCTL mark "local REPLAY BARRIER on ${!svc}"
536 replay_barrier_nodf() {
537 local facet=$1 echo running=${running}
539 local svc=${facet}_svc
540 echo Replay barrier on ${!svc}
541 do_facet $facet $LCTL --device %${!svc} readonly
542 do_facet $facet $LCTL --device %${!svc} notransno
543 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
544 $LCTL mark "local REPLAY BARRIER on ${!svc}"
548 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
549 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
553 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
554 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
558 facet_failover $* || error "failover: $?"
559 df $MOUNT || error "post-failover df: $?"
566 local svc=${facet}_svc
567 local dev=${facet}_dev
568 local opt=${facet}_opt
569 start $facet ${!dev} ${!opt}
570 do_facet $facet lctl --device %${!svc} abort_recovery
571 df $MOUNT || echo "first df failed: $?"
573 df $MOUNT || error "post-failover df: $?"
577 echo There is no lmc. This is mountconf, baby.
582 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
583 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
589 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
595 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
596 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
597 if [ -z "$ID" ]; then
598 echo "Could not get a ptl id for $1..."
607 h2name_or_ip "$1" "tcp"
612 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
613 if type __h2elan >/dev/null 2>&1; then
616 ID=`echo $1 | sed 's/[^0-9]*//g'`
624 h2name_or_ip "$1" "openib"
629 h2name_or_ip "$1" "o2ib"
635 varname=${facet}_HOST
636 if [ -z "${!varname}" ]; then
637 if [ "${facet:0:3}" == "ost" ]; then
638 eval ${facet}_HOST=${ost_HOST}
646 local activevar=${facet}active
648 if [ -f ./${facet}active ] ; then
649 source ./${facet}active
653 if [ -z "$active" ] ; then
660 facet_active_host() {
662 local active=`facet_active $facet`
663 if [ "$facet" == client ]; then
666 echo `facet_host $active`
672 failover=${facet}failover
673 host=`facet_host $failover`
674 [ -z "$host" ] && return
675 curactive=`facet_active $facet`
676 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
677 eval export ${facet}active=$facet
679 eval export ${facet}active=$failover
681 # save the active host for this facet
682 activevar=${facet}active
683 echo "$activevar=${!activevar}" > ./$activevar
690 if [ "$HOST" = "$(hostname)" ]; then
694 echo "CMD: $HOST $@" >&2
695 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
697 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
698 return ${PIPESTATUS[0]}
704 HOST=`facet_active_host $facet`
705 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
712 # make sure its not already running
715 do_facet ${facet} $MKFS $*
721 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
722 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
729 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
730 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
738 # make sure we are using the primary server, so test-framework will
739 # be able to clean up properly.
740 activemds=`facet_active mds1`
741 if [ $activemds != "mds1" ]; then
745 # assume client mount is local
746 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
747 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
748 for num in `seq $MDSCOUNT`; do
751 for num in `seq $OSTCOUNT`; do
766 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
770 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
773 # We need ldiskfs here, may as well load them all
775 [ "$CLIENTONLY" ] && return
776 echo "Formatting mdts, osts"
777 for num in `seq $MDSCOUNT`; do
778 echo "Format mds$num: $(mdsdevname $num)"
780 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
782 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
786 for num in `seq $OSTCOUNT`; do
787 echo "Format ost$num: $(ostdevname $num)"
789 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
791 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
797 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
803 if [ -z "$CLIENTONLY" ]; then
804 echo "Setup mdts, osts"
805 for num in `seq $MDSCOUNT`; do
806 DEVNAME=$(mdsdevname $num)
807 echo $REFORMAT | grep -q "reformat" \
808 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
809 start mds$num $DEVNAME $MDS_MOUNT_OPTS
811 for num in `seq $OSTCOUNT`; do
812 DEVNAME=$(ostdevname $num)
813 start ost$num $DEVNAME $OST_MOUNT_OPTS
816 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
818 if [ "$MOUNT_2" ]; then
824 mounted_lustre_filesystems() {
825 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
828 check_and_setup_lustre() {
829 MOUNTED="`mounted_lustre_filesystems`"
830 if [ -z "$MOUNTED" ]; then
831 [ "$REFORMAT" ] && formatall
833 MOUNTED="`mounted_lustre_filesystems`"
834 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
837 if [ "$ONLY" == "setup" ]; then
842 cleanup_and_setup_lustre() {
843 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
844 sysctl -w lnet.debug=0 || true
846 if [ "$ONLY" == "cleanup" ]; then
850 check_and_setup_lustre
853 check_and_cleanup_lustre() {
854 if [ "`mount | grep $MOUNT`" ]; then
855 rm -rf $DIR/[Rdfs][1-9]*
857 if [ "$I_MOUNTED" = "yes" ]; then
858 cleanupall -f || error "cleanup failed"
870 while [ $NETWORK -eq 0 ]; do
871 ping -c 1 -w 3 $1 > /dev/null
872 if [ $? -eq 0 ]; then
876 echo "waiting for $1, $((MAX - WAIT)) secs left"
879 if [ $WAIT -gt $MAX ]; then
880 echo "Network not available"
886 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
897 # the sed converts spaces to commas, but leaves the last space
898 # alone, so the line doesn't end with a comma.
899 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
903 (cd `dirname $1`; echo $PWD/`basename $1`)
906 ##################################
910 # OBD_FAIL_MDS_ALL_REQUEST_NET
912 do_facet mds sysctl -w lustre.fail_loc=0x123
913 do_facet client "$1" || RC=$?
914 do_facet mds sysctl -w lustre.fail_loc=0
919 # OBD_FAIL_MDS_ALL_REPLY_NET
921 do_facet mds sysctl -w lustre.fail_loc=0x122
922 do_facet client "$@" || RC=$?
923 do_facet mds sysctl -w lustre.fail_loc=0
928 # OBD_FAIL_MDS_REINT_NET_REP
930 do_facet mds sysctl -w lustre.fail_loc=0x119
931 do_facet client "$@" || RC=$?
932 do_facet mds sysctl -w lustre.fail_loc=0
937 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
939 do_facet ost1 sysctl -w lustre.fail_loc=0x214
940 do_facet client "$1" || RC=$?
941 do_facet client "sync"
942 do_facet ost1 sysctl -w lustre.fail_loc=0
947 #define OBD_FAIL_LDLM_CANCEL 0x304
949 do_facet client sysctl -w lustre.fail_loc=0x304
950 do_facet client "$@" || RC=$?
951 do_facet client sysctl -w lustre.fail_loc=0
956 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
958 do_facet client sysctl -w lustre.fail_loc=0x305
959 do_facet client "$@" || RC=$?
960 do_facet client sysctl -w lustre.fail_loc=0
965 #define OBD_FAIL_LDLM_REPLY 0x30c
967 do_facet mds sysctl -w lustre.fail_loc=0x30c
968 do_facet client "$@" || RC=$?
969 do_facet mds sysctl -w lustre.fail_loc=0
977 echo "clearing fail_loc on $facet"
978 do_facet $facet "sysctl -w lustre.fail_loc=0"
982 $LCTL mark "cancel_lru_locks $1 start"
983 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
984 [ -f $d/lru_size ] && echo clear > $d/lru_size
985 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
987 $LCTL mark "cancel_lru_locks $1 stop"
992 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
993 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
994 echo there is still data in page cache $a ?
1003 DEBUGSAVE="$(sysctl -n lnet.debug)"
1007 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1012 ##################################
1016 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1017 log "${TESTSUITE} ${TESTNAME}: **** FAIL:" $@
1018 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1019 echo "Dumping lctl log to $ERRLOG"
1020 # We need to dump the logs on all nodes
1022 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1023 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1025 [ "$TESTSUITELOG" ] && echo "$0: FAIL: $TESTNAME $@" >> $TESTSUITELOG
1026 if $FAIL_ON_ERROR; then
1032 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1033 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1036 build_test_filter() {
1037 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1041 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1042 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1043 for E in $EXCEPT $ALWAYS_EXCEPT; do
1044 eval EXCEPT_${E}=true
1046 for G in $GRANT_CHECK_LIST; do
1047 eval GCHECK_ONLY_${G}=true
1056 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1060 export base=`basetest $1`
1061 if [ ! -z "$ONLY" ]; then
1063 if [ ${!testname}x != x ]; then
1068 if [ ${!testname}x != x ]; then
1076 if [ ${!testname}x != x ]; then
1077 TESTNAME=test_$1 skip "skipping excluded test $1"
1080 testname=EXCEPT_$base
1081 if [ ${!testname}x != x ]; then
1082 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1090 EQUALS="======================================================================"
1094 local suffixlen=$((${#EQUALS} - ${#msg}))
1095 [ $suffixlen -lt 5 ] && suffixlen=5
1096 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1101 lsmod | grep lnet > /dev/null || load_modules
1102 $LCTL mark "$*" 2> /dev/null || true
1107 strace -o $TMP/$1.strace -ttt $*
1109 log "FINISHED: $*: rc $RC"
1118 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1119 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1120 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1127 export tdir=d${base}
1130 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1132 export TESTNAME=test_$testnum
1133 test_${testnum} || error "test_$testnum failed with $?"
1135 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1136 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1137 error "LBUG/LASSERT detected"
1138 pass "($((`date +%s` - $BEFORE))s)"
1146 (cd `dirname $1`; echo $PWD/`basename $1`)
1150 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1151 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1156 export base=`basetest $1`
1157 [ "$CHECK_GRANT" == "no" ] && return 0
1159 testname=GCHECK_ONLY_${base}
1160 [ ${!testname}x == x ] && return 0
1162 echo -n "checking grant......"
1164 # write some data to sync client lost_grant
1165 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1166 for i in `seq $OSTCOUNT`; do
1167 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1168 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1169 count=1 > /dev/null 2>&1
1171 # sync all the data and make sure no pending data on server
1174 #get client grant and server grant
1176 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1177 client_grant=$((client_grant + `cat $d`))
1180 for d in ${LPROC}/obdfilter/*/tot_granted; do
1181 server_grant=$((server_grant + `cat $d`))
1184 # cleanup the check_grant file
1185 for i in `seq $OSTCOUNT`; do
1186 rm $DIR1/${tfile}_check_grant_$i
1189 #check whether client grant == server grant
1190 if [ $client_grant != $server_grant ]; then
1191 echo "failed: client:${client_grant} server: ${server_grant}"
1198 ########################
1204 ost=`echo $1 | awk -F_ '{print $3}'`
1205 if [ -z $ost ]; then
1206 ost=`echo $1 | sed 's/-osc.*//'`
1213 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1218 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1223 grep -q patchless $LPROC/version