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" ] && [ -z "$CLIENTMODSONLY" ]; then
212 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
213 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
218 load_module lvfs/fsfilt_$FSTYPE
222 load_module obdfilter/obdfilter
225 load_module llite/lustre
226 load_module llite/llite_lloop
227 rm -f $TMP/ogdb-$HOSTNAME
229 [ -d /r ] && OGDB="/r/tmp"
230 $LCTL modules > $OGDB/ogdb-$HOSTNAME
232 # 'mount' doesn't look in $PATH, just sbin
233 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
237 if [ `uname -r | cut -c 3` -eq 4 ]; then
245 MODULES=$($LCTL modules | awk '{ print $2 }')
246 while [ -n "$MODULES" ]; do
248 $RMMOD $MODULES > /dev/null 2>&1 || true
249 MODULES=$($LCTL modules | awk '{ print $2 }')
250 if [ -z "$MODULES" ]; then
254 echo "waiting, $((MAX - WAIT)) secs left"
256 if [ $WAIT -eq $MAX ]; then
257 echo "LNET modules $MODULES will not unload"
265 wait_exit_ST client # bug 12845
267 lsmod | grep libcfs > /dev/null && $LCTL dl
268 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
269 $RMMOD $MODULES > /dev/null 2>&1 || true
270 # do it again, in case we tried to unload ksocklnd too early
271 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
272 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
273 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
275 MODULES=$($LCTL modules | awk '{ print $2 }')
276 if [ -n "$MODULES" ]; then
277 echo "Modules still loaded: "
279 if [ "$(lctl dl)" ]; then
280 echo "Lustre still loaded"
285 echo "Lustre stopped but LNET is still loaded, waiting..."
286 wait_for_lnet || return 3
292 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
293 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
294 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
295 echo "$LEAK_LUSTRE" 1>&2
296 echo "$LEAK_PORTALS" 1>&2
297 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
298 echo "Memory leaks detected"
299 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
302 echo "modules unloaded."
306 check_gss_daemon_facet() {
310 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
311 if [ $num -ne 1 ]; then
312 echo "$num instance of $dname on $facet"
321 do_facet $facet "killall -2 $@ 2>/dev/null || true"
324 start_gss_daemons() {
326 for num in `seq $MDSCOUNT`; do
327 do_facet mds$num "$LSVCGSSD -v"
329 do_facet mds$num "$LGSSD -v"
333 for num in `seq $OSTCOUNT`; do
334 do_facet ost$num "$LSVCGSSD -v"
337 # FIXME: is "client" the right facet name?
339 do_facet client "$LGSSD -v"
342 # wait daemons entering "stable" status
346 # check daemons are running
348 for num in `seq $MDSCOUNT`; do
349 check_gss_daemon_facet mds$num lsvcgssd
351 check_gss_daemon_facet mds$num lgssd
354 for num in `seq $OSTCOUNT`; do
355 check_gss_daemon_facet ost$num lsvcgssd
358 check_gss_daemon_facet client lgssd
363 for num in `seq $MDSCOUNT`; do
364 send_sigint mds$num lsvcgssd lgssd
366 for num in `seq $OSTCOUNT`; do
367 send_sigint ost$num lsvcgssd
369 send_sigint client lgssd
381 # maybe cleanup credential cache?
387 local device=`mdsdevname $num`
388 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
394 local device=`ostdevname $num`
395 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
403 local dev=${facet}_dev
404 local opt=${facet}_opt
405 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
406 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
408 if [ $RC -ne 0 ]; then
409 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
410 echo "Start of ${device} on ${facet} failed ${RC}"
412 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
413 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
414 sysctl -w lnet.debug_mb=${DEBUG_SIZE}; \
420 # start facet device options
426 eval export ${facet}_dev=${device}
427 eval export ${facet}_opt=\"$@\"
428 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
431 if [ $RC -eq 0 ]; then
432 label=$(do_facet ${facet} "e2label ${device}")
433 [ -z "$label" ] && echo no label for ${device} && exit 1
434 eval export ${facet}_svc=${label}
435 echo Started ${label}
444 HOST=`facet_active_host $facet`
445 [ -z $HOST ] && echo stop: no host for $facet && return 0
447 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
448 if [ ${running} -ne 0 ]; then
449 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
450 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
453 # umount should block, but we should wait for unrelated obd's
454 # like the MGS or MGC to also stop.
455 wait_exit_ST ${facet}
462 # Only supply -o to mount if we have options
463 if [ -n "$MOUNTOPT" ]; then
464 OPTIONS="-o $MOUNTOPT"
466 local device=$MGSNID:/$FSNAME
467 if [ -z "$mnt" -o -z "$FSNAME" ]; then
468 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
472 echo "Starting client: $client: $OPTIONS $device $mnt"
473 do_node $client mkdir -p $mnt
474 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
476 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
477 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
478 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
479 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
487 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
488 if [ $running -ne 0 ]; then
489 echo "Stopping client $client $mnt (opts:$force)"
490 lsof | grep "$mnt" || true
491 do_node $client umount $force $mnt
495 zconf_mount_clients() {
499 echo "Mounting clients: $clients"
501 for client in ${clients//,/ }; do
502 zconf_mount $client $mnt || true
506 zconf_umount_clients() {
511 echo "Umounting clients: $clients"
513 for client in ${clients//,/ }; do
514 zconf_umount $client $mnt $force || true
520 if [ "$FAILURE_MODE" = HARD ]; then
521 $POWER_DOWN `facet_active_host $facet`
523 elif [ "$FAILURE_MODE" = SOFT ]; then
530 if [ "$FAILURE_MODE" = HARD ]; then
531 $POWER_UP `facet_active_host $facet`
537 # verify that lustre actually cleaned up properly
539 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
540 error "LBUG/LASSERT detected"
541 BUSY=`dmesg | grep -i destruct || true`
544 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
547 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
548 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
549 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
550 echo "$0: $LEAK_LUSTRE" 1>&2
551 echo "$0: $LEAK_PORTALS" 1>&2
552 echo "$0: Memory leak(s) detected..." 1>&2
553 mv $TMP/debug $TMP/debug-leak.`date +%s`
557 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
558 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
560 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
561 echo "$0: modules still loaded..." 1>&2
568 wait_delete_completed () {
569 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
570 $LPROC/osc/*/kbytesavail`
574 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
576 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
577 $LPROC/osc/*/kbytesavail`
578 [ "$TOTAL" -eq "$TOTALPREV" ] && break
579 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
583 echo "Delete completed."
588 check_network "$HOST" 900
589 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
594 HOST=`facet_active_host $facet`
598 wait_mds_recovery_done () {
599 local timeout=`do_facet mds sysctl -n lustre.timeout`
600 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
601 # as we are in process of changing obd_timeout in different ways
602 # let's set MAX longer than that
603 MAX=$(( timeout * 4 ))
605 while [ $WAIT -lt $MAX ]; do
606 STATUS=`do_facet $SINGLEMDS grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
607 echo $STATUS | grep COMPLETE && return 0
610 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
612 echo "MDS recovery not done in $MAX sec"
621 # conf-sanity 31 takes a long time cleanup
622 while [ $WAIT -lt 300 ]; do
623 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
624 [ -z "${running}" ] && return 0
625 echo "waited $WAIT for${running}"
626 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
628 WAIT=$((WAIT + INTERVAL))
630 echo "service didn't stop after $WAIT seconds. Still running:"
636 # not every config has many clients
637 if [ ! -z "$CLIENTS" ]; then
638 $PDSH $CLIENTS "df $MOUNT" > /dev/null
640 df $MOUNT > /dev/null
645 uname -n >> $MOUNT/recon
646 if [ ! -z "$CLIENTS" ]; then
647 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
649 echo Connected clients:
651 ls -l $MOUNT/recon > /dev/null
657 echo "Failing $facet on node `facet_active_host $facet`"
658 shutdown_facet $facet
662 echo "df pid is $DFPID"
664 TO=`facet_active_host $facet`
665 echo "Failover $facet to $TO"
667 mount_facet $facet || error "Restart of $facet failed"
678 local svc=${facet}_svc
679 do_facet $facet $LCTL --device %${!svc} readonly
680 do_facet $facet $LCTL --device %${!svc} notransno
681 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
682 $LCTL mark "local REPLAY BARRIER on ${!svc}"
685 replay_barrier_nodf() {
686 local facet=$1 echo running=${running}
688 local svc=${facet}_svc
689 echo Replay barrier on ${!svc}
690 do_facet $facet $LCTL --device %${!svc} readonly
691 do_facet $facet $LCTL --device %${!svc} notransno
692 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
693 $LCTL mark "local REPLAY BARRIER on ${!svc}"
697 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
698 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
702 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
703 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
707 facet_failover $* || error "failover: $?"
708 df $MOUNT || error "post-failover df: $?"
713 facet_failover $facet
720 mount_facet $facet -o abort_recovery
721 df $MOUNT || echo "first df failed: $?"
723 df $MOUNT || error "post-failover df: $?"
727 echo There is no lmc. This is mountconf, baby.
732 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
733 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
739 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
745 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
746 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
747 if [ -z "$ID" ]; then
748 echo "Could not get a ptl id for $1..."
757 h2name_or_ip "$1" "tcp"
762 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
763 if type __h2elan >/dev/null 2>&1; then
766 ID=`echo $1 | sed 's/[^0-9]*//g'`
774 h2name_or_ip "$1" "openib"
779 h2name_or_ip "$1" "o2ib"
785 varname=${facet}_HOST
786 if [ -z "${!varname}" ]; then
787 if [ "${facet:0:3}" == "ost" ]; then
788 eval ${facet}_HOST=${ost_HOST}
796 local activevar=${facet}active
798 if [ -f ./${facet}active ] ; then
799 source ./${facet}active
803 if [ -z "$active" ] ; then
810 facet_active_host() {
812 local active=`facet_active $facet`
813 if [ "$facet" == client ]; then
816 echo `facet_host $active`
822 failover=${facet}failover
823 host=`facet_host $failover`
824 [ -z "$host" ] && return
825 curactive=`facet_active $facet`
826 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
827 eval export ${facet}active=$facet
829 eval export ${facet}active=$failover
831 # save the active host for this facet
832 activevar=${facet}active
833 echo "$activevar=${!activevar}" > ./$activevar
840 if [ "$HOST" = "$HOSTNAME" ]; then
842 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
843 echo "cannot run remote command on $HOST with $myPDSH"
847 echo "CMD: $HOST $@" >&2
848 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
851 if [ "$myPDSH" = "rsh" ]; then
852 # we need this because rsh does not return exit code of an executed command
853 local command_status="$TMP/cs"
854 rsh $HOST ":> $command_status"
855 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
856 cd $RPWD; sh -c \"$@\") ||
857 echo command failed >$command_status"
858 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
861 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
862 return ${PIPESTATUS[0]}
868 HOST=`facet_active_host $facet`
869 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
876 # make sure its not already running
879 do_facet ${facet} $MKFS $*
885 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
886 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
893 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
894 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
902 # make sure we are using the primary server, so test-framework will
903 # be able to clean up properly.
904 activemds=`facet_active mds1`
905 if [ $activemds != "mds1" ]; then
909 # assume client mount is local
910 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
911 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
913 if [ -n "$CLIENTS" ]; then
914 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
915 zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
918 [ "$CLIENTONLY" ] && return
919 for num in `seq $MDSCOUNT`; do
922 for num in `seq $OSTCOUNT`; do
937 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
941 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
943 if [ ! -z $SEC ]; then
944 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
945 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
949 # We need ldiskfs here, may as well load them all
951 [ "$CLIENTONLY" ] && return
952 echo "Formatting mdts, osts"
953 for num in `seq $MDSCOUNT`; do
954 echo "Format mds$num: $(mdsdevname $num)"
956 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
958 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
962 for num in `seq $OSTCOUNT`; do
963 echo "Format ost$num: $(ostdevname $num)"
965 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
967 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
973 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
977 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
981 # 0: success, the old identity set already.
982 # 1: success, the old identity does not set.
987 local j=`expr $num - 1`
988 local MDT="`do_facet mds$num find $LPROC/mdt/ -name \*MDT\*$j -printf %f 2>/dev/null || true`"
990 if [ -z "$MDT" ]; then
994 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
997 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
999 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
1002 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
1004 if [ $old = "NONE" ]; then
1013 zconf_umount `hostname` $1 || error "umount failed"
1014 zconf_mount `hostname` $1 || error "mount failed"
1021 do_facet $facet lsmod | grep -q obdclass || \
1022 do_facet $facet "modprobe obdclass"
1024 do_facet $facet "sysctl -w lustre.timeout=$timeout"
1030 if [ -z "$CLIENTONLY" ]; then
1031 echo "Setup mdts, osts"
1032 for num in `seq $MDSCOUNT`; do
1033 DEVNAME=$(mdsdevname $num)
1034 echo $REFORMAT | grep -q "reformat" \
1035 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1036 set_obd_timeout mds$num $TIMEOUT
1037 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1038 if [ $IDENTITY_UPCALL != "default" ]; then
1039 switch_identity $num $IDENTITY_UPCALL
1042 for num in `seq $OSTCOUNT`; do
1043 DEVNAME=$(ostdevname $num)
1044 set_obd_timeout ost$num $TIMEOUT
1045 start ost$num $DEVNAME $OST_MOUNT_OPTS
1048 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1050 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1052 if [ "$MOUNT_2" ]; then
1053 mount_client $MOUNT2
1054 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1057 # by remounting mdt before ost, initial connect from mdt to ost might
1058 # timeout because ost is not ready yet. wait some time to its fully
1059 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1060 # by a context negotiation rpc with $TIMEOUT.
1061 # FIXME better by monitoring import status.
1063 sleep $((TIMEOUT + 5))
1069 mounted_lustre_filesystems() {
1070 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1073 check_and_setup_lustre() {
1074 MOUNTED="`mounted_lustre_filesystems`"
1075 if [ -z "$MOUNTED" ]; then
1076 [ "$REFORMAT" ] && formatall
1078 MOUNTED="`mounted_lustre_filesystems`"
1079 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1080 export I_MOUNTED=yes
1082 if [ "$ONLY" == "setup" ]; then
1087 cleanup_and_setup_lustre() {
1088 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1089 sysctl -w lnet.debug=0 || true
1091 if [ "$ONLY" == "cleanup" ]; then
1095 check_and_setup_lustre
1098 check_and_cleanup_lustre() {
1099 if [ "`mount | grep $MOUNT`" ]; then
1100 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1102 if [ "$I_MOUNTED" = "yes" ]; then
1103 cleanupall -f || error "cleanup failed"
1115 while [ $NETWORK -eq 0 ]; do
1116 ping -c 1 -w 3 $1 > /dev/null
1117 if [ $? -eq 0 ]; then
1121 echo "waiting for $1, $((MAX - WAIT)) secs left"
1124 if [ $WAIT -gt $MAX ]; then
1125 echo "Network not available"
1131 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1142 # the sed converts spaces to commas, but leaves the last space
1143 # alone, so the line doesn't end with a comma.
1144 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1148 (cd `dirname $1`; echo $PWD/`basename $1`)
1151 ##################################
1155 # OBD_FAIL_MDS_ALL_REQUEST_NET
1157 do_facet mds sysctl -w lustre.fail_loc=0x123
1158 do_facet client "$1" || RC=$?
1159 do_facet mds sysctl -w lustre.fail_loc=0
1164 # OBD_FAIL_MDS_ALL_REPLY_NET
1166 do_facet mds sysctl -w lustre.fail_loc=0x122
1167 do_facet client "$@" || RC=$?
1168 do_facet mds sysctl -w lustre.fail_loc=0
1172 drop_reint_reply() {
1173 # OBD_FAIL_MDS_REINT_NET_REP
1175 do_facet mds sysctl -w lustre.fail_loc=0x119
1176 do_facet client "$@" || RC=$?
1177 do_facet mds sysctl -w lustre.fail_loc=0
1182 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1184 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1185 do_facet client "$1" || RC=$?
1186 do_facet client "sync"
1187 do_facet ost1 sysctl -w lustre.fail_loc=0
1191 drop_ldlm_cancel() {
1192 #define OBD_FAIL_LDLM_CANCEL 0x304
1194 do_facet client sysctl -w lustre.fail_loc=0x304
1195 do_facet client "$@" || RC=$?
1196 do_facet client sysctl -w lustre.fail_loc=0
1200 drop_bl_callback() {
1201 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1203 do_facet client sysctl -w lustre.fail_loc=0x305
1204 do_facet client "$@" || RC=$?
1205 do_facet client sysctl -w lustre.fail_loc=0
1210 #define OBD_FAIL_LDLM_REPLY 0x30c
1212 do_facet mds sysctl -w lustre.fail_loc=0x30c
1213 do_facet client "$@" || RC=$?
1214 do_facet mds sysctl -w lustre.fail_loc=0
1222 echo "clearing fail_loc on $facet"
1223 do_facet $facet "sysctl -e -w lustre.fail_loc=0"
1226 set_nodes_failloc () {
1230 for node in $nodes ; do
1231 do_node $node sysctl -w lustre.fail_loc=$2
1235 cancel_lru_locks() {
1236 $LCTL mark "cancel_lru_locks $1 start"
1237 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1238 [ -f $d/lru_size ] && echo clear > $d/lru_size
1239 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1241 $LCTL mark "cancel_lru_locks $1 stop"
1246 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1247 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1248 echo "$DEFAULT_LRU_SIZE"
1254 test "x$NS" = "x" && NS="mdc"
1255 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1257 log "Enable lru resize for $(basename $D)"
1262 lru_resize_disable()
1265 test "x$NS" = "x" && NS="mdc"
1266 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1268 log "Disable lru resize for $(basename $D)"
1269 DEFAULT_LRU_SIZE=$(default_lru_size)
1270 echo "$DEFAULT_LRU_SIZE" > $F
1275 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1276 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1277 echo there is still data in page cache $a ?
1286 DEBUGSAVE="$(sysctl -n lnet.debug)"
1290 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1294 ##################################
1296 ##################################
1299 local TYPE=${TYPE:-"FAIL"}
1301 sysctl -e -w lustre.fail_loc=0 || true
1302 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1303 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1304 echo "Dumping lctl log to $ERRLOG"
1305 # We need to dump the logs on all nodes
1306 local NODES=$(nodes_list)
1307 for NODE in $NODES; do
1308 do_node $NODE $LCTL dk $ERRLOG
1311 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1316 $FAIL_ON_ERROR && exit 1 || true
1324 # use only if we are ignoring failures for this test, bugno required.
1325 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1326 # e.g. error_ignore 5494 "your message"
1328 TYPE="IGNORE (bz$1)"
1334 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1335 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1338 build_test_filter() {
1339 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1343 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1344 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1345 [ "$EXCEPT_SLOW" ] && \
1346 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1347 for E in $EXCEPT $ALWAYS_EXCEPT; do
1348 eval EXCEPT_${E}=true
1350 for E in $EXCEPT_SLOW; do
1351 eval EXCEPT_SLOW_${E}=true
1353 for G in $GRANT_CHECK_LIST; do
1354 eval GCHECK_ONLY_${G}=true
1363 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1367 export base=`basetest $1`
1368 if [ ! -z "$ONLY" ]; then
1370 if [ ${!testname}x != x ]; then
1375 if [ ${!testname}x != x ]; then
1383 if [ ${!testname}x != x ]; then
1384 TESTNAME=test_$1 skip "skipping excluded test $1"
1387 testname=EXCEPT_$base
1388 if [ ${!testname}x != x ]; then
1389 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1392 testname=EXCEPT_SLOW_$1
1393 if [ ${!testname}x != x ]; then
1394 TESTNAME=test_$1 skip "skipping SLOW test $1"
1397 testname=EXCEPT_SLOW_$base
1398 if [ ${!testname}x != x ]; then
1399 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1408 EQUALS="======================================================================"
1412 local suffixlen=$((${#EQUALS} - ${#msg}))
1413 [ $suffixlen -lt 5 ] && suffixlen=5
1414 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1419 lsmod | grep lnet > /dev/null || load_modules
1430 local NODES=$(nodes_list)
1431 for NODE in $NODES; do
1432 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1438 strace -o $TMP/$1.strace -ttt $*
1440 log "FINISHED: $*: rc $RC"
1449 FFREE=`cat /proc/fs/lustre/osd/*MDT*/filesfree`
1450 FTOTAL=`cat /proc/fs/lustre/osd/*MDT*/filestotal`
1451 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1455 local myNODES=$(nodes_list)
1458 for NODE in $myNODES; do
1459 do_node $NODE sysctl -e -w lustre.fail_loc=0 || true
1467 export tdir=d0.${TESTSUITE}/d${base}
1468 local SAVE_UMASK=`umask`
1473 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1475 export TESTNAME=test_$testnum
1476 test_${testnum} || error "test_$testnum failed with $?"
1479 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1480 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1481 error "LBUG/LASSERT detected"
1482 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1483 pass "($((`date +%s` - $BEFORE))s)"
1484 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1493 (cd `dirname $1`; echo $PWD/`basename $1`)
1497 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1498 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1503 export base=`basetest $1`
1504 [ "$CHECK_GRANT" == "no" ] && return 0
1506 testname=GCHECK_ONLY_${base}
1507 [ ${!testname}x == x ] && return 0
1509 echo -n "checking grant......"
1511 # write some data to sync client lost_grant
1512 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1513 for i in `seq $OSTCOUNT`; do
1514 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1515 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1516 count=1 > /dev/null 2>&1
1518 # sync all the data and make sure no pending data on server
1521 #get client grant and server grant
1523 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1524 client_grant=$((client_grant + `cat $d`))
1527 for d in ${LPROC}/obdfilter/*/tot_granted; do
1528 server_grant=$((server_grant + `cat $d`))
1531 # cleanup the check_grant file
1532 for i in `seq $OSTCOUNT`; do
1533 rm $DIR1/${tfile}_check_grant_$i
1536 #check whether client grant == server grant
1537 if [ $client_grant != $server_grant ]; then
1538 echo "failed: client:${client_grant} server: ${server_grant}"
1545 ########################
1551 ost=`echo $1 | awk -F_ '{print $3}'`
1552 if [ -z $ost ]; then
1553 ost=`echo $1 | sed 's/-osc.*//'`
1560 [ -z "$(lctl dl | grep mdt)" ]
1565 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1570 [ -z "$(lctl dl | grep ost)" ]
1575 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1579 local MDSNODES=$(facet_host $SINGLEMDS)
1582 # FIXME: Currenly we use only $SINGLEMDS,
1583 # should be fixed when we will start to test cmd.
1587 for num in `seq $MDSCOUNT`; do
1588 local myMDS=$(facet_host mds$num)
1589 MDSNODES="$MDSNODES $myMDS"
1591 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1597 local OSTNODES=$(facet_host ost1)
1600 for num in `seq $OSTCOUNT`; do
1601 local myOST=$(facet_host ost$num)
1602 OSTNODES="$OSTNODES $myOST"
1604 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1610 # FIXME. We need a list of clients
1611 local myNODES=$HOSTNAME
1614 # CLIENTS (if specified) contains the local client
1615 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1617 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1618 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1621 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1628 lctl get_param version | grep -q patchless
1631 check_runas_id_ret() {
1636 if [ -z "$myRUNAS" ]; then
1637 error_exit "myRUNAS command must be specified for check_runas_id"
1640 $myRUNAS krb5_login.sh || \
1641 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1643 mkdir $DIR/d0_runas_test
1645 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1646 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1647 rm -rf $DIR/d0_runas_test
1655 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1656 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1657 Please set RUNAS_ID to some UID which exists on MDS and client or
1658 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1661 # Run multiop in the background, but wait for it to print
1662 # "PAUSING" to its stdout before returning from this function.
1663 multiop_bg_pause() {
1664 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1668 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1671 echo "$MULTIOP_PROG $FILE v$ARGS"
1672 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1674 echo "TMPPIPE=${TMPPIPE}"
1675 read -t 60 multiop_output < $TMPPIPE
1676 if [ $? -ne 0 ]; then
1681 if [ "$multiop_output" != "PAUSING" ]; then
1682 echo "Incorrect multiop output: $multiop_output"
1690 # reset llite stat counters
1691 clear_llite_stats(){
1692 lctl set_param -n llite.*.stats 0
1695 # sum llite stat items
1696 calc_llite_stats() {
1697 local res=$(lctl get_param -n llite.*.stats |
1698 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1702 # save_lustre_params(node, parameter_mask)
1703 # generate a stream of formatted strings (<node> <param name>=<param value>)
1704 save_lustre_params() {
1706 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1709 # restore lustre parameters from input stream, produces by save_lustre_params
1710 restore_lustre_params() {
1714 while IFS=" =" read node name val; do
1715 do_node $node "lctl set_param -n $name $val"