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=default
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 [ "$PTLDEBUG" ] && sysctl -w lnet.debug=$PTLDEBUG
186 [ "$SUBSYSTEM" ] && sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }
187 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
188 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
189 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
190 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
191 echo "lnet options: '$LNETOPTS'"
192 # note that insmod will ignore anything in modprobe.conf
193 load_module ../lnet/lnet/lnet $LNETOPTS
194 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
195 load_module ../lnet/klnds/$LNETLND
196 load_module lvfs/lvfs
197 load_module obdclass/obdclass
198 load_module ptlrpc/ptlrpc
199 load_module ptlrpc/gss/ptlrpc_gss
200 # Now, some modules depend on lquota without USE_QUOTA check,
201 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
202 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
203 load_module quota/lquota
211 if [ -z "$CLIENTONLY" ]; then
212 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
217 load_module lvfs/fsfilt_$FSTYPE
221 load_module obdfilter/obdfilter
224 load_module llite/lustre
225 load_module llite/llite_lloop
226 rm -f $TMP/ogdb-$HOSTNAME
228 [ -d /r ] && OGDB="/r/tmp"
229 $LCTL modules > $OGDB/ogdb-$HOSTNAME
231 # 'mount' doesn't look in $PATH, just sbin
232 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
236 if [ `uname -r | cut -c 3` -eq 4 ]; then
244 MODULES=$($LCTL modules | awk '{ print $2 }')
245 while [ -n "$MODULES" ]; do
247 $RMMOD $MODULES > /dev/null 2>&1 || true
248 MODULES=$($LCTL modules | awk '{ print $2 }')
249 if [ -z "$MODULES" ]; then
253 echo "waiting, $((MAX - WAIT)) secs left"
255 if [ $WAIT -eq $MAX ]; then
256 echo "LNET modules $MODULES will not unload"
264 wait_exit_ST client # bug 12845
266 lsmod | grep libcfs > /dev/null && $LCTL dl
267 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
268 $RMMOD $MODULES > /dev/null 2>&1 || true
269 # do it again, in case we tried to unload ksocklnd too early
270 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
271 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
272 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
274 MODULES=$($LCTL modules | awk '{ print $2 }')
275 if [ -n "$MODULES" ]; then
276 echo "Modules still loaded: "
278 if [ "$(lctl dl)" ]; then
279 echo "Lustre still loaded"
284 echo "Lustre stopped but LNET is still loaded, waiting..."
285 wait_for_lnet || return 3
291 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
292 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
293 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
294 echo "$LEAK_LUSTRE" 1>&2
295 echo "$LEAK_PORTALS" 1>&2
296 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
297 echo "Memory leaks detected"
298 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
301 echo "modules unloaded."
305 check_gss_daemon_facet() {
309 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
310 if [ $num -ne 1 ]; then
311 echo "$num instance of $dname on $facet"
320 do_facet $facet "killall -2 $@ 2>/dev/null || true"
323 start_gss_daemons() {
325 for num in `seq $MDSCOUNT`; do
326 do_facet mds$num "$LSVCGSSD -v"
328 do_facet mds$num "$LGSSD -v"
332 for num in `seq $OSTCOUNT`; do
333 do_facet ost$num "$LSVCGSSD -v"
336 # FIXME: is "client" the right facet name?
338 do_facet client "$LGSSD -v"
341 # wait daemons entering "stable" status
345 # check daemons are running
347 for num in `seq $MDSCOUNT`; do
348 check_gss_daemon_facet mds$num lsvcgssd
350 check_gss_daemon_facet mds$num lgssd
353 for num in `seq $OSTCOUNT`; do
354 check_gss_daemon_facet ost$num lsvcgssd
357 check_gss_daemon_facet client lgssd
362 for num in `seq $MDSCOUNT`; do
363 send_sigint mds$num lsvcgssd lgssd
365 for num in `seq $OSTCOUNT`; do
366 send_sigint ost$num lsvcgssd
368 send_sigint client lgssd
380 # maybe cleanup credential cache?
386 local device=`mdsdevname $num`
387 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
393 local device=`ostdevname $num`
394 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
399 # start facet device options
405 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
406 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
407 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
409 if [ $RC -ne 0 ]; then
410 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
411 echo Start of ${device} on ${facet} failed ${RC}
413 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
414 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
415 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
417 do_facet ${facet} sync
418 label=$(do_facet ${facet} "e2label ${device}")
419 [ -z "$label" ] && echo no label for ${device} && exit 1
420 eval export ${facet}_svc=${label}
421 eval export ${facet}_dev=${device}
422 eval export ${facet}_opt=\"$@\"
423 echo Started ${label}
432 HOST=`facet_active_host $facet`
433 [ -z $HOST ] && echo stop: no host for $facet && return 0
435 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
436 if [ ${running} -ne 0 ]; then
437 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
438 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
441 # umount should block, but we should wait for unrelated obd's
442 # like the MGS or MGC to also stop.
443 wait_exit_ST ${facet}
450 # Only supply -o to mount if we have options
451 if [ -n "$MOUNTOPT" ]; then
452 OPTIONS="-o $MOUNTOPT"
454 local device=$MGSNID:/$FSNAME
455 if [ -z "$mnt" -o -z "$FSNAME" ]; then
456 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
460 echo "Starting client: $OPTIONS $device $mnt"
461 do_node $client mkdir -p $mnt
462 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
464 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
465 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
466 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
467 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
475 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
476 if [ $running -ne 0 ]; then
477 echo "Stopping client $mnt (opts:$force)"
478 lsof | grep "$mnt" || true
479 do_node $client umount $force $mnt
485 if [ "$FAILURE_MODE" = HARD ]; then
486 $POWER_DOWN `facet_active_host $facet`
488 elif [ "$FAILURE_MODE" = SOFT ]; then
495 if [ "$FAILURE_MODE" = HARD ]; then
496 $POWER_UP `facet_active_host $facet`
502 # verify that lustre actually cleaned up properly
504 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
505 error "LBUG/LASSERT detected"
506 BUSY=`dmesg | grep -i destruct || true`
509 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
512 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
513 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
514 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
515 echo "$0: $LEAK_LUSTRE" 1>&2
516 echo "$0: $LEAK_PORTALS" 1>&2
517 echo "$0: Memory leak(s) detected..." 1>&2
518 mv $TMP/debug $TMP/debug-leak.`date +%s`
522 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
523 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
525 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
526 echo "$0: modules still loaded..." 1>&2
533 wait_delete_completed () {
534 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
535 $LPROC/osc/*/kbytesavail`
539 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
541 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
542 $LPROC/osc/*/kbytesavail`
543 [ "$TOTAL" -eq "$TOTALPREV" ] && break
544 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
548 echo "Delete completed."
553 check_network "$HOST" 900
554 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
559 HOST=`facet_active_host $facet`
563 wait_mds_recovery_done () {
564 local timeout=`do_facet mds sysctl -n lustre.timeout`
565 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
566 # as we are in process of changing obd_timeout in different ways
567 # let's set MAX longer than that
568 MAX=$(( timeout * 4 ))
570 while [ $WAIT -lt $MAX ]; do
571 STATUS=`do_facet $SINGLEMDS grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
572 echo $STATUS | grep COMPLETE && return 0
575 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
577 echo "MDS recovery not done in $MAX sec"
586 # conf-sanity 31 takes a long time cleanup
587 while [ $WAIT -lt 300 ]; do
588 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
589 [ -z "${running}" ] && return 0
590 echo "waited $WAIT for${running}"
591 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
593 WAIT=$((WAIT + INTERVAL))
595 echo "service didn't stop after $WAIT seconds. Still running:"
601 # not every config has many clients
602 if [ ! -z "$CLIENTS" ]; then
603 $PDSH $CLIENTS "df $MOUNT" > /dev/null
608 uname -n >> $MOUNT/recon
609 if [ ! -z "$CLIENTS" ]; then
610 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
612 echo Connected clients:
614 ls -l $MOUNT/recon > /dev/null
620 echo "Failing $facet on node `facet_active_host $facet`"
621 shutdown_facet $facet
625 echo "df pid is $DFPID"
627 TO=`facet_active_host $facet`
628 echo "Failover $facet to $TO"
630 local dev=${facet}_dev
631 local opt=${facet}_opt
632 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
643 local svc=${facet}_svc
644 do_facet $facet $LCTL --device %${!svc} readonly
645 do_facet $facet $LCTL --device %${!svc} notransno
646 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
647 $LCTL mark "local REPLAY BARRIER on ${!svc}"
650 replay_barrier_nodf() {
651 local facet=$1 echo running=${running}
653 local svc=${facet}_svc
654 echo Replay barrier on ${!svc}
655 do_facet $facet $LCTL --device %${!svc} readonly
656 do_facet $facet $LCTL --device %${!svc} notransno
657 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
658 $LCTL mark "local REPLAY BARRIER on ${!svc}"
662 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
663 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
667 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
668 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
672 facet_failover $* || error "failover: $?"
673 df $MOUNT || error "post-failover df: $?"
678 facet_failover $facet
685 local svc=${facet}_svc
686 local dev=${facet}_dev
687 local opt=${facet}_opt
688 start $facet ${!dev} ${!opt}
689 do_facet $facet lctl --device %${!svc} abort_recovery
690 df $MOUNT || echo "first df failed: $?"
692 df $MOUNT || error "post-failover df: $?"
696 echo There is no lmc. This is mountconf, baby.
701 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
702 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
708 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
714 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
715 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
716 if [ -z "$ID" ]; then
717 echo "Could not get a ptl id for $1..."
726 h2name_or_ip "$1" "tcp"
731 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
732 if type __h2elan >/dev/null 2>&1; then
735 ID=`echo $1 | sed 's/[^0-9]*//g'`
743 h2name_or_ip "$1" "openib"
748 h2name_or_ip "$1" "o2ib"
754 varname=${facet}_HOST
755 if [ -z "${!varname}" ]; then
756 if [ "${facet:0:3}" == "ost" ]; then
757 eval ${facet}_HOST=${ost_HOST}
765 local activevar=${facet}active
767 if [ -f ./${facet}active ] ; then
768 source ./${facet}active
772 if [ -z "$active" ] ; then
779 facet_active_host() {
781 local active=`facet_active $facet`
782 if [ "$facet" == client ]; then
785 echo `facet_host $active`
791 failover=${facet}failover
792 host=`facet_host $failover`
793 [ -z "$host" ] && return
794 curactive=`facet_active $facet`
795 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
796 eval export ${facet}active=$facet
798 eval export ${facet}active=$failover
800 # save the active host for this facet
801 activevar=${facet}active
802 echo "$activevar=${!activevar}" > ./$activevar
809 if [ "$HOST" = "$HOSTNAME" ]; then
811 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
812 echo "cannot run remote command on $HOST with $myPDSH"
816 echo "CMD: $HOST $@" >&2
817 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
820 if [ "$myPDSH" = "rsh" ]; then
821 # we need this because rsh does not return exit code of an executed command
822 local command_status="$TMP/cs"
823 rsh $HOST ":> $command_status"
824 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
825 cd $RPWD; sh -c \"$@\") ||
826 echo command failed >$command_status"
827 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
830 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
831 return ${PIPESTATUS[0]}
837 HOST=`facet_active_host $facet`
838 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
845 # make sure its not already running
848 do_facet ${facet} $MKFS $*
854 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
855 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
862 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
863 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
871 # make sure we are using the primary server, so test-framework will
872 # be able to clean up properly.
873 activemds=`facet_active mds1`
874 if [ $activemds != "mds1" ]; then
878 # assume client mount is local
879 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
880 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
881 [ "$CLIENTONLY" ] && return
882 for num in `seq $MDSCOUNT`; do
885 for num in `seq $OSTCOUNT`; do
900 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
904 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
906 if [ ! -z $SEC ]; then
907 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
908 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
912 # We need ldiskfs here, may as well load them all
914 [ "$CLIENTONLY" ] && return
915 echo "Formatting mdts, osts"
916 for num in `seq $MDSCOUNT`; do
917 echo "Format mds$num: $(mdsdevname $num)"
919 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
921 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
925 for num in `seq $OSTCOUNT`; do
926 echo "Format ost$num: $(ostdevname $num)"
928 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
930 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
936 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
940 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
944 # 0: success, the old identity set already.
945 # 1: success, the old identity does not set.
950 local j=`expr $num - 1`
951 local MDT="`do_facet mds$num find $LPROC/mdt/ -name \*MDT\*$j -printf %f 2>/dev/null || true`"
953 if [ -z "$MDT" ]; then
957 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
960 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
962 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
965 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
967 if [ $old = "NONE" ]; then
976 zconf_umount `hostname` $1 || error "umount failed"
977 zconf_mount `hostname` $1 || error "mount failed"
984 do_facet $facet lsmod | grep -q obdclass || \
985 do_facet $facet "modprobe obdclass"
987 do_facet $facet "sysctl -w lustre.timeout=$timeout"
993 if [ -z "$CLIENTONLY" ]; then
994 echo "Setup mdts, osts"
995 for num in `seq $MDSCOUNT`; do
996 DEVNAME=$(mdsdevname $num)
997 echo $REFORMAT | grep -q "reformat" \
998 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
999 set_obd_timeout mds$num $TIMEOUT
1000 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1001 if [ $IDENTITY_UPCALL != "default" ]; then
1002 switch_identity $num $IDENTITY_UPCALL
1005 for num in `seq $OSTCOUNT`; do
1006 DEVNAME=$(ostdevname $num)
1007 set_obd_timeout ost$num $TIMEOUT
1008 start ost$num $DEVNAME $OST_MOUNT_OPTS
1011 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1013 if [ "$MOUNT_2" ]; then
1014 mount_client $MOUNT2
1017 # by remounting mdt before ost, initial connect from mdt to ost might
1018 # timeout because ost is not ready yet. wait some time to its fully
1019 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1020 # by a context negotiation rpc with $TIMEOUT.
1021 # FIXME better by monitoring import status.
1023 sleep $((TIMEOUT + 5))
1029 mounted_lustre_filesystems() {
1030 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1033 check_and_setup_lustre() {
1034 MOUNTED="`mounted_lustre_filesystems`"
1035 if [ -z "$MOUNTED" ]; then
1036 [ "$REFORMAT" ] && formatall
1038 MOUNTED="`mounted_lustre_filesystems`"
1039 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1040 export I_MOUNTED=yes
1042 if [ "$ONLY" == "setup" ]; then
1047 cleanup_and_setup_lustre() {
1048 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1049 sysctl -w lnet.debug=0 || true
1051 if [ "$ONLY" == "cleanup" ]; then
1055 check_and_setup_lustre
1058 check_and_cleanup_lustre() {
1059 if [ "`mount | grep $MOUNT`" ]; then
1060 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1062 if [ "$I_MOUNTED" = "yes" ]; then
1063 cleanupall -f || error "cleanup failed"
1075 while [ $NETWORK -eq 0 ]; do
1076 ping -c 1 -w 3 $1 > /dev/null
1077 if [ $? -eq 0 ]; then
1081 echo "waiting for $1, $((MAX - WAIT)) secs left"
1084 if [ $WAIT -gt $MAX ]; then
1085 echo "Network not available"
1091 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1102 # the sed converts spaces to commas, but leaves the last space
1103 # alone, so the line doesn't end with a comma.
1104 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1108 (cd `dirname $1`; echo $PWD/`basename $1`)
1111 ##################################
1115 # OBD_FAIL_MDS_ALL_REQUEST_NET
1117 do_facet mds sysctl -w lustre.fail_loc=0x123
1118 do_facet client "$1" || RC=$?
1119 do_facet mds sysctl -w lustre.fail_loc=0
1124 # OBD_FAIL_MDS_ALL_REPLY_NET
1126 do_facet mds sysctl -w lustre.fail_loc=0x122
1127 do_facet client "$@" || RC=$?
1128 do_facet mds sysctl -w lustre.fail_loc=0
1132 drop_reint_reply() {
1133 # OBD_FAIL_MDS_REINT_NET_REP
1135 do_facet mds sysctl -w lustre.fail_loc=0x119
1136 do_facet client "$@" || RC=$?
1137 do_facet mds sysctl -w lustre.fail_loc=0
1142 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1144 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1145 do_facet client "$1" || RC=$?
1146 do_facet client "sync"
1147 do_facet ost1 sysctl -w lustre.fail_loc=0
1151 drop_ldlm_cancel() {
1152 #define OBD_FAIL_LDLM_CANCEL 0x304
1154 do_facet client sysctl -w lustre.fail_loc=0x304
1155 do_facet client "$@" || RC=$?
1156 do_facet client sysctl -w lustre.fail_loc=0
1160 drop_bl_callback() {
1161 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1163 do_facet client sysctl -w lustre.fail_loc=0x305
1164 do_facet client "$@" || RC=$?
1165 do_facet client sysctl -w lustre.fail_loc=0
1170 #define OBD_FAIL_LDLM_REPLY 0x30c
1172 do_facet mds sysctl -w lustre.fail_loc=0x30c
1173 do_facet client "$@" || RC=$?
1174 do_facet mds sysctl -w lustre.fail_loc=0
1182 echo "clearing fail_loc on $facet"
1183 do_facet $facet "sysctl -e -w lustre.fail_loc=0"
1186 cancel_lru_locks() {
1187 $LCTL mark "cancel_lru_locks $1 start"
1188 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1189 [ -f $d/lru_size ] && echo clear > $d/lru_size
1190 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1192 $LCTL mark "cancel_lru_locks $1 stop"
1197 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1198 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1199 echo "$DEFAULT_LRU_SIZE"
1205 test "x$NS" = "x" && NS="mdc"
1206 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1208 log "Enable lru resize for $(basename $D)"
1213 lru_resize_disable()
1216 test "x$NS" = "x" && NS="mdc"
1217 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1219 log "Disable lru resize for $(basename $D)"
1220 DEFAULT_LRU_SIZE=$(default_lru_size)
1221 echo "$DEFAULT_LRU_SIZE" > $F
1226 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1227 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1228 echo there is still data in page cache $a ?
1237 DEBUGSAVE="$(sysctl -n lnet.debug)"
1241 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1245 ##################################
1247 ##################################
1250 local TYPE=${TYPE:-"FAIL"}
1252 sysctl -e -w lustre.fail_loc=0 || true
1253 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1254 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1255 echo "Dumping lctl log to $ERRLOG"
1256 # We need to dump the logs on all nodes
1257 local NODES=$(nodes_list)
1258 for NODE in $NODES; do
1259 do_node $NODE $LCTL dk $ERRLOG
1262 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1267 [ "$FAIL_ON_ERROR" ] && exit 1 || true
1275 # use only if we are ignoring failures for this test, bugno required.
1276 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1277 # e.g. error_ignore 5494 "your message"
1279 TYPE="IGNORE (bz$1)"
1285 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1286 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1289 build_test_filter() {
1290 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1294 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1295 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1296 [ "$EXCEPT_SLOW" ] && \
1297 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1298 for E in $EXCEPT $ALWAYS_EXCEPT; do
1299 eval EXCEPT_${E}=true
1301 for E in $EXCEPT_SLOW; do
1302 eval EXCEPT_SLOW_${E}=true
1304 for G in $GRANT_CHECK_LIST; do
1305 eval GCHECK_ONLY_${G}=true
1314 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1318 export base=`basetest $1`
1319 if [ ! -z "$ONLY" ]; then
1321 if [ ${!testname}x != x ]; then
1326 if [ ${!testname}x != x ]; then
1334 if [ ${!testname}x != x ]; then
1335 TESTNAME=test_$1 skip "skipping excluded test $1"
1338 testname=EXCEPT_$base
1339 if [ ${!testname}x != x ]; then
1340 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1343 testname=EXCEPT_SLOW_$1
1344 if [ ${!testname}x != x ]; then
1345 TESTNAME=test_$1 skip "skipping SLOW test $1"
1348 testname=EXCEPT_SLOW_$base
1349 if [ ${!testname}x != x ]; then
1350 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1359 EQUALS="======================================================================"
1363 local suffixlen=$((${#EQUALS} - ${#msg}))
1364 [ $suffixlen -lt 5 ] && suffixlen=5
1365 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1370 lsmod | grep lnet > /dev/null || load_modules
1381 local NODES=$(nodes_list)
1382 for NODE in $NODES; do
1383 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1389 strace -o $TMP/$1.strace -ttt $*
1391 log "FINISHED: $*: rc $RC"
1400 FFREE=`cat /proc/fs/lustre/osd/*MDT*/filesfree`
1401 FTOTAL=`cat /proc/fs/lustre/osd/*MDT*/filestotal`
1402 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1406 local myNODES=$(nodes_list)
1409 for NODE in $myNODES; do
1410 do_node $NODE sysctl -e -w lustre.fail_loc=0 || true
1418 export tdir=d0.${TESTSUITE}/d${base}
1419 local SAVE_UMASK=`umask`
1424 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1426 export TESTNAME=test_$testnum
1427 test_${testnum} || error "test_$testnum failed with $?"
1430 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1431 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1432 error "LBUG/LASSERT detected"
1433 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1434 pass "($((`date +%s` - $BEFORE))s)"
1435 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1444 (cd `dirname $1`; echo $PWD/`basename $1`)
1448 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1449 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1454 export base=`basetest $1`
1455 [ "$CHECK_GRANT" == "no" ] && return 0
1457 testname=GCHECK_ONLY_${base}
1458 [ ${!testname}x == x ] && return 0
1460 echo -n "checking grant......"
1462 # write some data to sync client lost_grant
1463 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1464 for i in `seq $OSTCOUNT`; do
1465 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1466 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1467 count=1 > /dev/null 2>&1
1469 # sync all the data and make sure no pending data on server
1472 #get client grant and server grant
1474 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1475 client_grant=$((client_grant + `cat $d`))
1478 for d in ${LPROC}/obdfilter/*/tot_granted; do
1479 server_grant=$((server_grant + `cat $d`))
1482 # cleanup the check_grant file
1483 for i in `seq $OSTCOUNT`; do
1484 rm $DIR1/${tfile}_check_grant_$i
1487 #check whether client grant == server grant
1488 if [ $client_grant != $server_grant ]; then
1489 echo "failed: client:${client_grant} server: ${server_grant}"
1496 ########################
1502 ost=`echo $1 | awk -F_ '{print $3}'`
1503 if [ -z $ost ]; then
1504 ost=`echo $1 | sed 's/-osc.*//'`
1511 [ ! -z "$(lctl dl | grep \<mdt\>)" ]
1516 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1521 [ -z "$(lctl dl | grep \<ost\>)" ]
1526 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1530 local MDSNODES=$(facet_host $SINGLEMDS)
1533 # FIXME: Currenly we use only $SINGLEMDS,
1534 # should be fixed when we will start to test cmd.
1538 for num in `seq $MDSCOUNT`; do
1539 local myMDS=$(facet_host mds$num)
1540 MDSNODES="$MDSNODES $myMDS"
1542 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1548 local OSTNODES=$(facet_host ost1)
1551 for num in `seq $OSTCOUNT`; do
1552 local myOST=$(facet_host ost$num)
1553 OSTNODES="$OSTNODES $myOST"
1555 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1561 # FIXME. We need a list of clients
1562 local myNODES=$HOSTNAME
1565 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1566 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1569 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1576 lctl get_param version | grep -q patchless
1585 $myRUNAS krb5_login.sh || \
1586 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1589 mkdir $DIR/d0_runas_test
1591 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1592 $myRUNAS touch $DIR/d0_runas_test/f$$ || \
1593 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1594 Please set RUNAS_ID to some UID which exists on MDS and client or
1595 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1596 rm -rf $DIR/d0_runas_test
1599 # Run multiop in the background, but wait for it to print
1600 # "PAUSING" to its stdout before returning from this function.
1601 multiop_bg_pause() {
1602 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1606 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1609 echo "$MULTIOP_PROG $FILE v$ARGS"
1610 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1612 echo "TMPPIPE=${TMPPIPE}"
1613 read -t 60 multiop_output < $TMPPIPE
1614 if [ $? -ne 0 ]; then
1619 if [ "$multiop_output" != "PAUSING" ]; then
1620 echo "Incorrect multiop output: $multiop_output"