2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
25 if [ -z "${!name}" ]; then
26 echo "$0: $name must be set"
30 [ $failed ] && exit 1 || true
35 [[ $DIR/ = $MOUNT/* ]] || \
36 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
37 [[ $DIR1/ = $MOUNT1/* ]] || \
38 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
39 [[ $DIR2/ = $MOUNT2/* ]] || \
40 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
42 [ -n "$failed" ] && exit 99 || true
46 echo "usage: $0 [-r] [-f cfgfile]"
53 [ "$TESTSUITE" == "lfscktest" ] && return 0
54 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
55 local form="%-13s %-17s %s\n"
56 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
57 echo "------------------------------------------------------------------------------------"
58 for O in $TESTSUITE_LIST; do
61 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
64 local log=${TMP}/${o}.log
65 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
66 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
67 [ "${!O}" = "done" ] && \
68 printf "$form" "Done" "$O" "E=$skipped" && \
69 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
73 for O in $TESTSUITE_LIST; do
74 [ "${!O}" = "no" ] && \
75 printf "$form" "Skipped" "$O" ""
78 for O in $TESTSUITE_LIST; do
79 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
80 printf "$form" "UNFINISHED" "$O" ""
85 export LUSTRE=`absolute_path $LUSTRE`
86 export TESTSUITE=`basename $0 .sh`
87 export TEST_FAILED=false
89 export MKE2FS=${MKE2FS:-mke2fs}
90 export DEBUGFS=${DEBUGFS:-debugfs}
91 export TUNE2FS=${TUNE2FS:-tune2fs}
92 export E2LABEL=${E2LABEL:-e2label}
93 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
94 export E2FSCK=${E2FSCK:-e2fsck}
96 #[ -d /r ] && export ROOT=${ROOT:-/r}
97 export TMP=${TMP:-$ROOT/tmp}
98 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
99 export HOSTNAME=${HOSTNAME:-`hostname`}
100 if ! echo $PATH | grep -q $LUSTRE/utils; then
101 export PATH=$PATH:$LUSTRE/utils
103 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
104 export PATH=$PATH:$LUSTRE/utils/gss
106 if ! echo $PATH | grep -q $LUSTRE/tests; then
107 export PATH=$PATH:$LUSTRE/tests
109 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
110 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
111 if ! echo $PATH | grep -q $LUSTRE/test/racer; then
112 export PATH=$PATH:$LUSTRE/tests/racer
114 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
115 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
116 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
117 [ ! -f "$LFS" ] && export LFS=$(which lfs)
118 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
119 if [ ! -f "$L_GETIDENTITY" ]; then
120 if `which l_getidentity > /dev/null 2>&1`; then
121 export L_GETIDENTITY=$(which l_getidentity)
123 export L_GETIDENTITY=NONE
126 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
127 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
128 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
129 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
130 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
131 export FSTYPE=${FSTYPE:-"ldiskfs"}
132 export NAME=${NAME:-local}
133 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
134 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
135 export LGSSD=$(which lgssd)
136 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
137 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
138 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
140 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
143 if [ "$ACCEPTOR_PORT" ]; then
144 export PORT_OPT="--port $ACCEPTOR_PORT"
149 echo "Using GSS/krb5 ptlrpc security flavor"
150 which lgss_keyring > /dev/null 2>&1 || \
151 error "built with gss disabled! SEC=$SEC"
162 IDENTITY_UPCALL=false
166 # Paths on remote nodes, if different
167 export RLUSTRE=${RLUSTRE:-$LUSTRE}
168 export RPWD=${RPWD:-$PWD}
169 export I_MOUNTED=${I_MOUNTED:-"no"}
173 while getopts "rvwf:" opt $*; do
176 r) REFORMAT=--reformat;;
178 w) WRITECONF=writeconf;;
183 shift $((OPTIND - 1))
186 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
192 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
193 *) EXT=".ko"; USE_QUOTA=yes;;
200 BASE=`basename $module $EXT`
201 lsmod | grep -q ${BASE} || \
202 if [ -f ${LUSTRE}/${module}${EXT} ]; then
203 insmod ${LUSTRE}/${module}${EXT} $@
205 # must be testing a "make install" or "rpm" installation
206 # note failed to load ptlrpc_gss is considered not fatal
207 if [ "$BASE" == "ptlrpc_gss" ]; then
208 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
216 if [ -n "$MODPROBE" ]; then
220 if [ "$HAVE_MODULES" = true ]; then
226 echo Loading modules from $LUSTRE
227 load_module ../libcfs/libcfs/libcfs
228 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
229 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
231 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
232 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
233 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
234 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
235 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
236 echo "lnet options: '$LNETOPTS'"
237 # note that insmod will ignore anything in modprobe.conf
238 load_module ../lnet/lnet/lnet $LNETOPTS
239 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
240 load_module ../lnet/klnds/$LNETLND
241 load_module lvfs/lvfs
242 load_module obdclass/obdclass
243 load_module ptlrpc/ptlrpc
244 load_module ptlrpc/gss/ptlrpc_gss
245 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
253 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
254 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
255 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
260 load_module lvfs/fsfilt_$FSTYPE
264 load_module obdfilter/obdfilter
267 load_module llite/lustre
268 load_module llite/llite_lloop
269 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
271 rm -f $OGDB/ogdb-$HOSTNAME
272 $LCTL modules > $OGDB/ogdb-$HOSTNAME
274 # 'mount' doesn't look in $PATH, just sbin
275 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
279 if [ `uname -r | cut -c 3` -eq 4 ]; then
287 MODULES=$($LCTL modules | awk '{ print $2 }')
288 while [ -n "$MODULES" ]; do
290 $RMMOD $MODULES > /dev/null 2>&1 || true
291 MODULES=$($LCTL modules | awk '{ print $2 }')
292 if [ -z "$MODULES" ]; then
296 echo "waiting, $((MAX - WAIT)) secs left"
298 if [ $WAIT -eq $MAX ]; then
299 echo "LNET modules $MODULES will not unload"
306 unload_dep_module() {
308 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
310 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
311 for SUBMOD in $DEPS; do
312 unload_dep_module $SUBMOD
314 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
315 $RMMOD $MODULE || true
319 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
320 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
321 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
322 echo "$LEAK_LUSTRE" 1>&2
323 echo "$LEAK_PORTALS" 1>&2
324 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
325 echo "Memory leaks detected"
326 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
332 wait_exit_ST client # bug 12845
334 lsmod | grep libcfs > /dev/null && $LCTL dl
335 unload_dep_module $FSTYPE
336 unload_dep_module libcfs
338 local MODULES=$($LCTL modules | awk '{ print $2 }')
339 if [ -n "$MODULES" ]; then
340 echo "Modules still loaded: "
342 if [ "$(lctl dl)" ]; then
343 echo "Lustre still loaded"
348 echo "Lustre stopped but LNET is still loaded, waiting..."
349 wait_for_lnet || return 3
355 check_mem_leak || return 254
357 echo "modules unloaded."
361 check_gss_daemon_facet() {
365 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
366 if [ $num -ne 1 ]; then
367 echo "$num instance of $dname on $facet"
376 do_facet $facet "killall -2 $@ 2>/dev/null || true"
379 start_gss_daemons() {
381 for num in `seq $MDSCOUNT`; do
382 do_facet mds$num "$LSVCGSSD -v"
384 do_facet mds$num "$LGSSD -v"
388 for num in `seq $OSTCOUNT`; do
389 do_facet ost$num "$LSVCGSSD -v"
392 # FIXME: is "client" the right facet name?
394 do_facet client "$LGSSD -v"
397 # wait daemons entering "stable" status
401 # check daemons are running
403 for num in `seq $MDSCOUNT`; do
404 check_gss_daemon_facet mds$num lsvcgssd
406 check_gss_daemon_facet mds$num lgssd
409 for num in `seq $OSTCOUNT`; do
410 check_gss_daemon_facet ost$num lsvcgssd
413 check_gss_daemon_facet client lgssd
418 for num in `seq $MDSCOUNT`; do
419 send_sigint mds$num lsvcgssd lgssd
421 for num in `seq $OSTCOUNT`; do
422 send_sigint ost$num lsvcgssd
424 send_sigint client lgssd
431 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
432 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
440 # maybe cleanup credential cache?
446 local device=`mdsdevname $num`
447 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
453 local device=`ostdevname $num`
454 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
462 local dev=${facet}_dev
463 local opt=${facet}_opt
464 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
465 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
467 if [ $RC -ne 0 ]; then
468 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
469 echo "Start of ${!dev} on ${facet} failed ${RC}"
471 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
472 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
473 lctl set_param debug_mb=${DEBUG_SIZE}; \
476 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
477 [ -z "$label" ] && echo no label for ${!dev} && exit 1
478 eval export ${facet}_svc=${label}
479 echo Started ${label}
484 # start facet device options
490 eval export ${facet}_dev=${device}
491 eval export ${facet}_opt=\"$@\"
492 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
502 HOST=`facet_active_host $facet`
503 [ -z $HOST ] && echo stop: no host for $facet && return 0
505 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
506 if [ ${running} -ne 0 ]; then
507 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
508 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
511 # umount should block, but we should wait for unrelated obd's
512 # like the MGS or MGC to also stop.
513 wait_exit_ST ${facet}
520 # Only supply -o to mount if we have options
521 if [ -n "$MOUNTOPT" ]; then
522 OPTIONS="-o $MOUNTOPT"
524 local device=$MGSNID:/$FSNAME
525 if [ -z "$mnt" -o -z "$FSNAME" ]; then
526 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
530 echo "Starting client: $client: $OPTIONS $device $mnt"
531 do_node $client mkdir -p $mnt
532 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
534 do_node $client "lctl set_param debug=$PTLDEBUG;
535 lctl set_param subsystem_debug=${SUBSYSTEM# };
536 lctl set_param debug_mb=${DEBUG_SIZE}"
549 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
550 if [ $running -ne 0 ]; then
551 echo "Stopping client $client $mnt (opts:$force)"
552 do_node $client lsof -t $mnt || need_kill=no
553 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
554 pids=$(do_node $client lsof -t $mnt | sort -u);
555 if [ -n $pids ]; then
556 do_node $client kill -9 $pids || true
560 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
561 if [ $busy -ne 0 ] ; then
562 echo "$mnt is still busy, wait one second" && sleep 1
563 do_node $client umount $force $mnt
568 # mount clients if not mouted
569 zconf_mount_clients() {
575 # Only supply -o to mount if we have options
576 if [ -n "$MOUNTOPT" ]; then
577 OPTIONS="-o $MOUNTOPT"
579 local device=$MGSNID:/$FSNAME
580 if [ -z "$mnt" -o -z "$FSNAME" ]; then
581 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
585 echo "Starting client $clients: $OPTIONS $device $mnt"
586 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
588 echo "Started clients $clients: "
589 do_nodes $clients "mount | grep $mnt"
591 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
592 lctl set_param subsystem_debug=${SUBSYSTEM# };
593 lctl set_param debug_mb=${DEBUG_SIZE};"
598 zconf_umount_clients() {
605 echo "Stopping clients: $clients $mnt (opts:$force)"
606 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts)
607 if [ \\\$running -ne 0 ] ; then
608 echo Stopping client \\\$(hostname) client $mnt opts:$force
609 lsof -t $mnt || need_kill=no
610 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
611 pids=\\\$(lsof -t $mnt | sort -u);
612 if [ -n \\\$pids ]; then
616 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy")
617 if [ \\\$busy -ne 0 ] ; then
618 echo "$mnt is still busy, wait one second" && sleep 1
626 if [ "$FAILURE_MODE" = HARD ]; then
627 $POWER_DOWN `facet_active_host $facet`
629 elif [ "$FAILURE_MODE" = SOFT ]; then
636 if [ "$FAILURE_MODE" = HARD ]; then
637 $POWER_UP `facet_active_host $facet`
645 if [ "$FAILURE_MODE" = HARD ]; then
650 # recovery-scale functions
651 check_progs_installed () {
656 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
657 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
662 start_client_load() {
663 local list=(${1//,/ })
666 local numloads=${#CLIENT_LOADS[@]}
667 local testnum=$((nodenum % numloads))
669 do_node ${list[nodenum]} "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
670 BREAK_ON_ERROR=$BREAK_ON_ERROR \
671 END_RUN_FILE=$END_RUN_FILE \
672 LOAD_PID_FILE=$LOAD_PID_FILE \
673 TESTSUITELOG=$TESTSUITELOG \
674 run_${CLIENT_LOADS[testnum]}.sh" &
675 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
676 log "Started client load: ${CLIENT_LOADS[testnum]} on ${list[nodenum]}"
678 eval export ${list[nodenum]}_load=${CLIENT_LOADS[testnum]}
682 start_client_loads () {
683 local clients=(${1//,/ })
685 for ((num=0; num < ${#clients[@]}; num++ )); do
686 start_client_load $1 $num
690 # only for remote client
691 check_client_load () {
693 local var=${client}_load
695 local TESTLOAD=run_${!var}.sh
697 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
699 check_catastrophe $client || return 2
701 # see if the load is still on the client
704 while [ $RC = 254 -a $tries -gt 0 ]; do
708 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
713 if [ $RC = 254 ]; then
714 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
715 # see if we can diagnose a bit why this is
720 check_client_loads () {
721 local clients=${1//,/ }
725 for client in $clients; do
726 check_client_load $client
728 if [ "$rc" != 0 ]; then
729 log "Client load failed on node $client, rc=$rc"
734 # End recovery-scale functions
736 # verify that lustre actually cleaned up properly
738 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
739 error "LBUG/LASSERT detected"
740 BUSY=`dmesg | grep -i destruct || true`
743 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
747 check_mem_leak || exit 204
749 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
750 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
752 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
753 echo "$0: modules still loaded..." 1>&2
760 wait_delete_completed () {
761 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
762 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
766 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
768 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
769 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
770 [ "$TOTAL" -eq "$TOTALPREV" ] && break
771 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
775 echo "Delete completed."
780 check_network "$HOST" 900
781 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
786 HOST=`facet_active_host $facet`
790 wait_mds_recovery_done () {
791 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
792 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
793 # as we are in process of changing obd_timeout in different ways
794 # let's set MAX longer than that
795 MAX=$(( timeout * 4 ))
797 while [ $WAIT -lt $MAX ]; do
798 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
799 echo $STATUS | grep COMPLETE && return 0
802 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
804 echo "MDS recovery not done in $MAX sec"
814 # conf-sanity 31 takes a long time cleanup
815 while [ $WAIT -lt 300 ]; do
816 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
817 [ -z "${running}" ] && return 0
818 echo "waited $WAIT for${running}"
819 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
821 WAIT=$((WAIT + INTERVAL))
823 echo "service didn't stop after $WAIT seconds. Still running:"
828 wait_remote_prog () {
834 [ "$PDSH" = "no_dsh" ] && return 0
836 while [ $WAIT -lt $2 ]; do
837 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
838 [ -z "${running}" ] && return 0 || true
839 echo "waited $WAIT for: "
841 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
843 WAIT=$((WAIT + INTERVAL))
845 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
846 [ -z "$pids" ] && return 0
847 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
849 cat /proc/${pid}/status || true
850 cat /proc/${pid}/wchan || true
861 # not every config has many clients
862 if [ ! -z "$CLIENTS" ]; then
863 $PDSH $CLIENTS "df $MOUNT" > /dev/null
865 df $MOUNT > /dev/null
870 uname -n >> $MOUNT/recon
871 if [ -z "$CLIENTS" ]; then
872 df $MOUNT; uname -n >> $MOUNT/recon
874 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
876 echo Connected clients:
878 ls -l $MOUNT/recon > /dev/null
885 echo "Failing $facet on node `facet_active_host $facet`"
886 shutdown_facet $facet
887 [ -n "$sleep_time" ] && sleep $sleep_time
891 echo "df pid is $DFPID"
893 TO=`facet_active_host $facet`
894 echo "Failover $facet to $TO"
896 mount_facet $facet || error "Restart of $facet failed"
907 local svc=${facet}_svc
908 do_facet $facet $LCTL --device %${!svc} readonly
909 do_facet $facet $LCTL --device %${!svc} notransno
910 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
911 $LCTL mark "local REPLAY BARRIER on ${!svc}"
914 replay_barrier_nodf() {
915 local facet=$1 echo running=${running}
917 local svc=${facet}_svc
918 echo Replay barrier on ${!svc}
919 do_facet $facet $LCTL --device %${!svc} readonly
920 do_facet $facet $LCTL --device %${!svc} notransno
921 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
922 $LCTL mark "local REPLAY BARRIER on ${!svc}"
925 replay_barrier_nosync() {
926 local facet=$1 echo running=${running}
927 local svc=${facet}_svc
928 echo Replay barrier on ${!svc}
929 do_facet $facet $LCTL --device %${!svc} readonly
930 do_facet $facet $LCTL --device %${!svc} notransno
931 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
932 $LCTL mark "local REPLAY BARRIER on ${!svc}"
936 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
937 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
941 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
942 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
946 facet_failover $* || error "failover: $?"
947 df $MOUNT || error "post-failover df: $?"
952 facet_failover $facet
959 mount_facet $facet -o abort_recovery
960 df $MOUNT || echo "first df failed: $?"
962 df $MOUNT || error "post-failover df: $?"
966 echo There is no lmc. This is mountconf, baby.
971 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
972 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
978 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
984 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
985 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
986 if [ -z "$ID" ]; then
987 echo "Could not get a ptl id for $1..."
996 h2name_or_ip "$1" "tcp"
1001 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1002 if type __h2elan >/dev/null 2>&1; then
1005 ID=`echo $1 | sed 's/[^0-9]*//g'`
1013 h2name_or_ip "$1" "openib"
1015 declare -fx h2openib
1018 h2name_or_ip "$1" "o2ib"
1025 [ "$facet" == client ] && echo -n $HOSTNAME && return
1026 varname=${facet}_HOST
1027 if [ -z "${!varname}" ]; then
1028 if [ "${facet:0:3}" == "ost" ]; then
1029 eval ${facet}_HOST=${ost_HOST}
1037 local activevar=${facet}active
1039 if [ -f $TMP/${facet}active ] ; then
1040 source $TMP/${facet}active
1043 active=${!activevar}
1044 if [ -z "$active" ] ; then
1051 facet_active_host() {
1053 local active=`facet_active $facet`
1054 if [ "$facet" == client ]; then
1057 echo `facet_host $active`
1063 failover=${facet}failover
1064 host=`facet_host $failover`
1065 [ -z "$host" ] && return
1066 curactive=`facet_active $facet`
1067 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1068 eval export ${facet}active=$facet
1070 eval export ${facet}active=$failover
1072 # save the active host for this facet
1073 activevar=${facet}active
1074 echo "$activevar=${!activevar}" > $TMP/$activevar
1081 if [ "$HOST" = "$HOSTNAME" ]; then
1083 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1084 echo "cannot run remote command on $HOST with $myPDSH"
1088 echo "CMD: $HOST $@" >&2
1089 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1092 if [ "$myPDSH" = "rsh" ]; then
1093 # we need this because rsh does not return exit code of an executed command
1094 local command_status="$TMP/cs"
1095 rsh $HOST ":> $command_status"
1096 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1097 cd $RPWD; sh -c \"$@\") ||
1098 echo command failed >$command_status"
1099 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1102 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1103 return ${PIPESTATUS[0]}
1106 single_local_node () {
1107 [ "$1" = "$HOSTNAME" ]
1114 if $(single_local_node $rnodes); then
1119 # This is part from do_node
1122 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1123 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1126 echo "CMD: $rnodes $@" >&2
1127 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1130 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1131 return ${PIPESTATUS[0]}
1137 HOST=`facet_active_host $facet`
1138 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1145 # make sure its not already running
1147 rm -f $TMP/${facet}active
1148 do_facet ${facet} $MKFS $*
1154 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1155 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1162 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1163 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1171 # make sure we are using the primary server, so test-framework will
1172 # be able to clean up properly.
1173 activemds=`facet_active mds1`
1174 if [ $activemds != "mds1" ]; then
1178 # assume client mount is local
1179 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1180 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1182 if [ -n "$CLIENTS" ]; then
1183 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1184 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1187 [ "$CLIENTONLY" ] && return
1188 # The add fn does rm ${facet}active file, this would be enough
1189 # if we use do_facet <facet> only after the facet added, but
1190 # currently we use do_facet mds in local.sh
1191 for num in `seq $MDSCOUNT`; do
1193 rm -f ${TMP}/mds${num}active
1196 for num in `seq $OSTCOUNT`; do
1198 rm -f $TMP/ost${num}active
1213 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1217 if [ "$IAMDIR" == "yes" ]; then
1218 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1219 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1222 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1224 if [ ! -z $SEC ]; then
1225 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1226 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1227 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1231 # We need ldiskfs here, may as well load them all
1233 [ "$CLIENTONLY" ] && return
1234 echo "Formatting mdts, osts"
1235 for num in `seq $MDSCOUNT`; do
1236 echo "Format mds$num: $(mdsdevname $num)"
1238 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1240 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1244 for num in `seq $OSTCOUNT`; do
1245 echo "Format ost$num: $(ostdevname $num)"
1247 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1249 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1255 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1259 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1263 # 0: success, the old identity set already.
1264 # 1: success, the old identity does not set.
1269 local j=`expr $num - 1`
1270 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1272 if [ -z "$MDT" ]; then
1276 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1279 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1281 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1284 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1286 if [ $old = "NONE" ]; then
1295 zconf_umount `hostname` $1 || error "umount failed"
1296 zconf_mount `hostname` $1 || error "mount failed"
1303 do_facet $facet lsmod | grep -q obdclass || \
1304 do_facet $facet "modprobe obdclass"
1306 do_facet $facet "lctl set_param timeout=$timeout"
1309 writeconf_facet () {
1313 do_facet $facet "$TUNEFS --writeconf $dev"
1317 for num in `seq $MDSCOUNT`; do
1318 DEVNAME=$(mdsdevname $num)
1319 writeconf_facet mds$num $DEVNAME
1322 for num in `seq $OSTCOUNT`; do
1323 DEVNAME=$(ostdevname $num)
1324 writeconf_facet ost$num $DEVNAME
1331 if [ -z "$CLIENTONLY" ]; then
1332 echo "Setup mdts, osts"
1333 echo $WRITECONF | grep -q "writeconf" && \
1335 for num in `seq $MDSCOUNT`; do
1336 DEVNAME=$(mdsdevname $num)
1337 set_obd_timeout mds$num $TIMEOUT
1338 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1340 # We started mds, now we should set failover variables properly.
1341 # Set mds${num}failover_HOST if it is not set (the default failnode).
1342 local varname=mds${num}failover_HOST
1343 if [ -z "${!varname}" ]; then
1344 eval mds${num}failover_HOST=$(facet_host mds$num)
1347 if [ $IDENTITY_UPCALL != "default" ]; then
1348 switch_identity $num $IDENTITY_UPCALL
1351 for num in `seq $OSTCOUNT`; do
1352 DEVNAME=$(ostdevname $num)
1353 set_obd_timeout ost$num $TIMEOUT
1354 start ost$num $DEVNAME $OST_MOUNT_OPTS
1356 # We started ost$num, now we should set ost${num}failover variable properly.
1357 # Set ost${num}failover_HOST if it is not set (the default failnode).
1358 varname=ost${num}failover_HOST
1359 if [ -z "${!varname}" ]; then
1360 eval ost${num}failover_HOST=$(facet_host ost${num})
1365 # wait a while to allow sptlrpc configuration be propogated to targets,
1366 # only needed when mounting new target devices.
1369 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1371 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1373 if [ "$MOUNT_2" ]; then
1374 mount_client $MOUNT2
1375 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1380 # by remounting mdt before ost, initial connect from mdt to ost might
1381 # timeout because ost is not ready yet. wait some time to its fully
1382 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1383 # by a context negotiation rpc with $TIMEOUT.
1384 # FIXME better by monitoring import status.
1386 sleep $((TIMEOUT + 5))
1392 mounted_lustre_filesystems() {
1393 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1396 init_facet_vars () {
1403 eval export ${facet}_dev=${device}
1404 eval export ${facet}_opt=\"$@\"
1406 local dev=${facet}_dev
1407 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1408 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1410 eval export ${facet}_svc=${label}
1412 local varname=${facet}failover_HOST
1413 if [ -z "${!varname}" ]; then
1414 eval $varname=$(facet_host $facet)
1418 init_facets_vars () {
1421 for num in `seq $MDSCOUNT`; do
1422 DEVNAME=`mdsdevname $num`
1423 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1426 for num in `seq $OSTCOUNT`; do
1427 DEVNAME=`ostdevname $num`
1428 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1432 init_versions_vars () {
1433 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1434 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1435 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1440 local myMGS_host=$mgs_HOST
1441 if [ "$NETTYPE" = "ptl" ]; then
1442 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1445 echo Checking config lustre mounted on $mntpt
1446 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1447 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1449 if [ "$mgshost" != "$myMGS_host" ]; then
1450 FAIL_ON_ERROR=true \
1451 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1452 Please use correct config or set mds_HOST correctly!"
1456 check_and_setup_lustre() {
1457 local MOUNTED=$(mounted_lustre_filesystems)
1458 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1459 [ "$REFORMAT" ] && formatall
1461 MOUNTED=$(mounted_lustre_filesystems | head -1)
1462 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1463 export I_MOUNTED=yes
1469 if [ "$ONLY" == "setup" ]; then
1474 cleanup_and_setup_lustre() {
1475 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1476 lctl set_param debug=0 || true
1478 if [ "$ONLY" == "cleanup" ]; then
1482 check_and_setup_lustre
1485 check_and_cleanup_lustre() {
1486 if [ "`mount | grep $MOUNT`" ]; then
1487 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1489 if [ "$I_MOUNTED" = "yes" ]; then
1490 cleanupall -f || error "cleanup failed"
1502 while [ $NETWORK -eq 0 ]; do
1503 ping -c 1 -w 3 $1 > /dev/null
1504 if [ $? -eq 0 ]; then
1508 echo "waiting for $1, $((MAX - WAIT)) secs left"
1511 if [ $WAIT -gt $MAX ]; then
1512 echo "Network not available"
1518 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1529 # the sed converts spaces to commas, but leaves the last space
1530 # alone, so the line doesn't end with a comma.
1531 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1534 # list is comma separated list
1535 exclude_item_from_list () {
1540 list=$(echo " $list " | sed -re "s/\s+$excluded\s+/ /g")
1541 echo $(comma_list $list)
1545 (cd `dirname $1`; echo $PWD/`basename $1`)
1548 ##################################
1549 # Adaptive Timeouts funcs
1552 if [ -z "$AT_MAX_PATH" ]; then
1553 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1554 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1560 at_is_valid || error "invalid call"
1562 # only check mds, we assume at_max is the same on all nodes
1563 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1564 if [ $at_max -eq 0 ]; then
1574 at_is_valid || error "invalid call"
1576 # suppose that all ost-s has the same at_max set
1577 if [ $facet == "ost" ]; then
1578 do_facet ost1 "cat $AT_MAX_PATH"
1580 do_facet $facet "cat $AT_MAX_PATH"
1588 at_is_valid || error "invalid call"
1592 if [ $facet == "ost" ]; then
1593 for i in `seq $OSTCOUNT`; do
1594 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1596 elif [ $facet == "mds" ]; then
1597 for i in `seq $MDSCOUNT`; do
1598 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1601 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1606 ##################################
1610 # OBD_FAIL_MDS_ALL_REQUEST_NET
1612 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1613 do_facet client "$1" || RC=$?
1614 do_facet $SINGLEMDS lctl set_param fail_loc=0
1619 # OBD_FAIL_MDS_ALL_REPLY_NET
1621 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1622 do_facet client "$@" || RC=$?
1623 do_facet $SINGLEMDS lctl set_param fail_loc=0
1627 drop_reint_reply() {
1628 # OBD_FAIL_MDS_REINT_NET_REP
1630 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1631 do_facet client "$@" || RC=$?
1632 do_facet $SINGLEMDS lctl set_param fail_loc=0
1637 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1639 do_facet ost1 lctl set_param fail_loc=0x214
1640 do_facet client "$1" || RC=$?
1641 do_facet client "sync"
1642 do_facet ost1 lctl set_param fail_loc=0
1646 drop_ldlm_cancel() {
1647 #define OBD_FAIL_LDLM_CANCEL 0x304
1649 do_facet client lctl set_param fail_loc=0x304
1650 do_facet client "$@" || RC=$?
1651 do_facet client lctl set_param fail_loc=0
1655 drop_bl_callback() {
1656 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1658 do_facet client lctl set_param fail_loc=0x305
1659 do_facet client "$@" || RC=$?
1660 do_facet client lctl set_param fail_loc=0
1665 #define OBD_FAIL_LDLM_REPLY 0x30c
1667 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1668 do_facet client "$@" || RC=$?
1669 do_facet $SINGLEMDS lctl set_param fail_loc=0
1677 echo "clearing fail_loc on $facet"
1678 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1681 set_nodes_failloc () {
1685 for node in $nodes ; do
1686 do_node $node lctl set_param fail_loc=$2
1690 cancel_lru_locks() {
1691 $LCTL mark "cancel_lru_locks $1 start"
1692 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1693 $LCTL set_param -n $d=clear
1695 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1696 $LCTL mark "cancel_lru_locks $1 stop"
1701 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1702 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1703 echo "$DEFAULT_LRU_SIZE"
1708 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1711 lru_resize_disable()
1713 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1718 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1719 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1720 echo there is still data in page cache $FILE ?
1721 lctl get_param -n $FILE
1729 DEBUGSAVE="$(lctl get_param -n debug)"
1733 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1737 ##################################
1739 ##################################
1742 local TYPE=${TYPE:-"FAIL"}
1744 lctl set_param fail_loc=0 2>/dev/null || true
1745 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1746 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1747 echo "Dumping lctl log to $ERRLOG"
1748 # We need to dump the logs on all nodes
1749 local NODES=$(nodes_list)
1750 for NODE in $NODES; do
1751 do_node $NODE $LCTL dk $ERRLOG
1754 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1760 $FAIL_ON_ERROR && exit 1 || true
1768 # use only if we are ignoring failures for this test, bugno required.
1769 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1770 # e.g. error_ignore 5494 "your message"
1772 local TYPE="IGNORE (bz$1)"
1778 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1779 [ "$TESTSUITELOG" ] && \
1780 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1783 build_test_filter() {
1784 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1788 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1789 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1790 [ "$EXCEPT_SLOW" ] && \
1791 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1792 for E in $EXCEPT $ALWAYS_EXCEPT; do
1793 eval EXCEPT_${E}=true
1795 for E in $EXCEPT_SLOW; do
1796 eval EXCEPT_SLOW_${E}=true
1798 for G in $GRANT_CHECK_LIST; do
1799 eval GCHECK_ONLY_${G}=true
1808 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1811 # print a newline if the last test was skipped
1812 export LAST_SKIPPED=
1816 export base=`basetest $1`
1817 if [ ! -z "$ONLY" ]; then
1819 if [ ${!testname}x != x ]; then
1820 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1825 if [ ${!testname}x != x ]; then
1826 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1835 if [ ${!testname}x != x ]; then
1837 TESTNAME=test_$1 skip "skipping excluded test $1"
1840 testname=EXCEPT_$base
1841 if [ ${!testname}x != x ]; then
1843 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1846 testname=EXCEPT_SLOW_$1
1847 if [ ${!testname}x != x ]; then
1849 TESTNAME=test_$1 skip "skipping SLOW test $1"
1852 testname=EXCEPT_SLOW_$base
1853 if [ ${!testname}x != x ]; then
1855 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1865 EQUALS="======================================================================"
1869 local suffixlen=$((${#EQUALS} - ${#msg}))
1870 [ $suffixlen -lt 5 ] && suffixlen=5
1871 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1876 lsmod | grep lnet > /dev/null || load_modules
1888 local NODES=$(nodes_list)
1889 for NODE in $NODES; do
1890 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1896 strace -o $TMP/$1.strace -ttt $*
1898 log "FINISHED: $*: rc $RC"
1903 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
1908 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1909 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1910 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1914 local myNODES=$(nodes_list)
1917 for NODE in $myNODES; do
1918 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1926 export tdir=d0.${TESTSUITE}/d${base}
1928 local SAVE_UMASK=`umask`
1932 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1934 export TESTNAME=test_$testnum
1936 test_${testnum} || error "test_$testnum failed with $?"
1940 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1941 check_catastrophe || error "LBUG/LASSERT detected"
1942 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1943 pass "($((`date +%s` - $BEFORE))s)"
1951 (cd `dirname $1`; echo $PWD/`basename $1`)
1955 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1956 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1961 export base=`basetest $1`
1962 [ "$CHECK_GRANT" == "no" ] && return 0
1964 testname=GCHECK_ONLY_${base}
1965 [ ${!testname}x == x ] && return 0
1967 echo -n "checking grant......"
1969 # write some data to sync client lost_grant
1970 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1971 for i in `seq $OSTCOUNT`; do
1972 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1973 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1974 count=1 > /dev/null 2>&1
1976 # sync all the data and make sure no pending data on server
1979 #get client grant and server grant
1981 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1982 client_grant=$((client_grant + $d))
1985 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1986 server_grant=$((server_grant + $d))
1989 # cleanup the check_grant file
1990 for i in `seq $OSTCOUNT`; do
1991 rm $DIR1/${tfile}_check_grant_$i
1994 #check whether client grant == server grant
1995 if [ $client_grant != $server_grant ]; then
1996 echo "failed: client:${client_grant} server: ${server_grant}"
2003 ########################
2009 ost=`echo $1 | awk -F_ '{print $3}'`
2010 if [ -z $ost ]; then
2011 ost=`echo $1 | sed 's/-osc.*//'`
2018 [ "$node" != "$(hostname)" ]
2024 for node in $(mdts_nodes); do
2025 remote_node $node && return 0
2032 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2038 for node in $(osts_nodes) ; do
2039 remote_node $node && return 0
2046 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2052 for num in `seq $MDSCOUNT`; do
2053 MDSNODES="$MDSNODES $(facet_host mds$num)"
2055 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2061 remote_ost && remote_mds
2065 local OSTNODES=$(facet_host ost1)
2068 for num in `seq $OSTCOUNT`; do
2069 local myOST=$(facet_host ost$num)
2070 OSTNODES="$OSTNODES $myOST"
2072 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2078 # FIXME. We need a list of clients
2079 local myNODES=$HOSTNAME
2082 # CLIENTS (if specified) contains the local client
2083 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2085 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2086 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2089 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2094 remote_nodes_list () {
2095 local rnodes=$(nodes_list)
2096 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2100 init_clients_lists () {
2101 # Sanity check: exclude the local client from RCLIENTS
2102 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2104 # Sanity check: exclude the dup entries
2105 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2107 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2109 # Sanity check: exclude the dup entries from CLIENTS
2110 # for those configs which has SINGLCLIENT set to local client
2111 clients=$(for i in $clients; do echo $i; done | sort -u)
2113 CLIENTS=`comma_list $clients`
2114 local -a remoteclients=($rclients)
2115 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2116 varname=CLIENT$((i + 2))
2117 eval $varname=${remoteclients[i]}
2120 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2123 get_random_entry () {
2126 rnodes=${rnodes//,/ }
2128 local nodes=($rnodes)
2129 local num=${#nodes[@]}
2130 local i=$((RANDOM * num / 65536))
2137 lctl get_param version | grep -q patchless
2141 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2146 echo $nodes | wc -w || true
2150 local nodes=$(osts_nodes)
2151 local osscount=$(get_node_count "$nodes")
2152 [ ! "$OSTCOUNT" = "$osscount" ]
2156 local nodes=$(mdts_nodes)
2157 local mdtcount=$(get_node_count "$nodes")
2158 [ ! "$MDSCOUNT" = "$mdtcount" ]
2161 generate_machine_file() {
2162 local nodes=${1//,/ }
2163 local machinefile=$2
2164 rm -f $machinefile || error "can't rm $machinefile"
2165 for node in $nodes; do
2166 echo $node >>$machinefile
2171 local file=$1/stripe
2173 $LFS getstripe -v $file || error
2177 check_runas_id_ret() {
2179 local myRUNAS_UID=$1
2180 local myRUNAS_GID=$2
2183 if [ -z "$myRUNAS" ]; then
2184 error_exit "myRUNAS command must be specified for check_runas_id"
2187 $myRUNAS krb5_login.sh || \
2188 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2190 mkdir $DIR/d0_runas_test
2192 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2193 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2194 rm -rf $DIR/d0_runas_test
2199 local myRUNAS_UID=$1
2200 local myRUNAS_GID=$2
2203 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2204 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2205 Please set RUNAS_ID to some UID which exists on MDS and client or
2206 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2209 # Run multiop in the background, but wait for it to print
2210 # "PAUSING" to its stdout before returning from this function.
2211 multiop_bg_pause() {
2212 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2216 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2219 echo "$MULTIOP_PROG $FILE v$ARGS"
2220 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2222 echo "TMPPIPE=${TMPPIPE}"
2223 read -t 60 multiop_output < $TMPPIPE
2224 if [ $? -ne 0 ]; then
2229 if [ "$multiop_output" != "PAUSING" ]; then
2230 echo "Incorrect multiop output: $multiop_output"
2238 inodes_available () {
2239 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2243 # reset llite stat counters
2244 clear_llite_stats(){
2245 lctl set_param -n llite.*.stats 0
2248 # sum llite stat items
2249 calc_llite_stats() {
2250 local res=$(lctl get_param -n llite.*.stats |
2251 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2255 # reset osc stat counters
2257 lctl set_param -n osc.*.osc_stats 0
2260 # sum osc stat items
2262 local res=$(lctl get_param -n osc.*.osc_stats |
2263 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2268 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2271 calc_osc_kbytes () {
2272 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2275 # save_lustre_params(node, parameter_mask)
2276 # generate a stream of formatted strings (<node> <param name>=<param value>)
2277 save_lustre_params() {
2279 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2282 # restore lustre parameters from input stream, produces by save_lustre_params
2283 restore_lustre_params() {
2287 while IFS=" =" read node name val; do
2288 do_node $node "lctl set_param -n $name $val"
2292 check_catastrophe () {
2293 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2295 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
2296 if [ $rnodes ]; then
2297 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2312 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2314 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2315 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2316 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2320 # CMD: determine mds index where directory inode presents
2323 local file=$dir/$tfile
2326 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2327 local oldused=($iused)
2331 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2332 local newused=($iused)
2335 for ((i=0; i<${#newused[@]}; i++)); do
2336 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2342 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2346 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2347 local command="$mpirun $@"
2349 if [ "$MPI_USER" != root -a $mpirun ]; then
2350 echo "+ chmod 0777 $MOUNT"
2352 command="su $MPI_USER sh -c \"$command \""
2360 mdsrate_cleanup () {
2361 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5