2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
18 #export PDSH="pdsh -S -Rssh -w"
20 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
24 if [ -z "${!name}" ]; then
25 echo "$0: $name must be set"
29 [ $failed ] && exit 1 || true
34 [[ $DIR/ = $MOUNT/* ]] || \
35 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
36 [[ $DIR1/ = $MOUNT1/* ]] || \
37 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
38 [[ $DIR2/ = $MOUNT2/* ]] || \
39 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
41 [ -n "$failed" ] && exit 99 || true
45 echo "usage: $0 [-r] [-f cfgfile]"
52 [ "$TESTSUITE" == "lfscktest" ] && return 0
53 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
54 local form="%-13s %-17s %s\n"
55 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
56 echo "------------------------------------------------------------------------------------"
57 for O in $TESTSUITE_LIST; do
60 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
63 local log=${TMP}/${o}.log
64 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
65 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
66 [ "${!O}" = "done" ] && \
67 printf "$form" "Done" "$O" "E=$skipped" && \
68 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
72 for O in $TESTSUITE_LIST; do
73 [ "${!O}" = "no" ] && \
74 printf "$form" "Skipped" "$O" ""
77 for O in $TESTSUITE_LIST; do
78 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
79 printf "$form" "UNFINISHED" "$O" ""
84 export LUSTRE=`absolute_path $LUSTRE`
85 export TESTSUITE=`basename $0 .sh`
87 #[ -d /r ] && export ROOT=${ROOT:-/r}
88 export TMP=${TMP:-$ROOT/tmp}
89 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
90 export HOSTNAME=${HOSTNAME:-`hostname`}
91 if ! echo $PATH | grep -q $LUSTRE/utils; then
92 export PATH=$PATH:$LUSTRE/utils
94 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
95 export PATH=$PATH:$LUSTRE/utils/gss
97 if ! echo $PATH | grep -q $LUSTRE/tests; then
98 export PATH=$PATH:$LUSTRE/tests
100 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
101 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
102 if ! echo $PATH | grep -q $LUSTRE/test/racer; then
103 export PATH=$PATH:$LUSTRE/tests/racer
105 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
106 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
107 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
108 [ ! -f "$LFS" ] && export LFS=$(which lfs)
109 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
110 if [ ! -f "$L_GETIDENTITY" ]; then
111 if `which l_getidentity > /dev/null 2>&1`; then
112 export L_GETIDENTITY=$(which l_getidentity)
114 export L_GETIDENTITY=NONE
117 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
118 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
119 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
120 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
121 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
122 export FSYTPE=${FSTYPE:-"ldiskfs"}
123 export NAME=${NAME:-local}
124 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
125 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
126 export LGSSD=$(which lgssd)
127 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
128 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
129 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
131 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
134 if [ "$ACCEPTOR_PORT" ]; then
135 export PORT_OPT="--port $ACCEPTOR_PORT"
140 echo "Using GSS/krb5 ptlrpc security flavor"
141 which lgss_keyring > /dev/null 2>&1 || \
142 error "built with gss disabled! SEC=$SEC"
153 IDENTITY_UPCALL=false
157 # Paths on remote nodes, if different
158 export RLUSTRE=${RLUSTRE:-$LUSTRE}
159 export RPWD=${RPWD:-$PWD}
160 export I_MOUNTED=${I_MOUNTED:-"no"}
164 while getopts "rvwf:" opt $*; do
167 r) REFORMAT=--reformat;;
169 w) WRITECONF=writeconf;;
174 shift $((OPTIND - 1))
177 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
183 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
184 *) EXT=".ko"; USE_QUOTA=yes;;
191 BASE=`basename $module $EXT`
192 lsmod | grep -q ${BASE} || \
193 if [ -f ${LUSTRE}/${module}${EXT} ]; then
194 insmod ${LUSTRE}/${module}${EXT} $@
196 # must be testing a "make install" or "rpm" installation
197 # note failed to load ptlrpc_gss is considered not fatal
198 if [ "$BASE" == "ptlrpc_gss" ]; then
199 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
207 if [ -n "$MODPROBE" ]; then
211 if [ "$HAVE_MODULES" = true ]; then
217 echo Loading modules from $LUSTRE
218 load_module ../libcfs/libcfs/libcfs
219 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
220 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
221 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
222 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
223 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
224 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
225 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
226 echo "lnet options: '$LNETOPTS'"
227 # note that insmod will ignore anything in modprobe.conf
228 load_module ../lnet/lnet/lnet $LNETOPTS
229 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
230 load_module ../lnet/klnds/$LNETLND
231 load_module lvfs/lvfs
232 load_module obdclass/obdclass
233 load_module ptlrpc/ptlrpc
234 load_module ptlrpc/gss/ptlrpc_gss
235 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
243 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
244 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
245 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
250 load_module lvfs/fsfilt_$FSTYPE
254 load_module obdfilter/obdfilter
257 load_module llite/lustre
258 load_module llite/llite_lloop
260 rm -f $OGDB/ogdb-$HOSTNAME
261 [ -d /r ] && OGDB="/r/tmp"
262 $LCTL modules > $OGDB/ogdb-$HOSTNAME
264 # 'mount' doesn't look in $PATH, just sbin
265 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
269 if [ `uname -r | cut -c 3` -eq 4 ]; then
277 MODULES=$($LCTL modules | awk '{ print $2 }')
278 while [ -n "$MODULES" ]; do
280 $RMMOD $MODULES > /dev/null 2>&1 || true
281 MODULES=$($LCTL modules | awk '{ print $2 }')
282 if [ -z "$MODULES" ]; then
286 echo "waiting, $((MAX - WAIT)) secs left"
288 if [ $WAIT -eq $MAX ]; then
289 echo "LNET modules $MODULES will not unload"
296 unload_dep_module() {
298 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
300 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
301 for SUBMOD in $DEPS; do
302 unload_dep_module $SUBMOD
304 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
305 $RMMOD $MODULE || true
309 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
310 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
311 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
312 echo "$LEAK_LUSTRE" 1>&2
313 echo "$LEAK_PORTALS" 1>&2
314 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
315 log "Memory leaks detected"
316 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
322 wait_exit_ST client # bug 12845
324 lsmod | grep libcfs > /dev/null && $LCTL dl
325 unload_dep_module $FSTYPE
326 unload_dep_module libcfs
328 local MODULES=$($LCTL modules | awk '{ print $2 }')
329 if [ -n "$MODULES" ]; then
330 echo "Modules still loaded: "
332 if [ "$(lctl dl)" ]; then
333 echo "Lustre still loaded"
338 echo "Lustre stopped but LNET is still loaded, waiting..."
339 wait_for_lnet || return 3
345 check_mem_leak || return 254
347 echo "modules unloaded."
351 check_gss_daemon_facet() {
355 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
356 if [ $num -ne 1 ]; then
357 echo "$num instance of $dname on $facet"
366 do_facet $facet "killall -2 $@ 2>/dev/null || true"
369 start_gss_daemons() {
371 for num in `seq $MDSCOUNT`; do
372 do_facet mds$num "$LSVCGSSD -v"
374 do_facet mds$num "$LGSSD -v"
378 for num in `seq $OSTCOUNT`; do
379 do_facet ost$num "$LSVCGSSD -v"
382 # FIXME: is "client" the right facet name?
384 do_facet client "$LGSSD -v"
387 # wait daemons entering "stable" status
391 # check daemons are running
393 for num in `seq $MDSCOUNT`; do
394 check_gss_daemon_facet mds$num lsvcgssd
396 check_gss_daemon_facet mds$num lgssd
399 for num in `seq $OSTCOUNT`; do
400 check_gss_daemon_facet ost$num lsvcgssd
403 check_gss_daemon_facet client lgssd
408 for num in `seq $MDSCOUNT`; do
409 send_sigint mds$num lsvcgssd lgssd
411 for num in `seq $OSTCOUNT`; do
412 send_sigint ost$num lsvcgssd
414 send_sigint client lgssd
426 # maybe cleanup credential cache?
432 local device=`mdsdevname $num`
433 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
439 local device=`ostdevname $num`
440 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
448 local dev=${facet}_dev
449 local opt=${facet}_opt
450 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
451 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
453 if [ $RC -ne 0 ]; then
454 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
455 echo "Start of ${!dev} on ${facet} failed ${RC}"
457 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
458 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
459 lctl set_param debug_mb=${DEBUG_SIZE}; \
462 label=$(do_facet ${facet} "e2label ${!dev}")
463 [ -z "$label" ] && echo no label for ${!dev} && exit 1
464 eval export ${facet}_svc=${label}
465 echo Started ${label}
470 # start facet device options
476 eval export ${facet}_dev=${device}
477 eval export ${facet}_opt=\"$@\"
478 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
488 HOST=`facet_active_host $facet`
489 [ -z $HOST ] && echo stop: no host for $facet && return 0
491 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
492 if [ ${running} -ne 0 ]; then
493 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
494 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
497 # umount should block, but we should wait for unrelated obd's
498 # like the MGS or MGC to also stop.
499 wait_exit_ST ${facet}
506 # Only supply -o to mount if we have options
507 if [ -n "$MOUNTOPT" ]; then
508 OPTIONS="-o $MOUNTOPT"
510 local device=$MGSNID:/$FSNAME
511 if [ -z "$mnt" -o -z "$FSNAME" ]; then
512 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
516 echo "Starting client: $client: $OPTIONS $device $mnt"
517 do_node $client mkdir -p $mnt
518 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
520 do_node $client "lctl set_param debug=$PTLDEBUG;
521 lctl set_param subsystem_debug=${SUBSYSTEM# };
522 lctl set_param debug_mb=${DEBUG_SIZE}"
531 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
532 if [ $running -ne 0 ]; then
533 echo "Stopping client $client $mnt (opts:$force)"
534 lsof | grep "$mnt" || true
535 do_node $client umount $force $mnt
539 # mount clients if not mouted
540 zconf_mount_clients() {
546 # Only supply -o to mount if we have options
547 if [ -n "$MOUNTOPT" ]; then
548 OPTIONS="-o $MOUNTOPT"
550 local device=$MGSNID:/$FSNAME
551 if [ -z "$mnt" -o -z "$FSNAME" ]; then
552 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
556 echo "Starting client $clients: $OPTIONS $device $mnt"
557 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
559 echo "Started clients $clients: "
560 do_nodes $clients "mount | grep $mnt"
562 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
563 lctl set_param subsystem_debug=${SUBSYSTEM# };
564 lctl set_param debug_mb=${DEBUG_SIZE};"
569 zconf_umount_clients() {
574 echo "Umounting clients: $clients"
575 echo "Stopping clients: $clients $mnt (opts:$force)"
576 do_nodes $clients umount $force $mnt
581 if [ "$FAILURE_MODE" = HARD ]; then
582 $POWER_DOWN `facet_active_host $facet`
584 elif [ "$FAILURE_MODE" = SOFT ]; then
591 if [ "$FAILURE_MODE" = HARD ]; then
592 $POWER_UP `facet_active_host $facet`
600 if [ "$FAILURE_MODE" = HARD ]; then
605 # verify that lustre actually cleaned up properly
607 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
608 error "LBUG/LASSERT detected"
609 BUSY=`dmesg | grep -i destruct || true`
612 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
616 check_mem_leak || exit 204
618 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
619 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
621 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
622 echo "$0: modules still loaded..." 1>&2
629 wait_delete_completed () {
630 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
631 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
635 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
637 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
638 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
639 [ "$TOTAL" -eq "$TOTALPREV" ] && break
640 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
644 echo "Delete completed."
649 check_network "$HOST" 900
650 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
655 HOST=`facet_active_host $facet`
659 wait_mds_recovery_done () {
660 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
661 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
662 # as we are in process of changing obd_timeout in different ways
663 # let's set MAX longer than that
664 MAX=$(( timeout * 4 ))
666 while [ $WAIT -lt $MAX ]; do
667 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
668 echo $STATUS | grep COMPLETE && return 0
671 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
673 echo "MDS recovery not done in $MAX sec"
682 # conf-sanity 31 takes a long time cleanup
683 while [ $WAIT -lt 300 ]; do
684 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
685 [ -z "${running}" ] && return 0
686 echo "waited $WAIT for${running}"
687 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
689 WAIT=$((WAIT + INTERVAL))
691 echo "service didn't stop after $WAIT seconds. Still running:"
696 wait_remote_prog () {
702 [ "$PDSH" = "no_dsh" ] && return 0
704 while [ $WAIT -lt $2 ]; do
705 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
706 [ -z "${running}" ] && return 0 || true
707 echo "waited $WAIT for: "
709 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
711 WAIT=$((WAIT + INTERVAL))
713 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
714 [ -z "$pids" ] && return 0
715 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
717 cat /proc/${pid}/status || true
718 cat /proc/${pid}/wchan || true
729 # not every config has many clients
730 if [ ! -z "$CLIENTS" ]; then
731 $PDSH $CLIENTS "df $MOUNT" > /dev/null
733 df $MOUNT > /dev/null
738 uname -n >> $MOUNT/recon
739 if [ -z "$CLIENTS" ]; then
740 df $MOUNT; uname -n >> $MOUNT/recon
742 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
744 echo Connected clients:
746 ls -l $MOUNT/recon > /dev/null
753 echo "Failing $facet on node `facet_active_host $facet`"
754 shutdown_facet $facet
755 [ -n "$sleep_time" ] && sleep $sleep_time
759 echo "df pid is $DFPID"
761 TO=`facet_active_host $facet`
762 echo "Failover $facet to $TO"
764 mount_facet $facet || error "Restart of $facet failed"
775 local svc=${facet}_svc
776 do_facet $facet $LCTL --device %${!svc} readonly
777 do_facet $facet $LCTL --device %${!svc} notransno
778 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
779 $LCTL mark "local REPLAY BARRIER on ${!svc}"
782 replay_barrier_nodf() {
783 local facet=$1 echo running=${running}
785 local svc=${facet}_svc
786 echo Replay barrier on ${!svc}
787 do_facet $facet $LCTL --device %${!svc} readonly
788 do_facet $facet $LCTL --device %${!svc} notransno
789 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
790 $LCTL mark "local REPLAY BARRIER on ${!svc}"
793 replay_barrier_nosync() {
794 local facet=$1 echo running=${running}
795 local svc=${facet}_svc
796 echo Replay barrier on ${!svc}
797 do_facet $facet $LCTL --device %${!svc} readonly
798 do_facet $facet $LCTL --device %${!svc} notransno
799 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
800 $LCTL mark "local REPLAY BARRIER on ${!svc}"
804 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
805 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
809 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
810 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
814 facet_failover $* || error "failover: $?"
815 df $MOUNT || error "post-failover df: $?"
820 facet_failover $facet
827 mount_facet $facet -o abort_recovery
828 df $MOUNT || echo "first df failed: $?"
830 df $MOUNT || error "post-failover df: $?"
834 echo There is no lmc. This is mountconf, baby.
839 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
840 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
846 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
852 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
853 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
854 if [ -z "$ID" ]; then
855 echo "Could not get a ptl id for $1..."
864 h2name_or_ip "$1" "tcp"
869 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
870 if type __h2elan >/dev/null 2>&1; then
873 ID=`echo $1 | sed 's/[^0-9]*//g'`
881 h2name_or_ip "$1" "openib"
886 h2name_or_ip "$1" "o2ib"
892 varname=${facet}_HOST
893 if [ -z "${!varname}" ]; then
894 if [ "${facet:0:3}" == "ost" ]; then
895 eval ${facet}_HOST=${ost_HOST}
903 local activevar=${facet}active
905 if [ -f $TMP/${facet}active ] ; then
906 source $TMP/${facet}active
910 if [ -z "$active" ] ; then
917 facet_active_host() {
919 local active=`facet_active $facet`
920 if [ "$facet" == client ]; then
923 echo `facet_host $active`
929 failover=${facet}failover
930 host=`facet_host $failover`
931 [ -z "$host" ] && return
932 curactive=`facet_active $facet`
933 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
934 eval export ${facet}active=$facet
936 eval export ${facet}active=$failover
938 # save the active host for this facet
939 activevar=${facet}active
940 echo "$activevar=${!activevar}" > $TMP/$activevar
947 if [ "$HOST" = "$HOSTNAME" ]; then
949 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
950 echo "cannot run remote command on $HOST with $myPDSH"
954 echo "CMD: $HOST $@" >&2
955 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
958 if [ "$myPDSH" = "rsh" ]; then
959 # we need this because rsh does not return exit code of an executed command
960 local command_status="$TMP/cs"
961 rsh $HOST ":> $command_status"
962 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
963 cd $RPWD; sh -c \"$@\") ||
964 echo command failed >$command_status"
965 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
968 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
969 return ${PIPESTATUS[0]}
972 single_local_node () {
973 [ "$1" = "$HOSTNAME" ]
980 if $(single_local_node $rnodes); then
985 # This is part from do_node
988 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
989 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
992 echo "CMD: $rnodes $@" >&2
993 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
996 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
997 return ${PIPESTATUS[0]}
1003 HOST=`facet_active_host $facet`
1004 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1011 # make sure its not already running
1013 rm -f $TMP/${facet}active
1014 do_facet ${facet} $MKFS $*
1020 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1021 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1028 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1029 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1037 # make sure we are using the primary server, so test-framework will
1038 # be able to clean up properly.
1039 activemds=`facet_active mds1`
1040 if [ $activemds != "mds1" ]; then
1044 # assume client mount is local
1045 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1046 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1048 if [ -n "$CLIENTS" ]; then
1049 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1050 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1053 [ "$CLIENTONLY" ] && return
1054 # The add fn does rm ${facet}active file, this would be enough
1055 # if we use do_facet <facet> only after the facet added, but
1056 # currently we use do_facet mds in local.sh
1057 for num in `seq $MDSCOUNT`; do
1059 rm -f ${TMP}/mds${num}active
1062 for num in `seq $OSTCOUNT`; do
1064 rm -f $TMP/ost${num}active
1079 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1083 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1085 if [ ! -z $SEC ]; then
1086 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1087 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1088 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1092 # We need ldiskfs here, may as well load them all
1094 [ "$CLIENTONLY" ] && return
1095 echo "Formatting mdts, osts"
1096 for num in `seq $MDSCOUNT`; do
1097 echo "Format mds$num: $(mdsdevname $num)"
1099 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1101 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1105 for num in `seq $OSTCOUNT`; do
1106 echo "Format ost$num: $(ostdevname $num)"
1108 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1110 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1116 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1120 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1124 # 0: success, the old identity set already.
1125 # 1: success, the old identity does not set.
1130 local j=`expr $num - 1`
1131 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1133 if [ -z "$MDT" ]; then
1137 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1140 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1142 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1145 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1147 if [ $old = "NONE" ]; then
1156 zconf_umount `hostname` $1 || error "umount failed"
1157 zconf_mount `hostname` $1 || error "mount failed"
1164 do_facet $facet lsmod | grep -q obdclass || \
1165 do_facet $facet "modprobe obdclass"
1167 do_facet $facet "lctl set_param timeout=$timeout"
1170 writeconf_facet () {
1174 do_facet $facet "$TUNEFS --writeconf $dev"
1178 for num in `seq $MDSCOUNT`; do
1179 DEVNAME=$(mdsdevname $num)
1180 writeconf_facet mds$num $DEVNAME
1183 for num in `seq $OSTCOUNT`; do
1184 DEVNAME=$(ostdevname $num)
1185 writeconf_facet ost$num $DEVNAME
1192 if [ -z "$CLIENTONLY" ]; then
1193 echo "Setup mdts, osts"
1194 echo $WRITECONF | grep -q "writeconf" && \
1196 for num in `seq $MDSCOUNT`; do
1197 DEVNAME=$(mdsdevname $num)
1198 set_obd_timeout mds$num $TIMEOUT
1199 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1201 # We started mds, now we should set failover variables properly.
1202 # Set mds${num}failover_HOST if it is not set (the default failnode).
1203 local varname=mds${num}failover_HOST
1204 if [ -z "${!varname}" ]; then
1205 eval mds${num}failover_HOST=$(facet_host mds$num)
1208 if [ $IDENTITY_UPCALL != "default" ]; then
1209 switch_identity $num $IDENTITY_UPCALL
1212 for num in `seq $OSTCOUNT`; do
1213 DEVNAME=$(ostdevname $num)
1214 set_obd_timeout ost$num $TIMEOUT
1215 start ost$num $DEVNAME $OST_MOUNT_OPTS
1217 # We started ost$num, now we should set ost${num}failover variable properly.
1218 # Set ost${num}failover_HOST if it is not set (the default failnode).
1219 varname=ost${num}failover_HOST
1220 if [ -z "${!varname}" ]; then
1221 eval ost${num}failover_HOST=$(facet_host ost${num})
1226 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1228 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1230 if [ "$MOUNT_2" ]; then
1231 mount_client $MOUNT2
1232 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1235 # by remounting mdt before ost, initial connect from mdt to ost might
1236 # timeout because ost is not ready yet. wait some time to its fully
1237 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1238 # by a context negotiation rpc with $TIMEOUT.
1239 # FIXME better by monitoring import status.
1241 sleep $((TIMEOUT + 5))
1247 mounted_lustre_filesystems() {
1248 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1251 init_facet_vars () {
1258 eval export ${facet}_dev=${device}
1259 eval export ${facet}_opt=\"$@\"
1261 local dev=${facet}_dev
1262 local label=$(do_facet ${facet} "e2label ${!dev}")
1263 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1265 eval export ${facet}_svc=${label}
1267 local varname=${facet}failover_HOST
1268 if [ -z "${!varname}" ]; then
1269 eval $varname=$(facet_host $facet)
1273 init_facets_vars () {
1276 for num in `seq $MDSCOUNT`; do
1277 DEVNAME=`mdsdevname $num`
1278 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1281 for num in `seq $OSTCOUNT`; do
1282 DEVNAME=`ostdevname $num`
1283 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1290 echo Checking config lustre mounted on $mntpt
1291 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1292 if [ "$mgshost" != "$mgs_HOST" ]; then
1293 FAIL_ON_ERROR=true \
1294 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST
1295 Please use correct config or set mds_HOST correctly!"
1299 check_and_setup_lustre() {
1300 local MOUNTED=$(mounted_lustre_filesystems)
1301 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1302 [ "$REFORMAT" ] && formatall
1304 MOUNTED=$(mounted_lustre_filesystems | head -1)
1305 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1306 export I_MOUNTED=yes
1311 if [ "$ONLY" == "setup" ]; then
1316 cleanup_and_setup_lustre() {
1317 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1318 lctl set_param debug=0 || true
1320 if [ "$ONLY" == "cleanup" ]; then
1324 check_and_setup_lustre
1327 check_and_cleanup_lustre() {
1328 if [ "`mount | grep $MOUNT`" ]; then
1329 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1331 if [ "$I_MOUNTED" = "yes" ]; then
1332 cleanupall -f || error "cleanup failed"
1344 while [ $NETWORK -eq 0 ]; do
1345 ping -c 1 -w 3 $1 > /dev/null
1346 if [ $? -eq 0 ]; then
1350 echo "waiting for $1, $((MAX - WAIT)) secs left"
1353 if [ $WAIT -gt $MAX ]; then
1354 echo "Network not available"
1360 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1371 # the sed converts spaces to commas, but leaves the last space
1372 # alone, so the line doesn't end with a comma.
1373 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1377 (cd `dirname $1`; echo $PWD/`basename $1`)
1380 ##################################
1381 # Adaptive Timeouts funcs
1384 if [ -z "$AT_MAX_PATH" ]; then
1385 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1386 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1392 at_is_valid || error "invalid call"
1394 # only check mds, we assume at_max is the same on all nodes
1395 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1396 if [ $at_max -eq 0 ]; then
1406 at_is_valid || error "invalid call"
1408 # suppose that all ost-s has the same at_max set
1409 if [ $facet == "ost" ]; then
1410 do_facet ost1 "cat $AT_MAX_PATH"
1412 do_facet $facet "cat $AT_MAX_PATH"
1420 at_is_valid || error "invalid call"
1424 if [ $facet == "ost" ]; then
1425 for i in `seq $OSTCOUNT`; do
1426 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1428 elif [ $facet == "mds" ]; then
1429 for i in `seq $MDSCOUNT`; do
1430 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1433 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1438 ##################################
1442 # OBD_FAIL_MDS_ALL_REQUEST_NET
1444 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1445 do_facet client "$1" || RC=$?
1446 do_facet $SINGLEMDS lctl set_param fail_loc=0
1451 # OBD_FAIL_MDS_ALL_REPLY_NET
1453 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1454 do_facet client "$@" || RC=$?
1455 do_facet $SINGLEMDS lctl set_param fail_loc=0
1459 drop_reint_reply() {
1460 # OBD_FAIL_MDS_REINT_NET_REP
1462 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1463 do_facet client "$@" || RC=$?
1464 do_facet $SINGLEMDS lctl set_param fail_loc=0
1469 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1471 do_facet ost1 lctl set_param fail_loc=0x214
1472 do_facet client "$1" || RC=$?
1473 do_facet client "sync"
1474 do_facet ost1 lctl set_param fail_loc=0
1478 drop_ldlm_cancel() {
1479 #define OBD_FAIL_LDLM_CANCEL 0x304
1481 do_facet client lctl set_param fail_loc=0x304
1482 do_facet client "$@" || RC=$?
1483 do_facet client lctl set_param fail_loc=0
1487 drop_bl_callback() {
1488 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1490 do_facet client lctl set_param fail_loc=0x305
1491 do_facet client "$@" || RC=$?
1492 do_facet client lctl set_param fail_loc=0
1497 #define OBD_FAIL_LDLM_REPLY 0x30c
1499 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1500 do_facet client "$@" || RC=$?
1501 do_facet $SINGLEMDS lctl set_param fail_loc=0
1509 echo "clearing fail_loc on $facet"
1510 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1513 set_nodes_failloc () {
1517 for node in $nodes ; do
1518 do_node $node lctl set_param fail_loc=$2
1522 cancel_lru_locks() {
1523 $LCTL mark "cancel_lru_locks $1 start"
1524 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1525 $LCTL set_param -n $d=clear
1527 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1528 $LCTL mark "cancel_lru_locks $1 stop"
1533 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1534 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1535 echo "$DEFAULT_LRU_SIZE"
1540 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1543 lru_resize_disable()
1545 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1550 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1551 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1552 echo there is still data in page cache $FILE ?
1553 lctl get_param -n $FILE
1561 DEBUGSAVE="$(lctl get_param -n debug)"
1565 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1569 ##################################
1571 ##################################
1574 local TYPE=${TYPE:-"FAIL"}
1576 lctl set_param fail_loc=0 2>/dev/null || true
1577 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1578 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1579 echo "Dumping lctl log to $ERRLOG"
1580 # We need to dump the logs on all nodes
1581 local NODES=$(nodes_list)
1582 for NODE in $NODES; do
1583 do_node $NODE $LCTL dk $ERRLOG
1586 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1591 $FAIL_ON_ERROR && exit 1 || true
1599 # use only if we are ignoring failures for this test, bugno required.
1600 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1601 # e.g. error_ignore 5494 "your message"
1603 local TYPE="IGNORE (bz$1)"
1609 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1610 [ "$TESTSUITELOG" ] && \
1611 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1614 build_test_filter() {
1615 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1619 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1620 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1621 [ "$EXCEPT_SLOW" ] && \
1622 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1623 for E in $EXCEPT $ALWAYS_EXCEPT; do
1624 eval EXCEPT_${E}=true
1626 for E in $EXCEPT_SLOW; do
1627 eval EXCEPT_SLOW_${E}=true
1629 for G in $GRANT_CHECK_LIST; do
1630 eval GCHECK_ONLY_${G}=true
1639 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1642 # print a newline if the last test was skipped
1643 export LAST_SKIPPED=
1647 export base=`basetest $1`
1648 if [ ! -z "$ONLY" ]; then
1650 if [ ${!testname}x != x ]; then
1651 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1656 if [ ${!testname}x != x ]; then
1657 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1666 if [ ${!testname}x != x ]; then
1668 TESTNAME=test_$1 skip "skipping excluded test $1"
1671 testname=EXCEPT_$base
1672 if [ ${!testname}x != x ]; then
1674 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1677 testname=EXCEPT_SLOW_$1
1678 if [ ${!testname}x != x ]; then
1680 TESTNAME=test_$1 skip "skipping SLOW test $1"
1683 testname=EXCEPT_SLOW_$base
1684 if [ ${!testname}x != x ]; then
1686 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1696 EQUALS="======================================================================"
1700 local suffixlen=$((${#EQUALS} - ${#msg}))
1701 [ $suffixlen -lt 5 ] && suffixlen=5
1702 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1707 lsmod | grep lnet > /dev/null || load_modules
1719 local NODES=$(nodes_list)
1720 for NODE in $NODES; do
1721 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1727 strace -o $TMP/$1.strace -ttt $*
1729 log "FINISHED: $*: rc $RC"
1738 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1739 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1740 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1744 local myNODES=$(nodes_list)
1747 for NODE in $myNODES; do
1748 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1756 export tdir=d0.${TESTSUITE}/d${base}
1757 local SAVE_UMASK=`umask`
1761 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1763 export TESTNAME=test_$testnum
1764 test_${testnum} || error "test_$testnum failed with $?"
1768 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1769 check_catastrophe || error "LBUG/LASSERT detected"
1770 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1771 pass "($((`date +%s` - $BEFORE))s)"
1778 (cd `dirname $1`; echo $PWD/`basename $1`)
1782 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1783 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1788 export base=`basetest $1`
1789 [ "$CHECK_GRANT" == "no" ] && return 0
1791 testname=GCHECK_ONLY_${base}
1792 [ ${!testname}x == x ] && return 0
1794 echo -n "checking grant......"
1796 # write some data to sync client lost_grant
1797 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1798 for i in `seq $OSTCOUNT`; do
1799 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1800 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1801 count=1 > /dev/null 2>&1
1803 # sync all the data and make sure no pending data on server
1806 #get client grant and server grant
1808 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1809 client_grant=$((client_grant + $d))
1812 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1813 server_grant=$((server_grant + $d))
1816 # cleanup the check_grant file
1817 for i in `seq $OSTCOUNT`; do
1818 rm $DIR1/${tfile}_check_grant_$i
1821 #check whether client grant == server grant
1822 if [ $client_grant != $server_grant ]; then
1823 echo "failed: client:${client_grant} server: ${server_grant}"
1830 ########################
1836 ost=`echo $1 | awk -F_ '{print $3}'`
1837 if [ -z $ost ]; then
1838 ost=`echo $1 | sed 's/-osc.*//'`
1845 [ "$node" != "$(hostname)" ]
1851 for node in $(mdts_nodes); do
1852 remote_node $node && return 0
1859 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1865 for node in $(osts_nodes) ; do
1866 remote_node $node && return 0
1873 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1879 for num in `seq $MDSCOUNT`; do
1880 MDSNODES="$MDSNODES $(facet_host mds$num)"
1882 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1888 remote_ost && remote_mds
1892 local OSTNODES=$(facet_host ost1)
1895 for num in `seq $OSTCOUNT`; do
1896 local myOST=$(facet_host ost$num)
1897 OSTNODES="$OSTNODES $myOST"
1899 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1905 # FIXME. We need a list of clients
1906 local myNODES=$HOSTNAME
1909 # CLIENTS (if specified) contains the local client
1910 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1912 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1913 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1916 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1921 remote_nodes_list () {
1922 local rnodes=$(nodes_list)
1923 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1927 init_clients_lists () {
1928 # Sanity check: exclude the local client from RCLIENTS
1929 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1931 # Sanity check: exclude the dup entries
1932 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1934 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1936 # Sanity check: exclude the dup entries from CLIENTS
1937 # for those configs which has SINGLCLIENT set to local client
1938 clients=$(for i in $clients; do echo $i; done | sort -u)
1940 CLIENTS=`comma_list $clients`
1941 local -a remoteclients=($rclients)
1942 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1943 varname=CLIENT$((i + 2))
1944 eval $varname=${remoteclients[i]}
1947 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1952 lctl get_param version | grep -q patchless
1957 echo $nodes | wc -w || true
1961 local nodes=$(osts_nodes)
1962 local osscount=$(get_node_count "$nodes")
1963 [ ! "$OSTCOUNT" = "$osscount" ]
1967 local nodes=$(mdts_nodes)
1968 local mdtcount=$(get_node_count "$nodes")
1969 [ ! "$MDSCOUNT" = "$mdtcount" ]
1972 generate_machine_file() {
1973 local nodes=${1//,/ }
1974 local machinefile=$2
1975 rm -f $machinefile || error "can't rm $machinefile"
1976 for node in $nodes; do
1977 echo $node >>$machinefile
1982 local file=$1/stripe
1984 $LFS getstripe -v $file || error
1988 check_runas_id_ret() {
1993 if [ -z "$myRUNAS" ]; then
1994 error_exit "myRUNAS command must be specified for check_runas_id"
1997 $myRUNAS krb5_login.sh || \
1998 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2000 mkdir $DIR/d0_runas_test
2002 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
2003 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2004 rm -rf $DIR/d0_runas_test
2012 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
2013 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
2014 Please set RUNAS_ID to some UID which exists on MDS and client or
2015 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
2018 # Run multiop in the background, but wait for it to print
2019 # "PAUSING" to its stdout before returning from this function.
2020 multiop_bg_pause() {
2021 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2025 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2028 echo "$MULTIOP_PROG $FILE v$ARGS"
2029 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2031 echo "TMPPIPE=${TMPPIPE}"
2032 read -t 60 multiop_output < $TMPPIPE
2033 if [ $? -ne 0 ]; then
2038 if [ "$multiop_output" != "PAUSING" ]; then
2039 echo "Incorrect multiop output: $multiop_output"
2049 local TARGET_RATE=$2
2050 local NUM_CLIENTS=$3
2053 local RATE=$(awk '/^Rate: [0-9\.]+ '"${OP}"'s\/sec/ { print $2}' ${LOG})
2055 # We need to use bc since the rate is a floating point number
2056 local RES=$(echo "${RATE} < ${TARGET_RATE}" | bc -l )
2057 if [ ${RES} -eq 0 ]; then
2058 echo "Success: ${RATE} ${OP}s/sec met target rate" \
2059 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2062 echo "Failure: ${RATE} ${OP}s/sec did not meet target rate" \
2063 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2068 # reset llite stat counters
2069 clear_llite_stats(){
2070 lctl set_param -n llite.*.stats 0
2073 # sum llite stat items
2074 calc_llite_stats() {
2075 local res=$(lctl get_param -n llite.*.stats |
2076 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2080 # reset osc stat counters
2082 lctl set_param -n osc.*.osc_stats 0
2085 # sum osc stat items
2087 local res=$(lctl get_param -n osc.*.osc_stats |
2088 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2093 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2096 calc_osc_kbytes () {
2097 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2100 # save_lustre_params(node, parameter_mask)
2101 # generate a stream of formatted strings (<node> <param name>=<param value>)
2102 save_lustre_params() {
2104 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2107 # restore lustre parameters from input stream, produces by save_lustre_params
2108 restore_lustre_params() {
2112 while IFS=" =" read node name val; do
2113 do_node $node "lctl set_param -n $name $val"
2117 check_catastrophe () {
2118 local rnodes=$(comma_list $(remote_nodes_list))
2120 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && return 1
2121 if [ $rnodes ]; then
2122 do_nodes $rnodes "[ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"