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`
490 wait_mds_recovery_done () {
491 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
492 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
493 # as we are in process of changing obd_timeout in different ways
494 # let's set MAX longer than that
495 MAX=$(( timeout * 4 ))
497 while [ $WAIT -lt $MAX ]; do
498 STATUS=`do_facet mds grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
499 echo $STATUS | grep COMPLETE && return 0
502 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
504 echo "MDS recovery not done in $MAX sec"
509 # not every config has many clients
510 if [ ! -z "$CLIENTS" ]; then
511 $PDSH $CLIENTS "df $MOUNT" > /dev/null
516 uname -n >> $MOUNT/recon
517 if [ ! -z "$CLIENTS" ]; then
518 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
520 echo Connected clients:
522 ls -l $MOUNT/recon > /dev/null
528 echo "Failing $facet on node `facet_active_host $facet`"
529 shutdown_facet $facet
533 echo "df pid is $DFPID"
535 TO=`facet_active_host $facet`
536 echo "Failover $facet to $TO"
538 local dev=${facet}_dev
539 local opt=${facet}_opt
540 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
551 local svc=${facet}_svc
552 do_facet $facet $LCTL --device %${!svc} readonly
553 do_facet $facet $LCTL --device %${!svc} notransno
554 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
555 $LCTL mark "local REPLAY BARRIER on ${!svc}"
558 replay_barrier_nodf() {
559 local facet=$1 echo running=${running}
561 local svc=${facet}_svc
562 echo Replay barrier on ${!svc}
563 do_facet $facet $LCTL --device %${!svc} readonly
564 do_facet $facet $LCTL --device %${!svc} notransno
565 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
566 $LCTL mark "local REPLAY BARRIER on ${!svc}"
570 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
571 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
575 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
576 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
580 facet_failover $* || error "failover: $?"
581 df $MOUNT || error "post-failover df: $?"
588 local svc=${facet}_svc
589 local dev=${facet}_dev
590 local opt=${facet}_opt
591 start $facet ${!dev} ${!opt}
592 do_facet $facet lctl --device %${!svc} abort_recovery
593 df $MOUNT || echo "first df failed: $?"
595 df $MOUNT || error "post-failover df: $?"
599 echo There is no lmc. This is mountconf, baby.
604 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
605 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
611 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
617 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
618 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
619 if [ -z "$ID" ]; then
620 echo "Could not get a ptl id for $1..."
629 h2name_or_ip "$1" "tcp"
634 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
635 if type __h2elan >/dev/null 2>&1; then
638 ID=`echo $1 | sed 's/[^0-9]*//g'`
646 h2name_or_ip "$1" "openib"
651 h2name_or_ip "$1" "o2ib"
657 varname=${facet}_HOST
658 if [ -z "${!varname}" ]; then
659 if [ "${facet:0:3}" == "ost" ]; then
660 eval ${facet}_HOST=${ost_HOST}
668 local activevar=${facet}active
670 if [ -f ./${facet}active ] ; then
671 source ./${facet}active
675 if [ -z "$active" ] ; then
682 facet_active_host() {
684 local active=`facet_active $facet`
685 if [ "$facet" == client ]; then
688 echo `facet_host $active`
694 failover=${facet}failover
695 host=`facet_host $failover`
696 [ -z "$host" ] && return
697 curactive=`facet_active $facet`
698 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
699 eval export ${facet}active=$facet
701 eval export ${facet}active=$failover
703 # save the active host for this facet
704 activevar=${facet}active
705 echo "$activevar=${!activevar}" > ./$activevar
712 if [ "$HOST" = "$(hostname)" ]; then
716 echo "CMD: $HOST $@" >&2
717 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
719 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
720 return ${PIPESTATUS[0]}
726 HOST=`facet_active_host $facet`
727 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
734 # make sure its not already running
737 do_facet ${facet} $MKFS $*
743 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
744 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
751 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
752 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
760 # make sure we are using the primary server, so test-framework will
761 # be able to clean up properly.
762 activemds=`facet_active mds1`
763 if [ $activemds != "mds1" ]; then
767 # assume client mount is local
768 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
769 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
770 for num in `seq $MDSCOUNT`; do
773 for num in `seq $OSTCOUNT`; do
788 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
792 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
795 # We need ldiskfs here, may as well load them all
797 [ "$CLIENTONLY" ] && return
798 echo "Formatting mdts, osts"
799 for num in `seq $MDSCOUNT`; do
800 echo "Format mds$num: $(mdsdevname $num)"
802 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
804 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
808 for num in `seq $OSTCOUNT`; do
809 echo "Format ost$num: $(ostdevname $num)"
811 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
813 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
819 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
825 if [ -z "$CLIENTONLY" ]; then
826 echo "Setup mdts, osts"
827 for num in `seq $MDSCOUNT`; do
828 DEVNAME=$(mdsdevname $num)
829 echo $REFORMAT | grep -q "reformat" \
830 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
831 start mds$num $DEVNAME $MDS_MOUNT_OPTS
833 for num in `seq $OSTCOUNT`; do
834 DEVNAME=$(ostdevname $num)
835 start ost$num $DEVNAME $OST_MOUNT_OPTS
838 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
840 if [ "$MOUNT_2" ]; then
846 mounted_lustre_filesystems() {
847 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
850 check_and_setup_lustre() {
851 MOUNTED="`mounted_lustre_filesystems`"
852 if [ -z "$MOUNTED" ]; then
853 [ "$REFORMAT" ] && formatall
855 MOUNTED="`mounted_lustre_filesystems`"
856 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
859 if [ "$ONLY" == "setup" ]; then
864 cleanup_and_setup_lustre() {
865 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
866 sysctl -w lnet.debug=0 || true
868 if [ "$ONLY" == "cleanup" ]; then
872 check_and_setup_lustre
875 check_and_cleanup_lustre() {
876 if [ "`mount | grep $MOUNT`" ]; then
877 rm -rf $DIR/[Rdfs][1-9]*
879 if [ "$I_MOUNTED" = "yes" ]; then
880 cleanupall -f || error "cleanup failed"
892 while [ $NETWORK -eq 0 ]; do
893 ping -c 1 -w 3 $1 > /dev/null
894 if [ $? -eq 0 ]; then
898 echo "waiting for $1, $((MAX - WAIT)) secs left"
901 if [ $WAIT -gt $MAX ]; then
902 echo "Network not available"
908 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
919 # the sed converts spaces to commas, but leaves the last space
920 # alone, so the line doesn't end with a comma.
921 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
925 (cd `dirname $1`; echo $PWD/`basename $1`)
928 ##################################
932 # OBD_FAIL_MDS_ALL_REQUEST_NET
934 do_facet mds sysctl -w lustre.fail_loc=0x123
935 do_facet client "$1" || RC=$?
936 do_facet mds sysctl -w lustre.fail_loc=0
941 # OBD_FAIL_MDS_ALL_REPLY_NET
943 do_facet mds sysctl -w lustre.fail_loc=0x122
944 do_facet client "$@" || RC=$?
945 do_facet mds sysctl -w lustre.fail_loc=0
950 # OBD_FAIL_MDS_REINT_NET_REP
952 do_facet mds sysctl -w lustre.fail_loc=0x119
953 do_facet client "$@" || RC=$?
954 do_facet mds sysctl -w lustre.fail_loc=0
959 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
961 do_facet ost1 sysctl -w lustre.fail_loc=0x214
962 do_facet client "$1" || RC=$?
963 do_facet client "sync"
964 do_facet ost1 sysctl -w lustre.fail_loc=0
969 #define OBD_FAIL_LDLM_CANCEL 0x304
971 do_facet client sysctl -w lustre.fail_loc=0x304
972 do_facet client "$@" || RC=$?
973 do_facet client sysctl -w lustre.fail_loc=0
978 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
980 do_facet client sysctl -w lustre.fail_loc=0x305
981 do_facet client "$@" || RC=$?
982 do_facet client sysctl -w lustre.fail_loc=0
987 #define OBD_FAIL_LDLM_REPLY 0x30c
989 do_facet mds sysctl -w lustre.fail_loc=0x30c
990 do_facet client "$@" || RC=$?
991 do_facet mds sysctl -w lustre.fail_loc=0
999 echo "clearing fail_loc on $facet"
1000 do_facet $facet "sysctl -w lustre.fail_loc=0"
1003 cancel_lru_locks() {
1004 $LCTL mark "cancel_lru_locks $1 start"
1005 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1006 [ -f $d/lru_size ] && echo clear > $d/lru_size
1007 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1009 $LCTL mark "cancel_lru_locks $1 stop"
1014 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1015 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1016 echo there is still data in page cache $a ?
1025 DEBUGSAVE="$(sysctl -n lnet.debug)"
1029 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1034 ##################################
1038 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1039 log "${TESTSUITE} ${TESTNAME}: **** FAIL:" $@
1040 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1041 echo "Dumping lctl log to $ERRLOG"
1042 # We need to dump the logs on all nodes
1044 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1045 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1047 [ "$TESTSUITELOG" ] && echo "$0: FAIL: $TESTNAME $@" >> $TESTSUITELOG
1048 if $FAIL_ON_ERROR; then
1054 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1055 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1058 build_test_filter() {
1059 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1063 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1064 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1065 for E in $EXCEPT $ALWAYS_EXCEPT; do
1066 eval EXCEPT_${E}=true
1068 for G in $GRANT_CHECK_LIST; do
1069 eval GCHECK_ONLY_${G}=true
1078 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1082 export base=`basetest $1`
1083 if [ ! -z "$ONLY" ]; then
1085 if [ ${!testname}x != x ]; then
1090 if [ ${!testname}x != x ]; then
1098 if [ ${!testname}x != x ]; then
1099 TESTNAME=test_$1 skip "skipping excluded test $1"
1102 testname=EXCEPT_$base
1103 if [ ${!testname}x != x ]; then
1104 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1112 EQUALS="======================================================================"
1116 local suffixlen=$((${#EQUALS} - ${#msg}))
1117 [ $suffixlen -lt 5 ] && suffixlen=5
1118 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1123 lsmod | grep lnet > /dev/null || load_modules
1124 $LCTL mark "$*" 2> /dev/null || true
1129 strace -o $TMP/$1.strace -ttt $*
1131 log "FINISHED: $*: rc $RC"
1140 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1141 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1142 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1149 export tdir=d${base}
1152 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1154 export TESTNAME=test_$testnum
1155 test_${testnum} || error "test_$testnum failed with $?"
1157 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1158 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1159 error "LBUG/LASSERT detected"
1160 pass "($((`date +%s` - $BEFORE))s)"
1168 (cd `dirname $1`; echo $PWD/`basename $1`)
1172 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1173 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1178 export base=`basetest $1`
1179 [ "$CHECK_GRANT" == "no" ] && return 0
1181 testname=GCHECK_ONLY_${base}
1182 [ ${!testname}x == x ] && return 0
1184 echo -n "checking grant......"
1186 # write some data to sync client lost_grant
1187 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1188 for i in `seq $OSTCOUNT`; do
1189 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1190 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1191 count=1 > /dev/null 2>&1
1193 # sync all the data and make sure no pending data on server
1196 #get client grant and server grant
1198 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1199 client_grant=$((client_grant + `cat $d`))
1202 for d in ${LPROC}/obdfilter/*/tot_granted; do
1203 server_grant=$((server_grant + `cat $d`))
1206 # cleanup the check_grant file
1207 for i in `seq $OSTCOUNT`; do
1208 rm $DIR1/${tfile}_check_grant_$i
1211 #check whether client grant == server grant
1212 if [ $client_grant != $server_grant ]; then
1213 echo "failed: client:${client_grant} server: ${server_grant}"
1220 ########################
1226 ost=`echo $1 | awk -F_ '{print $3}'`
1227 if [ -z $ost ]; then
1228 ost=`echo $1 | sed 's/-osc.*//'`
1235 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1240 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1245 grep -q patchless $LPROC/version