2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
11 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
17 #export PDSH="pdsh -S -Rssh -w"
19 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
23 if [ -z "${!name}" ]; then
24 echo "$0: $name must be set"
28 [ $failed ] && exit 1 || true
33 [ -z "`echo :$DIR: | grep :$MOUNT:`" ] && \
34 failed=1 && echo "DIR not in $MOUNT. Aborting."
35 [ -z "`echo :$DIR1: | grep :$MOUNT1:`" ] && \
36 failed=1 && echo "DIR1 not in $MOUNT1. Aborting."
37 [ -z "`echo :$DIR2: | grep :$MOUNT2:`" ] && \
38 failed=1 && echo "DIR2 not in $MOUNT2. Aborting"
40 [ -n "$failed" ] && exit 99 || true
44 echo "usage: $0 [-r] [-f cfgfile]"
51 [ "$TESTSUITE" == "lfscktest" ] && return 0
52 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
53 local form="%-13s %-17s %s\n"
54 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
55 echo "------------------------------------------------------------------------------------"
56 for O in $TESTSUITE_LIST; do
59 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
62 local log=${TMP}/${o}.log
63 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
64 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
65 [ "${!O}" = "done" ] && \
66 printf "$form" "Done" "$O" "E=$skipped" && \
67 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
71 for O in $TESTSUITE_LIST; do
72 [ "${!O}" = "no" ] && \
73 printf "$form" "Skipped" "$O" ""
76 for O in $TESTSUITE_LIST; do
77 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
78 printf "$form" "UNFINISHED" "$O" ""
83 export LUSTRE=`absolute_path $LUSTRE`
84 export TESTSUITE=`basename $0 .sh`
86 [ -d /r ] && export ROOT=${ROOT:-/r}
87 export TMP=${TMP:-$ROOT/tmp}
88 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
89 export HOSTNAME=${HOSTNAME:-`hostname`}
90 if ! echo $PATH | grep -q $LUSTRE/utils; then
91 export PATH=$PATH:$LUSTRE/utils
93 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
94 export PATH=$PATH:$LUSTRE/utils/gss
96 if ! echo $PATH | grep -q $LUSTRE/tests; then
97 export PATH=$PATH:$LUSTRE/tests
99 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
100 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
101 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
102 [ ! -f "$LFS" ] && export LFS=$(which lfs)
103 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
104 if [ ! -f "$L_GETIDENTITY" ]; then
105 if `which l_getidentity > /dev/null 2>&1`; then
106 export L_GETIDENTITY=$(which l_getidentity)
108 export L_GETIDENTITY=NONE
111 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
112 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
113 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
114 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
115 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
116 export FSYTPE=${FSTYPE:-"ldiskfs"}
117 export NAME=${NAME:-local}
118 export LPROC=/proc/fs/lustre
119 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
120 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
121 export LGSSD=$(which lgssd)
122 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
123 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
124 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
126 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
129 if [ "$ACCEPTOR_PORT" ]; then
130 export PORT_OPT="--port $ACCEPTOR_PORT"
135 echo "Using GSS/krb5 ptlrpc security flavor"
146 IDENTITY_UPCALL=false
150 # Paths on remote nodes, if different
151 export RLUSTRE=${RLUSTRE:-$LUSTRE}
152 export RPWD=${RPWD:-$PWD}
153 export I_MOUNTED=${I_MOUNTED:-"no"}
157 while getopts "rvf:" opt $*; do
160 r) REFORMAT=--reformat;;
166 shift $((OPTIND - 1))
169 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
178 BASE=`basename $module $EXT`
179 lsmod | grep -q ${BASE} || \
180 if [ -f ${LUSTRE}/${module}${EXT} ]; then
181 insmod ${LUSTRE}/${module}${EXT} $@
183 # must be testing a "make install" or "rpm" installation
184 # note failed to load ptlrpc_gss is considered not fatal
185 if [ "$BASE" == "ptlrpc_gss" ]; then
186 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
194 if [ -n "$MODPROBE" ]; then
198 if [ "$HAVE_MODULES" = true ]; then
204 echo Loading modules from $LUSTRE
205 load_module ../libcfs/libcfs/libcfs
206 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
207 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
208 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
209 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
210 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
211 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
212 echo "lnet options: '$LNETOPTS'"
213 # note that insmod will ignore anything in modprobe.conf
214 load_module ../lnet/lnet/lnet $LNETOPTS
215 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
216 load_module ../lnet/klnds/$LNETLND
217 load_module lvfs/lvfs
218 load_module obdclass/obdclass
219 load_module ptlrpc/ptlrpc
220 load_module ptlrpc/gss/ptlrpc_gss
221 # Now, some modules depend on lquota without USE_QUOTA check,
222 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
223 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
224 load_module quota/lquota
232 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
233 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
234 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
239 load_module lvfs/fsfilt_$FSTYPE
243 load_module obdfilter/obdfilter
246 load_module llite/lustre
247 load_module llite/llite_lloop
248 rm -f $TMP/ogdb-$HOSTNAME
250 [ -d /r ] && OGDB="/r/tmp"
251 $LCTL modules > $OGDB/ogdb-$HOSTNAME
253 # 'mount' doesn't look in $PATH, just sbin
254 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
258 if [ `uname -r | cut -c 3` -eq 4 ]; then
266 MODULES=$($LCTL modules | awk '{ print $2 }')
267 while [ -n "$MODULES" ]; do
269 $RMMOD $MODULES > /dev/null 2>&1 || true
270 MODULES=$($LCTL modules | awk '{ print $2 }')
271 if [ -z "$MODULES" ]; then
275 echo "waiting, $((MAX - WAIT)) secs left"
277 if [ $WAIT -eq $MAX ]; then
278 echo "LNET modules $MODULES will not unload"
285 unload_dep_module() {
287 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
289 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
290 for SUBMOD in $DEPS; do
291 unload_dep_module $SUBMOD
293 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
294 $RMMOD $MODULE || true
298 wait_exit_ST client # bug 12845
300 lsmod | grep libcfs > /dev/null && $LCTL dl
301 unload_dep_module $FSTYPE
302 unload_dep_module libcfs
304 local MODULES=$($LCTL modules | awk '{ print $2 }')
305 if [ -n "$MODULES" ]; then
306 echo "Modules still loaded: "
308 if [ "$(lctl dl)" ]; then
309 echo "Lustre still loaded"
314 echo "Lustre stopped but LNET is still loaded, waiting..."
315 wait_for_lnet || return 3
321 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
322 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
323 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
324 echo "$LEAK_LUSTRE" 1>&2
325 echo "$LEAK_PORTALS" 1>&2
326 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
327 echo "Memory leaks detected"
328 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
331 echo "modules unloaded."
335 check_gss_daemon_facet() {
339 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
340 if [ $num -ne 1 ]; then
341 echo "$num instance of $dname on $facet"
350 do_facet $facet "killall -2 $@ 2>/dev/null || true"
353 start_gss_daemons() {
355 for num in `seq $MDSCOUNT`; do
356 do_facet mds$num "$LSVCGSSD -v"
358 do_facet mds$num "$LGSSD -v"
362 for num in `seq $OSTCOUNT`; do
363 do_facet ost$num "$LSVCGSSD -v"
366 # FIXME: is "client" the right facet name?
368 do_facet client "$LGSSD -v"
371 # wait daemons entering "stable" status
375 # check daemons are running
377 for num in `seq $MDSCOUNT`; do
378 check_gss_daemon_facet mds$num lsvcgssd
380 check_gss_daemon_facet mds$num lgssd
383 for num in `seq $OSTCOUNT`; do
384 check_gss_daemon_facet ost$num lsvcgssd
387 check_gss_daemon_facet client lgssd
392 for num in `seq $MDSCOUNT`; do
393 send_sigint mds$num lsvcgssd lgssd
395 for num in `seq $OSTCOUNT`; do
396 send_sigint ost$num lsvcgssd
398 send_sigint client lgssd
410 # maybe cleanup credential cache?
416 local device=`mdsdevname $num`
417 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
423 local device=`ostdevname $num`
424 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
432 local dev=${facet}_dev
433 local opt=${facet}_opt
434 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
435 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
437 if [ $RC -ne 0 ]; then
438 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
439 echo "Start of ${!dev} on ${facet} failed ${RC}"
441 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
442 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
443 lctl set_param debug_mb=${DEBUG_SIZE}; \
446 label=$(do_facet ${facet} "e2label ${!dev}")
447 [ -z "$label" ] && echo no label for ${!dev} && exit 1
448 eval export ${facet}_svc=${label}
449 echo Started ${label}
454 # start facet device options
460 eval export ${facet}_dev=${device}
461 eval export ${facet}_opt=\"$@\"
462 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
472 HOST=`facet_active_host $facet`
473 [ -z $HOST ] && echo stop: no host for $facet && return 0
475 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
476 if [ ${running} -ne 0 ]; then
477 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
478 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
481 # umount should block, but we should wait for unrelated obd's
482 # like the MGS or MGC to also stop.
483 wait_exit_ST ${facet}
490 # Only supply -o to mount if we have options
491 if [ -n "$MOUNTOPT" ]; then
492 OPTIONS="-o $MOUNTOPT"
494 local device=$MGSNID:/$FSNAME
495 if [ -z "$mnt" -o -z "$FSNAME" ]; then
496 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
500 echo "Starting client: $client: $OPTIONS $device $mnt"
501 do_node $client mkdir -p $mnt
502 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
504 do_node $client "lctl set_param debug=$PTLDEBUG;
505 lctl set_param subsystem_debug=${SUBSYSTEM# };
506 lctl set_param debug_mb=${DEBUG_SIZE}"
507 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
515 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
516 if [ $running -ne 0 ]; then
517 echo "Stopping client $client $mnt (opts:$force)"
518 lsof | grep "$mnt" || true
519 do_node $client umount $force $mnt
523 zconf_mount_clients() {
529 # Only supply -o to mount if we have options
530 if [ -n "$MOUNTOPT" ]; then
531 OPTIONS="-o $MOUNTOPT"
533 local device=$MGSNID:/$FSNAME
534 if [ -z "$mnt" -o -z "$FSNAME" ]; then
535 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
539 echo "Starting client $clients: $OPTIONS $device $mnt"
540 do_nodes $clients mkdir -p $mnt
541 do_nodes $clients mount -t lustre $OPTIONS $device $mnt || return 1
543 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
544 lctl set_param subsystem_debug=${SUBSYSTEM# };
545 lctl set_param debug_mb=${DEBUG_SIZE};"
550 zconf_umount_clients() {
555 echo "Umounting clients: $clients"
556 echo "Stopping client $client $mnt (opts:$force)"
557 do_nodes $clients umount $force $mnt
562 if [ "$FAILURE_MODE" = HARD ]; then
563 $POWER_DOWN `facet_active_host $facet`
565 elif [ "$FAILURE_MODE" = SOFT ]; then
572 if [ "$FAILURE_MODE" = HARD ]; then
573 $POWER_UP `facet_active_host $facet`
579 # verify that lustre actually cleaned up properly
581 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
582 error "LBUG/LASSERT detected"
583 BUSY=`dmesg | grep -i destruct || true`
586 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
589 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
590 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
591 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
592 echo "$0: $LEAK_LUSTRE" 1>&2
593 echo "$0: $LEAK_PORTALS" 1>&2
594 echo "$0: Memory leak(s) detected..." 1>&2
595 mv $TMP/debug $TMP/debug-leak.`date +%s`
599 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
600 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
602 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
603 echo "$0: modules still loaded..." 1>&2
610 wait_delete_completed () {
611 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
612 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
616 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
618 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
619 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
620 [ "$TOTAL" -eq "$TOTALPREV" ] && break
621 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
625 echo "Delete completed."
630 check_network "$HOST" 900
631 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
636 HOST=`facet_active_host $facet`
640 wait_mds_recovery_done () {
641 local timeout=`do_facet mds lctl get_param -n timeout`
642 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
643 # as we are in process of changing obd_timeout in different ways
644 # let's set MAX longer than that
645 MAX=$(( timeout * 4 ))
647 while [ $WAIT -lt $MAX ]; do
648 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT*.recovery_status | grep status"`
649 echo $STATUS | grep COMPLETE && return 0
652 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
654 echo "MDS recovery not done in $MAX sec"
663 # conf-sanity 31 takes a long time cleanup
664 while [ $WAIT -lt 300 ]; do
665 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
666 [ -z "${running}" ] && return 0
667 echo "waited $WAIT for${running}"
668 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
670 WAIT=$((WAIT + INTERVAL))
672 echo "service didn't stop after $WAIT seconds. Still running:"
677 wait_remote_prog () {
683 [ "$PDSH" = "no_dsh" ] && return 0
685 while [ $WAIT -lt $2 ]; do
686 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep)
687 [ -z "${running}" ] && return 0
688 echo "waited $WAIT for: "
690 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
692 WAIT=$((WAIT + INTERVAL))
694 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
695 [ -z "$pids" ] && return 0
696 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
698 cat /proc/${pid}/status || true
699 cat /proc/${pid}/wchan || true
710 # not every config has many clients
711 if [ ! -z "$CLIENTS" ]; then
712 $PDSH $CLIENTS "df $MOUNT" > /dev/null
714 df $MOUNT > /dev/null
719 uname -n >> $MOUNT/recon
720 if [ ! -z "$CLIENTS" ]; then
721 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
723 echo Connected clients:
725 ls -l $MOUNT/recon > /dev/null
731 echo "Failing $facet on node `facet_active_host $facet`"
732 shutdown_facet $facet
736 echo "df pid is $DFPID"
738 TO=`facet_active_host $facet`
739 echo "Failover $facet to $TO"
741 mount_facet $facet || error "Restart of $facet failed"
752 local svc=${facet}_svc
753 do_facet $facet $LCTL --device %${!svc} readonly
754 do_facet $facet $LCTL --device %${!svc} notransno
755 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
756 $LCTL mark "local REPLAY BARRIER on ${!svc}"
759 replay_barrier_nodf() {
760 local facet=$1 echo running=${running}
762 local svc=${facet}_svc
763 echo Replay barrier on ${!svc}
764 do_facet $facet $LCTL --device %${!svc} readonly
765 do_facet $facet $LCTL --device %${!svc} notransno
766 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
767 $LCTL mark "local REPLAY BARRIER on ${!svc}"
771 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
772 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
776 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
777 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
781 facet_failover $* || error "failover: $?"
782 df $MOUNT || error "post-failover df: $?"
787 facet_failover $facet
794 mount_facet $facet -o abort_recovery
795 df $MOUNT || echo "first df failed: $?"
797 df $MOUNT || error "post-failover df: $?"
801 echo There is no lmc. This is mountconf, baby.
806 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
807 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
813 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
819 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
820 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
821 if [ -z "$ID" ]; then
822 echo "Could not get a ptl id for $1..."
831 h2name_or_ip "$1" "tcp"
836 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
837 if type __h2elan >/dev/null 2>&1; then
840 ID=`echo $1 | sed 's/[^0-9]*//g'`
848 h2name_or_ip "$1" "openib"
853 h2name_or_ip "$1" "o2ib"
859 varname=${facet}_HOST
860 if [ -z "${!varname}" ]; then
861 if [ "${facet:0:3}" == "ost" ]; then
862 eval ${facet}_HOST=${ost_HOST}
870 local activevar=${facet}active
872 if [ -f $TMP/${facet}active ] ; then
873 source $TMP/${facet}active
877 if [ -z "$active" ] ; then
884 facet_active_host() {
886 local active=`facet_active $facet`
887 if [ "$facet" == client ]; then
890 echo `facet_host $active`
896 failover=${facet}failover
897 host=`facet_host $failover`
898 [ -z "$host" ] && return
899 curactive=`facet_active $facet`
900 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
901 eval export ${facet}active=$facet
903 eval export ${facet}active=$failover
905 # save the active host for this facet
906 activevar=${facet}active
907 echo "$activevar=${!activevar}" > $TMP/$activevar
914 if [ "$HOST" = "$HOSTNAME" ]; then
916 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
917 echo "cannot run remote command on $HOST with $myPDSH"
921 echo "CMD: $HOST $@" >&2
922 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
925 if [ "$myPDSH" = "rsh" ]; then
926 # we need this because rsh does not return exit code of an executed command
927 local command_status="$TMP/cs"
928 rsh $HOST ":> $command_status"
929 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
930 cd $RPWD; sh -c \"$@\") ||
931 echo command failed >$command_status"
932 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
935 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
936 return ${PIPESTATUS[0]}
944 # split list to local and remote
945 local rnodes=$(echo " $nodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
947 if [ "$(get_node_count $nodes)" != "$(get_node_count $rnodes)" ]; then
951 [ -z "$(echo $rnodes)" ] && return 0
953 # This is part from do_node
956 rnodes=$(comma_list $rnodes)
957 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ] && \
958 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
961 echo "CMD: $rnodes $@" >&2
962 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
965 if [ "$myPDSH" = "rsh" ]; then
966 # we need this because rsh does not return exit code of an executed command
967 local command_status="$TMP/cs"
968 rsh $rnodes ":> $command_status"
969 rsh $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
970 cd $RPWD; sh -c \"$@\") ||
971 echo command failed >$command_status"
972 [ -n "$($myPDSH $rnodes cat $command_status)" ] && return 1 || true
975 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
976 return ${PIPESTATUS[0]}
983 HOST=`facet_active_host $facet`
984 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
991 # make sure its not already running
993 rm -f $TMP/${facet}active
994 do_facet ${facet} $MKFS $*
1000 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1001 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1008 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1009 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1017 # make sure we are using the primary server, so test-framework will
1018 # be able to clean up properly.
1019 activemds=`facet_active mds1`
1020 if [ $activemds != "mds1" ]; then
1024 # assume client mount is local
1025 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1026 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1028 if [ -n "$CLIENTS" ]; then
1029 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1030 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1033 [ "$CLIENTONLY" ] && return
1034 # The add fn does rm ${facet}active file, this would be enough
1035 # if we use do_facet <facet> only after the facet added, but
1036 # currently we use do_facet mds in local.sh
1037 for num in `seq $MDSCOUNT`; do
1039 rm -f ${TMP}/mds${num}active
1042 for num in `seq $OSTCOUNT`; do
1044 rm -f $TMP/ost${num}active
1059 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1063 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1065 if [ ! -z $SEC ]; then
1066 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1067 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1071 # We need ldiskfs here, may as well load them all
1073 [ "$CLIENTONLY" ] && return
1074 echo "Formatting mdts, osts"
1075 for num in `seq $MDSCOUNT`; do
1076 echo "Format mds$num: $(mdsdevname $num)"
1078 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1080 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1084 for num in `seq $OSTCOUNT`; do
1085 echo "Format ost$num: $(ostdevname $num)"
1087 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1089 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1095 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1099 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1103 # 0: success, the old identity set already.
1104 # 1: success, the old identity does not set.
1109 local j=`expr $num - 1`
1110 local MDT="`do_facet mds$num lctl get_param -N mdt.*MDT*$j | cut -d"." -f2 2>/dev/null || true`"
1112 if [ -z "$MDT" ]; then
1116 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1119 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1121 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1124 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1126 if [ $old = "NONE" ]; then
1135 zconf_umount `hostname` $1 || error "umount failed"
1136 zconf_mount `hostname` $1 || error "mount failed"
1143 do_facet $facet lsmod | grep -q obdclass || \
1144 do_facet $facet "modprobe obdclass"
1146 do_facet $facet "lctl set_param timeout=$timeout"
1152 if [ -z "$CLIENTONLY" ]; then
1153 echo "Setup mdts, osts"
1154 for num in `seq $MDSCOUNT`; do
1155 DEVNAME=$(mdsdevname $num)
1156 echo $REFORMAT | grep -q "reformat" \
1157 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1158 set_obd_timeout mds$num $TIMEOUT
1159 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1161 # We started mds, now we should set failover variables properly.
1162 # Set mds${num}failover_HOST if it is not set (the default failnode).
1163 local varname=mds${num}failover_HOST
1164 if [ -z "${!varname}" ]; then
1165 eval mds${num}failover_HOST=$(facet_host mds$num)
1168 if [ $IDENTITY_UPCALL != "default" ]; then
1169 switch_identity $num $IDENTITY_UPCALL
1172 for num in `seq $OSTCOUNT`; do
1173 DEVNAME=$(ostdevname $num)
1174 set_obd_timeout ost$num $TIMEOUT
1175 start ost$num $DEVNAME $OST_MOUNT_OPTS
1177 # We started ost$num, now we should set ost${num}failover variable properly.
1178 # Set ost${num}failover_HOST if it is not set (the default failnode).
1179 varname=ost${num}failover_HOST
1180 if [ -z "${!varname}" ]; then
1181 eval ost${num}failover_HOST=$(facet_host ost${num})
1186 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1188 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1190 if [ "$MOUNT_2" ]; then
1191 mount_client $MOUNT2
1192 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1195 # by remounting mdt before ost, initial connect from mdt to ost might
1196 # timeout because ost is not ready yet. wait some time to its fully
1197 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1198 # by a context negotiation rpc with $TIMEOUT.
1199 # FIXME better by monitoring import status.
1201 sleep $((TIMEOUT + 5))
1207 mounted_lustre_filesystems() {
1208 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1211 check_and_setup_lustre() {
1212 MOUNTED="`mounted_lustre_filesystems`"
1213 if [ -z "$MOUNTED" ]; then
1214 [ "$REFORMAT" ] && formatall
1216 MOUNTED="`mounted_lustre_filesystems`"
1217 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1218 export I_MOUNTED=yes
1220 if [ "$ONLY" == "setup" ]; then
1225 cleanup_and_setup_lustre() {
1226 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1227 lctl set_param debug=0 || true
1229 if [ "$ONLY" == "cleanup" ]; then
1233 check_and_setup_lustre
1236 check_and_cleanup_lustre() {
1237 if [ "`mount | grep $MOUNT`" ]; then
1238 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1240 if [ "$I_MOUNTED" = "yes" ]; then
1241 cleanupall -f || error "cleanup failed"
1253 while [ $NETWORK -eq 0 ]; do
1254 ping -c 1 -w 3 $1 > /dev/null
1255 if [ $? -eq 0 ]; then
1259 echo "waiting for $1, $((MAX - WAIT)) secs left"
1262 if [ $WAIT -gt $MAX ]; then
1263 echo "Network not available"
1269 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1280 # the sed converts spaces to commas, but leaves the last space
1281 # alone, so the line doesn't end with a comma.
1282 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1286 (cd `dirname $1`; echo $PWD/`basename $1`)
1289 ##################################
1290 # Adaptive Timeouts funcs
1293 if [ -z "$AT_MAX_PATH" ]; then
1294 AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
1295 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1301 at_is_valid || error "invalid call"
1303 # only check mds, we assume at_max is the same on all nodes
1304 local at_max=$(do_facet mds "cat $AT_MAX_PATH")
1305 if [ $at_max -eq 0 ]; then
1313 at_is_valid || error "invalid call"
1315 do_facet $1 "cat $AT_MAX_PATH"
1322 at_is_valid || error "invalid call"
1325 if [ $facet == "ost" ]; then
1326 for i in `seq $OSTCOUNT`; do
1327 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1329 elif [ $facet == "mds" ]; then
1330 for i in `seq $MDSCOUNT`; do
1331 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1334 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1339 ##################################
1343 # OBD_FAIL_MDS_ALL_REQUEST_NET
1345 do_facet mds lctl set_param fail_loc=0x123
1346 do_facet client "$1" || RC=$?
1347 do_facet mds lctl set_param fail_loc=0
1352 # OBD_FAIL_MDS_ALL_REPLY_NET
1354 do_facet mds lctl set_param fail_loc=0x122
1355 do_facet client "$@" || RC=$?
1356 do_facet mds lctl set_param fail_loc=0
1360 drop_reint_reply() {
1361 # OBD_FAIL_MDS_REINT_NET_REP
1363 do_facet mds lctl set_param fail_loc=0x119
1364 do_facet client "$@" || RC=$?
1365 do_facet mds lctl set_param fail_loc=0
1370 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1372 do_facet ost1 lctl set_param fail_loc=0x214
1373 do_facet client "$1" || RC=$?
1374 do_facet client "sync"
1375 do_facet ost1 lctl set_param fail_loc=0
1379 drop_ldlm_cancel() {
1380 #define OBD_FAIL_LDLM_CANCEL 0x304
1382 do_facet client lctl set_param fail_loc=0x304
1383 do_facet client "$@" || RC=$?
1384 do_facet client lctl set_param fail_loc=0
1388 drop_bl_callback() {
1389 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1391 do_facet client lctl set_param fail_loc=0x305
1392 do_facet client "$@" || RC=$?
1393 do_facet client lctl set_param fail_loc=0
1398 #define OBD_FAIL_LDLM_REPLY 0x30c
1400 do_facet mds lctl set_param fail_loc=0x30c
1401 do_facet client "$@" || RC=$?
1402 do_facet mds lctl set_param fail_loc=0
1410 echo "clearing fail_loc on $facet"
1411 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1414 set_nodes_failloc () {
1418 for node in $nodes ; do
1419 do_node $node lctl set_param fail_loc=$2
1423 set_nodes_failloc () {
1427 for node in $nodes ; do
1428 do_node $node lctl set_param fail_loc=$2
1432 cancel_lru_locks() {
1433 $LCTL mark "cancel_lru_locks $1 start"
1434 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1435 lctl get_param ldlm.namespaces.*$1*.lock_unused_count | grep -v '=0'
1436 $LCTL mark "cancel_lru_locks $1 stop"
1441 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1442 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1443 echo "$DEFAULT_LRU_SIZE"
1448 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1451 lru_resize_disable()
1453 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1458 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1459 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1460 echo there is still data in page cache $FILE ?
1461 lctl get_param -n $FILE
1469 DEBUGSAVE="$(lctl get_param -n debug)"
1473 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1477 ##################################
1479 ##################################
1482 local TYPE=${TYPE:-"FAIL"}
1484 lctl set_param fail_loc=0 2>/dev/null || true
1485 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1486 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1487 echo "Dumping lctl log to $ERRLOG"
1488 # We need to dump the logs on all nodes
1489 local NODES=$(nodes_list)
1490 for NODE in $NODES; do
1491 do_node $NODE $LCTL dk $ERRLOG
1494 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1499 $FAIL_ON_ERROR && exit 1 || true
1507 # use only if we are ignoring failures for this test, bugno required.
1508 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1509 # e.g. error_ignore 5494 "your message"
1511 local TYPE="IGNORE (bz$1)"
1517 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1518 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1521 build_test_filter() {
1522 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1526 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1527 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1528 [ "$EXCEPT_SLOW" ] && \
1529 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1530 for E in $EXCEPT $ALWAYS_EXCEPT; do
1531 eval EXCEPT_${E}=true
1533 for E in $EXCEPT_SLOW; do
1534 eval EXCEPT_SLOW_${E}=true
1536 for G in $GRANT_CHECK_LIST; do
1537 eval GCHECK_ONLY_${G}=true
1546 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1552 export base=`basetest $1`
1553 if [ ! -z "$ONLY" ]; then
1555 if [ ${!testname}x != x ]; then
1560 if [ ${!testname}x != x ]; then
1568 if [ ${!testname}x != x ]; then
1569 TESTNAME=test_$1 skip "skipping excluded test $1"
1572 testname=EXCEPT_$base
1573 if [ ${!testname}x != x ]; then
1574 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1577 testname=EXCEPT_SLOW_$1
1578 if [ ${!testname}x != x ]; then
1579 TESTNAME=test_$1 skip "skipping SLOW test $1"
1582 testname=EXCEPT_SLOW_$base
1583 if [ ${!testname}x != x ]; then
1584 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1593 EQUALS="======================================================================"
1597 local suffixlen=$((${#EQUALS} - ${#msg}))
1598 [ $suffixlen -lt 5 ] && suffixlen=5
1599 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1604 lsmod | grep lnet > /dev/null || load_modules
1615 local NODES=$(nodes_list)
1616 for NODE in $NODES; do
1617 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1623 strace -o $TMP/$1.strace -ttt $*
1625 log "FINISHED: $*: rc $RC"
1634 FFREE=`lctl get_param -n osd.*MDT*.filesfree`
1635 FTOTAL=`lctl get_param -n osd.*MDT*.filestotal`
1636 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1640 local myNODES=$(nodes_list)
1643 for NODE in $myNODES; do
1644 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1652 export tdir=d0.${TESTSUITE}/d${base}
1653 local SAVE_UMASK=`umask`
1657 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1659 export TESTNAME=test_$testnum
1660 test_${testnum} || error "test_$testnum failed with $?"
1664 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1665 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1666 error "LBUG/LASSERT detected"
1667 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1668 pass "($((`date +%s` - $BEFORE))s)"
1676 (cd `dirname $1`; echo $PWD/`basename $1`)
1680 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1681 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1686 export base=`basetest $1`
1687 [ "$CHECK_GRANT" == "no" ] && return 0
1689 testname=GCHECK_ONLY_${base}
1690 [ ${!testname}x == x ] && return 0
1692 echo -n "checking grant......"
1694 # write some data to sync client lost_grant
1695 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1696 for i in `seq $OSTCOUNT`; do
1697 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1698 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1699 count=1 > /dev/null 2>&1
1701 # sync all the data and make sure no pending data on server
1704 #get client grant and server grant
1706 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1707 client_grant=$((client_grant + $d))
1710 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1711 server_grant=$((server_grant + $d))
1714 # cleanup the check_grant file
1715 for i in `seq $OSTCOUNT`; do
1716 rm $DIR1/${tfile}_check_grant_$i
1719 #check whether client grant == server grant
1720 if [ $client_grant != $server_grant ]; then
1721 echo "failed: client:${client_grant} server: ${server_grant}"
1728 ########################
1734 ost=`echo $1 | awk -F_ '{print $3}'`
1735 if [ -z $ost ]; then
1736 ost=`echo $1 | sed 's/-osc.*//'`
1743 [ -z "$(lctl dl | grep mdt)" ]
1748 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1753 [ -z "$(lctl dl | grep ost)" ]
1758 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1762 local MDSNODES=$(facet_host $SINGLEMDS)
1765 # FIXME: Currenly we use only $SINGLEMDS,
1766 # should be fixed when we will start to test cmd.
1770 for num in `seq $MDSCOUNT`; do
1771 local myMDS=$(facet_host mds$num)
1772 MDSNODES="$MDSNODES $myMDS"
1774 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1780 local OSTNODES=$(facet_host ost1)
1783 for num in `seq $OSTCOUNT`; do
1784 local myOST=$(facet_host ost$num)
1785 OSTNODES="$OSTNODES $myOST"
1787 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1793 # FIXME. We need a list of clients
1794 local myNODES=$HOSTNAME
1797 # CLIENTS (if specified) contains the local client
1798 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1800 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1801 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1804 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1811 lctl get_param version | grep -q patchless
1816 echo $nodes | wc -w || true
1820 local nodes=$(osts_nodes)
1821 local osscount=$(get_node_count "$nodes")
1822 [ ! "$OSTCOUNT" = "$osscount" ]
1825 check_runas_id_ret() {
1830 if [ -z "$myRUNAS" ]; then
1831 error_exit "myRUNAS command must be specified for check_runas_id"
1834 $myRUNAS krb5_login.sh || \
1835 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1837 mkdir $DIR/d0_runas_test
1839 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1840 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1841 rm -rf $DIR/d0_runas_test
1849 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1850 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1851 Please set RUNAS_ID to some UID which exists on MDS and client or
1852 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1855 # Run multiop in the background, but wait for it to print
1856 # "PAUSING" to its stdout before returning from this function.
1857 multiop_bg_pause() {
1858 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1862 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1865 echo "$MULTIOP_PROG $FILE v$ARGS"
1866 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1868 echo "TMPPIPE=${TMPPIPE}"
1869 read -t 60 multiop_output < $TMPPIPE
1870 if [ $? -ne 0 ]; then
1875 if [ "$multiop_output" != "PAUSING" ]; then
1876 echo "Incorrect multiop output: $multiop_output"
1884 # reset llite stat counters
1885 clear_llite_stats(){
1886 lctl set_param -n llite.*.stats 0
1889 # sum llite stat items
1890 calc_llite_stats() {
1891 local res=$(lctl get_param -n llite.*.stats |
1892 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1896 # save_lustre_params(node, parameter_mask)
1897 # generate a stream of formatted strings (<node> <param name>=<param value>)
1898 save_lustre_params() {
1900 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1903 # restore lustre parameters from input stream, produces by save_lustre_params
1904 restore_lustre_params() {
1908 while IFS=" =" read node name val; do
1909 do_node $node "lctl set_param -n $name $val"