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)
102 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
103 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
104 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
105 [ ! -f "$LFS" ] && export LFS=$(which lfs)
106 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
107 if [ ! -f "$L_GETIDENTITY" ]; then
108 if `which l_getidentity > /dev/null 2>&1`; then
109 export L_GETIDENTITY=$(which l_getidentity)
111 export L_GETIDENTITY=NONE
114 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
115 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
116 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
117 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
118 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
119 export FSYTPE=${FSTYPE:-"ldiskfs"}
120 export NAME=${NAME:-local}
121 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
122 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
123 export LGSSD=$(which lgssd)
124 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
125 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
126 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
128 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
131 if [ "$ACCEPTOR_PORT" ]; then
132 export PORT_OPT="--port $ACCEPTOR_PORT"
137 echo "Using GSS/krb5 ptlrpc security flavor"
138 which lgss_keyring > /dev/null 2>&1 || \
139 error "built with gss disabled! SEC=$SEC"
150 IDENTITY_UPCALL=false
154 # Paths on remote nodes, if different
155 export RLUSTRE=${RLUSTRE:-$LUSTRE}
156 export RPWD=${RPWD:-$PWD}
157 export I_MOUNTED=${I_MOUNTED:-"no"}
161 while getopts "rvwf:" opt $*; do
164 r) REFORMAT=--reformat;;
166 w) WRITECONF=writeconf;;
171 shift $((OPTIND - 1))
174 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
183 BASE=`basename $module $EXT`
184 lsmod | grep -q ${BASE} || \
185 if [ -f ${LUSTRE}/${module}${EXT} ]; then
186 insmod ${LUSTRE}/${module}${EXT} $@
188 # must be testing a "make install" or "rpm" installation
189 # note failed to load ptlrpc_gss is considered not fatal
190 if [ "$BASE" == "ptlrpc_gss" ]; then
191 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
199 if [ -n "$MODPROBE" ]; then
203 if [ "$HAVE_MODULES" = true ]; then
209 echo Loading modules from $LUSTRE
210 load_module ../libcfs/libcfs/libcfs
211 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
212 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
213 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
214 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
215 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
216 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
217 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
218 echo "lnet options: '$LNETOPTS'"
219 # note that insmod will ignore anything in modprobe.conf
220 load_module ../lnet/lnet/lnet $LNETOPTS
221 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
222 load_module ../lnet/klnds/$LNETLND
223 load_module lvfs/lvfs
224 load_module obdclass/obdclass
225 load_module ptlrpc/ptlrpc
226 load_module ptlrpc/gss/ptlrpc_gss
227 # Now, some modules depend on lquota without USE_QUOTA check,
228 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
229 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
230 load_module quota/lquota
238 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
239 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
240 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
245 load_module lvfs/fsfilt_$FSTYPE
249 load_module obdfilter/obdfilter
252 load_module llite/lustre
253 load_module llite/llite_lloop
255 rm -f $OGDB/ogdb-$HOSTNAME
256 [ -d /r ] && OGDB="/r/tmp"
257 $LCTL modules > $OGDB/ogdb-$HOSTNAME
259 # 'mount' doesn't look in $PATH, just sbin
260 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
264 if [ `uname -r | cut -c 3` -eq 4 ]; then
272 MODULES=$($LCTL modules | awk '{ print $2 }')
273 while [ -n "$MODULES" ]; do
275 $RMMOD $MODULES > /dev/null 2>&1 || true
276 MODULES=$($LCTL modules | awk '{ print $2 }')
277 if [ -z "$MODULES" ]; then
281 echo "waiting, $((MAX - WAIT)) secs left"
283 if [ $WAIT -eq $MAX ]; then
284 echo "LNET modules $MODULES will not unload"
291 unload_dep_module() {
293 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
295 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
296 for SUBMOD in $DEPS; do
297 unload_dep_module $SUBMOD
299 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
300 $RMMOD $MODULE || true
304 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
305 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
306 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
307 echo "$LEAK_LUSTRE" 1>&2
308 echo "$LEAK_PORTALS" 1>&2
309 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
310 log "Memory leaks detected"
311 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
317 wait_exit_ST client # bug 12845
319 lsmod | grep libcfs > /dev/null && $LCTL dl
320 unload_dep_module $FSTYPE
321 unload_dep_module libcfs
323 local MODULES=$($LCTL modules | awk '{ print $2 }')
324 if [ -n "$MODULES" ]; then
325 echo "Modules still loaded: "
327 if [ "$(lctl dl)" ]; then
328 echo "Lustre still loaded"
333 echo "Lustre stopped but LNET is still loaded, waiting..."
334 wait_for_lnet || return 3
340 check_mem_leak || return 254
342 echo "modules unloaded."
346 check_gss_daemon_facet() {
350 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
351 if [ $num -ne 1 ]; then
352 echo "$num instance of $dname on $facet"
361 do_facet $facet "killall -2 $@ 2>/dev/null || true"
364 start_gss_daemons() {
366 for num in `seq $MDSCOUNT`; do
367 do_facet mds$num "$LSVCGSSD -v"
369 do_facet mds$num "$LGSSD -v"
373 for num in `seq $OSTCOUNT`; do
374 do_facet ost$num "$LSVCGSSD -v"
377 # FIXME: is "client" the right facet name?
379 do_facet client "$LGSSD -v"
382 # wait daemons entering "stable" status
386 # check daemons are running
388 for num in `seq $MDSCOUNT`; do
389 check_gss_daemon_facet mds$num lsvcgssd
391 check_gss_daemon_facet mds$num lgssd
394 for num in `seq $OSTCOUNT`; do
395 check_gss_daemon_facet ost$num lsvcgssd
398 check_gss_daemon_facet client lgssd
403 for num in `seq $MDSCOUNT`; do
404 send_sigint mds$num lsvcgssd lgssd
406 for num in `seq $OSTCOUNT`; do
407 send_sigint ost$num lsvcgssd
409 send_sigint client lgssd
421 # maybe cleanup credential cache?
427 local device=`mdsdevname $num`
428 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
434 local device=`ostdevname $num`
435 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
443 local dev=${facet}_dev
444 local opt=${facet}_opt
445 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
446 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
448 if [ $RC -ne 0 ]; then
449 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
450 echo "Start of ${!dev} on ${facet} failed ${RC}"
452 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
453 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
454 lctl set_param debug_mb=${DEBUG_SIZE}; \
457 label=$(do_facet ${facet} "e2label ${!dev}")
458 [ -z "$label" ] && echo no label for ${!dev} && exit 1
459 eval export ${facet}_svc=${label}
460 echo Started ${label}
465 # start facet device options
471 eval export ${facet}_dev=${device}
472 eval export ${facet}_opt=\"$@\"
473 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
483 HOST=`facet_active_host $facet`
484 [ -z $HOST ] && echo stop: no host for $facet && return 0
486 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
487 if [ ${running} -ne 0 ]; then
488 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
489 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
492 # umount should block, but we should wait for unrelated obd's
493 # like the MGS or MGC to also stop.
494 wait_exit_ST ${facet}
501 # Only supply -o to mount if we have options
502 if [ -n "$MOUNTOPT" ]; then
503 OPTIONS="-o $MOUNTOPT"
505 local device=$MGSNID:/$FSNAME
506 if [ -z "$mnt" -o -z "$FSNAME" ]; then
507 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
511 echo "Starting client: $client: $OPTIONS $device $mnt"
512 do_node $client mkdir -p $mnt
513 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
515 do_node $client "lctl set_param debug=$PTLDEBUG;
516 lctl set_param subsystem_debug=${SUBSYSTEM# };
517 lctl set_param debug_mb=${DEBUG_SIZE}"
526 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
527 if [ $running -ne 0 ]; then
528 echo "Stopping client $client $mnt (opts:$force)"
529 lsof | grep "$mnt" || true
530 do_node $client umount $force $mnt
534 # mount clients if not mouted
535 zconf_mount_clients() {
541 # Only supply -o to mount if we have options
542 if [ -n "$MOUNTOPT" ]; then
543 OPTIONS="-o $MOUNTOPT"
545 local device=$MGSNID:/$FSNAME
546 if [ -z "$mnt" -o -z "$FSNAME" ]; then
547 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
551 echo "Starting client $clients: $OPTIONS $device $mnt"
552 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
554 echo "Started clients $clients: "
555 do_nodes $clients "mount | grep $mnt"
557 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
558 lctl set_param subsystem_debug=${SUBSYSTEM# };
559 lctl set_param debug_mb=${DEBUG_SIZE};"
564 zconf_umount_clients() {
569 echo "Umounting clients: $clients"
570 echo "Stopping clients: $clients $mnt (opts:$force)"
571 do_nodes $clients umount $force $mnt
576 if [ "$FAILURE_MODE" = HARD ]; then
577 $POWER_DOWN `facet_active_host $facet`
579 elif [ "$FAILURE_MODE" = SOFT ]; then
586 if [ "$FAILURE_MODE" = HARD ]; then
587 $POWER_UP `facet_active_host $facet`
595 if [ "$FAILURE_MODE" = HARD ]; then
600 # verify that lustre actually cleaned up properly
602 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
603 error "LBUG/LASSERT detected"
604 BUSY=`dmesg | grep -i destruct || true`
607 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
611 check_mem_leak || exit 204
613 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
614 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
616 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
617 echo "$0: modules still loaded..." 1>&2
624 wait_delete_completed () {
625 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
626 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
630 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
632 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
633 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
634 [ "$TOTAL" -eq "$TOTALPREV" ] && break
635 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
639 echo "Delete completed."
644 check_network "$HOST" 900
645 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
650 HOST=`facet_active_host $facet`
654 wait_mds_recovery_done () {
655 local timeout=`do_facet $SINGLEMDS lctl get_param -n timeout`
656 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
657 # as we are in process of changing obd_timeout in different ways
658 # let's set MAX longer than that
659 MAX=$(( timeout * 4 ))
661 while [ $WAIT -lt $MAX ]; do
662 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT0000.recovery_status | grep status"`
663 echo $STATUS | grep COMPLETE && return 0
666 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
668 echo "MDS recovery not done in $MAX sec"
677 # conf-sanity 31 takes a long time cleanup
678 while [ $WAIT -lt 300 ]; do
679 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
680 [ -z "${running}" ] && return 0
681 echo "waited $WAIT for${running}"
682 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
684 WAIT=$((WAIT + INTERVAL))
686 echo "service didn't stop after $WAIT seconds. Still running:"
691 wait_remote_prog () {
697 [ "$PDSH" = "no_dsh" ] && return 0
699 while [ $WAIT -lt $2 ]; do
700 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep)
701 [ -z "${running}" ] && return 0
702 echo "waited $WAIT for: "
704 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
706 WAIT=$((WAIT + INTERVAL))
708 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
709 [ -z "$pids" ] && return 0
710 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
712 cat /proc/${pid}/status || true
713 cat /proc/${pid}/wchan || true
724 # not every config has many clients
725 if [ ! -z "$CLIENTS" ]; then
726 $PDSH $CLIENTS "df $MOUNT" > /dev/null
728 df $MOUNT > /dev/null
733 uname -n >> $MOUNT/recon
734 if [ -z "$CLIENTS" ]; then
735 df $MOUNT; uname -n >> $MOUNT/recon
737 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
739 echo Connected clients:
741 ls -l $MOUNT/recon > /dev/null
747 echo "Failing $facet on node `facet_active_host $facet`"
748 shutdown_facet $facet
752 echo "df pid is $DFPID"
754 TO=`facet_active_host $facet`
755 echo "Failover $facet to $TO"
757 mount_facet $facet || error "Restart of $facet failed"
768 local svc=${facet}_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}"
775 replay_barrier_nodf() {
776 local facet=$1 echo running=${running}
778 local svc=${facet}_svc
779 echo Replay barrier on ${!svc}
780 do_facet $facet $LCTL --device %${!svc} readonly
781 do_facet $facet $LCTL --device %${!svc} notransno
782 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
783 $LCTL mark "local REPLAY BARRIER on ${!svc}"
786 replay_barrier_nosync() {
787 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}"
797 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
798 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
802 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
803 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
807 facet_failover $* || error "failover: $?"
808 df $MOUNT || error "post-failover df: $?"
813 facet_failover $facet
820 mount_facet $facet -o abort_recovery
821 df $MOUNT || echo "first df failed: $?"
823 df $MOUNT || error "post-failover df: $?"
827 echo There is no lmc. This is mountconf, baby.
832 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
833 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
839 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
845 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
846 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
847 if [ -z "$ID" ]; then
848 echo "Could not get a ptl id for $1..."
857 h2name_or_ip "$1" "tcp"
862 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
863 if type __h2elan >/dev/null 2>&1; then
866 ID=`echo $1 | sed 's/[^0-9]*//g'`
874 h2name_or_ip "$1" "openib"
879 h2name_or_ip "$1" "o2ib"
885 varname=${facet}_HOST
886 if [ -z "${!varname}" ]; then
887 if [ "${facet:0:3}" == "ost" ]; then
888 eval ${facet}_HOST=${ost_HOST}
896 local activevar=${facet}active
898 if [ -f $TMP/${facet}active ] ; then
899 source $TMP/${facet}active
903 if [ -z "$active" ] ; then
910 facet_active_host() {
912 local active=`facet_active $facet`
913 if [ "$facet" == client ]; then
916 echo `facet_host $active`
922 failover=${facet}failover
923 host=`facet_host $failover`
924 [ -z "$host" ] && return
925 curactive=`facet_active $facet`
926 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
927 eval export ${facet}active=$facet
929 eval export ${facet}active=$failover
931 # save the active host for this facet
932 activevar=${facet}active
933 echo "$activevar=${!activevar}" > $TMP/$activevar
940 if [ "$HOST" = "$HOSTNAME" ]; then
942 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
943 echo "cannot run remote command on $HOST with $myPDSH"
947 echo "CMD: $HOST $@" >&2
948 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
951 if [ "$myPDSH" = "rsh" ]; then
952 # we need this because rsh does not return exit code of an executed command
953 local command_status="$TMP/cs"
954 rsh $HOST ":> $command_status"
955 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
956 cd $RPWD; sh -c \"$@\") ||
957 echo command failed >$command_status"
958 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
961 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
962 return ${PIPESTATUS[0]}
965 single_local_node () {
966 [ "$1" = "$HOSTNAME" ]
973 if $(single_local_node $rnodes); then
978 # This is part from do_node
981 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
982 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
985 echo "CMD: $rnodes $@" >&2
986 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
989 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
990 return ${PIPESTATUS[0]}
996 HOST=`facet_active_host $facet`
997 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1004 # make sure its not already running
1006 rm -f $TMP/${facet}active
1007 do_facet ${facet} $MKFS $*
1013 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1014 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1021 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1022 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1030 # make sure we are using the primary server, so test-framework will
1031 # be able to clean up properly.
1032 activemds=`facet_active mds1`
1033 if [ $activemds != "mds1" ]; then
1037 # assume client mount is local
1038 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1039 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1041 if [ -n "$CLIENTS" ]; then
1042 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1043 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1046 [ "$CLIENTONLY" ] && return
1047 # The add fn does rm ${facet}active file, this would be enough
1048 # if we use do_facet <facet> only after the facet added, but
1049 # currently we use do_facet mds in local.sh
1050 for num in `seq $MDSCOUNT`; do
1052 rm -f ${TMP}/mds${num}active
1055 for num in `seq $OSTCOUNT`; do
1057 rm -f $TMP/ost${num}active
1072 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1076 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1078 if [ ! -z $SEC ]; then
1079 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1080 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1081 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1085 # We need ldiskfs here, may as well load them all
1087 [ "$CLIENTONLY" ] && return
1088 echo "Formatting mdts, osts"
1089 for num in `seq $MDSCOUNT`; do
1090 echo "Format mds$num: $(mdsdevname $num)"
1092 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1094 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1098 for num in `seq $OSTCOUNT`; do
1099 echo "Format ost$num: $(ostdevname $num)"
1101 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1103 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1109 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1113 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1117 # 0: success, the old identity set already.
1118 # 1: success, the old identity does not set.
1123 local j=`expr $num - 1`
1124 local MDT="`do_facet mds$num lctl get_param -N mdt.*MDT*$j | cut -d"." -f2 2>/dev/null || true`"
1126 if [ -z "$MDT" ]; then
1130 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1133 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1135 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1138 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1140 if [ $old = "NONE" ]; then
1149 zconf_umount `hostname` $1 || error "umount failed"
1150 zconf_mount `hostname` $1 || error "mount failed"
1157 do_facet $facet lsmod | grep -q obdclass || \
1158 do_facet $facet "modprobe obdclass"
1160 do_facet $facet "lctl set_param timeout=$timeout"
1163 writeconf_facet () {
1167 do_facet $facet "$TUNEFS --writeconf $dev"
1171 for num in `seq $MDSCOUNT`; do
1172 DEVNAME=$(mdsdevname $num)
1173 writeconf_facet mds$num $DEVNAME
1176 for num in `seq $OSTCOUNT`; do
1177 DEVNAME=$(ostdevname $num)
1178 writeconf_facet ost$num $DEVNAME
1185 if [ -z "$CLIENTONLY" ]; then
1186 echo "Setup mdts, osts"
1187 echo $WRITECONF | grep -q "writeconf" && \
1189 for num in `seq $MDSCOUNT`; do
1190 DEVNAME=$(mdsdevname $num)
1191 set_obd_timeout mds$num $TIMEOUT
1192 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1194 # We started mds, now we should set failover variables properly.
1195 # Set mds${num}failover_HOST if it is not set (the default failnode).
1196 local varname=mds${num}failover_HOST
1197 if [ -z "${!varname}" ]; then
1198 eval mds${num}failover_HOST=$(facet_host mds$num)
1201 if [ $IDENTITY_UPCALL != "default" ]; then
1202 switch_identity $num $IDENTITY_UPCALL
1205 for num in `seq $OSTCOUNT`; do
1206 DEVNAME=$(ostdevname $num)
1207 set_obd_timeout ost$num $TIMEOUT
1208 start ost$num $DEVNAME $OST_MOUNT_OPTS
1210 # We started ost$num, now we should set ost${num}failover variable properly.
1211 # Set ost${num}failover_HOST if it is not set (the default failnode).
1212 varname=ost${num}failover_HOST
1213 if [ -z "${!varname}" ]; then
1214 eval ost${num}failover_HOST=$(facet_host ost${num})
1219 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1221 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1223 if [ "$MOUNT_2" ]; then
1224 mount_client $MOUNT2
1225 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1228 # by remounting mdt before ost, initial connect from mdt to ost might
1229 # timeout because ost is not ready yet. wait some time to its fully
1230 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1231 # by a context negotiation rpc with $TIMEOUT.
1232 # FIXME better by monitoring import status.
1234 sleep $((TIMEOUT + 5))
1240 mounted_lustre_filesystems() {
1241 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1244 init_facet_vars () {
1251 eval export ${facet}_dev=${device}
1252 eval export ${facet}_opt=\"$@\"
1254 local dev=${facet}_dev
1255 local label=$(do_facet ${facet} "e2label ${!dev}")
1256 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1258 eval export ${facet}_svc=${label}
1260 local varname=${facet}failover_HOST
1261 if [ -z "${!varname}" ]; then
1262 eval $varname=$(facet_host $facet)
1266 init_facets_vars () {
1269 for num in `seq $MDSCOUNT`; do
1270 DEVNAME=`mdsdevname $num`
1271 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1274 for num in `seq $OSTCOUNT`; do
1275 DEVNAME=`ostdevname $num`
1276 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1283 echo Checking config lustre mounted on $mntpt
1284 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1285 if [ "$mgshost" != "$mgs_HOST" ]; then
1286 FAIL_ON_ERROR=true \
1287 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST
1288 Please use correct config or set mds_HOST correctly!"
1292 check_and_setup_lustre() {
1293 local MOUNTED=$(mounted_lustre_filesystems)
1294 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1295 [ "$REFORMAT" ] && formatall
1297 MOUNTED=$(mounted_lustre_filesystems | head -1)
1298 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1299 export I_MOUNTED=yes
1304 if [ "$ONLY" == "setup" ]; then
1309 cleanup_and_setup_lustre() {
1310 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1311 lctl set_param debug=0 || true
1313 if [ "$ONLY" == "cleanup" ]; then
1317 check_and_setup_lustre
1320 check_and_cleanup_lustre() {
1321 if [ "`mount | grep $MOUNT`" ]; then
1322 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1324 if [ "$I_MOUNTED" = "yes" ]; then
1325 cleanupall -f || error "cleanup failed"
1337 while [ $NETWORK -eq 0 ]; do
1338 ping -c 1 -w 3 $1 > /dev/null
1339 if [ $? -eq 0 ]; then
1343 echo "waiting for $1, $((MAX - WAIT)) secs left"
1346 if [ $WAIT -gt $MAX ]; then
1347 echo "Network not available"
1353 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1364 # the sed converts spaces to commas, but leaves the last space
1365 # alone, so the line doesn't end with a comma.
1366 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1370 (cd `dirname $1`; echo $PWD/`basename $1`)
1373 ##################################
1374 # Adaptive Timeouts funcs
1377 if [ -z "$AT_MAX_PATH" ]; then
1378 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1379 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1385 at_is_valid || error "invalid call"
1387 # only check mds, we assume at_max is the same on all nodes
1388 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1389 if [ $at_max -eq 0 ]; then
1399 at_is_valid || error "invalid call"
1401 # suppose that all ost-s has the same at_max set
1402 if [ $facet == "ost" ]; then
1403 do_facet ost1 "cat $AT_MAX_PATH"
1405 do_facet $facet "cat $AT_MAX_PATH"
1413 at_is_valid || error "invalid call"
1417 if [ $facet == "ost" ]; then
1418 for i in `seq $OSTCOUNT`; do
1419 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1421 elif [ $facet == "mds" ]; then
1422 for i in `seq $MDSCOUNT`; do
1423 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1426 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1431 ##################################
1435 # OBD_FAIL_MDS_ALL_REQUEST_NET
1437 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1438 do_facet client "$1" || RC=$?
1439 do_facet $SINGLEMDS lctl set_param fail_loc=0
1444 # OBD_FAIL_MDS_ALL_REPLY_NET
1446 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1447 do_facet client "$@" || RC=$?
1448 do_facet $SINGLEMDS lctl set_param fail_loc=0
1452 drop_reint_reply() {
1453 # OBD_FAIL_MDS_REINT_NET_REP
1455 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1456 do_facet client "$@" || RC=$?
1457 do_facet $SINGLEMDS lctl set_param fail_loc=0
1462 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1464 do_facet ost1 lctl set_param fail_loc=0x214
1465 do_facet client "$1" || RC=$?
1466 do_facet client "sync"
1467 do_facet ost1 lctl set_param fail_loc=0
1471 drop_ldlm_cancel() {
1472 #define OBD_FAIL_LDLM_CANCEL 0x304
1474 do_facet client lctl set_param fail_loc=0x304
1475 do_facet client "$@" || RC=$?
1476 do_facet client lctl set_param fail_loc=0
1480 drop_bl_callback() {
1481 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1483 do_facet client lctl set_param fail_loc=0x305
1484 do_facet client "$@" || RC=$?
1485 do_facet client lctl set_param fail_loc=0
1490 #define OBD_FAIL_LDLM_REPLY 0x30c
1492 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1493 do_facet client "$@" || RC=$?
1494 do_facet $SINGLEMDS lctl set_param fail_loc=0
1502 echo "clearing fail_loc on $facet"
1503 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1506 set_nodes_failloc () {
1510 for node in $nodes ; do
1511 do_node $node lctl set_param fail_loc=$2
1515 cancel_lru_locks() {
1516 $LCTL mark "cancel_lru_locks $1 start"
1517 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1518 $LCTL set_param -n $d=clear
1520 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1521 $LCTL mark "cancel_lru_locks $1 stop"
1526 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1527 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1528 echo "$DEFAULT_LRU_SIZE"
1533 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1536 lru_resize_disable()
1538 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1543 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1544 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1545 echo there is still data in page cache $FILE ?
1546 lctl get_param -n $FILE
1554 DEBUGSAVE="$(lctl get_param -n debug)"
1558 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1562 ##################################
1564 ##################################
1567 local TYPE=${TYPE:-"FAIL"}
1569 lctl set_param fail_loc=0 2>/dev/null || true
1570 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1571 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1572 echo "Dumping lctl log to $ERRLOG"
1573 # We need to dump the logs on all nodes
1574 local NODES=$(nodes_list)
1575 for NODE in $NODES; do
1576 do_node $NODE $LCTL dk $ERRLOG
1579 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1584 $FAIL_ON_ERROR && exit 1 || true
1592 # use only if we are ignoring failures for this test, bugno required.
1593 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1594 # e.g. error_ignore 5494 "your message"
1596 local TYPE="IGNORE (bz$1)"
1602 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1603 [ "$TESTSUITELOG" ] && \
1604 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1607 build_test_filter() {
1608 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1612 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1613 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1614 [ "$EXCEPT_SLOW" ] && \
1615 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1616 for E in $EXCEPT $ALWAYS_EXCEPT; do
1617 eval EXCEPT_${E}=true
1619 for E in $EXCEPT_SLOW; do
1620 eval EXCEPT_SLOW_${E}=true
1622 for G in $GRANT_CHECK_LIST; do
1623 eval GCHECK_ONLY_${G}=true
1632 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1638 export base=`basetest $1`
1639 if [ ! -z "$ONLY" ]; then
1641 if [ ${!testname}x != x ]; then
1646 if [ ${!testname}x != x ]; then
1654 if [ ${!testname}x != x ]; then
1655 TESTNAME=test_$1 skip "skipping excluded test $1"
1658 testname=EXCEPT_$base
1659 if [ ${!testname}x != x ]; then
1660 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1663 testname=EXCEPT_SLOW_$1
1664 if [ ${!testname}x != x ]; then
1665 TESTNAME=test_$1 skip "skipping SLOW test $1"
1668 testname=EXCEPT_SLOW_$base
1669 if [ ${!testname}x != x ]; then
1670 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1679 EQUALS="======================================================================"
1683 local suffixlen=$((${#EQUALS} - ${#msg}))
1684 [ $suffixlen -lt 5 ] && suffixlen=5
1685 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1690 lsmod | grep lnet > /dev/null || load_modules
1702 local NODES=$(nodes_list)
1703 for NODE in $NODES; do
1704 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1710 strace -o $TMP/$1.strace -ttt $*
1712 log "FINISHED: $*: rc $RC"
1721 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1722 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
1723 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1727 local myNODES=$(nodes_list)
1730 for NODE in $myNODES; do
1731 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1739 export tdir=d0.${TESTSUITE}/d${base}
1740 local SAVE_UMASK=`umask`
1744 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1746 export TESTNAME=test_$testnum
1747 test_${testnum} || error "test_$testnum failed with $?"
1751 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1752 check_catastrophe || error "LBUG/LASSERT detected"
1753 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1754 pass "($((`date +%s` - $BEFORE))s)"
1761 (cd `dirname $1`; echo $PWD/`basename $1`)
1765 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1766 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1771 export base=`basetest $1`
1772 [ "$CHECK_GRANT" == "no" ] && return 0
1774 testname=GCHECK_ONLY_${base}
1775 [ ${!testname}x == x ] && return 0
1777 echo -n "checking grant......"
1779 # write some data to sync client lost_grant
1780 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1781 for i in `seq $OSTCOUNT`; do
1782 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1783 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1784 count=1 > /dev/null 2>&1
1786 # sync all the data and make sure no pending data on server
1789 #get client grant and server grant
1791 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1792 client_grant=$((client_grant + $d))
1795 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1796 server_grant=$((server_grant + $d))
1799 # cleanup the check_grant file
1800 for i in `seq $OSTCOUNT`; do
1801 rm $DIR1/${tfile}_check_grant_$i
1804 #check whether client grant == server grant
1805 if [ $client_grant != $server_grant ]; then
1806 echo "failed: client:${client_grant} server: ${server_grant}"
1813 ########################
1819 ost=`echo $1 | awk -F_ '{print $3}'`
1820 if [ -z $ost ]; then
1821 ost=`echo $1 | sed 's/-osc.*//'`
1828 [ "$node" != "$(hostname)" ]
1834 for node in $(mdts_nodes); do
1835 remote_node $node && return 0
1842 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1848 for node in $(osts_nodes) ; do
1849 remote_node $node && return 0
1856 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1862 for num in `seq $MDSCOUNT`; do
1863 MDSNODES="$MDSNODES $(facet_host mds$num)"
1865 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1871 remote_ost && remote_mds
1875 local OSTNODES=$(facet_host ost1)
1878 for num in `seq $OSTCOUNT`; do
1879 local myOST=$(facet_host ost$num)
1880 OSTNODES="$OSTNODES $myOST"
1882 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1888 # FIXME. We need a list of clients
1889 local myNODES=$HOSTNAME
1892 # CLIENTS (if specified) contains the local client
1893 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1895 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1896 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1899 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1904 remote_nodes_list () {
1905 local rnodes=$(nodes_list)
1906 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1910 init_clients_lists () {
1911 # Sanity check: exclude the local client from RCLIENTS
1912 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1914 # Sanity check: exclude the dup entries
1915 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1917 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1919 # Sanity check: exclude the dup entries from CLIENTS
1920 # for those configs which has SINGLCLIENT set to local client
1921 clients=$(for i in $clients; do echo $i; done | sort -u)
1923 CLIENTS=`comma_list $clients`
1924 local -a remoteclients=($rclients)
1925 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1926 varname=CLIENT$((i + 2))
1927 eval $varname=${remoteclients[i]}
1930 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1935 lctl get_param version | grep -q patchless
1940 echo $nodes | wc -w || true
1944 local nodes=$(osts_nodes)
1945 local osscount=$(get_node_count "$nodes")
1946 [ ! "$OSTCOUNT" = "$osscount" ]
1950 local nodes=$(mdts_nodes)
1951 local mdtcount=$(get_node_count "$nodes")
1952 [ ! "$MDSCOUNT" = "$mdtcount" ]
1955 generate_machine_file() {
1956 local nodes=${1//,/ }
1957 local machinefile=$2
1958 rm -f $machinefile || error "can't rm $machinefile"
1959 for node in $nodes; do
1960 echo $node >>$machinefile
1965 local file=$1/stripe
1967 $LFS getstripe -v $file || error
1971 check_runas_id_ret() {
1976 if [ -z "$myRUNAS" ]; then
1977 error_exit "myRUNAS command must be specified for check_runas_id"
1980 $myRUNAS krb5_login.sh || \
1981 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1983 mkdir $DIR/d0_runas_test
1985 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1986 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1987 rm -rf $DIR/d0_runas_test
1995 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1996 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1997 Please set RUNAS_ID to some UID which exists on MDS and client or
1998 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
2001 # Run multiop in the background, but wait for it to print
2002 # "PAUSING" to its stdout before returning from this function.
2003 multiop_bg_pause() {
2004 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2008 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2011 echo "$MULTIOP_PROG $FILE v$ARGS"
2012 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2014 echo "TMPPIPE=${TMPPIPE}"
2015 read -t 60 multiop_output < $TMPPIPE
2016 if [ $? -ne 0 ]; then
2021 if [ "$multiop_output" != "PAUSING" ]; then
2022 echo "Incorrect multiop output: $multiop_output"
2032 local TARGET_RATE=$2
2033 local NUM_CLIENTS=$3
2036 local RATE=$(awk '/^Rate: [0-9\.]+ '"${OP}"'s\/sec/ { print $2}' ${LOG})
2038 # We need to use bc since the rate is a floating point number
2039 local RES=$(echo "${RATE} < ${TARGET_RATE}" | bc -l )
2040 if [ ${RES} -eq 0 ]; then
2041 echo "Success: ${RATE} ${OP}s/sec met target rate" \
2042 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2045 echo "Failure: ${RATE} ${OP}s/sec did not meet target rate" \
2046 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
2051 # reset llite stat counters
2052 clear_llite_stats(){
2053 lctl set_param -n llite.*.stats 0
2056 # sum llite stat items
2057 calc_llite_stats() {
2058 local res=$(lctl get_param -n llite.*.stats |
2059 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2063 # reset osc stat counters
2065 lctl set_param -n osc.*.osc_stats 0
2068 # sum osc stat items
2070 local res=$(lctl get_param -n osc.*.osc_stats |
2071 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2076 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2079 calc_osc_kbytes () {
2080 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2083 # save_lustre_params(node, parameter_mask)
2084 # generate a stream of formatted strings (<node> <param name>=<param value>)
2085 save_lustre_params() {
2087 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2090 # restore lustre parameters from input stream, produces by save_lustre_params
2091 restore_lustre_params() {
2095 while IFS=" =" read node name val; do
2096 do_node $node "lctl set_param -n $name $val"
2100 check_catastrophe () {
2101 local rnodes=$(comma_list $(remote_nodes_list))
2103 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && return 1
2104 if [ $rnodes ]; then
2105 do_nodes $rnodes "[ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"