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}
14 #export PDSH="pdsh -S -Rssh -w"
16 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
20 if [ -z "${!name}" ]; then
21 echo "$0: $name must be set"
25 [ $failed ] && exit 1 || true
30 [[ $DIR/ = $MOUNT/* ]] || \
31 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
32 [[ $DIR1/ = $MOUNT1/* ]] || \
33 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
34 [[ $DIR2/ = $MOUNT2/* ]] || \
35 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
37 [ -n "$failed" ] && exit 99 || true
41 echo "usage: $0 [-r] [-f cfgfile]"
48 [ "$TESTSUITE" == "lfscktest" ] && return 0
49 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
50 local form="%-13s %-17s %s\n"
51 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
52 echo "------------------------------------------------------------------------------------"
53 for O in $TESTSUITE_LIST; do
56 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
59 local log=${TMP}/${o}.log
60 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
61 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
62 [ "${!O}" = "done" ] && \
63 printf "$form" "Done" "$O" "E=$skipped" && \
64 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
68 for O in $TESTSUITE_LIST; do
69 [ "${!O}" = "no" ] && \
70 printf "$form" "Skipped" "$O" ""
73 for O in $TESTSUITE_LIST; do
74 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
75 printf "$form" "UNFINISHED" "$O" ""
80 export LUSTRE=`absolute_path $LUSTRE`
81 export TESTSUITE=`basename $0 .sh`
82 export TEST_FAILED=false
84 #[ -d /r ] && export ROOT=${ROOT:-/r}
85 export TMP=${TMP:-$ROOT/tmp}
86 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
87 export HOSTNAME=${HOSTNAME:-`hostname`}
88 if ! echo $PATH | grep -q $LUSTRE/utils; then
89 export PATH=$PATH:$LUSTRE/utils
91 if ! echo $PATH | grep -q $LUSTRE/test; then
92 export PATH=$PATH:$LUSTRE/tests
94 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
95 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
96 if ! echo $PATH | grep -q $LUSTRE/test/racer; then
97 export PATH=$PATH:$LUSTRE/tests/racer
99 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
100 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
101 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
102 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
103 [ ! -f "$LFS" ] && export LFS=$(which lfs)
104 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
105 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
106 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
107 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
108 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
109 export FSYTPE=${FSTYPE:-"ldiskfs"}
110 export NAME=${NAME:-local}
113 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
115 if [ "$ACCEPTOR_PORT" ]; then
116 export PORT_OPT="--port $ACCEPTOR_PORT"
119 # Paths on remote nodes, if different
120 export RLUSTRE=${RLUSTRE:-$LUSTRE}
121 export RPWD=${RPWD:-$PWD}
122 export I_MOUNTED=${I_MOUNTED:-"no"}
126 while getopts "rvwf:" opt $*; do
129 r) REFORMAT=--reformat;;
131 w) WRITECONF=writeconf;;
136 shift $((OPTIND - 1))
139 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
145 *) EXT=".ko"; USE_QUOTA=yes;;
151 BASE=`basename $module $EXT`
152 lsmod | grep -q ${BASE} || \
153 if [ -f ${LUSTRE}/${module}${EXT} ]; then
154 insmod ${LUSTRE}/${module}${EXT} $@
156 # must be testing a "make install" or "rpm" installation
162 if [ -n "$MODPROBE" ]; then
166 if [ "$HAVE_MODULES" = true ]; then
172 echo Loading modules from $LUSTRE
173 load_module ../lnet/libcfs/libcfs
174 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
175 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
177 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
178 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
179 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
180 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
181 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
182 echo "lnet options: '$LNETOPTS'"
183 # note that insmod will ignore anything in modprobe.conf
184 load_module ../lnet/lnet/lnet $LNETOPTS
185 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
186 load_module ../lnet/klnds/$LNETLND
187 load_module lvfs/lvfs
188 load_module obdclass/obdclass
189 load_module ptlrpc/ptlrpc
190 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
195 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
198 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
199 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
200 load_module lvfs/fsfilt_$FSTYPE
202 load_module obdfilter/obdfilter
205 load_module llite/lustre
206 load_module llite/llite_lloop
207 rm -f $TMP/ogdb-$HOSTNAME
209 [ -d /r ] && OGDB="/r/tmp"
210 $LCTL modules > $OGDB/ogdb-$HOSTNAME
211 # 'mount' doesn't look in $PATH, just sbin
212 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
216 if [ `uname -r | cut -c 3` -eq 4 ]; then
224 MODULES=$($LCTL modules | awk '{ print $2 }')
225 while [ -n "$MODULES" ]; do
227 $RMMOD $MODULES >/dev/null 2>&1 || true
228 MODULES=$($LCTL modules | awk '{ print $2 }')
229 if [ -z "$MODULES" ]; then
233 echo "waiting, $((MAX - WAIT)) secs left"
235 if [ $WAIT -eq $MAX ]; then
236 echo "LNET modules $MODULES will not unload"
243 unload_dep_module() {
245 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
247 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
248 for SUBMOD in $DEPS; do
249 unload_dep_module $SUBMOD
251 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
252 $RMMOD $MODULE || true
256 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
257 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
258 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
259 echo "$LEAK_LUSTRE" 1>&2
260 echo "$LEAK_PORTALS" 1>&2
261 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
262 echo "Memory leaks detected"
263 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
269 wait_exit_ST client # bug 12845
271 lsmod | grep libcfs > /dev/null && $LCTL dl
272 [ -z "$CLIENTONLY" ] && unload_dep_module $FSTYPE
273 unload_dep_module libcfs
275 local MODULES=$($LCTL modules | awk '{ print $2 }')
276 if [ -n "$MODULES" ]; then
277 echo "Modules still loaded: "
279 if [ "$(lctl dl)" ]; then
280 echo "Lustre still loaded"
285 echo "Lustre stopped but LNET is still loaded, waiting..."
286 wait_for_lnet || return 3
291 check_mem_leak || return 254
293 echo "modules unloaded."
301 local dev=${facet}_dev
302 local opt=${facet}_opt
303 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
304 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
306 if [ $RC -ne 0 ]; then
307 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
308 echo "Start of ${!dev} on ${facet} failed ${RC}"
310 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
311 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
312 lctl set_param debug_mb=${DEBUG_SIZE}; \
315 label=$(do_facet ${facet} "e2label ${!dev}")
316 [ -z "$label" ] && echo no label for ${!dev} && exit 1
317 eval export ${facet}_svc=${label}
318 echo Started ${label}
323 # start facet device options
329 eval export ${facet}_dev=${device}
330 eval export ${facet}_opt=\"$@\"
331 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
341 HOST=`facet_active_host $facet`
342 [ -z $HOST ] && echo stop: no host for $facet && return 0
344 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
345 if [ ${running} -ne 0 ]; then
346 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
347 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
350 # umount should block, but we should wait for unrelated obd's
351 # like the MGS or MGC to also stop.
353 wait_exit_ST ${facet}
360 # Only supply -o to mount if we have options
361 if [ -n "$MOUNTOPT" ]; then
362 OPTIONS="-o $MOUNTOPT"
364 local device=$MGSNID:/$FSNAME
365 if [ -z "$mnt" -o -z "$FSNAME" ]; then
366 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
370 echo "Starting client: $client: $OPTIONS $device $mnt"
371 do_node $client mkdir -p $mnt
372 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
373 do_node $client "lctl set_param debug=$PTLDEBUG;
374 lctl set_param subsystem_debug=${SUBSYSTEM# };
375 lctl set_param debug_mb=${DEBUG_SIZE}"
384 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
385 if [ $running -ne 0 ]; then
386 echo "Stopping client $client $mnt (opts:$force)"
387 do_node $client lsof | grep "$mnt" || true
388 do_node $client umount $force $mnt
392 # mount clients if not mouted
393 zconf_mount_clients() {
398 # Only supply -o to mount if we have options
399 if [ -n "$MOUNTOPT" ]; then
400 OPTIONS="-o $MOUNTOPT"
402 local device=$MGSNID:/$FSNAME
403 if [ -z "$mnt" -o -z "$FSNAME" ]; then
404 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
408 echo "Starting client $clients: $OPTIONS $device $mnt"
409 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
411 echo "Started clients $clients: "
412 do_nodes $clients "mount | grep $mnt"
414 do_nodes $clients "sysctl -w lnet.debug=$PTLDEBUG;
415 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
416 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
421 zconf_umount_clients() {
426 echo "Stopping clients: $clients $mnt (opts:$force)"
427 do_nodes $clients umount $force $mnt
432 if [ "$FAILURE_MODE" = HARD ]; then
433 $POWER_DOWN `facet_active_host $facet`
435 elif [ "$FAILURE_MODE" = SOFT ]; then
442 if [ "$FAILURE_MODE" = HARD ]; then
443 $POWER_UP `facet_active_host $facet`
451 if [ "$FAILURE_MODE" = HARD ]; then
456 # recovery-scale functions
457 check_progs_installed () {
462 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
463 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
468 start_client_load() {
469 local list=(${1//,/ })
472 local numloads=${#CLIENT_LOADS[@]}
473 local testnum=$((nodenum % numloads))
475 do_node ${list[nodenum]} "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
476 BREAK_ON_ERROR=$BREAK_ON_ERROR \
477 END_RUN_FILE=$END_RUN_FILE \
478 LOAD_PID_FILE=$LOAD_PID_FILE \
479 TESTSUITELOG=$TESTSUITELOG \
480 run_${CLIENT_LOADS[testnum]}.sh" &
481 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
482 log "Started client load: ${CLIENT_LOADS[testnum]} on ${list[nodenum]}"
484 eval export ${list[nodenum]}_load=${CLIENT_LOADS[testnum]}
488 start_client_loads () {
489 local clients=(${1//,/ })
491 for ((num=0; num < ${#clients[@]}; num++ )); do
492 start_client_load $1 $num
496 # only for remote client
497 check_client_load () {
499 local var=${client}_load
501 local TESTLOAD=run_${!var}.sh
503 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
505 check_catastrophe $client || return 2
507 # see if the load is still on the client
510 while [ $RC = 254 -a $tries -gt 0 ]; do
514 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
519 if [ $RC = 254 ]; then
520 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
521 # see if we can diagnose a bit why this is
526 check_client_loads () {
527 local clients=${1//,/ }
531 for client in $clients; do
532 check_client_load $client
534 if [ "$rc" != 0 ]; then
535 log "Client load failed on node $client, rc=$rc"
540 # End recovery-scale functions
542 # verify that lustre actually cleaned up properly
544 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
545 error "LBUG/LASSERT detected"
546 BUSY=`dmesg | grep -i destruct || true`
549 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
553 check_mem_leak || exit 204
555 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
556 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
558 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
559 echo "$0: modules still loaded..." 1>&2
566 wait_delete_completed () {
567 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
568 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
572 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
574 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
575 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
576 [ "$TOTAL" -eq "$TOTALPREV" ] && break
577 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
581 echo "Delete completed."
586 check_network "$HOST" 900
587 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
592 HOST=`facet_active_host $facet`
596 wait_mds_recovery_done () {
597 local timeout=`do_facet mds lctl get_param -n timeout`
598 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
599 # as we are in process of changing obd_timeout in different ways
600 # let's set MAX longer than that
601 MAX=$(( timeout * 4 ))
603 while [ $WAIT -lt $MAX ]; do
604 STATUS=`do_facet mds "lctl get_param -n mds.*-MDT*.recovery_status | grep status"`
605 echo $STATUS | grep COMPLETE && return 0
608 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
610 echo "MDS recovery not done in $MAX sec"
620 # conf-sanity 31 takes a long time cleanup
621 while [ $WAIT -lt 300 ]; do
622 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
623 [ -z "${running}" ] && return 0
624 echo "waited $WAIT for${running}"
625 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
627 WAIT=$((WAIT + INTERVAL))
629 echo "service didn't stop after $WAIT seconds. Still running:"
634 wait_remote_prog () {
640 [ "$PDSH" = "no_dsh" ] && return 0
642 while [ $WAIT -lt $2 ]; do
643 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
644 [ -z "${running}" ] && return 0 || true
645 echo "waited $WAIT for: "
647 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
649 WAIT=$((WAIT + INTERVAL))
651 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
652 [ -z "$pids" ] && return 0
653 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
655 cat /proc/${pid}/status || true
656 cat /proc/${pid}/wchan || true
667 # not every config has many clients
668 if [ -n "$CLIENTS" ]; then
669 $PDSH $CLIENTS "df $MOUNT" > /dev/null
671 df $MOUNT > /dev/null
676 uname -n >> $MOUNT/recon
677 if [ -z "$CLIENTS" ]; then
678 df $MOUNT; uname -n >> $MOUNT/recon
680 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
682 echo Connected clients:
684 ls -l $MOUNT/recon > /dev/null
691 echo "Failing $facet on node `facet_active_host $facet`"
692 shutdown_facet $facet
693 [ -n "$sleep_time" ] && sleep $sleep_time
697 RECOVERY_START_TIME=`date +%s`
698 echo "df pid is $DFPID"
700 TO=`facet_active_host $facet`
701 echo "Failover $facet to $TO"
703 mount_facet $facet || error "Restart of $facet failed"
714 local svc=${facet}_svc
715 do_facet $facet $LCTL --device %${!svc} readonly
716 do_facet $facet $LCTL --device %${!svc} notransno
717 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
718 $LCTL mark "local REPLAY BARRIER on ${!svc}"
721 replay_barrier_nodf() {
722 local facet=$1 echo running=${running}
724 local svc=${facet}_svc
725 echo Replay barrier on ${!svc}
726 do_facet $facet $LCTL --device %${!svc} readonly
727 do_facet $facet $LCTL --device %${!svc} notransno
728 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
729 $LCTL mark "local REPLAY BARRIER on ${!svc}"
733 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
734 do_facet mds "lctl set_param -n mds.${mds_svc}.evict_client $UUID"
738 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
739 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
743 facet_failover $* || error "failover: $?"
744 df $MOUNT || error "post-failover df: $?"
749 facet_failover $facet
756 mount_facet $facet -o abort_recovery
757 df $MOUNT || echo "first df failed: $?"
759 df $MOUNT || error "post-failover df: $?"
763 echo There is no lmc. This is mountconf, baby.
768 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
769 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
775 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
781 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
782 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
783 if [ -z "$ID" ]; then
784 echo "Could not get a ptl id for $1..."
793 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
800 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
801 if type __h2elan >/dev/null 2>&1; then
804 ID=`echo $1 | sed 's/[^0-9]*//g'`
812 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
813 ID=`echo $1 | sed 's/[^0-9]*//g'`
820 h2name_or_ip "$1" "o2ib"
827 [ "$facet" == client ] && echo -n $HOSTNAME && return
828 varname=${facet}_HOST
829 if [ -z "${!varname}" ]; then
830 if [ "${facet:0:3}" == "ost" ]; then
831 eval ${facet}_HOST=${ost_HOST}
839 local activevar=${facet}active
841 if [ -f $TMP/${facet}active ] ; then
842 source $TMP/${facet}active
846 if [ -z "$active" ] ; then
853 facet_active_host() {
855 local active=`facet_active $facet`
856 if [ "$facet" == client ]; then
859 echo `facet_host $active`
865 failover=${facet}failover
866 host=`facet_host $failover`
867 [ -z "$host" ] && return
868 curactive=`facet_active $facet`
869 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
870 eval export ${facet}active=$facet
872 eval export ${facet}active=$failover
874 # save the active host for this facet
875 activevar=${facet}active
876 echo "$activevar=${!activevar}" > $TMP/$activevar
883 if [ "$HOST" = "$HOSTNAME" ]; then
885 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
886 echo "cannot run remote command on $HOST with $myPDSH"
890 echo "CMD: $HOST $@" >&2
891 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
894 if [ "$myPDSH" = "rsh" ]; then
895 # we need this because rsh does not return exit code of an executed command
896 local command_status="$TMP/cs"
897 rsh $HOST ":> $command_status"
898 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
899 cd $RPWD; sh -c \"$@\") ||
900 echo command failed >$command_status"
901 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
904 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
905 return ${PIPESTATUS[0]}
908 single_local_node () {
909 [ "$1" = "$HOSTNAME" ]
916 if $(single_local_node $rnodes); then
921 # This is part from do_node
924 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
925 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
928 echo "CMD: $rnodes $@" >&2
929 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
932 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
933 return ${PIPESTATUS[0]}
939 HOST=`facet_active_host $facet`
940 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
947 # make sure its not already running
949 rm -f $TMP/${facet}active
950 do_facet ${facet} $MKFS $*
956 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
957 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
965 # make sure we are using the primary server, so test-framework will
966 # be able to clean up properly.
967 activemds=`facet_active mds`
968 if [ $activemds != "mds" ]; then
972 # assume client mount is local
973 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
974 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
976 if [ -n "$CLIENTS" ]; then
977 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
978 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
981 [ "$CLIENTONLY" ] && return
982 # The add fn does rm ${facet}active file, this would be enough
983 # if we use do_facet <facet> only after the facet added, but
984 # currently we use do_facet mds in local.sh
986 rm -f ${TMP}/mdsactive
987 for num in `seq $OSTCOUNT`; do
989 rm -f $TMP/ost${num}active
1000 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1003 # We need ldiskfs here, may as well load them all
1005 [ "$CLIENTONLY" ] && return
1006 echo Formatting mds, osts
1008 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
1010 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1013 for num in `seq $OSTCOUNT`; do
1015 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1017 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1023 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1028 zconf_umount `hostname` $1 || error "umount failed"
1029 zconf_mount `hostname` $1 || error "mount failed"
1036 do_facet $facet lsmod | grep -q obdclass || \
1037 do_facet $facet "modprobe obdclass"
1039 do_facet $facet "lctl set_param timeout=$timeout"
1042 writeconf_facet () {
1046 do_facet $facet "$TUNEFS --writeconf $dev"
1050 writeconf_facet mds $MDSDEV
1052 for num in `seq $OSTCOUNT`; do
1053 DEVNAME=`ostdevname $num`
1054 writeconf_facet ost$num $DEVNAME
1060 if [ -z "$CLIENTONLY" ]; then
1061 echo Setup mdt, osts
1063 echo $WRITECONF | grep -q "writeconf" && \
1066 set_obd_timeout mds $TIMEOUT
1067 start mds $MDSDEV $MDS_MOUNT_OPTS
1068 # We started mds, now we should set failover variable properly.
1069 # Set mdsfailover_HOST if it is not set (the default failnode).
1070 mdsfailover_HOST=$(facet_host mds)
1072 for num in `seq $OSTCOUNT`; do
1073 DEVNAME=`ostdevname $num`
1074 set_obd_timeout ost$num $TIMEOUT
1075 start ost$num $DEVNAME $OST_MOUNT_OPTS
1077 # We started ost$num, now we should set ost${num}failover variable properly.
1078 # Set ost${num}failover_HOST if it is not set (the default failnode).
1079 varname=ost${num}failover_HOST
1080 if [ -z "${!varname}" ]; then
1081 eval ost${num}failover_HOST=$(facet_host ost${num})
1086 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1088 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1090 if [ "$MOUNT_2" ]; then
1091 mount_client $MOUNT2
1092 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1098 mounted_lustre_filesystems() {
1099 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1102 init_facet_vars () {
1109 eval export ${facet}_dev=${device}
1110 eval export ${facet}_opt=\"$@\"
1112 local dev=${facet}_dev
1113 local label=$(do_facet ${facet} "e2label ${!dev}")
1114 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1116 eval export ${facet}_svc=${label}
1118 local varname=${facet}failover_HOST
1119 if [ -z "${!varname}" ]; then
1120 eval $varname=$(facet_host $facet)
1124 init_facets_vars () {
1125 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1127 for num in `seq $OSTCOUNT`; do
1128 DEVNAME=`ostdevname $num`
1129 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1133 init_versions_vars () {
1134 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1135 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1136 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1141 local myMGS_host=$mgs_HOST
1142 if [ "$NETTYPE" = "ptl" ]; then
1143 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1146 echo Checking config lustre mounted on $mntpt
1147 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1148 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1150 if [ "$mgshost" != "$myMGS_host" ]; then
1151 FAIL_ON_ERROR=true \
1152 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1153 Please use correct config or set mds_HOST correctly!"
1157 check_and_setup_lustre() {
1158 local MOUNTED=$(mounted_lustre_filesystems)
1159 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1160 [ "$REFORMAT" ] && formatall
1162 MOUNTED=$(mounted_lustre_filesystems | head -1)
1163 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1164 export I_MOUNTED=yes
1170 if [ "$ONLY" == "setup" ]; then
1175 cleanup_and_setup_lustre() {
1176 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1177 lctl set_param debug=0 || true
1179 if [ "$ONLY" == "cleanup" ]; then
1183 check_and_setup_lustre
1186 check_and_cleanup_lustre() {
1187 if [ "`mount | grep $MOUNT`" ]; then
1188 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1190 if [ "$I_MOUNTED" = "yes" ]; then
1191 cleanupall -f || error "cleanup failed"
1203 while [ $NETWORK -eq 0 ]; do
1204 ping -c 1 -w 3 $1 > /dev/null
1205 if [ $? -eq 0 ]; then
1209 echo "waiting for $1, $((MAX - WAIT)) secs left"
1212 if [ $WAIT -gt $MAX ]; then
1213 echo "Network not available"
1219 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1230 # the sed converts spaces to commas, but leaves the last space
1231 # alone, so the line doesn't end with a comma.
1232 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1235 # list is comma separated list
1236 exclude_item_from_list () {
1241 list=$(echo " $list " | sed -re "s/\s+$excluded\s+/ /g")
1242 echo $(comma_list $list)
1246 (cd `dirname $1`; echo $PWD/`basename $1`)
1249 ##################################
1250 # Adaptive Timeouts funcs
1253 if [ -z "$AT_MAX_PATH" ]; then
1254 AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
1255 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1261 at_is_valid || error "invalid call"
1263 # only check mds, we assume at_max is the same on all nodes
1264 local at_max=$(do_facet mds "cat $AT_MAX_PATH")
1265 if [ $at_max -eq 0 ]; then
1275 at_is_valid || error "invalid call"
1277 # suppose that all ost-s has the same at_max set
1278 if [ $facet == "ost" ]; then
1279 do_facet ost1 "cat $AT_MAX_PATH"
1281 do_facet $facet "cat $AT_MAX_PATH"
1289 at_is_valid || error "invalid call"
1293 if [ $facet == "ost" ]; then
1294 for i in `seq $OSTCOUNT`; do
1295 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1298 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1303 ##################################
1307 # OBD_FAIL_MDS_ALL_REQUEST_NET
1309 do_facet mds lctl set_param fail_loc=0x123
1310 do_facet client "$1" || RC=$?
1311 do_facet mds lctl set_param fail_loc=0
1316 # OBD_FAIL_MDS_ALL_REPLY_NET
1318 do_facet mds lctl set_param fail_loc=0x122
1319 do_facet client "$@" || RC=$?
1320 do_facet mds lctl set_param fail_loc=0
1324 drop_reint_reply() {
1325 # OBD_FAIL_MDS_REINT_NET_REP
1327 do_facet mds lctl set_param fail_loc=0x119
1328 do_facet client "$@" || RC=$?
1329 do_facet mds lctl set_param fail_loc=0
1334 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1336 do_facet ost1 lctl set_param fail_loc=0x214
1337 do_facet client "$1" || RC=$?
1338 do_facet client "sync"
1339 do_facet ost1 lctl set_param fail_loc=0
1343 drop_ldlm_cancel() {
1344 #define OBD_FAIL_LDLM_CANCEL 0x304
1346 do_facet client lctl set_param fail_loc=0x304
1347 do_facet client "$@" || RC=$?
1348 do_facet client lctl set_param fail_loc=0
1352 drop_bl_callback() {
1353 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1355 do_facet client lctl set_param fail_loc=0x305
1356 do_facet client "$@" || RC=$?
1357 do_facet client lctl set_param fail_loc=0
1362 #define OBD_FAIL_LDLM_REPLY 0x30c
1364 do_facet mds lctl set_param fail_loc=0x30c
1365 do_facet client "$@" || RC=$?
1366 do_facet mds lctl set_param fail_loc=0
1374 echo "clearing fail_loc on $facet"
1375 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1378 set_nodes_failloc () {
1382 for node in $nodes ; do
1383 do_node $node lctl set_param fail_loc=$2
1387 cancel_lru_locks() {
1388 $LCTL mark "cancel_lru_locks $1 start"
1389 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1390 $LCTL set_param -n $d=clear
1392 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1393 $LCTL mark "cancel_lru_locks $1 stop"
1398 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1399 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1400 echo "$DEFAULT_LRU_SIZE"
1405 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1408 lru_resize_disable()
1410 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1415 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1416 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1417 echo there is still data in page cache $FILE ?
1418 lctl get_param -n $FILE
1425 create_fake_exports () {
1428 #obd_fail_val = num;
1429 #define OBD_FAIL_TGT_FAKE_EXP 0x708
1430 do_facet $facet "lctl set_param fail_val=$num"
1431 do_facet $facet "lctl set_param fail_loc=0x80000708"
1436 DEBUGSAVE="$(lctl get_param -n debug)"
1440 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1444 ##################################
1446 ##################################
1449 local TYPE=${TYPE:-"FAIL"}
1451 lctl set_param fail_loc=0 2>/dev/null || true
1452 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1453 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1454 echo "Dumping lctl log to $ERRLOG"
1455 # We need to dump the logs on all nodes
1456 local NODES=$(nodes_list)
1457 for NODE in $NODES; do
1458 do_node $NODE $LCTL dk $ERRLOG
1461 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1467 $FAIL_ON_ERROR && exit 1 || true
1475 # use only if we are ignoring failures for this test, bugno required.
1476 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1477 # e.g. error_ignore 5494 "your message"
1479 local TYPE="IGNORE (bz$1)"
1485 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1486 [ "$TESTSUITELOG" ] && \
1487 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1490 build_test_filter() {
1491 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1495 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1496 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1497 [ "$EXCEPT_SLOW" ] && \
1498 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1499 for E in $EXCEPT $ALWAYS_EXCEPT; do
1500 eval EXCEPT_${E}=true
1502 for E in $EXCEPT_SLOW; do
1503 eval EXCEPT_SLOW_${E}=true
1505 for G in $GRANT_CHECK_LIST; do
1506 eval GCHECK_ONLY_${G}=true
1515 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1518 # print a newline if the last test was skipped
1519 export LAST_SKIPPED=
1523 export base=`basetest $1`
1524 if [ ! -z "$ONLY" ]; then
1526 if [ ${!testname}x != x ]; then
1527 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1532 if [ ${!testname}x != x ]; then
1533 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1542 if [ ${!testname}x != x ]; then
1544 TESTNAME=test_$1 skip "skipping excluded test $1"
1547 testname=EXCEPT_$base
1548 if [ ${!testname}x != x ]; then
1550 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1553 testname=EXCEPT_SLOW_$1
1554 if [ ${!testname}x != x ]; then
1556 TESTNAME=test_$1 skip "skipping SLOW test $1"
1559 testname=EXCEPT_SLOW_$base
1560 if [ ${!testname}x != x ]; then
1562 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1572 EQUALS="======================================================================"
1576 local suffixlen=$((${#EQUALS} - ${#msg}))
1577 [ $suffixlen -lt 5 ] && suffixlen=5
1578 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1583 lsmod | grep lnet > /dev/null || load_modules
1595 local NODES=$(nodes_list)
1596 for NODE in $NODES; do
1597 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1603 strace -o $TMP/$1.strace -ttt $*
1605 log "FINISHED: $*: rc $RC"
1610 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
1615 FFREE=`lctl get_param -n mds.*.filesfree`
1616 FTOTAL=`lctl get_param -n mds.*.filestotal`
1617 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1621 local myNODES=$(nodes_list)
1624 for NODE in $myNODES; do
1625 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1633 export tdir=d0.${TESTSUITE}/d${base}
1635 local SAVE_UMASK=`umask`
1639 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1641 export TESTNAME=test_$testnum
1643 test_${testnum} || error "test_$testnum failed with $?"
1647 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1648 check_catastrophe || error "LBUG/LASSERT detected"
1649 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1650 pass "($((`date +%s` - $BEFORE))s)"
1658 (cd `dirname $1`; echo $PWD/`basename $1`)
1662 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1663 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1668 export base=`basetest $1`
1669 [ "$CHECK_GRANT" == "no" ] && return 0
1671 testname=GCHECK_ONLY_${base}
1672 [ ${!testname}x == x ] && return 0
1674 echo -n "checking grant......"
1676 # write some data to sync client lost_grant
1677 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1678 for i in `seq $OSTCOUNT`; do
1679 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1680 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1681 count=1 > /dev/null 2>&1
1683 # sync all the data and make sure no pending data on server
1686 #get client grant and server grant
1688 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1689 client_grant=$((client_grant + $d))
1692 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1693 server_grant=$((server_grant + $d))
1696 # cleanup the check_grant file
1697 for i in `seq $OSTCOUNT`; do
1698 rm $DIR1/${tfile}_check_grant_$i
1701 #check whether client grant == server grant
1702 if [ $client_grant != $server_grant ]; then
1703 echo "failed: client:${client_grant} server: ${server_grant}"
1710 ########################
1716 ost=`echo $1 | awk -F_ '{print $3}'`
1717 if [ -z $ost ]; then
1718 ost=`echo $1 | sed 's/-osc.*//'`
1725 [ "$node" != "$(hostname)" ]
1730 remote_node $mds_HOST
1735 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1741 for node in $(osts_nodes) ; do
1742 remote_node $node && return 0
1749 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1753 remote_ost && remote_mds
1757 local OSTNODES=$(facet_host ost1)
1760 for num in `seq $OSTCOUNT`; do
1761 local myOST=$(facet_host ost$num)
1762 OSTNODES="$OSTNODES $myOST"
1764 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1770 # FIXME. We need a list of clients
1771 local myNODES=$HOSTNAME
1774 # CLIENTS (if specified) contains the local client
1775 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1777 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1778 myNODES="$myNODES $(osts_nodes) $mds_HOST"
1781 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1786 remote_nodes_list () {
1787 local rnodes=$(nodes_list)
1788 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1792 init_clients_lists () {
1793 # Sanity check: exclude the local client from RCLIENTS
1794 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1796 # Sanity check: exclude the dup entries
1797 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1799 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1801 # Sanity check: exclude the dup entries from CLIENTS
1802 # for those configs which has SINGLCLIENT set to local client
1803 clients=$(for i in $clients; do echo $i; done | sort -u)
1805 CLIENTS=`comma_list $clients`
1806 local -a remoteclients=($rclients)
1807 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1808 varname=CLIENT$((i + 2))
1809 eval $varname=${remoteclients[i]}
1812 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1815 get_random_entry () {
1818 rnodes=${rnodes//,/ }
1820 local nodes=($rnodes)
1821 local num=${#nodes[@]}
1822 local i=$((RANDOM * num / 65536))
1829 lctl get_param version | grep -q patchless
1833 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
1838 echo $nodes | wc -w || true
1842 local nodes=$(osts_nodes)
1843 local osscount=$(get_node_count "$nodes")
1844 [ ! "$OSTCOUNT" = "$osscount" ]
1847 generate_machine_file() {
1848 local nodes=${1//,/ }
1849 local machinefile=$2
1850 rm -f $machinefile || error "can't rm $machinefile"
1851 for node in $nodes; do
1852 echo $node >>$machinefile
1857 local file=$1/stripe
1859 $LFS getstripe -v $file || error
1863 check_runas_id_ret() {
1865 local myRUNAS_UID=$1
1866 local myRUNAS_GID=$2
1869 if [ -z "$myRUNAS" ]; then
1870 error_exit "myRUNAS command must be specified for check_runas_id"
1872 mkdir $DIR/d0_runas_test
1874 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
1875 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
1876 rm -rf $DIR/d0_runas_test
1881 local myRUNAS_UID=$1
1882 local myRUNAS_GID=$2
1885 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
1886 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
1887 Please set RUNAS_ID to some UID which exists on MDS and client or
1888 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
1891 # Run multiop in the background, but wait for it to print
1892 # "PAUSING" to its stdout before returning from this function.
1893 multiop_bg_pause() {
1894 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1898 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1901 echo "$MULTIOP_PROG $FILE v$ARGS"
1902 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1904 echo "TMPPIPE=${TMPPIPE}"
1905 local multiop_output
1908 read -t 60 multiop_output multiop_pid < $TMPPIPE
1909 if [ $? -ne 0 ]; then
1914 if [ "$multiop_output" != "PAUSING" ]; then
1915 echo "Incorrect multiop output: $multiop_output"
1926 local TARGET_RATE=$2
1927 local NUM_CLIENTS=$3
1930 local RATE=$(awk '/^Rate: [0-9\.]+ '"${OP}"'s\/sec/ { print $2}' ${LOG})
1932 # We need to use bc since the rate is a floating point number
1933 local RES=$(echo "${RATE} < ${TARGET_RATE}" | bc -l )
1934 if [ "${RES}" = 0 ]; then
1935 echo "Success: ${RATE} ${OP}s/sec met target rate" \
1936 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
1939 echo "Failure: ${RATE} ${OP}s/sec did not meet target rate" \
1940 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
1945 # reset llite stat counters
1946 clear_llite_stats(){
1947 lctl set_param -n llite.*.stats 0
1950 # sum llite stat items
1951 calc_llite_stats() {
1952 local res=$(lctl get_param -n llite.*.stats |
1953 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1958 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
1961 calc_osc_kbytes () {
1962 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
1965 # save_lustre_params(node, parameter_mask)
1966 # generate a stream of formatted strings (<node> <param name>=<param value>)
1967 save_lustre_params() {
1969 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1972 # restore lustre parameters from input stream, produces by save_lustre_params
1973 restore_lustre_params() {
1977 while IFS=" =" read node name val; do
1978 do_node $node "lctl set_param -n $name $val"
1982 check_catastrophe () {
1983 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
1985 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
1986 if [ $rnodes ]; then
1987 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2001 do_facet $1 lfs getstripe -v $2 > $tmp_file
2003 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2004 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2005 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2010 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2011 local command="$mpirun $@"
2013 if [ "$MPI_USER" != root -a $mpirun ]; then
2014 echo "+ chmod 0777 $MOUNT"
2016 command="su $MPI_USER sh -c \"$command \""
2024 delayed_recovery_enabled () {
2025 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1