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}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=false
17 #export PDSH="pdsh -S -Rssh -w"
19 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
23 if [ -z "${!name}" ]; then
24 echo "$0: $name must be set"
28 [ $failed ] && exit 1 || true
32 echo "usage: $0 [-r] [-f cfgfile]"
39 [ "$TESTSUITE" == "lfscktest" ] && return 0
40 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
41 local form="%-13s %-17s %s\n"
42 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
43 echo "------------------------------------------------------------------------------------"
44 for O in $TESTSUITE_LIST; do
47 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
50 local log=${TMP}/${o}.log
51 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
52 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
53 [ "${!O}" = "done" ] && \
54 printf "$form" "Done" "$O" "E=$skipped" && \
55 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
59 for O in $TESTSUITE_LIST; do
60 [ "${!O}" = "no" ] && \
61 printf "$form" "Skipped" "$O" ""
64 for O in $TESTSUITE_LIST; do
65 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
66 printf "$form" "UNFINISHED" "$O" ""
71 export LUSTRE=`absolute_path $LUSTRE`
72 export TESTSUITE=`basename $0 .sh`
73 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
75 [ -d /r ] && export ROOT=${ROOT:-/r}
76 export TMP=${TMP:-$ROOT/tmp}
77 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
78 export HOSTNAME=${HOSTNAME:-`hostname`}
80 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
81 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
82 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
83 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
84 [ ! -f "$LFS" ] && export LFS=$(which lfs)
85 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
86 if [ ! -f "$L_GETIDENTITY" ]; then
87 if `which l_getidentity > /dev/null 2>&1`; then
88 export L_GETIDENTITY=$(which l_getidentity)
90 export L_GETIDENTITY=NONE
93 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
94 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
95 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
96 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
97 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
98 export FSYTPE=${FSTYPE:-"ldiskfs"}
99 export NAME=${NAME:-local}
100 export LPROC=/proc/fs/lustre
101 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
102 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
103 export LGSSD=$(which lgssd)
104 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
105 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
106 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
109 if [ "$ACCEPTOR_PORT" ]; then
110 export PORT_OPT="--port $ACCEPTOR_PORT"
115 echo "Using GSS/krb5 ptlrpc security flavor"
126 IDENTITY_UPCALL=false
130 # Paths on remote nodes, if different
131 export RLUSTRE=${RLUSTRE:-$LUSTRE}
132 export RPWD=${RPWD:-$PWD}
133 export I_MOUNTED=${I_MOUNTED:-"no"}
137 while getopts "rvf:" opt $*; do
140 r) REFORMAT=--reformat;;
146 shift $((OPTIND - 1))
149 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
157 BASE=`basename $module $EXT`
158 lsmod | grep -q ${BASE} || \
159 if [ -f ${LUSTRE}/${module}${EXT} ]; then
160 insmod ${LUSTRE}/${module}${EXT} $@
162 # must be testing a "make install" or "rpm" installation
163 # note failed to load ptlrpc_gss is considered not fatal
164 if [ "$BASE" == "ptlrpc_gss" ]; then
165 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
173 if [ -n "$MODPROBE" ]; then
177 if [ "$HAVE_MODULES" = true ]; then
183 echo Loading modules from $LUSTRE
184 load_module ../lnet/libcfs/libcfs
185 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
186 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
187 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
188 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
189 echo "lnet options: '$LNETOPTS'"
190 # note that insmod will ignore anything in modprobe.conf
191 load_module ../lnet/lnet/lnet $LNETOPTS
192 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
193 load_module ../lnet/klnds/$LNETLND
194 load_module lvfs/lvfs
195 load_module obdclass/obdclass
196 load_module ptlrpc/ptlrpc
197 load_module ptlrpc/gss/ptlrpc_gss
198 # Now, some modules depend on lquota without USE_QUOTA check,
199 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
200 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
201 load_module quota/lquota
209 if [ -z "$CLIENTONLY" ]; then
210 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
215 load_module lvfs/fsfilt_$FSTYPE
219 load_module obdfilter/obdfilter
222 load_module llite/lustre
223 load_module llite/llite_lloop
224 rm -f $TMP/ogdb-$HOSTNAME
226 [ -d /r ] && OGDB="/r/tmp"
227 $LCTL modules > $OGDB/ogdb-$HOSTNAME
229 # 'mount' doesn't look in $PATH, just sbin
230 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
234 if [ `uname -r | cut -c 3` -eq 4 ]; then
242 MODULES=$($LCTL modules | awk '{ print $2 }')
243 while [ -n "$MODULES" ]; do
245 $RMMOD $MODULES > /dev/null 2>&1 || true
246 MODULES=$($LCTL modules | awk '{ print $2 }')
247 if [ -z "$MODULES" ]; then
251 echo "waiting, $((MAX - WAIT)) secs left"
253 if [ $WAIT -eq $MAX ]; then
254 echo "LNET modules $MODULES will not unload"
262 wait_exit_ST client # bug 12845
264 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
265 local MODULES=$($LCTL modules | awk '{ print $2 }')
266 $RMMOD $MODULES > /dev/null 2>&1 || true
267 # do it again, in case we tried to unload ksocklnd too early
268 MODULES=$($LCTL modules | awk '{ print $2 }')
269 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
270 MODULES=$($LCTL modules | awk '{ print $2 }')
271 if [ -n "$MODULES" ]; then
272 echo "Modules still loaded: "
274 if [ -e $LPROC ]; then
275 echo "Lustre still loaded"
276 cat $LPROC/devices || true
280 echo "Lustre stopped but LNET is still loaded, waiting..."
281 wait_for_lnet || return 3
286 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
287 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
288 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
289 echo "$LEAK_LUSTRE" 1>&2
290 echo "$LEAK_PORTALS" 1>&2
291 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
292 echo "Memory leaks detected"
293 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
296 echo "modules unloaded."
300 check_gss_daemon_facet() {
304 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
305 if [ $num -ne 1 ]; then
306 echo "$num instance of $dname on $facet"
315 do_facet $facet "killall -2 $@ 2>/dev/null || true"
318 start_gss_daemons() {
320 for num in `seq $MDSCOUNT`; do
321 do_facet mds$num "$LSVCGSSD -v"
323 do_facet mds$num "$LGSSD -v"
327 for num in `seq $OSTCOUNT`; do
328 do_facet ost$num "$LSVCGSSD -v"
331 # FIXME: is "client" the right facet name?
333 do_facet client "$LGSSD -v"
336 # wait daemons entering "stable" status
340 # check daemons are running
342 for num in `seq $MDSCOUNT`; do
343 check_gss_daemon_facet mds$num lsvcgssd
345 check_gss_daemon_facet mds$num lgssd
348 for num in `seq $OSTCOUNT`; do
349 check_gss_daemon_facet ost$num lsvcgssd
352 check_gss_daemon_facet client lgssd
357 for num in `seq $MDSCOUNT`; do
358 send_sigint mds$num lsvcgssd lgssd
360 for num in `seq $OSTCOUNT`; do
361 send_sigint ost$num lsvcgssd
363 send_sigint client lgssd
375 # maybe cleanup credential cache?
381 local device=`mdsdevname $num`
382 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
388 local device=`ostdevname $num`
389 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
394 # start facet device options
400 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
401 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
402 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
404 if [ $RC -ne 0 ]; then
405 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
406 echo Start of ${device} on ${facet} failed ${RC}
408 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
409 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
410 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
412 do_facet ${facet} sync
413 label=$(do_facet ${facet} "e2label ${device}")
414 [ -z "$label" ] && echo no label for ${device} && exit 1
415 eval export ${facet}_svc=${label}
416 eval export ${facet}_dev=${device}
417 eval export ${facet}_opt=\"$@\"
418 echo Started ${label}
427 HOST=`facet_active_host $facet`
428 [ -z $HOST ] && echo stop: no host for $facet && return 0
430 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
431 if [ ${running} -ne 0 ]; then
432 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
433 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
436 # umount should block, but we should wait for unrelated obd's
437 # like the MGS or MGC to also stop.
438 wait_exit_ST ${facet}
445 # Only supply -o to mount if we have options
446 if [ -n "$MOUNTOPT" ]; then
447 OPTIONS="-o $MOUNTOPT"
449 local device=$MGSNID:/$FSNAME
450 if [ -z "$mnt" -o -z "$FSNAME" ]; then
451 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
455 echo "Starting client: $OPTIONS $device $mnt"
456 do_node $client mkdir -p $mnt
457 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
459 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
460 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
461 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
462 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
470 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
471 if [ $running -ne 0 ]; then
472 echo "Stopping client $mnt (opts:$force)"
473 lsof | grep "$mnt" || true
474 do_node $client umount $force $mnt
480 if [ "$FAILURE_MODE" = HARD ]; then
481 $POWER_DOWN `facet_active_host $facet`
483 elif [ "$FAILURE_MODE" = SOFT ]; then
490 if [ "$FAILURE_MODE" = HARD ]; then
491 $POWER_UP `facet_active_host $facet`
497 # verify that lustre actually cleaned up properly
499 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
500 error "LBUG/LASSERT detected"
501 BUSY=`dmesg | grep -i destruct || true`
504 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
507 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
508 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
509 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
510 echo "$0: $LEAK_LUSTRE" 1>&2
511 echo "$0: $LEAK_PORTALS" 1>&2
512 echo "$0: Memory leak(s) detected..." 1>&2
513 mv $TMP/debug $TMP/debug-leak.`date +%s`
517 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
518 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
520 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
521 echo "$0: modules still loaded..." 1>&2
528 wait_delete_completed () {
529 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
530 $LPROC/osc/*/kbytesavail`
534 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
536 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
537 $LPROC/osc/*/kbytesavail`
538 [ "$TOTAL" -eq "$TOTALPREV" ] && break
539 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
543 echo "Delete completed."
548 check_network "$HOST" 900
549 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
554 HOST=`facet_active_host $facet`
558 wait_mds_recovery_done () {
559 local timeout=`do_facet mds cat /proc/sys/lustre/timeout`
560 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
561 # as we are in process of changing obd_timeout in different ways
562 # let's set MAX longer than that
563 MAX=$(( timeout * 4 ))
565 while [ $WAIT -lt $MAX ]; do
566 STATUS=`do_facet mds grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
567 echo $STATUS | grep COMPLETE && return 0
570 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
572 echo "MDS recovery not done in $MAX sec"
581 # conf-sanity 31 takes a long time cleanup
582 while [ $WAIT -lt 300 ]; do
583 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
584 [ -z "${running}" ] && return 0
585 echo "waited $WAIT for${running}"
586 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
588 WAIT=$((WAIT + INTERVAL))
590 echo "service didn't stop after $WAIT seconds. Still running:"
596 # not every config has many clients
597 if [ ! -z "$CLIENTS" ]; then
598 $PDSH $CLIENTS "df $MOUNT" > /dev/null
603 uname -n >> $MOUNT/recon
604 if [ ! -z "$CLIENTS" ]; then
605 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
607 echo Connected clients:
609 ls -l $MOUNT/recon > /dev/null
615 echo "Failing $facet on node `facet_active_host $facet`"
616 shutdown_facet $facet
620 echo "df pid is $DFPID"
622 TO=`facet_active_host $facet`
623 echo "Failover $facet to $TO"
625 local dev=${facet}_dev
626 local opt=${facet}_opt
627 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
638 local svc=${facet}_svc
639 do_facet $facet $LCTL --device %${!svc} readonly
640 do_facet $facet $LCTL --device %${!svc} notransno
641 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
642 $LCTL mark "local REPLAY BARRIER on ${!svc}"
645 replay_barrier_nodf() {
646 local facet=$1 echo running=${running}
648 local svc=${facet}_svc
649 echo Replay barrier on ${!svc}
650 do_facet $facet $LCTL --device %${!svc} readonly
651 do_facet $facet $LCTL --device %${!svc} notransno
652 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
653 $LCTL mark "local REPLAY BARRIER on ${!svc}"
657 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
658 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
662 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
663 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
667 facet_failover $* || error "failover: $?"
668 df $MOUNT || error "post-failover df: $?"
675 local svc=${facet}_svc
676 local dev=${facet}_dev
677 local opt=${facet}_opt
678 start $facet ${!dev} ${!opt}
679 do_facet $facet lctl --device %${!svc} abort_recovery
680 df $MOUNT || echo "first df failed: $?"
682 df $MOUNT || error "post-failover df: $?"
686 echo There is no lmc. This is mountconf, baby.
691 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
692 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
698 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
704 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
705 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
706 if [ -z "$ID" ]; then
707 echo "Could not get a ptl id for $1..."
716 h2name_or_ip "$1" "tcp"
721 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
722 if type __h2elan >/dev/null 2>&1; then
725 ID=`echo $1 | sed 's/[^0-9]*//g'`
733 h2name_or_ip "$1" "openib"
738 h2name_or_ip "$1" "o2ib"
744 varname=${facet}_HOST
745 if [ -z "${!varname}" ]; then
746 if [ "${facet:0:3}" == "ost" ]; then
747 eval ${facet}_HOST=${ost_HOST}
755 local activevar=${facet}active
757 if [ -f ./${facet}active ] ; then
758 source ./${facet}active
762 if [ -z "$active" ] ; then
769 facet_active_host() {
771 local active=`facet_active $facet`
772 if [ "$facet" == client ]; then
775 echo `facet_host $active`
781 failover=${facet}failover
782 host=`facet_host $failover`
783 [ -z "$host" ] && return
784 curactive=`facet_active $facet`
785 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
786 eval export ${facet}active=$facet
788 eval export ${facet}active=$failover
790 # save the active host for this facet
791 activevar=${facet}active
792 echo "$activevar=${!activevar}" > ./$activevar
799 if [ "$HOST" = "$HOSTNAME" ]; then
801 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
802 echo "cannot run remote command on $HOST with $myPDSH"
806 echo "CMD: $HOST $@" >&2
807 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
809 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
810 return ${PIPESTATUS[0]}
816 HOST=`facet_active_host $facet`
817 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
824 # make sure its not already running
827 do_facet ${facet} $MKFS $*
833 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
834 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
841 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
842 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
850 # make sure we are using the primary server, so test-framework will
851 # be able to clean up properly.
852 activemds=`facet_active mds1`
853 if [ $activemds != "mds1" ]; then
857 # assume client mount is local
858 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
859 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
860 [ "$CLIENTONLY" ] && return
861 for num in `seq $MDSCOUNT`; do
864 for num in `seq $OSTCOUNT`; do
879 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
883 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
885 if [ ! -z $SEC ]; then
886 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
887 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
891 # We need ldiskfs here, may as well load them all
893 [ "$CLIENTONLY" ] && return
894 echo "Formatting mdts, osts"
895 for num in `seq $MDSCOUNT`; do
896 echo "Format mds$num: $(mdsdevname $num)"
898 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
900 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
904 for num in `seq $OSTCOUNT`; do
905 echo "Format ost$num: $(ostdevname $num)"
907 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
909 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
915 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
919 # 0: success, the old identity set already.
920 # 1: success, the old identity does not set.
925 local j=`expr $num - 1`
926 local MDT="`do_facet mds$num ls -l $LPROC/mdt/ 2>/dev/null | grep MDT | awk '{print $9}' | grep $j$`"
928 if [ -z "$MDT" ]; then
932 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
935 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
937 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
940 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
942 if [ $old = "NONE" ]; then
952 if [ -z "$CLIENTONLY" ]; then
953 echo "Setup mdts, osts"
954 for num in `seq $MDSCOUNT`; do
955 DEVNAME=$(mdsdevname $num)
956 echo $REFORMAT | grep -q "reformat" \
957 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
958 start mds$num $DEVNAME $MDS_MOUNT_OPTS
959 switch_identity $num $IDENTITY_UPCALL
961 for num in `seq $OSTCOUNT`; do
962 DEVNAME=$(ostdevname $num)
963 start ost$num $DEVNAME $OST_MOUNT_OPTS
966 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
968 if [ "$MOUNT_2" ]; then
974 mounted_lustre_filesystems() {
975 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
978 check_and_setup_lustre() {
979 MOUNTED="`mounted_lustre_filesystems`"
980 if [ -z "$MOUNTED" ]; then
981 [ "$REFORMAT" ] && formatall
983 MOUNTED="`mounted_lustre_filesystems`"
984 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
987 if [ "$ONLY" == "setup" ]; then
992 cleanup_and_setup_lustre() {
993 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
994 sysctl -w lnet.debug=0 || true
996 if [ "$ONLY" == "cleanup" ]; then
1000 check_and_setup_lustre
1003 check_and_cleanup_lustre() {
1004 if [ "`mount | grep $MOUNT`" ]; then
1005 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1007 if [ "$I_MOUNTED" = "yes" ]; then
1008 cleanupall -f || error "cleanup failed"
1020 while [ $NETWORK -eq 0 ]; do
1021 ping -c 1 -w 3 $1 > /dev/null
1022 if [ $? -eq 0 ]; then
1026 echo "waiting for $1, $((MAX - WAIT)) secs left"
1029 if [ $WAIT -gt $MAX ]; then
1030 echo "Network not available"
1036 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1047 # the sed converts spaces to commas, but leaves the last space
1048 # alone, so the line doesn't end with a comma.
1049 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1053 (cd `dirname $1`; echo $PWD/`basename $1`)
1056 ##################################
1060 # OBD_FAIL_MDS_ALL_REQUEST_NET
1062 do_facet mds sysctl -w lustre.fail_loc=0x123
1063 do_facet client "$1" || RC=$?
1064 do_facet mds sysctl -w lustre.fail_loc=0
1069 # OBD_FAIL_MDS_ALL_REPLY_NET
1071 do_facet mds sysctl -w lustre.fail_loc=0x122
1072 do_facet client "$@" || RC=$?
1073 do_facet mds sysctl -w lustre.fail_loc=0
1077 drop_reint_reply() {
1078 # OBD_FAIL_MDS_REINT_NET_REP
1080 do_facet mds sysctl -w lustre.fail_loc=0x119
1081 do_facet client "$@" || RC=$?
1082 do_facet mds sysctl -w lustre.fail_loc=0
1087 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1089 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1090 do_facet client "$1" || RC=$?
1091 do_facet client "sync"
1092 do_facet ost1 sysctl -w lustre.fail_loc=0
1096 drop_ldlm_cancel() {
1097 #define OBD_FAIL_LDLM_CANCEL 0x304
1099 do_facet client sysctl -w lustre.fail_loc=0x304
1100 do_facet client "$@" || RC=$?
1101 do_facet client sysctl -w lustre.fail_loc=0
1105 drop_bl_callback() {
1106 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1108 do_facet client sysctl -w lustre.fail_loc=0x305
1109 do_facet client "$@" || RC=$?
1110 do_facet client sysctl -w lustre.fail_loc=0
1115 #define OBD_FAIL_LDLM_REPLY 0x30c
1117 do_facet mds sysctl -w lustre.fail_loc=0x30c
1118 do_facet client "$@" || RC=$?
1119 do_facet mds sysctl -w lustre.fail_loc=0
1127 echo "clearing fail_loc on $facet"
1128 do_facet $facet "sysctl -w lustre.fail_loc=0"
1131 cancel_lru_locks() {
1132 $LCTL mark "cancel_lru_locks $1 start"
1133 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1134 [ -f $d/lru_size ] && echo clear > $d/lru_size
1135 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1137 $LCTL mark "cancel_lru_locks $1 stop"
1142 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1143 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1144 echo there is still data in page cache $a ?
1153 DEBUGSAVE="$(sysctl -n lnet.debug)"
1157 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1161 ##################################
1163 ##################################
1166 local FAIL_ON_ERROR=${FAIL_ON_ERROR:-true}
1167 local TYPE=${TYPE:-"FAIL"}
1169 sysctl -w lustre.fail_loc=0 2> /dev/null || true
1170 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1171 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1172 echo "Dumping lctl log to $ERRLOG"
1173 # We need to dump the logs on all nodes
1174 local NODES=$(nodes_list)
1175 for NODE in $NODES; do
1176 do_node $NODE $LCTL dk $ERRLOG
1179 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1180 if $FAIL_ON_ERROR; then
1185 # use only if we are ignoring failures for this test, bugno required.
1186 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1187 # e.g. error_ignore 5494 "your message"
1189 FAIL_ON_ERROR=false TYPE="IGNORE (bz$1)" error $2
1193 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1194 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1197 build_test_filter() {
1198 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1202 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1203 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1204 [ "$EXCEPT_SLOW" ] && \
1205 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1206 for E in $EXCEPT $ALWAYS_EXCEPT; do
1207 eval EXCEPT_${E}=true
1209 for E in $EXCEPT_SLOW; do
1210 eval EXCEPT_SLOW_${E}=true
1212 for G in $GRANT_CHECK_LIST; do
1213 eval GCHECK_ONLY_${G}=true
1222 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1226 export base=`basetest $1`
1227 if [ ! -z "$ONLY" ]; then
1229 if [ ${!testname}x != x ]; then
1234 if [ ${!testname}x != x ]; then
1242 if [ ${!testname}x != x ]; then
1243 TESTNAME=test_$1 skip "skipping excluded test $1"
1246 testname=EXCEPT_$base
1247 if [ ${!testname}x != x ]; then
1248 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1251 testname=EXCEPT_SLOW_$1
1252 if [ ${!testname}x != x ]; then
1253 TESTNAME=test_$1 skip "skipping SLOW test $1"
1256 testname=EXCEPT_SLOW_$base
1257 if [ ${!testname}x != x ]; then
1258 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1267 EQUALS="======================================================================"
1271 local suffixlen=$((${#EQUALS} - ${#msg}))
1272 [ $suffixlen -lt 5 ] && suffixlen=5
1273 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1278 lsmod | grep lnet > /dev/null || load_modules
1289 local NODES=$(nodes_list)
1290 for NODE in $NODES; do
1291 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1297 strace -o $TMP/$1.strace -ttt $*
1299 log "FINISHED: $*: rc $RC"
1308 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1309 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1310 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1314 local myNODES=$(nodes_list)
1317 for NODE in $myNODES; do
1318 do_node $NODE sysctl -w lustre.fail_loc=0 || true
1326 export tdir=d0.${TESTSUITE}/d${base}
1327 local SAVE_UMASK=`umask`
1332 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1334 export TESTNAME=test_$testnum
1335 test_${testnum} || error "test_$testnum failed with $?"
1338 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1339 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1340 error "LBUG/LASSERT detected"
1341 pass "($((`date +%s` - $BEFORE))s)"
1342 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1351 (cd `dirname $1`; echo $PWD/`basename $1`)
1355 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1356 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1361 export base=`basetest $1`
1362 [ "$CHECK_GRANT" == "no" ] && return 0
1364 testname=GCHECK_ONLY_${base}
1365 [ ${!testname}x == x ] && return 0
1367 echo -n "checking grant......"
1369 # write some data to sync client lost_grant
1370 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1371 for i in `seq $OSTCOUNT`; do
1372 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1373 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1374 count=1 > /dev/null 2>&1
1376 # sync all the data and make sure no pending data on server
1379 #get client grant and server grant
1381 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1382 client_grant=$((client_grant + `cat $d`))
1385 for d in ${LPROC}/obdfilter/*/tot_granted; do
1386 server_grant=$((server_grant + `cat $d`))
1389 # cleanup the check_grant file
1390 for i in `seq $OSTCOUNT`; do
1391 rm $DIR1/${tfile}_check_grant_$i
1394 #check whether client grant == server grant
1395 if [ $client_grant != $server_grant ]; then
1396 echo "failed: client:${client_grant} server: ${server_grant}"
1403 ########################
1409 ost=`echo $1 | awk -F_ '{print $3}'`
1410 if [ -z $ost ]; then
1411 ost=`echo $1 | sed 's/-osc.*//'`
1418 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1423 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1428 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
1433 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1437 local MDSNODES=$(facet_host $SINGLEMDS)
1440 # FIXME: Currenly we use only $SINGLEMDS,
1441 # should be fixed when we will start to test cmd.
1445 for num in `seq $MDSCOUNT`; do
1446 local myMDS=$(facet_host mds$num)
1447 MDSNODES="$MDSNODES $myMDS"
1449 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1455 local OSTNODES=$(facet_host ost1)
1458 for num in `seq $OSTCOUNT`; do
1459 local myOST=$(facet_host ost$num)
1460 OSTNODES="$OSTNODES $myOST"
1462 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1468 # FIXME. We need a list of clients
1469 local myNODES=$HOSTNAME
1472 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1473 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1476 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1483 grep -q patchless $LPROC/version
1490 mkdir $DIR/d0_runas_test
1492 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1493 $myRUNAS touch $DIR/d0_runas_test/f$$ || \
1494 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1495 Please set RUNAS_ID to some UID which exists on MDS and client or
1496 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1497 rm -rf $DIR/d0_runas_test