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 # function used by scripts run on remote nodes
22 . $(dirname $0)/functions.sh
26 [[ $DIR/ = $MOUNT/* ]] || \
27 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
28 [[ $DIR1/ = $MOUNT1/* ]] || \
29 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
30 [[ $DIR2/ = $MOUNT2/* ]] || \
31 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
33 [ -n "$failed" ] && exit 99 || true
37 echo "usage: $0 [-r] [-f cfgfile]"
44 [ "$TESTSUITE" == "lfscktest" ] && return 0
45 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
46 local form="%-13s %-17s %s\n"
47 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
48 echo "------------------------------------------------------------------------------------"
49 for O in $TESTSUITE_LIST; do
52 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
55 local log=${TMP}/${o}.log
56 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
57 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
58 [ "${!O}" = "done" ] && \
59 printf "$form" "Done" "$O" "E=$skipped" && \
60 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
64 for O in $TESTSUITE_LIST; do
65 [ "${!O}" = "no" ] && \
66 printf "$form" "Skipped" "$O" ""
69 for O in $TESTSUITE_LIST; do
70 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
71 printf "$form" "UNFINISHED" "$O" ""
76 export LUSTRE=`absolute_path $LUSTRE`
77 export TESTSUITE=`basename $0 .sh`
78 export TEST_FAILED=false
80 export MKE2FS=${MKE2FS:-mke2fs}
81 export DEBUGFS=${DEBUGFS:-debugfs}
82 export TUNE2FS=${TUNE2FS:-tune2fs}
83 export E2LABEL=${E2LABEL:-e2label}
84 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
85 export E2FSCK=${E2FSCK:-e2fsck}
87 #[ -d /r ] && export ROOT=${ROOT:-/r}
88 export TMP=${TMP:-$ROOT/tmp}
89 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
90 export HOSTNAME=${HOSTNAME:-`hostname`}
91 if ! echo $PATH | grep -q $LUSTRE/utils; then
92 export PATH=$PATH:$LUSTRE/utils
94 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
95 export PATH=$PATH:$LUSTRE/utils/gss
97 if ! echo $PATH | grep -q $LUSTRE/tests; then
98 export PATH=$PATH:$LUSTRE/tests
100 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mdsrate"}
101 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
102 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
103 export PATH=$PATH:$LUSTRE/tests/racer
105 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
106 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
107 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
108 [ ! -f "$LFS" ] && export LFS=$(which lfs)
109 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
110 if [ ! -f "$L_GETIDENTITY" ]; then
111 if `which l_getidentity > /dev/null 2>&1`; then
112 export L_GETIDENTITY=$(which l_getidentity)
114 export L_GETIDENTITY=NONE
117 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
118 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
119 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
120 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
121 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
122 export FSTYPE=${FSTYPE:-"ldiskfs"}
123 export NAME=${NAME:-local}
124 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
125 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
126 export LGSSD=$(which lgssd)
127 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
128 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
129 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
131 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
134 if [ "$ACCEPTOR_PORT" ]; then
135 export PORT_OPT="--port $ACCEPTOR_PORT"
140 echo "Using GSS/krb5 ptlrpc security flavor"
141 which lgss_keyring > /dev/null 2>&1 || \
142 error "built with gss disabled! SEC=$SEC"
153 IDENTITY_UPCALL=false
157 # Paths on remote nodes, if different
158 export RLUSTRE=${RLUSTRE:-$LUSTRE}
159 export RPWD=${RPWD:-$PWD}
160 export I_MOUNTED=${I_MOUNTED:-"no"}
164 while getopts "rvwf:" opt $*; do
167 r) REFORMAT=--reformat;;
169 w) WRITECONF=writeconf;;
174 shift $((OPTIND - 1))
177 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
183 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
184 *) EXT=".ko"; USE_QUOTA=yes;;
191 BASE=`basename $module $EXT`
192 lsmod | grep -q ${BASE} || \
193 if [ -f ${LUSTRE}/${module}${EXT} ]; then
194 insmod ${LUSTRE}/${module}${EXT} $@
196 # must be testing a "make install" or "rpm" installation
197 # note failed to load ptlrpc_gss is considered not fatal
198 if [ "$BASE" == "ptlrpc_gss" ]; then
199 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
207 if [ -n "$MODPROBE" ]; then
211 if [ "$HAVE_MODULES" = true ]; then
217 echo Loading modules from $LUSTRE
218 load_module ../libcfs/libcfs/libcfs
219 [ "$PTLDEBUG" ] && lctl set_param debug=$PTLDEBUG
220 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug=${SUBSYSTEM# }
222 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
223 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
224 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
225 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
226 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
227 echo "lnet options: '$LNETOPTS'"
228 # note that insmod will ignore anything in modprobe.conf
229 load_module ../lnet/lnet/lnet $LNETOPTS
230 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
231 load_module ../lnet/klnds/$LNETLND
232 load_module lvfs/lvfs
233 load_module obdclass/obdclass
234 load_module ptlrpc/ptlrpc
235 load_module ptlrpc/gss/ptlrpc_gss
236 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
244 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
245 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
246 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
247 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
252 load_module lvfs/fsfilt_$FSTYPE
256 load_module obdfilter/obdfilter
259 load_module llite/lustre
260 load_module llite/llite_lloop
261 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
263 rm -f $OGDB/ogdb-$HOSTNAME
264 $LCTL modules > $OGDB/ogdb-$HOSTNAME
266 # 'mount' doesn't look in $PATH, just sbin
267 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
271 if [ `uname -r | cut -c 3` -eq 4 ]; then
279 MODULES=$($LCTL modules | awk '{ print $2 }')
280 while [ -n "$MODULES" ]; do
282 $RMMOD $MODULES > /dev/null 2>&1 || true
283 MODULES=$($LCTL modules | awk '{ print $2 }')
284 if [ -z "$MODULES" ]; then
288 echo "waiting, $((MAX - WAIT)) secs left"
290 if [ $WAIT -eq $MAX ]; then
291 echo "LNET modules $MODULES will not unload"
298 unload_dep_module() {
300 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
302 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
303 for SUBMOD in $DEPS; do
304 unload_dep_module $SUBMOD
306 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
307 $RMMOD $MODULE || true
311 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
312 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
313 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
314 echo "$LEAK_LUSTRE" 1>&2
315 echo "$LEAK_PORTALS" 1>&2
316 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
317 echo "Memory leaks detected"
318 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
324 wait_exit_ST client # bug 12845
326 lsmod | grep libcfs > /dev/null && $LCTL dl
327 unload_dep_module $FSTYPE
328 unload_dep_module libcfs
330 local MODULES=$($LCTL modules | awk '{ print $2 }')
331 if [ -n "$MODULES" ]; then
332 echo "Modules still loaded: "
334 if [ "$(lctl dl)" ]; then
335 echo "Lustre still loaded"
340 echo "Lustre stopped but LNET is still loaded, waiting..."
341 wait_for_lnet || return 3
347 check_mem_leak || return 254
349 echo "modules unloaded."
353 check_gss_daemon_facet() {
357 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
358 if [ $num -ne 1 ]; then
359 echo "$num instance of $dname on $facet"
368 do_facet $facet "killall -2 $@ 2>/dev/null || true"
371 start_gss_daemons() {
373 for num in `seq $MDSCOUNT`; do
374 do_facet mds$num "$LSVCGSSD -v"
376 do_facet mds$num "$LGSSD -v"
380 for num in `seq $OSTCOUNT`; do
381 do_facet ost$num "$LSVCGSSD -v"
384 # FIXME: is "client" the right facet name?
386 do_facet client "$LGSSD -v"
389 # wait daemons entering "stable" status
393 # check daemons are running
395 for num in `seq $MDSCOUNT`; do
396 check_gss_daemon_facet mds$num lsvcgssd
398 check_gss_daemon_facet mds$num lgssd
401 for num in `seq $OSTCOUNT`; do
402 check_gss_daemon_facet ost$num lsvcgssd
405 check_gss_daemon_facet client lgssd
410 for num in `seq $MDSCOUNT`; do
411 send_sigint mds$num lsvcgssd lgssd
413 for num in `seq $OSTCOUNT`; do
414 send_sigint ost$num lsvcgssd
416 send_sigint client lgssd
423 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
424 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
432 # maybe cleanup credential cache?
438 local device=`mdsdevname $num`
439 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
445 local device=`ostdevname $num`
446 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
454 local dev=${facet}_dev
455 local opt=${facet}_opt
456 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
457 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
459 if [ $RC -ne 0 ]; then
460 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
461 echo "Start of ${!dev} on ${facet} failed ${RC}"
463 do_facet ${facet} "lctl set_param debug=$PTLDEBUG; \
464 lctl set_param subsystem_debug=${SUBSYSTEM# }; \
465 lctl set_param debug_mb=${DEBUG_SIZE}; \
468 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
469 [ -z "$label" ] && echo no label for ${!dev} && exit 1
470 eval export ${facet}_svc=${label}
471 echo Started ${label}
476 # start facet device options
482 eval export ${facet}_dev=${device}
483 eval export ${facet}_opt=\"$@\"
484 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
494 HOST=`facet_active_host $facet`
495 [ -z $HOST ] && echo stop: no host for $facet && return 0
497 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
498 if [ ${running} -ne 0 ]; then
499 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
500 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
503 # umount should block, but we should wait for unrelated obd's
504 # like the MGS or MGC to also stop.
505 wait_exit_ST ${facet}
508 # save quota version (both administrative and operational quotas)
509 quota_save_version() {
510 local fsname=${2:-$FSNAME}
511 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$1"
513 local osts=$(get_facets OST)
514 for ost in ${osts//,/ }; do
516 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1"
520 # client could mount several lustre
522 local fsname=${1:-$FSNAME}
524 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
525 do_nodes $(comma_list $(osts_nodes)) \
526 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
530 restore_quota_type () {
531 local mntpt=${1:-$MOUNT}
532 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
533 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
537 quota_save_version $old_QUOTA_TYPE
538 $LFS quotacheck -ug $mntpt
545 # 1. run quotacheck only if quota is off
546 # 2. save the original quota_type params, restore them after testing
548 # Suppose that quota type the same on mds and ost
549 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
550 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
551 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
552 export old_QUOTA_TYPE=$quota_type
553 quota_save_version $QUOTA_TYPE
554 $LFS quotacheck -ug $mntpt
557 local quota_usrs=$QUOTA_USERS
559 # get_filesystem_size
560 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
561 local blk_soft=$((disksz + 1024))
562 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
564 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
566 local i_hard=$((i_soft + i_soft / 20))
568 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
569 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
572 for usr in $quota_usrs; do
573 echo "Setting up quota on $client:$mntpt for $usr..."
575 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
577 eval $cmd || error "$cmd FAILED!"
579 # display the quota status
580 echo "Quota settings for $usr : "
581 $LFS quota -v -u $usr $mntpt || true
589 # Only supply -o to mount if we have options
590 if [ -n "$MOUNTOPT" ]; then
591 OPTIONS="-o $MOUNTOPT"
593 local device=$MGSNID:/$FSNAME
594 if [ -z "$mnt" -o -z "$FSNAME" ]; then
595 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
599 echo "Starting client: $client: $OPTIONS $device $mnt"
600 do_node $client mkdir -p $mnt
601 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
603 do_node $client "lctl set_param debug=$PTLDEBUG;
604 lctl set_param subsystem_debug=${SUBSYSTEM# };
605 lctl set_param debug_mb=${DEBUG_SIZE}"
618 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
619 if [ $running -ne 0 ]; then
620 echo "Stopping client $client $mnt (opts:$force)"
621 do_node $client lsof -t $mnt || need_kill=no
622 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
623 pids=$(do_node $client lsof -t $mnt | sort -u);
624 if [ -n $pids ]; then
625 do_node $client kill -9 $pids || true
629 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
630 if [ $busy -ne 0 ] ; then
631 echo "$mnt is still busy, wait one second" && sleep 1
632 do_node $client umount $force $mnt
637 # nodes is comma list
638 sanity_mount_check_nodes () {
644 # FIXME: assume that all cluster nodes run the same os
645 [ "$(uname)" = Linux ] || return 0
648 for mnt in $mnts ; do
649 do_nodes $nodes "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
650 mpts=\\\$(mount | grep -w -c $mnt);
651 if [ \\\$running -ne \\\$mpts ]; then
652 echo \\\$(hostname) env are INSANE!;
660 sanity_mount_check_servers () {
661 echo Checking servers environments
663 # FIXME: modify get_facets to display all facets wo params
664 local facets="$(get_facets OST),$(get_facets MDS)"
668 for facet in ${facets//,/ }; do
669 node=$(facet_host ${facet})
670 mnt=${MOUNT%/*}/${facet}
671 sanity_mount_check_nodes $node $mnt ||
672 { error "server $node environments are insane!"; return 1; }
676 sanity_mount_check_clients () {
677 local clients=${1:-$CLIENTS}
678 local mntpt=${2:-$MOUNT}
679 local mntpt2=${3:-$MOUNT2}
681 [ -z $clients ] && clients=$(hostname)
682 echo Checking clients $clients environments
684 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
685 error "clients environments are insane!"
688 sanity_mount_check () {
689 sanity_mount_check_servers || return 1
690 sanity_mount_check_clients || return 2
693 # mount clients if not mouted
694 zconf_mount_clients() {
700 # Only supply -o to mount if we have options
701 if [ -n "$MOUNTOPT" ]; then
702 OPTIONS="-o $MOUNTOPT"
704 local device=$MGSNID:/$FSNAME
705 if [ -z "$mnt" -o -z "$FSNAME" ]; then
706 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
710 echo "Starting client $clients: $OPTIONS $device $mnt"
712 do_nodes $clients "set -x;
713 running=\\\$(mount | grep -c $mnt' ')
715 if [ \\\$running -eq 0 ] ; then
717 mount -t lustre $OPTIONS $device $mnt
722 echo "Started clients $clients: "
723 do_nodes $clients "mount | grep -w $mnt"
725 do_nodes $clients "lctl set_param debug=$PTLDEBUG;
726 lctl set_param subsystem_debug=${SUBSYSTEM# };
727 lctl set_param debug_mb=${DEBUG_SIZE};"
732 zconf_umount_clients() {
739 echo "Stopping clients: $clients $mnt (opts:$force)"
740 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
741 if [ \\\$running -ne 0 ] ; then
742 echo Stopping client \\\$(hostname) client $mnt opts:$force;
743 lsof -t $mnt || need_kill=no;
744 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
745 pids=\\\$(lsof -t $mnt | sort -u);
746 if [ -n \\\"\\\$pids\\\" ]; then
750 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
751 if [ \\\$busy -ne 0 ] ; then
752 echo "$mnt is still busy, wait one second" && sleep 1;
758 shudown_node_hard () {
762 for i in $(seq $attempts) ; do
765 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
766 echo "waiting for $host to fail attempts=$attempts"
767 [ $i -lt $attempts ] || \
768 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
774 local mnt=${2:-$MOUNT}
777 if [ "$FAILURE_MODE" = HARD ]; then
778 shudown_node_hard $client
780 zconf_umount_clients $client $mnt -f
786 if [ "$FAILURE_MODE" = HARD ]; then
787 shudown_node_hard $(facet_active_host $facet)
788 elif [ "$FAILURE_MODE" = SOFT ]; then
795 if [ "$FAILURE_MODE" = HARD ]; then
796 $POWER_UP `facet_active_host $facet`
804 if [ "$FAILURE_MODE" = HARD ]; then
809 # recovery-scale functions
810 check_progs_installed () {
815 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
816 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
821 start_client_load() {
823 local var=${client}_load
825 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
826 BREAK_ON_ERROR=$BREAK_ON_ERROR \
827 END_RUN_FILE=$END_RUN_FILE \
828 LOAD_PID_FILE=$LOAD_PID_FILE \
829 TESTSUITELOG=$TESTSUITELOG \
831 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
832 log "Started client load: ${!var} on $client"
837 start_client_loads () {
838 local -a clients=(${1//,/ })
839 local numloads=${#CLIENT_LOADS[@]}
842 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
843 testnum=$((nodenum % numloads))
844 eval export ${clients[nodenum]}_load=${CLIENT_LOADS[testnum]}
845 start_client_load ${clients[nodenum]}
849 # only for remote client
850 check_client_load () {
852 local var=${client}_load
854 local TESTLOAD=run_${!var}.sh
856 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
858 check_catastrophe $client || return 2
860 # see if the load is still on the client
863 while [ $RC = 254 -a $tries -gt 0 ]; do
867 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
872 if [ $RC = 254 ]; then
873 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
874 # see if we can diagnose a bit why this is
879 check_client_loads () {
880 local clients=${1//,/ }
884 for client in $clients; do
885 check_client_load $client
887 if [ "$rc" != 0 ]; then
888 log "Client load failed on node $client, rc=$rc"
894 restart_client_loads () {
895 local clients=${1//,/ }
896 local expectedfail=${2:-""}
900 for client in $clients; do
901 check_client_load $client
903 if [ "$rc" != 0 -a "$expectedfail" ]; then
904 start_client_load $client
905 echo "Restarted client load: on $client. Checking ..."
906 check_client_load $client
908 if [ "$rc" != 0 ]; then
909 log "Client load failed to restart on node $client, rc=$rc"
910 # failure one client load means test fail
911 # we do not need to check other
919 # End recovery-scale functions
921 # verify that lustre actually cleaned up properly
923 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
924 error "LBUG/LASSERT detected"
925 BUSY=`dmesg | grep -i destruct || true`
928 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
932 check_mem_leak || exit 204
934 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
935 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
937 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
938 echo "$0: modules still loaded..." 1>&2
954 while [ $WAIT -lt $MAX ]; do
955 RESULT=$(do_node $node "$TEST")
956 if [ "$RESULT" == "$FINAL" ]; then
957 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
960 echo "Waiting $((MAX - WAIT)) secs for update"
961 WAIT=$((WAIT + sleep))
964 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
968 wait_update_facet () {
970 wait_update $(facet_host $facet) $@
973 wait_delete_completed () {
974 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
975 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
979 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
981 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
982 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
983 [ "$TOTAL" -eq "$TOTALPREV" ] && break
984 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
988 echo "Delete completed."
993 check_network "$host" 900
994 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
999 local host=`facet_active_host $facet`
1003 wait_recovery_complete () {
1006 # Use default policy if $2 is not passed by caller.
1007 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1008 # as we are in process of changing obd_timeout in different ways
1009 # let's set MAX longer than that
1010 local MAX=${2:-$(( TIMEOUT * 4 ))}
1012 local var_svc=${facet}_svc
1013 local procfile="*.${!var_svc}.recovery_status"
1017 while [ $WAIT -lt $MAX ]; do
1018 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1019 [[ $STATUS = "status: COMPLETE" ]] && return 0
1022 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1024 echo "$facet recovery not done in $MAX sec. $STATUS"
1034 # conf-sanity 31 takes a long time cleanup
1035 while [ $WAIT -lt 300 ]; do
1036 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1037 [ -z "${running}" ] && return 0
1038 echo "waited $WAIT for${running}"
1039 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1041 WAIT=$((WAIT + INTERVAL))
1043 echo "service didn't stop after $WAIT seconds. Still running:"
1048 wait_remote_prog () {
1054 [ "$PDSH" = "no_dsh" ] && return 0
1056 while [ $WAIT -lt $2 ]; do
1057 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1058 [ -z "${running}" ] && return 0 || true
1059 echo "waited $WAIT for: "
1061 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1063 WAIT=$((WAIT + INTERVAL))
1065 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1066 [ -z "$pids" ] && return 0
1067 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1068 # FIXME: not portable
1069 for pid in $pids; do
1070 cat /proc/${pid}/status || true
1071 cat /proc/${pid}/wchan || true
1073 kill -9 $pid || true
1082 # not every config has many clients
1083 if [ ! -z "$CLIENTS" ]; then
1084 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1086 df $MOUNT > /dev/null
1090 client_reconnect() {
1091 uname -n >> $MOUNT/recon
1092 if [ -z "$CLIENTS" ]; then
1093 df $MOUNT; uname -n >> $MOUNT/recon
1095 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1097 echo Connected clients:
1099 ls -l $MOUNT/recon > /dev/null
1106 echo "Failing $facet on node `facet_active_host $facet`"
1107 shutdown_facet $facet
1108 [ -n "$sleep_time" ] && sleep $sleep_time
1112 echo "df pid is $DFPID"
1113 change_active $facet
1114 local TO=`facet_active_host $facet`
1115 echo "Failover $facet to $TO"
1117 mount_facet $facet || error "Restart of $facet failed"
1126 do_facet $facet sync
1128 local svc=${facet}_svc
1129 do_facet $facet $LCTL --device %${!svc} readonly
1130 do_facet $facet $LCTL --device %${!svc} notransno
1131 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1132 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1135 replay_barrier_nodf() {
1136 local facet=$1 echo running=${running}
1137 do_facet $facet sync
1138 local svc=${facet}_svc
1139 echo Replay barrier on ${!svc}
1140 do_facet $facet $LCTL --device %${!svc} readonly
1141 do_facet $facet $LCTL --device %${!svc} notransno
1142 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1143 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1146 replay_barrier_nosync() {
1147 local facet=$1 echo running=${running}
1148 local svc=${facet}_svc
1149 echo Replay barrier on ${!svc}
1150 do_facet $facet $LCTL --device %${!svc} readonly
1151 do_facet $facet $LCTL --device %${!svc} notransno
1152 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1153 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1156 mds_evict_client() {
1157 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1158 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1161 ost_evict_client() {
1162 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1163 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1167 facet_failover $* || error "failover: $?"
1168 df $MOUNT || error "post-failover df: $?"
1173 facet_failover $facet
1179 change_active $facet
1180 mount_facet $facet -o abort_recovery
1181 df $MOUNT || echo "first df failed: $?"
1183 df $MOUNT || error "post-failover df: $?"
1187 echo There is no lmc. This is mountconf, baby.
1192 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1193 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1199 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1205 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1206 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1207 if [ -z "$ID" ]; then
1208 echo "Could not get a ptl id for $1..."
1217 h2name_or_ip "$1" "tcp"
1222 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1223 if type __h2elan >/dev/null 2>&1; then
1226 ID=`echo $1 | sed 's/[^0-9]*//g'`
1234 h2name_or_ip "$1" "openib"
1236 declare -fx h2openib
1239 h2name_or_ip "$1" "o2ib"
1246 [ "$facet" == client ] && echo -n $HOSTNAME && return
1247 varname=${facet}_HOST
1248 if [ -z "${!varname}" ]; then
1249 if [ "${facet:0:3}" == "ost" ]; then
1250 eval ${facet}_HOST=${ost_HOST}
1258 local activevar=${facet}active
1260 if [ -f $TMP/${facet}active ] ; then
1261 source $TMP/${facet}active
1264 active=${!activevar}
1265 if [ -z "$active" ] ; then
1272 facet_active_host() {
1274 local active=`facet_active $facet`
1275 if [ "$facet" == client ]; then
1278 echo `facet_host $active`
1284 failover=${facet}failover
1285 host=`facet_host $failover`
1286 [ -z "$host" ] && return
1287 curactive=`facet_active $facet`
1288 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1289 eval export ${facet}active=$facet
1291 eval export ${facet}active=$failover
1293 # save the active host for this facet
1294 activevar=${facet}active
1295 echo "$activevar=${!activevar}" > $TMP/$activevar
1302 if [ "$HOST" = "$HOSTNAME" ]; then
1304 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1305 echo "cannot run remote command on $HOST with $myPDSH"
1309 echo "CMD: $HOST $@" >&2
1310 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1313 if [ "$myPDSH" = "rsh" ]; then
1314 # we need this because rsh does not return exit code of an executed command
1315 local command_status="$TMP/cs"
1316 rsh $HOST ":> $command_status"
1317 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1318 cd $RPWD; sh -c \"$@\") ||
1319 echo command failed >$command_status"
1320 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1323 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1324 return ${PIPESTATUS[0]}
1327 single_local_node () {
1328 [ "$1" = "$HOSTNAME" ]
1335 if $(single_local_node $rnodes); then
1340 # This is part from do_node
1343 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1344 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1347 echo "CMD: $rnodes $@" >&2
1348 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1351 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1352 return ${PIPESTATUS[0]}
1358 HOST=`facet_active_host $facet`
1359 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1366 # make sure its not already running
1368 rm -f $TMP/${facet}active
1369 do_facet ${facet} $MKFS $*
1375 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1376 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1383 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1384 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1392 # make sure we are using the primary server, so test-framework will
1393 # be able to clean up properly.
1394 activemds=`facet_active mds1`
1395 if [ $activemds != "mds1" ]; then
1399 local clients=$CLIENTS
1400 [ -z $clients ] && clients=$(hostname)
1402 zconf_umount_clients $clients $MOUNT "$*" || true
1403 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1405 [ "$CLIENTONLY" ] && return
1406 # The add fn does rm ${facet}active file, this would be enough
1407 # if we use do_facet <facet> only after the facet added, but
1408 # currently we use do_facet mds in local.sh
1409 for num in `seq $MDSCOUNT`; do
1411 rm -f ${TMP}/mds${num}active
1414 for num in `seq $OSTCOUNT`; do
1416 rm -f $TMP/ost${num}active
1431 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1435 if [ "$IAMDIR" == "yes" ]; then
1436 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1437 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1440 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1442 if [ ! -z $SEC ]; then
1443 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1444 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1445 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1449 # We need ldiskfs here, may as well load them all
1451 [ "$CLIENTONLY" ] && return
1452 echo "Formatting mdts, osts"
1453 for num in `seq $MDSCOUNT`; do
1454 echo "Format mds$num: $(mdsdevname $num)"
1456 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1458 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1462 for num in `seq $OSTCOUNT`; do
1463 echo "Format ost$num: $(ostdevname $num)"
1465 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1467 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1473 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1477 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1481 # 0: success, the old identity set already.
1482 # 1: success, the old identity does not set.
1487 local j=`expr $num - 1`
1488 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1490 if [ -z "$MDT" ]; then
1494 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1497 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1499 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1502 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1504 if [ $old = "NONE" ]; then
1513 zconf_umount `hostname` $1 || error "umount failed"
1514 zconf_mount `hostname` $1 || error "mount failed"
1517 writeconf_facet () {
1521 do_facet $facet "$TUNEFS --writeconf $dev"
1525 for num in `seq $MDSCOUNT`; do
1526 DEVNAME=$(mdsdevname $num)
1527 writeconf_facet mds$num $DEVNAME
1530 for num in `seq $OSTCOUNT`; do
1531 DEVNAME=$(ostdevname $num)
1532 writeconf_facet ost$num $DEVNAME
1537 sanity_mount_check ||
1538 error "environments are insane!"
1542 if [ -z "$CLIENTONLY" ]; then
1543 echo "Setup mdts, osts"
1544 echo $WRITECONF | grep -q "writeconf" && \
1546 for num in `seq $MDSCOUNT`; do
1547 DEVNAME=$(mdsdevname $num)
1548 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1550 # We started mds, now we should set failover variables properly.
1551 # Set mds${num}failover_HOST if it is not set (the default failnode).
1552 local varname=mds${num}failover_HOST
1553 if [ -z "${!varname}" ]; then
1554 eval mds${num}failover_HOST=$(facet_host mds$num)
1557 if [ $IDENTITY_UPCALL != "default" ]; then
1558 switch_identity $num $IDENTITY_UPCALL
1561 for num in `seq $OSTCOUNT`; do
1562 DEVNAME=$(ostdevname $num)
1563 start ost$num $DEVNAME $OST_MOUNT_OPTS
1565 # We started ost$num, now we should set ost${num}failover variable properly.
1566 # Set ost${num}failover_HOST if it is not set (the default failnode).
1567 varname=ost${num}failover_HOST
1568 if [ -z "${!varname}" ]; then
1569 eval ost${num}failover_HOST=$(facet_host ost${num})
1574 # wait a while to allow sptlrpc configuration be propogated to targets,
1575 # only needed when mounting new target devices.
1578 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1580 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1582 if [ "$MOUNT_2" ]; then
1583 mount_client $MOUNT2
1584 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1589 # by remounting mdt before ost, initial connect from mdt to ost might
1590 # timeout because ost is not ready yet. wait some time to its fully
1591 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1592 # by a context negotiation rpc with $TIMEOUT.
1593 # FIXME better by monitoring import status.
1595 sleep $((TIMEOUT + 5))
1601 mounted_lustre_filesystems() {
1602 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1605 init_facet_vars () {
1612 eval export ${facet}_dev=${device}
1613 eval export ${facet}_opt=\"$@\"
1615 local dev=${facet}_dev
1616 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1617 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1619 eval export ${facet}_svc=${label}
1621 local varname=${facet}failover_HOST
1622 if [ -z "${!varname}" ]; then
1623 eval $varname=$(facet_host $facet)
1627 init_facets_vars () {
1630 if ! remote_mds_nodsh; then
1631 for num in `seq $MDSCOUNT`; do
1632 DEVNAME=`mdsdevname $num`
1633 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1637 remote_ost_nodsh && return
1639 for num in `seq $OSTCOUNT`; do
1640 DEVNAME=`ostdevname $num`
1641 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1645 init_param_vars () {
1646 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1647 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1648 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1649 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1653 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1655 log "Using TIMEOUT=$TIMEOUT"
1657 if [ "$ENABLE_QUOTA" ]; then
1658 setup_quota $MOUNT || return 2
1664 local myMGS_host=$mgs_HOST
1665 if [ "$NETTYPE" = "ptl" ]; then
1666 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1669 echo Checking config lustre mounted on $mntpt
1670 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1671 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1673 if [ "$mgshost" != "$myMGS_host" ]; then
1674 FAIL_ON_ERROR=true \
1675 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1676 Please use correct config or set mds_HOST correctly!"
1679 sanity_mount_check ||
1680 error "environments are insane!"
1684 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1685 local cltimeout=$(lctl get_param -n timeout)
1686 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1687 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1692 check_and_setup_lustre() {
1693 local MOUNTED=$(mounted_lustre_filesystems)
1694 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1695 [ "$REFORMAT" ] && formatall
1697 MOUNTED=$(mounted_lustre_filesystems | head -1)
1698 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1699 export I_MOUNTED=yes
1705 if [ "$ONLY" == "setup" ]; then
1710 cleanup_and_setup_lustre() {
1711 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1712 lctl set_param debug=0 || true
1714 if [ "$ONLY" == "cleanup" ]; then
1718 check_and_setup_lustre
1721 check_and_cleanup_lustre() {
1722 if [ "`mount | grep $MOUNT`" ]; then
1723 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1724 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1726 if [ "$I_MOUNTED" = "yes" ]; then
1727 cleanupall -f || error "cleanup failed"
1739 while [ $NETWORK -eq 0 ]; do
1740 ping -c 1 -w 3 $1 > /dev/null
1741 if [ $? -eq 0 ]; then
1745 echo "waiting for $1, $((MAX - WAIT)) secs left"
1748 if [ $WAIT -gt $MAX ]; then
1749 echo "Network not available"
1755 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1766 # the sed converts spaces to commas, but leaves the last space
1767 # alone, so the line doesn't end with a comma.
1768 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1771 # list, excluded are the comma separated lists
1772 exclude_items_from_list () {
1778 for item in ${excluded//,/ }; do
1779 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1781 echo $(comma_list $list)
1784 # list, expand are the comma separated lists
1786 local list=${1//,/ }
1787 local expand=${2//,/ }
1790 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1791 echo $(comma_list $expanded)
1795 (cd `dirname $1`; echo $PWD/`basename $1`)
1799 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1800 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1803 local count=${type}COUNT
1804 for ((i=1; i<=${!count}; i++)) do
1805 list="$list ${name}$i"
1807 echo $(comma_list $list)
1810 ##################################
1811 # Adaptive Timeouts funcs
1814 if [ -z "$AT_MAX_PATH" ]; then
1815 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1816 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1822 at_is_valid || error "invalid call"
1824 # only check mds, we assume at_max is the same on all nodes
1825 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1826 if [ $at_max -eq 0 ]; then
1836 at_is_valid || error "invalid call"
1838 # suppose that all ost-s has the same at_max set
1839 if [ $facet == "ost" ]; then
1840 do_facet ost1 "cat $AT_MAX_PATH"
1842 do_facet $facet "cat $AT_MAX_PATH"
1850 at_is_valid || error "invalid call"
1854 if [ $facet == "ost" ]; then
1855 for i in `seq $OSTCOUNT`; do
1856 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1858 elif [ $facet == "mds" ]; then
1859 for i in `seq $MDSCOUNT`; do
1860 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1863 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1868 ##################################
1872 # OBD_FAIL_MDS_ALL_REQUEST_NET
1874 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1875 do_facet client "$1" || RC=$?
1876 do_facet $SINGLEMDS lctl set_param fail_loc=0
1881 # OBD_FAIL_MDS_ALL_REPLY_NET
1883 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1884 do_facet client "$@" || RC=$?
1885 do_facet $SINGLEMDS lctl set_param fail_loc=0
1889 drop_reint_reply() {
1890 # OBD_FAIL_MDS_REINT_NET_REP
1892 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1893 do_facet client "$@" || RC=$?
1894 do_facet $SINGLEMDS lctl set_param fail_loc=0
1899 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1901 do_facet ost1 lctl set_param fail_loc=0x214
1902 do_facet client "$1" || RC=$?
1903 do_facet client "sync"
1904 do_facet ost1 lctl set_param fail_loc=0
1908 drop_ldlm_cancel() {
1909 #define OBD_FAIL_LDLM_CANCEL 0x304
1911 do_facet client lctl set_param fail_loc=0x304
1912 do_facet client "$@" || RC=$?
1913 do_facet client lctl set_param fail_loc=0
1917 drop_bl_callback() {
1918 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1920 do_facet client lctl set_param fail_loc=0x305
1921 do_facet client "$@" || RC=$?
1922 do_facet client lctl set_param fail_loc=0
1927 #define OBD_FAIL_LDLM_REPLY 0x30c
1929 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1930 do_facet client "$@" || RC=$?
1931 do_facet $SINGLEMDS lctl set_param fail_loc=0
1939 echo "clearing fail_loc on $facet"
1940 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1943 set_nodes_failloc () {
1947 for node in $nodes ; do
1948 do_node $node lctl set_param fail_loc=$2
1952 cancel_lru_locks() {
1953 $LCTL mark "cancel_lru_locks $1 start"
1954 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1955 $LCTL set_param -n $d=clear
1957 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1958 $LCTL mark "cancel_lru_locks $1 stop"
1963 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1964 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1965 echo "$DEFAULT_LRU_SIZE"
1970 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1973 lru_resize_disable()
1975 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1980 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1981 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1982 echo there is still data in page cache $FILE ?
1983 lctl get_param -n $FILE
1991 DEBUGSAVE="$(lctl get_param -n debug)"
1995 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1999 ##################################
2001 ##################################
2004 local TYPE=${TYPE:-"FAIL"}
2006 lctl set_param fail_loc=0 2>/dev/null || true
2007 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2008 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2009 echo "Dumping lctl log to $ERRLOG"
2010 # We need to dump the logs on all nodes
2011 local NODES=$(nodes_list)
2012 for NODE in $NODES; do
2013 do_node $NODE $LCTL dk $ERRLOG
2016 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2022 $FAIL_ON_ERROR && exit 1 || true
2030 # use only if we are ignoring failures for this test, bugno required.
2031 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2032 # e.g. error_ignore 5494 "your message"
2034 local TYPE="IGNORE (bz$1)"
2040 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2041 [ "$TESTSUITELOG" ] && \
2042 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2045 build_test_filter() {
2046 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2050 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2051 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2052 [ "$EXCEPT_SLOW" ] && \
2053 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2054 for E in $EXCEPT $ALWAYS_EXCEPT; do
2055 eval EXCEPT_${E}=true
2057 for E in $EXCEPT_SLOW; do
2058 eval EXCEPT_SLOW_${E}=true
2060 for G in $GRANT_CHECK_LIST; do
2061 eval GCHECK_ONLY_${G}=true
2070 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
2073 # print a newline if the last test was skipped
2074 export LAST_SKIPPED=
2078 export base=`basetest $1`
2079 if [ ! -z "$ONLY" ]; then
2081 if [ ${!testname}x != x ]; then
2082 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2087 if [ ${!testname}x != x ]; then
2088 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2097 if [ ${!testname}x != x ]; then
2099 TESTNAME=test_$1 skip "skipping excluded test $1"
2102 testname=EXCEPT_$base
2103 if [ ${!testname}x != x ]; then
2105 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2108 testname=EXCEPT_SLOW_$1
2109 if [ ${!testname}x != x ]; then
2111 TESTNAME=test_$1 skip "skipping SLOW test $1"
2114 testname=EXCEPT_SLOW_$base
2115 if [ ${!testname}x != x ]; then
2117 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2127 EQUALS="======================================================================"
2131 local suffixlen=$((${#EQUALS} - ${#msg}))
2132 [ $suffixlen -lt 5 ] && suffixlen=5
2133 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2138 lsmod | grep lnet > /dev/null || load_modules
2150 local NODES=$(nodes_list)
2151 for NODE in $NODES; do
2152 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
2158 strace -o $TMP/$1.strace -ttt $*
2160 log "FINISHED: $*: rc $RC"
2165 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2170 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2171 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2172 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2176 local myNODES=$(nodes_list)
2179 for NODE in $myNODES; do
2180 do_node $NODE "lctl set_param fail_loc=0 2>/dev/null || true"
2188 export tdir=d0.${TESTSUITE}/d${base}
2190 local SAVE_UMASK=`umask`
2193 local BEFORE=`date +%s`
2194 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2196 export TESTNAME=test_$testnum
2198 test_${testnum} || error "test_$testnum failed with $?"
2202 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2203 check_catastrophe || error "LBUG/LASSERT detected"
2204 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2205 pass "($((`date +%s` - $BEFORE))s)"
2213 (cd `dirname $1`; echo $PWD/`basename $1`)
2217 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2218 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2223 export base=`basetest $1`
2224 [ "$CHECK_GRANT" == "no" ] && return 0
2226 testname=GCHECK_ONLY_${base}
2227 [ ${!testname}x == x ] && return 0
2229 echo -n "checking grant......"
2231 # write some data to sync client lost_grant
2232 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2233 for i in `seq $OSTCOUNT`; do
2234 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2235 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2236 count=1 > /dev/null 2>&1
2238 # sync all the data and make sure no pending data on server
2241 #get client grant and server grant
2243 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2244 client_grant=$((client_grant + $d))
2247 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2248 server_grant=$((server_grant + $d))
2251 # cleanup the check_grant file
2252 for i in `seq $OSTCOUNT`; do
2253 rm $DIR1/${tfile}_check_grant_$i
2256 #check whether client grant == server grant
2257 if [ $client_grant != $server_grant ]; then
2258 echo "failed: client:${client_grant} server: ${server_grant}"
2265 ########################
2271 ost=`echo $1 | awk -F_ '{print $3}'`
2272 if [ -z $ost ]; then
2273 ost=`echo $1 | sed 's/-osc.*//'`
2280 [ "$node" != "$(hostname)" ]
2286 for node in $(mdts_nodes); do
2287 remote_node $node && return 0
2294 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2300 for node in $(osts_nodes) ; do
2301 remote_node $node && return 0
2308 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2314 MGS=$(facet_host mgs)
2315 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2321 for num in `seq $MDSCOUNT`; do
2322 MDSNODES="$MDSNODES $(facet_host mds$num)"
2324 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2330 remote_ost && remote_mds
2334 local OSTNODES=$(facet_host ost1)
2337 for num in `seq $OSTCOUNT`; do
2338 local myOST=$(facet_host ost$num)
2339 OSTNODES="$OSTNODES $myOST"
2341 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2347 # FIXME. We need a list of clients
2348 local myNODES=$HOSTNAME
2351 # CLIENTS (if specified) contains the local client
2352 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2354 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2355 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2358 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2363 remote_nodes_list () {
2364 local rnodes=$(nodes_list)
2365 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2369 init_clients_lists () {
2370 # Sanity check: exclude the local client from RCLIENTS
2371 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2373 # Sanity check: exclude the dup entries
2374 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2376 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2378 # Sanity check: exclude the dup entries from CLIENTS
2379 # for those configs which has SINGLCLIENT set to local client
2380 clients=$(for i in $clients; do echo $i; done | sort -u)
2382 CLIENTS=`comma_list $clients`
2383 local -a remoteclients=($rclients)
2384 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2385 varname=CLIENT$((i + 2))
2386 eval $varname=${remoteclients[i]}
2389 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2392 get_random_entry () {
2395 rnodes=${rnodes//,/ }
2397 local -a nodes=($rnodes)
2398 local num=${#nodes[@]}
2399 local i=$((RANDOM * num * 2 / 65536))
2406 lctl get_param version | grep -q patchless
2410 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2415 echo $nodes | wc -w || true
2419 local nodes=$(osts_nodes)
2420 local osscount=$(get_node_count "$nodes")
2421 [ ! "$OSTCOUNT" = "$osscount" ]
2425 local nodes=$(mdts_nodes)
2426 local mdtcount=$(get_node_count "$nodes")
2427 [ ! "$MDSCOUNT" = "$mdtcount" ]
2430 generate_machine_file() {
2431 local nodes=${1//,/ }
2432 local machinefile=$2
2433 rm -f $machinefile || error "can't rm $machinefile"
2434 for node in $nodes; do
2435 echo $node >>$machinefile
2440 local file=$1/stripe
2442 $LFS getstripe -v $file || error
2446 check_runas_id_ret() {
2448 local myRUNAS_UID=$1
2449 local myRUNAS_GID=$2
2452 if [ -z "$myRUNAS" ]; then
2453 error_exit "myRUNAS command must be specified for check_runas_id"
2456 $myRUNAS krb5_login.sh || \
2457 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2459 mkdir $DIR/d0_runas_test
2461 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2462 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2463 rm -rf $DIR/d0_runas_test
2468 local myRUNAS_UID=$1
2469 local myRUNAS_GID=$2
2472 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2473 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2474 Please set RUNAS_ID to some UID which exists on MDS and client or
2475 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2478 # Run multiop in the background, but wait for it to print
2479 # "PAUSING" to its stdout before returning from this function.
2480 multiop_bg_pause() {
2481 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2485 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2488 echo "$MULTIOP_PROG $FILE v$ARGS"
2489 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2491 echo "TMPPIPE=${TMPPIPE}"
2492 read -t 60 multiop_output < $TMPPIPE
2493 if [ $? -ne 0 ]; then
2498 if [ "$multiop_output" != "PAUSING" ]; then
2499 echo "Incorrect multiop output: $multiop_output"
2507 inodes_available () {
2508 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2512 # reset llite stat counters
2513 clear_llite_stats(){
2514 lctl set_param -n llite.*.stats 0
2517 # sum llite stat items
2518 calc_llite_stats() {
2519 local res=$(lctl get_param -n llite.*.stats |
2520 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2524 # reset osc stat counters
2526 lctl set_param -n osc.*.osc_stats 0
2529 # sum osc stat items
2531 local res=$(lctl get_param -n osc.*.osc_stats |
2532 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2537 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2540 calc_osc_kbytes () {
2541 df $MOUNT > /dev/null
2542 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2545 # save_lustre_params(node, parameter_mask)
2546 # generate a stream of formatted strings (<node> <param name>=<param value>)
2547 save_lustre_params() {
2549 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2552 # restore lustre parameters from input stream, produces by save_lustre_params
2553 restore_lustre_params() {
2557 while IFS=" =" read node name val; do
2558 do_node $node "lctl set_param -n $name $val"
2562 check_catastrophe () {
2563 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2565 [ -f $CATASTROPHE ] && [ $(cat $CATASTROPHE) -ne 0 ] && return 1
2566 if [ $rnodes ]; then
2567 do_nodes $rnodes "set -x; [ -f $CATASTROPHE ] && { [ \`cat $CATASTROPHE\` -eq 0 ] || false; } || true"
2582 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2584 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2585 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2586 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2590 # CMD: determine mds index where directory inode presents
2593 local file=$dir/f0.get_mds_dir_tmpfile
2596 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2597 local oldused=($iused)
2601 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2602 local newused=($iused)
2605 for ((i=0; i<${#newused[@]}; i++)); do
2606 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2612 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2616 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2617 local command="$mpirun $@"
2618 local mpilog=$TMP/mpi.log
2621 if [ "$MPI_USER" != root -a $mpirun ]; then
2622 echo "+ chmod 0777 $MOUNT"
2624 command="su $MPI_USER sh -c \"$command \""
2629 eval $command 2>&1 > $mpilog || true
2632 if [ $rc -eq 0 ] && grep -q "p4_error: : [^0]" $mpilog ; then
2639 mdsrate_cleanup () {
2640 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2643 delayed_recovery_enabled () {
2644 local var=${SINGLEMDS}_svc
2645 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1