2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap '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}
13 #export PDSH="pdsh -S -Rssh -w"
15 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
19 if [ -z "${!name}" ]; then
20 echo "$0: $name must be set"
24 [ $failed ] && exit 1 || true
28 echo "usage: $0 [-r] [-f cfgfile]"
35 export LUSTRE=`absolute_path $LUSTRE`
36 export TESTSUITE=`basename $0 .sh`
37 export LTESTDIR=${LTESTDIR:-$LUSTRE/../ltest}
39 [ -d /r ] && export ROOT=${ROOT:-/r}
40 export TMP=${TMP:-$ROOT/tmp}
41 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
43 export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
44 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
45 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
46 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
47 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
48 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
49 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
50 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
51 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
52 export FSYTPE=${FSTYPE:-"ldiskfs"}
53 export NAME=${NAME:-local}
54 export LPROC=/proc/fs/lustre
55 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
56 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
57 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
59 if [ "$ACCEPTOR_PORT" ]; then
60 export PORT_OPT="--port $ACCEPTOR_PORT"
65 echo "Using GSS/krb5 ptlrpc security flavor"
70 # Paths on remote nodes, if different
71 export RLUSTRE=${RLUSTRE:-$LUSTRE}
72 export RPWD=${RPWD:-$PWD}
73 export I_MOUNTED=${I_MOUNTED:-"no"}
77 while getopts "rvf:" opt $*; do
80 r) REFORMAT=--reformat;;
89 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
97 BASE=`basename $module $EXT`
98 lsmod | grep -q ${BASE} || \
99 if [ -f ${LUSTRE}/${module}${EXT} ]; then
100 insmod ${LUSTRE}/${module}${EXT} $@
102 # must be testing a "make install" or "rpm" installation
103 # note failed to load ptlrpc_gss is considered not fatal
104 if [ "$BASE" == "ptlrpc_gss" ]; then
105 modprobe $BASE $@ || echo "gss/krb5 is not supported"
113 if [ -n "$MODPROBE" ]; then
117 if [ "$HAVE_MODULES" = true ]; then
123 echo Loading modules from $LUSTRE
124 load_module ../lnet/libcfs/libcfs
125 [ -z "$LNETOPTS" ] && \
126 LNETOPTS=$(awk '/^options lnet/ { print $0}' /etc/modprobe.conf | sed 's/^options lnet //g')
127 echo "lnet options: '$LNETOPTS'"
128 # note that insmod will ignore anything in modprobe.conf
129 load_module ../lnet/lnet/lnet $LNETOPTS
130 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
131 load_module ../lnet/klnds/$LNETLND
132 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
133 load_module lvfs/lvfs
134 load_module obdclass/obdclass
135 load_module lvfs/fsfilt_$FSTYPE
136 load_module ptlrpc/ptlrpc
137 load_module ptlrpc/gss/ptlrpc_gss
138 # Now, some modules depend on lquota without USE_QUOTA check,
139 # will fix later. Disable check "$USE_QUOTA" = "yes" temporary.
140 #[ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
141 load_module quota/lquota
154 load_module obdfilter/obdfilter
155 load_module llite/lustre
158 rm -f $TMP/ogdb-`hostname`
159 $LCTL modules > $TMP/ogdb-`hostname`
160 # 'mount' doesn't look in $PATH, just sbin
161 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
165 if [ `uname -r | cut -c 3` -eq 4 ]; then
173 MODULES=$($LCTL modules | awk '{ print $2 }')
174 while [ -n "$MODULES" ]; do
176 $RMMOD $MODULES > /dev/null 2>&1 || true
177 MODULES=$($LCTL modules | awk '{ print $2 }')
178 if [ -z "$MODULES" ]; then
182 echo "waiting, $((MAX - WAIT)) secs left"
184 if [ $WAIT -eq $MAX ]; then
185 echo "LNET modules $MODULES will not unload"
193 lsmod | grep lnet > /dev/null && $LCTL dl && $LCTL dk $TMP/debug
194 local MODULES=$($LCTL modules | awk '{ print $2 }')
195 $RMMOD $MODULES > /dev/null 2>&1 || true
196 # do it again, in case we tried to unload ksocklnd too early
197 MODULES=$($LCTL modules | awk '{ print $2 }')
198 [ -n "$MODULES" ] && $RMMOD $MODULES > /dev/null 2>&1 || true
199 MODULES=$($LCTL modules | awk '{ print $2 }')
200 if [ -n "$MODULES" ]; then
201 echo "Modules still loaded: "
203 if [ -e $LPROC ]; then
204 echo "Lustre still loaded"
205 cat $LPROC/devices || true
209 echo "Lustre stopped but LNET is still loaded, waiting..."
210 wait_for_lnet || return 3
215 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd mem.*leaked" || true)
216 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
217 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
218 echo "$LEAK_LUSTRE" 1>&2
219 echo "$LEAK_PORTALS" 1>&2
220 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
221 echo "Memory leaks detected"
224 echo "modules unloaded."
228 check_gss_daemon_facet() {
232 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
233 if [ $num -ne 1 ]; then
234 echo "$num instance of $dname on $facet"
243 do_facet $facet "killall -2 $@ 2>/dev/null || true"
246 start_gss_daemons() {
248 for num in `seq $MDSCOUNT`; do
249 do_facet mds$num "$LSVCGSSD -v"
250 do_facet mds$num "$LGSSD -v"
253 for num in `seq $OSTCOUNT`; do
254 do_facet ost$num "$LSVCGSSD -v"
257 # FIXME: is "client" the right facet name?
258 do_facet client "$LGSSD -v"
260 # wait daemons entering "stable" status
264 # check daemons are running
266 for num in `seq $MDSCOUNT`; do
267 check_gss_daemon_facet mds$num lsvcgssd
268 check_gss_daemon_facet mds$num lgssd
270 for num in `seq $OSTCOUNT`; do
271 check_gss_daemon_facet ost$num lsvcgssd
273 check_gss_daemon_facet client lgssd
277 for num in `seq $MDSCOUNT`; do
278 send_sigint mds$num lsvcgssd lgssd
280 for num in `seq $OSTCOUNT`; do
281 send_sigint ost$num lsvcgssd
283 send_sigint client lgssd
287 if [ ! -z $SEC ]; then
288 MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
289 OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
292 if [ ! -z $USING_KRB5 ]; then
298 if [ ! -z $USING_KRB5 ]; then
300 # maybe cleanup credential cache?
306 local device=`mdsdevname $num`
307 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
313 local device=`ostdevname $num`
314 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
319 # start facet device options
325 echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
326 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
327 do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
329 if [ $RC -ne 0 ]; then
330 echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
331 echo Start of ${device} on ${facet} failed ${RC}
333 do_facet ${facet} sync
334 label=$(do_facet ${facet} "e2label ${device}")
335 [ -z "$label" ] && echo no label for ${device} && exit 1
336 eval export ${facet}_svc=${label}
337 eval export ${facet}_dev=${device}
338 eval export ${facet}_opt=\"$@\"
339 echo Started ${label}
348 HOST=`facet_active_host $facet`
349 [ -z $HOST ] && echo stop: no host for $facet && return 0
351 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
352 if [ ${running} -ne 0 ]; then
353 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
354 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
357 # umount should block, but we should wait for unrelated obd's
358 # like the MGS or MGC to also stop.
361 # conf-sanity 31 takes a long time cleanup
362 while [ $WAIT -lt 300 ]; do
363 running=$(do_facet ${facet} "[ -e $LPROC ] && grep ST' ' $LPROC/devices") || true
364 if [ -z "${running}" ]; then
367 echo "waited $WAIT for${running}"
368 if [ $INTERVAL -lt 64 ]; then
369 INTERVAL=$((INTERVAL + INTERVAL))
372 WAIT=$((WAIT + INTERVAL))
374 echo "service didn't stop after $WAIT seconds. Still running:"
383 # Only supply -o to mount if we have options
384 if [ -n "$MOUNTOPT" ]; then
385 OPTIONS="-o $MOUNTOPT"
387 local device=$MGSNID:/$FSNAME
388 if [ -z "$mnt" -o -z "$FSNAME" ]; then
389 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
393 echo "Starting client: $OPTIONS $device $mnt"
394 do_node $client mkdir -p $mnt
395 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
397 do_node $client "sysctl -w lnet.debug=$PTLDEBUG; sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }"
398 [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
406 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
407 if [ $running -ne 0 ]; then
408 echo "Stopping client $mnt (opts:$force)"
409 do_node $client umount $force $mnt
415 if [ "$FAILURE_MODE" = HARD ]; then
416 $POWER_DOWN `facet_active_host $facet`
418 elif [ "$FAILURE_MODE" = SOFT ]; then
425 if [ "$FAILURE_MODE" = HARD ]; then
426 $POWER_UP `facet_active_host $facet`
432 # verify that lustre actually cleaned up properly
434 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
435 error "LBUG/LASSERT detected"
436 BUSY=`dmesg | grep -i destruct || true`
439 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
442 LEAK_LUSTRE=`dmesg | tail -n 30 | grep "obd mem.*leaked" || true`
443 LEAK_PORTALS=`dmesg | tail -n 20 | grep "Portals memory leaked" || true`
444 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
445 echo "$0: $LEAK_LUSTRE" 1>&2
446 echo "$0: $LEAK_PORTALS" 1>&2
447 echo "$0: Memory leak(s) detected..." 1>&2
448 mv $TMP/debug $TMP/debug-leak.`date +%s`
452 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
453 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
455 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
456 echo "$0: modules still loaded..." 1>&2
465 check_network "$HOST" 900
466 while ! do_node $HOST "ls -d $LUSTRE " > /dev/null; do sleep 5; done
471 HOST=`facet_active_host $facet`
476 # not every config has many clients
477 if [ ! -z "$CLIENTS" ]; then
478 $PDSH $CLIENTS "df $MOUNT" > /dev/null
483 uname -n >> $MOUNT/recon
484 if [ ! -z "$CLIENTS" ]; then
485 $PDSH $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
487 echo Connected clients:
489 ls -l $MOUNT/recon > /dev/null
495 echo "Failing $facet on node `facet_active_host $facet`"
496 shutdown_facet $facet
500 echo "df pid is $DFPID"
502 TO=`facet_active_host $facet`
503 echo "Failover $facet to $TO"
505 local dev=${facet}_dev
506 local opt=${facet}_opt
507 start $facet ${!dev} ${!opt} || error "Restart of $facet failed"
518 local svc=${facet}_svc
519 do_facet $facet $LCTL --device %${!svc} readonly
520 do_facet $facet $LCTL --device %${!svc} notransno
521 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
522 $LCTL mark "local REPLAY BARRIER on ${!svc}"
525 replay_barrier_nodf() {
526 local facet=$1 echo running=${running}
528 local svc=${facet}_svc
529 echo Replay barrier on ${!svc}
530 do_facet $facet $LCTL --device %${!svc} readonly
531 do_facet $facet $LCTL --device %${!svc} notransno
532 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
533 $LCTL mark "local REPLAY BARRIER on ${!svc}"
537 UUID=`cat /proc/fs/lustre/mdc/${mds1_svc}-mdc-*/uuid`
538 do_facet mds1 "echo $UUID > /proc/fs/lustre/mdt/${mds1_svc}/evict_client"
542 UUID=`grep ${ost1_svc}-osc- $LPROC/devices | egrep -v 'MDT' | awk '{print $5}'`
543 do_facet ost1 "echo $UUID > /proc/fs/lustre/obdfilter/${ost1_svc}/evict_client"
547 facet_failover $* || error "failover: $?"
548 df $MOUNT || error "post-failover df: $?"
555 local svc=${facet}_svc
556 local dev=${facet}_dev
557 local opt=${facet}_opt
558 start $facet ${!dev} ${!opt}
559 do_facet $facet lctl --device %${!svc} abort_recovery
560 df $MOUNT || echo "first df failed: $?"
562 df $MOUNT || error "post-failover df: $?"
566 echo There is no lmc. This is mountconf, baby.
571 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
572 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
578 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
584 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
585 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
586 if [ -z "$ID" ]; then
587 echo "Could not get a ptl id for $1..."
596 h2name_or_ip "$1" "tcp"
601 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
602 if type __h2elan >/dev/null 2>&1; then
605 ID=`echo $1 | sed 's/[^0-9]*//g'`
613 h2name_or_ip "$1" "openib"
618 h2name_or_ip "$1" "o2ib"
624 varname=${facet}_HOST
625 if [ -z "${!varname}" ]; then
626 if [ "${facet:0:3}" == "ost" ]; then
627 eval ${facet}_HOST=${ost_HOST}
635 local activevar=${facet}active
637 if [ -f ./${facet}active ] ; then
638 source ./${facet}active
642 if [ -z "$active" ] ; then
649 facet_active_host() {
651 local active=`facet_active $facet`
652 if [ "$facet" == client ]; then
655 echo `facet_host $active`
661 failover=${facet}failover
662 host=`facet_host $failover`
663 [ -z "$host" ] && return
664 curactive=`facet_active $facet`
665 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
666 eval export ${facet}active=$facet
668 eval export ${facet}active=$failover
670 # save the active host for this facet
671 activevar=${facet}active
672 echo "$activevar=${!activevar}" > ./$activevar
679 if [ "$HOST" = "$(hostname)" ]; then
683 echo "CMD: $HOST $@" >&2
684 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
686 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
687 return ${PIPESTATUS[0]}
693 HOST=`facet_active_host $facet`
694 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
701 # make sure its not already running
704 do_facet ${facet} $MKFS $*
710 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
711 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
718 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
719 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
727 # make sure we are using the primary server, so test-framework will
728 # be able to clean up properly.
729 activemds=`facet_active mds1`
730 if [ $activemds != "mds1" ]; then
734 # assume client mount is local
735 grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
736 grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
737 for num in `seq $MDSCOUNT`; do
740 for num in `seq $OSTCOUNT`; do
755 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
759 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
762 # We need ldiskfs here, may as well load them all
764 [ "$CLIENTONLY" ] && return
765 echo "Formatting mdts, osts"
766 for num in `seq $MDSCOUNT`; do
767 echo "Format mds$num: $(mdsdevname $num)"
769 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
771 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
775 for num in `seq $OSTCOUNT`; do
776 echo "Format ost$num: $(ostdevname $num)"
778 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
780 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
786 grep " $1 " /proc/mounts || zconf_mount `hostname` $*
792 if [ -z "$CLIENTONLY" ]; then
793 echo "Setup mdts, osts"
794 for num in `seq $MDSCOUNT`; do
795 DEVNAME=$(mdsdevname $num)
796 echo $REFORMAT | grep -q "reformat" \
797 || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
798 start mds$num $DEVNAME $MDS_MOUNT_OPTS
800 for num in `seq $OSTCOUNT`; do
801 DEVNAME=$(ostdevname $num)
802 start ost$num $DEVNAME $OST_MOUNT_OPTS
805 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
807 if [ "$MOUNT_2" ]; then
813 mounted_lustre_filesystems() {
814 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
817 check_and_setup_lustre() {
818 MOUNTED="`mounted_lustre_filesystems`"
819 if [ -z "$MOUNTED" ]; then
820 [ "$REFORMAT" ] && formatall
822 MOUNTED="`mounted_lustre_filesystems`"
823 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
826 if [ "$ONLY" == "setup" ]; then
831 cleanup_and_setup_lustre() {
832 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
833 sysctl -w lnet.debug=0 || true
835 if [ "$ONLY" == "cleanup" ]; then
839 check_and_setup_lustre
842 check_and_cleanup_lustre() {
843 if [ "`mount | grep $MOUNT`" ]; then
844 rm -rf $DIR/[Rdfs][1-9]*
846 if [ "$I_MOUNTED" = "yes" ]; then
847 cleanupall -f || error "cleanup failed"
859 while [ $NETWORK -eq 0 ]; do
860 ping -c 1 -w 3 $1 > /dev/null
861 if [ $? -eq 0 ]; then
865 echo "waiting for $1, $((MAX - WAIT)) secs left"
868 if [ $WAIT -gt $MAX ]; then
869 echo "Network not available"
875 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
886 # the sed converts spaces to commas, but leaves the last space
887 # alone, so the line doesn't end with a comma.
888 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
892 (cd `dirname $1`; echo $PWD/`basename $1`)
895 ##################################
899 # OBD_FAIL_MDS_ALL_REQUEST_NET
901 do_facet mds sysctl -w lustre.fail_loc=0x123
902 do_facet client "$1" || RC=$?
903 do_facet mds sysctl -w lustre.fail_loc=0
908 # OBD_FAIL_MDS_ALL_REPLY_NET
910 do_facet mds sysctl -w lustre.fail_loc=0x122
911 do_facet client "$@" || RC=$?
912 do_facet mds sysctl -w lustre.fail_loc=0
917 # OBD_FAIL_MDS_REINT_NET_REP
919 do_facet mds sysctl -w lustre.fail_loc=0x119
920 do_facet client "$@" || RC=$?
921 do_facet mds sysctl -w lustre.fail_loc=0
926 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
928 do_facet ost1 sysctl -w lustre.fail_loc=0x214
929 do_facet client "$1" || RC=$?
930 do_facet client "sync"
931 do_facet ost1 sysctl -w lustre.fail_loc=0
936 #define OBD_FAIL_LDLM_CANCEL 0x304
938 do_facet client sysctl -w lustre.fail_loc=0x304
939 do_facet client "$@" || RC=$?
940 do_facet client sysctl -w lustre.fail_loc=0
945 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
947 do_facet client sysctl -w lustre.fail_loc=0x305
948 do_facet client "$@" || RC=$?
949 do_facet client sysctl -w lustre.fail_loc=0
954 #define OBD_FAIL_LDLM_REPLY 0x30c
956 do_facet mds sysctl -w lustre.fail_loc=0x30c
957 do_facet client "$@" || RC=$?
958 do_facet mds sysctl -w lustre.fail_loc=0
966 echo "clearing fail_loc on $facet"
967 do_facet $facet "sysctl -w lustre.fail_loc=0"
971 $LCTL mark "cancel_lru_locks $1 start"
972 for d in `find $LPROC/ldlm/namespaces | egrep -i $1`; do
973 [ -f $d/lru_size ] && echo clear > $d/lru_size
974 [ -f $d/lock_unused_count ] && grep [1-9] $d/lock_unused_count /dev/null
976 $LCTL mark "cancel_lru_locks $1 stop"
981 for a in /proc/fs/lustre/llite/*/dump_page_cache; do
982 if [ `wc -l $a | awk '{print $1}'` -gt 1 ]; then
983 echo there is still data in page cache $a ?
992 ##################################
996 sysctl -w lustre.fail_loc=0 2> /dev/null || true
997 log "${TESTSUITE} ${TESTNAME}: **** FAIL:" $@
998 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
999 echo "Dumping lctl log to $ERRLOG"
1000 # We need to dump the logs on all nodes
1002 [ ! "$mds_HOST" = "$(hostname)" ] && do_node $mds_HOST $LCTL dk $ERRLOG
1003 [ ! "$ost_HOST" = "$(hostname)" -a ! "$ost_HOST" = "$mds_HOST" ] && do_node $ost_HOST $LCTL dk $ERRLOG
1005 [ "$TESTSUITELOG" ] && echo "$0: FAIL: $TESTNAME $@" >> $TESTSUITELOG
1006 if $FAIL_ON_ERROR; then
1012 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1013 [ "$TESTSUITELOG" ] && echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG
1016 build_test_filter() {
1017 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1021 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1022 log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1023 for E in $EXCEPT $ALWAYS_EXCEPT; do
1024 eval EXCEPT_${E}=true
1026 for G in $GRANT_CHECK_LIST; do
1027 eval GCHECK_ONLY_${G}=true
1036 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1040 export base=`basetest $1`
1041 if [ ! -z "$ONLY" ]; then
1043 if [ ${!testname}x != x ]; then
1048 if [ ${!testname}x != x ]; then
1056 if [ ${!testname}x != x ]; then
1057 TESTNAME=test_$1 skip "skipping excluded test $1"
1060 testname=EXCEPT_$base
1061 if [ ${!testname}x != x ]; then
1062 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1070 EQUALS="======================================================================"
1074 local suffixlen=$((${#EQUALS} - ${#msg}))
1075 [ $suffixlen -lt 5 ] && suffixlen=5
1076 printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS
1081 lsmod | grep lnet > /dev/null || load_modules
1082 $LCTL mark "$*" 2> /dev/null || true
1087 strace -o $TMP/$1.strace -ttt $*
1089 log "FINISHED: $*: rc $RC"
1098 FFREE=`cat /proc/fs/lustre/mds/*/filesfree`
1099 FTOTAL=`cat /proc/fs/lustre/mds/*/filestotal`
1100 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
1110 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
1112 export TESTNAME=test_$testnum
1113 test_${testnum} || error "test_$testnum failed with $?"
1115 check_grant ${testnum} || error "check_grant $testnum failed with $?"
1116 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1117 error "LBUG/LASSERT detected"
1118 pass "($((`date +%s` - $BEFORE))s)"
1125 (cd `dirname $1`; echo $PWD/`basename $1`)
1129 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
1130 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
1135 export base=`basetest $1`
1136 [ "$CHECK_GRANT" == "no" ] && return 0
1138 testname=GCHECK_ONLY_${base}
1139 [ ${!testname}x == x ] && return 0
1141 echo -n "checking grant......"
1143 # write some data to sync client lost_grant
1144 rm -f $DIR1/${tfile}_check_grant_* 2>&1
1145 for i in `seq $OSTCOUNT`; do
1146 $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
1147 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
1148 count=1 > /dev/null 2>&1
1150 # sync all the data and make sure no pending data on server
1153 #get client grant and server grant
1155 for d in ${LPROC}/osc/*/cur_grant_bytes; do
1156 client_grant=$((client_grant + `cat $d`))
1159 for d in ${LPROC}/obdfilter/*/tot_granted; do
1160 server_grant=$((server_grant + `cat $d`))
1163 # cleanup the check_grant file
1164 for i in `seq $OSTCOUNT`; do
1165 rm $DIR1/${tfile}_check_grant_$i
1168 #check whether client grant == server grant
1169 if [ $client_grant != $server_grant ]; then
1170 echo "failed: client:${client_grant} server: ${server_grant}"
1177 ########################
1183 ost=`echo $1 | awk -F_ '{print $3}'`
1184 if [ -z $ost ]; then
1185 ost=`echo $1 | sed 's/-osc.*//'`
1192 [ ! -e /proc/fs/lustre/mdt/*MDT* ]
1197 [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]