2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && 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 [ "$TESTSUITE" == "lfscktest" ] && return 0
36 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
37 local form="%-13s %-17s %s\n"
38 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
39 echo "------------------------------------------------------------------------------------"
40 for O in $TESTSUITE_LIST; do
43 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
46 local log=${TMP}/${o}.log
47 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
48 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
49 [ "${!O}" = "done" ] && \
50 printf "$form" "Done" "$O" "E=$skipped" && \
51 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
55 for O in $TESTSUITE_LIST; do
56 [ "${!O}" = "no" ] && \
57 printf "$form" "Skipped" "$O" ""
60 for O in $TESTSUITE_LIST; do
61 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
62 printf "$form" "UNFINISHED" "$O" ""
67 export LUSTRE=`absolute_path $LUSTRE`
68 export TESTSUITE=`basename $0 .sh`
69 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
71 [ -d /r ] && export ROOT=${ROOT:-/r}
72 export TMP=${TMP:-$ROOT/tmp}
73 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
74 export HOSTNAME=${HOSTNAME:-`hostname`}
76 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests
77 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
78 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
79 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
80 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
81 [ ! -f "$LFS" ] && export LFS=$(which lfs)
82 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
83 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
84 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
85 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
86 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
87 export FSYTPE=${FSTYPE:-"ldiskfs"}
88 export NAME=${NAME:-local}
89 export LPROC=/proc/fs/lustre
93 if [ "$ACCEPTOR_PORT" ]; then
94 export PORT_OPT="--port $ACCEPTOR_PORT"
97 # Paths on remote nodes, if different
98 export RLUSTRE=${RLUSTRE:-$LUSTRE}
99 export RPWD=${RPWD:-$PWD}
100 export I_MOUNTED=${I_MOUNTED:-"no"}
104 while getopts "rvf:" opt $*; do
107 r) REFORMAT=--reformat;;
113 shift $((OPTIND - 1))
116 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
121 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
122 *) EXT=".ko"; USE_QUOTA=yes;;
128 BASE=`basename $module $EXT`
129 lsmod | grep -q ${BASE} || \
130 if [ -f ${LUSTRE}/${module}${EXT} ]; then
131 insmod ${LUSTRE}/${module}${EXT} $@
133 # must be testing a "make install" or "rpm" installation
139 if [ -n "$MODPROBE" ]; then
143 if [ "$HAVE_MODULES" = true ]; then
149 echo Loading modules from $LUSTRE
150 load_module ../lnet/libcfs/libcfs
151 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
152 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
153 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
154 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
155 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
156 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
157 echo "lnet options: '$LNETOPTS'"
158 # note that insmod will ignore anything in modprobe.conf
159 load_module ../lnet/lnet/lnet $LNETOPTS
160 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
161 load_module ../lnet/klnds/$LNETLND
162 load_module lvfs/lvfs
163 load_module obdclass/obdclass
164 load_module ptlrpc/ptlrpc
165 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
170 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
173 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
174 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
175 load_module lvfs/fsfilt_$FSTYPE
177 load_module obdfilter/obdfilter
180 load_module llite/lustre
181 load_module llite/llite_lloop
182 rm -f $TMP/ogdb-$HOSTNAME
184 [ -d /r ] && OGDB="/r/tmp"
185 $LCTL modules > $OGDB/ogdb-$HOSTNAME
186 # 'mount' doesn't look in $PATH, just sbin
187 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
191 if [ `uname -r | cut -c 3` -eq 4 ]; then
199 MODULES=$($LCTL modules | awk '{ print $2 }')
200 while [ -n "$MODULES" ]; do
202 $RMMOD $MODULES >/dev/null 2>&1 || true
203 MODULES=$($LCTL modules | awk '{ print $2 }')
204 if [ -z "$MODULES" ]; then
208 echo "waiting, $((MAX - WAIT)) secs left"
210 if [ $WAIT -eq $MAX ]; then
211 echo "LNET modules $MODULES will not unload"
219 wait_exit_ST client # bug 12845
221 lsmod | grep libcfs > /dev/null && $LCTL dl
222 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
223 $RMMOD $MODULES > /dev/null 2>&1 || true
224 # do it again, in case we tried to unload ksocklnd too early
225 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
226 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
227 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
229 MODULES=$($LCTL modules | awk '{ print $2 }')
230 if [ -n "$MODULES" ]; then
231 echo "Modules still loaded: "
233 if [ "$(lctl dl)" ]; then
234 echo "Lustre still loaded"
239 echo "Lustre stopped but LNET is still loaded, waiting..."
240 wait_for_lnet || return 3
245 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
246 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
247 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
248 echo "$LEAK_LUSTRE" 1>&2
249 echo "$LEAK_PORTALS" 1>&2
250 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
251 echo "Memory leaks detected"
252 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
255 echo "modules unloaded."
263 local dev=${facet}_dev
264 local opt=${facet}_opt
265 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
266 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
268 if [ $RC -ne 0 ]; then
269 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
270 echo "Start of ${device} on ${facet} failed ${RC}"
272 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
273 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
274 lctl set_param debug_mb=${DEBUG_SIZE}; \
280 # start facet device options
286 eval export ${facet}_dev=${device}
287 eval export ${facet}_opt=\"$@\"
288 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
291 if [ $RC -eq 0 ]; then
292 label=$(do_facet ${facet} "e2label ${device}")
293 [ -z "$label" ] && echo no label for ${device} && exit 1
294 eval export ${facet}_svc=${label}
295 echo Started ${label}
304 HOST=`facet_active_host $facet`
305 [ -z $HOST ] && echo stop: no host for $facet && return 0
307 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
308 if [ ${running} -ne 0 ]; then
309 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
310 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
313 # umount should block, but we should wait for unrelated obd's
314 # like the MGS or MGC to also stop.
316 wait_exit_ST ${facet}
323 # Only supply -o to mount if we have options
324 if [ -n "$MOUNTOPT" ]; then
325 OPTIONS="-o $MOUNTOPT"
327 local device=$MGSNID:/$FSNAME
328 if [ -z "$mnt" -o -z "$FSNAME" ]; then
329 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
333 echo "Starting client: $client: $OPTIONS $device $mnt"
334 do_node $client mkdir -p $mnt
335 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
337 do_node $client "lctl set_param debug=$PTLDEBUG;
338 lctl set_param subsystem_debug=${SUBSYSTEM# };
339 lctl set_param debug_mb=${DEBUG_SIZE}"
340 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
348 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
349 if [ $running -ne 0 ]; then
350 echo "Stopping client $client $mnt (opts:$force)"
351 lsof | grep "$mnt" || true
352 do_node $client umount $force $mnt
356 zconf_mount_clients() {
360 echo "Mounting clients: $clients"
362 for client in ${clients//,/ }; do
363 zconf_mount $client $mnt || true
367 zconf_umount_clients() {
372 echo "Umounting clients: $clients"
374 for client in ${clients//,/ }; do
375 zconf_umount $client $mnt $force || true
381 if [ "$FAILURE_MODE" = HARD ]; then
382 $POWER_DOWN `facet_active_host $facet`
384 elif [ "$FAILURE_MODE" = SOFT ]; then
391 if [ "$FAILURE_MODE" = HARD ]; then
392 $POWER_UP `facet_active_host $facet`
398 # verify that lustre actually cleaned up properly
400 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
401 error "LBUG/LASSERT detected"
402 BUSY=`dmesg | grep -i destruct || true`
405 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
408 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
409 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
410 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
411 echo "$0: $LEAK_LUSTRE" 1>&2
412 echo "$0: $LEAK_PORTALS" 1>&2
413 echo "$0: Memory leak(s) detected..." 1>&2
414 mv $TMP/debug $TMP/debug-leak.`date +%s`
418 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
419 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
421 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
422 echo "$0: modules still loaded..." 1>&2
429 wait_delete_completed () {
430 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
431 $LPROC/osc/*/kbytesavail`
435 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
437 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
438 $LPROC/osc/*/kbytesavail`
439 [ "$TOTAL" -eq "$TOTALPREV" ] && break
440 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
444 echo "Delete completed."
449 check_network "$HOST" 900
450 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
455 HOST=`facet_active_host $facet`
459 wait_mds_recovery_done () {
460 local timeout=`do_facet mds lctl get_param -n timeout`
461 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
462 # as we are in process of changing obd_timeout in different ways
463 # let's set MAX longer than that
464 MAX=$(( timeout * 4 ))
466 while [ $WAIT -lt $MAX ]; do
467 STATUS=`do_facet mds grep status /proc/fs/lustre/mds/*-MDT*/recovery_status`
468 echo $STATUS | grep COMPLETE && return 0
471 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
473 echo "MDS recovery not done in $MAX sec"
482 # conf-sanity 31 takes a long time cleanup
483 while [ $WAIT -lt 300 ]; do
484 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
485 [ -z "${running}" ] && return 0
486 echo "waited $WAIT for${running}"
487 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
489 WAIT=$((WAIT + INTERVAL))
491 echo "service didn't stop after $WAIT seconds. Still running:"
497 # not every config has many clients
498 if [ -n "$CLIENTS" ]; then
499 $PDSH $CLIENTS "df $MOUNT" > /dev/null
501 df $MOUNT > /dev/null
506 uname -n >> $MOUNT/recon
507 if [ ! -z "$CLIENTS" ]; then
508 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
510 echo Connected clients:
512 ls -l $MOUNT/recon > /dev/null
518 echo "Failing $facet on node `facet_active_host $facet`"
519 shutdown_facet $facet
523 echo "df pid is $DFPID"
525 TO=`facet_active_host $facet`
526 echo "Failover $facet to $TO"
528 mount_facet $facet || error "Restart of $facet failed"
539 local svc=${facet}_svc
540 do_facet $facet $LCTL --device %${!svc} readonly
541 do_facet $facet $LCTL --device %${!svc} notransno
542 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
543 $LCTL mark "local REPLAY BARRIER on ${!svc}"
546 replay_barrier_nodf() {
547 local facet=$1 echo running=${running}
549 local svc=${facet}_svc
550 echo Replay barrier on ${!svc}
551 do_facet $facet $LCTL --device %${!svc} readonly
552 do_facet $facet $LCTL --device %${!svc} notransno
553 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
554 $LCTL mark "local REPLAY BARRIER on ${!svc}"
558 UUID=`cat /proc/fs/lustre/mdc/${mds_svc}-mdc-*/uuid`
559 do_facet mds "echo $UUID > /proc/fs/lustre/mds/${mds_svc}/evict_client"
563 UUID=`cat /proc/fs/lustre/osc/${ost1_svc}-osc-*/uuid`
564 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
568 facet_failover $* || error "failover: $?"
569 df $MOUNT || error "post-failover df: $?"
574 facet_failover $facet
581 mount_facet $facet -o abort_recovery
582 df $MOUNT || echo "first df failed: $?"
584 df $MOUNT || error "post-failover df: $?"
588 echo There is no lmc. This is mountconf, baby.
593 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
594 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
600 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
601 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
602 if [ -z "$ID" ]; then
603 echo "Could not get a ptl id for $1..."
612 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
619 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
620 if type __h2elan >/dev/null 2>&1; then
623 ID=`echo $1 | sed 's/[^0-9]*//g'`
631 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
632 ID=`echo $1 | sed 's/[^0-9]*//g'`
640 varname=${facet}_HOST
641 if [ -z "${!varname}" ]; then
642 if [ "${facet:0:3}" == "ost" ]; then
643 eval ${facet}_HOST=${ost_HOST}
651 local activevar=${facet}active
653 if [ -f ./${facet}active ] ; then
654 source ./${facet}active
658 if [ -z "$active" ] ; then
665 facet_active_host() {
667 local active=`facet_active $facet`
668 if [ "$facet" == client ]; then
671 echo `facet_host $active`
677 failover=${facet}failover
678 host=`facet_host $failover`
679 [ -z "$host" ] && return
680 curactive=`facet_active $facet`
681 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
682 eval export ${facet}active=$facet
684 eval export ${facet}active=$failover
686 # save the active host for this facet
687 activevar=${facet}active
688 echo "$activevar=${!activevar}" > ./$activevar
695 if [ "$HOST" = "$HOSTNAME" ]; then
697 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
698 echo "cannot run remote command on $HOST with $myPDSH"
702 echo "CMD: $HOST $@" >&2
703 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
706 if [ "$myPDSH" = "rsh" ]; then
707 # we need this because rsh does not return exit code of an executed command
708 local command_status="$TMP/cs"
709 rsh $HOST ":> $command_status"
710 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
711 cd $RPWD; sh -c \"$@\") ||
712 echo command failed >$command_status"
713 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
716 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
717 return ${PIPESTATUS[0]}
723 HOST=`facet_active_host $facet`
724 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
731 # make sure its not already running
734 do_facet ${facet} $MKFS $*
740 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
741 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
749 # make sure we are using the primary server, so test-framework will
750 # be able to clean up properly.
751 activemds=`facet_active mds`
752 if [ $activemds != "mds" ]; then
756 # assume client mount is local
757 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
758 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
760 if [ -n "$CLIENTS" ]; then
761 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
762 zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
765 [ "$CLIENTONLY" ] && return
767 for num in `seq $OSTCOUNT`; do
779 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
782 # We need ldiskfs here, may as well load them all
784 [ "$CLIENTONLY" ] && return
785 echo Formatting mds, osts
787 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
789 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
792 for num in `seq $OSTCOUNT`; do
794 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
796 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
802 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
807 zconf_umount `hostname` $1 || error "umount failed"
808 zconf_mount `hostname` $1 || error "mount failed"
815 do_facet $facet lsmod | grep -q obdclass || \
816 do_facet $facet "modprobe obdclass"
818 do_facet $facet "lctl set_param timeout=$timeout"
823 if [ -z "$CLIENTONLY" ]; then
825 echo $REFORMAT | grep -q "reformat" \
826 || do_facet mds "$TUNEFS --writeconf $MDSDEV"
827 set_obd_timeout mds $TIMEOUT
828 start mds $MDSDEV $MDS_MOUNT_OPTS
829 for num in `seq $OSTCOUNT`; do
830 DEVNAME=`ostdevname $num`
831 set_obd_timeout ost$num $TIMEOUT
832 start ost$num $DEVNAME $OST_MOUNT_OPTS
835 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
837 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
839 if [ "$MOUNT_2" ]; then
841 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
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 lctl set_param 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 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-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 ##################################
929 # Adaptive Timeouts funcs
932 if [ -z "$AT_MAX_PATH" ]; then
933 AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
934 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
940 at_is_valid || error "invalid call"
942 # only check mds, we assume at_max is the same on all nodes
943 local at_max=$(do_facet mds "cat $AT_MAX_PATH")
944 if [ $at_max -eq 0 ]; then
952 at_is_valid || error "invalid call"
954 do_facet $1 "cat $AT_MAX_PATH"
961 at_is_valid || error "invalid call"
964 if [ $facet == "ost" ]; then
965 for i in `seq $OSTCOUNT`; do
966 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
969 do_facet $facet "echo $at_max > $AT_MAX_PATH"
974 ##################################
978 # OBD_FAIL_MDS_ALL_REQUEST_NET
980 do_facet mds lctl set_param fail_loc=0x123
981 do_facet client "$1" || RC=$?
982 do_facet mds lctl set_param fail_loc=0
987 # OBD_FAIL_MDS_ALL_REPLY_NET
989 do_facet mds lctl set_param fail_loc=0x122
990 do_facet client "$@" || RC=$?
991 do_facet mds lctl set_param fail_loc=0
996 # OBD_FAIL_MDS_REINT_NET_REP
998 do_facet mds lctl set_param fail_loc=0x119
999 do_facet client "$@" || RC=$?
1000 do_facet mds lctl set_param fail_loc=0
1005 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1007 do_facet ost1 lctl set_param fail_loc=0x214
1008 do_facet client "$1" || RC=$?
1009 do_facet client "sync"
1010 do_facet ost1 lctl set_param fail_loc=0
1014 drop_ldlm_cancel() {
1015 #define OBD_FAIL_LDLM_CANCEL 0x304
1017 do_facet client lctl set_param fail_loc=0x304
1018 do_facet client "$@" || RC=$?
1019 do_facet client lctl set_param fail_loc=0
1023 drop_bl_callback() {
1024 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1026 do_facet client lctl set_param fail_loc=0x305
1027 do_facet client "$@" || RC=$?
1028 do_facet client lctl set_param fail_loc=0
1033 #define OBD_FAIL_LDLM_REPLY 0x30c
1035 do_facet mds lctl set_param fail_loc=0x30c
1036 do_facet client "$@" || RC=$?
1037 do_facet mds lctl set_param fail_loc=0
1045 echo "clearing fail_loc on $facet"
1046 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1049 set_nodes_failloc () {
1053 for node in $nodes ; do
1054 do_node $node lctl set_param fail_loc=$2
1058 cancel_lru_locks() {
1059 $LCTL mark "cancel_lru_locks $1 start"
1060 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1061 [ -f $d/lru_size ] && echo clear > $d/lru_size
1062 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1064 $LCTL mark "cancel_lru_locks $1 stop"
1069 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1070 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1071 echo "$DEFAULT_LRU_SIZE"
1077 test "x$NS" = "x" && NS="mdc"
1078 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1080 log "Enable lru resize for $(basename $D)"
1085 lru_resize_disable()
1088 test "x$NS" = "x" && NS="mdc"
1089 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1091 log "Disable lru resize for $(basename $D)"
1092 DEFAULT_LRU_SIZE=$(default_lru_size)
1093 echo "$DEFAULT_LRU_SIZE" > $F
1098 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1099 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1100 echo there is still data in page cache $a ?
1109 DEBUGSAVE="$(lctl get_param -n debug)"
1113 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1117 ##################################
1119 ##################################
1122 local TYPE=${TYPE:-"FAIL"}
1124 lctl set_param fail_loc=0 2>/dev/null || true
1125 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1126 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1127 echo "Dumping lctl log to $ERRLOG"
1128 # We need to dump the logs on all nodes
1129 local NODES=$(nodes_list)
1130 for NODE in $NODES; do
1131 do_node $NODE $LCTL dk $ERRLOG
1134 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1139 $FAIL_ON_ERROR && exit 1 || true
1147 # use only if we are ignoring failures for this test, bugno required.
1148 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1149 # e.g. error_ignore 5494 "your message"
1151 TYPE="IGNORE (bz$1)"
1157 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1158 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1161 build_test_filter() {
1162 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1166 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1167 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1168 [ "$EXCEPT_SLOW" ] && \
1169 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1170 for E in $EXCEPT $ALWAYS_EXCEPT; do
1171 eval EXCEPT_${E}=true
1173 for E in $EXCEPT_SLOW; do
1174 eval EXCEPT_SLOW_${E}=true
1176 for G in $GRANT_CHECK_LIST; do
1177 eval GCHECK_ONLY_${G}=true
1186 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1190 export base=`basetest $1`
1191 if [ ! -z "$ONLY" ]; then
1193 if [ ${!testname}x != x ]; then
1198 if [ ${!testname}x != x ]; then
1206 if [ ${!testname}x != x ]; then
1207 TESTNAME=test_$1 skip "skipping excluded test $1"
1210 testname=EXCEPT_$base
1211 if [ ${!testname}x != x ]; then
1212 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1215 testname=EXCEPT_SLOW_$1
1216 if [ ${!testname}x != x ]; then
1217 TESTNAME=test_$1 skip "skipping SLOW test $1"
1220 testname=EXCEPT_SLOW_$base
1221 if [ ${!testname}x != x ]; then
1222 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1231 EQUALS="======================================================================"
1235 local suffixlen=$((${#EQUALS} - ${#msg}))
1236 [ $suffixlen -lt 5 ] && suffixlen=5
1237 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1242 lsmod | grep lnet > /dev/null || load_modules
1253 local NODES=$(nodes_list)
1254 for NODE in $NODES; do
1255 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1261 strace -o $TMP/$1.strace -ttt $*
1263 log "FINISHED: $*: rc $RC"
1272 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1273 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1274 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1278 local myNODES=$(nodes_list)
1281 for NODE in $myNODES; do
1282 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1290 export tdir=d0.${TESTSUITE}/d${base}
1291 local SAVE_UMASK=`umask`
1296 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1298 export TESTNAME=test_$testnum
1299 test_${testnum} || error "test_$testnum failed with $?"
1302 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1303 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1304 error "LBUG/LASSERT detected"
1305 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1306 pass "($((`date +%s` - $BEFORE))s)"
1307 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1316 (cd `dirname $1`; echo $PWD/`basename $1`)
1320 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1321 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1326 export base=`basetest $1`
1327 [ "$CHECK_GRANT" == "no" ] && return 0
1329 testname=GCHECK_ONLY_${base}
1330 [ ${!testname}x == x ] && return 0
1332 echo -n "checking grant......"
1334 # write some data to sync client lost_grant
1335 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1336 for i in `seq $OSTCOUNT`; do
1337 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1338 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1339 count=1 > /dev/null 2>&1
1341 # sync all the data and make sure no pending data on server
1344 #get client grant and server grant
1346 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1347 client_grant=$((client_grant + `cat $d`))
1350 for d in ${LPROC}/obdfilter/*/tot_granted; do
1351 server_grant=$((server_grant + `cat $d`))
1354 # cleanup the check_grant file
1355 for i in `seq $OSTCOUNT`; do
1356 rm $DIR1/${tfile}_check_grant_$i
1359 #check whether client grant == server grant
1360 if [ $client_grant != $server_grant ]; then
1361 echo "failed: client:${client_grant} server: ${server_grant}"
1368 ########################
1374 ost=`echo $1 | awk -F_ '{print $3}'`
1375 if [ -z $ost ]; then
1376 ost=`echo $1 | sed 's/-osc.*//'`
1383 [ -z "$(lctl dl | grep mdt)" ]
1388 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1393 [ -z "$(lctl dl | grep ost)" ]
1398 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1402 local OSTNODES=$(facet_host ost1)
1405 for num in `seq $OSTCOUNT`; do
1406 local myOST=$(facet_host ost$num)
1407 OSTNODES="$OSTNODES $myOST"
1409 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1415 # FIXME. We need a list of clients
1416 local myNODES=$HOSTNAME
1419 # CLIENTS (if specified) contains the local client
1420 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1422 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1423 myNODES="$myNODES $(osts_nodes) $mds_HOST"
1426 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1433 lctl get_param version | grep -q patchless
1436 check_runas_id_ret() {
1441 if [ -z "$myRUNAS" ]; then
1442 error_exit "myRUNAS command must be specified for check_runas_id"
1444 mkdir $DIR/d0_runas_test
1446 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1447 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
1448 rm -rf $DIR/d0_runas_test
1456 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1457 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1458 Please set RUNAS_ID to some UID which exists on MDS and client or
1459 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1462 # Run multiop in the background, but wait for it to print
1463 # "PAUSING" to its stdout before returning from this function.
1464 multiop_bg_pause() {
1465 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1469 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1472 echo "$MULTIOP_PROG $FILE v$ARGS"
1473 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1475 echo "TMPPIPE=${TMPPIPE}"
1476 read -t 60 multiop_output < $TMPPIPE
1477 if [ $? -ne 0 ]; then
1482 if [ "$multiop_output" != "PAUSING" ]; then
1483 echo "Incorrect multiop output: $multiop_output"
1491 # reset llite stat counters
1492 clear_llite_stats(){
1493 lctl set_param -n llite.*.stats 0
1496 # sum llite stat items
1497 calc_llite_stats() {
1498 local res=$(lctl get_param -n llite.*.stats |
1499 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1503 # save_lustre_params(node, parameter_mask)
1504 # generate a stream of formatted strings (<node> <param name>=<param value>)
1505 save_lustre_params() {
1507 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1510 # restore lustre parameters from input stream, produces by save_lustre_params
1511 restore_lustre_params() {
1515 while IFS=" =" read node name val; do
1516 do_node $node "lctl set_param -n $name $val"