2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
25 if [ -z "${!name}" ]; then
26 echo "$0: $name must be set"
30 [ $failed ] && exit 1 || true
35 [[ $DIR/ = $MOUNT/* ]] || \
36 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
37 [[ $DIR1/ = $MOUNT1/* ]] || \
38 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
39 [[ $DIR2/ = $MOUNT2/* ]] || \
40 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
42 [ -n "$failed" ] && exit 99 || true
46 echo "usage: $0 [-r] [-f cfgfile]"
53 [ "$TESTSUITE" == "lfscktest" ] && return 0
54 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
55 local form="%-13s %-17s %s\n"
56 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
57 echo "------------------------------------------------------------------------------------"
58 for O in $TESTSUITE_LIST; do
61 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
64 local log=${TMP}/${o}.log
65 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
66 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
67 [ "${!O}" = "done" ] && \
68 printf "$form" "Done" "$O" "E=$skipped" && \
69 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
73 for O in $TESTSUITE_LIST; do
74 [ "${!O}" = "no" ] && \
75 printf "$form" "Skipped" "$O" ""
78 for O in $TESTSUITE_LIST; do
79 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
80 printf "$form" "UNFINISHED" "$O" ""
85 export LUSTRE=`absolute_path $LUSTRE`
86 export TESTSUITE=`basename $0 .sh`
87 export TEST_FAILED=false
89 export MKE2FS=${MKE2FS:-mke2fs}
90 export DEBUGFS=${DEBUGFS:-debugfs}
91 export TUNE2FS=${TUNE2FS:-tune2fs}
92 export E2LABEL=${E2LABEL:-e2label}
93 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
94 export E2FSCK=${E2FSCK:-e2fsck}
96 #[ -d /r ] && export ROOT=${ROOT:-/r}
97 export TMP=${TMP:-$ROOT/tmp}
98 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
99 export HOSTNAME=${HOSTNAME:-`hostname`}
100 if ! echo $PATH | grep -q $LUSTRE/utils; then
101 export PATH=$PATH:$LUSTRE/utils
103 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
104 export PATH=$PATH:$LUSTRE/utils/gss
106 if ! echo $PATH | grep -q $LUSTRE/tests; then
107 export PATH=$PATH:$LUSTRE/tests
109 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
110 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
111 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
112 export PATH=$PATH:$LUSTRE/tests/racer
114 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
115 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
116 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
117 [ ! -f "$LFS" ] && export LFS=$(which lfs)
118 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
119 if [ ! -f "$L_GETIDENTITY" ]; then
120 if `which l_getidentity > /dev/null 2>&1`; then
121 export L_GETIDENTITY=$(which l_getidentity)
123 export L_GETIDENTITY=NONE
126 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
127 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
128 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
129 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
130 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
131 export FSTYPE=${FSTYPE:-"ldiskfs"}
132 export NAME=${NAME:-local}
133 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
134 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
135 export LGSSD=$(which lgssd)
136 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
137 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
138 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
140 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
143 if [ "$ACCEPTOR_PORT" ]; then
144 export PORT_OPT="--port $ACCEPTOR_PORT"
149 echo "Using GSS/krb5 ptlrpc security flavor"
150 which lgss_keyring > /dev/null 2>&1 || \
151 error "built with gss disabled! SEC=$SEC"
162 IDENTITY_UPCALL=false
166 # Paths on remote nodes, if different
167 export RLUSTRE=${RLUSTRE:-$LUSTRE}
168 export RPWD=${RPWD:-$PWD}
169 export I_MOUNTED=${I_MOUNTED:-"no"}
173 while getopts "rvwf:" opt $*; do
176 r) REFORMAT=--reformat;;
178 w) WRITECONF=writeconf;;
183 shift $((OPTIND - 1))
186 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
192 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
193 *) EXT=".ko"; USE_QUOTA=yes;;
200 BASE=`basename $module $EXT`
201 lsmod | grep -q ${BASE} || \
202 if [ -f ${LUSTRE}/${module}${EXT} ]; then
203 insmod ${LUSTRE}/${module}${EXT} $@
205 # must be testing a "make install" or "rpm" installation
206 # note failed to load ptlrpc_gss is considered not fatal
207 if [ "$BASE" == "ptlrpc_gss" ]; then
208 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
216 if [ -n "$MODPROBE" ]; then
220 if [ "$HAVE_MODULES" = true ]; then
226 echo Loading modules from $LUSTRE
227 load_module ../libcfs/libcfs/libcfs
228 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
229 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
231 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
232 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
233 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
234 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
235 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
236 echo "lnet options: '$LNETOPTS'"
237 # note that insmod will ignore anything in modprobe.conf
238 load_module ../lnet/lnet/lnet $LNETOPTS
239 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
240 load_module ../lnet/klnds/$LNETLND
241 load_module lvfs/lvfs
242 load_module obdclass/obdclass
243 load_module ptlrpc/ptlrpc
244 load_module ptlrpc/gss/ptlrpc_gss
245 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
253 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
254 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
255 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
256 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
261 load_module lvfs/fsfilt_$FSTYPE
265 load_module obdfilter/obdfilter
268 load_module llite/lustre
269 load_module llite/llite_lloop
270 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
272 rm -f $OGDB/ogdb-$HOSTNAME
273 $LCTL modules > $OGDB/ogdb-$HOSTNAME
275 # 'mount' doesn't look in $PATH, just sbin
276 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
280 if [ `uname -r | cut -c 3` -eq 4 ]; then
288 MODULES=$($LCTL modules | awk '{ print $2 }')
289 while [ -n "$MODULES" ]; do
291 $RMMOD $MODULES > /dev/null 2>&1 || true
292 MODULES=$($LCTL modules | awk '{ print $2 }')
293 if [ -z "$MODULES" ]; then
297 echo "waiting, $((MAX - WAIT)) secs left"
299 if [ $WAIT -eq $MAX ]; then
300 echo "LNET modules $MODULES will not unload"
307 unload_dep_module() {
309 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
311 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
312 for SUBMOD in $DEPS; do
313 unload_dep_module $SUBMOD
315 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
316 $RMMOD $MODULE || true
320 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
321 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
322 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
323 echo "$LEAK_LUSTRE" 1>&2
324 echo "$LEAK_PORTALS" 1>&2
325 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
326 echo "Memory leaks detected"
327 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
333 wait_exit_ST client # bug 12845
335 lsmod | grep libcfs > /dev/null && $LCTL dl
336 unload_dep_module $FSTYPE
337 unload_dep_module libcfs
339 local MODULES=$($LCTL modules | awk '{ print $2 }')
340 if [ -n "$MODULES" ]; then
341 echo "Modules still loaded: "
343 if [ "$(lctl dl)" ]; then
344 echo "Lustre still loaded"
349 echo "Lustre stopped but LNET is still loaded, waiting..."
350 wait_for_lnet || return 3
356 check_mem_leak || return 254
358 echo "modules unloaded."
362 check_gss_daemon_facet() {
366 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
367 if [ $num -ne 1 ]; then
368 echo "$num instance of $dname on $facet"
377 do_facet $facet "killall -2 $@ 2>/dev/null || true"
380 start_gss_daemons() {
382 for num in `seq $MDSCOUNT`; do
383 do_facet mds$num "$LSVCGSSD -v"
385 do_facet mds$num "$LGSSD -v"
389 for num in `seq $OSTCOUNT`; do
390 do_facet ost$num "$LSVCGSSD -v"
393 # FIXME: is "client" the right facet name?
395 do_facet client "$LGSSD -v"
398 # wait daemons entering "stable" status
402 # check daemons are running
404 for num in `seq $MDSCOUNT`; do
405 check_gss_daemon_facet mds$num lsvcgssd
407 check_gss_daemon_facet mds$num lgssd
410 for num in `seq $OSTCOUNT`; do
411 check_gss_daemon_facet ost$num lsvcgssd
414 check_gss_daemon_facet client lgssd
419 for num in `seq $MDSCOUNT`; do
420 send_sigint mds$num lsvcgssd lgssd
422 for num in `seq $OSTCOUNT`; do
423 send_sigint ost$num lsvcgssd
425 send_sigint client lgssd
432 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
433 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
441 # maybe cleanup credential cache?
447 local device=`mdsdevname $num`
448 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
454 local device=`ostdevname $num`
455 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
463 local dev=${facet}_dev
464 local opt=${facet}_opt
465 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
466 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
468 if [ $RC -ne 0 ]; then
469 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
470 echo "Start of ${!dev} on ${facet} failed ${RC}"
472 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
473 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
474 lctl set_param debug_mb=${DEBUG_SIZE}; \
477 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
478 [ -z "$label" ] && echo no label for ${!dev} && exit 1
479 eval export ${facet}_svc=${label}
480 echo Started ${label}
485 # start facet device options
491 eval export ${facet}_dev=${device}
492 eval export ${facet}_opt=\"$@\"
493 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
503 HOST=`facet_active_host $facet`
504 [ -z $HOST ] && echo stop: no host for $facet && return 0
506 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
507 if [ ${running} -ne 0 ]; then
508 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
509 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
512 # umount should block, but we should wait for unrelated obd's
513 # like the MGS or MGC to also stop.
514 wait_exit_ST ${facet}
521 # Only supply -o to mount if we have options
522 if [ -n "$MOUNTOPT" ]; then
523 OPTIONS="-o $MOUNTOPT"
525 local device=$MGSNID:/$FSNAME
526 if [ -z "$mnt" -o -z "$FSNAME" ]; then
527 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
531 echo "Starting client: $client: $OPTIONS $device $mnt"
532 do_node $client mkdir -p $mnt
533 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
535 do_node $client "lctl set_param debug=$PTLDEBUG;
536 lctl set_param subsystem_debug=${SUBSYSTEM# };
537 lctl set_param debug_mb=${DEBUG_SIZE}"
550 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
551 if [ $running -ne 0 ]; then
552 echo "Stopping client $client $mnt (opts:$force)"
553 do_node $client lsof -t $mnt || need_kill=no
554 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
555 pids=$(do_node $client lsof -t $mnt | sort -u);
556 if [ -n $pids ]; then
557 do_node $client kill -9 $pids || true
561 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
562 if [ $busy -ne 0 ] ; then
563 echo "$mnt is still busy, wait one second" && sleep 1
564 do_node $client umount $force $mnt
569 # mount clients if not mouted
570 zconf_mount_clients() {
576 # Only supply -o to mount if we have options
577 if [ -n "$MOUNTOPT" ]; then
578 OPTIONS="-o $MOUNTOPT"
580 local device=$MGSNID:/$FSNAME
581 if [ -z "$mnt" -o -z "$FSNAME" ]; then
582 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
586 echo "Starting client $clients: $OPTIONS $device $mnt"
587 do_nodes $clients "mount | grep $mnt || { mkdir -p $mnt && mount -t lustre $OPTIONS $device $mnt || false; }"
589 echo "Started clients $clients: "
590 do_nodes $clients "mount | grep $mnt"
592 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
593 lctl set_param subsystem_debug=${SUBSYSTEM# };
594 lctl set_param debug_mb=${DEBUG_SIZE};"
599 zconf_umount_clients() {
606 echo "Stopping clients: $clients $mnt (opts:$force)"
607 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts)
608 if [ \\\$running -ne 0 ] ; then
609 echo Stopping client \\\$(hostname) client $mnt opts:$force
610 lsof -t $mnt || need_kill=no
611 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
612 pids=\\\$(lsof -t $mnt | sort -u);
613 if [ -n \\\"\\\$pids\\\" ]; then
617 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy")
618 if [ \\\$busy -ne 0 ] ; then
619 echo "$mnt is still busy, wait one second" && sleep 1
625 shudown_node_hard () {
629 for i in $(seq $attempts) ; do
632 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
633 echo "waiting for $host to fail attempts=$attempts"
634 [ $i -lt $attempts ] || \
635 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
641 local mnt=${2:-$MOUNT}
644 if [ "$FAILURE_MODE" = HARD ]; then
645 shudown_node_hard $client
647 zconf_umount_clients $client $mnt -f
653 if [ "$FAILURE_MODE" = HARD ]; then
654 shudown_node_hard $(facet_active_host $facet)
655 elif [ "$FAILURE_MODE" = SOFT ]; then
662 if [ "$FAILURE_MODE" = HARD ]; then
663 $POWER_UP `facet_active_host $facet`
671 if [ "$FAILURE_MODE" = HARD ]; then
676 # recovery-scale functions
677 check_progs_installed () {
682 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
683 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
688 start_client_load() {
690 local var=${client}_load
692 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
693 BREAK_ON_ERROR=$BREAK_ON_ERROR \
694 END_RUN_FILE=$END_RUN_FILE \
695 LOAD_PID_FILE=$LOAD_PID_FILE \
696 TESTSUITELOG=$TESTSUITELOG \
698 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
699 log "Started client load: ${!var} on $client"
704 start_client_loads () {
705 local -a clients=(${1//,/ })
706 local numloads=${#CLIENT_LOADS[@]}
709 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
710 testnum=$((nodenum % numloads))
711 eval export ${clients[nodenum]}_load=${CLIENT_LOADS[testnum]}
712 start_client_load ${clients[nodenum]}
716 # only for remote client
717 check_client_load () {
719 local var=${client}_load
721 local TESTLOAD=run_${!var}.sh
723 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
725 check_catastrophe $client || return 2
727 # see if the load is still on the client
730 while [ $RC = 254 -a $tries -gt 0 ]; do
734 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
739 if [ $RC = 254 ]; then
740 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
741 # see if we can diagnose a bit why this is
746 check_client_loads () {
747 local clients=${1//,/ }
751 for client in $clients; do
752 check_client_load $client
754 if [ "$rc" != 0 ]; then
755 log "Client load failed on node $client, rc=$rc"
761 restart_client_loads () {
762 local clients=${1//,/ }
763 local expectedfail=${2:-""}
767 for client in $clients; do
768 check_client_load $client
770 if [ "$rc" != 0 -a "$expectedfail" ]; then
771 start_client_load $client
772 echo "Restarted client load: on $client. Checking ..."
773 check_client_load $client
775 if [ "$rc" != 0 ]; then
776 log "Client load failed to restart on node $client, rc=$rc"
777 # failure one client load means test fail
778 # we do not need to check other
786 # End recovery-scale functions
788 # verify that lustre actually cleaned up properly
790 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
791 error "LBUG/LASSERT detected"
792 BUSY=`dmesg | grep -i destruct || true`
795 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
799 check_mem_leak || exit 204
801 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
802 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
804 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
805 echo "$0: modules still loaded..." 1>&2
821 while [ $WAIT -lt $MAX ]; do
822 RESULT=$(do_node $node "$TEST")
823 if [ "$RESULT" == "$FINAL" ]; then
824 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
827 echo "Waiting $((MAX - WAIT)) secs for update"
828 WAIT=$((WAIT + sleep))
831 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
835 wait_update_facet () {
837 wait_update $(facet_host $facet) $@
840 wait_delete_completed () {
841 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
842 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
846 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
848 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
849 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
850 [ "$TOTAL" -eq "$TOTALPREV" ] && break
851 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
855 echo "Delete completed."
860 check_network "$host" 900
861 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
866 local host=`facet_active_host $facet`
870 wait_recovery_complete () {
873 # Use default policy if $2 is not passed by caller.
874 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
875 # as we are in process of changing obd_timeout in different ways
876 # let's set MAX longer than that
877 local MAX=${2:-$(( TIMEOUT * 4 ))}
879 local var_svc=${facet}_svc
880 local procfile="*.${!var_svc}.recovery_status"
884 while [ $WAIT -lt $MAX ]; do
885 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
886 [[ $STATUS = "status: COMPLETE" ]] && return 0
889 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
891 echo "$facet recovery not done in $MAX sec. $STATUS"
901 # conf-sanity 31 takes a long time cleanup
902 while [ $WAIT -lt 300 ]; do
903 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
904 [ -z "${running}" ] && return 0
905 echo "waited $WAIT for${running}"
906 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
908 WAIT=$((WAIT + INTERVAL))
910 echo "service didn't stop after $WAIT seconds. Still running:"
915 wait_remote_prog () {
921 [ "$PDSH" = "no_dsh" ] && return 0
923 while [ $WAIT -lt $2 ]; do
924 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
925 [ -z "${running}" ] && return 0 || true
926 echo "waited $WAIT for: "
928 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
930 WAIT=$((WAIT + INTERVAL))
932 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
933 [ -z "$pids" ] && return 0
934 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
936 cat /proc/${pid}/status || true
937 cat /proc/${pid}/wchan || true
948 # not every config has many clients
949 if [ ! -z "$CLIENTS" ]; then
950 $PDSH $CLIENTS "df $MOUNT" > /dev/null
952 df $MOUNT > /dev/null
957 uname -n >> $MOUNT/recon
958 if [ -z "$CLIENTS" ]; then
959 df $MOUNT; uname -n >> $MOUNT/recon
961 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
963 echo Connected clients:
965 ls -l $MOUNT/recon > /dev/null
972 echo "Failing $facet on node `facet_active_host $facet`"
973 shutdown_facet $facet
974 [ -n "$sleep_time" ] && sleep $sleep_time
978 echo "df pid is $DFPID"
980 local TO=`facet_active_host $facet`
981 echo "Failover $facet to $TO"
983 mount_facet $facet || error "Restart of $facet failed"
994 local svc=${facet}_svc
995 do_facet $facet $LCTL --device %${!svc} readonly
996 do_facet $facet $LCTL --device %${!svc} notransno
997 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
998 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1001 replay_barrier_nodf() {
1002 local facet=$1 echo running=${running}
1003 do_facet $facet sync
1004 local svc=${facet}_svc
1005 echo Replay barrier on ${!svc}
1006 do_facet $facet $LCTL --device %${!svc} readonly
1007 do_facet $facet $LCTL --device %${!svc} notransno
1008 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1009 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1012 replay_barrier_nosync() {
1013 local facet=$1 echo running=${running}
1014 local svc=${facet}_svc
1015 echo Replay barrier on ${!svc}
1016 do_facet $facet $LCTL --device %${!svc} readonly
1017 do_facet $facet $LCTL --device %${!svc} notransno
1018 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1019 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1022 mds_evict_client() {
1023 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1024 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1027 ost_evict_client() {
1028 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1029 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1033 facet_failover $* || error "failover: $?"
1034 df $MOUNT || error "post-failover df: $?"
1039 facet_failover $facet
1045 change_active $facet
1046 mount_facet $facet -o abort_recovery
1047 df $MOUNT || echo "first df failed: $?"
1049 df $MOUNT || error "post-failover df: $?"
1053 echo There is no lmc. This is mountconf, baby.
1058 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1059 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1065 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1071 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1072 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1073 if [ -z "$ID" ]; then
1074 echo "Could not get a ptl id for $1..."
1083 h2name_or_ip "$1" "tcp"
1088 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1089 if type __h2elan >/dev/null 2>&1; then
1092 ID=`echo $1 | sed 's/[^0-9]*//g'`
1100 h2name_or_ip "$1" "openib"
1102 declare -fx h2openib
1105 h2name_or_ip "$1" "o2ib"
1112 [ "$facet" == client ] && echo -n $HOSTNAME && return
1113 varname=${facet}_HOST
1114 if [ -z "${!varname}" ]; then
1115 if [ "${facet:0:3}" == "ost" ]; then
1116 eval ${facet}_HOST=${ost_HOST}
1124 local activevar=${facet}active
1126 if [ -f $TMP/${facet}active ] ; then
1127 source $TMP/${facet}active
1130 active=${!activevar}
1131 if [ -z "$active" ] ; then
1138 facet_active_host() {
1140 local active=`facet_active $facet`
1141 if [ "$facet" == client ]; then
1144 echo `facet_host $active`
1150 failover=${facet}failover
1151 host=`facet_host $failover`
1152 [ -z "$host" ] && return
1153 curactive=`facet_active $facet`
1154 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1155 eval export ${facet}active=$facet
1157 eval export ${facet}active=$failover
1159 # save the active host for this facet
1160 activevar=${facet}active
1161 echo "$activevar=${!activevar}" > $TMP/$activevar
1168 if [ "$HOST" = "$HOSTNAME" ]; then
1170 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1171 echo "cannot run remote command on $HOST with $myPDSH"
1175 echo "CMD: $HOST $@" >&2
1176 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1179 if [ "$myPDSH" = "rsh" ]; then
1180 # we need this because rsh does not return exit code of an executed command
1181 local command_status="$TMP/cs"
1182 rsh $HOST ":> $command_status"
1183 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1184 cd $RPWD; sh -c \"$@\") ||
1185 echo command failed >$command_status"
1186 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1189 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1190 return ${PIPESTATUS[0]}
1193 single_local_node () {
1194 [ "$1" = "$HOSTNAME" ]
1201 if $(single_local_node $rnodes); then
1206 # This is part from do_node
1209 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1210 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1213 echo "CMD: $rnodes $@" >&2
1214 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1217 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1218 return ${PIPESTATUS[0]}
1224 HOST=`facet_active_host $facet`
1225 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1232 # make sure its not already running
1234 rm -f $TMP/${facet}active
1235 do_facet ${facet} $MKFS $*
1241 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1242 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1249 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1250 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1258 # make sure we are using the primary server, so test-framework will
1259 # be able to clean up properly.
1260 activemds=`facet_active mds1`
1261 if [ $activemds != "mds1" ]; then
1265 # assume client mount is local
1266 grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
1267 grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
1269 if [ -n "$CLIENTS" ]; then
1270 zconf_umount_clients $CLIENTS $MOUNT "$*" || true
1271 [ -n "$MOUNT2" ] && zconf_umount_clients $CLIENTS $MOUNT2 "$*" || true
1274 [ "$CLIENTONLY" ] && return
1275 # The add fn does rm ${facet}active file, this would be enough
1276 # if we use do_facet <facet> only after the facet added, but
1277 # currently we use do_facet mds in local.sh
1278 for num in `seq $MDSCOUNT`; do
1280 rm -f ${TMP}/mds${num}active
1283 for num in `seq $OSTCOUNT`; do
1285 rm -f $TMP/ost${num}active
1300 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1304 if [ "$IAMDIR" == "yes" ]; then
1305 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1306 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1309 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1311 if [ ! -z $SEC ]; then
1312 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1313 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1314 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1318 # We need ldiskfs here, may as well load them all
1320 [ "$CLIENTONLY" ] && return
1321 echo "Formatting mdts, osts"
1322 for num in `seq $MDSCOUNT`; do
1323 echo "Format mds$num: $(mdsdevname $num)"
1325 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1327 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1331 for num in `seq $OSTCOUNT`; do
1332 echo "Format ost$num: $(ostdevname $num)"
1334 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1336 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1342 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1346 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1350 # 0: success, the old identity set already.
1351 # 1: success, the old identity does not set.
1356 local j=`expr $num - 1`
1357 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1359 if [ -z "$MDT" ]; then
1363 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1366 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1368 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1371 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1373 if [ $old = "NONE" ]; then
1382 zconf_umount `hostname` $1 || error "umount failed"
1383 zconf_mount `hostname` $1 || error "mount failed"
1386 writeconf_facet () {
1390 do_facet $facet "$TUNEFS --writeconf $dev"
1394 for num in `seq $MDSCOUNT`; do
1395 DEVNAME=$(mdsdevname $num)
1396 writeconf_facet mds$num $DEVNAME
1399 for num in `seq $OSTCOUNT`; do
1400 DEVNAME=$(ostdevname $num)
1401 writeconf_facet ost$num $DEVNAME
1408 if [ -z "$CLIENTONLY" ]; then
1409 echo "Setup mdts, osts"
1410 echo $WRITECONF | grep -q "writeconf" && \
1412 for num in `seq $MDSCOUNT`; do
1413 DEVNAME=$(mdsdevname $num)
1414 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1416 # We started mds, now we should set failover variables properly.
1417 # Set mds${num}failover_HOST if it is not set (the default failnode).
1418 local varname=mds${num}failover_HOST
1419 if [ -z "${!varname}" ]; then
1420 eval mds${num}failover_HOST=$(facet_host mds$num)
1423 if [ $IDENTITY_UPCALL != "default" ]; then
1424 switch_identity $num $IDENTITY_UPCALL
1427 for num in `seq $OSTCOUNT`; do
1428 DEVNAME=$(ostdevname $num)
1429 start ost$num $DEVNAME $OST_MOUNT_OPTS
1431 # We started ost$num, now we should set ost${num}failover variable properly.
1432 # Set ost${num}failover_HOST if it is not set (the default failnode).
1433 varname=ost${num}failover_HOST
1434 if [ -z "${!varname}" ]; then
1435 eval ost${num}failover_HOST=$(facet_host ost${num})
1440 # wait a while to allow sptlrpc configuration be propogated to targets,
1441 # only needed when mounting new target devices.
1444 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1446 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1448 if [ "$MOUNT_2" ]; then
1449 mount_client $MOUNT2
1450 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1455 # by remounting mdt before ost, initial connect from mdt to ost might
1456 # timeout because ost is not ready yet. wait some time to its fully
1457 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1458 # by a context negotiation rpc with $TIMEOUT.
1459 # FIXME better by monitoring import status.
1461 sleep $((TIMEOUT + 5))
1467 mounted_lustre_filesystems() {
1468 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1471 init_facet_vars () {
1478 eval export ${facet}_dev=${device}
1479 eval export ${facet}_opt=\"$@\"
1481 local dev=${facet}_dev
1482 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1483 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1485 eval export ${facet}_svc=${label}
1487 local varname=${facet}failover_HOST
1488 if [ -z "${!varname}" ]; then
1489 eval $varname=$(facet_host $facet)
1493 init_facets_vars () {
1496 for num in `seq $MDSCOUNT`; do
1497 DEVNAME=`mdsdevname $num`
1498 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1501 for num in `seq $OSTCOUNT`; do
1502 DEVNAME=`ostdevname $num`
1503 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1507 init_param_vars () {
1508 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1509 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1510 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1512 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1513 log "Using TIMEOUT=$TIMEOUT"
1518 local myMGS_host=$mgs_HOST
1519 if [ "$NETTYPE" = "ptl" ]; then
1520 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1523 echo Checking config lustre mounted on $mntpt
1524 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1525 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1527 if [ "$mgshost" != "$myMGS_host" ]; then
1528 FAIL_ON_ERROR=true \
1529 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1530 Please use correct config or set mds_HOST correctly!"
1535 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1536 local cltimeout=$(lctl get_param -n timeout)
1537 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1538 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1543 check_and_setup_lustre() {
1544 local MOUNTED=$(mounted_lustre_filesystems)
1545 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1546 [ "$REFORMAT" ] && formatall
1548 MOUNTED=$(mounted_lustre_filesystems | head -1)
1549 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1550 export I_MOUNTED=yes
1556 if [ "$ONLY" == "setup" ]; then
1561 cleanup_and_setup_lustre() {
1562 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1563 lctl set_param debug=0 || true
1565 if [ "$ONLY" == "cleanup" ]; then
1569 check_and_setup_lustre
1572 check_and_cleanup_lustre() {
1573 if [ "`mount | grep $MOUNT`" ]; then
1574 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1576 if [ "$I_MOUNTED" = "yes" ]; then
1577 cleanupall -f || error "cleanup failed"
1589 while [ $NETWORK -eq 0 ]; do
1590 ping -c 1 -w 3 $1 > /dev/null
1591 if [ $? -eq 0 ]; then
1595 echo "waiting for $1, $((MAX - WAIT)) secs left"
1598 if [ $WAIT -gt $MAX ]; then
1599 echo "Network not available"
1605 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1616 # the sed converts spaces to commas, but leaves the last space
1617 # alone, so the line doesn't end with a comma.
1618 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1621 # list, excluded are the comma separated lists
1622 exclude_items_from_list () {
1628 for item in ${excluded//,/ }; do
1629 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1631 echo $(comma_list $list)
1634 # list, expand are the comma separated lists
1636 local list=${1//,/ }
1637 local expand=${2//,/ }
1640 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1641 echo $(comma_list $expanded)
1645 (cd `dirname $1`; echo $PWD/`basename $1`)
1649 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1650 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1653 local count=${type}COUNT
1654 for ((i=1; i<=${!count}; i++)) do
1655 list="$list ${name}$i"
1657 echo $(comma_list $list)
1660 ##################################
1661 # Adaptive Timeouts funcs
1664 if [ -z "$AT_MAX_PATH" ]; then
1665 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1666 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1672 at_is_valid || error "invalid call"
1674 # only check mds, we assume at_max is the same on all nodes
1675 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1676 if [ $at_max -eq 0 ]; then
1686 at_is_valid || error "invalid call"
1688 # suppose that all ost-s has the same at_max set
1689 if [ $facet == "ost" ]; then
1690 do_facet ost1 "cat $AT_MAX_PATH"
1692 do_facet $facet "cat $AT_MAX_PATH"
1700 at_is_valid || error "invalid call"
1704 if [ $facet == "ost" ]; then
1705 for i in `seq $OSTCOUNT`; do
1706 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1708 elif [ $facet == "mds" ]; then
1709 for i in `seq $MDSCOUNT`; do
1710 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1713 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1718 ##################################
1722 # OBD_FAIL_MDS_ALL_REQUEST_NET
1724 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1725 do_facet client "$1" || RC=$?
1726 do_facet $SINGLEMDS lctl set_param fail_loc=0
1731 # OBD_FAIL_MDS_ALL_REPLY_NET
1733 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1734 do_facet client "$@" || RC=$?
1735 do_facet $SINGLEMDS lctl set_param fail_loc=0
1739 drop_reint_reply() {
1740 # OBD_FAIL_MDS_REINT_NET_REP
1742 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1743 do_facet client "$@" || RC=$?
1744 do_facet $SINGLEMDS lctl set_param fail_loc=0
1749 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1751 do_facet ost1 lctl set_param fail_loc=0x214
1752 do_facet client "$1" || RC=$?
1753 do_facet client "sync"
1754 do_facet ost1 lctl set_param fail_loc=0
1758 drop_ldlm_cancel() {
1759 #define OBD_FAIL_LDLM_CANCEL 0x304
1761 do_facet client lctl set_param fail_loc=0x304
1762 do_facet client "$@" || RC=$?
1763 do_facet client lctl set_param fail_loc=0
1767 drop_bl_callback() {
1768 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1770 do_facet client lctl set_param fail_loc=0x305
1771 do_facet client "$@" || RC=$?
1772 do_facet client lctl set_param fail_loc=0
1777 #define OBD_FAIL_LDLM_REPLY 0x30c
1779 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1780 do_facet client "$@" || RC=$?
1781 do_facet $SINGLEMDS lctl set_param fail_loc=0
1789 echo "clearing fail_loc on $facet"
1790 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1793 set_nodes_failloc () {
1797 for node in $nodes ; do
1798 do_node $node lctl set_param fail_loc=$2
1802 cancel_lru_locks() {
1803 $LCTL mark "cancel_lru_locks $1 start"
1804 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1805 $LCTL set_param -n $d=clear
1807 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1808 $LCTL mark "cancel_lru_locks $1 stop"
1813 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1814 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1815 echo "$DEFAULT_LRU_SIZE"
1820 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1823 lru_resize_disable()
1825 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1830 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1831 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1832 echo there is still data in page cache $FILE ?
1833 lctl get_param -n $FILE
1841 DEBUGSAVE="$(lctl get_param -n debug)"
1845 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1849 ##################################
1851 ##################################
1854 local TYPE=${TYPE:-"FAIL"}
1856 lctl set_param fail_loc=0 2>/dev/null || true
1857 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1858 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1859 echo "Dumping lctl log to $ERRLOG"
1860 # We need to dump the logs on all nodes
1861 local NODES=$(nodes_list)
1862 for NODE in $NODES; do
1863 do_node $NODE $LCTL dk $ERRLOG
1866 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1872 $FAIL_ON_ERROR && exit 1 || true
1880 # use only if we are ignoring failures for this test, bugno required.
1881 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1882 # e.g. error_ignore 5494 "your message"
1884 local TYPE="IGNORE (bz$1)"
1890 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1891 [ "$TESTSUITELOG" ] && \
1892 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1895 build_test_filter() {
1896 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1900 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1901 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1902 [ "$EXCEPT_SLOW" ] && \
1903 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1904 for E in $EXCEPT $ALWAYS_EXCEPT; do
1905 eval EXCEPT_${E}=true
1907 for E in $EXCEPT_SLOW; do
1908 eval EXCEPT_SLOW_${E}=true
1910 for G in $GRANT_CHECK_LIST; do
1911 eval GCHECK_ONLY_${G}=true
1920 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
1923 # print a newline if the last test was skipped
1924 export LAST_SKIPPED=
1928 export base=`basetest $1`
1929 if [ ! -z "$ONLY" ]; then
1931 if [ ${!testname}x != x ]; then
1932 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1937 if [ ${!testname}x != x ]; then
1938 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
1947 if [ ${!testname}x != x ]; then
1949 TESTNAME=test_$1 skip "skipping excluded test $1"
1952 testname=EXCEPT_$base
1953 if [ ${!testname}x != x ]; then
1955 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
1958 testname=EXCEPT_SLOW_$1
1959 if [ ${!testname}x != x ]; then
1961 TESTNAME=test_$1 skip "skipping SLOW test $1"
1964 testname=EXCEPT_SLOW_$base
1965 if [ ${!testname}x != x ]; then
1967 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
1977 EQUALS="======================================================================"
1981 local suffixlen=$((${#EQUALS} - ${#msg}))
1982 [ $suffixlen -lt 5 ] && suffixlen=5
1983 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
1988 lsmod | grep lnet > /dev/null || load_modules
2000 local NODES=$(nodes_list)
2001 for NODE in $NODES; do
2002 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
2008 strace -o $TMP/$1.strace -ttt $*
2010 log "FINISHED: $*: rc $RC"
2015 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2020 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2021 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2022 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2026 local myNODES=$(nodes_list)
2029 for NODE in $myNODES; do
2030 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
2038 export tdir=d0.${TESTSUITE}/d${base}
2040 local SAVE_UMASK=`umask`
2043 local BEFORE=`date +%s`
2044 log "== test $testnum: $message ============ `date +%H:%M:%S` ($BEFORE)"
2046 export TESTNAME=test_$testnum
2048 test_${testnum} || error "test_$testnum failed with $?"
2052 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2053 check_catastrophe || error "LBUG/LASSERT detected"
2054 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2055 pass "($((`date +%s` - $BEFORE))s)"
2063 (cd `dirname $1`; echo $PWD/`basename $1`)
2067 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2068 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2073 export base=`basetest $1`
2074 [ "$CHECK_GRANT" == "no" ] && return 0
2076 testname=GCHECK_ONLY_${base}
2077 [ ${!testname}x == x ] && return 0
2079 echo -n "checking grant......"
2081 # write some data to sync client lost_grant
2082 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2083 for i in `seq $OSTCOUNT`; do
2084 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2085 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2086 count=1 > /dev/null 2>&1
2088 # sync all the data and make sure no pending data on server
2091 #get client grant and server grant
2093 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2094 client_grant=$((client_grant + $d))
2097 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2098 server_grant=$((server_grant + $d))
2101 # cleanup the check_grant file
2102 for i in `seq $OSTCOUNT`; do
2103 rm $DIR1/${tfile}_check_grant_$i
2106 #check whether client grant == server grant
2107 if [ $client_grant != $server_grant ]; then
2108 echo "failed: client:${client_grant} server: ${server_grant}"
2115 ########################
2121 ost=`echo $1 | awk -F_ '{print $3}'`
2122 if [ -z $ost ]; then
2123 ost=`echo $1 | sed 's/-osc.*//'`
2130 [ "$node" != "$(hostname)" ]
2136 for node in $(mdts_nodes); do
2137 remote_node $node && return 0
2144 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2150 for node in $(osts_nodes) ; do
2151 remote_node $node && return 0
2158 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2164 MGS=$(facet_host mgs)
2165 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2171 for num in `seq $MDSCOUNT`; do
2172 MDSNODES="$MDSNODES $(facet_host mds$num)"
2174 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2180 remote_ost && remote_mds
2184 local OSTNODES=$(facet_host ost1)
2187 for num in `seq $OSTCOUNT`; do
2188 local myOST=$(facet_host ost$num)
2189 OSTNODES="$OSTNODES $myOST"
2191 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2197 # FIXME. We need a list of clients
2198 local myNODES=$HOSTNAME
2201 # CLIENTS (if specified) contains the local client
2202 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2204 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2205 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2208 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2213 remote_nodes_list () {
2214 local rnodes=$(nodes_list)
2215 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2219 init_clients_lists () {
2220 # Sanity check: exclude the local client from RCLIENTS
2221 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2223 # Sanity check: exclude the dup entries
2224 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2226 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2228 # Sanity check: exclude the dup entries from CLIENTS
2229 # for those configs which has SINGLCLIENT set to local client
2230 clients=$(for i in $clients; do echo $i; done | sort -u)
2232 CLIENTS=`comma_list $clients`
2233 local -a remoteclients=($rclients)
2234 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2235 varname=CLIENT$((i + 2))
2236 eval $varname=${remoteclients[i]}
2239 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2242 get_random_entry () {
2245 rnodes=${rnodes//,/ }
2247 local -a nodes=($rnodes)
2248 local num=${#nodes[@]}
2249 local i=$((RANDOM * num * 2 / 65536))
2256 lctl get_param version | grep -q patchless
2260 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2265 echo $nodes | wc -w || true
2269 local nodes=$(osts_nodes)
2270 local osscount=$(get_node_count "$nodes")
2271 [ ! "$OSTCOUNT" = "$osscount" ]
2275 local nodes=$(mdts_nodes)
2276 local mdtcount=$(get_node_count "$nodes")
2277 [ ! "$MDSCOUNT" = "$mdtcount" ]
2280 generate_machine_file() {
2281 local nodes=${1//,/ }
2282 local machinefile=$2
2283 rm -f $machinefile || error "can't rm $machinefile"
2284 for node in $nodes; do
2285 echo $node >>$machinefile
2290 local file=$1/stripe
2292 $LFS getstripe -v $file || error
2296 check_runas_id_ret() {
2298 local myRUNAS_UID=$1
2299 local myRUNAS_GID=$2
2302 if [ -z "$myRUNAS" ]; then
2303 error_exit "myRUNAS command must be specified for check_runas_id"
2306 $myRUNAS krb5_login.sh || \
2307 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2309 mkdir $DIR/d0_runas_test
2311 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2312 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2313 rm -rf $DIR/d0_runas_test
2318 local myRUNAS_UID=$1
2319 local myRUNAS_GID=$2
2322 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2323 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2324 Please set RUNAS_ID to some UID which exists on MDS and client or
2325 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2328 # Run multiop in the background, but wait for it to print
2329 # "PAUSING" to its stdout before returning from this function.
2330 multiop_bg_pause() {
2331 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2335 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2338 echo "$MULTIOP_PROG $FILE v$ARGS"
2339 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2341 echo "TMPPIPE=${TMPPIPE}"
2342 read -t 60 multiop_output < $TMPPIPE
2343 if [ $? -ne 0 ]; then
2348 if [ "$multiop_output" != "PAUSING" ]; then
2349 echo "Incorrect multiop output: $multiop_output"
2357 inodes_available () {
2358 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2362 # reset llite stat counters
2363 clear_llite_stats(){
2364 lctl set_param -n llite.*.stats 0
2367 # sum llite stat items
2368 calc_llite_stats() {
2369 local res=$(lctl get_param -n llite.*.stats |
2370 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2374 # reset osc stat counters
2376 lctl set_param -n osc.*.osc_stats 0
2379 # sum osc stat items
2381 local res=$(lctl get_param -n osc.*.osc_stats |
2382 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2387 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2390 calc_osc_kbytes () {
2391 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2394 # save_lustre_params(node, parameter_mask)
2395 # generate a stream of formatted strings (<node> <param name>=<param value>)
2396 save_lustre_params() {
2398 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2401 # restore lustre parameters from input stream, produces by save_lustre_params
2402 restore_lustre_params() {
2406 while IFS=" =" read node name val; do
2407 do_node $node "lctl set_param -n $name $val"
2411 check_catastrophe () {
2412 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2414 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
2415 if [ $rnodes ]; then
2416 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2431 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2433 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2434 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2435 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2439 # CMD: determine mds index where directory inode presents
2442 local file=$dir/f0.get_mds_dir_tmpfile
2445 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2446 local oldused=($iused)
2450 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2451 local newused=($iused)
2454 for ((i=0; i<${#newused[@]}; i++)); do
2455 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2461 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2465 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2466 local command="$mpirun $@"
2468 if [ "$MPI_USER" != root -a $mpirun ]; then
2469 echo "+ chmod 0777 $MOUNT"
2471 command="su $MPI_USER sh -c \"$command \""
2479 mdsrate_cleanup () {
2480 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5