2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
25 if [ -z "${!name}" ]; then
26 echo "$0: $name must be set"
30 [ $failed ] && exit 1 || true
35 [[ $DIR/ = $MOUNT/* ]] || \
36 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
37 [[ $DIR1/ = $MOUNT1/* ]] || \
38 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
39 [[ $DIR2/ = $MOUNT2/* ]] || \
40 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
42 [ -n "$failed" ] && exit 99 || true
46 echo "usage: $0 [-r] [-f cfgfile]"
53 [ "$TESTSUITE" == "lfscktest" ] && return 0
54 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
55 local form="%-13s %-17s %s\n"
56 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
57 echo "------------------------------------------------------------------------------------"
58 for O in $TESTSUITE_LIST; do
61 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
64 local log=${TMP}/${o}.log
65 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
66 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
67 [ "${!O}" = "done" ] && \
68 printf "$form" "Done" "$O" "E=$skipped" && \
69 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
73 for O in $TESTSUITE_LIST; do
74 [ "${!O}" = "no" ] && \
75 printf "$form" "Skipped" "$O" ""
78 for O in $TESTSUITE_LIST; do
79 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
80 printf "$form" "UNFINISHED" "$O" ""
85 export LUSTRE=`absolute_path $LUSTRE`
86 export TESTSUITE=`basename $0 .sh`
88 #[ -d /r ] && export ROOT=${ROOT:-/r}
89 export TMP=${TMP:-$ROOT/tmp}
90 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
91 export HOSTNAME=${HOSTNAME:-`hostname`}
92 if ! echo $PATH | grep -q $LUSTRE/utils; then
93 export PATH=$PATH:$LUSTRE/utils
95 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
96 export PATH=$PATH:$LUSTRE/utils/gss
98 if ! echo $PATH | grep -q $LUSTRE/tests; then
99 export PATH=$PATH:$LUSTRE/tests
101 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
102 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
103 if ! echo $PATH | grep -q $LUSTRE/test/racer; then
104 export PATH=$PATH:$LUSTRE/tests/racer
106 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
107 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
108 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
109 [ ! -f "$LFS" ] && export LFS=$(which lfs)
110 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
111 if [ ! -f "$L_GETIDENTITY" ]; then
112 if `which l_getidentity > /dev/null 2>&1`; then
113 export L_GETIDENTITY=$(which l_getidentity)
115 export L_GETIDENTITY=NONE
118 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
119 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
120 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
121 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
122 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
123 export FSYTPE=${FSTYPE:-"ldiskfs"}
124 export NAME=${NAME:-local}
125 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
126 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
127 export LGSSD=$(which lgssd)
128 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
129 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
130 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
132 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
135 if [ "$ACCEPTOR_PORT" ]; then
136 export PORT_OPT="--port $ACCEPTOR_PORT"
141 echo "Using GSS/krb5 ptlrpc security flavor"
142 which lgss_keyring > /dev/null 2>&1 || \
143 error "built with gss disabled! SEC=$SEC"
154 IDENTITY_UPCALL=false
158 # Paths on remote nodes, if different
159 export RLUSTRE=${RLUSTRE:-$LUSTRE}
160 export RPWD=${RPWD:-$PWD}
161 export I_MOUNTED=${I_MOUNTED:-"no"}
165 while getopts "rvwf:" opt $*; do
168 r) REFORMAT=--reformat;;
170 w) WRITECONF=writeconf;;
175 shift $((OPTIND - 1))
178 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
184 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
185 *) EXT=".ko"; USE_QUOTA=yes;;
192 BASE=`basename $module $EXT`
193 lsmod | grep -q ${BASE} || \
194 if [ -f ${LUSTRE}/${module}${EXT} ]; then
195 insmod ${LUSTRE}/${module}${EXT} $@
197 # must be testing a "make install" or "rpm" installation
198 # note failed to load ptlrpc_gss is considered not fatal
199 if [ "$BASE" == "ptlrpc_gss" ]; then
200 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
208 if [ -n "$MODPROBE" ]; then
212 if [ "$HAVE_MODULES" = true ]; then
218 echo Loading modules from $LUSTRE
219 load_module ../libcfs/libcfs/libcfs
220 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
221 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
223 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
224 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
225 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
226 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
227 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
228 echo "lnet options: '$LNETOPTS'"
229 # note that insmod will ignore anything in modprobe.conf
230 load_module ../lnet/lnet/lnet $LNETOPTS
231 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
232 load_module ../lnet/klnds/$LNETLND
233 load_module lvfs/lvfs
234 load_module obdclass/obdclass
235 load_module ptlrpc/ptlrpc
236 load_module ptlrpc/gss/ptlrpc_gss
237 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
245 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
246 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
247 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
252 load_module lvfs/fsfilt_$FSTYPE
256 load_module obdfilter/obdfilter
259 load_module llite/lustre
260 load_module llite/llite_lloop
262 rm -f $OGDB/ogdb-$HOSTNAME
263 [ -d /r ] && OGDB="/r/tmp"
264 $LCTL modules > $OGDB/ogdb-$HOSTNAME
266 # 'mount' doesn't look in $PATH, just sbin
267 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
271 if [ `uname -r | cut -c 3` -eq 4 ]; then
279 MODULES=$($LCTL modules | awk '{ print $2 }')
280 while [ -n "$MODULES" ]; do
282 $RMMOD $MODULES > /dev/null 2>&1 || true
283 MODULES=$($LCTL modules | awk '{ print $2 }')
284 if [ -z "$MODULES" ]; then
288 echo "waiting, $((MAX - WAIT)) secs left"
290 if [ $WAIT -eq $MAX ]; then
291 echo "LNET modules $MODULES will not unload"
298 unload_dep_module() {
300 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
302 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
303 for SUBMOD in $DEPS; do
304 unload_dep_module $SUBMOD
306 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
307 $RMMOD $MODULE || true
311 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
312 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
313 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
314 echo "$LEAK_LUSTRE" 1>&2
315 echo "$LEAK_PORTALS" 1>&2
316 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
317 echo "Memory leaks detected"
318 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
324 wait_exit_ST client # bug 12845
326 lsmod | grep libcfs > /dev/null && $LCTL dl
327 unload_dep_module $FSTYPE
328 unload_dep_module libcfs
330 local MODULES=$($LCTL modules | awk '{ print $2 }')
331 if [ -n "$MODULES" ]; then
332 echo "Modules still loaded: "
334 if [ "$(lctl dl)" ]; then
335 echo "Lustre still loaded"
340 echo "Lustre stopped but LNET is still loaded, waiting..."
341 wait_for_lnet || return 3
347 check_mem_leak || return 254
349 echo "modules unloaded."
353 check_gss_daemon_facet() {
357 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
358 if [ $num -ne 1 ]; then
359 echo "$num instance of $dname on $facet"
368 do_facet $facet "killall -2 $@ 2>/dev/null || true"
371 start_gss_daemons() {
373 for num in `seq $MDSCOUNT`; do
374 do_facet mds$num "$LSVCGSSD -v"
376 do_facet mds$num "$LGSSD -v"
380 for num in `seq $OSTCOUNT`; do
381 do_facet ost$num "$LSVCGSSD -v"
384 # FIXME: is "client" the right facet name?
386 do_facet client "$LGSSD -v"
389 # wait daemons entering "stable" status
393 # check daemons are running
395 for num in `seq $MDSCOUNT`; do
396 check_gss_daemon_facet mds$num lsvcgssd
398 check_gss_daemon_facet mds$num lgssd
401 for num in `seq $OSTCOUNT`; do
402 check_gss_daemon_facet ost$num lsvcgssd
405 check_gss_daemon_facet client lgssd
410 for num in `seq $MDSCOUNT`; do
411 send_sigint mds$num lsvcgssd lgssd
413 for num in `seq $OSTCOUNT`; do
414 send_sigint ost$num lsvcgssd
416 send_sigint client lgssd
428 # maybe cleanup credential cache?
434 local device=`mdsdevname $num`
435 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
441 local device=`ostdevname $num`
442 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
450 local dev=${facet}_dev
451 local opt=${facet}_opt
452 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
453 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
455 if [ $RC -ne 0 ]; then
456 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
457 echo "Start of ${!dev} on ${facet} failed ${RC}"
459 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
460 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
461 lctl set_param debug_mb=${DEBUG_SIZE}; \
464 label=$(do_facet ${facet} "e2label ${!dev}")
465 [ -z "$label" ] && echo no label for ${!dev} && exit 1
466 eval export ${facet}_svc=${label}
467 echo Started ${label}
472 # start facet device options
478 eval export ${facet}_dev=${device}
479 eval export ${facet}_opt=\"$@\"
480 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
490 HOST=`facet_active_host $facet`
491 [ -z $HOST ] && echo stop: no host for $facet && return 0
493 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
494 if [ ${running} -ne 0 ]; then
495 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
496 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
499 # umount should block, but we should wait for unrelated obd's
500 # like the MGS or MGC to also stop.
501 wait_exit_ST ${facet}
508 # Only supply -o to mount if we have options
509 if [ -n "$MOUNTOPT" ]; then
510 OPTIONS="-o $MOUNTOPT"
512 local device=$MGSNID:/$FSNAME
513 if [ -z "$mnt" -o -z "$FSNAME" ]; then
514 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
518 echo "Starting client: $client: $OPTIONS $device $mnt"
519 do_node $client mkdir -p $mnt
520 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
522 do_node $client "lctl set_param debug=$PTLDEBUG;
523 lctl set_param subsystem_debug=${SUBSYSTEM# };
524 lctl set_param debug_mb=${DEBUG_SIZE}"
533 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
534 if [ $running -ne 0 ]; then
535 echo "Stopping client $client $mnt (opts:$force)"
536 lsof | grep "$mnt" || true
537 do_node $client umount $force $mnt
541 # mount clients if not mouted
542 zconf_mount_clients() {
548 # Only supply -o to mount if we have options
549 if [ -n "$MOUNTOPT" ]; then
550 OPTIONS="-o $MOUNTOPT"
552 local device=$MGSNID:/$FSNAME
553 if [ -z "$mnt" -o -z "$FSNAME" ]; then
554 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
558 echo "Starting client $clients: $OPTIONS $device $mnt"
559 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
561 echo "Started clients $clients: "
562 do_nodes $clients "mount | grep $mnt"
564 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
565 lctl set_param subsystem_debug=${SUBSYSTEM# };
566 lctl set_param debug_mb=${DEBUG_SIZE};"
571 zconf_umount_clients() {
576 echo "Umounting clients: $clients"
577 echo "Stopping clients: $clients $mnt (opts:$force)"
578 do_nodes $clients umount $force $mnt
583 if [ "$FAILURE_MODE" = HARD ]; then
584 $POWER_DOWN `facet_active_host $facet`
586 elif [ "$FAILURE_MODE" = SOFT ]; then
593 if [ "$FAILURE_MODE" = HARD ]; then
594 $POWER_UP `facet_active_host $facet`
602 if [ "$FAILURE_MODE" = HARD ]; then
607 # verify that lustre actually cleaned up properly
609 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
610 error "LBUG/LASSERT detected"
611 BUSY=`dmesg | grep -i destruct || true`
614 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
618 check_mem_leak || exit 204
620 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
621 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
623 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
624 echo "$0: modules still loaded..." 1>&2
631 wait_delete_completed () {
632 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
633 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
637 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
639 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
640 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
641 [ "$TOTAL" -eq "$TOTALPREV" ] && break
642 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
646 echo "Delete completed."
651 check_network "$HOST" 900
652 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
657 HOST=`facet_active_host $facet`
661 wait_mds_recovery_done () {
662 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
663 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
664 # as we are in process of changing obd_timeout in different ways
665 # let's set MAX longer than that
666 MAX=$(( timeout * 4 ))
668 while [ $WAIT -lt $MAX ]; do
669 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
670 echo $STATUS | grep COMPLETE && return 0
673 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
675 echo "MDS recovery not done in $MAX sec"
685 # conf-sanity 31 takes a long time cleanup
686 while [ $WAIT -lt 300 ]; do
687 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
688 [ -z "${running}" ] && return 0
689 echo "waited $WAIT for${running}"
690 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
692 WAIT=$((WAIT + INTERVAL))
694 echo "service didn't stop after $WAIT seconds. Still running:"
699 wait_remote_prog () {
705 [ "$PDSH" = "no_dsh" ] && return 0
707 while [ $WAIT -lt $2 ]; do
708 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
709 [ -z "${running}" ] && return 0 || true
710 echo "waited $WAIT for: "
712 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
714 WAIT=$((WAIT + INTERVAL))
716 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
717 [ -z "$pids" ] && return 0
718 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
720 cat /proc/${pid}/status || true
721 cat /proc/${pid}/wchan || true
732 # not every config has many clients
733 if [ ! -z "$CLIENTS" ]; then
734 $PDSH $CLIENTS "df $MOUNT" > /dev/null
736 df $MOUNT > /dev/null
741 uname -n >> $MOUNT/recon
742 if [ -z "$CLIENTS" ]; then
743 df $MOUNT; uname -n >> $MOUNT/recon
745 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
747 echo Connected clients:
749 ls -l $MOUNT/recon > /dev/null
756 echo "Failing $facet on node `facet_active_host $facet`"
757 shutdown_facet $facet
758 [ -n "$sleep_time" ] && sleep $sleep_time
762 echo "df pid is $DFPID"
764 TO=`facet_active_host $facet`
765 echo "Failover $facet to $TO"
767 mount_facet $facet || error "Restart of $facet failed"
778 local svc=${facet}_svc
779 do_facet $facet $LCTL --device %${!svc} readonly
780 do_facet $facet $LCTL --device %${!svc} notransno
781 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
782 $LCTL mark "local REPLAY BARRIER on ${!svc}"
785 replay_barrier_nodf() {
786 local facet=$1 echo running=${running}
788 local svc=${facet}_svc
789 echo Replay barrier on ${!svc}
790 do_facet $facet $LCTL --device %${!svc} readonly
791 do_facet $facet $LCTL --device %${!svc} notransno
792 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
793 $LCTL mark "local REPLAY BARRIER on ${!svc}"
796 replay_barrier_nosync() {
797 local facet=$1 echo running=${running}
798 local svc=${facet}_svc
799 echo Replay barrier on ${!svc}
800 do_facet $facet $LCTL --device %${!svc} readonly
801 do_facet $facet $LCTL --device %${!svc} notransno
802 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
803 $LCTL mark "local REPLAY BARRIER on ${!svc}"
807 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
808 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
812 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
813 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
817 facet_failover $* || error "failover: $?"
818 df $MOUNT || error "post-failover df: $?"
823 facet_failover $facet
830 mount_facet $facet -o abort_recovery
831 df $MOUNT || echo "first df failed: $?"
833 df $MOUNT || error "post-failover df: $?"
837 echo There is no lmc. This is mountconf, baby.
842 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
843 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
849 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
855 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
856 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
857 if [ -z "$ID" ]; then
858 echo "Could not get a ptl id for $1..."
867 h2name_or_ip "$1" "tcp"
872 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
873 if type __h2elan >/dev/null 2>&1; then
876 ID=`echo $1 | sed 's/[^0-9]*//g'`
884 h2name_or_ip "$1" "openib"
889 h2name_or_ip "$1" "o2ib"
896 [ "$facet" == client ] && echo -n $HOSTNAME && return
897 varname=${facet}_HOST
898 if [ -z "${!varname}" ]; then
899 if [ "${facet:0:3}" == "ost" ]; then
900 eval ${facet}_HOST=${ost_HOST}
908 local activevar=${facet}active
910 if [ -f $TMP/${facet}active ] ; then
911 source $TMP/${facet}active
915 if [ -z "$active" ] ; then
922 facet_active_host() {
924 local active=`facet_active $facet`
925 if [ "$facet" == client ]; then
928 echo `facet_host $active`
934 failover=${facet}failover
935 host=`facet_host $failover`
936 [ -z "$host" ] && return
937 curactive=`facet_active $facet`
938 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
939 eval export ${facet}active=$facet
941 eval export ${facet}active=$failover
943 # save the active host for this facet
944 activevar=${facet}active
945 echo "$activevar=${!activevar}" > $TMP/$activevar
952 if [ "$HOST" = "$HOSTNAME" ]; then
954 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
955 echo "cannot run remote command on $HOST with $myPDSH"
959 echo "CMD: $HOST $@" >&2
960 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
963 if [ "$myPDSH" = "rsh" ]; then
964 # we need this because rsh does not return exit code of an executed command
965 local command_status="$TMP/cs"
966 rsh $HOST ":> $command_status"
967 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
968 cd $RPWD; sh -c \"$@\") ||
969 echo command failed >$command_status"
970 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
973 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
974 return ${PIPESTATUS[0]}
977 single_local_node () {
978 [ "$1" = "$HOSTNAME" ]
985 if $(single_local_node $rnodes); then
990 # This is part from do_node
993 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
994 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
997 echo "CMD: $rnodes $@" >&2
998 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1001 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1002 return ${PIPESTATUS[0]}
1008 HOST=`facet_active_host $facet`
1009 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1016 # make sure its not already running
1018 rm -f $TMP/${facet}active
1019 do_facet ${facet} $MKFS $*
1025 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1026 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1033 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1034 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1042 # make sure we are using the primary server, so test-framework will
1043 # be able to clean up properly.
1044 activemds=`facet_active mds1`
1045 if [ $activemds != "mds1" ]; then
1049 # assume client mount is local
1050 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1051 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1053 if [ -n "$CLIENTS" ]; then
1054 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1055 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1058 [ "$CLIENTONLY" ] && return
1059 # The add fn does rm ${facet}active file, this would be enough
1060 # if we use do_facet <facet> only after the facet added, but
1061 # currently we use do_facet mds in local.sh
1062 for num in `seq $MDSCOUNT`; do
1064 rm -f ${TMP}/mds${num}active
1067 for num in `seq $OSTCOUNT`; do
1069 rm -f $TMP/ost${num}active
1084 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1088 if [ "$IAMDIR" == "yes" ]; then
1089 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1090 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1093 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1095 if [ ! -z $SEC ]; then
1096 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1097 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1098 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1102 # We need ldiskfs here, may as well load them all
1104 [ "$CLIENTONLY" ] && return
1105 echo "Formatting mdts, osts"
1106 for num in `seq $MDSCOUNT`; do
1107 echo "Format mds$num: $(mdsdevname $num)"
1109 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1111 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1115 for num in `seq $OSTCOUNT`; do
1116 echo "Format ost$num: $(ostdevname $num)"
1118 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1120 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1126 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1130 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1134 # 0: success, the old identity set already.
1135 # 1: success, the old identity does not set.
1140 local j=`expr $num - 1`
1141 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1143 if [ -z "$MDT" ]; then
1147 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1150 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1152 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1155 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1157 if [ $old = "NONE" ]; then
1166 zconf_umount `hostname` $1 || error "umount failed"
1167 zconf_mount `hostname` $1 || error "mount failed"
1174 do_facet $facet lsmod | grep -q obdclass || \
1175 do_facet $facet "modprobe obdclass"
1177 do_facet $facet "lctl set_param timeout=$timeout"
1180 writeconf_facet () {
1184 do_facet $facet "$TUNEFS --writeconf $dev"
1188 for num in `seq $MDSCOUNT`; do
1189 DEVNAME=$(mdsdevname $num)
1190 writeconf_facet mds$num $DEVNAME
1193 for num in `seq $OSTCOUNT`; do
1194 DEVNAME=$(ostdevname $num)
1195 writeconf_facet ost$num $DEVNAME
1202 if [ -z "$CLIENTONLY" ]; then
1203 echo "Setup mdts, osts"
1204 echo $WRITECONF | grep -q "writeconf" && \
1206 for num in `seq $MDSCOUNT`; do
1207 DEVNAME=$(mdsdevname $num)
1208 set_obd_timeout mds$num $TIMEOUT
1209 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1211 # We started mds, now we should set failover variables properly.
1212 # Set mds${num}failover_HOST if it is not set (the default failnode).
1213 local varname=mds${num}failover_HOST
1214 if [ -z "${!varname}" ]; then
1215 eval mds${num}failover_HOST=$(facet_host mds$num)
1218 if [ $IDENTITY_UPCALL != "default" ]; then
1219 switch_identity $num $IDENTITY_UPCALL
1222 for num in `seq $OSTCOUNT`; do
1223 DEVNAME=$(ostdevname $num)
1224 set_obd_timeout ost$num $TIMEOUT
1225 start ost$num $DEVNAME $OST_MOUNT_OPTS
1227 # We started ost$num, now we should set ost${num}failover variable properly.
1228 # Set ost${num}failover_HOST if it is not set (the default failnode).
1229 varname=ost${num}failover_HOST
1230 if [ -z "${!varname}" ]; then
1231 eval ost${num}failover_HOST=$(facet_host ost${num})
1236 # wait a while to allow sptlrpc configuration be propogated to targets,
1237 # only needed when mounting new target devices.
1240 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1242 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1244 if [ "$MOUNT_2" ]; then
1245 mount_client $MOUNT2
1246 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1251 # by remounting mdt before ost, initial connect from mdt to ost might
1252 # timeout because ost is not ready yet. wait some time to its fully
1253 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1254 # by a context negotiation rpc with $TIMEOUT.
1255 # FIXME better by monitoring import status.
1257 sleep $((TIMEOUT + 5))
1263 mounted_lustre_filesystems() {
1264 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1267 init_facet_vars () {
1274 eval export ${facet}_dev=${device}
1275 eval export ${facet}_opt=\"$@\"
1277 local dev=${facet}_dev
1278 local label=$(do_facet ${facet} "e2label ${!dev}")
1279 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1281 eval export ${facet}_svc=${label}
1283 local varname=${facet}failover_HOST
1284 if [ -z "${!varname}" ]; then
1285 eval $varname=$(facet_host $facet)
1289 init_facets_vars () {
1292 for num in `seq $MDSCOUNT`; do
1293 DEVNAME=`mdsdevname $num`
1294 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1297 for num in `seq $OSTCOUNT`; do
1298 DEVNAME=`ostdevname $num`
1299 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1303 init_versions_vars () {
1304 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1305 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1306 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1311 local myMGS_host=$mgs_HOST
1312 if [ "$NETTYPE" = "ptl" ]; then
1313 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1316 echo Checking config lustre mounted on $mntpt
1317 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1318 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1320 if [ "$mgshost" != "$myMGS_host" ]; then
1321 FAIL_ON_ERROR=true \
1322 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1323 Please use correct config or set mds_HOST correctly!"
1327 check_and_setup_lustre() {
1328 local MOUNTED=$(mounted_lustre_filesystems)
1329 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1330 [ "$REFORMAT" ] && formatall
1332 MOUNTED=$(mounted_lustre_filesystems | head -1)
1333 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1334 export I_MOUNTED=yes
1340 if [ "$ONLY" == "setup" ]; then
1345 cleanup_and_setup_lustre() {
1346 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1347 lctl set_param debug=0 || true
1349 if [ "$ONLY" == "cleanup" ]; then
1353 check_and_setup_lustre
1356 check_and_cleanup_lustre() {
1357 if [ "`mount | grep $MOUNT`" ]; then
1358 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1360 if [ "$I_MOUNTED" = "yes" ]; then
1361 cleanupall -f || error "cleanup failed"
1373 while [ $NETWORK -eq 0 ]; do
1374 ping -c 1 -w 3 $1 > /dev/null
1375 if [ $? -eq 0 ]; then
1379 echo "waiting for $1, $((MAX - WAIT)) secs left"
1382 if [ $WAIT -gt $MAX ]; then
1383 echo "Network not available"
1389 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1400 # the sed converts spaces to commas, but leaves the last space
1401 # alone, so the line doesn't end with a comma.
1402 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1406 (cd `dirname $1`; echo $PWD/`basename $1`)
1409 ##################################
1410 # Adaptive Timeouts funcs
1413 if [ -z "$AT_MAX_PATH" ]; then
1414 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1415 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1421 at_is_valid || error "invalid call"
1423 # only check mds, we assume at_max is the same on all nodes
1424 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1425 if [ $at_max -eq 0 ]; then
1435 at_is_valid || error "invalid call"
1437 # suppose that all ost-s has the same at_max set
1438 if [ $facet == "ost" ]; then
1439 do_facet ost1 "cat $AT_MAX_PATH"
1441 do_facet $facet "cat $AT_MAX_PATH"
1449 at_is_valid || error "invalid call"
1453 if [ $facet == "ost" ]; then
1454 for i in `seq $OSTCOUNT`; do
1455 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1457 elif [ $facet == "mds" ]; then
1458 for i in `seq $MDSCOUNT`; do
1459 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1462 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1467 ##################################
1471 # OBD_FAIL_MDS_ALL_REQUEST_NET
1473 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1474 do_facet client "$1" || RC=$?
1475 do_facet $SINGLEMDS lctl set_param fail_loc=0
1480 # OBD_FAIL_MDS_ALL_REPLY_NET
1482 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1483 do_facet client "$@" || RC=$?
1484 do_facet $SINGLEMDS lctl set_param fail_loc=0
1488 drop_reint_reply() {
1489 # OBD_FAIL_MDS_REINT_NET_REP
1491 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1492 do_facet client "$@" || RC=$?
1493 do_facet $SINGLEMDS lctl set_param fail_loc=0
1498 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1500 do_facet ost1 lctl set_param fail_loc=0x214
1501 do_facet client "$1" || RC=$?
1502 do_facet client "sync"
1503 do_facet ost1 lctl set_param fail_loc=0
1507 drop_ldlm_cancel() {
1508 #define OBD_FAIL_LDLM_CANCEL 0x304
1510 do_facet client lctl set_param fail_loc=0x304
1511 do_facet client "$@" || RC=$?
1512 do_facet client lctl set_param fail_loc=0
1516 drop_bl_callback() {
1517 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1519 do_facet client lctl set_param fail_loc=0x305
1520 do_facet client "$@" || RC=$?
1521 do_facet client lctl set_param fail_loc=0
1526 #define OBD_FAIL_LDLM_REPLY 0x30c
1528 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1529 do_facet client "$@" || RC=$?
1530 do_facet $SINGLEMDS lctl set_param fail_loc=0
1538 echo "clearing fail_loc on $facet"
1539 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1542 set_nodes_failloc () {
1546 for node in $nodes ; do
1547 do_node $node lctl set_param fail_loc=$2
1551 cancel_lru_locks() {
1552 $LCTL mark "cancel_lru_locks $1 start"
1553 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1554 $LCTL set_param -n $d=clear
1556 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1557 $LCTL mark "cancel_lru_locks $1 stop"
1562 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1563 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1564 echo "$DEFAULT_LRU_SIZE"
1569 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1572 lru_resize_disable()
1574 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1579 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1580 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1581 echo there is still data in page cache $FILE ?
1582 lctl get_param -n $FILE
1590 DEBUGSAVE="$(lctl get_param -n debug)"
1594 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1598 ##################################
1600 ##################################
1603 local TYPE=${TYPE:-"FAIL"}
1605 lctl set_param fail_loc=0 2>/dev/null || true
1606 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1607 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1608 echo "Dumping lctl log to $ERRLOG"
1609 # We need to dump the logs on all nodes
1610 local NODES=$(nodes_list)
1611 for NODE in $NODES; do
1612 do_node $NODE $LCTL dk $ERRLOG
1615 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1620 $FAIL_ON_ERROR && exit 1 || true
1628 # use only if we are ignoring failures for this test, bugno required.
1629 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1630 # e.g. error_ignore 5494 "your message"
1632 local TYPE="IGNORE (bz$1)"
1638 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1639 [ "$TESTSUITELOG" ] && \
1640 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1643 build_test_filter() {
1644 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1648 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1649 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1650 [ "$EXCEPT_SLOW" ] && \
1651 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1652 for E in $EXCEPT $ALWAYS_EXCEPT; do
1653 eval EXCEPT_${E}=true
1655 for E in $EXCEPT_SLOW; do
1656 eval EXCEPT_SLOW_${E}=true
1658 for G in $GRANT_CHECK_LIST; do
1659 eval GCHECK_ONLY_${G}=true
1668 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1671 # print a newline if the last test was skipped
1672 export LAST_SKIPPED=
1676 export base=`basetest $1`
1677 if [ ! -z "$ONLY" ]; then
1679 if [ ${!testname}x != x ]; then
1680 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1685 if [ ${!testname}x != x ]; then
1686 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1695 if [ ${!testname}x != x ]; then
1697 TESTNAME=test_$1 skip "skipping excluded test $1"
1700 testname=EXCEPT_$base
1701 if [ ${!testname}x != x ]; then
1703 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1706 testname=EXCEPT_SLOW_$1
1707 if [ ${!testname}x != x ]; then
1709 TESTNAME=test_$1 skip "skipping SLOW test $1"
1712 testname=EXCEPT_SLOW_$base
1713 if [ ${!testname}x != x ]; then
1715 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1725 EQUALS="======================================================================"
1729 local suffixlen=$((${#EQUALS} - ${#msg}))
1730 [ $suffixlen -lt 5 ] && suffixlen=5
1731 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1736 lsmod | grep lnet > /dev/null || load_modules
1748 local NODES=$(nodes_list)
1749 for NODE in $NODES; do
1750 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1756 strace -o $TMP/$1.strace -ttt $*
1758 log "FINISHED: $*: rc $RC"
1767 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1768 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1769 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1773 local myNODES=$(nodes_list)
1776 for NODE in $myNODES; do
1777 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1785 export tdir=d0.${TESTSUITE}/d${base}
1786 local SAVE_UMASK=`umask`
1790 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1792 export TESTNAME=test_$testnum
1793 test_${testnum} || error "test_$testnum failed with $?"
1797 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1798 check_catastrophe || error "LBUG/LASSERT detected"
1799 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1800 pass "($((`date +%s` - $BEFORE))s)"
1807 (cd `dirname $1`; echo $PWD/`basename $1`)
1811 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1812 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1817 export base=`basetest $1`
1818 [ "$CHECK_GRANT" == "no" ] && return 0
1820 testname=GCHECK_ONLY_${base}
1821 [ ${!testname}x == x ] && return 0
1823 echo -n "checking grant......"
1825 # write some data to sync client lost_grant
1826 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1827 for i in `seq $OSTCOUNT`; do
1828 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1829 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1830 count=1 > /dev/null 2>&1
1832 # sync all the data and make sure no pending data on server
1835 #get client grant and server grant
1837 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1838 client_grant=$((client_grant + $d))
1841 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1842 server_grant=$((server_grant + $d))
1845 # cleanup the check_grant file
1846 for i in `seq $OSTCOUNT`; do
1847 rm $DIR1/${tfile}_check_grant_$i
1850 #check whether client grant == server grant
1851 if [ $client_grant != $server_grant ]; then
1852 echo "failed: client:${client_grant} server: ${server_grant}"
1859 ########################
1865 ost=`echo $1 | awk -F_ '{print $3}'`
1866 if [ -z $ost ]; then
1867 ost=`echo $1 | sed 's/-osc.*//'`
1874 [ "$node" != "$(hostname)" ]
1880 for node in $(mdts_nodes); do
1881 remote_node $node && return 0
1888 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1894 for node in $(osts_nodes) ; do
1895 remote_node $node && return 0
1902 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1908 for num in `seq $MDSCOUNT`; do
1909 MDSNODES="$MDSNODES $(facet_host mds$num)"
1911 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1917 remote_ost && remote_mds
1921 local OSTNODES=$(facet_host ost1)
1924 for num in `seq $OSTCOUNT`; do
1925 local myOST=$(facet_host ost$num)
1926 OSTNODES="$OSTNODES $myOST"
1928 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1934 # FIXME. We need a list of clients
1935 local myNODES=$HOSTNAME
1938 # CLIENTS (if specified) contains the local client
1939 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1941 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1942 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1945 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1950 remote_nodes_list () {
1951 local rnodes=$(nodes_list)
1952 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1956 init_clients_lists () {
1957 # Sanity check: exclude the local client from RCLIENTS
1958 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1960 # Sanity check: exclude the dup entries
1961 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1963 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1965 # Sanity check: exclude the dup entries from CLIENTS
1966 # for those configs which has SINGLCLIENT set to local client
1967 clients=$(for i in $clients; do echo $i; done | sort -u)
1969 CLIENTS=`comma_list $clients`
1970 local -a remoteclients=($rclients)
1971 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1972 varname=CLIENT$((i + 2))
1973 eval $varname=${remoteclients[i]}
1976 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1981 lctl get_param version | grep -q patchless
1985 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
1990 echo $nodes | wc -w || true
1994 local nodes=$(osts_nodes)
1995 local osscount=$(get_node_count "$nodes")
1996 [ ! "$OSTCOUNT" = "$osscount" ]
2000 local nodes=$(mdts_nodes)
2001 local mdtcount=$(get_node_count "$nodes")
2002 [ ! "$MDSCOUNT" = "$mdtcount" ]
2005 generate_machine_file() {
2006 local nodes=${1//,/ }
2007 local machinefile=$2
2008 rm -f $machinefile || error "can't rm $machinefile"
2009 for node in $nodes; do
2010 echo $node >>$machinefile
2015 local file=$1/stripe
2017 $LFS getstripe -v $file || error
2021 check_runas_id_ret() {
2026 if [ -z "$myRUNAS" ]; then
2027 error_exit "myRUNAS command must be specified for check_runas_id"
2030 $myRUNAS krb5_login.sh || \
2031 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2033 mkdir $DIR/d0_runas_test
2035 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
2036 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2037 rm -rf $DIR/d0_runas_test
2045 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
2046 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
2047 Please set RUNAS_ID to some UID which exists on MDS and client or
2048 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
2051 # Run multiop in the background, but wait for it to print
2052 # "PAUSING" to its stdout before returning from this function.
2053 multiop_bg_pause() {
2054 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2058 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2061 echo "$MULTIOP_PROG $FILE v$ARGS"
2062 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2064 echo "TMPPIPE=${TMPPIPE}"
2065 read -t 60 multiop_output < $TMPPIPE
2066 if [ $? -ne 0 ]; then
2071 if [ "$multiop_output" != "PAUSING" ]; then
2072 echo "Incorrect multiop output: $multiop_output"
2082 local TARGET_RATE=$2
2083 local NUM_CLIENTS=$3
2086 local RATE=$(awk '/^Rate: [0-9\.]+ '"${OP}"'s\/sec/ { print $2}' ${LOG})
2088 # We need to use bc since the rate is a floating point number
2089 local RES=$(echo "${RATE} < ${TARGET_RATE}" | bc -l )
2090 if [ ${RES} -eq 0 ]; then
2091 echo "Success: ${RATE} ${OP}s/sec met target rate" \
2092 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2095 echo "Failure: ${RATE} ${OP}s/sec did not meet target rate" \
2096 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2101 # reset llite stat counters
2102 clear_llite_stats(){
2103 lctl set_param -n llite.*.stats 0
2106 # sum llite stat items
2107 calc_llite_stats() {
2108 local res=$(lctl get_param -n llite.*.stats |
2109 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2113 # reset osc stat counters
2115 lctl set_param -n osc.*.osc_stats 0
2118 # sum osc stat items
2120 local res=$(lctl get_param -n osc.*.osc_stats |
2121 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2126 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2129 calc_osc_kbytes () {
2130 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2133 # save_lustre_params(node, parameter_mask)
2134 # generate a stream of formatted strings (<node> <param name>=<param value>)
2135 save_lustre_params() {
2137 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2140 # restore lustre parameters from input stream, produces by save_lustre_params
2141 restore_lustre_params() {
2145 while IFS=" =" read node name val; do
2146 do_node $node "lctl set_param -n $name $val"
2150 check_catastrophe () {
2151 local rnodes=$(comma_list $(remote_nodes_list))
2153 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && return 1
2154 if [ $rnodes ]; then
2155 do_nodes $rnodes "[ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2169 do_facet $1 lfs getstripe -v $2 > $tmp_file
2171 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2172 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2173 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`