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"
136 which lgss_keyring > /dev/null 2>&1 || \
137 error "built with gss disabled! SEC=$SEC"
148 IDENTITY_UPCALL=false
152 # Paths on remote nodes, if different
153 export RLUSTRE=${RLUSTRE:-$LUSTRE}
154 export RPWD=${RPWD:-$PWD}
155 export I_MOUNTED=${I_MOUNTED:-"no"}
159 while getopts "rvf:" opt $*; do
162 r) REFORMAT=--reformat;;
168 shift $((OPTIND - 1))
171 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
180 BASE=`basename $module $EXT`
181 lsmod | grep -q ${BASE} || \
182 if [ -f ${LUSTRE}/${module}${EXT} ]; then
183 insmod ${LUSTRE}/${module}${EXT} $@
185 # must be testing a "make install" or "rpm" installation
186 # note failed to load ptlrpc_gss is considered not fatal
187 if [ "$BASE" == "ptlrpc_gss" ]; then
188 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
196 if [ -n "$MODPROBE" ]; then
200 if [ "$HAVE_MODULES" = true ]; then
206 echo Loading modules from $LUSTRE
207 load_module ../libcfs/libcfs/libcfs
208 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
209 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
210 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
211 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
212 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
213 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
214 echo "lnet options: '$LNETOPTS'"
215 # note that insmod will ignore anything in modprobe.conf
216 load_module ../lnet/lnet/lnet $LNETOPTS
217 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
218 load_module ../lnet/klnds/$LNETLND
219 load_module lvfs/lvfs
220 load_module obdclass/obdclass
221 load_module ptlrpc/ptlrpc
222 load_module ptlrpc/gss/ptlrpc_gss
223 # Now, some modules depend on lquota without USE_QUOTA check,
224 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
225 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
226 load_module quota/lquota
234 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
235 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
236 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
241 load_module lvfs/fsfilt_$FSTYPE
245 load_module obdfilter/obdfilter
248 load_module llite/lustre
249 load_module llite/llite_lloop
250 rm -f $TMP/ogdb-$HOSTNAME
252 [ -d /r ] && OGDB="/r/tmp"
253 $LCTL modules > $OGDB/ogdb-$HOSTNAME
255 # 'mount' doesn't look in $PATH, just sbin
256 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
260 if [ `uname -r | cut -c 3` -eq 4 ]; then
268 MODULES=$($LCTL modules | awk '{ print $2 }')
269 while [ -n "$MODULES" ]; do
271 $RMMOD $MODULES > /dev/null 2>&1 || true
272 MODULES=$($LCTL modules | awk '{ print $2 }')
273 if [ -z "$MODULES" ]; then
277 echo "waiting, $((MAX - WAIT)) secs left"
279 if [ $WAIT -eq $MAX ]; then
280 echo "LNET modules $MODULES will not unload"
287 unload_dep_module() {
289 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
291 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
292 for SUBMOD in $DEPS; do
293 unload_dep_module $SUBMOD
295 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
296 $RMMOD $MODULE || true
300 wait_exit_ST client # bug 12845
302 lsmod | grep libcfs > /dev/null && $LCTL dl
303 unload_dep_module $FSTYPE
304 unload_dep_module libcfs
306 local MODULES=$($LCTL modules | awk '{ print $2 }')
307 if [ -n "$MODULES" ]; then
308 echo "Modules still loaded: "
310 if [ "$(lctl dl)" ]; then
311 echo "Lustre still loaded"
316 echo "Lustre stopped but LNET is still loaded, waiting..."
317 wait_for_lnet || return 3
323 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
324 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
325 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
326 echo "$LEAK_LUSTRE" 1>&2
327 echo "$LEAK_PORTALS" 1>&2
328 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
329 echo "Memory leaks detected"
330 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
333 echo "modules unloaded."
337 check_gss_daemon_facet() {
341 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
342 if [ $num -ne 1 ]; then
343 echo "$num instance of $dname on $facet"
352 do_facet $facet "killall -2 $@ 2>/dev/null || true"
355 start_gss_daemons() {
357 for num in `seq $MDSCOUNT`; do
358 do_facet mds$num "$LSVCGSSD -v"
360 do_facet mds$num "$LGSSD -v"
364 for num in `seq $OSTCOUNT`; do
365 do_facet ost$num "$LSVCGSSD -v"
368 # FIXME: is "client" the right facet name?
370 do_facet client "$LGSSD -v"
373 # wait daemons entering "stable" status
377 # check daemons are running
379 for num in `seq $MDSCOUNT`; do
380 check_gss_daemon_facet mds$num lsvcgssd
382 check_gss_daemon_facet mds$num lgssd
385 for num in `seq $OSTCOUNT`; do
386 check_gss_daemon_facet ost$num lsvcgssd
389 check_gss_daemon_facet client lgssd
394 for num in `seq $MDSCOUNT`; do
395 send_sigint mds$num lsvcgssd lgssd
397 for num in `seq $OSTCOUNT`; do
398 send_sigint ost$num lsvcgssd
400 send_sigint client lgssd
412 # maybe cleanup credential cache?
418 local device=`mdsdevname $num`
419 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
425 local device=`ostdevname $num`
426 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
434 local dev=${facet}_dev
435 local opt=${facet}_opt
436 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
437 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
439 if [ $RC -ne 0 ]; then
440 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
441 echo "Start of ${!dev} on ${facet} failed ${RC}"
443 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
444 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
445 lctl set_param debug_mb=${DEBUG_SIZE}; \
448 label=$(do_facet ${facet} "e2label ${!dev}")
449 [ -z "$label" ] && echo no label for ${!dev} && exit 1
450 eval export ${facet}_svc=${label}
451 echo Started ${label}
456 # start facet device options
462 eval export ${facet}_dev=${device}
463 eval export ${facet}_opt=\"$@\"
464 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
474 HOST=`facet_active_host $facet`
475 [ -z $HOST ] && echo stop: no host for $facet && return 0
477 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
478 if [ ${running} -ne 0 ]; then
479 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
480 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
483 # umount should block, but we should wait for unrelated obd's
484 # like the MGS or MGC to also stop.
485 wait_exit_ST ${facet}
492 # Only supply -o to mount if we have options
493 if [ -n "$MOUNTOPT" ]; then
494 OPTIONS="-o $MOUNTOPT"
496 local device=$MGSNID:/$FSNAME
497 if [ -z "$mnt" -o -z "$FSNAME" ]; then
498 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
502 echo "Starting client: $client: $OPTIONS $device $mnt"
503 do_node $client mkdir -p $mnt
504 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
506 do_node $client "lctl set_param debug=$PTLDEBUG;
507 lctl set_param subsystem_debug=${SUBSYSTEM# };
508 lctl set_param debug_mb=${DEBUG_SIZE}"
509 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
517 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
518 if [ $running -ne 0 ]; then
519 echo "Stopping client $client $mnt (opts:$force)"
520 lsof | grep "$mnt" || true
521 do_node $client umount $force $mnt
525 # mount clients if not mouted
526 zconf_mount_clients() {
532 # Only supply -o to mount if we have options
533 if [ -n "$MOUNTOPT" ]; then
534 OPTIONS="-o $MOUNTOPT"
536 local device=$MGSNID:/$FSNAME
537 if [ -z "$mnt" -o -z "$FSNAME" ]; then
538 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
542 echo "Starting client $clients: $OPTIONS $device $mnt"
543 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
545 echo "Started clients $clients: "
546 do_nodes $clients "mount | grep $mnt"
548 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
549 lctl set_param subsystem_debug=${SUBSYSTEM# };
550 lctl set_param debug_mb=${DEBUG_SIZE};"
555 zconf_umount_clients() {
560 echo "Umounting clients: $clients"
561 echo "Stopping clients: $clients $mnt (opts:$force)"
562 do_nodes $clients umount $force $mnt
567 if [ "$FAILURE_MODE" = HARD ]; then
568 $POWER_DOWN `facet_active_host $facet`
570 elif [ "$FAILURE_MODE" = SOFT ]; then
577 if [ "$FAILURE_MODE" = HARD ]; then
578 $POWER_UP `facet_active_host $facet`
584 # verify that lustre actually cleaned up properly
586 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
587 error "LBUG/LASSERT detected"
588 BUSY=`dmesg | grep -i destruct || true`
591 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
594 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
595 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
596 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
597 echo "$0: $LEAK_LUSTRE" 1>&2
598 echo "$0: $LEAK_PORTALS" 1>&2
599 echo "$0: Memory leak(s) detected..." 1>&2
600 mv $TMP/debug $TMP/debug-leak.`date +%s`
604 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
605 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
607 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
608 echo "$0: modules still loaded..." 1>&2
615 wait_delete_completed () {
616 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
617 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
621 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
623 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
624 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
625 [ "$TOTAL" -eq "$TOTALPREV" ] && break
626 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
630 echo "Delete completed."
635 check_network "$HOST" 900
636 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
641 HOST=`facet_active_host $facet`
645 wait_mds_recovery_done () {
646 local timeout=`do_facet mds lctl get_param -n timeout`
647 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
648 # as we are in process of changing obd_timeout in different ways
649 # let's set MAX longer than that
650 MAX=$(( timeout * 4 ))
652 while [ $WAIT -lt $MAX ]; do
653 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT*.recovery_status | grep status"`
654 echo $STATUS | grep COMPLETE && return 0
657 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
659 echo "MDS recovery not done in $MAX sec"
668 # conf-sanity 31 takes a long time cleanup
669 while [ $WAIT -lt 300 ]; do
670 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
671 [ -z "${running}" ] && return 0
672 echo "waited $WAIT for${running}"
673 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
675 WAIT=$((WAIT + INTERVAL))
677 echo "service didn't stop after $WAIT seconds. Still running:"
682 wait_remote_prog () {
688 [ "$PDSH" = "no_dsh" ] && return 0
690 while [ $WAIT -lt $2 ]; do
691 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep)
692 [ -z "${running}" ] && return 0
693 echo "waited $WAIT for: "
695 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
697 WAIT=$((WAIT + INTERVAL))
699 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
700 [ -z "$pids" ] && return 0
701 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
703 cat /proc/${pid}/status || true
704 cat /proc/${pid}/wchan || true
715 # not every config has many clients
716 if [ ! -z "$CLIENTS" ]; then
717 $PDSH $CLIENTS "df $MOUNT" > /dev/null
719 df $MOUNT > /dev/null
724 uname -n >> $MOUNT/recon
725 if [ ! -z "$CLIENTS" ]; then
726 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
728 echo Connected clients:
730 ls -l $MOUNT/recon > /dev/null
736 echo "Failing $facet on node `facet_active_host $facet`"
737 shutdown_facet $facet
741 echo "df pid is $DFPID"
743 TO=`facet_active_host $facet`
744 echo "Failover $facet to $TO"
746 mount_facet $facet || error "Restart of $facet failed"
757 local svc=${facet}_svc
758 do_facet $facet $LCTL --device %${!svc} readonly
759 do_facet $facet $LCTL --device %${!svc} notransno
760 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
761 $LCTL mark "local REPLAY BARRIER on ${!svc}"
764 replay_barrier_nodf() {
765 local facet=$1 echo running=${running}
767 local svc=${facet}_svc
768 echo Replay barrier on ${!svc}
769 do_facet $facet $LCTL --device %${!svc} readonly
770 do_facet $facet $LCTL --device %${!svc} notransno
771 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
772 $LCTL mark "local REPLAY BARRIER on ${!svc}"
776 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
777 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
781 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
782 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
786 facet_failover $* || error "failover: $?"
787 df $MOUNT || error "post-failover df: $?"
792 facet_failover $facet
799 mount_facet $facet -o abort_recovery
800 df $MOUNT || echo "first df failed: $?"
802 df $MOUNT || error "post-failover df: $?"
806 echo There is no lmc. This is mountconf, baby.
811 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
812 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
818 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
824 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
825 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
826 if [ -z "$ID" ]; then
827 echo "Could not get a ptl id for $1..."
836 h2name_or_ip "$1" "tcp"
841 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
842 if type __h2elan >/dev/null 2>&1; then
845 ID=`echo $1 | sed 's/[^0-9]*//g'`
853 h2name_or_ip "$1" "openib"
858 h2name_or_ip "$1" "o2ib"
864 varname=${facet}_HOST
865 if [ -z "${!varname}" ]; then
866 if [ "${facet:0:3}" == "ost" ]; then
867 eval ${facet}_HOST=${ost_HOST}
875 local activevar=${facet}active
877 if [ -f $TMP/${facet}active ] ; then
878 source $TMP/${facet}active
882 if [ -z "$active" ] ; then
889 facet_active_host() {
891 local active=`facet_active $facet`
892 if [ "$facet" == client ]; then
895 echo `facet_host $active`
901 failover=${facet}failover
902 host=`facet_host $failover`
903 [ -z "$host" ] && return
904 curactive=`facet_active $facet`
905 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
906 eval export ${facet}active=$facet
908 eval export ${facet}active=$failover
910 # save the active host for this facet
911 activevar=${facet}active
912 echo "$activevar=${!activevar}" > $TMP/$activevar
919 if [ "$HOST" = "$HOSTNAME" ]; then
921 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
922 echo "cannot run remote command on $HOST with $myPDSH"
926 echo "CMD: $HOST $@" >&2
927 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
930 if [ "$myPDSH" = "rsh" ]; then
931 # we need this because rsh does not return exit code of an executed command
932 local command_status="$TMP/cs"
933 rsh $HOST ":> $command_status"
934 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
935 cd $RPWD; sh -c \"$@\") ||
936 echo command failed >$command_status"
937 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
940 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
941 return ${PIPESTATUS[0]}
948 # This is part from do_node
951 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
952 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
955 echo "CMD: $rnodes $@" >&2
956 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
959 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
960 return ${PIPESTATUS[0]}
966 HOST=`facet_active_host $facet`
967 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
974 # make sure its not already running
976 rm -f $TMP/${facet}active
977 do_facet ${facet} $MKFS $*
983 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
984 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
991 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
992 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1000 # make sure we are using the primary server, so test-framework will
1001 # be able to clean up properly.
1002 activemds=`facet_active mds1`
1003 if [ $activemds != "mds1" ]; then
1007 # assume client mount is local
1008 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1009 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1011 if [ -n "$CLIENTS" ]; then
1012 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1013 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1016 [ "$CLIENTONLY" ] && return
1017 # The add fn does rm ${facet}active file, this would be enough
1018 # if we use do_facet <facet> only after the facet added, but
1019 # currently we use do_facet mds in local.sh
1020 for num in `seq $MDSCOUNT`; do
1022 rm -f ${TMP}/mds${num}active
1025 for num in `seq $OSTCOUNT`; do
1027 rm -f $TMP/ost${num}active
1042 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1046 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1048 if [ ! -z $SEC ]; then
1049 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1050 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1054 # We need ldiskfs here, may as well load them all
1056 [ "$CLIENTONLY" ] && return
1057 echo "Formatting mdts, osts"
1058 for num in `seq $MDSCOUNT`; do
1059 echo "Format mds$num: $(mdsdevname $num)"
1061 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1063 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1067 for num in `seq $OSTCOUNT`; do
1068 echo "Format ost$num: $(ostdevname $num)"
1070 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1072 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1078 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1082 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1086 # 0: success, the old identity set already.
1087 # 1: success, the old identity does not set.
1092 local j=`expr $num - 1`
1093 local MDT="`do_facet mds$num lctl get_param -N mdt.*MDT*$j | cut -d"." -f2 2>/dev/null || true`"
1095 if [ -z "$MDT" ]; then
1099 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1102 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1104 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1107 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1109 if [ $old = "NONE" ]; then
1118 zconf_umount `hostname` $1 || error "umount failed"
1119 zconf_mount `hostname` $1 || error "mount failed"
1126 do_facet $facet lsmod | grep -q obdclass || \
1127 do_facet $facet "modprobe obdclass"
1129 do_facet $facet "lctl set_param timeout=$timeout"
1135 if [ -z "$CLIENTONLY" ]; then
1136 echo "Setup mdts, osts"
1137 for num in `seq $MDSCOUNT`; do
1138 DEVNAME=$(mdsdevname $num)
1139 echo $REFORMAT | grep -q "reformat" \
1140 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1141 set_obd_timeout mds$num $TIMEOUT
1142 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1144 # We started mds, now we should set failover variables properly.
1145 # Set mds${num}failover_HOST if it is not set (the default failnode).
1146 local varname=mds${num}failover_HOST
1147 if [ -z "${!varname}" ]; then
1148 eval mds${num}failover_HOST=$(facet_host mds$num)
1151 if [ $IDENTITY_UPCALL != "default" ]; then
1152 switch_identity $num $IDENTITY_UPCALL
1155 for num in `seq $OSTCOUNT`; do
1156 DEVNAME=$(ostdevname $num)
1157 set_obd_timeout ost$num $TIMEOUT
1158 start ost$num $DEVNAME $OST_MOUNT_OPTS
1160 # We started ost$num, now we should set ost${num}failover variable properly.
1161 # Set ost${num}failover_HOST if it is not set (the default failnode).
1162 varname=ost${num}failover_HOST
1163 if [ -z "${!varname}" ]; then
1164 eval ost${num}failover_HOST=$(facet_host ost${num})
1169 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1171 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1173 if [ "$MOUNT_2" ]; then
1174 mount_client $MOUNT2
1175 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1178 # by remounting mdt before ost, initial connect from mdt to ost might
1179 # timeout because ost is not ready yet. wait some time to its fully
1180 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1181 # by a context negotiation rpc with $TIMEOUT.
1182 # FIXME better by monitoring import status.
1184 sleep $((TIMEOUT + 5))
1190 mounted_lustre_filesystems() {
1191 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1194 check_and_setup_lustre() {
1195 MOUNTED="`mounted_lustre_filesystems`"
1196 if [ -z "$MOUNTED" ]; then
1197 [ "$REFORMAT" ] && formatall
1199 MOUNTED="`mounted_lustre_filesystems`"
1200 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1201 export I_MOUNTED=yes
1203 if [ "$ONLY" == "setup" ]; then
1208 cleanup_and_setup_lustre() {
1209 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1210 lctl set_param debug=0 || true
1212 if [ "$ONLY" == "cleanup" ]; then
1216 check_and_setup_lustre
1219 check_and_cleanup_lustre() {
1220 if [ "`mount | grep $MOUNT`" ]; then
1221 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1223 if [ "$I_MOUNTED" = "yes" ]; then
1224 cleanupall -f || error "cleanup failed"
1236 while [ $NETWORK -eq 0 ]; do
1237 ping -c 1 -w 3 $1 > /dev/null
1238 if [ $? -eq 0 ]; then
1242 echo "waiting for $1, $((MAX - WAIT)) secs left"
1245 if [ $WAIT -gt $MAX ]; then
1246 echo "Network not available"
1252 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1263 # the sed converts spaces to commas, but leaves the last space
1264 # alone, so the line doesn't end with a comma.
1265 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1269 (cd `dirname $1`; echo $PWD/`basename $1`)
1272 ##################################
1273 # Adaptive Timeouts funcs
1276 if [ -z "$AT_MAX_PATH" ]; then
1277 AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
1278 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1284 at_is_valid || error "invalid call"
1286 # only check mds, we assume at_max is the same on all nodes
1287 local at_max=$(do_facet mds "cat $AT_MAX_PATH")
1288 if [ $at_max -eq 0 ]; then
1296 at_is_valid || error "invalid call"
1298 do_facet $1 "cat $AT_MAX_PATH"
1305 at_is_valid || error "invalid call"
1308 if [ $facet == "ost" ]; then
1309 for i in `seq $OSTCOUNT`; do
1310 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1312 elif [ $facet == "mds" ]; then
1313 for i in `seq $MDSCOUNT`; do
1314 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1317 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1322 ##################################
1326 # OBD_FAIL_MDS_ALL_REQUEST_NET
1328 do_facet mds lctl set_param fail_loc=0x123
1329 do_facet client "$1" || RC=$?
1330 do_facet mds lctl set_param fail_loc=0
1335 # OBD_FAIL_MDS_ALL_REPLY_NET
1337 do_facet mds lctl set_param fail_loc=0x122
1338 do_facet client "$@" || RC=$?
1339 do_facet mds lctl set_param fail_loc=0
1343 drop_reint_reply() {
1344 # OBD_FAIL_MDS_REINT_NET_REP
1346 do_facet mds lctl set_param fail_loc=0x119
1347 do_facet client "$@" || RC=$?
1348 do_facet mds lctl set_param fail_loc=0
1353 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1355 do_facet ost1 lctl set_param fail_loc=0x214
1356 do_facet client "$1" || RC=$?
1357 do_facet client "sync"
1358 do_facet ost1 lctl set_param fail_loc=0
1362 drop_ldlm_cancel() {
1363 #define OBD_FAIL_LDLM_CANCEL 0x304
1365 do_facet client lctl set_param fail_loc=0x304
1366 do_facet client "$@" || RC=$?
1367 do_facet client lctl set_param fail_loc=0
1371 drop_bl_callback() {
1372 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1374 do_facet client lctl set_param fail_loc=0x305
1375 do_facet client "$@" || RC=$?
1376 do_facet client lctl set_param fail_loc=0
1381 #define OBD_FAIL_LDLM_REPLY 0x30c
1383 do_facet mds lctl set_param fail_loc=0x30c
1384 do_facet client "$@" || RC=$?
1385 do_facet mds lctl set_param fail_loc=0
1393 echo "clearing fail_loc on $facet"
1394 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1397 set_nodes_failloc () {
1401 for node in $nodes ; do
1402 do_node $node lctl set_param fail_loc=$2
1406 set_nodes_failloc () {
1410 for node in $nodes ; do
1411 do_node $node lctl set_param fail_loc=$2
1415 cancel_lru_locks() {
1416 $LCTL mark "cancel_lru_locks $1 start"
1417 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1418 $LCTL set_param -n $d=clear
1420 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1421 $LCTL mark "cancel_lru_locks $1 stop"
1426 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1427 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1428 echo "$DEFAULT_LRU_SIZE"
1433 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1436 lru_resize_disable()
1438 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1443 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1444 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1445 echo there is still data in page cache $FILE ?
1446 lctl get_param -n $FILE
1454 DEBUGSAVE="$(lctl get_param -n debug)"
1458 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1462 ##################################
1464 ##################################
1467 local TYPE=${TYPE:-"FAIL"}
1469 lctl set_param fail_loc=0 2>/dev/null || true
1470 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1471 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1472 echo "Dumping lctl log to $ERRLOG"
1473 # We need to dump the logs on all nodes
1474 local NODES=$(nodes_list)
1475 for NODE in $NODES; do
1476 do_node $NODE $LCTL dk $ERRLOG
1479 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1484 $FAIL_ON_ERROR && exit 1 || true
1492 # use only if we are ignoring failures for this test, bugno required.
1493 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1494 # e.g. error_ignore 5494 "your message"
1496 local TYPE="IGNORE (bz$1)"
1502 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1503 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1506 build_test_filter() {
1507 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1511 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1512 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1513 [ "$EXCEPT_SLOW" ] && \
1514 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1515 for E in $EXCEPT $ALWAYS_EXCEPT; do
1516 eval EXCEPT_${E}=true
1518 for E in $EXCEPT_SLOW; do
1519 eval EXCEPT_SLOW_${E}=true
1521 for G in $GRANT_CHECK_LIST; do
1522 eval GCHECK_ONLY_${G}=true
1531 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1537 export base=`basetest $1`
1538 if [ ! -z "$ONLY" ]; then
1540 if [ ${!testname}x != x ]; then
1545 if [ ${!testname}x != x ]; then
1553 if [ ${!testname}x != x ]; then
1554 TESTNAME=test_$1 skip "skipping excluded test $1"
1557 testname=EXCEPT_$base
1558 if [ ${!testname}x != x ]; then
1559 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1562 testname=EXCEPT_SLOW_$1
1563 if [ ${!testname}x != x ]; then
1564 TESTNAME=test_$1 skip "skipping SLOW test $1"
1567 testname=EXCEPT_SLOW_$base
1568 if [ ${!testname}x != x ]; then
1569 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1578 EQUALS="======================================================================"
1582 local suffixlen=$((${#EQUALS} - ${#msg}))
1583 [ $suffixlen -lt 5 ] && suffixlen=5
1584 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1589 lsmod | grep lnet > /dev/null || load_modules
1600 local NODES=$(nodes_list)
1601 for NODE in $NODES; do
1602 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1608 strace -o $TMP/$1.strace -ttt $*
1610 log "FINISHED: $*: rc $RC"
1619 FFREE=`lctl get_param -n osd.*MDT*.filesfree`
1620 FTOTAL=`lctl get_param -n osd.*MDT*.filestotal`
1621 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1625 local myNODES=$(nodes_list)
1628 for NODE in $myNODES; do
1629 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1637 export tdir=d0.${TESTSUITE}/d${base}
1638 local SAVE_UMASK=`umask`
1642 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1644 export TESTNAME=test_$testnum
1645 test_${testnum} || error "test_$testnum failed with $?"
1649 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1650 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1651 error "LBUG/LASSERT detected"
1652 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1653 pass "($((`date +%s` - $BEFORE))s)"
1661 (cd `dirname $1`; echo $PWD/`basename $1`)
1665 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1666 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1671 export base=`basetest $1`
1672 [ "$CHECK_GRANT" == "no" ] && return 0
1674 testname=GCHECK_ONLY_${base}
1675 [ ${!testname}x == x ] && return 0
1677 echo -n "checking grant......"
1679 # write some data to sync client lost_grant
1680 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1681 for i in `seq $OSTCOUNT`; do
1682 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1683 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1684 count=1 > /dev/null 2>&1
1686 # sync all the data and make sure no pending data on server
1689 #get client grant and server grant
1691 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1692 client_grant=$((client_grant + $d))
1695 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1696 server_grant=$((server_grant + $d))
1699 # cleanup the check_grant file
1700 for i in `seq $OSTCOUNT`; do
1701 rm $DIR1/${tfile}_check_grant_$i
1704 #check whether client grant == server grant
1705 if [ $client_grant != $server_grant ]; then
1706 echo "failed: client:${client_grant} server: ${server_grant}"
1713 ########################
1719 ost=`echo $1 | awk -F_ '{print $3}'`
1720 if [ -z $ost ]; then
1721 ost=`echo $1 | sed 's/-osc.*//'`
1728 [ -z "$(lctl dl | grep mdt)" ]
1733 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1738 [ -z "$(lctl dl | grep ost)" ]
1743 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1747 local MDSNODES=$(facet_host $SINGLEMDS)
1750 # FIXME: Currenly we use only $SINGLEMDS,
1751 # should be fixed when we will start to test cmd.
1755 for num in `seq $MDSCOUNT`; do
1756 local myMDS=$(facet_host mds$num)
1757 MDSNODES="$MDSNODES $myMDS"
1759 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1765 local OSTNODES=$(facet_host ost1)
1768 for num in `seq $OSTCOUNT`; do
1769 local myOST=$(facet_host ost$num)
1770 OSTNODES="$OSTNODES $myOST"
1772 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1778 # FIXME. We need a list of clients
1779 local myNODES=$HOSTNAME
1782 # CLIENTS (if specified) contains the local client
1783 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1785 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1786 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1789 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1794 init_clients_lists () {
1795 # Sanity check: exclude the local client from RCLIENTS
1796 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1798 # Sanity check: exclude the dup entries
1799 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1801 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1803 # Sanity check: exclude the dup entries from CLIENTS
1804 # for those configs which has SINGLCLIENT set to local client
1805 clients=$(for i in $clients; do echo $i; done | sort -u)
1807 CLIENTS=`comma_list $clients`
1808 local -a remoteclients=($rclients)
1809 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1810 varname=CLIENT$((i + 2))
1811 eval $varname=${remoteclients[i]}
1814 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1819 lctl get_param version | grep -q patchless
1824 echo $nodes | wc -w || true
1828 local nodes=$(osts_nodes)
1829 local osscount=$(get_node_count "$nodes")
1830 [ ! "$OSTCOUNT" = "$osscount" ]
1833 check_runas_id_ret() {
1838 if [ -z "$myRUNAS" ]; then
1839 error_exit "myRUNAS command must be specified for check_runas_id"
1842 $myRUNAS krb5_login.sh || \
1843 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1845 mkdir $DIR/d0_runas_test
1847 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1848 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1849 rm -rf $DIR/d0_runas_test
1857 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1858 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1859 Please set RUNAS_ID to some UID which exists on MDS and client or
1860 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1863 # Run multiop in the background, but wait for it to print
1864 # "PAUSING" to its stdout before returning from this function.
1865 multiop_bg_pause() {
1866 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1870 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1873 echo "$MULTIOP_PROG $FILE v$ARGS"
1874 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1876 echo "TMPPIPE=${TMPPIPE}"
1877 read -t 60 multiop_output < $TMPPIPE
1878 if [ $? -ne 0 ]; then
1883 if [ "$multiop_output" != "PAUSING" ]; then
1884 echo "Incorrect multiop output: $multiop_output"
1892 # reset llite stat counters
1893 clear_llite_stats(){
1894 lctl set_param -n llite.*.stats 0
1897 # sum llite stat items
1898 calc_llite_stats() {
1899 local res=$(lctl get_param -n llite.*.stats |
1900 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1904 # save_lustre_params(node, parameter_mask)
1905 # generate a stream of formatted strings (<node> <param name>=<param value>)
1906 save_lustre_params() {
1908 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1911 # restore lustre parameters from input stream, produces by save_lustre_params
1912 restore_lustre_params() {
1916 while IFS=" =" read node name val; do
1917 do_node $node "lctl set_param -n $name $val"