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
32 echo "usage: $0 [-r] [-f cfgfile]"
39 [ "$TESTSUITE" == "lfscktest" ] && return 0
40 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
41 local form="%-13s %-17s %s\n"
42 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
43 echo "------------------------------------------------------------------------------------"
44 for O in $TESTSUITE_LIST; do
47 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
50 local log=${TMP}/${o}.log
51 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
52 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
53 [ "${!O}" = "done" ] && \
54 printf "$form" "Done" "$O" "E=$skipped" && \
55 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
59 for O in $TESTSUITE_LIST; do
60 [ "${!O}" = "no" ] && \
61 printf "$form" "Skipped" "$O" ""
64 for O in $TESTSUITE_LIST; do
65 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
66 printf "$form" "UNFINISHED" "$O" ""
71 export LUSTRE=`absolute_path $LUSTRE`
72 export TESTSUITE=`basename $0 .sh`
73 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
75 [ -d /r ] && export ROOT=${ROOT:-/r}
76 export TMP=${TMP:-$ROOT/tmp}
77 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
78 export HOSTNAME=${HOSTNAME:-`hostname`}
80 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
81 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
82 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
83 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
84 [ ! -f "$LFS" ] && export LFS=$(which lfs)
85 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
86 if [ ! -f "$L_GETIDENTITY" ]; then
87 if `which l_getidentity > /dev/null 2>&1`; then
88 export L_GETIDENTITY=$(which l_getidentity)
90 export L_GETIDENTITY=NONE
93 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
94 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
95 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
96 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
97 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
98 export FSYTPE=${FSTYPE:-"ldiskfs"}
99 export NAME=${NAME:-local}
100 export LPROC=/proc/fs/lustre
101 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
102 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
103 export LGSSD=$(which lgssd)
104 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
105 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
106 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
109 if [ "$ACCEPTOR_PORT" ]; then
110 export PORT_OPT="--port $ACCEPTOR_PORT"
115 echo "Using GSS/krb5 ptlrpc security flavor"
126 IDENTITY_UPCALL=false
130 # Paths on remote nodes, if different
131 export RLUSTRE=${RLUSTRE:-$LUSTRE}
132 export RPWD=${RPWD:-$PWD}
133 export I_MOUNTED=${I_MOUNTED:-"no"}
137 while getopts "rvf:" opt $*; do
140 r) REFORMAT=--reformat;;
146 shift $((OPTIND - 1))
149 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
157 BASE=`basename $module $EXT`
158 lsmod | grep -q ${BASE} || \
159 if [ -f ${LUSTRE}/${module}${EXT} ]; then
160 insmod ${LUSTRE}/${module}${EXT} $@
162 # must be testing a "make install" or "rpm" installation
163 # note failed to load ptlrpc_gss is considered not fatal
164 if [ "$BASE" == "ptlrpc_gss" ]; then
165 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
173 if [ -n "$MODPROBE" ]; then
177 if [ "$HAVE_MODULES" = true ]; then
183 echo Loading modules from $LUSTRE
184 load_module ../lnet/libcfs/libcfs
185 [ "$PTLDEBUG" ] && sysctl -w lnet.debug=$PTLDEBUG
186 [ "$SUBSYSTEM" ] && sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }
187 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
188 [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
189 [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
190 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
191 echo "lnet options: '$LNETOPTS'"
192 # note that insmod will ignore anything in modprobe.conf
193 load_module ../lnet/lnet/lnet $LNETOPTS
194 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
195 load_module ../lnet/klnds/$LNETLND
196 load_module lvfs/lvfs
197 load_module obdclass/obdclass
198 load_module ptlrpc/ptlrpc
199 load_module ptlrpc/gss/ptlrpc_gss
200 # Now, some modules depend on lquota without USE_QUOTA check,
201 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
202 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
203 load_module quota/lquota
211 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
212 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
213 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
218 load_module lvfs/fsfilt_$FSTYPE
222 load_module obdfilter/obdfilter
225 load_module llite/lustre
226 load_module llite/llite_lloop
227 rm -f $TMP/ogdb-$HOSTNAME
229 [ -d /r ] && OGDB="/r/tmp"
230 $LCTL modules > $OGDB/ogdb-$HOSTNAME
232 # 'mount' doesn't look in $PATH, just sbin
233 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
237 if [ `uname -r | cut -c 3` -eq 4 ]; then
245 MODULES=$($LCTL modules | awk '{ print $2 }')
246 while [ -n "$MODULES" ]; do
248 $RMMOD $MODULES > /dev/null 2>&1 || true
249 MODULES=$($LCTL modules | awk '{ print $2 }')
250 if [ -z "$MODULES" ]; then
254 echo "waiting, $((MAX - WAIT)) secs left"
256 if [ $WAIT -eq $MAX ]; then
257 echo "LNET modules $MODULES will not unload"
265 wait_exit_ST client # bug 12845
267 lsmod | grep libcfs > /dev/null && $LCTL dl
268 local MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
269 $RMMOD $MODULES > /dev/null 2>&1 || true
270 # do it again, in case we tried to unload ksocklnd too early
271 MODULES=$($LCTL modules | awk '{ print $2 }' | grep -v libcfs) || true
272 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
273 lsmod | grep libcfs > /dev/null && $LCTL dk $TMP/debug
275 MODULES=$($LCTL modules | awk '{ print $2 }')
276 if [ -n "$MODULES" ]; then
277 echo "Modules still loaded: "
279 if [ "$(lctl dl)" ]; then
280 echo "Lustre still loaded"
285 echo "Lustre stopped but LNET is still loaded, waiting..."
286 wait_for_lnet || return 3
292 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
293 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
294 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
295 echo "$LEAK_LUSTRE" 1>&2
296 echo "$LEAK_PORTALS" 1>&2
297 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
298 echo "Memory leaks detected"
299 [ -n "$IGNORE_LEAK" ] && echo "ignoring leaks" && return 0
302 echo "modules unloaded."
306 check_gss_daemon_facet() {
310 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
311 if [ $num -ne 1 ]; then
312 echo "$num instance of $dname on $facet"
321 do_facet $facet "killall -2 $@ 2>/dev/null || true"
324 start_gss_daemons() {
326 for num in `seq $MDSCOUNT`; do
327 do_facet mds$num "$LSVCGSSD -v"
329 do_facet mds$num "$LGSSD -v"
333 for num in `seq $OSTCOUNT`; do
334 do_facet ost$num "$LSVCGSSD -v"
337 # FIXME: is "client" the right facet name?
339 do_facet client "$LGSSD -v"
342 # wait daemons entering "stable" status
346 # check daemons are running
348 for num in `seq $MDSCOUNT`; do
349 check_gss_daemon_facet mds$num lsvcgssd
351 check_gss_daemon_facet mds$num lgssd
354 for num in `seq $OSTCOUNT`; do
355 check_gss_daemon_facet ost$num lsvcgssd
358 check_gss_daemon_facet client lgssd
363 for num in `seq $MDSCOUNT`; do
364 send_sigint mds$num lsvcgssd lgssd
366 for num in `seq $OSTCOUNT`; do
367 send_sigint ost$num lsvcgssd
369 send_sigint client lgssd
381 # maybe cleanup credential cache?
387 local device=`mdsdevname $num`
388 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
394 local device=`ostdevname $num`
395 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
403 local dev=${facet}_dev
404 local opt=${facet}_opt
405 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
406 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
408 if [ $RC -ne 0 ]; then
409 echo "mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}"
410 echo "Start of ${device} on ${facet} failed ${RC}"
412 do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
413 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
414 sysctl -w lnet.debug_mb=${DEBUG_SIZE}; \
420 # start facet device options
426 eval export ${facet}_dev=${device}
427 eval export ${facet}_opt=\"$@\"
428 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
431 if [ $RC -eq 0 ]; then
432 label=$(do_facet ${facet} "e2label ${device}")
433 [ -z "$label" ] && echo no label for ${device} && exit 1
434 eval export ${facet}_svc=${label}
435 echo Started ${label}
444 HOST=`facet_active_host $facet`
445 [ -z $HOST ] && echo stop: no host for $facet && return 0
447 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
448 if [ ${running} -ne 0 ]; then
449 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
450 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
453 # umount should block, but we should wait for unrelated obd's
454 # like the MGS or MGC to also stop.
455 wait_exit_ST ${facet}
462 # Only supply -o to mount if we have options
463 if [ -n "$MOUNTOPT" ]; then
464 OPTIONS="-o $MOUNTOPT"
466 local device=$MGSNID:/$FSNAME
467 if [ -z "$mnt" -o -z "$FSNAME" ]; then
468 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
472 echo "Starting client: $OPTIONS $device $mnt"
473 do_node $client mkdir -p $mnt
474 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
476 do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
477 sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
478 sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
479 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
487 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
488 if [ $running -ne 0 ]; then
489 echo "Stopping client $mnt (opts:$force)"
490 lsof | grep "$mnt" || true
491 do_node $client umount $force $mnt
497 if [ "$FAILURE_MODE" = HARD ]; then
498 $POWER_DOWN `facet_active_host $facet`
500 elif [ "$FAILURE_MODE" = SOFT ]; then
507 if [ "$FAILURE_MODE" = HARD ]; then
508 $POWER_UP `facet_active_host $facet`
514 # verify that lustre actually cleaned up properly
516 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
517 error "LBUG/LASSERT detected"
518 BUSY=`dmesg | grep -i destruct || true`
521 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
524 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
525 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
526 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
527 echo "$0: $LEAK_LUSTRE" 1>&2
528 echo "$0: $LEAK_PORTALS" 1>&2
529 echo "$0: Memory leak(s) detected..." 1>&2
530 mv $TMP/debug $TMP/debug-leak.`date +%s`
534 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
535 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
537 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
538 echo "$0: modules still loaded..." 1>&2
545 wait_delete_completed () {
546 local TOTALPREV=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
547 $LPROC/osc/*/kbytesavail`
551 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
553 TOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
554 $LPROC/osc/*/kbytesavail`
555 [ "$TOTAL" -eq "$TOTALPREV" ] && break
556 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
560 echo "Delete completed."
565 check_network "$HOST" 900
566 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
571 HOST=`facet_active_host $facet`
575 wait_mds_recovery_done () {
576 local timeout=`do_facet mds sysctl -n lustre.timeout`
577 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
578 # as we are in process of changing obd_timeout in different ways
579 # let's set MAX longer than that
580 MAX=$(( timeout * 4 ))
582 while [ $WAIT -lt $MAX ]; do
583 STATUS=`do_facet $SINGLEMDS grep status /proc/fs/lustre/mdt/*-MDT*/recovery_status`
584 echo $STATUS | grep COMPLETE && return 0
587 echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
589 echo "MDS recovery not done in $MAX sec"
598 # conf-sanity 31 takes a long time cleanup
599 while [ $WAIT -lt 300 ]; do
600 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
601 [ -z "${running}" ] && return 0
602 echo "waited $WAIT for${running}"
603 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
605 WAIT=$((WAIT + INTERVAL))
607 echo "service didn't stop after $WAIT seconds. Still running:"
613 # not every config has many clients
614 if [ ! -z "$CLIENTS" ]; then
615 $PDSH $CLIENTS "df $MOUNT" > /dev/null
620 uname -n >> $MOUNT/recon
621 if [ ! -z "$CLIENTS" ]; then
622 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
624 echo Connected clients:
626 ls -l $MOUNT/recon > /dev/null
632 echo "Failing $facet on node `facet_active_host $facet`"
633 shutdown_facet $facet
637 echo "df pid is $DFPID"
639 TO=`facet_active_host $facet`
640 echo "Failover $facet to $TO"
642 mount_facet $facet || error "Restart of $facet failed"
653 local svc=${facet}_svc
654 do_facet $facet $LCTL --device %${!svc} readonly
655 do_facet $facet $LCTL --device %${!svc} notransno
656 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
657 $LCTL mark "local REPLAY BARRIER on ${!svc}"
660 replay_barrier_nodf() {
661 local facet=$1 echo running=${running}
663 local svc=${facet}_svc
664 echo Replay barrier on ${!svc}
665 do_facet $facet $LCTL --device %${!svc} readonly
666 do_facet $facet $LCTL --device %${!svc} notransno
667 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
668 $LCTL mark "local REPLAY BARRIER on ${!svc}"
672 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
673 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
677 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
678 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
682 facet_failover $* || error "failover: $?"
683 df $MOUNT || error "post-failover df: $?"
688 facet_failover $facet
695 mount_facet $facet -o abort_recovery
696 df $MOUNT || echo "first df failed: $?"
698 df $MOUNT || error "post-failover df: $?"
702 echo There is no lmc. This is mountconf, baby.
707 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
708 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
714 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
720 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
721 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
722 if [ -z "$ID" ]; then
723 echo "Could not get a ptl id for $1..."
732 h2name_or_ip "$1" "tcp"
737 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
738 if type __h2elan >/dev/null 2>&1; then
741 ID=`echo $1 | sed 's/[^0-9]*//g'`
749 h2name_or_ip "$1" "openib"
754 h2name_or_ip "$1" "o2ib"
760 varname=${facet}_HOST
761 if [ -z "${!varname}" ]; then
762 if [ "${facet:0:3}" == "ost" ]; then
763 eval ${facet}_HOST=${ost_HOST}
771 local activevar=${facet}active
773 if [ -f ./${facet}active ] ; then
774 source ./${facet}active
778 if [ -z "$active" ] ; then
785 facet_active_host() {
787 local active=`facet_active $facet`
788 if [ "$facet" == client ]; then
791 echo `facet_host $active`
797 failover=${facet}failover
798 host=`facet_host $failover`
799 [ -z "$host" ] && return
800 curactive=`facet_active $facet`
801 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
802 eval export ${facet}active=$facet
804 eval export ${facet}active=$failover
806 # save the active host for this facet
807 activevar=${facet}active
808 echo "$activevar=${!activevar}" > ./$activevar
815 if [ "$HOST" = "$HOSTNAME" ]; then
817 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
818 echo "cannot run remote command on $HOST with $myPDSH"
822 echo "CMD: $HOST $@" >&2
823 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
826 if [ "$myPDSH" = "rsh" ]; then
827 # we need this because rsh does not return exit code of an executed command
828 local command_status="$TMP/cs"
829 rsh $HOST ":> $command_status"
830 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
831 cd $RPWD; sh -c \"$@\") ||
832 echo command failed >$command_status"
833 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
836 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
837 return ${PIPESTATUS[0]}
843 HOST=`facet_active_host $facet`
844 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
851 # make sure its not already running
854 do_facet ${facet} $MKFS $*
860 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
861 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
868 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
869 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
877 # make sure we are using the primary server, so test-framework will
878 # be able to clean up properly.
879 activemds=`facet_active mds1`
880 if [ $activemds != "mds1" ]; then
884 # assume client mount is local
885 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
886 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
887 [ "$CLIENTONLY" ] && return
888 for num in `seq $MDSCOUNT`; do
891 for num in `seq $OSTCOUNT`; do
906 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
910 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
912 if [ ! -z $SEC ]; then
913 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
914 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
918 # We need ldiskfs here, may as well load them all
920 [ "$CLIENTONLY" ] && return
921 echo "Formatting mdts, osts"
922 for num in `seq $MDSCOUNT`; do
923 echo "Format mds$num: $(mdsdevname $num)"
925 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
927 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
931 for num in `seq $OSTCOUNT`; do
932 echo "Format ost$num: $(ostdevname $num)"
934 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
936 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
942 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
946 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
950 # 0: success, the old identity set already.
951 # 1: success, the old identity does not set.
956 local j=`expr $num - 1`
957 local MDT="`do_facet mds$num find $LPROC/mdt/ -name \*MDT\*$j -printf %f 2>/dev/null || true`"
959 if [ -z "$MDT" ]; then
963 local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
966 do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
968 do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
971 do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
973 if [ $old = "NONE" ]; then
982 zconf_umount `hostname` $1 || error "umount failed"
983 zconf_mount `hostname` $1 || error "mount failed"
990 do_facet $facet lsmod | grep -q obdclass || \
991 do_facet $facet "modprobe obdclass"
993 do_facet $facet "sysctl -w lustre.timeout=$timeout"
999 if [ -z "$CLIENTONLY" ]; then
1000 echo "Setup mdts, osts"
1001 for num in `seq $MDSCOUNT`; do
1002 DEVNAME=$(mdsdevname $num)
1003 echo $REFORMAT | grep -q "reformat" \
1004 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
1005 set_obd_timeout mds$num $TIMEOUT
1006 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1007 if [ $IDENTITY_UPCALL != "default" ]; then
1008 switch_identity $num $IDENTITY_UPCALL
1011 for num in `seq $OSTCOUNT`; do
1012 DEVNAME=$(ostdevname $num)
1013 set_obd_timeout ost$num $TIMEOUT
1014 start ost$num $DEVNAME $OST_MOUNT_OPTS
1017 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1019 if [ "$MOUNT_2" ]; then
1020 mount_client $MOUNT2
1023 # by remounting mdt before ost, initial connect from mdt to ost might
1024 # timeout because ost is not ready yet. wait some time to its fully
1025 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1026 # by a context negotiation rpc with $TIMEOUT.
1027 # FIXME better by monitoring import status.
1029 sleep $((TIMEOUT + 5))
1035 mounted_lustre_filesystems() {
1036 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1039 check_and_setup_lustre() {
1040 MOUNTED="`mounted_lustre_filesystems`"
1041 if [ -z "$MOUNTED" ]; then
1042 [ "$REFORMAT" ] && formatall
1044 MOUNTED="`mounted_lustre_filesystems`"
1045 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1046 export I_MOUNTED=yes
1048 if [ "$ONLY" == "setup" ]; then
1053 cleanup_and_setup_lustre() {
1054 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1055 sysctl -w lnet.debug=0 || true
1057 if [ "$ONLY" == "cleanup" ]; then
1061 check_and_setup_lustre
1064 check_and_cleanup_lustre() {
1065 if [ "`mount | grep $MOUNT`" ]; then
1066 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1068 if [ "$I_MOUNTED" = "yes" ]; then
1069 cleanupall -f || error "cleanup failed"
1081 while [ $NETWORK -eq 0 ]; do
1082 ping -c 1 -w 3 $1 > /dev/null
1083 if [ $? -eq 0 ]; then
1087 echo "waiting for $1, $((MAX - WAIT)) secs left"
1090 if [ $WAIT -gt $MAX ]; then
1091 echo "Network not available"
1097 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1108 # the sed converts spaces to commas, but leaves the last space
1109 # alone, so the line doesn't end with a comma.
1110 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1114 (cd `dirname $1`; echo $PWD/`basename $1`)
1117 ##################################
1121 # OBD_FAIL_MDS_ALL_REQUEST_NET
1123 do_facet mds sysctl -w lustre.fail_loc=0x123
1124 do_facet client "$1" || RC=$?
1125 do_facet mds sysctl -w lustre.fail_loc=0
1130 # OBD_FAIL_MDS_ALL_REPLY_NET
1132 do_facet mds sysctl -w lustre.fail_loc=0x122
1133 do_facet client "$@" || RC=$?
1134 do_facet mds sysctl -w lustre.fail_loc=0
1138 drop_reint_reply() {
1139 # OBD_FAIL_MDS_REINT_NET_REP
1141 do_facet mds sysctl -w lustre.fail_loc=0x119
1142 do_facet client "$@" || RC=$?
1143 do_facet mds sysctl -w lustre.fail_loc=0
1148 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1150 do_facet ost1 sysctl -w lustre.fail_loc=0x214
1151 do_facet client "$1" || RC=$?
1152 do_facet client "sync"
1153 do_facet ost1 sysctl -w lustre.fail_loc=0
1157 drop_ldlm_cancel() {
1158 #define OBD_FAIL_LDLM_CANCEL 0x304
1160 do_facet client sysctl -w lustre.fail_loc=0x304
1161 do_facet client "$@" || RC=$?
1162 do_facet client sysctl -w lustre.fail_loc=0
1166 drop_bl_callback() {
1167 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1169 do_facet client sysctl -w lustre.fail_loc=0x305
1170 do_facet client "$@" || RC=$?
1171 do_facet client sysctl -w lustre.fail_loc=0
1176 #define OBD_FAIL_LDLM_REPLY 0x30c
1178 do_facet mds sysctl -w lustre.fail_loc=0x30c
1179 do_facet client "$@" || RC=$?
1180 do_facet mds sysctl -w lustre.fail_loc=0
1188 echo "clearing fail_loc on $facet"
1189 do_facet $facet "sysctl -e -w lustre.fail_loc=0"
1192 set_nodes_failloc () {
1196 for node in $nodes ; do
1197 do_node $node sysctl -w lustre.fail_loc=$2
1201 cancel_lru_locks() {
1202 $LCTL mark "cancel_lru_locks $1 start"
1203 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
1204 [ -f $d/lru_size ] && echo clear > $d/lru_size
1205 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
1207 $LCTL mark "cancel_lru_locks $1 stop"
1212 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1213 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1214 echo "$DEFAULT_LRU_SIZE"
1220 test "x$NS" = "x" && NS="mdc"
1221 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1223 log "Enable lru resize for $(basename $D)"
1228 lru_resize_disable()
1231 test "x$NS" = "x" && NS="mdc"
1232 for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
1234 log "Disable lru resize for $(basename $D)"
1235 DEFAULT_LRU_SIZE=$(default_lru_size)
1236 echo "$DEFAULT_LRU_SIZE" > $F
1241 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
1242 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
1243 echo there is still data in page cache $a ?
1252 DEBUGSAVE="$(sysctl -n lnet.debug)"
1256 [ -n "$DEBUGSAVE" ] && sysctl -w lnet.debug="${DEBUGSAVE}"
1260 ##################################
1262 ##################################
1265 local TYPE=${TYPE:-"FAIL"}
1267 sysctl -e -w lustre.fail_loc=0 || true
1268 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1269 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1270 echo "Dumping lctl log to $ERRLOG"
1271 # We need to dump the logs on all nodes
1272 local NODES=$(nodes_list)
1273 for NODE in $NODES; do
1274 do_node $NODE $LCTL dk $ERRLOG
1277 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1282 $FAIL_ON_ERROR && exit 1 || true
1290 # use only if we are ignoring failures for this test, bugno required.
1291 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1292 # e.g. error_ignore 5494 "your message"
1294 TYPE="IGNORE (bz$1)"
1300 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1301 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1304 build_test_filter() {
1305 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1309 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1310 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1311 [ "$EXCEPT_SLOW" ] && \
1312 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1313 for E in $EXCEPT $ALWAYS_EXCEPT; do
1314 eval EXCEPT_${E}=true
1316 for E in $EXCEPT_SLOW; do
1317 eval EXCEPT_SLOW_${E}=true
1319 for G in $GRANT_CHECK_LIST; do
1320 eval GCHECK_ONLY_${G}=true
1329 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1333 export base=`basetest $1`
1334 if [ ! -z "$ONLY" ]; then
1336 if [ ${!testname}x != x ]; then
1341 if [ ${!testname}x != x ]; then
1349 if [ ${!testname}x != x ]; then
1350 TESTNAME=test_$1 skip "skipping excluded test $1"
1353 testname=EXCEPT_$base
1354 if [ ${!testname}x != x ]; then
1355 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1358 testname=EXCEPT_SLOW_$1
1359 if [ ${!testname}x != x ]; then
1360 TESTNAME=test_$1 skip "skipping SLOW test $1"
1363 testname=EXCEPT_SLOW_$base
1364 if [ ${!testname}x != x ]; then
1365 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1374 EQUALS="======================================================================"
1378 local suffixlen=$((${#EQUALS} - ${#msg}))
1379 [ $suffixlen -lt 5 ] && suffixlen=5
1380 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1385 lsmod | grep lnet > /dev/null || load_modules
1396 local NODES=$(nodes_list)
1397 for NODE in $NODES; do
1398 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
1404 strace -o $TMP/$1.strace -ttt $*
1406 log "FINISHED: $*: rc $RC"
1415 FFREE=`cat /proc/fs/lustre/osd/*MDT*/filesfree`
1416 FTOTAL=`cat /proc/fs/lustre/osd/*MDT*/filestotal`
1417 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1421 local myNODES=$(nodes_list)
1424 for NODE in $myNODES; do
1425 do_node $NODE sysctl -e -w lustre.fail_loc=0 || true
1433 export tdir=d0.${TESTSUITE}/d${base}
1434 local SAVE_UMASK=`umask`
1439 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1441 export TESTNAME=test_$testnum
1442 test_${testnum} || error "test_$testnum failed with $?"
1445 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1446 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1447 error "LBUG/LASSERT detected"
1448 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
1449 pass "($((`date +%s` - $BEFORE))s)"
1450 rmdir ${DIR}/$tdir >/dev/null 2>&1 || true
1459 (cd `dirname $1`; echo $PWD/`basename $1`)
1463 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1464 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1469 export base=`basetest $1`
1470 [ "$CHECK_GRANT" == "no" ] && return 0
1472 testname=GCHECK_ONLY_${base}
1473 [ ${!testname}x == x ] && return 0
1475 echo -n "checking grant......"
1477 # write some data to sync client lost_grant
1478 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1479 for i in `seq $OSTCOUNT`; do
1480 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
1481 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1482 count=1 > /dev/null 2>&1
1484 # sync all the data and make sure no pending data on server
1487 #get client grant and server grant
1489 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1490 client_grant=$((client_grant + `cat $d`))
1493 for d in ${LPROC}/obdfilter/*/tot_granted; do
1494 server_grant=$((server_grant + `cat $d`))
1497 # cleanup the check_grant file
1498 for i in `seq $OSTCOUNT`; do
1499 rm $DIR1/${tfile}_check_grant_$i
1502 #check whether client grant == server grant
1503 if [ $client_grant != $server_grant ]; then
1504 echo "failed: client:${client_grant} server: ${server_grant}"
1511 ########################
1517 ost=`echo $1 | awk -F_ '{print $3}'`
1518 if [ -z $ost ]; then
1519 ost=`echo $1 | sed 's/-osc.*//'`
1526 [ -z "$(lctl dl | grep mdt)" ]
1531 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
1536 [ -z "$(lctl dl | grep ost)" ]
1541 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
1545 local MDSNODES=$(facet_host $SINGLEMDS)
1548 # FIXME: Currenly we use only $SINGLEMDS,
1549 # should be fixed when we will start to test cmd.
1553 for num in `seq $MDSCOUNT`; do
1554 local myMDS=$(facet_host mds$num)
1555 MDSNODES="$MDSNODES $myMDS"
1557 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
1563 local OSTNODES=$(facet_host ost1)
1566 for num in `seq $OSTCOUNT`; do
1567 local myOST=$(facet_host ost$num)
1568 OSTNODES="$OSTNODES $myOST"
1570 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
1576 # FIXME. We need a list of clients
1577 local myNODES=$HOSTNAME
1580 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
1581 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
1584 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
1591 lctl get_param version | grep -q patchless
1594 check_runas_id_ret() {
1599 if [ -z "$myRUNAS" ]; then
1600 error_exit "myRUNAS command must be specified for check_runas_id"
1603 $myRUNAS krb5_login.sh || \
1604 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
1606 mkdir $DIR/d0_runas_test
1608 chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
1609 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
1610 rm -rf $DIR/d0_runas_test
1618 check_runas_id_ret $myRUNAS_ID $myRUNAS || \
1619 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
1620 Please set RUNAS_ID to some UID which exists on MDS and client or
1621 add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
1624 # Run multiop in the background, but wait for it to print
1625 # "PAUSING" to its stdout before returning from this function.
1626 multiop_bg_pause() {
1627 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
1631 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
1634 echo "$MULTIOP_PROG $FILE v$ARGS"
1635 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
1637 echo "TMPPIPE=${TMPPIPE}"
1638 read -t 60 multiop_output < $TMPPIPE
1639 if [ $? -ne 0 ]; then
1644 if [ "$multiop_output" != "PAUSING" ]; then
1645 echo "Incorrect multiop output: $multiop_output"
1653 # reset llite stat counters
1654 clear_llite_stats(){
1655 lctl set_param -n llite.*.stats 0
1658 # sum llite stat items
1659 calc_llite_stats() {
1660 local res=$(lctl get_param -n llite.*.stats |
1661 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
1665 # save_lustre_params(node, parameter_mask)
1666 # generate a stream of formatted strings (<node> <param name>=<param value>)
1667 save_lustre_params() {
1669 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
1672 # restore lustre parameters from input stream, produces by save_lustre_params
1673 restore_lustre_params() {
1677 while IFS=" =" read node name val; do
1678 do_node $node "lctl set_param -n $name $val"