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 do_facet mds$num "$LGSSD -v"
256 for num in `seq $OSTCOUNT`; do
257 do_facet ost$num "$LSVCGSSD -v"
260 # FIXME: is "client" the right facet name?
261 do_facet client "$LGSSD -v"
263 # wait daemons entering "stable" status
267 # check daemons are running
269 for num in `seq $MDSCOUNT`; do
270 check_gss_daemon_facet mds$num lsvcgssd
271 check_gss_daemon_facet mds$num lgssd
273 for num in `seq $OSTCOUNT`; do
274 check_gss_daemon_facet ost$num lsvcgssd
276 check_gss_daemon_facet client lgssd
280 for num in `seq $MDSCOUNT`; do
281 send_sigint mds$num lsvcgssd lgssd
283 for num in `seq $OSTCOUNT`; do
284 send_sigint ost$num lsvcgssd
286 send_sigint client lgssd
290 if [ ! -z $SEC ]; then
291 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
292 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
295 if [ ! -z $USING_KRB5 ]; then
301 if [ ! -z $USING_KRB5 ]; then
303 # maybe cleanup credential cache?
309 local device=`mdsdevname $num`
310 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
316 local device=`ostdevname $num`
317 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
322 # start facet device options
328 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
329 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
330 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
332 if [ $RC -ne 0 ]; then
333 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
334 echo Start of ${device} on ${facet} failed ${RC}
336 do_facet ${facet} sync
337 label=$(do_facet ${facet} "e2label ${device}")
338 [ -z "$label" ] && echo no label for ${device} && exit 1
339 eval export ${facet}_svc=${label}
340 eval export ${facet}_dev=${device}
341 eval export ${facet}_opt=\"$@\"
342 echo Started ${label}
351 HOST=`facet_active_host $facet`
352 [ -z $HOST ] && echo stop: no host for $facet && return 0
354 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
355 if [ ${running} -ne 0 ]; then
356 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
357 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
360 # umount should block, but we should wait for unrelated obd's
361 # like the MGS or MGC to also stop.
364 # conf-sanity 31 takes a long time cleanup
365 while [ $WAIT -lt 300 ]; do
366 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
367 if [ -z "${running}" ]; then
370 echo "waited $WAIT for${running}"
371 if [ $INTERVAL -lt 64 ]; then
372 INTERVAL=$((INTERVAL + INTERVAL))
375 WAIT=$((WAIT + INTERVAL))
377 echo "service didn't stop after $WAIT seconds. Still running:"
386 # Only supply -o to mount if we have options
387 if [ -n "$MOUNTOPT" ]; then
388 OPTIONS="-o $MOUNTOPT"
390 local device=$MGSNID:/$FSNAME
391 if [ -z "$mnt" -o -z "$FSNAME" ]; then
392 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
396 echo "Starting client: $OPTIONS $device $mnt"
397 do_node $client mkdir -p $mnt
398 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
400 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
401 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
409 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
410 if [ $running -ne 0 ]; then
411 echo "Stopping client $mnt (opts:$force)"
412 do_node $client umount $force $mnt
418 if [ "$FAILURE_MODE" = HARD ]; then
419 $POWER_DOWN `facet_active_host $facet`
421 elif [ "$FAILURE_MODE" = SOFT ]; then
428 if [ "$FAILURE_MODE" = HARD ]; then
429 $POWER_UP `facet_active_host $facet`
435 # verify that lustre actually cleaned up properly
437 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
438 error "LBUG/LASSERT detected"
439 BUSY=`dmesg | grep -i destruct || true`
442 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
445 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
446 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
447 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
448 echo "$0: $LEAK_LUSTRE" 1>&2
449 echo "$0: $LEAK_PORTALS" 1>&2
450 echo "$0: Memory leak(s) detected..." 1>&2
451 mv $TMP/debug $TMP/debug-leak.`date +%s`
455 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
456 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
458 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
459 echo "$0: modules still loaded..." 1>&2
468 check_network "$HOST" 900
469 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
474 HOST=`facet_active_host $facet`
479 # not every config has many clients
480 if [ ! -z "$CLIENTS" ]; then
481 $PDSH $CLIENTS "df $MOUNT" > /dev/null
486 uname -n >> $MOUNT/recon
487 if [ ! -z "$CLIENTS" ]; then
488 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
490 echo Connected clients:
492 ls -l $MOUNT/recon > /dev/null
498 echo "Failing $facet on node `facet_active_host $facet`"
499 shutdown_facet $facet
503 echo "df pid is $DFPID"
505 TO=`facet_active_host $facet`
506 echo "Failover $facet to $TO"
508 local dev=${facet}_dev
509 local opt=${facet}_opt
510 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
521 local svc=${facet}_svc
522 do_facet $facet $LCTL --device %${!svc} readonly
523 do_facet $facet $LCTL --device %${!svc} notransno
524 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
525 $LCTL mark "local REPLAY BARRIER on ${!svc}"
528 replay_barrier_nodf() {
529 local facet=$1 echo running=${running}
531 local svc=${facet}_svc
532 echo Replay barrier on ${!svc}
533 do_facet $facet $LCTL --device %${!svc} readonly
534 do_facet $facet $LCTL --device %${!svc} notransno
535 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
536 $LCTL mark "local REPLAY BARRIER on ${!svc}"
540 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
541 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
545 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
546 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
550 facet_failover $* || error "failover: $?"
551 df $MOUNT || error "post-failover df: $?"
558 local svc=${facet}_svc
559 local dev=${facet}_dev
560 local opt=${facet}_opt
561 start $facet ${!dev} ${!opt}
562 do_facet $facet lctl --device %${!svc} abort_recovery
563 df $MOUNT || echo "first df failed: $?"
565 df $MOUNT || error "post-failover df: $?"
569 echo There is no lmc. This is mountconf, baby.
574 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
575 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
581 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
587 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
588 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
589 if [ -z "$ID" ]; then
590 echo "Could not get a ptl id for $1..."
599 h2name_or_ip "$1" "tcp"
604 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
605 if type __h2elan >/dev/null 2>&1; then
608 ID=`echo $1 | sed 's/[^0-9]*//g'`
616 h2name_or_ip "$1" "openib"
621 h2name_or_ip "$1" "o2ib"
627 varname=${facet}_HOST
628 if [ -z "${!varname}" ]; then
629 if [ "${facet:0:3}" == "ost" ]; then
630 eval ${facet}_HOST=${ost_HOST}
638 local activevar=${facet}active
640 if [ -f ./${facet}active ] ; then
641 source ./${facet}active
645 if [ -z "$active" ] ; then
652 facet_active_host() {
654 local active=`facet_active $facet`
655 if [ "$facet" == client ]; then
658 echo `facet_host $active`
664 failover=${facet}failover
665 host=`facet_host $failover`
666 [ -z "$host" ] && return
667 curactive=`facet_active $facet`
668 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
669 eval export ${facet}active=$facet
671 eval export ${facet}active=$failover
673 # save the active host for this facet
674 activevar=${facet}active
675 echo "$activevar=${!activevar}" > ./$activevar
682 if [ "$HOST" = "$(hostname)" ]; then
686 echo "CMD: $HOST $@" >&2
687 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
689 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
690 return ${PIPESTATUS[0]}
696 HOST=`facet_active_host $facet`
697 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
704 # make sure its not already running
707 do_facet ${facet} $MKFS $*
713 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
714 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
721 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
722 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
730 # make sure we are using the primary server, so test-framework will
731 # be able to clean up properly.
732 activemds=`facet_active mds1`
733 if [ $activemds != "mds1" ]; then
737 # assume client mount is local
738 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
739 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
740 for num in `seq $MDSCOUNT`; do
743 for num in `seq $OSTCOUNT`; do
758 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
762 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
765 # We need ldiskfs here, may as well load them all
767 [ "$CLIENTONLY" ] && return
768 echo "Formatting mdts, osts"
769 for num in `seq $MDSCOUNT`; do
770 echo "Format mds$num: $(mdsdevname $num)"
772 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
774 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
778 for num in `seq $OSTCOUNT`; do
779 echo "Format ost$num: $(ostdevname $num)"
781 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
783 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
789 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
795 if [ -z "$CLIENTONLY" ]; then
796 echo "Setup mdts, osts"
797 for num in `seq $MDSCOUNT`; do
798 DEVNAME=$(mdsdevname $num)
799 echo $REFORMAT | grep -q "reformat" \
800 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
801 start mds$num $DEVNAME $MDS_MOUNT_OPTS
803 for num in `seq $OSTCOUNT`; do
804 DEVNAME=$(ostdevname $num)
805 start ost$num $DEVNAME $OST_MOUNT_OPTS
808 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
810 if [ "$MOUNT_2" ]; then
816 mounted_lustre_filesystems() {
817 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
820 check_and_setup_lustre() {
821 MOUNTED="`mounted_lustre_filesystems`"
822 if [ -z "$MOUNTED" ]; then
823 [ "$REFORMAT" ] && formatall
825 MOUNTED="`mounted_lustre_filesystems`"
826 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
829 if [ "$ONLY" == "setup" ]; then
834 cleanup_and_setup_lustre() {
835 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
836 sysctl -w lnet.debug=0 || true
838 if [ "$ONLY" == "cleanup" ]; then
842 check_and_setup_lustre
845 check_and_cleanup_lustre() {
846 if [ "`mount | grep $MOUNT`" ]; then
847 rm -rf $DIR/[Rdfs][1-9]*
849 if [ "$I_MOUNTED" = "yes" ]; then
850 cleanupall -f || error "cleanup failed"
862 while [ $NETWORK -eq 0 ]; do
863 ping -c 1 -w 3 $1 > /dev/null
864 if [ $? -eq 0 ]; then
868 echo "waiting for $1, $((MAX - WAIT)) secs left"
871 if [ $WAIT -gt $MAX ]; then
872 echo "Network not available"
878 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
889 # the sed converts spaces to commas, but leaves the last space
890 # alone, so the line doesn't end with a comma.
891 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
895 (cd `dirname $1`; echo $PWD/`basename $1`)
898 ##################################
902 # OBD_FAIL_MDS_ALL_REQUEST_NET
904 do_facet mds sysctl -w lustre.fail_loc=0x123
905 do_facet client "$1" || RC=$?
906 do_facet mds sysctl -w lustre.fail_loc=0
911 # OBD_FAIL_MDS_ALL_REPLY_NET
913 do_facet mds sysctl -w lustre.fail_loc=0x122
914 do_facet client "$@" || RC=$?
915 do_facet mds sysctl -w lustre.fail_loc=0
920 # OBD_FAIL_MDS_REINT_NET_REP
922 do_facet mds sysctl -w lustre.fail_loc=0x119
923 do_facet client "$@" || RC=$?
924 do_facet mds sysctl -w lustre.fail_loc=0
929 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
931 do_facet ost1 sysctl -w lustre.fail_loc=0x214
932 do_facet client "$1" || RC=$?
933 do_facet client "sync"
934 do_facet ost1 sysctl -w lustre.fail_loc=0
939 #define OBD_FAIL_LDLM_CANCEL 0x304
941 do_facet client sysctl -w lustre.fail_loc=0x304
942 do_facet client "$@" || RC=$?
943 do_facet client sysctl -w lustre.fail_loc=0
948 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
950 do_facet client sysctl -w lustre.fail_loc=0x305
951 do_facet client "$@" || RC=$?
952 do_facet client sysctl -w lustre.fail_loc=0
957 #define OBD_FAIL_LDLM_REPLY 0x30c
959 do_facet mds sysctl -w lustre.fail_loc=0x30c
960 do_facet client "$@" || RC=$?
961 do_facet mds sysctl -w lustre.fail_loc=0
969 echo "clearing fail_loc on $facet"
970 do_facet $facet "sysctl -w lustre.fail_loc=0"
974 $LCTL mark "cancel_lru_locks $1 start"
975 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
976 [ -f $d/lru_size ] && echo clear > $d/lru_size
977 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
979 $LCTL mark "cancel_lru_locks $1 stop"
984 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
985 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
986 echo there is still data in page cache $a ?
995 DEBUGSAVE="$(sysctl -n lnet.debug)"
999 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1004 ##################################
1008 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1009 log "${TESTSUITE} ${TESTNAME}: **** FAIL:" $@
1010 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1011 echo "Dumping lctl log to $ERRLOG"
1012 # We need to dump the logs on all nodes
1014 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1015 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1017 [ "$TESTSUITELOG" ] && echo "$0: FAIL: $TESTNAME $@" >> $TESTSUITELOG
1018 if $FAIL_ON_ERROR; then
1024 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1025 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1028 build_test_filter() {
1029 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1033 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1034 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1035 for E in $EXCEPT $ALWAYS_EXCEPT; do
1036 eval EXCEPT_${E}=true
1038 for G in $GRANT_CHECK_LIST; do
1039 eval GCHECK_ONLY_${G}=true
1048 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1052 export base=`basetest $1`
1053 if [ ! -z "$ONLY" ]; then
1055 if [ ${!testname}x != x ]; then
1060 if [ ${!testname}x != x ]; then
1068 if [ ${!testname}x != x ]; then
1069 TESTNAME=test_$1 skip "skipping excluded test $1"
1072 testname=EXCEPT_$base
1073 if [ ${!testname}x != x ]; then
1074 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1082 EQUALS="======================================================================"
1086 local suffixlen=$((${#EQUALS} - ${#msg}))
1087 [ $suffixlen -lt 5 ] && suffixlen=5
1088 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1093 lsmod | grep lnet > /dev/null || load_modules
1094 $LCTL mark "$*" 2> /dev/null || true
1099 strace -o $TMP/$1.strace -ttt $*
1101 log "FINISHED: $*: rc $RC"
1110 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1111 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1112 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1119 export tdir=d${base}
1122 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1124 export TESTNAME=test_$testnum
1125 test_${testnum} || error "test_$testnum failed with $?"
1127 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1128 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1129 error "LBUG/LASSERT detected"
1130 pass "($((`date +%s` - $BEFORE))s)"
1138 (cd `dirname $1`; echo $PWD/`basename $1`)
1142 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1143 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1148 export base=`basetest $1`
1149 [ "$CHECK_GRANT" == "no" ] && return 0
1151 testname=GCHECK_ONLY_${base}
1152 [ ${!testname}x == x ] && return 0
1154 echo -n "checking grant......"
1156 # write some data to sync client lost_grant
1157 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1158 for i in `seq $OSTCOUNT`; do
1159 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1160 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1161 count=1 > /dev/null 2>&1
1163 # sync all the data and make sure no pending data on server
1166 #get client grant and server grant
1168 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1169 client_grant=$((client_grant + `cat $d`))
1172 for d in ${LPROC}/obdfilter/*/tot_granted; do
1173 server_grant=$((server_grant + `cat $d`))
1176 # cleanup the check_grant file
1177 for i in `seq $OSTCOUNT`; do
1178 rm $DIR1/${tfile}_check_grant_$i
1181 #check whether client grant == server grant
1182 if [ $client_grant != $server_grant ]; then
1183 echo "failed: client:${client_grant} server: ${server_grant}"
1190 ########################
1196 ost=`echo $1 | awk -F_ '{print $3}'`
1197 if [ -z $ost ]; then
1198 ost=`echo $1 | sed 's/-osc.*//'`
1205 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1210 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1215 grep -q patchless $LPROC/version