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/tests/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 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
256 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
261 load_module lvfs/fsfilt_$FSTYPE
265 load_module obdfilter/obdfilter
268 load_module llite/lustre
269 load_module llite/llite_lloop
270 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
272 rm -f $OGDB/ogdb-$HOSTNAME
273 $LCTL modules > $OGDB/ogdb-$HOSTNAME
275 # 'mount' doesn't look in $PATH, just sbin
276 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
280 if [ `uname -r | cut -c 3` -eq 4 ]; then
288 MODULES=$($LCTL modules | awk '{ print $2 }')
289 while [ -n "$MODULES" ]; do
291 $RMMOD $MODULES > /dev/null 2>&1 || true
292 MODULES=$($LCTL modules | awk '{ print $2 }')
293 if [ -z "$MODULES" ]; then
297 echo "waiting, $((MAX - WAIT)) secs left"
299 if [ $WAIT -eq $MAX ]; then
300 echo "LNET modules $MODULES will not unload"
307 unload_dep_module() {
309 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
311 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
312 for SUBMOD in $DEPS; do
313 unload_dep_module $SUBMOD
315 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
316 $RMMOD $MODULE || true
320 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
321 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
322 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
323 echo "$LEAK_LUSTRE" 1>&2
324 echo "$LEAK_PORTALS" 1>&2
325 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
326 echo "Memory leaks detected"
327 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
333 wait_exit_ST client # bug 12845
335 lsmod | grep libcfs > /dev/null && $LCTL dl
336 unload_dep_module $FSTYPE
337 unload_dep_module libcfs
339 local MODULES=$($LCTL modules | awk '{ print $2 }')
340 if [ -n "$MODULES" ]; then
341 echo "Modules still loaded: "
343 if [ "$(lctl dl)" ]; then
344 echo "Lustre still loaded"
349 echo "Lustre stopped but LNET is still loaded, waiting..."
350 wait_for_lnet || return 3
356 check_mem_leak || return 254
358 echo "modules unloaded."
362 check_gss_daemon_facet() {
366 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
367 if [ $num -ne 1 ]; then
368 echo "$num instance of $dname on $facet"
377 do_facet $facet "killall -2 $@ 2>/dev/null || true"
380 start_gss_daemons() {
382 for num in `seq $MDSCOUNT`; do
383 do_facet mds$num "$LSVCGSSD -v"
385 do_facet mds$num "$LGSSD -v"
389 for num in `seq $OSTCOUNT`; do
390 do_facet ost$num "$LSVCGSSD -v"
393 # FIXME: is "client" the right facet name?
395 do_facet client "$LGSSD -v"
398 # wait daemons entering "stable" status
402 # check daemons are running
404 for num in `seq $MDSCOUNT`; do
405 check_gss_daemon_facet mds$num lsvcgssd
407 check_gss_daemon_facet mds$num lgssd
410 for num in `seq $OSTCOUNT`; do
411 check_gss_daemon_facet ost$num lsvcgssd
414 check_gss_daemon_facet client lgssd
419 for num in `seq $MDSCOUNT`; do
420 send_sigint mds$num lsvcgssd lgssd
422 for num in `seq $OSTCOUNT`; do
423 send_sigint ost$num lsvcgssd
425 send_sigint client lgssd
432 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
433 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
441 # maybe cleanup credential cache?
447 local device=`mdsdevname $num`
448 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
454 local device=`ostdevname $num`
455 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
463 local dev=${facet}_dev
464 local opt=${facet}_opt
465 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
466 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
468 if [ $RC -ne 0 ]; then
469 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
470 echo "Start of ${!dev} on ${facet} failed ${RC}"
472 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
473 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
474 lctl set_param debug_mb=${DEBUG_SIZE}; \
477 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
478 [ -z "$label" ] && echo no label for ${!dev} && exit 1
479 eval export ${facet}_svc=${label}
480 echo Started ${label}
485 # start facet device options
491 eval export ${facet}_dev=${device}
492 eval export ${facet}_opt=\"$@\"
493 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
503 HOST=`facet_active_host $facet`
504 [ -z $HOST ] && echo stop: no host for $facet && return 0
506 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
507 if [ ${running} -ne 0 ]; then
508 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
509 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
512 # umount should block, but we should wait for unrelated obd's
513 # like the MGS or MGC to also stop.
514 wait_exit_ST ${facet}
521 # Only supply -o to mount if we have options
522 if [ -n "$MOUNTOPT" ]; then
523 OPTIONS="-o $MOUNTOPT"
525 local device=$MGSNID:/$FSNAME
526 if [ -z "$mnt" -o -z "$FSNAME" ]; then
527 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
531 echo "Starting client: $client: $OPTIONS $device $mnt"
532 do_node $client mkdir -p $mnt
533 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
535 do_node $client "lctl set_param debug=$PTLDEBUG;
536 lctl set_param subsystem_debug=${SUBSYSTEM# };
537 lctl set_param debug_mb=${DEBUG_SIZE}"
550 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
551 if [ $running -ne 0 ]; then
552 echo "Stopping client $client $mnt (opts:$force)"
553 do_node $client lsof -t $mnt || need_kill=no
554 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
555 pids=$(do_node $client lsof -t $mnt | sort -u);
556 if [ -n $pids ]; then
557 do_node $client kill -9 $pids || true
561 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
562 if [ $busy -ne 0 ] ; then
563 echo "$mnt is still busy, wait one second" && sleep 1
564 do_node $client umount $force $mnt
569 # mount clients if not mouted
570 zconf_mount_clients() {
576 # Only supply -o to mount if we have options
577 if [ -n "$MOUNTOPT" ]; then
578 OPTIONS="-o $MOUNTOPT"
580 local device=$MGSNID:/$FSNAME
581 if [ -z "$mnt" -o -z "$FSNAME" ]; then
582 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
586 echo "Starting client $clients: $OPTIONS $device $mnt"
587 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
589 echo "Started clients $clients: "
590 do_nodes $clients "mount | grep $mnt"
592 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
593 lctl set_param subsystem_debug=${SUBSYSTEM# };
594 lctl set_param debug_mb=${DEBUG_SIZE};"
599 zconf_umount_clients() {
606 echo "Stopping clients: $clients $mnt (opts:$force)"
607 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts)
608 if [ \\\$running -ne 0 ] ; then
609 echo Stopping client \\\$(hostname) client $mnt opts:$force
610 lsof -t $mnt || need_kill=no
611 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
612 pids=\\\$(lsof -t $mnt | sort -u);
613 if [ -n \\\$pids ]; then
617 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy")
618 if [ \\\$busy -ne 0 ] ; then
619 echo "$mnt is still busy, wait one second" && sleep 1
627 if [ "$FAILURE_MODE" = HARD ]; then
628 $POWER_DOWN `facet_active_host $facet`
630 elif [ "$FAILURE_MODE" = SOFT ]; then
637 if [ "$FAILURE_MODE" = HARD ]; then
638 $POWER_UP `facet_active_host $facet`
646 if [ "$FAILURE_MODE" = HARD ]; then
651 # recovery-scale functions
652 check_progs_installed () {
657 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
658 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
663 start_client_load() {
664 local list=(${1//,/ })
667 local numloads=${#CLIENT_LOADS[@]}
668 local testnum=$((nodenum % numloads))
670 do_node ${list[nodenum]} "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
671 BREAK_ON_ERROR=$BREAK_ON_ERROR \
672 END_RUN_FILE=$END_RUN_FILE \
673 LOAD_PID_FILE=$LOAD_PID_FILE \
674 TESTSUITELOG=$TESTSUITELOG \
675 run_${CLIENT_LOADS[testnum]}.sh" &
676 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
677 log "Started client load: ${CLIENT_LOADS[testnum]} on ${list[nodenum]}"
679 eval export ${list[nodenum]}_load=${CLIENT_LOADS[testnum]}
683 start_client_loads () {
684 local clients=(${1//,/ })
686 for ((num=0; num < ${#clients[@]}; num++ )); do
687 start_client_load $1 $num
691 # only for remote client
692 check_client_load () {
694 local var=${client}_load
696 local TESTLOAD=run_${!var}.sh
698 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
700 check_catastrophe $client || return 2
702 # see if the load is still on the client
705 while [ $RC = 254 -a $tries -gt 0 ]; do
709 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
714 if [ $RC = 254 ]; then
715 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
716 # see if we can diagnose a bit why this is
721 check_client_loads () {
722 local clients=${1//,/ }
726 for client in $clients; do
727 check_client_load $client
729 if [ "$rc" != 0 ]; then
730 log "Client load failed on node $client, rc=$rc"
735 # End recovery-scale functions
737 # verify that lustre actually cleaned up properly
739 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
740 error "LBUG/LASSERT detected"
741 BUSY=`dmesg | grep -i destruct || true`
744 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
748 check_mem_leak || exit 204
750 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
751 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
753 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
754 echo "$0: modules still loaded..." 1>&2
770 while [ $WAIT -lt $MAX ]; do
772 RESULT=$(do_node $node "$TEST")
773 if [ $RESULT -eq $FINAL ]; then
774 echo "Updated after $WAIT sec: wanted $FINAL got $RESULT"
777 WAIT=$((WAIT + sleep))
778 echo "Waiting $((MAX - WAIT)) secs for update"
780 echo "Update not seen after $MAX sec: wanted $FINAL got $RESULT"
784 wait_update_facet () {
786 wait_update $(facet_host $facet) $@
789 wait_delete_completed () {
790 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
791 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
795 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
797 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
798 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
799 [ "$TOTAL" -eq "$TOTALPREV" ] && break
800 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
804 echo "Delete completed."
809 check_network "$HOST" 900
810 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
815 local HOST=`facet_active_host $facet`
819 wait_mds_recovery_done () {
820 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
821 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
822 # as we are in process of changing obd_timeout in different ways
823 # let's set MAX longer than that
824 local MAX=$(( timeout * 4 ))
826 while [ $WAIT -lt $MAX ]; do
827 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
828 echo $STATUS | grep COMPLETE && return 0
831 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
833 echo "MDS recovery not done in $MAX sec"
843 # conf-sanity 31 takes a long time cleanup
844 while [ $WAIT -lt 300 ]; do
845 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
846 [ -z "${running}" ] && return 0
847 echo "waited $WAIT for${running}"
848 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
850 WAIT=$((WAIT + INTERVAL))
852 echo "service didn't stop after $WAIT seconds. Still running:"
857 wait_remote_prog () {
863 [ "$PDSH" = "no_dsh" ] && return 0
865 while [ $WAIT -lt $2 ]; do
866 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
867 [ -z "${running}" ] && return 0 || true
868 echo "waited $WAIT for: "
870 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
872 WAIT=$((WAIT + INTERVAL))
874 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
875 [ -z "$pids" ] && return 0
876 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
878 cat /proc/${pid}/status || true
879 cat /proc/${pid}/wchan || true
890 # not every config has many clients
891 if [ ! -z "$CLIENTS" ]; then
892 $PDSH $CLIENTS "df $MOUNT" > /dev/null
894 df $MOUNT > /dev/null
899 uname -n >> $MOUNT/recon
900 if [ -z "$CLIENTS" ]; then
901 df $MOUNT; uname -n >> $MOUNT/recon
903 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
905 echo Connected clients:
907 ls -l $MOUNT/recon > /dev/null
914 echo "Failing $facet on node `facet_active_host $facet`"
915 shutdown_facet $facet
916 [ -n "$sleep_time" ] && sleep $sleep_time
920 echo "df pid is $DFPID"
922 TO=`facet_active_host $facet`
923 echo "Failover $facet to $TO"
925 mount_facet $facet || error "Restart of $facet failed"
936 local svc=${facet}_svc
937 do_facet $facet $LCTL --device %${!svc} readonly
938 do_facet $facet $LCTL --device %${!svc} notransno
939 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
940 $LCTL mark "local REPLAY BARRIER on ${!svc}"
943 replay_barrier_nodf() {
944 local facet=$1 echo running=${running}
946 local svc=${facet}_svc
947 echo Replay barrier on ${!svc}
948 do_facet $facet $LCTL --device %${!svc} readonly
949 do_facet $facet $LCTL --device %${!svc} notransno
950 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
951 $LCTL mark "local REPLAY BARRIER on ${!svc}"
954 replay_barrier_nosync() {
955 local facet=$1 echo running=${running}
956 local svc=${facet}_svc
957 echo Replay barrier on ${!svc}
958 do_facet $facet $LCTL --device %${!svc} readonly
959 do_facet $facet $LCTL --device %${!svc} notransno
960 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
961 $LCTL mark "local REPLAY BARRIER on ${!svc}"
965 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
966 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
970 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
971 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
975 facet_failover $* || error "failover: $?"
976 df $MOUNT || error "post-failover df: $?"
981 facet_failover $facet
988 mount_facet $facet -o abort_recovery
989 df $MOUNT || echo "first df failed: $?"
991 df $MOUNT || error "post-failover df: $?"
995 echo There is no lmc. This is mountconf, baby.
1000 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1001 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1007 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1013 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1014 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1015 if [ -z "$ID" ]; then
1016 echo "Could not get a ptl id for $1..."
1025 h2name_or_ip "$1" "tcp"
1030 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1031 if type __h2elan >/dev/null 2>&1; then
1034 ID=`echo $1 | sed 's/[^0-9]*//g'`
1042 h2name_or_ip "$1" "openib"
1044 declare -fx h2openib
1047 h2name_or_ip "$1" "o2ib"
1054 [ "$facet" == client ] && echo -n $HOSTNAME && return
1055 varname=${facet}_HOST
1056 if [ -z "${!varname}" ]; then
1057 if [ "${facet:0:3}" == "ost" ]; then
1058 eval ${facet}_HOST=${ost_HOST}
1066 local activevar=${facet}active
1068 if [ -f $TMP/${facet}active ] ; then
1069 source $TMP/${facet}active
1072 active=${!activevar}
1073 if [ -z "$active" ] ; then
1080 facet_active_host() {
1082 local active=`facet_active $facet`
1083 if [ "$facet" == client ]; then
1086 echo `facet_host $active`
1092 failover=${facet}failover
1093 host=`facet_host $failover`
1094 [ -z "$host" ] && return
1095 curactive=`facet_active $facet`
1096 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1097 eval export ${facet}active=$facet
1099 eval export ${facet}active=$failover
1101 # save the active host for this facet
1102 activevar=${facet}active
1103 echo "$activevar=${!activevar}" > $TMP/$activevar
1110 if [ "$HOST" = "$HOSTNAME" ]; then
1112 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1113 echo "cannot run remote command on $HOST with $myPDSH"
1117 echo "CMD: $HOST $@" >&2
1118 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1121 if [ "$myPDSH" = "rsh" ]; then
1122 # we need this because rsh does not return exit code of an executed command
1123 local command_status="$TMP/cs"
1124 rsh $HOST ":> $command_status"
1125 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1126 cd $RPWD; sh -c \"$@\") ||
1127 echo command failed >$command_status"
1128 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1131 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1132 return ${PIPESTATUS[0]}
1135 single_local_node () {
1136 [ "$1" = "$HOSTNAME" ]
1143 if $(single_local_node $rnodes); then
1148 # This is part from do_node
1151 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1152 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1155 echo "CMD: $rnodes $@" >&2
1156 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1159 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1160 return ${PIPESTATUS[0]}
1166 HOST=`facet_active_host $facet`
1167 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1174 # make sure its not already running
1176 rm -f $TMP/${facet}active
1177 do_facet ${facet} $MKFS $*
1183 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1184 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1191 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1192 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1200 # make sure we are using the primary server, so test-framework will
1201 # be able to clean up properly.
1202 activemds=`facet_active mds1`
1203 if [ $activemds != "mds1" ]; then
1207 # assume client mount is local
1208 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1209 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1211 if [ -n "$CLIENTS" ]; then
1212 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1213 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1216 [ "$CLIENTONLY" ] && return
1217 # The add fn does rm ${facet}active file, this would be enough
1218 # if we use do_facet <facet> only after the facet added, but
1219 # currently we use do_facet mds in local.sh
1220 for num in `seq $MDSCOUNT`; do
1222 rm -f ${TMP}/mds${num}active
1225 for num in `seq $OSTCOUNT`; do
1227 rm -f $TMP/ost${num}active
1242 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1246 if [ "$IAMDIR" == "yes" ]; then
1247 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1248 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1251 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1253 if [ ! -z $SEC ]; then
1254 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1255 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1256 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1260 # We need ldiskfs here, may as well load them all
1262 [ "$CLIENTONLY" ] && return
1263 echo "Formatting mdts, osts"
1264 for num in `seq $MDSCOUNT`; do
1265 echo "Format mds$num: $(mdsdevname $num)"
1267 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1269 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1273 for num in `seq $OSTCOUNT`; do
1274 echo "Format ost$num: $(ostdevname $num)"
1276 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1278 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1284 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1288 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1292 # 0: success, the old identity set already.
1293 # 1: success, the old identity does not set.
1298 local j=`expr $num - 1`
1299 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1301 if [ -z "$MDT" ]; then
1305 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1308 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1310 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1313 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1315 if [ $old = "NONE" ]; then
1324 zconf_umount `hostname` $1 || error "umount failed"
1325 zconf_mount `hostname` $1 || error "mount failed"
1328 writeconf_facet () {
1332 do_facet $facet "$TUNEFS --writeconf $dev"
1336 for num in `seq $MDSCOUNT`; do
1337 DEVNAME=$(mdsdevname $num)
1338 writeconf_facet mds$num $DEVNAME
1341 for num in `seq $OSTCOUNT`; do
1342 DEVNAME=$(ostdevname $num)
1343 writeconf_facet ost$num $DEVNAME
1350 if [ -z "$CLIENTONLY" ]; then
1351 echo "Setup mdts, osts"
1352 echo $WRITECONF | grep -q "writeconf" && \
1354 for num in `seq $MDSCOUNT`; do
1355 DEVNAME=$(mdsdevname $num)
1356 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1358 # We started mds, now we should set failover variables properly.
1359 # Set mds${num}failover_HOST if it is not set (the default failnode).
1360 local varname=mds${num}failover_HOST
1361 if [ -z "${!varname}" ]; then
1362 eval mds${num}failover_HOST=$(facet_host mds$num)
1365 if [ $IDENTITY_UPCALL != "default" ]; then
1366 switch_identity $num $IDENTITY_UPCALL
1369 for num in `seq $OSTCOUNT`; do
1370 DEVNAME=$(ostdevname $num)
1371 start ost$num $DEVNAME $OST_MOUNT_OPTS
1373 # We started ost$num, now we should set ost${num}failover variable properly.
1374 # Set ost${num}failover_HOST if it is not set (the default failnode).
1375 varname=ost${num}failover_HOST
1376 if [ -z "${!varname}" ]; then
1377 eval ost${num}failover_HOST=$(facet_host ost${num})
1382 # wait a while to allow sptlrpc configuration be propogated to targets,
1383 # only needed when mounting new target devices.
1386 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1388 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1390 if [ "$MOUNT_2" ]; then
1391 mount_client $MOUNT2
1392 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1397 # by remounting mdt before ost, initial connect from mdt to ost might
1398 # timeout because ost is not ready yet. wait some time to its fully
1399 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1400 # by a context negotiation rpc with $TIMEOUT.
1401 # FIXME better by monitoring import status.
1403 sleep $((TIMEOUT + 5))
1409 mounted_lustre_filesystems() {
1410 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1413 init_facet_vars () {
1420 eval export ${facet}_dev=${device}
1421 eval export ${facet}_opt=\"$@\"
1423 local dev=${facet}_dev
1424 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1425 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1427 eval export ${facet}_svc=${label}
1429 local varname=${facet}failover_HOST
1430 if [ -z "${!varname}" ]; then
1431 eval $varname=$(facet_host $facet)
1435 init_facets_vars () {
1438 for num in `seq $MDSCOUNT`; do
1439 DEVNAME=`mdsdevname $num`
1440 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1443 for num in `seq $OSTCOUNT`; do
1444 DEVNAME=`ostdevname $num`
1445 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1449 init_param_vars () {
1450 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1451 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1452 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1454 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1455 log "Using TIMEOUT=$TIMEOUT"
1460 local myMGS_host=$mgs_HOST
1461 if [ "$NETTYPE" = "ptl" ]; then
1462 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1465 echo Checking config lustre mounted on $mntpt
1466 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1467 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1469 if [ "$mgshost" != "$myMGS_host" ]; then
1470 FAIL_ON_ERROR=true \
1471 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1472 Please use correct config or set mds_HOST correctly!"
1477 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1478 local cltimeout=$(lctl get_param -n timeout)
1479 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1480 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1485 check_and_setup_lustre() {
1486 local MOUNTED=$(mounted_lustre_filesystems)
1487 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1488 [ "$REFORMAT" ] && formatall
1490 MOUNTED=$(mounted_lustre_filesystems | head -1)
1491 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1492 export I_MOUNTED=yes
1498 if [ "$ONLY" == "setup" ]; then
1503 cleanup_and_setup_lustre() {
1504 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1505 lctl set_param debug=0 || true
1507 if [ "$ONLY" == "cleanup" ]; then
1511 check_and_setup_lustre
1514 check_and_cleanup_lustre() {
1515 if [ "`mount | grep $MOUNT`" ]; then
1516 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1518 if [ "$I_MOUNTED" = "yes" ]; then
1519 cleanupall -f || error "cleanup failed"
1531 while [ $NETWORK -eq 0 ]; do
1532 ping -c 1 -w 3 $1 > /dev/null
1533 if [ $? -eq 0 ]; then
1537 echo "waiting for $1, $((MAX - WAIT)) secs left"
1540 if [ $WAIT -gt $MAX ]; then
1541 echo "Network not available"
1547 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1558 # the sed converts spaces to commas, but leaves the last space
1559 # alone, so the line doesn't end with a comma.
1560 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1563 # list is comma separated list
1564 exclude_item_from_list () {
1569 list=$(echo " $list " | sed -re "s/\s+$excluded\s+/ /g")
1570 echo $(comma_list $list)
1574 (cd `dirname $1`; echo $PWD/`basename $1`)
1577 ##################################
1578 # Adaptive Timeouts funcs
1581 if [ -z "$AT_MAX_PATH" ]; then
1582 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1583 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1589 at_is_valid || error "invalid call"
1591 # only check mds, we assume at_max is the same on all nodes
1592 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1593 if [ $at_max -eq 0 ]; then
1603 at_is_valid || error "invalid call"
1605 # suppose that all ost-s has the same at_max set
1606 if [ $facet == "ost" ]; then
1607 do_facet ost1 "cat $AT_MAX_PATH"
1609 do_facet $facet "cat $AT_MAX_PATH"
1617 at_is_valid || error "invalid call"
1621 if [ $facet == "ost" ]; then
1622 for i in `seq $OSTCOUNT`; do
1623 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1625 elif [ $facet == "mds" ]; then
1626 for i in `seq $MDSCOUNT`; do
1627 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1630 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1635 ##################################
1639 # OBD_FAIL_MDS_ALL_REQUEST_NET
1641 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1642 do_facet client "$1" || RC=$?
1643 do_facet $SINGLEMDS lctl set_param fail_loc=0
1648 # OBD_FAIL_MDS_ALL_REPLY_NET
1650 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1651 do_facet client "$@" || RC=$?
1652 do_facet $SINGLEMDS lctl set_param fail_loc=0
1656 drop_reint_reply() {
1657 # OBD_FAIL_MDS_REINT_NET_REP
1659 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1660 do_facet client "$@" || RC=$?
1661 do_facet $SINGLEMDS lctl set_param fail_loc=0
1666 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1668 do_facet ost1 lctl set_param fail_loc=0x214
1669 do_facet client "$1" || RC=$?
1670 do_facet client "sync"
1671 do_facet ost1 lctl set_param fail_loc=0
1675 drop_ldlm_cancel() {
1676 #define OBD_FAIL_LDLM_CANCEL 0x304
1678 do_facet client lctl set_param fail_loc=0x304
1679 do_facet client "$@" || RC=$?
1680 do_facet client lctl set_param fail_loc=0
1684 drop_bl_callback() {
1685 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1687 do_facet client lctl set_param fail_loc=0x305
1688 do_facet client "$@" || RC=$?
1689 do_facet client lctl set_param fail_loc=0
1694 #define OBD_FAIL_LDLM_REPLY 0x30c
1696 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1697 do_facet client "$@" || RC=$?
1698 do_facet $SINGLEMDS lctl set_param fail_loc=0
1706 echo "clearing fail_loc on $facet"
1707 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1710 set_nodes_failloc () {
1714 for node in $nodes ; do
1715 do_node $node lctl set_param fail_loc=$2
1719 cancel_lru_locks() {
1720 $LCTL mark "cancel_lru_locks $1 start"
1721 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1722 $LCTL set_param -n $d=clear
1724 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1725 $LCTL mark "cancel_lru_locks $1 stop"
1730 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1731 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1732 echo "$DEFAULT_LRU_SIZE"
1737 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1740 lru_resize_disable()
1742 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1747 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1748 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1749 echo there is still data in page cache $FILE ?
1750 lctl get_param -n $FILE
1758 DEBUGSAVE="$(lctl get_param -n debug)"
1762 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1766 ##################################
1768 ##################################
1771 local TYPE=${TYPE:-"FAIL"}
1773 lctl set_param fail_loc=0 2>/dev/null || true
1774 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1775 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1776 echo "Dumping lctl log to $ERRLOG"
1777 # We need to dump the logs on all nodes
1778 local NODES=$(nodes_list)
1779 for NODE in $NODES; do
1780 do_node $NODE $LCTL dk $ERRLOG
1783 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1789 $FAIL_ON_ERROR && exit 1 || true
1797 # use only if we are ignoring failures for this test, bugno required.
1798 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1799 # e.g. error_ignore 5494 "your message"
1801 local TYPE="IGNORE (bz$1)"
1807 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1808 [ "$TESTSUITELOG" ] && \
1809 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1812 build_test_filter() {
1813 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1817 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1818 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1819 [ "$EXCEPT_SLOW" ] && \
1820 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1821 for E in $EXCEPT $ALWAYS_EXCEPT; do
1822 eval EXCEPT_${E}=true
1824 for E in $EXCEPT_SLOW; do
1825 eval EXCEPT_SLOW_${E}=true
1827 for G in $GRANT_CHECK_LIST; do
1828 eval GCHECK_ONLY_${G}=true
1837 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1840 # print a newline if the last test was skipped
1841 export LAST_SKIPPED=
1845 export base=`basetest $1`
1846 if [ ! -z "$ONLY" ]; then
1848 if [ ${!testname}x != x ]; then
1849 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1854 if [ ${!testname}x != x ]; then
1855 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1864 if [ ${!testname}x != x ]; then
1866 TESTNAME=test_$1 skip "skipping excluded test $1"
1869 testname=EXCEPT_$base
1870 if [ ${!testname}x != x ]; then
1872 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1875 testname=EXCEPT_SLOW_$1
1876 if [ ${!testname}x != x ]; then
1878 TESTNAME=test_$1 skip "skipping SLOW test $1"
1881 testname=EXCEPT_SLOW_$base
1882 if [ ${!testname}x != x ]; then
1884 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1894 EQUALS="======================================================================"
1898 local suffixlen=$((${#EQUALS} - ${#msg}))
1899 [ $suffixlen -lt 5 ] && suffixlen=5
1900 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1905 lsmod | grep lnet > /dev/null || load_modules
1917 local NODES=$(nodes_list)
1918 for NODE in $NODES; do
1919 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1925 strace -o $TMP/$1.strace -ttt $*
1927 log "FINISHED: $*: rc $RC"
1932 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
1937 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1938 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1939 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1943 local myNODES=$(nodes_list)
1946 for NODE in $myNODES; do
1947 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1955 export tdir=d0.${TESTSUITE}/d${base}
1957 local SAVE_UMASK=`umask`
1961 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1963 export TESTNAME=test_$testnum
1965 test_${testnum} || error "test_$testnum failed with $?"
1969 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1970 check_catastrophe || error "LBUG/LASSERT detected"
1971 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1972 pass "($((`date +%s` - $BEFORE))s)"
1980 (cd `dirname $1`; echo $PWD/`basename $1`)
1984 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1985 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1990 export base=`basetest $1`
1991 [ "$CHECK_GRANT" == "no" ] && return 0
1993 testname=GCHECK_ONLY_${base}
1994 [ ${!testname}x == x ] && return 0
1996 echo -n "checking grant......"
1998 # write some data to sync client lost_grant
1999 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2000 for i in `seq $OSTCOUNT`; do
2001 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2002 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2003 count=1 > /dev/null 2>&1
2005 # sync all the data and make sure no pending data on server
2008 #get client grant and server grant
2010 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2011 client_grant=$((client_grant + $d))
2014 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2015 server_grant=$((server_grant + $d))
2018 # cleanup the check_grant file
2019 for i in `seq $OSTCOUNT`; do
2020 rm $DIR1/${tfile}_check_grant_$i
2023 #check whether client grant == server grant
2024 if [ $client_grant != $server_grant ]; then
2025 echo "failed: client:${client_grant} server: ${server_grant}"
2032 ########################
2038 ost=`echo $1 | awk -F_ '{print $3}'`
2039 if [ -z $ost ]; then
2040 ost=`echo $1 | sed 's/-osc.*//'`
2047 [ "$node" != "$(hostname)" ]
2053 for node in $(mdts_nodes); do
2054 remote_node $node && return 0
2061 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2067 for node in $(osts_nodes) ; do
2068 remote_node $node && return 0
2075 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2081 for num in `seq $MDSCOUNT`; do
2082 MDSNODES="$MDSNODES $(facet_host mds$num)"
2084 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2090 remote_ost && remote_mds
2094 local OSTNODES=$(facet_host ost1)
2097 for num in `seq $OSTCOUNT`; do
2098 local myOST=$(facet_host ost$num)
2099 OSTNODES="$OSTNODES $myOST"
2101 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2107 # FIXME. We need a list of clients
2108 local myNODES=$HOSTNAME
2111 # CLIENTS (if specified) contains the local client
2112 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2114 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2115 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2118 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2123 remote_nodes_list () {
2124 local rnodes=$(nodes_list)
2125 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2129 init_clients_lists () {
2130 # Sanity check: exclude the local client from RCLIENTS
2131 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2133 # Sanity check: exclude the dup entries
2134 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2136 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2138 # Sanity check: exclude the dup entries from CLIENTS
2139 # for those configs which has SINGLCLIENT set to local client
2140 clients=$(for i in $clients; do echo $i; done | sort -u)
2142 CLIENTS=`comma_list $clients`
2143 local -a remoteclients=($rclients)
2144 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2145 varname=CLIENT$((i + 2))
2146 eval $varname=${remoteclients[i]}
2149 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2152 get_random_entry () {
2155 rnodes=${rnodes//,/ }
2157 local nodes=($rnodes)
2158 local num=${#nodes[@]}
2159 local i=$((RANDOM * num / 65536))
2166 lctl get_param version | grep -q patchless
2170 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2175 echo $nodes | wc -w || true
2179 local nodes=$(osts_nodes)
2180 local osscount=$(get_node_count "$nodes")
2181 [ ! "$OSTCOUNT" = "$osscount" ]
2185 local nodes=$(mdts_nodes)
2186 local mdtcount=$(get_node_count "$nodes")
2187 [ ! "$MDSCOUNT" = "$mdtcount" ]
2190 generate_machine_file() {
2191 local nodes=${1//,/ }
2192 local machinefile=$2
2193 rm -f $machinefile || error "can't rm $machinefile"
2194 for node in $nodes; do
2195 echo $node >>$machinefile
2200 local file=$1/stripe
2202 $LFS getstripe -v $file || error
2206 check_runas_id_ret() {
2208 local myRUNAS_UID=$1
2209 local myRUNAS_GID=$2
2212 if [ -z "$myRUNAS" ]; then
2213 error_exit "myRUNAS command must be specified for check_runas_id"
2216 $myRUNAS krb5_login.sh || \
2217 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2219 mkdir $DIR/d0_runas_test
2221 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2222 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2223 rm -rf $DIR/d0_runas_test
2228 local myRUNAS_UID=$1
2229 local myRUNAS_GID=$2
2232 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2233 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2234 Please set RUNAS_ID to some UID which exists on MDS and client or
2235 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2238 # Run multiop in the background, but wait for it to print
2239 # "PAUSING" to its stdout before returning from this function.
2240 multiop_bg_pause() {
2241 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2245 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2248 echo "$MULTIOP_PROG $FILE v$ARGS"
2249 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2251 echo "TMPPIPE=${TMPPIPE}"
2252 read -t 60 multiop_output < $TMPPIPE
2253 if [ $? -ne 0 ]; then
2258 if [ "$multiop_output" != "PAUSING" ]; then
2259 echo "Incorrect multiop output: $multiop_output"
2267 inodes_available () {
2268 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2272 # reset llite stat counters
2273 clear_llite_stats(){
2274 lctl set_param -n llite.*.stats 0
2277 # sum llite stat items
2278 calc_llite_stats() {
2279 local res=$(lctl get_param -n llite.*.stats |
2280 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2284 # reset osc stat counters
2286 lctl set_param -n osc.*.osc_stats 0
2289 # sum osc stat items
2291 local res=$(lctl get_param -n osc.*.osc_stats |
2292 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2297 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2300 calc_osc_kbytes () {
2301 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2304 # save_lustre_params(node, parameter_mask)
2305 # generate a stream of formatted strings (<node> <param name>=<param value>)
2306 save_lustre_params() {
2308 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2311 # restore lustre parameters from input stream, produces by save_lustre_params
2312 restore_lustre_params() {
2316 while IFS=" =" read node name val; do
2317 do_node $node "lctl set_param -n $name $val"
2321 check_catastrophe () {
2322 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2324 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
2325 if [ $rnodes ]; then
2326 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2341 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2343 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2344 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2345 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2349 # CMD: determine mds index where directory inode presents
2352 local file=$dir/f0.get_mds_dir_tmpfile
2355 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2356 local oldused=($iused)
2360 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2361 local newused=($iused)
2364 for ((i=0; i<${#newused[@]}; i++)); do
2365 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2371 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2375 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2376 local command="$mpirun $@"
2378 if [ "$MPI_USER" != root -a $mpirun ]; then
2379 echo "+ chmod 0777 $MOUNT"
2381 command="su $MPI_USER sh -c \"$command \""
2389 mdsrate_cleanup () {
2390 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5