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
20 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
22 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
24 if [ -f "$EXCEPT_LIST_FILE" ]; then
25 echo "Reading test skip list from $EXCEPT_LIST_FILE"
32 [[ $DIR/ = $MOUNT/* ]] || \
33 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
34 [[ $DIR1/ = $MOUNT1/* ]] || \
35 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
36 [[ $DIR2/ = $MOUNT2/* ]] || \
37 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
39 [ -n "$failed" ] && exit 99 || true
43 echo "usage: $0 [-r] [-f cfgfile]"
51 [ "$TESTSUITE" == "lfscktest" ] && return 0
52 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
54 local form="%-13s %-17s %-9s %s %s\n"
55 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
56 echo "------------------------------------------------------------------------------------"
57 for O in $TESTSUITE_LIST; do
58 [ "${!O}" = "no" ] && continue || true
59 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
61 local log=${TMP}/${o}.log
62 if is_sanity_benchmark $o; then
63 log=${TMP}/sanity-benchmark.log
68 local status=Unfinished
70 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
71 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | sort -nr -k 3 | head -5 | awk '{ print $2":"$3"s" }')
72 total=$(grep duration $log | awk '{ print $2}')
73 if [ "${!O}" = "done" ]; then
77 local durations=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | awk '{ print $2":"$3"|" }')
78 details=$(printf "%s\n%s %s %s\n" "$details" "DDETAILS" "$O" "$(echo $durations)")
81 printf "$form" $status "$O" "${total}" "E=$skipped"
82 printf "$form" "-" "-" "-" "S=$(echo $slow)"
85 for O in $TESTSUITE_LIST; do
86 if [ "${!O}" = "no" ]; then
88 # only for those tests suits which are run directly from acc-sm script:
89 # bonnie, iozone, etc.
90 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
91 printf "$form" "UNFINISHED" "$O" ""
93 printf "$form" "Skipped" "$O" ""
98 # print the detailed tests durations if DDETAILS=true
105 export LUSTRE=`absolute_path $LUSTRE`
106 export TESTSUITE=`basename $0 .sh`
107 export TEST_FAILED=false
108 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
110 export MKE2FS=${MKE2FS:-mke2fs}
111 export DEBUGFS=${DEBUGFS:-debugfs}
112 export TUNE2FS=${TUNE2FS:-tune2fs}
113 export E2LABEL=${E2LABEL:-e2label}
114 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
115 export E2FSCK=${E2FSCK:-e2fsck}
116 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
117 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
118 export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
119 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
120 export FSCK_MAX_ERR=4 # File system errors left uncorrected
121 if [ "$SKIP_LFSCK" == "no" ]; then
122 if [ ! -x `which $LFSCK_BIN` ]; then
124 error_exit "$E2FSCK does not support lfsck"
127 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
128 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
129 export MDSDB_OPT="--mdsdb $MDSDB"
130 export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
134 #[ -d /r ] && export ROOT=${ROOT:-/r}
135 export TMP=${TMP:-$ROOT/tmp}
136 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
137 export HOSTNAME=${HOSTNAME:-`hostname`}
138 if ! echo $PATH | grep -q $LUSTRE/utils; then
139 export PATH=$PATH:$LUSTRE/utils
141 if ! echo $PATH | grep -q $LUSTRE/test; then
142 export PATH=$PATH:$LUSTRE/tests
144 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
145 export PATH=$PATH:$LUSTRE/../lustre-iokit/sgpdd-survey
147 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
148 [ ! -f "$LST" ] && export LST=$(which lst)
149 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
150 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
151 # Ubuntu, at least, has a truncate command in /usr/bin
152 # so fully path our truncate command.
153 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
154 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
155 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
156 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
157 export PATH=$PATH:$LUSTRE/tests/racer
159 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
160 export PATH=$PATH:$LUSTRE/tests/mpi
162 export RSYNC_RSH=${RSYNC_RSH:-rsh}
163 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
164 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
165 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
166 [ ! -f "$LFS" ] && export LFS=$(which lfs)
167 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
168 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
169 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
170 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
171 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
172 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
173 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
174 export FSTYPE=${FSTYPE:-"ldiskfs"}
175 export NAME=${NAME:-local}
177 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
179 if [ "$ACCEPTOR_PORT" ]; then
180 export PORT_OPT="--port $ACCEPTOR_PORT"
183 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
185 # Paths on remote nodes, if different
186 export RLUSTRE=${RLUSTRE:-$LUSTRE}
187 export RPWD=${RPWD:-$PWD}
188 export I_MOUNTED=${I_MOUNTED:-"no"}
189 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
190 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
191 ! -f `dirname $0`/../mds/mds.ko ]; then
192 export CLIENTMODSONLY=yes
195 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
199 while getopts "rvwf:" opt $*; do
202 r) REFORMAT=--reformat;;
204 w) WRITECONF=writeconf;;
209 shift $((OPTIND - 1))
212 # print the durations of each test if "true"
213 DDETAILS=${DDETAILS:-false}
214 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
220 *) EXT=".ko"; USE_QUOTA=yes;;
224 do_facet mgs lctl pool_list $1
228 local fsname=${1%%.*}
229 local poolname=${1##$fsname.}
231 do_facet mgs lctl pool_new $1
233 # get param should return err unless pool is created
234 [[ $RC -ne 0 ]] && return $RC
236 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
237 2>/dev/null || echo foo" "" || RC=1
238 if [[ $RC -eq 0 ]]; then
241 error "pool_new failed $1"
246 add_pool_to_list () {
247 local fsname=${1%%.*}
248 local poolname=${1##$fsname.}
250 local listvar=${fsname}_CREATED_POOLS
251 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
254 remove_pool_from_list () {
255 local fsname=${1%%.*}
256 local poolname=${1##$fsname.}
258 local listvar=${fsname}_CREATED_POOLS
259 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
263 /sbin/lsmod | grep -q $1
269 BASE=`basename $module $EXT`
271 module_loaded ${BASE} && return
273 if [ "$BASE" == "lnet_selftest" ] && \
274 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
275 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
277 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
278 insmod ${LUSTRE}/${module}${EXT} $@
280 # must be testing a "make install" or "rpm" installation
285 load_modules_local() {
286 if [ -n "$MODPROBE" ]; then
290 if [ "$HAVE_MODULES" = true ]; then
296 echo Loading modules from $LUSTRE
297 load_module ../lnet/libcfs/libcfs
298 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
299 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
301 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
302 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
303 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
304 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
305 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
307 # disable it for now since it only hides the stack overflow upon test w/
309 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
310 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
311 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
313 echo "lnet options: '$LNETOPTS'"
314 # note that insmod will ignore anything in modprobe.conf
315 load_module ../lnet/lnet/lnet $LNETOPTS
316 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
317 load_module ../lnet/klnds/$LNETLND
318 load_module lvfs/lvfs
319 load_module obdclass/obdclass
320 load_module ptlrpc/ptlrpc
321 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota $LQUOTAOPTS
326 if ! client_only; then
329 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
330 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
331 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
332 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
333 load_module lvfs/fsfilt_$FSTYPE
335 load_module obdfilter/obdfilter
338 load_module llite/lustre
339 load_module llite/llite_lloop
340 rm -f $TMP/ogdb-$HOSTNAME
342 [ -d /r ] && OGDB="/r/tmp"
343 $LCTL modules > $OGDB/ogdb-$HOSTNAME
344 # 'mount' doesn't look in $PATH, just sbin
345 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
351 # load modules on remote nodes optionally
352 # lustre-tests have to be installed on these nodes
353 if $LOAD_MODULES_REMOTE ; then
354 local list=$(comma_list $(remote_nodes_list))
355 echo loading modules on $list
356 do_rpc_nodes $list load_modules
361 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
362 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
363 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
364 echo "$LEAK_LUSTRE" 1>&2
365 echo "$LEAK_PORTALS" 1>&2
366 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
367 echo "Memory leaks detected"
368 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
374 wait_exit_ST client # bug 12845
376 if $LOAD_MODULES_REMOTE ; then
377 local list=$(comma_list $(remote_nodes_list))
378 if [ ! -z $list ]; then
379 echo unloading modules on $list
380 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
381 do_rpc_nodes $list check_mem_leak
385 $LUSTRE_RMMOD $FSTYPE || return 2
389 check_mem_leak || return 254
391 echo "modules unloaded."
396 local dz=${1:-$DEBUG_SIZE}
397 local cpus=$(getconf _NPROCESSORS_CONF)
399 # bug 19944, adjust size to be -gt num_possible_cpus()
400 # promise 2MB for every cpu at least
401 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
404 lctl set_param debug_mb=$dz
407 set_default_debug () {
408 lctl set_param debug=$PTLDEBUG
409 lctl set_param subsystem_debug=${SUBSYSTEM# }
411 set_debug_size $DEBUG_SIZE
417 [ "$node" != "$(hostname)" ]
420 set_default_debug_nodes () {
423 if remote_node $nodes; then
424 do_rpc_nodes $nodes set_default_debug
430 set_default_debug_facet () {
433 set_default_debug_nodes $(facet_host ${facet})
438 local facets=${1:-$(get_facets)}
441 for facet in ${facets//,/ }; do
442 mount_facet $facet || error "Restart of $facet failed!"
449 local dev=$(facet_active $facet)_dev
450 local opt=${facet}_opt
451 local mntpt=$(facet_mntpt $facet)
453 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
454 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
456 if [ $RC -ne 0 ]; then
457 echo "mount -t lustre $@ ${!dev} $mntpt"
458 echo "Start of ${!dev} on ${facet} failed ${RC}"
460 set_default_debug_facet $facet
462 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
463 [ -z "$label" ] && echo no label for ${!dev} && exit 1
464 eval export ${facet}_svc=${label}
465 echo Started ${label}
470 # start facet device options
476 eval export ${facet}_dev=${device}
477 eval export ${facet}_opt=\"$@\"
479 local varname=${facet}failover_dev
480 if [ -n "${!varname}" ] ; then
481 eval export ${facet}failover_dev=${!varname}
483 eval export ${facet}failover_dev=$device
486 local mntpt=$(facet_mntpt $facet)
487 do_facet ${facet} mkdir -p $mntpt
488 eval export ${facet}_MOUNT=$mntpt
498 local HOST=`facet_active_host $facet`
499 [ -z $HOST ] && echo stop: no host for $facet && return 0
501 local mntpt=$(facet_mntpt $facet)
502 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
503 if [ ${running} -ne 0 ]; then
504 echo "Stopping $mntpt (opts:$@)"
505 do_facet ${facet} umount -d $@ $mntpt
508 # umount should block, but we should wait for unrelated obd's
509 # like the MGS or MGC to also stop.
511 wait_exit_ST ${facet}
514 # set quota version (both administrative and operational quotas)
515 quota_set_version() {
516 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
518 local osts=$(get_facets OST)
519 for ost in ${osts//,/ }; do
521 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
525 # save quota version (both administrative and operational quotas)
526 # the function will also switch to the new version and the new type
527 quota_save_version() {
529 local ver=$(tr -c -d "123" <<< $spec)
530 local type=$(tr -c -d "ug" <<< $spec)
532 local lustre_version=$(get_lustre_version mds)
533 if [[ $lustre_version = 1.8* ]] ; then
534 $LFS quotaoff -ug $MOUNT # just in case
535 [ -n "$ver" ] && quota_set_version $ver
537 echo mds running $lustre_version
538 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
541 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
543 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.$(get_md_name).quota_type=$spec"
545 local osts=$(get_facets OST)
546 for ost in ${osts//,/ }; do
548 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
552 # client could mount several lustre
554 local fsname=${1:-$FSNAME}
556 do_facet mgs lctl get_param md*.${fsname}-MDT*.quota_type || rc=$?
557 do_nodes $(comma_list $(osts_nodes)) \
558 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
562 restore_quota_type () {
563 local mntpt=${1:-$MOUNT}
564 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
565 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
568 quota_save_version $old_QUOTA_TYPE
575 # 1. run quotacheck only if quota is off
576 # 2. save the original quota_type params, restore them after testing
578 # Suppose that quota type the same on mds and ost
579 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
580 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
581 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
582 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
583 export old_QUOTA_TYPE=$quota_type
584 quota_save_version $QUOTA_TYPE
587 local quota_usrs=$QUOTA_USERS
589 # get_filesystem_size
590 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
591 local blk_soft=$((disksz + 1024))
592 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
594 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
596 local i_hard=$((i_soft + i_soft / 20))
598 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
599 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
602 for usr in $quota_usrs; do
603 echo "Setting up quota on $client:$mntpt for $usr..."
605 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
607 eval $cmd || error "$cmd FAILED!"
609 # display the quota status
610 echo "Quota settings for $usr : "
611 $LFS quota -v -u $usr $mntpt || true
618 local OPTIONS=${3:-$MOUNTOPT}
620 local device=$MGSNID:/$FSNAME
621 if [ -z "$mnt" -o -z "$FSNAME" ]; then
622 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
626 echo "Starting client: $client: $OPTIONS $device $mnt"
627 do_node $client mkdir -p $mnt
628 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
629 set_default_debug_nodes $client
642 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
643 if [ $running -ne 0 ]; then
644 echo "Stopping client $client $mnt (opts:$force)"
645 do_node $client lsof -t $mnt || need_kill=no
646 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
647 pids=$(do_node $client lsof -t $mnt | sort -u);
648 if [ -n $pids ]; then
649 do_node $client kill -9 $pids || true
653 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
654 if [ $busy -ne 0 ] ; then
655 echo "$mnt is still busy, wait one second" && sleep 1
656 do_node $client umount $force $mnt
661 # nodes is comma list
662 sanity_mount_check_nodes () {
668 # FIXME: assume that all cluster nodes run the same os
669 [ "$(uname)" = Linux ] || return 0
672 for mnt in $mnts ; do
673 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
674 mpts=\\\$(mount | grep -w -c $mnt);
675 if [ \\\$running -ne \\\$mpts ]; then
676 echo \\\$(hostname) env are INSANE!;
684 sanity_mount_check_servers () {
686 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
687 echo Checking servers environments
689 # FIXME: modify get_facets to display all facets wo params
690 local facets="$(get_facets OST),$(get_facets MDS),mgs"
694 for facet in ${facets//,/ }; do
695 node=$(facet_host ${facet})
696 mntpt=$(facet_mntpt $facet)
697 sanity_mount_check_nodes $node $mntpt ||
698 { error "server $node environments are insane!"; return 1; }
702 sanity_mount_check_clients () {
703 local clients=${1:-$CLIENTS}
704 local mntpt=${2:-$MOUNT}
705 local mntpt2=${3:-$MOUNT2}
707 [ -z $clients ] && clients=$(hostname)
708 echo Checking clients $clients environments
710 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
711 error "clients environments are insane!"
714 sanity_mount_check () {
715 sanity_mount_check_servers || return 1
716 sanity_mount_check_clients || return 2
719 # mount clients if not mouted
720 zconf_mount_clients() {
723 local OPTIONS=${3:-$MOUNTOPT}
725 local device=$MGSNID:/$FSNAME
726 if [ -z "$mnt" -o -z "$FSNAME" ]; then
727 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
731 echo "Starting client $clients: $OPTIONS $device $mnt"
734 running=\\\$(mount | grep -c $mnt' ');
736 if [ \\\$running -eq 0 ] ; then
738 mount -t lustre $OPTIONS $device $mnt;
743 echo "Started clients $clients: "
744 do_nodes $clients "mount | grep -w $mnt"
746 set_default_debug_nodes $clients
751 zconf_umount_clients() {
758 echo "Stopping clients: $clients $mnt (opts:$force)"
759 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
760 if [ \\\$running -ne 0 ] ; then
761 echo Stopping client \\\$(hostname) $mnt opts:$force;
762 lsof -t $mnt || need_kill=no;
763 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
764 pids=\\\$(lsof -t $mnt | sort -u);
765 if [ -n \\\"\\\$pids\\\" ]; then
769 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
770 if [ \\\$busy -ne 0 ] ; then
771 echo "$mnt is still busy, wait one second" && sleep 1;
779 echo + $POWER_DOWN $node
783 shutdown_node_hard () {
785 local attempts=$SHUTDOWN_ATTEMPTS
787 for i in $(seq $attempts) ; do
790 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
791 echo "waiting for $host to fail attempts=$attempts"
792 [ $i -lt $attempts ] || \
793 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
799 local mnt=${2:-$MOUNT}
802 if [ "$FAILURE_MODE" = HARD ]; then
803 shutdown_node_hard $client
805 zconf_umount_clients $client $mnt -f
811 local facets="$(get_facets OST),$(get_facets MDS)"
814 combined_mgs_mds || facets="$facets,mgs"
816 for facet in ${facets//,/ }; do
817 if [ $(facet_active_host $facet) == $host ]; then
818 affected="$affected $facet"
822 echo $(comma_list $affected)
827 local host=${2:-$(facet_host $facet)}
829 local label=$(convert_facet2label $facet)
830 do_node $host lctl dl | awk '{print $4}' | grep -q $label
833 facets_up_on_host () {
835 local facets=$(facets_on_host $host)
838 for facet in ${facets//,/ }; do
839 if $(facet_up $facet $host); then
840 affected_up="$affected_up $facet"
844 echo $(comma_list $affected_up)
850 if [ "$FAILURE_MODE" = HARD ]; then
851 shutdown_node_hard $(facet_active_host $facet)
859 echo + $POWER_UP $node
872 if [ "$FAILURE_MODE" = HARD ]; then
873 reboot_node $(facet_active_host $facet)
881 if [ "$FAILURE_MODE" = HARD ]; then
891 for facet in ${facets//,/ }; do
892 hosts=$(expand_list $hosts $(facet_host $facet) )
898 _check_progs_installed () {
902 for prog in $progs; do
903 if ! [ "$(which $prog)" -o "${!prog}" ]; then
904 echo $prog missing on $(hostname)
911 check_progs_installed () {
915 do_rpc_nodes $nodes _check_progs_installed $@
919 echo __$(echo $1 | tr '-' 'X')
922 start_client_load() {
925 local var=$(node_var_name $client)_load
926 eval export ${var}=$load
928 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
929 BREAK_ON_ERROR=$BREAK_ON_ERROR \
930 END_RUN_FILE=$END_RUN_FILE \
931 LOAD_PID_FILE=$LOAD_PID_FILE \
932 TESTSUITELOG=$TESTSUITELOG \
934 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
935 log "Started client load: ${load} on $client"
940 start_client_loads () {
941 local -a clients=(${1//,/ })
942 local numloads=${#CLIENT_LOADS[@]}
945 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
946 testnum=$((nodenum % numloads))
947 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
949 # bug 22169: wait the background threads to start
953 # only for remote client
954 check_client_load () {
956 local var=$(node_var_name $client)_load
957 local TESTLOAD=run_${!var}.sh
959 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
961 # bug 18914: try to connect several times not only when
962 # check ps, but while check_catastrophe also
965 while [ $RC = 254 -a $tries -gt 0 ]; do
969 if ! check_catastrophe $client; then
971 if [ $RC -eq 254 ]; then
972 # FIXME: not sure how long we shuold sleep here
976 echo "check catastrophe failed: RC=$RC "
981 # We can continue try to connect if RC=254
982 # Just print the warning about this
983 if [ $RC = 254 ]; then
984 echo "got a return status of $RC from do_node while checking catastrophe on $client"
987 # see if the load is still on the client
990 while [ $RC = 254 -a $tries -gt 0 ]; do
994 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
999 if [ $RC = 254 ]; then
1000 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1001 # see if we can diagnose a bit why this is
1006 check_client_loads () {
1007 local clients=${1//,/ }
1011 for client in $clients; do
1012 check_client_load $client
1014 if [ "$rc" != 0 ]; then
1015 log "Client load failed on node $client, rc=$rc"
1021 restart_client_loads () {
1022 local clients=${1//,/ }
1023 local expectedfail=${2:-""}
1027 for client in $clients; do
1028 check_client_load $client
1030 if [ "$rc" != 0 -a "$expectedfail" ]; then
1031 local var=$(node_var_name $client)_load
1032 start_client_load $client ${!var}
1033 echo "Restarted client load ${!var}: on $client. Checking ..."
1034 check_client_load $client
1036 if [ "$rc" != 0 ]; then
1037 log "Client load failed to restart on node $client, rc=$rc"
1038 # failure one client load means test fail
1039 # we do not need to check other
1047 # End recovery-scale functions
1049 # verify that lustre actually cleaned up properly
1051 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1052 error "LBUG/LASSERT detected"
1053 BUSY=`dmesg | grep -i destruct || true`
1054 if [ "$BUSY" ]; then
1056 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1060 check_mem_leak || exit 204
1062 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1063 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1065 if module_loaded lnet || module_loaded libcfs; then
1066 echo "$0: modules still loaded..." 1>&2
1083 RESULT=$(do_node $node "$TEST")
1084 if [ "$RESULT" == "$FINAL" ]; then
1085 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1088 [ $WAIT -ge $MAX ] && break
1089 echo "Waiting $((MAX - WAIT)) secs for update"
1090 WAIT=$((WAIT + sleep))
1093 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1097 wait_update_facet () {
1100 wait_update $(facet_active_host $facet) "$@"
1103 wait_delete_completed () {
1104 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1105 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1109 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1111 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1112 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1113 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1114 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1118 echo "Delete is not completed in $MAX_WAIT sec"
1125 # we can use "for" here because we are waiting the slowest
1126 for host in ${hostlist//,/ }; do
1127 check_network "$host" 900
1129 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1136 for facet in ${facetlist//,/ }; do
1137 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1139 wait_for_host $hostlist
1142 _wait_recovery_complete () {
1145 # Use default policy if $2 is not passed by caller.
1146 local MAX=${2:-$(max_recovery_time)}
1151 while [ $WAIT -lt $MAX ]; do
1152 STATUS=$(lctl get_param -n $param | grep status)
1154 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1157 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1159 echo "$param recovery not done in $MAX sec. $STATUS"
1163 wait_recovery_complete () {
1166 # with an assumption that at_max is the same on all nodes
1167 local MAX=${2:-$(max_recovery_time)}
1170 if [ "$FAILURE_MODE" = HARD ]; then
1171 facets=$(facets_on_host $(facet_active_host $facet))
1173 echo affected facets: $facets
1175 # we can use "for" here because we are waiting the slowest
1176 for facet in ${facets//,/ }; do
1177 local var_svc=${facet}_svc
1178 local param="*.${!var_svc}.recovery_status"
1180 local host=$(facet_active_host $facet)
1181 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1185 wait_mds_ost_sync () {
1186 # just because recovery is done doesn't mean we've finished
1187 # orphan cleanup. Wait for llogs to get synchronized.
1188 echo "Waiting for orphan cleanup..."
1189 # MAX value includes time needed for MDS-OST reconnection
1190 local MAX=$(( TIMEOUT * 2 ))
1192 while [ $WAIT -lt $MAX ]; do
1193 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1194 "$LCTL get_param -n obdfilter.*.mds_sync"))
1196 for ((i=0; i<${#sync[@]}; i++)); do
1197 [ ${sync[$i]} -eq 0 ] && continue
1198 # there is a not finished MDS-OST synchronization
1202 sleep 2 # increase waiting time and cover statfs cache
1203 [ ${con} -eq 1 ] && return 0
1204 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1207 echo "$facet recovery not done in $MAX sec. $STATUS"
1211 wait_destroy_complete () {
1212 echo "Waiting for destroy to be done..."
1213 # MAX value shouldn't be big as this mean server responsiveness
1214 # never increase this just to make test pass but investigate
1215 # why it takes so long time
1218 while [ $WAIT -lt $MAX ]; do
1219 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1221 for ((i=0; i<${#RPCs[@]}; i++)); do
1222 [ ${RPCs[$i]} -eq 0 ] && continue
1223 # there are still some destroy RPCs in flight
1228 [ ${con} -eq 1 ] && return 0 # done waiting
1229 echo "Waiting $WAIT secs for destroys to be done."
1232 echo "Destroys weren't done in $MAX sec."
1242 # conf-sanity 31 takes a long time cleanup
1243 while [ $WAIT -lt 300 ]; do
1244 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1245 [ -z "${running}" ] && return 0
1246 echo "waited $WAIT for${running}"
1247 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1249 WAIT=$((WAIT + INTERVAL))
1251 echo "service didn't stop after $WAIT seconds. Still running:"
1256 wait_remote_prog () {
1262 [ "$PDSH" = "no_dsh" ] && return 0
1264 while [ $WAIT -lt $2 ]; do
1265 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1266 [ -z "${running}" ] && return 0 || true
1267 echo "waited $WAIT for: "
1269 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1271 WAIT=$((WAIT + INTERVAL))
1273 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1274 [ -z "$pids" ] && return 0
1275 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1276 # FIXME: not portable
1277 for pid in $pids; do
1278 cat /proc/${pid}/status || true
1279 cat /proc/${pid}/wchan || true
1281 kill -9 $pid || true
1290 # not every config has many clients
1292 if [ -n "$CLIENTS" ]; then
1293 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1295 stat -f $MOUNT > /dev/null
1301 # usually checked on particular client or locally
1303 if [ ! -z "$client" ]; then
1304 $PDSH $client "stat -f $MOUNT" > /dev/null
1306 stat -f $MOUNT > /dev/null
1314 client_reconnect() {
1315 uname -n >> $MOUNT/recon
1316 if [ -z "$CLIENTS" ]; then
1317 df $MOUNT; uname -n >> $MOUNT/recon
1319 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1321 echo Connected clients:
1323 ls -l $MOUNT/recon > /dev/null
1327 affected_facets () {
1330 local host=$(facet_active_host $facet)
1331 local affected=$facet
1333 if [ "$FAILURE_MODE" = HARD ]; then
1334 affected=$(facets_up_on_host $host)
1342 local host=$(facet_active_host $facet)
1344 echo "Failing $facet on node $host"
1346 local affected=$(affected_facets $facet)
1348 shutdown_facet $facet
1350 echo affected facets: $affected
1352 [ -n "$sleep_time" ] && sleep $sleep_time
1357 RECOVERY_START_TIME=`date +%s`
1358 echo "df pid is $dfpid"
1360 change_active $affected
1362 wait_for_facet $affected
1363 # start mgs first if it is affected
1364 if ! combined_mgs_mds && list_member $affected mgs; then
1365 mount_facet mgs || error "Restart of mgs failed"
1367 # FIXME; has to be changed to mount all facets concurrently
1368 affected=$(exclude_items_from_list $affected mgs)
1369 mount_facets $affected
1378 do_facet $facet sync
1380 local svc=${facet}_svc
1381 do_facet $facet $LCTL --device %${!svc} notransno
1382 do_facet $facet $LCTL --device %${!svc} readonly
1383 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1384 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1387 replay_barrier_nodf() {
1388 local facet=$1 echo running=${running}
1389 do_facet $facet sync
1390 local svc=${facet}_svc
1391 echo Replay barrier on ${!svc}
1392 do_facet $facet $LCTL --device %${!svc} notransno
1393 do_facet $facet $LCTL --device %${!svc} readonly
1394 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1395 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1398 mds_evict_client() {
1399 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1400 local mdtdevice=$(get_mds_mdt_device_proc_path)
1401 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1404 ost_evict_client() {
1405 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1406 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1410 facet_failover $* || error "failover: $?"
1411 clients_up || error "post-failover df: $?"
1416 facet_failover $facet
1422 change_active $facet
1423 mount_facet $facet -o abort_recovery
1424 clients_up || echo "first df failed: $?"
1425 clients_up || error "post-failover df: $?"
1429 echo There is no lmc. This is mountconf, baby.
1434 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1435 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1441 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1447 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1448 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1449 if [ -z "$ID" ]; then
1450 echo "Could not get a ptl id for $1..."
1459 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1466 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1467 if type __h2elan >/dev/null 2>&1; then
1470 ID=`echo $1 | sed 's/[^0-9]*//g'`
1478 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1479 ID=`echo $1 | sed 's/[^0-9]*//g'`
1483 declare -fx h2openib
1486 h2name_or_ip "$1" "o2ib"
1493 [ "$facet" == client ] && echo -n $HOSTNAME && return
1494 varname=${facet}_HOST
1495 if [ -z "${!varname}" ]; then
1496 if [ "${facet:0:3}" == "ost" ]; then
1497 eval ${facet}_HOST=${ost_HOST}
1505 local activevar=${facet}active
1507 if [ -f $TMP/${facet}active ] ; then
1508 source $TMP/${facet}active
1511 active=${!activevar}
1512 if [ -z "$active" ] ; then
1519 facet_active_host() {
1521 local active=`facet_active $facet`
1522 if [ "$facet" == client ]; then
1525 echo `facet_host $active`
1533 facetlist=$(exclude_items_from_list $facetlist mgs)
1535 for facet in ${facetlist//,/ }; do
1536 local failover=${facet}failover
1537 local host=`facet_host $failover`
1538 [ -z "$host" ] && return
1540 local curactive=`facet_active $facet`
1541 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1542 eval export ${facet}active=$facet
1544 eval export ${facet}active=$failover
1546 # save the active host for this facet
1547 local activevar=${facet}active
1548 echo "$activevar=${!activevar}" > $TMP/$activevar
1549 local TO=`facet_active_host $facet`
1550 echo "Failover $facet to $TO"
1556 # do not stripe off hostname if verbose, bug 19215
1557 if [ x$1 = x--verbose ]; then
1565 if [ "$HOST" = "$HOSTNAME" ]; then
1567 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1568 echo "cannot run remote command on $HOST with $myPDSH"
1572 echo "CMD: $HOST $@" >&2
1573 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1576 if [ "$myPDSH" = "rsh" ]; then
1577 # we need this because rsh does not return exit code of an executed command
1578 local command_status="$TMP/cs"
1579 rsh $HOST ":> $command_status"
1580 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1581 cd $RPWD; sh -c \"$@\") ||
1582 echo command failed >$command_status"
1583 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1588 # print HOSTNAME for myPDSH="no_dsh"
1589 if [[ $myPDSH = no_dsh ]]; then
1590 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1592 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1595 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1597 return ${PIPESTATUS[0]}
1601 do_node --verbose "$@"
1604 single_local_node () {
1605 [ "$1" = "$HOSTNAME" ]
1610 # do not stripe off hostname if verbose, bug 19215
1611 if [ x$1 = x--verbose ]; then
1619 if $(single_local_node $rnodes); then
1621 do_nodev $rnodes "$@"
1623 do_node $rnodes "$@"
1628 # This is part from do_node
1631 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1632 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1635 echo "CMD: $rnodes $@" >&2
1636 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1639 # do not replace anything from pdsh output if -N is used
1640 # -N Disable hostname: prefix on lines of output.
1641 if $verbose || [[ $myPDSH = *-N* ]]; then
1642 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1644 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1646 return ${PIPESTATUS[0]}
1652 local HOST=`facet_active_host $facet`
1653 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1658 do_nodes --verbose "$@"
1664 # make sure its not already running
1666 rm -f $TMP/${facet}active
1667 do_facet ${facet} $MKFS $*
1673 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1674 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1680 if combined_mgs_mds && [[ $facet = "mgs" ]] ; then
1683 local var=${facet}_MOUNT
1684 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1693 # make sure we are using the primary server, so test-framework will
1694 # be able to clean up properly.
1695 activemds=`facet_active mds`
1696 if [ $activemds != "mds" ]; then
1700 local clients=$CLIENTS
1701 [ -z $clients ] && clients=$(hostname)
1703 zconf_umount_clients $clients $MOUNT "$*" || true
1704 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1706 [ "$CLIENTONLY" ] && return
1707 # The add fn does rm ${facet}active file, this would be enough
1708 # if we use do_facet <facet> only after the facet added, but
1709 # currently we use do_facet mds in local.sh
1711 rm -f ${TMP}/mdsactive
1712 for num in `seq $OSTCOUNT`; do
1714 rm -f $TMP/ost${num}active
1716 if ! combined_mgs_mds ; then
1723 cleanup_echo_devs () {
1724 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1726 for dev in $devs; do
1727 $LCTL --device $dev cleanup
1728 $LCTL --device $dev detach
1733 nfs_client_mode && return
1741 combined_mgs_mds () {
1742 [[ $MDSDEV = $MGSDEV ]] && [[ $mds_HOST = $mgs_HOST ]]
1748 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1749 local optvar=${tgt}_MKFS_OPTS
1750 local opt=${!optvar}
1752 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1753 [[ $facet = mgs ]] && echo $opt && return
1756 # --failnode options
1757 local var=${facet}failover_HOST
1758 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1759 local failnode=$(h2$NETTYPE ${!var})
1760 failnode="--failnode=$failnode"
1761 # options does not contain
1762 # or contains wrong --failnode=
1763 if [[ $opt != *${failnode}* ]]; then
1764 opt=$(echo $opt | sed 's/--failnode=.* / /')
1765 opt="$opt $failnode"
1771 # no additional mkfs mds "--mgsnode" option for this configuration
1772 if [[ $facet = mds ]] && combined_mgs_mds; then
1777 # additional mkfs "--mgsnode"
1778 local mgsnode="--mgsnode=$MGSNID"
1779 opt=${opt//$mgsnode }
1780 for nid in ${MGSNID//:/ }; do
1781 local mgsnode="--mgsnode=$nid"
1782 # options does not contain
1784 if [[ $opt != *${mgsnode}" "* ]]; then
1785 opt="$opt --mgsnode=$nid"
1793 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1796 # We need ldiskfs here, may as well load them all
1798 [ "$CLIENTONLY" ] && return
1799 echo Formatting mgs, mds, osts
1800 if ! combined_mgs_mds ; then
1801 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1805 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV || exit 10
1807 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1810 # the ost-s could have different OST_MKFS_OPTS
1811 # because of different failnode-s
1812 for num in `seq $OSTCOUNT`; do
1814 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1816 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1822 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1827 zconf_umount `hostname` $1 || error "umount failed"
1828 zconf_mount `hostname` $1 || error "mount failed"
1831 writeconf_facet () {
1835 do_facet $facet "$TUNEFS --writeconf $dev"
1839 writeconf_facet mds $MDSDEV
1841 for num in `seq $OSTCOUNT`; do
1842 DEVNAME=`ostdevname $num`
1843 writeconf_facet ost$num $DEVNAME
1848 nfs_client_mode && return
1850 sanity_mount_check ||
1851 error "environments are insane!"
1854 if [ -z "$CLIENTONLY" ]; then
1855 echo Setup mgs, mdt, osts
1857 echo $WRITECONF | grep -q "writeconf" && \
1860 if ! combined_mgs_mds ; then
1861 start mgs $MGSDEV $MGS_MOUNT_OPTS
1864 start mds $MDSDEV $MDS_MOUNT_OPTS
1865 # We started mds, now we should set failover variable properly.
1866 # Set mdsfailover_HOST if it is not set (the default failnode).
1867 if [ -z "$mdsfailover_HOST" ]; then
1868 mdsfailover_HOST=$(facet_host mds)
1871 for num in `seq $OSTCOUNT`; do
1872 DEVNAME=`ostdevname $num`
1873 start ost$num $DEVNAME $OST_MOUNT_OPTS
1875 # We started ost$num, now we should set ost${num}failover variable properly.
1876 # Set ost${num}failover_HOST if it is not set (the default failnode).
1877 varname=ost${num}failover_HOST
1878 if [ -z "${!varname}" ]; then
1879 eval ost${num}failover_HOST=$(facet_host ost${num})
1884 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1886 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1888 if [ "$MOUNT_2" ]; then
1889 mount_client $MOUNT2
1890 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1896 mounted_lustre_filesystems() {
1897 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1900 init_facet_vars () {
1901 [ "$CLIENTONLY" ] && return 0
1908 eval export ${facet}_dev=${device}
1909 eval export ${facet}_opt=\"$@\"
1911 local dev=${facet}_dev
1912 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1913 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1915 eval export ${facet}_svc=${label}
1917 local varname=${facet}failover_HOST
1918 if [ -z "${!varname}" ]; then
1919 eval $varname=$(facet_host $facet)
1922 # ${facet}failover_dev is set in cfg file
1923 varname=${facet}failover_dev
1924 if [ -n "${!varname}" ] ; then
1925 eval export ${facet}failover_dev=${!varname}
1927 eval export ${facet}failover_dev=$device
1930 # get mount point of already mounted device
1931 # is facet_dev is already mounted then use the real
1932 # mount point of this facet; otherwise use $(facet_mntpt $facet)
1933 # i.e. ${facet}_MOUNT if specified by user or default
1934 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
1935 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
1936 if [ -z $mntpt ]; then
1937 mntpt=$(facet_mntpt $facet)
1939 eval export ${facet}_MOUNT=$mntpt
1942 init_facets_vars () {
1944 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1946 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
1948 remote_ost_nodsh && return
1950 for num in `seq $OSTCOUNT`; do
1951 DEVNAME=`ostdevname $num`
1952 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1956 init_param_vars () {
1957 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1958 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1959 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1960 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1964 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1966 log "Using TIMEOUT=$TIMEOUT"
1968 if [ "$ENABLE_QUOTA" ]; then
1969 setup_quota $MOUNT || return 2
1973 nfs_client_mode () {
1974 if [ "$NFSCLIENT" ]; then
1975 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1976 local clients=$CLIENTS
1977 [ -z $clients ] && clients=$(hostname)
1979 # FIXME: remove hostname when 19215 fixed
1980 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1981 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1982 if [[ ${#nfsexport[@]} -eq 0 ]]; then
1983 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
1985 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1991 check_config_client () {
1994 local mounted=$(mount | grep " $mntpt ")
1995 if [ "$CLIENTONLY" ]; then
1997 # CLIENTONLY should not depend on *_HOST settings
1998 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1999 # in theory someone could create a new,
2000 # client-only config file that assumed lustre was already
2001 # configured and didn't set the MGSNID. If MGSNID is not set,
2002 # then we should use the mgs nid currently being used
2003 # as the default value. bug 18021
2004 [[ x$MGSNID = x ]] &&
2007 if [[ x$mgc != xMGC$MGSNID ]]; then
2008 if [ "$mgs_HOST" ]; then
2009 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2010 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2011 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2017 local myMGS_host=$mgs_HOST
2018 if [ "$NETTYPE" = "ptl" ]; then
2019 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2022 echo Checking config lustre mounted on $mntpt
2023 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2024 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2026 # if [ "$mgshost" != "$myMGS_host" ]; then
2027 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2028 # Please use correct config or set mds_HOST correctly!"
2033 check_config_clients () {
2034 local clients=${CLIENTS:-$HOSTNAME}
2037 nfs_client_mode && return
2039 do_rpc_nodes $clients check_config_client $mntpt
2041 sanity_mount_check ||
2042 error "environments are insane!"
2046 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
2047 local cltimeout=$(lctl get_param -n timeout)
2048 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2049 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2056 local mounted=$(mounted_lustre_filesystems)
2058 echo $mounted' ' | grep -w -q $mntpt' '
2062 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2066 # empty lustre filesystem may have empty directories lost+found and .lustre
2068 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2069 -print | wc -l) = 1 ] || return 1
2070 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2071 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2075 check_and_setup_lustre() {
2076 nfs_client_mode && return
2078 local MOUNTED=$(mounted_lustre_filesystems)
2082 # both MOUNT and MOUNT2 are not mounted
2083 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2084 [ "$REFORMAT" ] && formatall
2085 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2087 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2088 export I_MOUNTED=yes
2092 elif is_mounted $MOUNT2; then
2094 # MOUNT2 is mounted, while MOUNT_2 is not set
2095 if ! [ "$MOUNT_2" ]; then
2096 cleanup_mount $MOUNT2
2097 export I_UMOUNTED2=yes
2100 # MOUNT2 is mounted, MOUNT_2 is set
2102 # FIXME: what to do if check_config failed?
2104 # 1) remote client has mounted other Lustre fs ?
2105 # 2) it has insane env ?
2106 # let's try umount MOUNT2 on all clients and mount it again:
2107 if ! check_config_clients $MOUNT2; then
2108 cleanup_mount $MOUNT2
2109 restore_mount $MOUNT2
2110 export I_MOUNTED2=yes
2115 # MOUNT is mounted MOUNT2 is not mounted
2116 elif [ "$MOUNT_2" ]; then
2117 restore_mount $MOUNT2
2118 export I_MOUNTED2=yes
2122 # FIXME: what to do if check_config failed?
2124 # 1) remote client has mounted other Lustre fs?
2125 # 2) lustre is mounted on remote_clients atall ?
2126 check_config_clients $MOUNT
2130 set_default_debug_nodes $(comma_list $(nodes_list))
2132 if [ "$ONLY" == "setup" ]; then
2138 local clients=${CLIENTS:-$HOSTNAME}
2141 zconf_mount_clients $clients $mntpt
2145 local clients=${CLIENTS:-$HOSTNAME}
2148 zconf_umount_clients $clients $mntpt
2151 cleanup_and_setup_lustre() {
2152 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2153 lctl set_param debug=0 || true
2155 if [ "$ONLY" == "cleanup" ]; then
2159 check_and_setup_lustre
2162 # Get all of the server target devices from a given server node and type.
2171 mdt) obd_type="osd" ;;
2172 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2173 *) echo "invalid server type" && return 1 ;;
2176 devs=$(do_node $node "lctl get_param -n $obd_type.*.mntdev")
2177 for dev in $devs; do
2179 *loop*) do_node $node "losetup $dev" | \
2180 sed -e "s/.*(//" -e "s/).*//" ;;
2186 # Get all of the server target devices.
2192 for node in $(osts_nodes); do
2193 OSTDEVS[i]=$(get_mnt_devs $node ost)
2198 # Run e2fsck on MDT or OST device.
2205 df > /dev/null # update statfs data on disk
2206 local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
2209 do_node $node $cmd || rc=$?
2210 [ $rc -le $FSCK_MAX_ERR ] || \
2211 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2215 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2222 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2223 error_exit "fail to create file in $SHARED_DIRECTORY")
2225 # make sure everything gets to the backing store
2226 local list=$(comma_list $CLIENTS $(facet_host mds) $(osts_nodes))
2227 do_nodes $list "sync; sleep 2; sync"
2229 do_nodes $list ls $tmp_file || \
2230 error_exit "$SHARED_DIRECTORY is not a shared directory"
2233 run_e2fsck $(facet_host mds) $MDSDEV
2238 for node in $(osts_nodes); do
2239 for dev in ${OSTDEVS[i]}; do
2240 local ostdb_opt=`eval echo $OSTDB_OPT`
2241 run_e2fsck $node $dev $ostidx "$ostdb_opt"
2242 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2243 ostidx=$((ostidx + 1))
2250 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2254 [ $rc -le $FSCK_MAX_ERR ] || \
2255 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2256 echo "lfsck finished with rc=$rc"
2258 rm -rvf $MDSDB* $OSTDB* || true
2262 check_and_cleanup_lustre() {
2263 if [ "$LFSCK_ALWAYS" = "yes" ]; then
2266 if [ "$SKIP_LFSCK" == "no" ]; then
2273 if is_mounted $MOUNT; then
2274 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2275 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2278 if [ "$I_UMOUNTED2" = "yes" ]; then
2279 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2282 if [ "$I_MOUNTED2" = "yes" ]; then
2283 cleanup_mount $MOUNT2
2286 if [ "$I_MOUNTED" = "yes" ]; then
2287 cleanupall -f || error "cleanup failed"
2295 wait_for_function () {
2298 # suppress fn both stderr and stdout
2299 if [ "$1" = "--quiet" ]; then
2301 quiet=" > /dev/null 2>&1"
2313 eval $fn $quiet && return 0
2315 wait=$((wait + sleep))
2316 [ $wait -lt $max ] || return 1
2317 echo waiting $fn, $((max - wait)) secs left ...
2327 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2328 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2329 echo "Network not available!"
2333 echo `date +"%H:%M:%S (%s)"` network interface is UP
2342 # the sed converts spaces to commas, but leaves the last space
2343 # alone, so the line doesn't end with a comma.
2344 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2350 echo $list | grep -qw $item
2353 # list, excluded are the comma separated lists
2354 exclude_items_from_list () {
2360 for item in ${excluded//,/ }; do
2361 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2363 echo $(comma_list $list)
2366 # list, expand are the comma separated lists
2368 local list=${1//,/ }
2369 local expand=${2//,/ }
2372 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2373 echo $(comma_list $expanded)
2376 testslist_filter () {
2377 local script=$LUSTRE/tests/${TESTSUITE}.sh
2379 [ -f $script ] || return 0
2381 local start_at=$START_AT
2382 local stop_at=$STOP_AT
2384 local var=${TESTSUITE//-/_}_START_AT
2385 [ x"${!var}" != x ] && start_at=${!var}
2386 var=${TESTSUITE//-/_}_STOP_AT
2387 [ x"${!var}" != x ] && stop_at=${!var}
2389 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2390 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2391 /^'${start_at}'$/ {flag = 0}
2392 {if (flag == 1) print $0}
2393 /^'${stop_at}'$/ { flag = 1 }'
2397 (cd `dirname $1`; echo $PWD/`basename $1`)
2401 local types=${1:-"OST MDS MGS"}
2404 for entry in $types; do
2405 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2406 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2409 MDS|MGS ) list="$list $name";;
2410 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
2411 list="$list ${name}$i"
2413 * ) error "Invalid facet type"
2417 echo $(comma_list $list)
2420 ##################################
2421 # Adaptive Timeouts funcs
2424 # only check mds, we assume at_max is the same on all nodes
2425 local at_max=$(do_facet mds "lctl get_param -n at_max")
2426 if [ $at_max -eq 0 ]; then
2436 # suppose that all ost-s has the same at_max set
2437 if [ $facet == "ost" ]; then
2438 do_facet ost1 "lctl get_param -n at_max"
2440 do_facet $facet "lctl get_param -n at_max"
2450 if [ $facet == "ost" ]; then
2451 for i in `seq $OSTCOUNT`; do
2452 do_facet ost$i "lctl set_param at_max=$at_max"
2455 do_facet $facet "lctl set_param at_max=$at_max"
2460 ##################################
2464 # OBD_FAIL_MDS_ALL_REQUEST_NET
2466 do_facet mds lctl set_param fail_loc=0x123
2467 do_facet client "$1" || RC=$?
2468 do_facet mds lctl set_param fail_loc=0
2473 # OBD_FAIL_MDS_ALL_REPLY_NET
2475 do_facet mds lctl set_param fail_loc=0x122
2476 do_facet client "$@" || RC=$?
2477 do_facet mds lctl set_param fail_loc=0
2481 drop_reint_reply() {
2482 # OBD_FAIL_MDS_REINT_NET_REP
2484 do_facet mds lctl set_param fail_loc=0x119
2485 do_facet client "$@" || RC=$?
2486 do_facet mds lctl set_param fail_loc=0
2491 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2493 do_facet ost1 lctl set_param fail_loc=0x214
2494 do_facet client "$1" || RC=$?
2495 do_facet client "sync"
2496 do_facet ost1 lctl set_param fail_loc=0
2500 drop_ldlm_cancel() {
2501 #define OBD_FAIL_LDLM_CANCEL 0x304
2503 do_facet client lctl set_param fail_loc=0x304
2504 do_facet client "$@" || RC=$?
2505 do_facet client lctl set_param fail_loc=0
2509 drop_bl_callback() {
2510 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2512 do_facet client lctl set_param fail_loc=0x305
2513 do_facet client "$@" || RC=$?
2514 do_facet client lctl set_param fail_loc=0
2519 #define OBD_FAIL_LDLM_REPLY 0x30c
2521 do_facet mds lctl set_param fail_loc=0x30c
2522 do_facet client "$@" || RC=$?
2523 do_facet mds lctl set_param fail_loc=0
2531 echo "clearing fail_loc on $facet"
2532 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2535 set_nodes_failloc () {
2536 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2539 cancel_lru_locks() {
2540 $LCTL mark "cancel_lru_locks $1 start"
2541 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2542 $LCTL set_param -n $d=clear
2544 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2545 $LCTL mark "cancel_lru_locks $1 stop"
2550 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2551 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2552 echo "$DEFAULT_LRU_SIZE"
2557 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2560 lru_resize_disable()
2562 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2567 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2568 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2569 echo there is still data in page cache $FILE ?
2570 lctl get_param -n $FILE
2577 create_fake_exports () {
2580 #obd_fail_val = num;
2581 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2582 do_facet $facet "lctl set_param fail_val=$num"
2583 do_facet $facet "lctl set_param fail_loc=0x80000708"
2588 DEBUGSAVE="$(lctl get_param -n debug)"
2592 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2596 ##################################
2598 ##################################
2601 local TYPE=${TYPE:-"FAIL"}
2604 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS
2607 # do not dump logs if $1=false
2608 if [ "x$1" = "xfalse" ]; then
2613 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2616 ERRLOG=$tmp/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2617 [[ $cntlog -eq 0 ]] || ERRLOG=$ERRLOG.$cntlog
2619 echo "Dumping lctl log to $ERRLOG"
2620 # We need to dump the logs on all nodes
2621 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2624 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2630 local log=$TESTSUITELOG
2632 [ -f "$log" ] && egrep -q .FAIL: $log && status=1
2638 if $FAIL_ON_ERROR; then
2649 # use only if we are ignoring failures for this test, bugno required.
2650 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2651 # e.g. error_ignore 5494 "your message"
2653 local TYPE="IGNORE (bz$1)"
2659 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2663 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2664 [ "$TESTSUITELOG" ] && \
2665 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2668 build_test_filter() {
2669 EXCEPT="$EXCEPT $(testslist_filter)"
2671 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2675 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2676 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2677 [ "$EXCEPT_SLOW" ] && \
2678 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2679 for E in $EXCEPT $ALWAYS_EXCEPT; do
2680 eval EXCEPT_${E}=true
2682 for E in $EXCEPT_SLOW; do
2683 eval EXCEPT_SLOW_${E}=true
2685 for G in $GRANT_CHECK_LIST; do
2686 eval GCHECK_ONLY_${G}=true
2691 if [[ $1 = [a-z]* ]]; then
2698 # print a newline if the last test was skipped
2699 export LAST_SKIPPED=
2703 export base=`basetest $1`
2704 if [ ! -z "$ONLY" ]; then
2706 if [ ${!testname}x != x ]; then
2707 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2712 if [ ${!testname}x != x ]; then
2713 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2722 if [ ${!testname}x != x ]; then
2724 TESTNAME=test_$1 skip "skipping excluded test $1"
2727 testname=EXCEPT_$base
2728 if [ ${!testname}x != x ]; then
2730 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2733 testname=EXCEPT_SLOW_$1
2734 if [ ${!testname}x != x ]; then
2736 TESTNAME=test_$1 skip "skipping SLOW test $1"
2739 testname=EXCEPT_SLOW_$base
2740 if [ ${!testname}x != x ]; then
2742 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2752 EQUALS="======================================================================"
2756 local suffixlen=$((${#EQUALS} - ${#msg}))
2757 [ $suffixlen -lt 5 ] && suffixlen=5
2758 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2763 module_loaded lnet || load_modules
2775 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2780 strace -o $TMP/$1.strace -ttt $*
2782 log "FINISHED: $*: rc $RC"
2787 equals_msg $1 test complete, duration $2 sec
2788 [ -f "$TESTSUITELOG" ] && grep ".IGNORE\|.FAIL" $TESTSUITELOG || true
2789 echo duration $2 >>$TESTSUITELOG
2794 $TEST_FAILED && status=FAIL
2795 echo "$status $testnum $@" 2>&1 | tee -a $TESTSUITELOG
2799 FFREE=`lctl get_param -n mds.*.filesfree`
2800 FTOTAL=`lctl get_param -n mds.*.filestotal`
2801 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2805 echo -n "Resetting fail_loc on all nodes..."
2806 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2814 export tdir=d0.${TESTSUITE}/d${base}
2816 local SAVE_UMASK=`umask`
2819 local BEFORE=`date +%s`
2821 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2822 export TESTNAME=test_$testnum
2825 test_${testnum} || error "test_$testnum failed with $?"
2828 check_grant ${testnum} || $TEST_FAILED || error "check_grant $testnum failed"
2829 check_catastrophe || $TEST_FAILED || error "LBUG/LASSERT detected"
2830 ps auxww | grep -v grep | grep -q multiop && ($TEST_FAILED || error "multiop still running")
2831 pass "($((`date +%s` - $BEFORE))s)"
2840 (cd `dirname $1`; echo $PWD/`basename $1`)
2844 export base=`basetest $1`
2845 [ "$CHECK_GRANT" == "no" ] && return 0
2847 testname=GCHECK_ONLY_${base}
2848 [ ${!testname}x == x ] && return 0
2850 echo -n "checking grant......"
2852 local clients=$CLIENTS
2853 [ -z $clients ] && clients=$(hostname)
2855 # sync all the data and make sure no pending data on server
2856 do_nodes $clients sync
2859 client_grant=`do_nodes $clients \
2860 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
2861 awk '{total += $1} END{print total}'`
2864 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
2865 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
2866 awk '{total += $1} END{print total}'`
2868 # check whether client grant == server grant
2869 if [ $client_grant -ne $server_grant ]; then
2870 echo "failed: client:${client_grant} server: ${server_grant}."
2871 do_nodes $(comma_list $(osts_nodes)) \
2872 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
2873 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
2876 echo "pass: client:${client_grant} server: ${server_grant}"
2880 ########################
2886 ost=`echo $1 | awk -F_ '{print $3}'`
2887 if [ -z $ost ]; then
2888 ost=`echo $1 | sed 's/-osc.*//'`
2893 ostuuid_from_index()
2895 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
2900 remote_node $mds_HOST
2905 [ "$CLIENTONLY" ] && return 0 || true
2906 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2912 for node in $(osts_nodes) ; do
2913 remote_node $node && return 0
2920 [ "$CLIENTONLY" ] && return 0 || true
2921 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2927 MGS=$(facet_host mgs)
2928 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2932 remote_ost && remote_mds
2937 remote_mds_nodsh || remote_ost_nodsh || \
2938 $(single_local_node $(comma_list $(nodes_list)))
2946 for facet in ${facets//,/ }; do
2947 if [ "$FAILURE_MODE" = HARD ]; then
2948 nodes="$nodes $(facet_active_host $facet)"
2950 nodes="$nodes $(facet_host $facet)"
2953 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
2959 local facets=$(get_facets OST)
2960 local nodes=$(facets_nodes $facets)
2966 # FIXME. We need a list of clients
2967 local myNODES=$HOSTNAME
2970 # CLIENTS (if specified) contains the local client
2971 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2973 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2974 myNODES="$myNODES $(facets_nodes $(get_facets))"
2977 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2982 remote_nodes_list () {
2983 local rnodes=$(nodes_list)
2984 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2988 init_clients_lists () {
2989 # Sanity check: exclude the local client from RCLIENTS
2990 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2992 # Sanity check: exclude the dup entries
2993 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2995 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2997 # Sanity check: exclude the dup entries from CLIENTS
2998 # for those configs which has SINGLCLIENT set to local client
2999 clients=$(for i in $clients; do echo $i; done | sort -u)
3001 CLIENTS=`comma_list $clients`
3002 local -a remoteclients=($rclients)
3003 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3004 varname=CLIENT$((i + 2))
3005 eval $varname=${remoteclients[i]}
3008 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3011 get_random_entry () {
3014 rnodes=${rnodes//,/ }
3016 local -a nodes=($rnodes)
3017 local num=${#nodes[@]}
3018 local i=$((RANDOM * num * 2 / 65536))
3024 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3029 lctl get_param version | grep -q patchless
3033 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3038 echo $nodes | wc -w || true
3042 local nodes=$(osts_nodes)
3043 local osscount=$(get_node_count "$nodes")
3044 [ ! "$OSTCOUNT" = "$osscount" ]
3047 generate_machine_file() {
3048 local nodes=${1//,/ }
3049 local machinefile=$2
3051 for node in $nodes; do
3052 echo $node >>$machinefile || \
3053 { echo "can not generate machinefile $machinefile" && return 1; }
3058 local file=$1/stripe
3060 $LFS getstripe -v $file || error
3064 setstripe_nfsserver () {
3067 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3068 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3070 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3072 do_nodev $nfsserver lfs setstripe "$@"
3075 check_runas_id_ret() {
3077 local myRUNAS_UID=$1
3078 local myRUNAS_GID=$2
3081 if [ -z "$myRUNAS" ]; then
3082 error_exit "myRUNAS command must be specified for check_runas_id"
3084 mkdir $DIR/d0_runas_test
3086 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3087 if ! $myRUNAS touch $DIR/d0_runas_test/f$$ ; then
3088 do_nodesv $(comma_list $(nodes_list)) grep -w $myRUNAS_UID /etc/passwd
3091 rm -rf $DIR/d0_runas_test
3096 local myRUNAS_UID=$1
3097 local myRUNAS_GID=$2
3100 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3101 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3102 Please set RUNAS_ID to some UID which exists on MDS and client or
3103 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3106 # Run multiop in the background, but wait for it to print
3107 # "PAUSING" to its stdout before returning from this function.
3108 multiop_bg_pause() {
3109 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3113 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3116 echo "$MULTIOP_PROG $FILE v$ARGS"
3117 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3119 echo "TMPPIPE=${TMPPIPE}"
3120 local multiop_output
3122 read -t 60 multiop_output < $TMPPIPE
3123 if [ $? -ne 0 ]; then
3128 if [ "$multiop_output" != "PAUSING" ]; then
3129 echo "Incorrect multiop output: $multiop_output"
3144 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3150 inodes_available () {
3151 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3155 mdsrate_inodes_available () {
3156 echo $(($(inodes_available) - 1))
3159 # reset llite stat counters
3160 clear_llite_stats(){
3161 lctl set_param -n llite.*.stats 0
3164 # sum llite stat items
3165 calc_llite_stats() {
3166 local res=$(lctl get_param -n llite.*.stats |
3167 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3172 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3175 calc_osc_kbytes () {
3176 df $MOUNT > /dev/null
3177 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
3180 # save_lustre_params(node, parameter_mask)
3181 # generate a stream of formatted strings (<node> <param name>=<param value>)
3182 save_lustre_params() {
3184 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3187 # restore lustre parameters from input stream, produces by save_lustre_params
3188 restore_lustre_params() {
3192 while IFS=" =" read node name val; do
3193 do_node ${node//:/} "lctl set_param -n $name $val"
3197 check_catastrophe() {
3198 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3199 local C=$CATASTROPHE
3200 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3202 if [ $rnodes ]; then
3203 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3204 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3220 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3222 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3223 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3224 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3228 mdsrate_cleanup () {
3229 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3232 delayed_recovery_enabled () {
3233 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
3236 ################################################################################
3237 # The following functions are used to enable interop testing between
3238 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
3240 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
3241 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
3242 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
3243 ################################################################################
3245 get_lustre_version () {
3246 local node=${1:-"mds"}
3247 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3250 get_mds_version_major () {
3251 local version=$(get_lustre_version mds)
3252 echo $version | awk -F. '{print $1}'
3255 get_mds_version_minor () {
3256 local version=$(get_lustre_version mds)
3257 echo $version | awk -F. '{print $2}'
3260 get_mds_version_patch () {
3261 local version=$(get_lustre_version mds)
3262 echo $version | awk -F. '{print $3}'
3265 get_mds_version_fix () {
3266 local version=$(get_lustre_version mds)
3267 echo $version | awk -F. '{print $4}'
3270 get_kernel_version () {
3271 local facet=${1:-"mds"}
3272 do_facet $facet uname -r | awk -F "-" '{print $1}'
3275 get_mds_kernel_major () {
3276 local version=$(get_kernel_version mds)
3277 echo $version | awk -F. '{print $1"."$2}'
3280 get_mds_kernel_minor () {
3281 local version=$(get_kernel_version mds)
3282 echo $version | awk -F. '{print $3}'
3285 get_mds_fsstat_proc_path() {
3286 local major=$(get_mds_version_major)
3287 local minor=$(get_mds_version_minor)
3288 if [ $major -le 1 -a $minor -le 8 ] ; then
3295 get_mds_mntdev_proc_path() {
3296 local fsstat_dev=$(get_mds_fsstat_proc_path)
3297 echo "$fsstat_dev.*.mntdev"
3300 get_mdtlov_proc_path() {
3302 local major=$(get_mds_version_major)
3303 local minor=$(get_mds_version_minor)
3304 if [ $major -le 1 -a $minor -le 8 ] ; then
3305 echo "${fsname}-mdtlov"
3307 echo "${fsname}-MDT0000-mdtlov"
3311 get_mdtosc_proc_path() {
3313 local major=$(get_mds_version_major)
3314 local minor=$(get_mds_version_minor)
3315 if [ $major -le 1 -a $minor -le 8 ] ; then
3318 echo "${ost}-osc-MDT0000"
3322 get_mds_mdt_device_proc_path() {
3323 local major=$(get_mds_version_major)
3324 local minor=$(get_mds_version_minor)
3325 if [ $major -le 1 -a $minor -le 8 ] ; then
3333 local major=$(get_mds_version_major)
3334 local minor=$(get_mds_version_minor)
3335 if [ $major -le 1 -a $minor -le 8 ] ; then
3342 ########################
3344 convert_facet2label() {
3347 if [ x$facet = xost ]; then
3351 local varsvc=${facet}_svc
3353 if [ -n ${!varsvc} ]; then
3356 error "No lablel for $facet!"
3360 get_clientosc_proc_path() {
3366 get_osc_import_name() {
3369 local label=$(convert_facet2label $ost)
3371 if [ "$facet" == "mds" ]; then
3372 get_mdtosc_proc_path $label
3376 get_clientosc_proc_path $label
3380 _wait_import_state () {
3383 local maxtime=${3:-max_recovery_time}
3387 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3388 while [ "${CONN_STATE}" != "${expected}" ]; do
3389 [ $i -ge $maxtime ] && \
3390 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3393 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3397 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3401 wait_import_state() {
3404 local maxtime=${3:-max_recovery_time}
3407 for param in ${params//,/ }; do
3408 _wait_import_state $state $param $maxtime || return
3411 wait_osc_import_state() {
3415 local ost=$(get_osc_import_name $facet $ost_facet)
3420 CONN_PROC="osc.${ost}.ost_server_uuid"
3421 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3422 while [ "${CONN_STATE}" != "${expected}" ]; do
3423 if [ "${expected}" == "DISCONN" ]; then
3424 # for disconn we can check after proc entry is removed
3425 [ "x${CONN_STATE}" == "x" ] && return 0
3426 # with AT enabled, we can have connect request timeout near of
3427 # reconnect timeout and test can't see real disconnect
3428 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3430 # disconnect rpc should be wait not more obd_timeout
3431 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3432 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3434 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3438 log "${ost_facet} now in ${CONN_STATE} state"
3442 get_clientmdc_proc_path() {
3450 local RPATH="PATH=$LUSTRE/tests/:$PATH"
3451 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3454 wait_clients_import_state () {
3461 if [ "$FAILURE_MODE" = HARD ]; then
3462 facets=$(facets_on_host $(facet_active_host $facet))
3465 for facet in ${facets//,/ }; do
3466 local label=$(convert_facet2label $facet)
3469 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3470 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3471 *) error "unknown facet!" ;;
3473 local params=$(expand_list $params $proc_path)
3476 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3477 error "import is not in ${expected} state"
3482 destroy_pool_int() {
3484 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
3485 for ost in $OSTS; do
3486 do_facet mgs lctl pool_remove $1 $ost
3488 do_facet mgs lctl pool_destroy $1
3491 # <fsname>.<poolname> or <poolname>
3493 local fsname=${1%%.*}
3494 local poolname=${1##$fsname.}
3496 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3500 pool_list $fsname.$poolname || return $?
3502 destroy_pool_int $fsname.$poolname
3504 [[ $RC -ne 0 ]] && return $RC
3506 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3507 2>/dev/null || echo foo" "foo" || RC=1
3509 if [[ $RC -eq 0 ]]; then
3510 remove_pool_from_list $fsname.$poolname
3512 error "destroy pool failed $1"
3518 local fsname=${1:-$FSNAME}
3520 local listvar=${fsname}_CREATED_POOLS
3524 [ x${!listvar} = x ] && return 0
3526 echo destroy the created pools: ${!listvar}
3527 for poolname in ${!listvar//,/ }; do
3528 destroy_pool $fsname.$poolname
3533 local fsname=${1:-$FSNAME}
3535 destroy_pools $fsname
3541 local ts=$(date +%s)
3543 # bug 20237, comment 11
3544 # It would also be useful to provide the option
3545 # of writing the file to an NFS directory so it doesn't need to be copied.
3548 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3550 # dump lustre logs, dmesg
3551 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3552 lctl dk \\\$log >/dev/null;
3553 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3556 # FIXME: does it make sense to collect the logs for $ts only, but all
3558 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3559 local logs=$TMP/'*'${TESTSUITE}'*'
3561 logs=$logs' '$tmp/'*'$ts'*'
3563 for node in ${list//,/ }; do
3564 rsync -az $node:"$logs" $TMP
3567 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3568 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3574 local list=${1:-$(comma_list $(nodes_list))}
3576 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3588 for i in $(seq 0 $num_mntpts); do
3589 cmd="ls -laf ${mntpt_root}$i/$dir"
3595 for pid in $pids; do
3602 # target_start_and_reset_recovery_timer()
3603 # service_time = at_est2timeout(service_time);
3604 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3605 # INITIAL_CONNECT_TIMEOUT);
3606 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3607 #define CONNECTION_SWITCH_INC 1
3608 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3609 #define CONNECTION_SWITCH_MIN 5U
3611 max_recovery_time () {
3612 local init_connect_timeout=$(( TIMEOUT / 20 ))
3613 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
3615 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
3620 remove_mdt_files() {
3625 local mntpt=${MOUNT%/*}/$facet
3627 echo "removing files from $mdtdev on $facet: $files"
3628 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3631 rm $mntpt/ROOT/$f || { rc=$?; break; }
3633 umount -f $mntpt || return $?
3637 duplicate_mdt_files() {
3642 local mntpt=${MOUNT%/*}/$facet
3644 echo "duplicating files on $mdtdev on $facet: $files"
3645 mkdir -p $mntpt || return $?
3646 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3656 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
3657 pushd $mntpt/ROOT > /dev/null || return $?
3660 touch $f.bad || return $?
3661 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
3663 [ $rc -eq 0 ] || return $rc
3664 setfattr --restore $tmp || return $?
3670 local devs=${1//,/ }
3673 local rslt=$TMP/sgpdd_survey
3675 # sgpdd-survey cleanups ${rslt}.* files
3677 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
3683 # returns the canonical name for an ldiskfs device
3688 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
3689 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
3690 echo dm-\\\${foo##*:};
3692 echo \\\$(basename \\\$dv);
3696 is_sanity_benchmark() {
3697 local benchmarks="dbench bonnie iozone fsx"
3699 for b in $benchmarks; do
3700 if [ "$b" == "$suite" ]; then
3708 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1