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}
14 #export PDSH="pdsh -S -Rssh -w"
16 # function used by scripts run on remote nodes
17 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
18 . $LUSTRE/tests/functions.sh
22 [[ $DIR/ = $MOUNT/* ]] || \
23 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
24 [[ $DIR1/ = $MOUNT1/* ]] || \
25 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
26 [[ $DIR2/ = $MOUNT2/* ]] || \
27 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
29 [ -n "$failed" ] && exit 99 || true
33 echo "usage: $0 [-r] [-f cfgfile]"
41 [ "$TESTSUITE" == "lfscktest" ] && return 0
42 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
43 local form="%-13s %-17s %s\n"
44 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
45 echo "------------------------------------------------------------------------------------"
46 for O in $TESTSUITE_LIST; do
49 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
52 local log=${TMP}/${o}.log
53 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
54 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
55 [ "${!O}" = "done" ] && \
56 printf "$form" "Done" "$O" "E=$skipped" && \
57 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
61 for O in $TESTSUITE_LIST; do
62 if [ "${!O}" = "no" ]; then
64 # only for those tests suits which are run directly from acc-sm script:
65 # bonnie, iozone, etc.
66 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
67 printf "$form" "UNFINISHED" "$O" ""
69 printf "$form" "Skipped" "$O" ""
74 for O in $TESTSUITE_LIST; do
75 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
76 printf "$form" "UNFINISHED" "$O" ""
81 export LUSTRE=`absolute_path $LUSTRE`
82 export TESTSUITE=`basename $0 .sh`
83 export TEST_FAILED=false
84 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
86 export MKE2FS=${MKE2FS:-mke2fs}
87 export DEBUGFS=${DEBUGFS:-debugfs}
88 export TUNE2FS=${TUNE2FS:-tune2fs}
89 export E2LABEL=${E2LABEL:-e2label}
90 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
91 export E2FSCK=${E2FSCK:-e2fsck}
93 #[ -d /r ] && export ROOT=${ROOT:-/r}
94 export TMP=${TMP:-$ROOT/tmp}
95 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
96 export HOSTNAME=${HOSTNAME:-`hostname`}
97 if ! echo $PATH | grep -q $LUSTRE/utils; then
98 export PATH=$PATH:$LUSTRE/utils
100 if ! echo $PATH | grep -q $LUSTRE/test; then
101 export PATH=$PATH:$LUSTRE/tests
103 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
104 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
105 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
106 export PATH=$PATH:$LUSTRE/tests/racer
108 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
109 export PATH=$PATH:$LUSTRE/tests/mpi
111 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
112 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
113 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
114 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
115 [ ! -f "$LFS" ] && export LFS=$(which lfs)
116 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
117 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
118 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
119 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
120 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
121 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
122 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
123 export FSTYPE=${FSTYPE:-"ldiskfs"}
124 export NAME=${NAME:-local}
126 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
128 if [ "$ACCEPTOR_PORT" ]; then
129 export PORT_OPT="--port $ACCEPTOR_PORT"
132 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
134 # Paths on remote nodes, if different
135 export RLUSTRE=${RLUSTRE:-$LUSTRE}
136 export RPWD=${RPWD:-$PWD}
137 export I_MOUNTED=${I_MOUNTED:-"no"}
138 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
139 ! -f `dirname $0`/../mds/mds.ko ]; then
140 export CLIENTMODSONLY=yes
145 while getopts "rvwf:" opt $*; do
148 r) REFORMAT=--reformat;;
150 w) WRITECONF=writeconf;;
155 shift $((OPTIND - 1))
158 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
163 *) EXT=".ko"; USE_QUOTA=yes;;
169 BASE=`basename $module $EXT`
170 lsmod | grep -q ${BASE} || \
171 if [ -f ${LUSTRE}/${module}${EXT} ]; then
172 insmod ${LUSTRE}/${module}${EXT} $@
174 # must be testing a "make install" or "rpm" installation
179 load_modules_local() {
180 if [ -n "$MODPROBE" ]; then
184 if [ "$HAVE_MODULES" = true ]; then
190 echo Loading modules from $LUSTRE
191 load_module ../lnet/libcfs/libcfs
192 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
193 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
195 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
196 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
197 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
198 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
199 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
201 # disable it for now since it only hides the stack overflow upon test w/
203 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
204 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
205 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
207 echo "lnet options: '$LNETOPTS'"
208 # note that insmod will ignore anything in modprobe.conf
209 load_module ../lnet/lnet/lnet $LNETOPTS
210 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
211 load_module ../lnet/klnds/$LNETLND
212 load_module lvfs/lvfs
213 load_module obdclass/obdclass
214 load_module ptlrpc/ptlrpc
215 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
220 if ! client_only; then
223 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
224 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
225 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
226 load_module lvfs/fsfilt_$FSTYPE
228 load_module obdfilter/obdfilter
231 load_module llite/lustre
232 load_module llite/llite_lloop
233 rm -f $TMP/ogdb-$HOSTNAME
235 [ -d /r ] && OGDB="/r/tmp"
236 $LCTL modules > $OGDB/ogdb-$HOSTNAME
237 # 'mount' doesn't look in $PATH, just sbin
238 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
244 # load modules on remote nodes optionally
245 # lustre-tests have to be installed on these nodes
246 if $LOAD_MODULES_REMOTE ; then
247 local list=$(comma_list $(remote_nodes_list))
248 echo loading modules on $list
249 do_rpc_nodes $list load_modules
254 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
255 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
256 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
257 echo "$LEAK_LUSTRE" 1>&2
258 echo "$LEAK_PORTALS" 1>&2
259 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
260 echo "Memory leaks detected"
261 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
267 wait_exit_ST client # bug 12845
269 if $LOAD_MODULES_REMOTE ; then
270 local list=$(comma_list $(remote_nodes_list))
271 echo unloading modules on $list
272 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
273 do_rpc_nodes $list check_mem_leak
276 $LUSTRE_RMMOD $FSTYPE || return 2
280 check_mem_leak || return 254
282 echo "modules unloaded."
290 local dev=$(facet_active $facet)_dev
291 local opt=${facet}_opt
292 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
293 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
295 if [ $RC -ne 0 ]; then
296 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
297 echo "Start of ${!dev} on ${facet} failed ${RC}"
299 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
300 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
301 lctl set_param debug_mb=${DEBUG_SIZE}; \
304 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
305 [ -z "$label" ] && echo no label for ${!dev} && exit 1
306 eval export ${facet}_svc=${label}
307 echo Started ${label}
312 # start facet device options
318 eval export ${facet}_dev=${device}
319 eval export ${facet}_opt=\"$@\"
321 local varname=${facet}failover_dev
322 if [ -n "${!varname}" ] ; then
323 eval export ${facet}failover_dev=${!varname}
325 eval export ${facet}failover_dev=$device
328 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
338 HOST=`facet_active_host $facet`
339 [ -z $HOST ] && echo stop: no host for $facet && return 0
341 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
342 if [ ${running} -ne 0 ]; then
343 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
344 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
347 # umount should block, but we should wait for unrelated obd's
348 # like the MGS or MGC to also stop.
350 wait_exit_ST ${facet}
353 # set quota version (both administrative and operational quotas)
354 quota_set_version() {
355 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
356 for j in `seq $OSTCOUNT`; do
357 do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=$1"
361 # save quota version (both administrative and operational quotas)
362 # the function will also switch to the new version and the new type
363 quota_save_version() {
365 local ver=$(tr -c -d "123" <<< $spec)
366 local type=$(tr -c -d "ug" <<< $spec)
368 $LFS quotaoff -ug $MOUNT # just in case
369 [ -n "$ver" ] && quota_set_version $ver
370 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
372 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdt.quota_type=$spec"
374 local osts=$(get_facets OST)
375 for ost in ${osts//,/ }; do
377 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
381 # client could mount several lustre
383 local fsname=${1:-$FSNAME}
385 do_facet mgs lctl get_param mds.${fsname}-MDT*.quota_type || rc=$?
386 do_nodes $(comma_list $(osts_nodes)) \
387 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
391 restore_quota_type () {
392 local mntpt=${1:-$MOUNT}
393 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
394 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
397 quota_save_version $old_QUOTA_TYPE
404 # 1. run quotacheck only if quota is off
405 # 2. save the original quota_type params, restore them after testing
407 # Suppose that quota type the same on mds and ost
408 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
409 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
410 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
411 export old_QUOTA_TYPE=$quota_type
412 quota_save_version $QUOTA_TYPE
415 local quota_usrs=$QUOTA_USERS
417 # get_filesystem_size
418 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
419 local blk_soft=$((disksz + 1024))
420 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
422 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
424 local i_hard=$((i_soft + i_soft / 20))
426 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
427 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
430 for usr in $quota_usrs; do
431 echo "Setting up quota on $client:$mntpt for $usr..."
433 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
435 eval $cmd || error "$cmd FAILED!"
437 # display the quota status
438 echo "Quota settings for $usr : "
439 $LFS quota -v -u $usr $mntpt || true
447 # Only supply -o to mount if we have options
448 if [ -n "$MOUNTOPT" ]; then
449 OPTIONS="-o $MOUNTOPT"
451 local device=$MGSNID:/$FSNAME
452 if [ -z "$mnt" -o -z "$FSNAME" ]; then
453 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
457 echo "Starting client: $client: $OPTIONS $device $mnt"
458 do_node $client mkdir -p $mnt
459 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
460 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
461 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
462 lctl set_param debug_mb=${DEBUG_SIZE}"
475 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
476 if [ $running -ne 0 ]; then
477 echo "Stopping client $client $mnt (opts:$force)"
478 do_node $client lsof -t $mnt || need_kill=no
479 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
480 pids=$(do_node $client lsof -t $mnt | sort -u);
481 if [ -n $pids ]; then
482 do_node $client kill -9 $pids || true
486 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
487 if [ $busy -ne 0 ] ; then
488 echo "$mnt is still busy, wait one second" && sleep 1
489 do_node $client umount $force $mnt
494 # nodes is comma list
495 sanity_mount_check_nodes () {
501 # FIXME: assume that all cluster nodes run the same os
502 [ "$(uname)" = Linux ] || return 0
505 for mnt in $mnts ; do
506 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
507 mpts=\\\$(mount | grep -w -c $mnt);
508 if [ \\\$running -ne \\\$mpts ]; then
509 echo \\\$(hostname) env are INSANE!;
517 sanity_mount_check_servers () {
519 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
520 echo Checking servers environments
522 # FIXME: modify get_facets to display all facets wo params
523 local facets="$(get_facets OST),$(get_facets MDS),mgs"
527 for facet in ${facets//,/ }; do
528 node=$(facet_host ${facet})
529 mnt=${MOUNT%/*}/${facet}
530 sanity_mount_check_nodes $node $mnt ||
531 { error "server $node environments are insane!"; return 1; }
535 sanity_mount_check_clients () {
536 local clients=${1:-$CLIENTS}
537 local mntpt=${2:-$MOUNT}
538 local mntpt2=${3:-$MOUNT2}
540 [ -z $clients ] && clients=$(hostname)
541 echo Checking clients $clients environments
543 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
544 error "clients environments are insane!"
547 sanity_mount_check () {
548 sanity_mount_check_servers || return 1
549 sanity_mount_check_clients || return 2
552 # mount clients if not mouted
553 zconf_mount_clients() {
558 # Only supply -o to mount if we have options
559 if [ -n "$MOUNTOPT" ]; then
560 OPTIONS="-o $MOUNTOPT"
562 local device=$MGSNID:/$FSNAME
563 if [ -z "$mnt" -o -z "$FSNAME" ]; then
564 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
568 echo "Starting client $clients: $OPTIONS $device $mnt"
571 running=\\\$(mount | grep -c $mnt' ');
573 if [ \\\$running -eq 0 ] ; then
575 mount -t lustre $OPTIONS $device $mnt;
580 echo "Started clients $clients: "
581 do_nodes $clients "mount | grep -w $mnt"
583 do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
584 sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
585 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
590 zconf_umount_clients() {
597 echo "Stopping clients: $clients $mnt (opts:$force)"
598 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
599 if [ \\\$running -ne 0 ] ; then
600 echo Stopping client \\\$(hostname) client $mnt opts:$force;
601 lsof -t $mnt || need_kill=no;
602 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
603 pids=\\\$(lsof -t $mnt | sort -u);
604 if [ -n \\\"\\\$pids\\\" ]; then
608 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
609 if [ \\\$busy -ne 0 ] ; then
610 echo "$mnt is still busy, wait one second" && sleep 1;
616 shudown_node_hard () {
620 for i in $(seq $attempts) ; do
623 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
624 echo "waiting for $host to fail attempts=$attempts"
625 [ $i -lt $attempts ] || \
626 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
632 local mnt=${2:-$MOUNT}
635 if [ "$FAILURE_MODE" = HARD ]; then
636 shudown_node_hard $client
638 zconf_umount_clients $client $mnt -f
644 if [ "$FAILURE_MODE" = HARD ]; then
645 shudown_node_hard $(facet_active_host $facet)
646 elif [ "$FAILURE_MODE" = SOFT ]; then
653 if [ "$FAILURE_MODE" = HARD ]; then
654 $POWER_UP `facet_active_host $facet`
662 if [ "$FAILURE_MODE" = HARD ]; then
668 # recovery-scale functions
669 check_progs_installed () {
674 do_nodes $clients "PATH=:$PATH; status=true;
675 for prog in $progs; do
676 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
677 echo \\\$prog missing on \\\$(hostname);
685 echo __$(echo $1 | tr '-' 'X')
688 start_client_load() {
691 local var=$(client_var_name $client)_load
692 eval export ${var}=$load
694 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
695 BREAK_ON_ERROR=$BREAK_ON_ERROR \
696 END_RUN_FILE=$END_RUN_FILE \
697 LOAD_PID_FILE=$LOAD_PID_FILE \
698 TESTSUITELOG=$TESTSUITELOG \
700 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
701 log "Started client load: ${load} on $client"
706 start_client_loads () {
707 local -a clients=(${1//,/ })
708 local numloads=${#CLIENT_LOADS[@]}
711 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
712 testnum=$((nodenum % numloads))
713 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
717 # only for remote client
718 check_client_load () {
720 local var=$(client_var_name $client)_load
721 local TESTLOAD=run_${!var}.sh
723 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
725 # bug 18914: try to connect several times not only when
726 # check ps, but while check_catastrophe also
729 while [ $RC = 254 -a $tries -gt 0 ]; do
733 if ! check_catastrophe $client; then
735 if [ $RC -eq 254 ]; then
736 # FIXME: not sure how long we shuold sleep here
740 echo "check catastrophe failed: RC=$RC "
745 # We can continue try to connect if RC=254
746 # Just print the warning about this
747 if [ $RC = 254 ]; then
748 echo "got a return status of $RC from do_node while checking catastrophe on $client"
751 # see if the load is still on the client
754 while [ $RC = 254 -a $tries -gt 0 ]; do
758 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
763 if [ $RC = 254 ]; then
764 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
765 # see if we can diagnose a bit why this is
770 check_client_loads () {
771 local clients=${1//,/ }
775 for client in $clients; do
776 check_client_load $client
778 if [ "$rc" != 0 ]; then
779 log "Client load failed on node $client, rc=$rc"
785 restart_client_loads () {
786 local clients=${1//,/ }
787 local expectedfail=${2:-""}
791 for client in $clients; do
792 check_client_load $client
794 if [ "$rc" != 0 -a "$expectedfail" ]; then
795 local var=$(client_var_name $client)_load
796 start_client_load $client ${!var}
797 echo "Restarted client load ${!var}: on $client. Checking ..."
798 check_client_load $client
800 if [ "$rc" != 0 ]; then
801 log "Client load failed to restart on node $client, rc=$rc"
802 # failure one client load means test fail
803 # we do not need to check other
811 # End recovery-scale functions
813 # verify that lustre actually cleaned up properly
815 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
816 error "LBUG/LASSERT detected"
817 BUSY=`dmesg | grep -i destruct || true`
820 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
824 check_mem_leak || exit 204
826 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
827 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
829 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
830 echo "$0: modules still loaded..." 1>&2
847 RESULT=$(do_node $node "$TEST")
848 if [ "$RESULT" == "$FINAL" ]; then
849 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
852 [ $WAIT -ge $MAX ] && break
853 echo "Waiting $((MAX - WAIT)) secs for update"
854 WAIT=$((WAIT + sleep))
857 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
861 wait_update_facet () {
864 wait_update $(facet_active_host $facet) "$@"
867 wait_delete_completed () {
868 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
869 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
873 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
875 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
876 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
877 [ "$TOTAL" -eq "$TOTALPREV" ] && break
878 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
882 echo "Delete completed."
887 check_network "$host" 900
888 while ! do_node $host hostname > /dev/null; do sleep 5; done
893 local host=`facet_active_host $facet`
897 wait_recovery_complete () {
900 # Use default policy if $2 is not passed by caller.
901 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
902 # as we are in process of changing obd_timeout in different ways
903 # let's set MAX longer than that
904 local MAX=${2:-$(( TIMEOUT * 4 ))}
906 local var_svc=${facet}_svc
907 local procfile="*.${!var_svc}.recovery_status"
911 while [ $WAIT -lt $MAX ]; do
912 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
913 [[ $STATUS = "status: COMPLETE" ]] && return 0
916 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
918 echo "$facet recovery not done in $MAX sec. $STATUS"
928 # conf-sanity 31 takes a long time cleanup
929 while [ $WAIT -lt 300 ]; do
930 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
931 [ -z "${running}" ] && return 0
932 echo "waited $WAIT for${running}"
933 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
935 WAIT=$((WAIT + INTERVAL))
937 echo "service didn't stop after $WAIT seconds. Still running:"
942 wait_remote_prog () {
948 [ "$PDSH" = "no_dsh" ] && return 0
950 while [ $WAIT -lt $2 ]; do
951 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
952 [ -z "${running}" ] && return 0 || true
953 echo "waited $WAIT for: "
955 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
957 WAIT=$((WAIT + INTERVAL))
959 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
960 [ -z "$pids" ] && return 0
961 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
962 # FIXME: not portable
964 cat /proc/${pid}/status || true
965 cat /proc/${pid}/wchan || true
976 # not every config has many clients
977 if [ -n "$CLIENTS" ]; then
978 $PDSH $CLIENTS "df $MOUNT" > /dev/null
980 df $MOUNT > /dev/null
985 uname -n >> $MOUNT/recon
986 if [ -z "$CLIENTS" ]; then
987 df $MOUNT; uname -n >> $MOUNT/recon
989 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
991 echo Connected clients:
993 ls -l $MOUNT/recon > /dev/null
1000 echo "Failing $facet on node `facet_active_host $facet`"
1001 shutdown_facet $facet
1002 [ -n "$sleep_time" ] && sleep $sleep_time
1006 RECOVERY_START_TIME=`date +%s`
1007 echo "df pid is $DFPID"
1008 change_active $facet
1009 local TO=`facet_active_host $facet`
1010 echo "Failover $facet to $TO"
1012 mount_facet $facet || error "Restart of $facet failed"
1021 do_facet $facet sync
1023 local svc=${facet}_svc
1024 do_facet $facet $LCTL --device %${!svc} notransno
1025 do_facet $facet $LCTL --device %${!svc} readonly
1026 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1027 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1030 replay_barrier_nodf() {
1031 local facet=$1 echo running=${running}
1032 do_facet $facet sync
1033 local svc=${facet}_svc
1034 echo Replay barrier on ${!svc}
1035 do_facet $facet $LCTL --device %${!svc} notransno
1036 do_facet $facet $LCTL --device %${!svc} readonly
1037 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1038 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1041 mds_evict_client() {
1042 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1043 local mdtdevice=$(get_mds_mdt_device_proc_path)
1044 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1047 ost_evict_client() {
1048 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1049 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1053 facet_failover $* || error "failover: $?"
1054 df $MOUNT || error "post-failover df: $?"
1059 facet_failover $facet
1065 change_active $facet
1066 mount_facet $facet -o abort_recovery
1067 df $MOUNT || echo "first df failed: $?"
1069 df $MOUNT || error "post-failover df: $?"
1073 echo There is no lmc. This is mountconf, baby.
1078 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1079 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1085 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1091 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1092 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1093 if [ -z "$ID" ]; then
1094 echo "Could not get a ptl id for $1..."
1103 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1110 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1111 if type __h2elan >/dev/null 2>&1; then
1114 ID=`echo $1 | sed 's/[^0-9]*//g'`
1122 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1123 ID=`echo $1 | sed 's/[^0-9]*//g'`
1127 declare -fx h2openib
1130 h2name_or_ip "$1" "o2ib"
1137 [ "$facet" == client ] && echo -n $HOSTNAME && return
1138 varname=${facet}_HOST
1139 if [ -z "${!varname}" ]; then
1140 if [ "${facet:0:3}" == "ost" ]; then
1141 eval ${facet}_HOST=${ost_HOST}
1149 local activevar=${facet}active
1151 if [ -f $TMP/${facet}active ] ; then
1152 source $TMP/${facet}active
1155 active=${!activevar}
1156 if [ -z "$active" ] ; then
1163 facet_active_host() {
1165 local active=`facet_active $facet`
1166 if [ "$facet" == client ]; then
1169 echo `facet_host $active`
1175 local failover=${facet}failover
1176 host=`facet_host $failover`
1177 [ -z "$host" ] && return
1178 local curactive=`facet_active $facet`
1179 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1180 eval export ${facet}active=$facet
1182 eval export ${facet}active=$failover
1184 # save the active host for this facet
1185 local activevar=${facet}active
1186 echo "$activevar=${!activevar}" > $TMP/$activevar
1191 # do not stripe off hostname if verbose, bug 19215
1192 if [ x$1 = x--verbose ]; then
1200 if [ "$HOST" = "$HOSTNAME" ]; then
1202 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1203 echo "cannot run remote command on $HOST with $myPDSH"
1207 echo "CMD: $HOST $@" >&2
1208 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1211 if [ "$myPDSH" = "rsh" ]; then
1212 # we need this because rsh does not return exit code of an executed command
1213 local command_status="$TMP/cs"
1214 rsh $HOST ":> $command_status"
1215 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1216 cd $RPWD; sh -c \"$@\") ||
1217 echo command failed >$command_status"
1218 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1223 # print HOSTNAME for myPDSH="no_dsh"
1224 if [[ $myPDSH = no_dsh ]]; then
1225 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1227 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1230 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1232 return ${PIPESTATUS[0]}
1235 single_local_node () {
1236 [ "$1" = "$HOSTNAME" ]
1241 # do not stripe off hostname if verbose, bug 19215
1242 if [ x$1 = x--verbose ]; then
1250 if $(single_local_node $rnodes); then
1252 do_node --verbose $rnodes $@
1259 # This is part from do_node
1262 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1263 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1266 echo "CMD: $rnodes $@" >&2
1267 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1271 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1273 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1275 return ${PIPESTATUS[0]}
1281 local HOST=`facet_active_host $facet`
1282 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1289 # make sure its not already running
1291 rm -f $TMP/${facet}active
1292 do_facet ${facet} $MKFS $*
1298 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1299 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1307 # make sure we are using the primary server, so test-framework will
1308 # be able to clean up properly.
1309 activemds=`facet_active mds`
1310 if [ $activemds != "mds" ]; then
1314 local clients=$CLIENTS
1315 [ -z $clients ] && clients=$(hostname)
1317 zconf_umount_clients $clients $MOUNT "$*" || true
1318 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1320 [ "$CLIENTONLY" ] && return
1321 # The add fn does rm ${facet}active file, this would be enough
1322 # if we use do_facet <facet> only after the facet added, but
1323 # currently we use do_facet mds in local.sh
1325 rm -f ${TMP}/mdsactive
1326 for num in `seq $OSTCOUNT`; do
1328 rm -f $TMP/ost${num}active
1330 if [[ $MDSDEV != $MGSDEV ]]; then
1338 nfs_client_mode && return
1345 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1348 # We need ldiskfs here, may as well load them all
1350 [ "$CLIENTONLY" ] && return
1351 echo Formatting mgs, mds, osts
1352 if [[ $MDSDEV != $MGSDEV ]] || [[ $mds_HOST != $mgs_HOST ]]; then
1353 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1357 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
1359 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1362 for num in `seq $OSTCOUNT`; do
1364 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1366 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1372 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1377 zconf_umount `hostname` $1 || error "umount failed"
1378 zconf_mount `hostname` $1 || error "mount failed"
1381 writeconf_facet () {
1385 do_facet $facet "$TUNEFS --writeconf $dev"
1389 writeconf_facet mds $MDSDEV
1391 for num in `seq $OSTCOUNT`; do
1392 DEVNAME=`ostdevname $num`
1393 writeconf_facet ost$num $DEVNAME
1398 nfs_client_mode && return
1400 sanity_mount_check ||
1401 error "environments are insane!"
1404 if [ -z "$CLIENTONLY" ]; then
1405 echo Setup mgs, mdt, osts
1407 echo $WRITECONF | grep -q "writeconf" && \
1410 if [[ $mds_HOST != $mgs_HOST ]] || [[ $MDSDEV != $MGSDEV ]]; then
1411 start mgs $MGSDEV $mgs_MOUNT_OPTS
1414 start mds $MDSDEV $MDS_MOUNT_OPTS
1415 # We started mds, now we should set failover variable properly.
1416 # Set mdsfailover_HOST if it is not set (the default failnode).
1417 if [ -z "$mdsfailover_HOST" ]; then
1418 mdsfailover_HOST=$(facet_host mds)
1421 for num in `seq $OSTCOUNT`; do
1422 DEVNAME=`ostdevname $num`
1423 start ost$num $DEVNAME $OST_MOUNT_OPTS
1425 # We started ost$num, now we should set ost${num}failover variable properly.
1426 # Set ost${num}failover_HOST if it is not set (the default failnode).
1427 varname=ost${num}failover_HOST
1428 if [ -z "${!varname}" ]; then
1429 eval ost${num}failover_HOST=$(facet_host ost${num})
1434 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1436 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1438 if [ "$MOUNT_2" ]; then
1439 mount_client $MOUNT2
1440 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1446 mounted_lustre_filesystems() {
1447 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1450 init_facet_vars () {
1451 [ "$CLIENTONLY" ] && return 0
1458 eval export ${facet}_dev=${device}
1459 eval export ${facet}_opt=\"$@\"
1461 local dev=${facet}_dev
1462 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1463 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1465 eval export ${facet}_svc=${label}
1467 local varname=${facet}failover_HOST
1468 if [ -z "${!varname}" ]; then
1469 eval $varname=$(facet_host $facet)
1472 # ${facet}failover_dev is set in cfg file
1473 varname=${facet}failover_dev
1474 if [ -n "${!varname}" ] ; then
1475 eval export ${facet}failover_dev=${!varname}
1477 eval export ${facet}failover_dev=$device
1481 init_facets_vars () {
1483 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1485 remote_ost_nodsh && return
1487 for num in `seq $OSTCOUNT`; do
1488 DEVNAME=`ostdevname $num`
1489 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1493 init_param_vars () {
1494 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1495 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1496 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1497 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1501 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1503 log "Using TIMEOUT=$TIMEOUT"
1505 if [ "$ENABLE_QUOTA" ]; then
1506 setup_quota $MOUNT || return 2
1510 nfs_client_mode () {
1511 if [ "$NFSCLIENT" ]; then
1512 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1513 local clients=$CLIENTS
1514 [ -z $clients ] && clients=$(hostname)
1516 # FIXME: remove hostname when 19215 fixed
1517 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1518 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1519 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1526 nfs_client_mode && return
1530 local mounted=$(mount | grep " $mntpt ")
1531 if [ "$CLIENTONLY" ]; then
1533 # CLIENTONLY should not depend on *_HOST settings
1534 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1535 # in theory someone could create a new,
1536 # client-only config file that assumed lustre was already
1537 # configured and didn't set the MGSNID. If MGSNID is not set,
1538 # then we should use the mgs nid currently being used
1539 # as the default value. bug 18021
1540 [[ x$MGSNID = x ]] &&
1543 if [[ x$mgc != xMGC$MGSNID ]]; then
1544 if [ "$mgs_HOST" ]; then
1545 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1546 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1547 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1553 local myMGS_host=$mgs_HOST
1554 if [ "$NETTYPE" = "ptl" ]; then
1555 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1558 echo Checking config lustre mounted on $mntpt
1559 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1560 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1562 # if [ "$mgshost" != "$myMGS_host" ]; then
1563 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1564 # Please use correct config or set mds_HOST correctly!"
1567 sanity_mount_check ||
1568 error "environments are insane!"
1572 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
1573 local cltimeout=$(lctl get_param -n timeout)
1574 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1575 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1580 check_and_setup_lustre() {
1581 nfs_client_mode && return
1583 local MOUNTED=$(mounted_lustre_filesystems)
1584 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1585 [ "$REFORMAT" ] && formatall
1587 MOUNTED=$(mounted_lustre_filesystems | head -1)
1588 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1589 export I_MOUNTED=yes
1595 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1596 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1597 lctl set_param debug_mb=${DEBUG_SIZE};
1600 if [ "$ONLY" == "setup" ]; then
1605 cleanup_and_setup_lustre() {
1606 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1607 lctl set_param debug=0 || true
1609 if [ "$ONLY" == "cleanup" ]; then
1613 check_and_setup_lustre
1616 check_and_cleanup_lustre() {
1617 if [ "`mount | grep $MOUNT`" ]; then
1618 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1619 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1621 if [ "$I_MOUNTED" = "yes" ]; then
1622 cleanupall -f || error "cleanup failed"
1634 while [ $NETWORK -eq 0 ]; do
1635 if ping -c 1 -w 3 $1 > /dev/null; then
1639 echo "waiting for $1, $((MAX - WAIT)) secs left"
1642 if [ $WAIT -gt $MAX ]; then
1643 echo "Network not available"
1649 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1660 # the sed converts spaces to commas, but leaves the last space
1661 # alone, so the line doesn't end with a comma.
1662 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1665 # list, excluded are the comma separated lists
1666 exclude_items_from_list () {
1672 for item in ${excluded//,/ }; do
1673 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1675 echo $(comma_list $list)
1678 # list, expand are the comma separated lists
1680 local list=${1//,/ }
1681 local expand=${2//,/ }
1684 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1685 echo $(comma_list $expanded)
1688 testslist_filter () {
1689 local script=$LUSTRE/tests/${TESTSUITE}.sh
1691 [ -f $script ] || return 0
1693 local start_at=$START_AT
1694 local stop_at=$STOP_AT
1696 local var=${TESTSUITE}_START_AT
1697 [ x"${!var}" != x ] && start_at=${!var}
1698 var=${TESTSUITE}_STOP_AT
1699 [ x"${!var}" != x ] && stop_at=${!var}
1701 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
1702 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
1703 /^'${start_at}'$/ {flag = 0}
1704 {if (flag == 1) print $0}
1705 /^'${stop_at}'$/ { flag = 1 }'
1709 (cd `dirname $1`; echo $PWD/`basename $1`)
1713 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1714 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1720 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
1721 list="$list ${name}$i"
1723 * ) error "Invalid facet type"
1726 echo $(comma_list $list)
1729 ##################################
1730 # Adaptive Timeouts funcs
1733 # only check mds, we assume at_max is the same on all nodes
1734 local at_max=$(do_facet mds "lctl get_param -n at_max")
1735 if [ $at_max -eq 0 ]; then
1745 # suppose that all ost-s has the same at_max set
1746 if [ $facet == "ost" ]; then
1747 do_facet ost1 "lctl get_param -n at_max"
1749 do_facet $facet "lctl get_param -n at_max"
1759 if [ $facet == "ost" ]; then
1760 for i in `seq $OSTCOUNT`; do
1761 do_facet ost$i "lctl set_param at_max=$at_max"
1764 do_facet $facet "lctl set_param at_max=$at_max"
1769 ##################################
1773 # OBD_FAIL_MDS_ALL_REQUEST_NET
1775 do_facet mds lctl set_param fail_loc=0x123
1776 do_facet client "$1" || RC=$?
1777 do_facet mds lctl set_param fail_loc=0
1782 # OBD_FAIL_MDS_ALL_REPLY_NET
1784 do_facet mds lctl set_param fail_loc=0x122
1785 do_facet client "$@" || RC=$?
1786 do_facet mds lctl set_param fail_loc=0
1790 drop_reint_reply() {
1791 # OBD_FAIL_MDS_REINT_NET_REP
1793 do_facet mds lctl set_param fail_loc=0x119
1794 do_facet client "$@" || RC=$?
1795 do_facet mds lctl set_param fail_loc=0
1800 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1802 do_facet ost1 lctl set_param fail_loc=0x214
1803 do_facet client "$1" || RC=$?
1804 do_facet client "sync"
1805 do_facet ost1 lctl set_param fail_loc=0
1809 drop_ldlm_cancel() {
1810 #define OBD_FAIL_LDLM_CANCEL 0x304
1812 do_facet client lctl set_param fail_loc=0x304
1813 do_facet client "$@" || RC=$?
1814 do_facet client lctl set_param fail_loc=0
1818 drop_bl_callback() {
1819 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1821 do_facet client lctl set_param fail_loc=0x305
1822 do_facet client "$@" || RC=$?
1823 do_facet client lctl set_param fail_loc=0
1828 #define OBD_FAIL_LDLM_REPLY 0x30c
1830 do_facet mds lctl set_param fail_loc=0x30c
1831 do_facet client "$@" || RC=$?
1832 do_facet mds lctl set_param fail_loc=0
1840 echo "clearing fail_loc on $facet"
1841 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1844 set_nodes_failloc () {
1845 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
1848 cancel_lru_locks() {
1849 $LCTL mark "cancel_lru_locks $1 start"
1850 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1851 $LCTL set_param -n $d=clear
1853 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1854 $LCTL mark "cancel_lru_locks $1 stop"
1859 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1860 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1861 echo "$DEFAULT_LRU_SIZE"
1866 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1869 lru_resize_disable()
1871 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
1876 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
1877 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
1878 echo there is still data in page cache $FILE ?
1879 lctl get_param -n $FILE
1886 create_fake_exports () {
1889 #obd_fail_val = num;
1890 #define OBD_FAIL_TGT_FAKE_EXP 0x708
1891 do_facet $facet "lctl set_param fail_val=$num"
1892 do_facet $facet "lctl set_param fail_loc=0x80000708"
1897 DEBUGSAVE="$(lctl get_param -n debug)"
1901 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
1905 ##################################
1907 ##################################
1910 local TYPE=${TYPE:-"FAIL"}
1912 lctl set_param fail_loc=0 2>/dev/null || true
1915 # do not dump logs if $1=false
1916 if [ "x$1" = "xfalse" ]; then
1921 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
1924 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
1925 echo "Dumping lctl log to $ERRLOG"
1926 # We need to dump the logs on all nodes
1927 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
1930 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
1936 $FAIL_ON_ERROR && exit 1 || true
1944 # use only if we are ignoring failures for this test, bugno required.
1945 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
1946 # e.g. error_ignore 5494 "your message"
1948 local TYPE="IGNORE (bz$1)"
1954 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
1958 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
1959 [ "$TESTSUITELOG" ] && \
1960 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
1963 build_test_filter() {
1964 EXCEPT="$EXCEPT $(testslist_filter)"
1966 [ "$ONLY" ] && log "only running test `echo $ONLY`"
1970 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
1971 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
1972 [ "$EXCEPT_SLOW" ] && \
1973 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
1974 for E in $EXCEPT $ALWAYS_EXCEPT; do
1975 eval EXCEPT_${E}=true
1977 for E in $EXCEPT_SLOW; do
1978 eval EXCEPT_SLOW_${E}=true
1980 for G in $GRANT_CHECK_LIST; do
1981 eval GCHECK_ONLY_${G}=true
1989 # print a newline if the last test was skipped
1990 export LAST_SKIPPED=
1994 export base=`basetest $1`
1995 if [ ! -z "$ONLY" ]; then
1997 if [ ${!testname}x != x ]; then
1998 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2003 if [ ${!testname}x != x ]; then
2004 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2013 if [ ${!testname}x != x ]; then
2015 TESTNAME=test_$1 skip "skipping excluded test $1"
2018 testname=EXCEPT_$base
2019 if [ ${!testname}x != x ]; then
2021 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2024 testname=EXCEPT_SLOW_$1
2025 if [ ${!testname}x != x ]; then
2027 TESTNAME=test_$1 skip "skipping SLOW test $1"
2030 testname=EXCEPT_SLOW_$base
2031 if [ ${!testname}x != x ]; then
2033 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2043 EQUALS="======================================================================"
2047 local suffixlen=$((${#EQUALS} - ${#msg}))
2048 [ $suffixlen -lt 5 ] && suffixlen=5
2049 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2054 lsmod | grep lnet > /dev/null || load_modules
2066 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2071 strace -o $TMP/$1.strace -ttt $*
2073 log "FINISHED: $*: rc $RC"
2078 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2083 FFREE=`lctl get_param -n mds.*.filesfree`
2084 FTOTAL=`lctl get_param -n mds.*.filestotal`
2085 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2089 echo -n "Resetting fail_loc on all nodes..."
2090 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2098 export tdir=d0.${TESTSUITE}/d${base}
2100 local SAVE_UMASK=`umask`
2103 local BEFORE=`date +%s`
2105 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2107 export TESTNAME=test_$testnum
2109 test_${testnum} || error "test_$testnum failed with $?"
2113 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2114 check_catastrophe || error "LBUG/LASSERT detected"
2115 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2116 pass "($((`date +%s` - $BEFORE))s)"
2124 (cd `dirname $1`; echo $PWD/`basename $1`)
2128 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2129 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2134 export base=`basetest $1`
2135 [ "$CHECK_GRANT" == "no" ] && return 0
2137 testname=GCHECK_ONLY_${base}
2138 [ ${!testname}x == x ] && return 0
2140 echo -n "checking grant......"
2142 # write some data to sync client lost_grant
2143 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2144 for i in `seq $OSTCOUNT`; do
2145 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2146 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2147 count=1 > /dev/null 2>&1
2149 # sync all the data and make sure no pending data on server
2152 #get client grant and server grant
2154 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2155 client_grant=$((client_grant + $d))
2158 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2159 server_grant=$((server_grant + $d))
2162 # cleanup the check_grant file
2163 for i in `seq $OSTCOUNT`; do
2164 rm $DIR1/${tfile}_check_grant_$i
2167 #check whether client grant == server grant
2168 if [ $client_grant != $server_grant ]; then
2169 echo "failed: client:${client_grant} server: ${server_grant}"
2176 ########################
2182 ost=`echo $1 | awk -F_ '{print $3}'`
2183 if [ -z $ost ]; then
2184 ost=`echo $1 | sed 's/-osc.*//'`
2191 [ "$node" != "$(hostname)" ]
2196 remote_node $mds_HOST
2201 [ "$CLIENTONLY" ] && return 0 || true
2202 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2208 for node in $(osts_nodes) ; do
2209 remote_node $node && return 0
2216 [ "$CLIENTONLY" ] && return 0 || true
2217 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2223 MGS=$(facet_host mgs)
2224 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2228 remote_ost && remote_mds
2232 local OSTNODES=$(facet_host ost1)
2235 for num in `seq $OSTCOUNT`; do
2236 local myOST=$(facet_host ost$num)
2237 OSTNODES="$OSTNODES $myOST"
2239 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2245 # FIXME. We need a list of clients
2246 local myNODES=$HOSTNAME
2249 # CLIENTS (if specified) contains the local client
2250 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2252 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2253 myNODES="$myNODES $(osts_nodes) $mds_HOST"
2256 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2261 remote_nodes_list () {
2262 local rnodes=$(nodes_list)
2263 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2267 init_clients_lists () {
2268 # Sanity check: exclude the local client from RCLIENTS
2269 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2271 # Sanity check: exclude the dup entries
2272 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2274 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2276 # Sanity check: exclude the dup entries from CLIENTS
2277 # for those configs which has SINGLCLIENT set to local client
2278 clients=$(for i in $clients; do echo $i; done | sort -u)
2280 CLIENTS=`comma_list $clients`
2281 local -a remoteclients=($rclients)
2282 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2283 varname=CLIENT$((i + 2))
2284 eval $varname=${remoteclients[i]}
2287 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2290 get_random_entry () {
2293 rnodes=${rnodes//,/ }
2295 local -a nodes=($rnodes)
2296 local num=${#nodes[@]}
2297 local i=$((RANDOM * num * 2 / 65536))
2303 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2308 lctl get_param version | grep -q patchless
2312 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2317 echo $nodes | wc -w || true
2321 local nodes=$(osts_nodes)
2322 local osscount=$(get_node_count "$nodes")
2323 [ ! "$OSTCOUNT" = "$osscount" ]
2326 generate_machine_file() {
2327 local nodes=${1//,/ }
2328 local machinefile=$2
2329 rm -f $machinefile || error "can't rm $machinefile"
2330 for node in $nodes; do
2331 echo $node >>$machinefile
2336 local file=$1/stripe
2338 $LFS getstripe -v $file || error
2342 check_runas_id_ret() {
2344 local myRUNAS_UID=$1
2345 local myRUNAS_GID=$2
2348 if [ -z "$myRUNAS" ]; then
2349 error_exit "myRUNAS command must be specified for check_runas_id"
2351 mkdir $DIR/d0_runas_test
2353 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2354 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
2355 rm -rf $DIR/d0_runas_test
2360 local myRUNAS_UID=$1
2361 local myRUNAS_GID=$2
2364 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2365 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2366 Please set RUNAS_ID to some UID which exists on MDS and client or
2367 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2370 # Run multiop in the background, but wait for it to print
2371 # "PAUSING" to its stdout before returning from this function.
2372 multiop_bg_pause() {
2373 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2377 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2380 echo "$MULTIOP_PROG $FILE v$ARGS"
2381 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2383 echo "TMPPIPE=${TMPPIPE}"
2384 local multiop_output
2386 read -t 60 multiop_output < $TMPPIPE
2387 if [ $? -ne 0 ]; then
2392 if [ "$multiop_output" != "PAUSING" ]; then
2393 echo "Incorrect multiop output: $multiop_output"
2408 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2414 inodes_available () {
2415 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2419 # reset llite stat counters
2420 clear_llite_stats(){
2421 lctl set_param -n llite.*.stats 0
2424 # sum llite stat items
2425 calc_llite_stats() {
2426 local res=$(lctl get_param -n llite.*.stats |
2427 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2432 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2435 calc_osc_kbytes () {
2436 df $MOUNT > /dev/null
2437 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
2440 # save_lustre_params(node, parameter_mask)
2441 # generate a stream of formatted strings (<node> <param name>=<param value>)
2442 save_lustre_params() {
2444 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2447 # restore lustre parameters from input stream, produces by save_lustre_params
2448 restore_lustre_params() {
2452 while IFS=" =" read node name val; do
2453 do_node ${node//:/} "lctl set_param -n $name $val"
2457 check_catastrophe() {
2458 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2459 local C=$CATASTROPHE
2460 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2462 if [ $rnodes ]; then
2463 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2464 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2480 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2482 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2483 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2484 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2488 mdsrate_cleanup () {
2489 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2492 delayed_recovery_enabled () {
2493 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
2496 ################################################################################
2497 # The following functions are used to enable interop testing between
2498 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
2500 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
2501 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
2502 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
2503 ################################################################################
2505 get_lustre_version () {
2506 local node=${1:-"mds"}
2507 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2510 get_mds_version_major () {
2511 local version=$(get_lustre_version mds)
2512 echo $version | awk -F. '{print $1}'
2515 get_mds_version_minor () {
2516 local version=$(get_lustre_version mds)
2517 echo $version | awk -F. '{print $2}'
2520 get_mds_version_patch () {
2521 local version=$(get_lustre_version mds)
2522 echo $version | awk -F. '{print $3}'
2525 get_mds_version_fix () {
2526 local version=$(get_lustre_version mds)
2527 echo $version | awk -F. '{print $4}'
2530 get_mds_fsstat_proc_path() {
2531 local major=$(get_mds_version_major)
2532 local minor=$(get_mds_version_minor)
2533 if [ $major -le 1 -a $minor -le 8 ] ; then
2540 get_mds_mntdev_proc_path() {
2541 local fsstat_dev=$(get_mds_fsstat_proc_path)
2542 echo "$fsstat_dev.*.mntdev"
2545 get_mdtlov_proc_path() {
2547 local major=$(get_mds_version_major)
2548 local minor=$(get_mds_version_minor)
2549 if [ $major -le 1 -a $minor -le 8 ] ; then
2550 echo "${fsname}-mdtlov"
2552 echo "${fsname}-MDT0000-mdtlov"
2556 get_mdtosc_proc_path() {
2558 local major=$(get_mds_version_major)
2559 local minor=$(get_mds_version_minor)
2560 if [ $major -le 1 -a $minor -le 8 ] ; then
2563 echo "${ost}-osc-MDT0000"
2567 get_mds_mdt_device_proc_path() {
2568 local major=$(get_mds_version_major)
2569 local minor=$(get_mds_version_minor)
2570 if [ $major -le 1 -a $minor -le 8 ] ; then
2577 ########################
2579 convert_facet2label() {
2582 if [ x$facet = xost ]; then
2586 local varsvc=${facet}_svc
2588 if [ -n ${!varsvc} ]; then
2591 error "No lablel for $facet!"
2595 get_clientosc_proc_path() {
2601 get_osc_import_name() {
2604 local label=$(convert_facet2label $ost)
2606 if [ "$facet" == "mds" ]; then
2607 get_mdtosc_proc_path $label
2611 get_clientosc_proc_path $label
2615 wait_import_state () {
2621 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2622 while [ "${CONN_STATE}" != "${expected}" ]; do
2623 if [ "${expected}" == "DISCONN" ]; then
2624 # for disconn we can check after proc entry is removed
2625 [ "x${CONN_STATE}" == "x" ] && return 0
2626 # with AT we can have connect request timeout ~ reconnect timeout
2627 # and test can't see real disconnect
2628 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2630 # disconnect rpc should be wait not more obd_timeout
2631 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2632 error "can't put import for $CONN_PROC into ${expected} state" && return 1
2634 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2638 log "$CONN_PROC now in ${CONN_STATE} state"
2642 wait_osc_import_state() {
2646 local ost=$(get_osc_import_name $facet $ost_facet)
2651 CONN_PROC="osc.${ost}.ost_server_uuid"
2652 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2653 while [ "${CONN_STATE}" != "${expected}" ]; do
2654 if [ "${expected}" == "DISCONN" ]; then
2655 # for disconn we can check after proc entry is removed
2656 [ "x${CONN_STATE}" == "x" ] && return 0
2657 # with AT enabled, we can have connect request timeout near of
2658 # reconnect timeout and test can't see real disconnect
2659 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2661 # disconnect rpc should be wait not more obd_timeout
2662 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2663 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2665 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC | cut -f2)
2669 log "${ost_facet} now in ${CONN_STATE} state"
2673 get_clientmdc_proc_path() {
2681 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
2684 wait_clients_import_state () {
2690 local label=$(convert_facet2label $facet)
2693 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
2694 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
2695 *) error "unknown facet!" ;;
2698 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
2699 error "import is not in ${expected} state"
2707 local ts=$(date +%s)
2709 # bug 20237, comment 11
2710 # It would also be useful to provide the option
2711 # of writing the file to an NFS directory so it doesn't need to be copied.
2714 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
2716 # dump lustre logs, dmesg
2717 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
2718 lctl dk \\\$log >/dev/null;
2719 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
2722 # FIXME: does it make sense to collect the logs for $ts only, but all
2724 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
2725 local logs=$TMP/'*'${TESTSUITE}'*'
2727 logs=$logs' '$tmp/'*'$ts'*'
2729 for node in ${list//,/ }; do
2730 rsync -az $node:"$logs" $TMP
2733 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
2734 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
2740 local list=${1:-$(comma_list $(nodes_list))}
2742 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true