2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
11 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
17 #export PDSH="pdsh -S -Rssh -w"
19 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
23 if [ -z "${!name}" ]; then
24 echo "$0: $name must be set"
28 [ $failed ] && exit 1 || true
33 [ -z "`echo :$DIR: | grep :$MOUNT:`" ] && \
34 failed=1 && echo "DIR not in $MOUNT. Aborting."
35 [ -z "`echo :$DIR1: | grep :$MOUNT1:`" ] && \
36 failed=1 && echo "DIR1 not in $MOUNT1. Aborting."
37 [ -z "`echo :$DIR2: | grep :$MOUNT2:`" ] && \
38 failed=1 && echo "DIR2 not in $MOUNT2. Aborting"
40 [ -n "$failed" ] && exit 99 || true
44 echo "usage: $0 [-r] [-f cfgfile]"
51 [ "$TESTSUITE" == "lfscktest" ] && return 0
52 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
53 local form="%-13s %-17s %s\n"
54 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
55 echo "------------------------------------------------------------------------------------"
56 for O in $TESTSUITE_LIST; do
59 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
62 local log=${TMP}/${o}.log
63 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
64 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
65 [ "${!O}" = "done" ] && \
66 printf "$form" "Done" "$O" "E=$skipped" && \
67 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
71 for O in $TESTSUITE_LIST; do
72 [ "${!O}" = "no" ] && \
73 printf "$form" "Skipped" "$O" ""
76 for O in $TESTSUITE_LIST; do
77 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
78 printf "$form" "UNFINISHED" "$O" ""
83 export LUSTRE=`absolute_path $LUSTRE`
84 export TESTSUITE=`basename $0 .sh`
86 #[ -d /r ] && export ROOT=${ROOT:-/r}
87 export TMP=${TMP:-$ROOT/tmp}
88 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
89 export HOSTNAME=${HOSTNAME:-`hostname`}
90 if ! echo $PATH | grep -q $LUSTRE/utils; then
91 export PATH=$PATH:$LUSTRE/utils
93 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
94 export PATH=$PATH:$LUSTRE/utils/gss
96 if ! echo $PATH | grep -q $LUSTRE/tests; then
97 export PATH=$PATH:$LUSTRE/tests
99 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
100 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate)
101 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
102 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
103 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
104 [ ! -f "$LFS" ] && export LFS=$(which lfs)
105 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
106 if [ ! -f "$L_GETIDENTITY" ]; then
107 if `which l_getidentity > /dev/null 2>&1`; then
108 export L_GETIDENTITY=$(which l_getidentity)
110 export L_GETIDENTITY=NONE
113 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
114 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
115 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
116 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
117 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
118 export FSYTPE=${FSTYPE:-"ldiskfs"}
119 export NAME=${NAME:-local}
120 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
121 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
122 export LGSSD=$(which lgssd)
123 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
124 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
125 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
127 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
130 if [ "$ACCEPTOR_PORT" ]; then
131 export PORT_OPT="--port $ACCEPTOR_PORT"
136 echo "Using GSS/krb5 ptlrpc security flavor"
137 which lgss_keyring > /dev/null 2>&1 || \
138 error "built with gss disabled! SEC=$SEC"
149 IDENTITY_UPCALL=false
153 # Paths on remote nodes, if different
154 export RLUSTRE=${RLUSTRE:-$LUSTRE}
155 export RPWD=${RPWD:-$PWD}
156 export I_MOUNTED=${I_MOUNTED:-"no"}
160 while getopts "rvf:" opt $*; do
163 r) REFORMAT=--reformat;;
169 shift $((OPTIND - 1))
172 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
181 BASE=`basename $module $EXT`
182 lsmod | grep -q ${BASE} || \
183 if [ -f ${LUSTRE}/${module}${EXT} ]; then
184 insmod ${LUSTRE}/${module}${EXT} $@
186 # must be testing a "make install" or "rpm" installation
187 # note failed to load ptlrpc_gss is considered not fatal
188 if [ "$BASE" == "ptlrpc_gss" ]; then
189 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
197 if [ -n "$MODPROBE" ]; then
201 if [ "$HAVE_MODULES" = true ]; then
207 echo Loading modules from $LUSTRE
208 load_module ../libcfs/libcfs/libcfs
209 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
210 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
211 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
212 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
213 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
214 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
215 echo "lnet options: '$LNETOPTS'"
216 # note that insmod will ignore anything in modprobe.conf
217 load_module ../lnet/lnet/lnet $LNETOPTS
218 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
219 load_module ../lnet/klnds/$LNETLND
220 load_module lvfs/lvfs
221 load_module obdclass/obdclass
222 load_module ptlrpc/ptlrpc
223 load_module ptlrpc/gss/ptlrpc_gss
224 # Now, some modules depend on lquota without USE_QUOTA check,
225 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
226 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
227 load_module quota/lquota
235 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
236 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
237 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
242 load_module lvfs/fsfilt_$FSTYPE
246 load_module obdfilter/obdfilter
249 load_module llite/lustre
250 load_module llite/llite_lloop
251 rm -f $TMP/ogdb-$HOSTNAME
253 [ -d /r ] && OGDB="/r/tmp"
254 $LCTL modules > $OGDB/ogdb-$HOSTNAME
256 # 'mount' doesn't look in $PATH, just sbin
257 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
261 if [ `uname -r | cut -c 3` -eq 4 ]; then
269 MODULES=$($LCTL modules | awk '{ print $2 }')
270 while [ -n "$MODULES" ]; do
272 $RMMOD $MODULES > /dev/null 2>&1 || true
273 MODULES=$($LCTL modules | awk '{ print $2 }')
274 if [ -z "$MODULES" ]; then
278 echo "waiting, $((MAX - WAIT)) secs left"
280 if [ $WAIT -eq $MAX ]; then
281 echo "LNET modules $MODULES will not unload"
288 unload_dep_module() {
290 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
292 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
293 for SUBMOD in $DEPS; do
294 unload_dep_module $SUBMOD
296 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
297 $RMMOD $MODULE || true
301 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
302 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
303 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
304 echo "$LEAK_LUSTRE" 1>&2
305 echo "$LEAK_PORTALS" 1>&2
306 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
307 log "Memory leaks detected"
308 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
314 wait_exit_ST client # bug 12845
316 lsmod | grep libcfs > /dev/null && $LCTL dl
317 unload_dep_module $FSTYPE
318 unload_dep_module libcfs
320 local MODULES=$($LCTL modules | awk '{ print $2 }')
321 if [ -n "$MODULES" ]; then
322 echo "Modules still loaded: "
324 if [ "$(lctl dl)" ]; then
325 echo "Lustre still loaded"
330 echo "Lustre stopped but LNET is still loaded, waiting..."
331 wait_for_lnet || return 3
337 check_mem_leak || return 254
339 echo "modules unloaded."
343 check_gss_daemon_facet() {
347 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
348 if [ $num -ne 1 ]; then
349 echo "$num instance of $dname on $facet"
358 do_facet $facet "killall -2 $@ 2>/dev/null || true"
361 start_gss_daemons() {
363 for num in `seq $MDSCOUNT`; do
364 do_facet mds$num "$LSVCGSSD -v"
366 do_facet mds$num "$LGSSD -v"
370 for num in `seq $OSTCOUNT`; do
371 do_facet ost$num "$LSVCGSSD -v"
374 # FIXME: is "client" the right facet name?
376 do_facet client "$LGSSD -v"
379 # wait daemons entering "stable" status
383 # check daemons are running
385 for num in `seq $MDSCOUNT`; do
386 check_gss_daemon_facet mds$num lsvcgssd
388 check_gss_daemon_facet mds$num lgssd
391 for num in `seq $OSTCOUNT`; do
392 check_gss_daemon_facet ost$num lsvcgssd
395 check_gss_daemon_facet client lgssd
400 for num in `seq $MDSCOUNT`; do
401 send_sigint mds$num lsvcgssd lgssd
403 for num in `seq $OSTCOUNT`; do
404 send_sigint ost$num lsvcgssd
406 send_sigint client lgssd
418 # maybe cleanup credential cache?
424 local device=`mdsdevname $num`
425 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
431 local device=`ostdevname $num`
432 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
440 local dev=${facet}_dev
441 local opt=${facet}_opt
442 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
443 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
445 if [ $RC -ne 0 ]; then
446 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
447 echo "Start of ${!dev} on ${facet} failed ${RC}"
449 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
450 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
451 lctl set_param debug_mb=${DEBUG_SIZE}; \
454 label=$(do_facet ${facet} "e2label ${!dev}")
455 [ -z "$label" ] && echo no label for ${!dev} && exit 1
456 eval export ${facet}_svc=${label}
457 echo Started ${label}
462 # start facet device options
468 eval export ${facet}_dev=${device}
469 eval export ${facet}_opt=\"$@\"
470 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
480 HOST=`facet_active_host $facet`
481 [ -z $HOST ] && echo stop: no host for $facet && return 0
483 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
484 if [ ${running} -ne 0 ]; then
485 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
486 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
489 # umount should block, but we should wait for unrelated obd's
490 # like the MGS or MGC to also stop.
491 wait_exit_ST ${facet}
498 # Only supply -o to mount if we have options
499 if [ -n "$MOUNTOPT" ]; then
500 OPTIONS="-o $MOUNTOPT"
502 local device=$MGSNID:/$FSNAME
503 if [ -z "$mnt" -o -z "$FSNAME" ]; then
504 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
508 echo "Starting client: $client: $OPTIONS $device $mnt"
509 do_node $client mkdir -p $mnt
510 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
512 do_node $client "lctl set_param debug=$PTLDEBUG;
513 lctl set_param subsystem_debug=${SUBSYSTEM# };
514 lctl set_param debug_mb=${DEBUG_SIZE}"
523 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
524 if [ $running -ne 0 ]; then
525 echo "Stopping client $client $mnt (opts:$force)"
526 lsof | grep "$mnt" || true
527 do_node $client umount $force $mnt
531 # mount clients if not mouted
532 zconf_mount_clients() {
538 # Only supply -o to mount if we have options
539 if [ -n "$MOUNTOPT" ]; then
540 OPTIONS="-o $MOUNTOPT"
542 local device=$MGSNID:/$FSNAME
543 if [ -z "$mnt" -o -z "$FSNAME" ]; then
544 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
548 echo "Starting client $clients: $OPTIONS $device $mnt"
549 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
551 echo "Started clients $clients: "
552 do_nodes $clients "mount | grep $mnt"
554 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
555 lctl set_param subsystem_debug=${SUBSYSTEM# };
556 lctl set_param debug_mb=${DEBUG_SIZE};"
561 zconf_umount_clients() {
566 echo "Umounting clients: $clients"
567 echo "Stopping clients: $clients $mnt (opts:$force)"
568 do_nodes $clients umount $force $mnt
573 if [ "$FAILURE_MODE" = HARD ]; then
574 $POWER_DOWN `facet_active_host $facet`
576 elif [ "$FAILURE_MODE" = SOFT ]; then
583 if [ "$FAILURE_MODE" = HARD ]; then
584 $POWER_UP `facet_active_host $facet`
590 # verify that lustre actually cleaned up properly
592 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
593 error "LBUG/LASSERT detected"
594 BUSY=`dmesg | grep -i destruct || true`
597 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
601 check_mem_leak || exit 204
603 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
604 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
606 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
607 echo "$0: modules still loaded..." 1>&2
614 wait_delete_completed () {
615 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
616 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
620 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
622 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
623 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
624 [ "$TOTAL" -eq "$TOTALPREV" ] && break
625 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
629 echo "Delete completed."
634 check_network "$HOST" 900
635 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
640 HOST=`facet_active_host $facet`
644 wait_mds_recovery_done () {
645 local timeout=`do_facet mds lctl get_param -n timeout`
646 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
647 # as we are in process of changing obd_timeout in different ways
648 # let's set MAX longer than that
649 MAX=$(( timeout * 4 ))
651 while [ $WAIT -lt $MAX ]; do
652 STATUS=`do_facet $SINGLEMDS "lctl get_param -n mdt.*-MDT*.recovery_status | grep status"`
653 echo $STATUS | grep COMPLETE && return 0
656 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
658 echo "MDS recovery not done in $MAX sec"
667 # conf-sanity 31 takes a long time cleanup
668 while [ $WAIT -lt 300 ]; do
669 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
670 [ -z "${running}" ] && return 0
671 echo "waited $WAIT for${running}"
672 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
674 WAIT=$((WAIT + INTERVAL))
676 echo "service didn't stop after $WAIT seconds. Still running:"
681 wait_remote_prog () {
687 [ "$PDSH" = "no_dsh" ] && return 0
689 while [ $WAIT -lt $2 ]; do
690 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep)
691 [ -z "${running}" ] && return 0
692 echo "waited $WAIT for: "
694 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
696 WAIT=$((WAIT + INTERVAL))
698 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
699 [ -z "$pids" ] && return 0
700 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
702 cat /proc/${pid}/status || true
703 cat /proc/${pid}/wchan || true
714 # not every config has many clients
715 if [ ! -z "$CLIENTS" ]; then
716 $PDSH $CLIENTS "df $MOUNT" > /dev/null
718 df $MOUNT > /dev/null
723 uname -n >> $MOUNT/recon
724 if [ -z "$CLIENTS" ]; then
725 df $MOUNT; uname -n >> $MOUNT/recon
727 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
729 echo Connected clients:
731 ls -l $MOUNT/recon > /dev/null
737 echo "Failing $facet on node `facet_active_host $facet`"
738 shutdown_facet $facet
742 echo "df pid is $DFPID"
744 TO=`facet_active_host $facet`
745 echo "Failover $facet to $TO"
747 mount_facet $facet || error "Restart of $facet failed"
758 local svc=${facet}_svc
759 do_facet $facet $LCTL --device %${!svc} readonly
760 do_facet $facet $LCTL --device %${!svc} notransno
761 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
762 $LCTL mark "local REPLAY BARRIER on ${!svc}"
765 replay_barrier_nodf() {
766 local facet=$1 echo running=${running}
768 local svc=${facet}_svc
769 echo Replay barrier on ${!svc}
770 do_facet $facet $LCTL --device %${!svc} readonly
771 do_facet $facet $LCTL --device %${!svc} notransno
772 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
773 $LCTL mark "local REPLAY BARRIER on ${!svc}"
777 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
778 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
782 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
783 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
787 facet_failover $* || error "failover: $?"
788 df $MOUNT || error "post-failover df: $?"
793 facet_failover $facet
800 mount_facet $facet -o abort_recovery
801 df $MOUNT || echo "first df failed: $?"
803 df $MOUNT || error "post-failover df: $?"
807 echo There is no lmc. This is mountconf, baby.
812 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
813 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
819 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
825 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
826 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
827 if [ -z "$ID" ]; then
828 echo "Could not get a ptl id for $1..."
837 h2name_or_ip "$1" "tcp"
842 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
843 if type __h2elan >/dev/null 2>&1; then
846 ID=`echo $1 | sed 's/[^0-9]*//g'`
854 h2name_or_ip "$1" "openib"
859 h2name_or_ip "$1" "o2ib"
865 varname=${facet}_HOST
866 if [ -z "${!varname}" ]; then
867 if [ "${facet:0:3}" == "ost" ]; then
868 eval ${facet}_HOST=${ost_HOST}
876 local activevar=${facet}active
878 if [ -f $TMP/${facet}active ] ; then
879 source $TMP/${facet}active
883 if [ -z "$active" ] ; then
890 facet_active_host() {
892 local active=`facet_active $facet`
893 if [ "$facet" == client ]; then
896 echo `facet_host $active`
902 failover=${facet}failover
903 host=`facet_host $failover`
904 [ -z "$host" ] && return
905 curactive=`facet_active $facet`
906 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
907 eval export ${facet}active=$facet
909 eval export ${facet}active=$failover
911 # save the active host for this facet
912 activevar=${facet}active
913 echo "$activevar=${!activevar}" > $TMP/$activevar
920 if [ "$HOST" = "$HOSTNAME" ]; then
922 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
923 echo "cannot run remote command on $HOST with $myPDSH"
927 echo "CMD: $HOST $@" >&2
928 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
931 if [ "$myPDSH" = "rsh" ]; then
932 # we need this because rsh does not return exit code of an executed command
933 local command_status="$TMP/cs"
934 rsh $HOST ":> $command_status"
935 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
936 cd $RPWD; sh -c \"$@\") ||
937 echo command failed >$command_status"
938 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
941 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
942 return ${PIPESTATUS[0]}
949 # This is part from do_node
952 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
953 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
956 echo "CMD: $rnodes $@" >&2
957 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
960 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
961 return ${PIPESTATUS[0]}
967 HOST=`facet_active_host $facet`
968 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
975 # make sure its not already running
977 rm -f $TMP/${facet}active
978 do_facet ${facet} $MKFS $*
984 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
985 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
992 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
993 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1001 # make sure we are using the primary server, so test-framework will
1002 # be able to clean up properly.
1003 activemds=`facet_active mds1`
1004 if [ $activemds != "mds1" ]; then
1008 # assume client mount is local
1009 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1010 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1012 if [ -n "$CLIENTS" ]; then
1013 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1014 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1017 [ "$CLIENTONLY" ] && return
1018 # The add fn does rm ${facet}active file, this would be enough
1019 # if we use do_facet <facet> only after the facet added, but
1020 # currently we use do_facet mds in local.sh
1021 for num in `seq $MDSCOUNT`; do
1023 rm -f ${TMP}/mds${num}active
1026 for num in `seq $OSTCOUNT`; do
1028 rm -f $TMP/ost${num}active
1043 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1047 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1049 if [ ! -z $SEC ]; then
1050 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1051 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1055 # We need ldiskfs here, may as well load them all
1057 [ "$CLIENTONLY" ] && return
1058 echo "Formatting mdts, osts"
1059 for num in `seq $MDSCOUNT`; do
1060 echo "Format mds$num: $(mdsdevname $num)"
1062 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1064 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1068 for num in `seq $OSTCOUNT`; do
1069 echo "Format ost$num: $(ostdevname $num)"
1071 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1073 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1079 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1083 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1087 # 0: success, the old identity set already.
1088 # 1: success, the old identity does not set.
1093 local j=`expr $num - 1`
1094 local MDT="`do_facet mds$num lctl get_param -N mdt.*MDT*$j | cut -d"." -f2 2>/dev/null || true`"
1096 if [ -z "$MDT" ]; then
1100 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1103 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1105 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1108 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1110 if [ $old = "NONE" ]; then
1119 zconf_umount `hostname` $1 || error "umount failed"
1120 zconf_mount `hostname` $1 || error "mount failed"
1127 do_facet $facet lsmod | grep -q obdclass || \
1128 do_facet $facet "modprobe obdclass"
1130 do_facet $facet "lctl set_param timeout=$timeout"
1136 if [ -z "$CLIENTONLY" ]; then
1137 echo "Setup mdts, osts"
1138 for num in `seq $MDSCOUNT`; do
1139 DEVNAME=$(mdsdevname $num)
1140 echo $REFORMAT | grep -q "reformat" \
1141 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1142 set_obd_timeout mds$num $TIMEOUT
1143 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1145 # We started mds, now we should set failover variables properly.
1146 # Set mds${num}failover_HOST if it is not set (the default failnode).
1147 local varname=mds${num}failover_HOST
1148 if [ -z "${!varname}" ]; then
1149 eval mds${num}failover_HOST=$(facet_host mds$num)
1152 if [ $IDENTITY_UPCALL != "default" ]; then
1153 switch_identity $num $IDENTITY_UPCALL
1156 for num in `seq $OSTCOUNT`; do
1157 DEVNAME=$(ostdevname $num)
1158 set_obd_timeout ost$num $TIMEOUT
1159 start ost$num $DEVNAME $OST_MOUNT_OPTS
1161 # We started ost$num, now we should set ost${num}failover variable properly.
1162 # Set ost${num}failover_HOST if it is not set (the default failnode).
1163 varname=ost${num}failover_HOST
1164 if [ -z "${!varname}" ]; then
1165 eval ost${num}failover_HOST=$(facet_host ost${num})
1170 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1172 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1174 if [ "$MOUNT_2" ]; then
1175 mount_client $MOUNT2
1176 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1179 # by remounting mdt before ost, initial connect from mdt to ost might
1180 # timeout because ost is not ready yet. wait some time to its fully
1181 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1182 # by a context negotiation rpc with $TIMEOUT.
1183 # FIXME better by monitoring import status.
1185 sleep $((TIMEOUT + 5))
1191 mounted_lustre_filesystems() {
1192 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1195 check_and_setup_lustre() {
1196 MOUNTED="`mounted_lustre_filesystems`"
1197 if [ -z "$MOUNTED" ]; then
1198 [ "$REFORMAT" ] && formatall
1200 MOUNTED="`mounted_lustre_filesystems`"
1201 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1202 export I_MOUNTED=yes
1204 if [ "$ONLY" == "setup" ]; then
1209 cleanup_and_setup_lustre() {
1210 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1211 lctl set_param debug=0 || true
1213 if [ "$ONLY" == "cleanup" ]; then
1217 check_and_setup_lustre
1220 check_and_cleanup_lustre() {
1221 if [ "`mount | grep $MOUNT`" ]; then
1222 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1224 if [ "$I_MOUNTED" = "yes" ]; then
1225 cleanupall -f || error "cleanup failed"
1237 while [ $NETWORK -eq 0 ]; do
1238 ping -c 1 -w 3 $1 > /dev/null
1239 if [ $? -eq 0 ]; then
1243 echo "waiting for $1, $((MAX - WAIT)) secs left"
1246 if [ $WAIT -gt $MAX ]; then
1247 echo "Network not available"
1253 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1264 # the sed converts spaces to commas, but leaves the last space
1265 # alone, so the line doesn't end with a comma.
1266 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1270 (cd `dirname $1`; echo $PWD/`basename $1`)
1273 ##################################
1274 # Adaptive Timeouts funcs
1277 if [ -z "$AT_MAX_PATH" ]; then
1278 AT_MAX_PATH=$(do_facet mds "find /sys/ -name at_max")
1279 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1285 at_is_valid || error "invalid call"
1287 # only check mds, we assume at_max is the same on all nodes
1288 local at_max=$(do_facet mds "cat $AT_MAX_PATH")
1289 if [ $at_max -eq 0 ]; then
1299 at_is_valid || error "invalid call"
1301 # suppose that all ost-s has the same at_max set
1302 if [ $facet == "ost" ]; then
1303 do_facet ost1 "cat $AT_MAX_PATH"
1305 do_facet $facet "cat $AT_MAX_PATH"
1313 at_is_valid || error "invalid call"
1317 if [ $facet == "ost" ]; then
1318 for i in `seq $OSTCOUNT`; do
1319 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1321 elif [ $facet == "mds" ]; then
1322 for i in `seq $MDSCOUNT`; do
1323 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1326 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1331 ##################################
1335 # OBD_FAIL_MDS_ALL_REQUEST_NET
1337 do_facet mds lctl set_param fail_loc=0x123
1338 do_facet client "$1" || RC=$?
1339 do_facet mds lctl set_param fail_loc=0
1344 # OBD_FAIL_MDS_ALL_REPLY_NET
1346 do_facet mds lctl set_param fail_loc=0x122
1347 do_facet client "$@" || RC=$?
1348 do_facet mds lctl set_param fail_loc=0
1352 drop_reint_reply() {
1353 # OBD_FAIL_MDS_REINT_NET_REP
1355 do_facet mds lctl set_param fail_loc=0x119
1356 do_facet client "$@" || RC=$?
1357 do_facet mds lctl set_param fail_loc=0
1362 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1364 do_facet ost1 lctl set_param fail_loc=0x214
1365 do_facet client "$1" || RC=$?
1366 do_facet client "sync"
1367 do_facet ost1 lctl set_param fail_loc=0
1371 drop_ldlm_cancel() {
1372 #define OBD_FAIL_LDLM_CANCEL 0x304
1374 do_facet client lctl set_param fail_loc=0x304
1375 do_facet client "$@" || RC=$?
1376 do_facet client lctl set_param fail_loc=0
1380 drop_bl_callback() {
1381 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1383 do_facet client lctl set_param fail_loc=0x305
1384 do_facet client "$@" || RC=$?
1385 do_facet client lctl set_param fail_loc=0
1390 #define OBD_FAIL_LDLM_REPLY 0x30c
1392 do_facet mds lctl set_param fail_loc=0x30c
1393 do_facet client "$@" || RC=$?
1394 do_facet mds lctl set_param fail_loc=0
1402 echo "clearing fail_loc on $facet"
1403 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1406 set_nodes_failloc () {
1410 for node in $nodes ; do
1411 do_node $node lctl set_param fail_loc=$2
1415 set_nodes_failloc () {
1419 for node in $nodes ; do
1420 do_node $node lctl set_param fail_loc=$2
1424 cancel_lru_locks() {
1425 $LCTL mark "cancel_lru_locks $1 start"
1426 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1427 $LCTL set_param -n $d=clear
1429 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1430 $LCTL mark "cancel_lru_locks $1 stop"
1435 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1436 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1437 echo "$DEFAULT_LRU_SIZE"
1442 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1445 lru_resize_disable()
1447 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1452 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1453 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1454 echo there is still data in page cache $FILE ?
1455 lctl get_param -n $FILE
1463 DEBUGSAVE="$(lctl get_param -n debug)"
1467 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1471 ##################################
1473 ##################################
1476 local TYPE=${TYPE:-"FAIL"}
1478 lctl set_param fail_loc=0 2>/dev/null || true
1479 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1480 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1481 echo "Dumping lctl log to $ERRLOG"
1482 # We need to dump the logs on all nodes
1483 local NODES=$(nodes_list)
1484 for NODE in $NODES; do
1485 do_node $NODE $LCTL dk $ERRLOG
1488 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1493 $FAIL_ON_ERROR && exit 1 || true
1501 # use only if we are ignoring failures for this test, bugno required.
1502 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1503 # e.g. error_ignore 5494 "your message"
1505 local TYPE="IGNORE (bz$1)"
1511 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1512 [ "$TESTSUITELOG" ] && \
1513 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1516 build_test_filter() {
1517 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1521 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1522 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1523 [ "$EXCEPT_SLOW" ] && \
1524 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1525 for E in $EXCEPT $ALWAYS_EXCEPT; do
1526 eval EXCEPT_${E}=true
1528 for E in $EXCEPT_SLOW; do
1529 eval EXCEPT_SLOW_${E}=true
1531 for G in $GRANT_CHECK_LIST; do
1532 eval GCHECK_ONLY_${G}=true
1541 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1547 export base=`basetest $1`
1548 if [ ! -z "$ONLY" ]; then
1550 if [ ${!testname}x != x ]; then
1555 if [ ${!testname}x != x ]; then
1563 if [ ${!testname}x != x ]; then
1564 TESTNAME=test_$1 skip "skipping excluded test $1"
1567 testname=EXCEPT_$base
1568 if [ ${!testname}x != x ]; then
1569 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1572 testname=EXCEPT_SLOW_$1
1573 if [ ${!testname}x != x ]; then
1574 TESTNAME=test_$1 skip "skipping SLOW test $1"
1577 testname=EXCEPT_SLOW_$base
1578 if [ ${!testname}x != x ]; then
1579 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1588 EQUALS="======================================================================"
1592 local suffixlen=$((${#EQUALS} - ${#msg}))
1593 [ $suffixlen -lt 5 ] && suffixlen=5
1594 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1599 lsmod | grep lnet > /dev/null || load_modules
1611 local NODES=$(nodes_list)
1612 for NODE in $NODES; do
1613 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1619 strace -o $TMP/$1.strace -ttt $*
1621 log "FINISHED: $*: rc $RC"
1630 FFREE=`lctl get_param -n osd.*MDT*.filesfree`
1631 FTOTAL=`lctl get_param -n osd.*MDT*.filestotal`
1632 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1636 local myNODES=$(nodes_list)
1639 for NODE in $myNODES; do
1640 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
1648 export tdir=d0.${TESTSUITE}/d${base}
1649 local SAVE_UMASK=`umask`
1653 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1655 export TESTNAME=test_$testnum
1656 test_${testnum} || error "test_$testnum failed with $?"
1660 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1661 check_catastrophe || error "LBUG/LASSERT detected"
1662 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1663 pass "($((`date +%s` - $BEFORE))s)"
1671 (cd `dirname $1`; echo $PWD/`basename $1`)
1675 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1676 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1681 export base=`basetest $1`
1682 [ "$CHECK_GRANT" == "no" ] && return 0
1684 testname=GCHECK_ONLY_${base}
1685 [ ${!testname}x == x ] && return 0
1687 echo -n "checking grant......"
1689 # write some data to sync client lost_grant
1690 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1691 for i in `seq $OSTCOUNT`; do
1692 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1693 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1694 count=1 > /dev/null 2>&1
1696 # sync all the data and make sure no pending data on server
1699 #get client grant and server grant
1701 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
1702 client_grant=$((client_grant + $d))
1705 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
1706 server_grant=$((server_grant + $d))
1709 # cleanup the check_grant file
1710 for i in `seq $OSTCOUNT`; do
1711 rm $DIR1/${tfile}_check_grant_$i
1714 #check whether client grant == server grant
1715 if [ $client_grant != $server_grant ]; then
1716 echo "failed: client:${client_grant} server: ${server_grant}"
1723 ########################
1729 ost=`echo $1 | awk -F_ '{print $3}'`
1730 if [ -z $ost ]; then
1731 ost=`echo $1 | sed 's/-osc.*//'`
1738 [ -z "$(lctl dl | grep mdt)" ]
1743 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1748 [ -z "$(lctl dl | grep ost)" ]
1753 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1757 local MDSNODES=$(facet_host $SINGLEMDS)
1760 # FIXME: Currenly we use only $SINGLEMDS,
1761 # should be fixed when we will start to test cmd.
1765 for num in `seq $MDSCOUNT`; do
1766 local myMDS=$(facet_host mds$num)
1767 MDSNODES="$MDSNODES $myMDS"
1769 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1775 local OSTNODES=$(facet_host ost1)
1778 for num in `seq $OSTCOUNT`; do
1779 local myOST=$(facet_host ost$num)
1780 OSTNODES="$OSTNODES $myOST"
1782 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1788 # FIXME. We need a list of clients
1789 local myNODES=$HOSTNAME
1792 # CLIENTS (if specified) contains the local client
1793 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
1795 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1796 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1799 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1804 remote_nodes_list () {
1805 local rnodes=$(nodes_list)
1806 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1810 init_clients_lists () {
1811 # Sanity check: exclude the local client from RCLIENTS
1812 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
1814 # Sanity check: exclude the dup entries
1815 rclients=$(for i in $rclients; do echo $i; done | sort -u)
1817 local clients="$SINGLECLIENT $HOSTNAME $rclients"
1819 # Sanity check: exclude the dup entries from CLIENTS
1820 # for those configs which has SINGLCLIENT set to local client
1821 clients=$(for i in $clients; do echo $i; done | sort -u)
1823 CLIENTS=`comma_list $clients`
1824 local -a remoteclients=($rclients)
1825 for ((i=0; $i<${#remoteclients[@]}; i++)); do
1826 varname=CLIENT$((i + 2))
1827 eval $varname=${remoteclients[i]}
1830 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
1835 lctl get_param version | grep -q patchless
1840 echo $nodes | wc -w || true
1844 local nodes=$(osts_nodes)
1845 local osscount=$(get_node_count "$nodes")
1846 [ ! "$OSTCOUNT" = "$osscount" ]
1849 generate_machine_file() {
1850 local nodes=${1//,/ }
1851 local machinefile=$2
1852 rm -f $machinefile || error "can't rm $machinefile"
1853 for node in $nodes; do
1854 echo $node >>$machinefile
1859 local file=$1/stripe
1861 $LFS getstripe -v $file || error
1865 check_runas_id_ret() {
1870 if [ -z "$myRUNAS" ]; then
1871 error_exit "myRUNAS command must be specified for check_runas_id"
1874 $myRUNAS krb5_login.sh || \
1875 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1877 mkdir $DIR/d0_runas_test
1879 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1880 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1881 rm -rf $DIR/d0_runas_test
1889 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1890 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1891 Please set RUNAS_ID to some UID which exists on MDS and client or
1892 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1895 # Run multiop in the background, but wait for it to print
1896 # "PAUSING" to its stdout before returning from this function.
1897 multiop_bg_pause() {
1898 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1902 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1905 echo "$MULTIOP_PROG $FILE v$ARGS"
1906 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1908 echo "TMPPIPE=${TMPPIPE}"
1909 read -t 60 multiop_output < $TMPPIPE
1910 if [ $? -ne 0 ]; then
1915 if [ "$multiop_output" != "PAUSING" ]; then
1916 echo "Incorrect multiop output: $multiop_output"
1926 local TARGET_RATE=$2
1927 local NUM_CLIENTS=$3
1930 local RATE=$(awk '/^Rate: [0-9\.]+ '"${OP}"'s\/sec/ { print $2}' ${LOG})
1932 # We need to use bc since the rate is a floating point number
1933 local RES=$(echo "${RATE} < ${TARGET_RATE}" | bc -l )
1934 if [ ${RES} -eq 0 ]; then
1935 echo "Success: ${RATE} ${OP}s/sec met target rate" \
1936 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
1939 echo "Failure: ${RATE} ${OP}s/sec did not meet target rate" \
1940 "${TARGET_RATE} ${OP}s/sec for ${NUM_CLIENTS} client(s)."
1945 # reset llite stat counters
1946 clear_llite_stats(){
1947 lctl set_param -n llite.*.stats 0
1950 # sum llite stat items
1951 calc_llite_stats() {
1952 local res=$(lctl get_param -n llite.*.stats |
1953 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1957 # save_lustre_params(node, parameter_mask)
1958 # generate a stream of formatted strings (<node> <param name>=<param value>)
1959 save_lustre_params() {
1961 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1964 # restore lustre parameters from input stream, produces by save_lustre_params
1965 restore_lustre_params() {
1969 while IFS=" =" read node name val; do
1970 do_node $node "lctl set_param -n $name $val"
1974 check_catastrophe () {
1975 local rnodes=$(comma_list $(remote_nodes_list))
1977 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && return 1
1978 if [ $rnodes ]; then
1979 do_nodes $rnodes "[ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"