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
436 # maybe cleanup credential cache?
442 local device=`mdsdevname $num`
443 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
449 local device=`ostdevname $num`
450 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
458 local dev=${facet}_dev
459 local opt=${facet}_opt
460 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
461 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
463 if [ $RC -ne 0 ]; then
464 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
465 echo "Start of ${!dev} on ${facet} failed ${RC}"
467 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
468 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
469 lctl set_param debug_mb=${DEBUG_SIZE}; \
472 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
473 [ -z "$label" ] && echo no label for ${!dev} && exit 1
474 eval export ${facet}_svc=${label}
475 echo Started ${label}
480 # start facet device options
486 eval export ${facet}_dev=${device}
487 eval export ${facet}_opt=\"$@\"
488 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
498 HOST=`facet_active_host $facet`
499 [ -z $HOST ] && echo stop: no host for $facet && return 0
501 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
502 if [ ${running} -ne 0 ]; then
503 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
504 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
507 # umount should block, but we should wait for unrelated obd's
508 # like the MGS or MGC to also stop.
509 wait_exit_ST ${facet}
516 # Only supply -o to mount if we have options
517 if [ -n "$MOUNTOPT" ]; then
518 OPTIONS="-o $MOUNTOPT"
520 local device=$MGSNID:/$FSNAME
521 if [ -z "$mnt" -o -z "$FSNAME" ]; then
522 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
526 echo "Starting client: $client: $OPTIONS $device $mnt"
527 do_node $client mkdir -p $mnt
528 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
530 do_node $client "lctl set_param debug=$PTLDEBUG;
531 lctl set_param subsystem_debug=${SUBSYSTEM# };
532 lctl set_param debug_mb=${DEBUG_SIZE}"
545 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
546 if [ $running -ne 0 ]; then
547 echo "Stopping client $client $mnt (opts:$force)"
548 do_node $client lsof -t $mnt || need_kill=no
549 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
550 pids=$(do_node $client lsof -t $mnt | sort -u);
551 if [ -n $pids ]; then
552 do_node $client kill -9 $pids || true
556 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
557 if [ $busy -ne 0 ] ; then
558 echo "$mnt is still busy, wait one second" && sleep 1
559 do_node $client umount $force $mnt
564 # mount clients if not mouted
565 zconf_mount_clients() {
571 # Only supply -o to mount if we have options
572 if [ -n "$MOUNTOPT" ]; then
573 OPTIONS="-o $MOUNTOPT"
575 local device=$MGSNID:/$FSNAME
576 if [ -z "$mnt" -o -z "$FSNAME" ]; then
577 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
581 echo "Starting client $clients: $OPTIONS $device $mnt"
582 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
584 echo "Started clients $clients: "
585 do_nodes $clients "mount | grep $mnt"
587 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
588 lctl set_param subsystem_debug=${SUBSYSTEM# };
589 lctl set_param debug_mb=${DEBUG_SIZE};"
594 zconf_umount_clients() {
601 echo "Stopping clients: $clients $mnt (opts:$force)"
602 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts)
603 if [ \\\$running -ne 0 ] ; then
604 echo Stopping client \\\$(hostname) client $mnt opts:$force
605 lsof -t $mnt || need_kill=no
606 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
607 pids=\\\$(lsof -t $mnt | sort -u);
608 if [ -n \\\$pids ]; then
612 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy")
613 if [ \\\$busy -ne 0 ] ; then
614 echo "$mnt is still busy, wait one second" && sleep 1
622 if [ "$FAILURE_MODE" = HARD ]; then
623 $POWER_DOWN `facet_active_host $facet`
625 elif [ "$FAILURE_MODE" = SOFT ]; then
632 if [ "$FAILURE_MODE" = HARD ]; then
633 $POWER_UP `facet_active_host $facet`
641 if [ "$FAILURE_MODE" = HARD ]; then
646 # recovery-scale functions
647 check_progs_installed () {
652 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
653 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
658 start_client_load() {
659 local list=(${1//,/ })
662 local numloads=${#CLIENT_LOADS[@]}
663 local testnum=$((nodenum % numloads))
665 do_node ${list[nodenum]} "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
666 BREAK_ON_ERROR=$BREAK_ON_ERROR \
667 END_RUN_FILE=$END_RUN_FILE \
668 LOAD_PID_FILE=$LOAD_PID_FILE \
669 TESTSUITELOG=$TESTSUITELOG \
670 run_${CLIENT_LOADS[testnum]}.sh" &
671 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
672 log "Started client load: ${CLIENT_LOADS[testnum]} on ${list[nodenum]}"
674 eval export ${list[nodenum]}_load=${CLIENT_LOADS[testnum]}
678 start_client_loads () {
679 local clients=(${1//,/ })
681 for ((num=0; num < ${#clients[@]}; num++ )); do
682 start_client_load $1 $num
686 # only for remote client
687 check_client_load () {
689 local var=${client}_load
691 local TESTLOAD=run_${!var}.sh
693 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
695 check_catastrophe $client || return 2
697 # see if the load is still on the client
700 while [ $RC = 254 -a $tries -gt 0 ]; do
704 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
709 if [ $RC = 254 ]; then
710 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
711 # see if we can diagnose a bit why this is
716 check_client_loads () {
717 local clients=${1//,/ }
721 for client in $clients; do
722 check_client_load $client
724 if [ "$rc" != 0 ]; then
725 log "Client load failed on node $client, rc=$rc"
730 # End recovery-scale functions
732 # verify that lustre actually cleaned up properly
734 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
735 error "LBUG/LASSERT detected"
736 BUSY=`dmesg | grep -i destruct || true`
739 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
743 check_mem_leak || exit 204
745 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
746 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
748 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
749 echo "$0: modules still loaded..." 1>&2
756 wait_delete_completed () {
757 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
758 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
762 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
764 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
765 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
766 [ "$TOTAL" -eq "$TOTALPREV" ] && break
767 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
771 echo "Delete completed."
776 check_network "$HOST" 900
777 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
782 HOST=`facet_active_host $facet`
786 wait_mds_recovery_done () {
787 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
788 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
789 # as we are in process of changing obd_timeout in different ways
790 # let's set MAX longer than that
791 MAX=$(( timeout * 4 ))
793 while [ $WAIT -lt $MAX ]; do
794 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
795 echo $STATUS | grep COMPLETE && return 0
798 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
800 echo "MDS recovery not done in $MAX sec"
810 # conf-sanity 31 takes a long time cleanup
811 while [ $WAIT -lt 300 ]; do
812 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
813 [ -z "${running}" ] && return 0
814 echo "waited $WAIT for${running}"
815 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
817 WAIT=$((WAIT + INTERVAL))
819 echo "service didn't stop after $WAIT seconds. Still running:"
824 wait_remote_prog () {
830 [ "$PDSH" = "no_dsh" ] && return 0
832 while [ $WAIT -lt $2 ]; do
833 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
834 [ -z "${running}" ] && return 0 || true
835 echo "waited $WAIT for: "
837 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
839 WAIT=$((WAIT + INTERVAL))
841 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
842 [ -z "$pids" ] && return 0
843 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
845 cat /proc/${pid}/status || true
846 cat /proc/${pid}/wchan || true
857 # not every config has many clients
858 if [ ! -z "$CLIENTS" ]; then
859 $PDSH $CLIENTS "df $MOUNT" > /dev/null
861 df $MOUNT > /dev/null
866 uname -n >> $MOUNT/recon
867 if [ -z "$CLIENTS" ]; then
868 df $MOUNT; uname -n >> $MOUNT/recon
870 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
872 echo Connected clients:
874 ls -l $MOUNT/recon > /dev/null
881 echo "Failing $facet on node `facet_active_host $facet`"
882 shutdown_facet $facet
883 [ -n "$sleep_time" ] && sleep $sleep_time
887 echo "df pid is $DFPID"
889 TO=`facet_active_host $facet`
890 echo "Failover $facet to $TO"
892 mount_facet $facet || error "Restart of $facet failed"
903 local svc=${facet}_svc
904 do_facet $facet $LCTL --device %${!svc} readonly
905 do_facet $facet $LCTL --device %${!svc} notransno
906 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
907 $LCTL mark "local REPLAY BARRIER on ${!svc}"
910 replay_barrier_nodf() {
911 local facet=$1 echo running=${running}
913 local svc=${facet}_svc
914 echo Replay barrier on ${!svc}
915 do_facet $facet $LCTL --device %${!svc} readonly
916 do_facet $facet $LCTL --device %${!svc} notransno
917 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
918 $LCTL mark "local REPLAY BARRIER on ${!svc}"
921 replay_barrier_nosync() {
922 local facet=$1 echo running=${running}
923 local svc=${facet}_svc
924 echo Replay barrier on ${!svc}
925 do_facet $facet $LCTL --device %${!svc} readonly
926 do_facet $facet $LCTL --device %${!svc} notransno
927 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
928 $LCTL mark "local REPLAY BARRIER on ${!svc}"
932 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
933 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
937 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
938 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
942 facet_failover $* || error "failover: $?"
943 df $MOUNT || error "post-failover df: $?"
948 facet_failover $facet
955 mount_facet $facet -o abort_recovery
956 df $MOUNT || echo "first df failed: $?"
958 df $MOUNT || error "post-failover df: $?"
962 echo There is no lmc. This is mountconf, baby.
967 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
968 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
974 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
980 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
981 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
982 if [ -z "$ID" ]; then
983 echo "Could not get a ptl id for $1..."
992 h2name_or_ip "$1" "tcp"
997 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
998 if type __h2elan >/dev/null 2>&1; then
1001 ID=`echo $1 | sed 's/[^0-9]*//g'`
1009 h2name_or_ip "$1" "openib"
1011 declare -fx h2openib
1014 h2name_or_ip "$1" "o2ib"
1021 [ "$facet" == client ] && echo -n $HOSTNAME && return
1022 varname=${facet}_HOST
1023 if [ -z "${!varname}" ]; then
1024 if [ "${facet:0:3}" == "ost" ]; then
1025 eval ${facet}_HOST=${ost_HOST}
1033 local activevar=${facet}active
1035 if [ -f $TMP/${facet}active ] ; then
1036 source $TMP/${facet}active
1039 active=${!activevar}
1040 if [ -z "$active" ] ; then
1047 facet_active_host() {
1049 local active=`facet_active $facet`
1050 if [ "$facet" == client ]; then
1053 echo `facet_host $active`
1059 failover=${facet}failover
1060 host=`facet_host $failover`
1061 [ -z "$host" ] && return
1062 curactive=`facet_active $facet`
1063 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1064 eval export ${facet}active=$facet
1066 eval export ${facet}active=$failover
1068 # save the active host for this facet
1069 activevar=${facet}active
1070 echo "$activevar=${!activevar}" > $TMP/$activevar
1077 if [ "$HOST" = "$HOSTNAME" ]; then
1079 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1080 echo "cannot run remote command on $HOST with $myPDSH"
1084 echo "CMD: $HOST $@" >&2
1085 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1088 if [ "$myPDSH" = "rsh" ]; then
1089 # we need this because rsh does not return exit code of an executed command
1090 local command_status="$TMP/cs"
1091 rsh $HOST ":> $command_status"
1092 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1093 cd $RPWD; sh -c \"$@\") ||
1094 echo command failed >$command_status"
1095 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1098 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1099 return ${PIPESTATUS[0]}
1102 single_local_node () {
1103 [ "$1" = "$HOSTNAME" ]
1110 if $(single_local_node $rnodes); then
1115 # This is part from do_node
1118 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1119 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1122 echo "CMD: $rnodes $@" >&2
1123 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1126 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1127 return ${PIPESTATUS[0]}
1133 HOST=`facet_active_host $facet`
1134 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1141 # make sure its not already running
1143 rm -f $TMP/${facet}active
1144 do_facet ${facet} $MKFS $*
1150 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1151 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1158 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1159 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1167 # make sure we are using the primary server, so test-framework will
1168 # be able to clean up properly.
1169 activemds=`facet_active mds1`
1170 if [ $activemds != "mds1" ]; then
1174 # assume client mount is local
1175 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1176 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1178 if [ -n "$CLIENTS" ]; then
1179 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1180 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1183 [ "$CLIENTONLY" ] && return
1184 # The add fn does rm ${facet}active file, this would be enough
1185 # if we use do_facet <facet> only after the facet added, but
1186 # currently we use do_facet mds in local.sh
1187 for num in `seq $MDSCOUNT`; do
1189 rm -f ${TMP}/mds${num}active
1192 for num in `seq $OSTCOUNT`; do
1194 rm -f $TMP/ost${num}active
1209 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1213 if [ "$IAMDIR" == "yes" ]; then
1214 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1215 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1218 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1220 if [ ! -z $SEC ]; then
1221 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1222 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1223 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1227 # We need ldiskfs here, may as well load them all
1229 [ "$CLIENTONLY" ] && return
1230 echo "Formatting mdts, osts"
1231 for num in `seq $MDSCOUNT`; do
1232 echo "Format mds$num: $(mdsdevname $num)"
1234 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1236 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1240 for num in `seq $OSTCOUNT`; do
1241 echo "Format ost$num: $(ostdevname $num)"
1243 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1245 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1251 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1255 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1259 # 0: success, the old identity set already.
1260 # 1: success, the old identity does not set.
1265 local j=`expr $num - 1`
1266 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1268 if [ -z "$MDT" ]; then
1272 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1275 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1277 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1280 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1282 if [ $old = "NONE" ]; then
1291 zconf_umount `hostname` $1 || error "umount failed"
1292 zconf_mount `hostname` $1 || error "mount failed"
1299 do_facet $facet lsmod | grep -q obdclass || \
1300 do_facet $facet "modprobe obdclass"
1302 do_facet $facet "lctl set_param timeout=$timeout"
1305 writeconf_facet () {
1309 do_facet $facet "$TUNEFS --writeconf $dev"
1313 for num in `seq $MDSCOUNT`; do
1314 DEVNAME=$(mdsdevname $num)
1315 writeconf_facet mds$num $DEVNAME
1318 for num in `seq $OSTCOUNT`; do
1319 DEVNAME=$(ostdevname $num)
1320 writeconf_facet ost$num $DEVNAME
1327 if [ -z "$CLIENTONLY" ]; then
1328 echo "Setup mdts, osts"
1329 echo $WRITECONF | grep -q "writeconf" && \
1331 for num in `seq $MDSCOUNT`; do
1332 DEVNAME=$(mdsdevname $num)
1333 set_obd_timeout mds$num $TIMEOUT
1334 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1336 # We started mds, now we should set failover variables properly.
1337 # Set mds${num}failover_HOST if it is not set (the default failnode).
1338 local varname=mds${num}failover_HOST
1339 if [ -z "${!varname}" ]; then
1340 eval mds${num}failover_HOST=$(facet_host mds$num)
1343 if [ $IDENTITY_UPCALL != "default" ]; then
1344 switch_identity $num $IDENTITY_UPCALL
1347 for num in `seq $OSTCOUNT`; do
1348 DEVNAME=$(ostdevname $num)
1349 set_obd_timeout ost$num $TIMEOUT
1350 start ost$num $DEVNAME $OST_MOUNT_OPTS
1352 # We started ost$num, now we should set ost${num}failover variable properly.
1353 # Set ost${num}failover_HOST if it is not set (the default failnode).
1354 varname=ost${num}failover_HOST
1355 if [ -z "${!varname}" ]; then
1356 eval ost${num}failover_HOST=$(facet_host ost${num})
1361 # wait a while to allow sptlrpc configuration be propogated to targets,
1362 # only needed when mounting new target devices.
1365 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1367 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1369 if [ "$MOUNT_2" ]; then
1370 mount_client $MOUNT2
1371 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1376 # by remounting mdt before ost, initial connect from mdt to ost might
1377 # timeout because ost is not ready yet. wait some time to its fully
1378 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1379 # by a context negotiation rpc with $TIMEOUT.
1380 # FIXME better by monitoring import status.
1382 sleep $((TIMEOUT + 5))
1388 mounted_lustre_filesystems() {
1389 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1392 init_facet_vars () {
1399 eval export ${facet}_dev=${device}
1400 eval export ${facet}_opt=\"$@\"
1402 local dev=${facet}_dev
1403 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1404 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1406 eval export ${facet}_svc=${label}
1408 local varname=${facet}failover_HOST
1409 if [ -z "${!varname}" ]; then
1410 eval $varname=$(facet_host $facet)
1414 init_facets_vars () {
1417 for num in `seq $MDSCOUNT`; do
1418 DEVNAME=`mdsdevname $num`
1419 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1422 for num in `seq $OSTCOUNT`; do
1423 DEVNAME=`ostdevname $num`
1424 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1428 init_versions_vars () {
1429 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1430 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1431 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1436 local myMGS_host=$mgs_HOST
1437 if [ "$NETTYPE" = "ptl" ]; then
1438 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1441 echo Checking config lustre mounted on $mntpt
1442 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1443 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1445 if [ "$mgshost" != "$myMGS_host" ]; then
1446 FAIL_ON_ERROR=true \
1447 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1448 Please use correct config or set mds_HOST correctly!"
1452 check_and_setup_lustre() {
1453 local MOUNTED=$(mounted_lustre_filesystems)
1454 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1455 [ "$REFORMAT" ] && formatall
1457 MOUNTED=$(mounted_lustre_filesystems | head -1)
1458 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1459 export I_MOUNTED=yes
1465 if [ "$ONLY" == "setup" ]; then
1470 cleanup_and_setup_lustre() {
1471 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1472 lctl set_param debug=0 || true
1474 if [ "$ONLY" == "cleanup" ]; then
1478 check_and_setup_lustre
1481 check_and_cleanup_lustre() {
1482 if [ "`mount | grep $MOUNT`" ]; then
1483 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1485 if [ "$I_MOUNTED" = "yes" ]; then
1486 cleanupall -f || error "cleanup failed"
1498 while [ $NETWORK -eq 0 ]; do
1499 ping -c 1 -w 3 $1 > /dev/null
1500 if [ $? -eq 0 ]; then
1504 echo "waiting for $1, $((MAX - WAIT)) secs left"
1507 if [ $WAIT -gt $MAX ]; then
1508 echo "Network not available"
1514 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1525 # the sed converts spaces to commas, but leaves the last space
1526 # alone, so the line doesn't end with a comma.
1527 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1530 # list is comma separated list
1531 exclude_item_from_list () {
1536 list=$(echo " $list " | sed -re "s/\s+$excluded\s+/ /g")
1537 echo $(comma_list $list)
1541 (cd `dirname $1`; echo $PWD/`basename $1`)
1544 ##################################
1545 # Adaptive Timeouts funcs
1548 if [ -z "$AT_MAX_PATH" ]; then
1549 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1550 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1556 at_is_valid || error "invalid call"
1558 # only check mds, we assume at_max is the same on all nodes
1559 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1560 if [ $at_max -eq 0 ]; then
1570 at_is_valid || error "invalid call"
1572 # suppose that all ost-s has the same at_max set
1573 if [ $facet == "ost" ]; then
1574 do_facet ost1 "cat $AT_MAX_PATH"
1576 do_facet $facet "cat $AT_MAX_PATH"
1584 at_is_valid || error "invalid call"
1588 if [ $facet == "ost" ]; then
1589 for i in `seq $OSTCOUNT`; do
1590 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1592 elif [ $facet == "mds" ]; then
1593 for i in `seq $MDSCOUNT`; do
1594 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1597 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1602 ##################################
1606 # OBD_FAIL_MDS_ALL_REQUEST_NET
1608 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1609 do_facet client "$1" || RC=$?
1610 do_facet $SINGLEMDS lctl set_param fail_loc=0
1615 # OBD_FAIL_MDS_ALL_REPLY_NET
1617 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1618 do_facet client "$@" || RC=$?
1619 do_facet $SINGLEMDS lctl set_param fail_loc=0
1623 drop_reint_reply() {
1624 # OBD_FAIL_MDS_REINT_NET_REP
1626 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1627 do_facet client "$@" || RC=$?
1628 do_facet $SINGLEMDS lctl set_param fail_loc=0
1633 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1635 do_facet ost1 lctl set_param fail_loc=0x214
1636 do_facet client "$1" || RC=$?
1637 do_facet client "sync"
1638 do_facet ost1 lctl set_param fail_loc=0
1642 drop_ldlm_cancel() {
1643 #define OBD_FAIL_LDLM_CANCEL 0x304
1645 do_facet client lctl set_param fail_loc=0x304
1646 do_facet client "$@" || RC=$?
1647 do_facet client lctl set_param fail_loc=0
1651 drop_bl_callback() {
1652 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1654 do_facet client lctl set_param fail_loc=0x305
1655 do_facet client "$@" || RC=$?
1656 do_facet client lctl set_param fail_loc=0
1661 #define OBD_FAIL_LDLM_REPLY 0x30c
1663 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1664 do_facet client "$@" || RC=$?
1665 do_facet $SINGLEMDS lctl set_param fail_loc=0
1673 echo "clearing fail_loc on $facet"
1674 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1677 set_nodes_failloc () {
1681 for node in $nodes ; do
1682 do_node $node lctl set_param fail_loc=$2
1686 cancel_lru_locks() {
1687 $LCTL mark "cancel_lru_locks $1 start"
1688 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1689 $LCTL set_param -n $d=clear
1691 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1692 $LCTL mark "cancel_lru_locks $1 stop"
1697 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1698 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1699 echo "$DEFAULT_LRU_SIZE"
1704 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1707 lru_resize_disable()
1709 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1714 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1715 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1716 echo there is still data in page cache $FILE ?
1717 lctl get_param -n $FILE
1725 DEBUGSAVE="$(lctl get_param -n debug)"
1729 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1733 ##################################
1735 ##################################
1738 local TYPE=${TYPE:-"FAIL"}
1740 lctl set_param fail_loc=0 2>/dev/null || true
1741 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1742 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1743 echo "Dumping lctl log to $ERRLOG"
1744 # We need to dump the logs on all nodes
1745 local NODES=$(nodes_list)
1746 for NODE in $NODES; do
1747 do_node $NODE $LCTL dk $ERRLOG
1750 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1756 $FAIL_ON_ERROR && exit 1 || true
1764 # use only if we are ignoring failures for this test, bugno required.
1765 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1766 # e.g. error_ignore 5494 "your message"
1768 local TYPE="IGNORE (bz$1)"
1774 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1775 [ "$TESTSUITELOG" ] && \
1776 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1779 build_test_filter() {
1780 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1784 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1785 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1786 [ "$EXCEPT_SLOW" ] && \
1787 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1788 for E in $EXCEPT $ALWAYS_EXCEPT; do
1789 eval EXCEPT_${E}=true
1791 for E in $EXCEPT_SLOW; do
1792 eval EXCEPT_SLOW_${E}=true
1794 for G in $GRANT_CHECK_LIST; do
1795 eval GCHECK_ONLY_${G}=true
1804 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1807 # print a newline if the last test was skipped
1808 export LAST_SKIPPED=
1812 export base=`basetest $1`
1813 if [ ! -z "$ONLY" ]; then
1815 if [ ${!testname}x != x ]; then
1816 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1821 if [ ${!testname}x != x ]; then
1822 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1831 if [ ${!testname}x != x ]; then
1833 TESTNAME=test_$1 skip "skipping excluded test $1"
1836 testname=EXCEPT_$base
1837 if [ ${!testname}x != x ]; then
1839 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1842 testname=EXCEPT_SLOW_$1
1843 if [ ${!testname}x != x ]; then
1845 TESTNAME=test_$1 skip "skipping SLOW test $1"
1848 testname=EXCEPT_SLOW_$base
1849 if [ ${!testname}x != x ]; then
1851 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1861 EQUALS="======================================================================"
1865 local suffixlen=$((${#EQUALS} - ${#msg}))
1866 [ $suffixlen -lt 5 ] && suffixlen=5
1867 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1872 lsmod | grep lnet > /dev/null || load_modules
1884 local NODES=$(nodes_list)
1885 for NODE in $NODES; do
1886 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1892 strace -o $TMP/$1.strace -ttt $*
1894 log "FINISHED: $*: rc $RC"
1899 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
1904 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1905 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1906 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1910 local myNODES=$(nodes_list)
1913 for NODE in $myNODES; do
1914 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1922 export tdir=d0.${TESTSUITE}/d${base}
1924 local SAVE_UMASK=`umask`
1928 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1930 export TESTNAME=test_$testnum
1932 test_${testnum} || error "test_$testnum failed with $?"
1936 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1937 check_catastrophe || error "LBUG/LASSERT detected"
1938 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1939 pass "($((`date +%s` - $BEFORE))s)"
1947 (cd `dirname $1`; echo $PWD/`basename $1`)
1951 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1952 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1957 export base=`basetest $1`
1958 [ "$CHECK_GRANT" == "no" ] && return 0
1960 testname=GCHECK_ONLY_${base}
1961 [ ${!testname}x == x ] && return 0
1963 echo -n "checking grant......"
1965 # write some data to sync client lost_grant
1966 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1967 for i in `seq $OSTCOUNT`; do
1968 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1969 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1970 count=1 > /dev/null 2>&1
1972 # sync all the data and make sure no pending data on server
1975 #get client grant and server grant
1977 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1978 client_grant=$((client_grant + $d))
1981 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1982 server_grant=$((server_grant + $d))
1985 # cleanup the check_grant file
1986 for i in `seq $OSTCOUNT`; do
1987 rm $DIR1/${tfile}_check_grant_$i
1990 #check whether client grant == server grant
1991 if [ $client_grant != $server_grant ]; then
1992 echo "failed: client:${client_grant} server: ${server_grant}"
1999 ########################
2005 ost=`echo $1 | awk -F_ '{print $3}'`
2006 if [ -z $ost ]; then
2007 ost=`echo $1 | sed 's/-osc.*//'`
2014 [ "$node" != "$(hostname)" ]
2020 for node in $(mdts_nodes); do
2021 remote_node $node && return 0
2028 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2034 for node in $(osts_nodes) ; do
2035 remote_node $node && return 0
2042 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2048 for num in `seq $MDSCOUNT`; do
2049 MDSNODES="$MDSNODES $(facet_host mds$num)"
2051 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2057 remote_ost && remote_mds
2061 local OSTNODES=$(facet_host ost1)
2064 for num in `seq $OSTCOUNT`; do
2065 local myOST=$(facet_host ost$num)
2066 OSTNODES="$OSTNODES $myOST"
2068 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2074 # FIXME. We need a list of clients
2075 local myNODES=$HOSTNAME
2078 # CLIENTS (if specified) contains the local client
2079 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2081 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2082 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2085 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2090 remote_nodes_list () {
2091 local rnodes=$(nodes_list)
2092 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2096 init_clients_lists () {
2097 # Sanity check: exclude the local client from RCLIENTS
2098 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2100 # Sanity check: exclude the dup entries
2101 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2103 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2105 # Sanity check: exclude the dup entries from CLIENTS
2106 # for those configs which has SINGLCLIENT set to local client
2107 clients=$(for i in $clients; do echo $i; done | sort -u)
2109 CLIENTS=`comma_list $clients`
2110 local -a remoteclients=($rclients)
2111 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2112 varname=CLIENT$((i + 2))
2113 eval $varname=${remoteclients[i]}
2116 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2119 get_random_entry () {
2122 rnodes=${rnodes//,/ }
2124 local nodes=($rnodes)
2125 local num=${#nodes[@]}
2126 local i=$((RANDOM * num / 65536))
2133 lctl get_param version | grep -q patchless
2137 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2142 echo $nodes | wc -w || true
2146 local nodes=$(osts_nodes)
2147 local osscount=$(get_node_count "$nodes")
2148 [ ! "$OSTCOUNT" = "$osscount" ]
2152 local nodes=$(mdts_nodes)
2153 local mdtcount=$(get_node_count "$nodes")
2154 [ ! "$MDSCOUNT" = "$mdtcount" ]
2157 generate_machine_file() {
2158 local nodes=${1//,/ }
2159 local machinefile=$2
2160 rm -f $machinefile || error "can't rm $machinefile"
2161 for node in $nodes; do
2162 echo $node >>$machinefile
2167 local file=$1/stripe
2169 $LFS getstripe -v $file || error
2173 check_runas_id_ret() {
2175 local myRUNAS_UID=$1
2176 local myRUNAS_GID=$2
2179 if [ -z "$myRUNAS" ]; then
2180 error_exit "myRUNAS command must be specified for check_runas_id"
2183 $myRUNAS krb5_login.sh || \
2184 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2186 mkdir $DIR/d0_runas_test
2188 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2189 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2190 rm -rf $DIR/d0_runas_test
2195 local myRUNAS_UID=$1
2196 local myRUNAS_GID=$2
2199 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2200 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2201 Please set RUNAS_ID to some UID which exists on MDS and client or
2202 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2205 # Run multiop in the background, but wait for it to print
2206 # "PAUSING" to its stdout before returning from this function.
2207 multiop_bg_pause() {
2208 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2212 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2215 echo "$MULTIOP_PROG $FILE v$ARGS"
2216 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2218 echo "TMPPIPE=${TMPPIPE}"
2219 read -t 60 multiop_output < $TMPPIPE
2220 if [ $? -ne 0 ]; then
2225 if [ "$multiop_output" != "PAUSING" ]; then
2226 echo "Incorrect multiop output: $multiop_output"
2234 inodes_available () {
2235 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2239 # reset llite stat counters
2240 clear_llite_stats(){
2241 lctl set_param -n llite.*.stats 0
2244 # sum llite stat items
2245 calc_llite_stats() {
2246 local res=$(lctl get_param -n llite.*.stats |
2247 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2251 # reset osc stat counters
2253 lctl set_param -n osc.*.osc_stats 0
2256 # sum osc stat items
2258 local res=$(lctl get_param -n osc.*.osc_stats |
2259 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2264 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2267 calc_osc_kbytes () {
2268 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2271 # save_lustre_params(node, parameter_mask)
2272 # generate a stream of formatted strings (<node> <param name>=<param value>)
2273 save_lustre_params() {
2275 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2278 # restore lustre parameters from input stream, produces by save_lustre_params
2279 restore_lustre_params() {
2283 while IFS=" =" read node name val; do
2284 do_node $node "lctl set_param -n $name $val"
2288 check_catastrophe () {
2289 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2291 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
2292 if [ $rnodes ]; then
2293 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2308 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2310 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2311 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2312 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2316 # CMD: determine mds index where directory inode presents
2319 local file=$dir/$tfile
2322 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2323 local oldused=($iused)
2327 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2328 local newused=($iused)
2331 for ((i=0; i<${#newused[@]}; i++)); do
2332 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2338 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2342 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2343 local command="$mpirun $@"
2345 if [ "$MPI_USER" != root -a $mpirun ]; then
2346 echo "+ chmod 0777 $MOUNT"
2348 command="su $MPI_USER sh -c \"$command \""
2356 mdsrate_cleanup () {
2357 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5