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 [ "$o" = racer ] && log=${TMP}/runracer.log
63 if is_sanity_benchmark $o; then
64 log=${TMP}/sanity-benchmark.log
69 local status=Unfinished
71 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
72 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | sort -nr -k 3 | head -5 | awk '{ print $2":"$3"s" }')
73 total=$(grep duration $log | awk '{ print $2}')
74 if [ "${!O}" = "done" ]; then
78 local durations=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | awk '{ print $2":"$3"|" }')
79 details=$(printf "%s\n%s %s %s\n" "$details" "DDETAILS" "$O" "$(echo $durations)")
82 printf "$form" $status "$O" "${total}" "E=$skipped"
83 printf "$form" "-" "-" "-" "S=$(echo $slow)"
86 for O in $TESTSUITE_LIST; do
87 if [ "${!O}" = "no" ]; then
89 # only for those tests suits which are run directly from acc-sm script:
90 # bonnie, iozone, etc.
91 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
92 printf "$form" "UNFINISHED" "$O" ""
94 printf "$form" "Skipped" "$O" ""
99 # print the detailed tests durations if DDETAILS=true
106 export LUSTRE=`absolute_path $LUSTRE`
107 export TESTSUITE=`basename $0 .sh`
108 export TEST_FAILED=false
109 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
111 export MKE2FS=${MKE2FS:-mke2fs}
112 export DEBUGFS=${DEBUGFS:-debugfs}
113 export TUNE2FS=${TUNE2FS:-tune2fs}
114 export E2LABEL=${E2LABEL:-e2label}
115 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
116 export E2FSCK=${E2FSCK:-e2fsck}
117 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
118 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
119 export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
120 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
121 export FSCK_MAX_ERR=4 # File system errors left uncorrected
122 if [ "$SKIP_LFSCK" == "no" ]; then
123 if [ ! -x `which $LFSCK_BIN` ]; then
125 error_exit "$E2FSCK does not support lfsck"
128 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
129 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
130 export MDSDB_OPT="--mdsdb $MDSDB"
131 export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
135 #[ -d /r ] && export ROOT=${ROOT:-/r}
136 export TMP=${TMP:-$ROOT/tmp}
137 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
138 export HOSTNAME=${HOSTNAME:-`hostname`}
139 if ! echo $PATH | grep -q $LUSTRE/utils; then
140 export PATH=$PATH:$LUSTRE/utils
142 if ! echo $PATH | grep -q $LUSTRE/test; then
143 export PATH=$PATH:$LUSTRE/tests
145 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
146 export PATH=$PATH:$LUSTRE/../lustre-iokit/sgpdd-survey
148 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
149 [ ! -f "$LST" ] && export LST=$(which lst)
150 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
151 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
152 # Ubuntu, at least, has a truncate command in /usr/bin
153 # so fully path our truncate command.
154 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
155 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
156 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
157 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
158 export PATH=$PATH:$LUSTRE/tests/racer
160 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
161 export PATH=$PATH:$LUSTRE/tests/mpi
163 export RSYNC_RSH=${RSYNC_RSH:-rsh}
164 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
165 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
166 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
167 [ ! -f "$LFS" ] && export LFS=$(which lfs)
168 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
169 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
170 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
171 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
172 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
173 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
174 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
175 export FSTYPE=${FSTYPE:-"ldiskfs"}
176 export NAME=${NAME:-local}
178 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
180 if [ "$ACCEPTOR_PORT" ]; then
181 export PORT_OPT="--port $ACCEPTOR_PORT"
184 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
186 # Paths on remote nodes, if different
187 export RLUSTRE=${RLUSTRE:-$LUSTRE}
188 export RPWD=${RPWD:-$PWD}
189 export I_MOUNTED=${I_MOUNTED:-"no"}
190 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
191 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
192 ! -f `dirname $0`/../mds/mds.ko ]; then
193 export CLIENTMODSONLY=yes
196 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
200 while getopts "rvwf:" opt $*; do
203 r) REFORMAT=--reformat;;
205 w) WRITECONF=writeconf;;
210 shift $((OPTIND - 1))
213 # print the durations of each test if "true"
214 DDETAILS=${DDETAILS:-false}
215 [ "$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."
397 local facets=${1:-$(get_facets)}
400 for facet in ${facets//,/ }; do
401 mount_facet $facet || error "Restart of $facet failed!"
408 local dev=$(facet_active $facet)_dev
409 local opt=${facet}_opt
410 local mntpt=$(facet_mntpt $facet)
412 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
413 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
415 if [ $RC -ne 0 ]; then
416 echo "mount -t lustre $@ ${!dev} $mntpt"
417 echo "Start of ${!dev} on ${facet} failed ${RC}"
419 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
420 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
421 lctl set_param debug_mb=${DEBUG_SIZE}; \
424 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
425 [ -z "$label" ] && echo no label for ${!dev} && exit 1
426 eval export ${facet}_svc=${label}
427 echo Started ${label}
432 # start facet device options
438 eval export ${facet}_dev=${device}
439 eval export ${facet}_opt=\"$@\"
441 local varname=${facet}failover_dev
442 if [ -n "${!varname}" ] ; then
443 eval export ${facet}failover_dev=${!varname}
445 eval export ${facet}failover_dev=$device
448 local mntpt=$(facet_mntpt $facet)
449 do_facet ${facet} mkdir -p $mntpt
450 eval export ${facet}_MOUNT=$mntpt
460 local HOST=`facet_active_host $facet`
461 [ -z $HOST ] && echo stop: no host for $facet && return 0
463 local mntpt=$(facet_mntpt $facet)
464 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
465 if [ ${running} -ne 0 ]; then
466 echo "Stopping $mntpt (opts:$@)"
467 do_facet ${facet} umount -d $@ $mntpt
470 # umount should block, but we should wait for unrelated obd's
471 # like the MGS or MGC to also stop.
473 wait_exit_ST ${facet}
476 # set quota version (both administrative and operational quotas)
477 quota_set_version() {
478 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
480 local osts=$(get_facets OST)
481 for ost in ${osts//,/ }; do
483 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
487 # save quota version (both administrative and operational quotas)
488 # the function will also switch to the new version and the new type
489 quota_save_version() {
491 local ver=$(tr -c -d "123" <<< $spec)
492 local type=$(tr -c -d "ug" <<< $spec)
494 local lustre_version=$(get_lustre_version mds)
495 if [[ $lustre_version = 1.8* ]] ; then
496 $LFS quotaoff -ug $MOUNT # just in case
497 [ -n "$ver" ] && quota_set_version $ver
499 echo mds running $lustre_version
500 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
503 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
505 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.$(get_md_name).quota_type=$spec"
507 local osts=$(get_facets OST)
508 for ost in ${osts//,/ }; do
510 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
514 # client could mount several lustre
516 local fsname=${1:-$FSNAME}
518 do_facet mgs lctl get_param md*.${fsname}-MDT*.quota_type || rc=$?
519 do_nodes $(comma_list $(osts_nodes)) \
520 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
524 restore_quota_type () {
525 local mntpt=${1:-$MOUNT}
526 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
527 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
530 quota_save_version $old_QUOTA_TYPE
537 # 1. run quotacheck only if quota is off
538 # 2. save the original quota_type params, restore them after testing
540 # Suppose that quota type the same on mds and ost
541 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
542 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
543 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
544 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
545 export old_QUOTA_TYPE=$quota_type
546 quota_save_version $QUOTA_TYPE
549 local quota_usrs=$QUOTA_USERS
551 # get_filesystem_size
552 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
553 local blk_soft=$((disksz + 1024))
554 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
556 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
558 local i_hard=$((i_soft + i_soft / 20))
560 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
561 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
564 for usr in $quota_usrs; do
565 echo "Setting up quota on $client:$mntpt for $usr..."
567 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
569 eval $cmd || error "$cmd FAILED!"
571 # display the quota status
572 echo "Quota settings for $usr : "
573 $LFS quota -v -u $usr $mntpt || true
580 local OPTIONS=${3:-$MOUNTOPT}
582 local device=$MGSNID:/$FSNAME
583 if [ -z "$mnt" -o -z "$FSNAME" ]; then
584 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
588 echo "Starting client: $client: $OPTIONS $device $mnt"
589 do_node $client mkdir -p $mnt
590 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
591 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
592 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
593 lctl set_param debug_mb=${DEBUG_SIZE}"
606 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
607 if [ $running -ne 0 ]; then
608 echo "Stopping client $client $mnt (opts:$force)"
609 do_node $client lsof -t $mnt || need_kill=no
610 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
611 pids=$(do_node $client lsof -t $mnt | sort -u);
612 if [ -n $pids ]; then
613 do_node $client kill -9 $pids || true
617 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
618 if [ $busy -ne 0 ] ; then
619 echo "$mnt is still busy, wait one second" && sleep 1
620 do_node $client umount $force $mnt
625 # nodes is comma list
626 sanity_mount_check_nodes () {
632 # FIXME: assume that all cluster nodes run the same os
633 [ "$(uname)" = Linux ] || return 0
636 for mnt in $mnts ; do
637 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
638 mpts=\\\$(mount | grep -w -c $mnt);
639 if [ \\\$running -ne \\\$mpts ]; then
640 echo \\\$(hostname) env are INSANE!;
648 sanity_mount_check_servers () {
650 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
651 echo Checking servers environments
653 # FIXME: modify get_facets to display all facets wo params
654 local facets="$(get_facets OST),$(get_facets MDS),mgs"
658 for facet in ${facets//,/ }; do
659 node=$(facet_host ${facet})
660 mntpt=$(facet_mntpt $facet)
661 sanity_mount_check_nodes $node $mntpt ||
662 { error "server $node environments are insane!"; return 1; }
666 sanity_mount_check_clients () {
667 local clients=${1:-$CLIENTS}
668 local mntpt=${2:-$MOUNT}
669 local mntpt2=${3:-$MOUNT2}
671 [ -z $clients ] && clients=$(hostname)
672 echo Checking clients $clients environments
674 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
675 error "clients environments are insane!"
678 sanity_mount_check () {
679 sanity_mount_check_servers || return 1
680 sanity_mount_check_clients || return 2
683 # mount clients if not mouted
684 zconf_mount_clients() {
687 local OPTIONS=${3:-$MOUNTOPT}
689 local device=$MGSNID:/$FSNAME
690 if [ -z "$mnt" -o -z "$FSNAME" ]; then
691 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
695 echo "Starting client $clients: $OPTIONS $device $mnt"
698 running=\\\$(mount | grep -c $mnt' ');
700 if [ \\\$running -eq 0 ] ; then
702 mount -t lustre $OPTIONS $device $mnt;
707 echo "Started clients $clients: "
708 do_nodes $clients "mount | grep -w $mnt"
710 do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
711 sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
712 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
717 zconf_umount_clients() {
724 echo "Stopping clients: $clients $mnt (opts:$force)"
725 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
726 if [ \\\$running -ne 0 ] ; then
727 echo Stopping client \\\$(hostname) $mnt opts:$force;
728 lsof -t $mnt || need_kill=no;
729 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
730 pids=\\\$(lsof -t $mnt | sort -u);
731 if [ -n \\\"\\\$pids\\\" ]; then
735 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
736 if [ \\\$busy -ne 0 ] ; then
737 echo "$mnt is still busy, wait one second" && sleep 1;
745 echo + $POWER_DOWN $node
749 shutdown_node_hard () {
751 local attempts=$SHUTDOWN_ATTEMPTS
753 for i in $(seq $attempts) ; do
756 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
757 echo "waiting for $host to fail attempts=$attempts"
758 [ $i -lt $attempts ] || \
759 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
765 local mnt=${2:-$MOUNT}
768 if [ "$FAILURE_MODE" = HARD ]; then
769 shutdown_node_hard $client
771 zconf_umount_clients $client $mnt -f
777 local facets="$(get_facets OST),$(get_facets MDS)"
780 combined_mgs_mds || facets="$facets,mgs"
782 for facet in ${facets//,/ }; do
783 if [ $(facet_active_host $facet) == $host ]; then
784 affected="$affected $facet"
788 echo $(comma_list $affected)
793 local host=${2:-$(facet_host $facet)}
795 local label=$(convert_facet2label $facet)
796 do_node $host lctl dl | awk '{print $4}' | grep -q $label
799 facets_up_on_host () {
801 local facets=$(facets_on_host $host)
804 for facet in ${facets//,/ }; do
805 if $(facet_up $facet $host); then
806 affected_up="$affected_up $facet"
810 echo $(comma_list $affected_up)
816 if [ "$FAILURE_MODE" = HARD ]; then
817 shutdown_node_hard $(facet_active_host $facet)
825 echo + $POWER_UP $node
838 if [ "$FAILURE_MODE" = HARD ]; then
839 reboot_node $(facet_active_host $facet)
847 if [ "$FAILURE_MODE" = HARD ]; then
857 for facet in ${facets//,/ }; do
858 hosts=$(expand_list $hosts $(facet_host $facet) )
864 _check_progs_installed () {
868 for prog in $progs; do
869 if ! [ "$(which $prog)" -o "${!prog}" ]; then
870 echo $prog missing on $(hostname)
877 check_progs_installed () {
881 do_rpc_nodes $nodes _check_progs_installed $@
885 echo __$(echo $1 | tr '-' 'X')
888 start_client_load() {
891 local var=$(node_var_name $client)_load
892 eval export ${var}=$load
894 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
895 BREAK_ON_ERROR=$BREAK_ON_ERROR \
896 END_RUN_FILE=$END_RUN_FILE \
897 LOAD_PID_FILE=$LOAD_PID_FILE \
898 TESTSUITELOG=$TESTSUITELOG \
900 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
901 log "Started client load: ${load} on $client"
906 start_client_loads () {
907 local -a clients=(${1//,/ })
908 local numloads=${#CLIENT_LOADS[@]}
911 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
912 testnum=$((nodenum % numloads))
913 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
915 # bug 22169: wait the background threads to start
919 # only for remote client
920 check_client_load () {
922 local var=$(node_var_name $client)_load
923 local TESTLOAD=run_${!var}.sh
925 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
927 # bug 18914: try to connect several times not only when
928 # check ps, but while check_catastrophe also
931 while [ $RC = 254 -a $tries -gt 0 ]; do
935 if ! check_catastrophe $client; then
937 if [ $RC -eq 254 ]; then
938 # FIXME: not sure how long we shuold sleep here
942 echo "check catastrophe failed: RC=$RC "
947 # We can continue try to connect if RC=254
948 # Just print the warning about this
949 if [ $RC = 254 ]; then
950 echo "got a return status of $RC from do_node while checking catastrophe on $client"
953 # see if the load is still on the client
956 while [ $RC = 254 -a $tries -gt 0 ]; do
960 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
965 if [ $RC = 254 ]; then
966 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
967 # see if we can diagnose a bit why this is
972 check_client_loads () {
973 local clients=${1//,/ }
977 for client in $clients; do
978 check_client_load $client
980 if [ "$rc" != 0 ]; then
981 log "Client load failed on node $client, rc=$rc"
987 restart_client_loads () {
988 local clients=${1//,/ }
989 local expectedfail=${2:-""}
993 for client in $clients; do
994 check_client_load $client
996 if [ "$rc" != 0 -a "$expectedfail" ]; then
997 local var=$(node_var_name $client)_load
998 start_client_load $client ${!var}
999 echo "Restarted client load ${!var}: on $client. Checking ..."
1000 check_client_load $client
1002 if [ "$rc" != 0 ]; then
1003 log "Client load failed to restart on node $client, rc=$rc"
1004 # failure one client load means test fail
1005 # we do not need to check other
1013 # End recovery-scale functions
1015 # verify that lustre actually cleaned up properly
1017 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1018 error "LBUG/LASSERT detected"
1019 BUSY=`dmesg | grep -i destruct || true`
1020 if [ "$BUSY" ]; then
1022 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1026 check_mem_leak || exit 204
1028 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1029 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1031 if module_loaded lnet || module_loaded libcfs; then
1032 echo "$0: modules still loaded..." 1>&2
1049 RESULT=$(do_node $node "$TEST")
1050 if [ "$RESULT" == "$FINAL" ]; then
1051 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1054 [ $WAIT -ge $MAX ] && break
1055 echo "Waiting $((MAX - WAIT)) secs for update"
1056 WAIT=$((WAIT + sleep))
1059 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1063 wait_update_facet () {
1066 wait_update $(facet_active_host $facet) "$@"
1069 wait_delete_completed () {
1070 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1071 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1075 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1077 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1078 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1079 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1080 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1084 echo "Delete is not completed in $MAX_WAIT sec"
1091 # we can use "for" here because we are waiting the slowest
1092 for host in ${hostlist//,/ }; do
1093 check_network "$host" 900
1095 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1102 for facet in ${facetlist//,/ }; do
1103 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1105 wait_for_host $hostlist
1108 _wait_recovery_complete () {
1111 # Use default policy if $2 is not passed by caller.
1112 local MAX=${2:-$(max_recovery_time)}
1117 while [ $WAIT -lt $MAX ]; do
1118 STATUS=$(lctl get_param -n $param | grep status)
1120 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1123 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1125 echo "$param recovery not done in $MAX sec. $STATUS"
1129 wait_recovery_complete () {
1132 # with an assumption that at_max is the same on all nodes
1133 local MAX=${2:-$(max_recovery_time)}
1136 if [ "$FAILURE_MODE" = HARD ]; then
1137 facets=$(facets_on_host $(facet_active_host $facet))
1139 echo affected facets: $facets
1141 # we can use "for" here because we are waiting the slowest
1142 for facet in ${facets//,/ }; do
1143 local var_svc=${facet}_svc
1144 local param="*.${!var_svc}.recovery_status"
1146 local host=$(facet_active_host $facet)
1147 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1151 wait_mds_ost_sync () {
1152 # just because recovery is done doesn't mean we've finished
1153 # orphan cleanup. Wait for llogs to get synchronized.
1154 echo "Waiting for orphan cleanup..."
1155 # MAX value includes time needed for MDS-OST reconnection
1156 local MAX=$(( TIMEOUT * 2 ))
1158 while [ $WAIT -lt $MAX ]; do
1159 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1160 "$LCTL get_param -n obdfilter.*.mds_sync"))
1162 for ((i=0; i<${#sync[@]}; i++)); do
1163 [ ${sync[$i]} -eq 0 ] && continue
1164 # there is a not finished MDS-OST synchronization
1168 sleep 2 # increase waiting time and cover statfs cache
1169 [ ${con} -eq 1 ] && return 0
1170 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1173 echo "$facet recovery not done in $MAX sec. $STATUS"
1177 wait_destroy_complete () {
1178 echo "Waiting for destroy to be done..."
1179 # MAX value shouldn't be big as this mean server responsiveness
1180 # never increase this just to make test pass but investigate
1181 # why it takes so long time
1184 while [ $WAIT -lt $MAX ]; do
1185 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1187 for ((i=0; i<${#RPCs[@]}; i++)); do
1188 [ ${RPCs[$i]} -eq 0 ] && continue
1189 # there are still some destroy RPCs in flight
1194 [ ${con} -eq 1 ] && return 0 # done waiting
1195 echo "Waiting $WAIT secs for destroys to be done."
1198 echo "Destroys weren't done in $MAX sec."
1208 # conf-sanity 31 takes a long time cleanup
1209 while [ $WAIT -lt 300 ]; do
1210 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1211 [ -z "${running}" ] && return 0
1212 echo "waited $WAIT for${running}"
1213 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1215 WAIT=$((WAIT + INTERVAL))
1217 echo "service didn't stop after $WAIT seconds. Still running:"
1222 wait_remote_prog () {
1228 [ "$PDSH" = "no_dsh" ] && return 0
1230 while [ $WAIT -lt $2 ]; do
1231 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1232 [ -z "${running}" ] && return 0 || true
1233 echo "waited $WAIT for: "
1235 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1237 WAIT=$((WAIT + INTERVAL))
1239 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1240 [ -z "$pids" ] && return 0
1241 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1242 # FIXME: not portable
1243 for pid in $pids; do
1244 cat /proc/${pid}/status || true
1245 cat /proc/${pid}/wchan || true
1247 kill -9 $pid || true
1256 # not every config has many clients
1258 if [ -n "$CLIENTS" ]; then
1259 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1261 stat -f $MOUNT > /dev/null
1267 # usually checked on particular client or locally
1269 if [ ! -z "$client" ]; then
1270 $PDSH $client "stat -f $MOUNT" > /dev/null
1272 stat -f $MOUNT > /dev/null
1280 client_reconnect() {
1281 uname -n >> $MOUNT/recon
1282 if [ -z "$CLIENTS" ]; then
1283 df $MOUNT; uname -n >> $MOUNT/recon
1285 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1287 echo Connected clients:
1289 ls -l $MOUNT/recon > /dev/null
1293 affected_facets () {
1296 local host=$(facet_active_host $facet)
1297 local affected=$facet
1299 if [ "$FAILURE_MODE" = HARD ]; then
1300 affected=$(facets_up_on_host $host)
1308 local host=$(facet_active_host $facet)
1310 echo "Failing $facet on node $host"
1312 local affected=$(affected_facets $facet)
1314 shutdown_facet $facet
1316 echo affected facets: $affected
1318 [ -n "$sleep_time" ] && sleep $sleep_time
1323 RECOVERY_START_TIME=`date +%s`
1324 echo "df pid is $dfpid"
1326 change_active $affected
1328 wait_for_facet $affected
1329 # start mgs first if it is affected
1330 if ! combined_mgs_mds && list_member $affected mgs; then
1331 mount_facet mgs || error "Restart of mgs failed"
1333 # FIXME; has to be changed to mount all facets concurrently
1334 affected=$(exclude_items_from_list $affected mgs)
1335 mount_facets $affected
1344 do_facet $facet sync
1346 local svc=${facet}_svc
1347 do_facet $facet $LCTL --device %${!svc} notransno
1348 do_facet $facet $LCTL --device %${!svc} readonly
1349 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1350 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1353 replay_barrier_nodf() {
1354 local facet=$1 echo running=${running}
1355 do_facet $facet sync
1356 local svc=${facet}_svc
1357 echo Replay barrier on ${!svc}
1358 do_facet $facet $LCTL --device %${!svc} notransno
1359 do_facet $facet $LCTL --device %${!svc} readonly
1360 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1361 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1364 mds_evict_client() {
1365 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1366 local mdtdevice=$(get_mds_mdt_device_proc_path)
1367 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1370 ost_evict_client() {
1371 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1372 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1376 facet_failover $* || error "failover: $?"
1377 clients_up || error "post-failover df: $?"
1382 facet_failover $facet
1388 change_active $facet
1389 mount_facet $facet -o abort_recovery
1390 clients_up || echo "first df failed: $?"
1391 clients_up || error "post-failover df: $?"
1395 echo There is no lmc. This is mountconf, baby.
1400 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1401 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1407 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1413 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1414 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1415 if [ -z "$ID" ]; then
1416 echo "Could not get a ptl id for $1..."
1425 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1432 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1433 if type __h2elan >/dev/null 2>&1; then
1436 ID=`echo $1 | sed 's/[^0-9]*//g'`
1444 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1445 ID=`echo $1 | sed 's/[^0-9]*//g'`
1449 declare -fx h2openib
1452 h2name_or_ip "$1" "o2ib"
1459 [ "$facet" == client ] && echo -n $HOSTNAME && return
1460 varname=${facet}_HOST
1461 if [ -z "${!varname}" ]; then
1462 if [ "${facet:0:3}" == "ost" ]; then
1463 eval ${facet}_HOST=${ost_HOST}
1471 local activevar=${facet}active
1473 if [ -f $TMP/${facet}active ] ; then
1474 source $TMP/${facet}active
1477 active=${!activevar}
1478 if [ -z "$active" ] ; then
1485 facet_active_host() {
1487 local active=`facet_active $facet`
1488 if [ "$facet" == client ]; then
1491 echo `facet_host $active`
1499 facetlist=$(exclude_items_from_list $facetlist mgs)
1501 for facet in ${facetlist//,/ }; do
1502 local failover=${facet}failover
1503 local host=`facet_host $failover`
1504 [ -z "$host" ] && return
1506 local curactive=`facet_active $facet`
1507 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1508 eval export ${facet}active=$facet
1510 eval export ${facet}active=$failover
1512 # save the active host for this facet
1513 local activevar=${facet}active
1514 echo "$activevar=${!activevar}" > $TMP/$activevar
1515 local TO=`facet_active_host $facet`
1516 echo "Failover $facet to $TO"
1522 # do not stripe off hostname if verbose, bug 19215
1523 if [ x$1 = x--verbose ]; then
1531 if [ "$HOST" = "$HOSTNAME" ]; then
1533 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1534 echo "cannot run remote command on $HOST with $myPDSH"
1538 echo "CMD: $HOST $@" >&2
1539 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1542 if [ "$myPDSH" = "rsh" ]; then
1543 # we need this because rsh does not return exit code of an executed command
1544 local command_status="$TMP/cs"
1545 rsh $HOST ":> $command_status"
1546 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1547 cd $RPWD; sh -c \"$@\") ||
1548 echo command failed >$command_status"
1549 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1554 # print HOSTNAME for myPDSH="no_dsh"
1555 if [[ $myPDSH = no_dsh ]]; then
1556 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1558 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1561 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1563 return ${PIPESTATUS[0]}
1567 do_node --verbose "$@"
1570 single_local_node () {
1571 [ "$1" = "$HOSTNAME" ]
1576 # do not stripe off hostname if verbose, bug 19215
1577 if [ x$1 = x--verbose ]; then
1585 if $(single_local_node $rnodes); then
1587 do_nodev $rnodes "$@"
1589 do_node $rnodes "$@"
1594 # This is part from do_node
1597 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1598 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1601 echo "CMD: $rnodes $@" >&2
1602 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1605 # do not replace anything from pdsh output if -N is used
1606 # -N Disable hostname: prefix on lines of output.
1607 if $verbose || [[ $myPDSH = *-N* ]]; then
1608 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1610 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1612 return ${PIPESTATUS[0]}
1618 local HOST=`facet_active_host $facet`
1619 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1624 do_nodes --verbose "$@"
1630 # make sure its not already running
1632 rm -f $TMP/${facet}active
1633 do_facet ${facet} $MKFS $*
1639 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1640 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1646 if combined_mgs_mds && [[ $facet = "mgs" ]] ; then
1649 local var=${facet}_MOUNT
1650 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1659 # make sure we are using the primary server, so test-framework will
1660 # be able to clean up properly.
1661 activemds=`facet_active mds`
1662 if [ $activemds != "mds" ]; then
1666 local clients=$CLIENTS
1667 [ -z $clients ] && clients=$(hostname)
1669 zconf_umount_clients $clients $MOUNT "$*" || true
1670 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1672 [ "$CLIENTONLY" ] && return
1673 # The add fn does rm ${facet}active file, this would be enough
1674 # if we use do_facet <facet> only after the facet added, but
1675 # currently we use do_facet mds in local.sh
1677 rm -f ${TMP}/mdsactive
1678 for num in `seq $OSTCOUNT`; do
1680 rm -f $TMP/ost${num}active
1682 if ! combined_mgs_mds ; then
1689 cleanup_echo_devs () {
1690 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1692 for dev in $devs; do
1693 $LCTL --device $dev cleanup
1694 $LCTL --device $dev detach
1699 nfs_client_mode && return
1707 combined_mgs_mds () {
1708 [[ $MDSDEV = $MGSDEV ]] && [[ $mds_HOST = $mgs_HOST ]]
1714 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1715 local optvar=${tgt}_MKFS_OPTS
1716 local opt=${!optvar}
1718 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1719 [[ $facet = mgs ]] && echo $opt && return
1722 # --failnode options
1723 local var=${facet}failover_HOST
1724 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1725 local failnode=$(h2$NETTYPE ${!var})
1726 failnode="--failnode=$failnode"
1727 # options does not contain
1728 # or contains wrong --failnode=
1729 if [[ $opt != *${failnode}* ]]; then
1730 opt=$(echo $opt | sed 's/--failnode=.* / /')
1731 opt="$opt $failnode"
1737 # no additional mkfs mds "--mgsnode" option for this configuration
1738 if [[ $facet = mds ]] && combined_mgs_mds; then
1743 # additional mkfs "--mgsnode"
1744 local mgsnode="--mgsnode=$MGSNID"
1745 opt=${opt//$mgsnode }
1746 for nid in ${MGSNID//:/ }; do
1747 local mgsnode="--mgsnode=$nid"
1748 # options does not contain
1750 if [[ $opt != *${mgsnode}" "* ]]; then
1751 opt="$opt --mgsnode=$nid"
1759 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1762 # We need ldiskfs here, may as well load them all
1764 [ "$CLIENTONLY" ] && return
1765 echo Formatting mgs, mds, osts
1766 if ! combined_mgs_mds ; then
1767 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1771 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV || exit 10
1773 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1776 # the ost-s could have different OST_MKFS_OPTS
1777 # because of different failnode-s
1778 for num in `seq $OSTCOUNT`; do
1780 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1782 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1788 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1793 zconf_umount `hostname` $1 || error "umount failed"
1794 zconf_mount `hostname` $1 || error "mount failed"
1797 writeconf_facet () {
1801 do_facet $facet "$TUNEFS --writeconf $dev"
1805 writeconf_facet mds $MDSDEV
1807 for num in `seq $OSTCOUNT`; do
1808 DEVNAME=`ostdevname $num`
1809 writeconf_facet ost$num $DEVNAME
1814 nfs_client_mode && return
1816 sanity_mount_check ||
1817 error "environments are insane!"
1820 if [ -z "$CLIENTONLY" ]; then
1821 echo Setup mgs, mdt, osts
1823 echo $WRITECONF | grep -q "writeconf" && \
1826 if ! combined_mgs_mds ; then
1827 start mgs $MGSDEV $MGS_MOUNT_OPTS
1830 start mds $MDSDEV $MDS_MOUNT_OPTS
1831 # We started mds, now we should set failover variable properly.
1832 # Set mdsfailover_HOST if it is not set (the default failnode).
1833 if [ -z "$mdsfailover_HOST" ]; then
1834 mdsfailover_HOST=$(facet_host mds)
1837 for num in `seq $OSTCOUNT`; do
1838 DEVNAME=`ostdevname $num`
1839 start ost$num $DEVNAME $OST_MOUNT_OPTS
1841 # We started ost$num, now we should set ost${num}failover variable properly.
1842 # Set ost${num}failover_HOST if it is not set (the default failnode).
1843 varname=ost${num}failover_HOST
1844 if [ -z "${!varname}" ]; then
1845 eval ost${num}failover_HOST=$(facet_host ost${num})
1850 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1852 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1854 if [ "$MOUNT_2" ]; then
1855 mount_client $MOUNT2
1856 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1862 mounted_lustre_filesystems() {
1863 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1866 init_facet_vars () {
1867 [ "$CLIENTONLY" ] && return 0
1874 eval export ${facet}_dev=${device}
1875 eval export ${facet}_opt=\"$@\"
1877 local dev=${facet}_dev
1878 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1879 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1881 eval export ${facet}_svc=${label}
1883 local varname=${facet}failover_HOST
1884 if [ -z "${!varname}" ]; then
1885 eval $varname=$(facet_host $facet)
1888 # ${facet}failover_dev is set in cfg file
1889 varname=${facet}failover_dev
1890 if [ -n "${!varname}" ] ; then
1891 eval export ${facet}failover_dev=${!varname}
1893 eval export ${facet}failover_dev=$device
1896 # get mount point of already mounted device
1897 # is facet_dev is already mounted then use the real
1898 # mount point of this facet; otherwise use $(facet_mntpt $facet)
1899 # i.e. ${facet}_MOUNT if specified by user or default
1900 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
1901 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
1902 if [ -z $mntpt ]; then
1903 mntpt=$(facet_mntpt $facet)
1905 eval export ${facet}_MOUNT=$mntpt
1908 init_facets_vars () {
1910 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1912 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
1914 remote_ost_nodsh && return
1916 for num in `seq $OSTCOUNT`; do
1917 DEVNAME=`ostdevname $num`
1918 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1922 init_param_vars () {
1923 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1924 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1925 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1926 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1930 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1932 log "Using TIMEOUT=$TIMEOUT"
1934 if [ "$ENABLE_QUOTA" ]; then
1935 setup_quota $MOUNT || return 2
1939 nfs_client_mode () {
1940 if [ "$NFSCLIENT" ]; then
1941 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1942 local clients=$CLIENTS
1943 [ -z $clients ] && clients=$(hostname)
1945 # FIXME: remove hostname when 19215 fixed
1946 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1947 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1948 if [[ ${#nfsexport[@]} -eq 0 ]]; then
1949 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
1951 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1957 check_config_client () {
1960 local mounted=$(mount | grep " $mntpt ")
1961 if [ "$CLIENTONLY" ]; then
1963 # CLIENTONLY should not depend on *_HOST settings
1964 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1965 # in theory someone could create a new,
1966 # client-only config file that assumed lustre was already
1967 # configured and didn't set the MGSNID. If MGSNID is not set,
1968 # then we should use the mgs nid currently being used
1969 # as the default value. bug 18021
1970 [[ x$MGSNID = x ]] &&
1973 if [[ x$mgc != xMGC$MGSNID ]]; then
1974 if [ "$mgs_HOST" ]; then
1975 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1976 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1977 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1983 local myMGS_host=$mgs_HOST
1984 if [ "$NETTYPE" = "ptl" ]; then
1985 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1988 echo Checking config lustre mounted on $mntpt
1989 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1990 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1992 # if [ "$mgshost" != "$myMGS_host" ]; then
1993 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1994 # Please use correct config or set mds_HOST correctly!"
1999 check_config_clients () {
2000 local clients=${CLIENTS:-$HOSTNAME}
2003 nfs_client_mode && return
2005 do_rpc_nodes $clients check_config_client $mntpt
2007 sanity_mount_check ||
2008 error "environments are insane!"
2012 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
2013 local cltimeout=$(lctl get_param -n timeout)
2014 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2015 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2022 local mounted=$(mounted_lustre_filesystems)
2024 echo $mounted' ' | grep -w -q $mntpt' '
2028 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2032 # empty lustre filesystem may have empty directories lost+found and .lustre
2034 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2035 -print | wc -l) = 1 ] || return 1
2036 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2037 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2041 check_and_setup_lustre() {
2042 nfs_client_mode && return
2044 local MOUNTED=$(mounted_lustre_filesystems)
2048 # both MOUNT and MOUNT2 are not mounted
2049 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2050 [ "$REFORMAT" ] && formatall
2051 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2053 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2054 export I_MOUNTED=yes
2058 elif is_mounted $MOUNT2; then
2060 # MOUNT2 is mounted, while MOUNT_2 is not set
2061 if ! [ "$MOUNT_2" ]; then
2062 cleanup_mount $MOUNT2
2063 export I_UMOUNTED2=yes
2066 # MOUNT2 is mounted, MOUNT_2 is set
2068 # FIXME: what to do if check_config failed?
2070 # 1) remote client has mounted other Lustre fs ?
2071 # 2) it has insane env ?
2072 # let's try umount MOUNT2 on all clients and mount it again:
2073 if ! check_config_clients $MOUNT2; then
2074 cleanup_mount $MOUNT2
2075 restore_mount $MOUNT2
2076 export I_MOUNTED2=yes
2081 # MOUNT is mounted MOUNT2 is not mounted
2082 elif [ "$MOUNT_2" ]; then
2083 restore_mount $MOUNT2
2084 export I_MOUNTED2=yes
2088 # FIXME: what to do if check_config failed?
2090 # 1) remote client has mounted other Lustre fs?
2091 # 2) lustre is mounted on remote_clients atall ?
2092 check_config_clients $MOUNT
2096 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2097 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2098 lctl set_param debug_mb=${DEBUG_SIZE};
2101 if [ "$ONLY" == "setup" ]; then
2107 local clients=${CLIENTS:-$HOSTNAME}
2110 zconf_mount_clients $clients $mntpt
2114 local clients=${CLIENTS:-$HOSTNAME}
2117 zconf_umount_clients $clients $mntpt
2120 cleanup_and_setup_lustre() {
2121 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2122 lctl set_param debug=0 || true
2124 if [ "$ONLY" == "cleanup" ]; then
2128 check_and_setup_lustre
2131 # Get all of the server target devices from a given server node and type.
2140 mdt) obd_type="osd" ;;
2141 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2142 *) echo "invalid server type" && return 1 ;;
2145 devs=$(do_node $node "lctl get_param -n $obd_type.*.mntdev")
2146 for dev in $devs; do
2148 *loop*) do_node $node "losetup $dev" | \
2149 sed -e "s/.*(//" -e "s/).*//" ;;
2155 # Get all of the server target devices.
2161 for node in $(osts_nodes); do
2162 OSTDEVS[i]=$(get_mnt_devs $node ost)
2167 # Run e2fsck on MDT or OST device.
2174 df > /dev/null # update statfs data on disk
2175 local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
2178 do_node $node $cmd || rc=$?
2179 [ $rc -le $FSCK_MAX_ERR ] || \
2180 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2184 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2191 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2192 error_exit "fail to create file in $SHARED_DIRECTORY")
2194 # make sure everything gets to the backing store
2195 local list=$(comma_list $CLIENTS $(facet_host mds) $(osts_nodes))
2196 do_nodes $list "sync; sleep 2; sync"
2198 do_nodes $list ls $tmp_file || \
2199 error_exit "$SHARED_DIRECTORY is not a shared directory"
2202 run_e2fsck $(facet_host mds) $MDSDEV
2207 for node in $(osts_nodes); do
2208 for dev in ${OSTDEVS[i]}; do
2209 local ostdb_opt=`eval echo $OSTDB_OPT`
2210 run_e2fsck $node $dev $ostidx "$ostdb_opt"
2211 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2212 ostidx=$((ostidx + 1))
2219 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2223 [ $rc -le $FSCK_MAX_ERR ] || \
2224 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2225 echo "lfsck finished with rc=$rc"
2227 rm -rvf $MDSDB* $OSTDB* || true
2231 check_and_cleanup_lustre() {
2232 if [ "$LFSCK_ALWAYS" = "yes" ]; then
2235 if [ "$SKIP_LFSCK" == "no" ]; then
2242 if is_mounted $MOUNT; then
2243 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2244 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2247 if [ "$I_UMOUNTED2" = "yes" ]; then
2248 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2251 if [ "$I_MOUNTED2" = "yes" ]; then
2252 cleanup_mount $MOUNT2
2255 if [ "$I_MOUNTED" = "yes" ]; then
2256 cleanupall -f || error "cleanup failed"
2264 wait_for_function () {
2267 # suppress fn both stderr and stdout
2268 if [ "$1" = "--quiet" ]; then
2270 quiet=" > /dev/null 2>&1"
2282 eval $fn $quiet && return 0
2284 wait=$((wait + sleep))
2285 [ $wait -lt $max ] || return 1
2286 echo waiting $fn, $((max - wait)) secs left ...
2296 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2297 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2298 echo "Network not available!"
2302 echo `date +"%H:%M:%S (%s)"` network interface is UP
2311 # the sed converts spaces to commas, but leaves the last space
2312 # alone, so the line doesn't end with a comma.
2313 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2319 echo $list | grep -qw $item
2322 # list, excluded are the comma separated lists
2323 exclude_items_from_list () {
2329 for item in ${excluded//,/ }; do
2330 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2332 echo $(comma_list $list)
2335 # list, expand are the comma separated lists
2337 local list=${1//,/ }
2338 local expand=${2//,/ }
2341 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2342 echo $(comma_list $expanded)
2345 testslist_filter () {
2346 local script=$LUSTRE/tests/${TESTSUITE}.sh
2348 [ -f $script ] || return 0
2350 local start_at=$START_AT
2351 local stop_at=$STOP_AT
2353 local var=${TESTSUITE//-/_}_START_AT
2354 [ x"${!var}" != x ] && start_at=${!var}
2355 var=${TESTSUITE//-/_}_STOP_AT
2356 [ x"${!var}" != x ] && stop_at=${!var}
2358 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2359 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2360 /^'${start_at}'$/ {flag = 0}
2361 {if (flag == 1) print $0}
2362 /^'${stop_at}'$/ { flag = 1 }'
2366 (cd `dirname $1`; echo $PWD/`basename $1`)
2370 local types=${1:-"OST MDS MGS"}
2373 for entry in $types; do
2374 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2375 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2378 MDS|MGS ) list="$list $name";;
2379 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
2380 list="$list ${name}$i"
2382 * ) error "Invalid facet type"
2386 echo $(comma_list $list)
2389 ##################################
2390 # Adaptive Timeouts funcs
2393 # only check mds, we assume at_max is the same on all nodes
2394 local at_max=$(do_facet mds "lctl get_param -n at_max")
2395 if [ $at_max -eq 0 ]; then
2405 # suppose that all ost-s has the same at_max set
2406 if [ $facet == "ost" ]; then
2407 do_facet ost1 "lctl get_param -n at_max"
2409 do_facet $facet "lctl get_param -n at_max"
2419 if [ $facet == "ost" ]; then
2420 for i in `seq $OSTCOUNT`; do
2421 do_facet ost$i "lctl set_param at_max=$at_max"
2424 do_facet $facet "lctl set_param at_max=$at_max"
2429 ##################################
2433 # OBD_FAIL_MDS_ALL_REQUEST_NET
2435 do_facet mds lctl set_param fail_loc=0x123
2436 do_facet client "$1" || RC=$?
2437 do_facet mds lctl set_param fail_loc=0
2442 # OBD_FAIL_MDS_ALL_REPLY_NET
2444 do_facet mds lctl set_param fail_loc=0x122
2445 do_facet client "$@" || RC=$?
2446 do_facet mds lctl set_param fail_loc=0
2450 drop_reint_reply() {
2451 # OBD_FAIL_MDS_REINT_NET_REP
2453 do_facet mds lctl set_param fail_loc=0x119
2454 do_facet client "$@" || RC=$?
2455 do_facet mds lctl set_param fail_loc=0
2460 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2462 do_facet ost1 lctl set_param fail_loc=0x214
2463 do_facet client "$1" || RC=$?
2464 do_facet client "sync"
2465 do_facet ost1 lctl set_param fail_loc=0
2469 drop_ldlm_cancel() {
2470 #define OBD_FAIL_LDLM_CANCEL 0x304
2472 do_facet client lctl set_param fail_loc=0x304
2473 do_facet client "$@" || RC=$?
2474 do_facet client lctl set_param fail_loc=0
2478 drop_bl_callback() {
2479 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2481 do_facet client lctl set_param fail_loc=0x305
2482 do_facet client "$@" || RC=$?
2483 do_facet client lctl set_param fail_loc=0
2488 #define OBD_FAIL_LDLM_REPLY 0x30c
2490 do_facet mds lctl set_param fail_loc=0x30c
2491 do_facet client "$@" || RC=$?
2492 do_facet mds lctl set_param fail_loc=0
2500 echo "clearing fail_loc on $facet"
2501 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2504 set_nodes_failloc () {
2505 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2508 cancel_lru_locks() {
2509 $LCTL mark "cancel_lru_locks $1 start"
2510 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2511 $LCTL set_param -n $d=clear
2513 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2514 $LCTL mark "cancel_lru_locks $1 stop"
2519 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2520 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2521 echo "$DEFAULT_LRU_SIZE"
2526 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2529 lru_resize_disable()
2531 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2536 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2537 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2538 echo there is still data in page cache $FILE ?
2539 lctl get_param -n $FILE
2546 create_fake_exports () {
2549 #obd_fail_val = num;
2550 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2551 do_facet $facet "lctl set_param fail_val=$num"
2552 do_facet $facet "lctl set_param fail_loc=0x80000708"
2557 DEBUGSAVE="$(lctl get_param -n debug)"
2561 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2565 ##################################
2567 ##################################
2570 local TYPE=${TYPE:-"FAIL"}
2573 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS
2576 # do not dump logs if $1=false
2577 if [ "x$1" = "xfalse" ]; then
2582 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2585 ERRLOG=$tmp/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2586 echo "Dumping lctl log to $ERRLOG"
2587 # We need to dump the logs on all nodes
2588 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2591 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2597 local log=$TESTSUITELOG
2599 [ -f "$log" ] && egrep -q .FAIL $log && status=1
2605 if $FAIL_ON_ERROR; then
2616 # use only if we are ignoring failures for this test, bugno required.
2617 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2618 # e.g. error_ignore 5494 "your message"
2620 local TYPE="IGNORE (bz$1)"
2626 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2630 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2631 [ "$TESTSUITELOG" ] && \
2632 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2635 build_test_filter() {
2636 EXCEPT="$EXCEPT $(testslist_filter)"
2638 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2642 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2643 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2644 [ "$EXCEPT_SLOW" ] && \
2645 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2646 for E in $EXCEPT $ALWAYS_EXCEPT; do
2647 eval EXCEPT_${E}=true
2649 for E in $EXCEPT_SLOW; do
2650 eval EXCEPT_SLOW_${E}=true
2652 for G in $GRANT_CHECK_LIST; do
2653 eval GCHECK_ONLY_${G}=true
2658 if [[ $1 = [a-z]* ]]; then
2665 # print a newline if the last test was skipped
2666 export LAST_SKIPPED=
2670 export base=`basetest $1`
2671 if [ ! -z "$ONLY" ]; then
2673 if [ ${!testname}x != x ]; then
2674 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2679 if [ ${!testname}x != x ]; then
2680 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2689 if [ ${!testname}x != x ]; then
2691 TESTNAME=test_$1 skip "skipping excluded test $1"
2694 testname=EXCEPT_$base
2695 if [ ${!testname}x != x ]; then
2697 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2700 testname=EXCEPT_SLOW_$1
2701 if [ ${!testname}x != x ]; then
2703 TESTNAME=test_$1 skip "skipping SLOW test $1"
2706 testname=EXCEPT_SLOW_$base
2707 if [ ${!testname}x != x ]; then
2709 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2719 EQUALS="======================================================================"
2723 local suffixlen=$((${#EQUALS} - ${#msg}))
2724 [ $suffixlen -lt 5 ] && suffixlen=5
2725 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2730 module_loaded lnet || load_modules
2742 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2747 strace -o $TMP/$1.strace -ttt $*
2749 log "FINISHED: $*: rc $RC"
2754 equals_msg $1 test complete, duration $2 sec
2755 [ -f "$TESTSUITELOG" ] && grep ".IGNORE\|.FAIL" $TESTSUITELOG || true
2756 echo duration $2 >>$TESTSUITELOG
2761 $TEST_FAILED && status=FAIL
2762 echo "$status $testnum $@" 2>&1 | tee -a $TESTSUITELOG
2766 FFREE=`lctl get_param -n mds.*.filesfree`
2767 FTOTAL=`lctl get_param -n mds.*.filestotal`
2768 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2772 echo -n "Resetting fail_loc on all nodes..."
2773 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2781 export tdir=d0.${TESTSUITE}/d${base}
2783 local SAVE_UMASK=`umask`
2786 local BEFORE=`date +%s`
2788 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2790 export TESTNAME=test_$testnum
2792 test_${testnum} || error "test_$testnum failed with $?"
2796 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2797 check_catastrophe || error "LBUG/LASSERT detected"
2798 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2799 pass "($((`date +%s` - $BEFORE))s)"
2807 (cd `dirname $1`; echo $PWD/`basename $1`)
2811 export base=`basetest $1`
2812 [ "$CHECK_GRANT" == "no" ] && return 0
2814 testname=GCHECK_ONLY_${base}
2815 [ ${!testname}x == x ] && return 0
2817 echo -n "checking grant......"
2819 local clients=$CLIENTS
2820 [ -z $clients ] && clients=$(hostname)
2822 # sync all the data and make sure no pending data on server
2823 do_nodes $clients sync
2826 client_grant=`do_nodes $clients \
2827 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
2828 awk '{total += $1} END{print total}'`
2831 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
2832 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
2833 awk '{total += $1} END{print total}'`
2835 # check whether client grant == server grant
2836 if [ $client_grant -ne $server_grant ]; then
2837 echo "failed: client:${client_grant} server: ${server_grant}."
2838 do_nodes $(comma_list $(osts_nodes)) \
2839 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
2840 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
2843 echo "pass: client:${client_grant} server: ${server_grant}"
2847 ########################
2853 ost=`echo $1 | awk -F_ '{print $3}'`
2854 if [ -z $ost ]; then
2855 ost=`echo $1 | sed 's/-osc.*//'`
2860 ostuuid_from_index()
2862 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
2867 [ "$node" != "$(hostname)" ]
2872 remote_node $mds_HOST
2877 [ "$CLIENTONLY" ] && return 0 || true
2878 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2884 for node in $(osts_nodes) ; do
2885 remote_node $node && return 0
2892 [ "$CLIENTONLY" ] && return 0 || true
2893 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2899 MGS=$(facet_host mgs)
2900 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2904 remote_ost && remote_mds
2909 remote_mds_nodsh || remote_ost_nodsh || \
2910 $(single_local_node $(comma_list $(nodes_list)))
2918 for facet in ${facets//,/ }; do
2919 if [ "$FAILURE_MODE" = HARD ]; then
2920 nodes="$nodes $(facet_active_host $facet)"
2922 nodes="$nodes $(facet_host $facet)"
2925 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
2931 local facets=$(get_facets OST)
2932 local nodes=$(facets_nodes $facets)
2938 # FIXME. We need a list of clients
2939 local myNODES=$HOSTNAME
2942 # CLIENTS (if specified) contains the local client
2943 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2945 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2946 myNODES="$myNODES $(facets_nodes $(get_facets))"
2949 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2954 remote_nodes_list () {
2955 local rnodes=$(nodes_list)
2956 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2960 init_clients_lists () {
2961 # Sanity check: exclude the local client from RCLIENTS
2962 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2964 # Sanity check: exclude the dup entries
2965 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2967 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2969 # Sanity check: exclude the dup entries from CLIENTS
2970 # for those configs which has SINGLCLIENT set to local client
2971 clients=$(for i in $clients; do echo $i; done | sort -u)
2973 CLIENTS=`comma_list $clients`
2974 local -a remoteclients=($rclients)
2975 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2976 varname=CLIENT$((i + 2))
2977 eval $varname=${remoteclients[i]}
2980 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2983 get_random_entry () {
2986 rnodes=${rnodes//,/ }
2988 local -a nodes=($rnodes)
2989 local num=${#nodes[@]}
2990 local i=$((RANDOM * num * 2 / 65536))
2996 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3001 lctl get_param version | grep -q patchless
3005 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3010 echo $nodes | wc -w || true
3014 local nodes=$(osts_nodes)
3015 local osscount=$(get_node_count "$nodes")
3016 [ ! "$OSTCOUNT" = "$osscount" ]
3019 generate_machine_file() {
3020 local nodes=${1//,/ }
3021 local machinefile=$2
3023 for node in $nodes; do
3024 echo $node >>$machinefile || \
3025 { echo "can not generate machinefile $machinefile" && return 1; }
3030 local file=$1/stripe
3032 $LFS getstripe -v $file || error
3036 setstripe_nfsserver () {
3039 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3040 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3042 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3044 do_nodev $nfsserver lfs setstripe "$@"
3047 check_runas_id_ret() {
3049 local myRUNAS_UID=$1
3050 local myRUNAS_GID=$2
3053 if [ -z "$myRUNAS" ]; then
3054 error_exit "myRUNAS command must be specified for check_runas_id"
3056 mkdir $DIR/d0_runas_test
3058 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3059 if ! $myRUNAS touch $DIR/d0_runas_test/f$$ ; then
3060 do_nodesv $(comma_list $(nodes_list)) grep -w $myRUNAS_UID /etc/passwd
3063 rm -rf $DIR/d0_runas_test
3068 local myRUNAS_UID=$1
3069 local myRUNAS_GID=$2
3072 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3073 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3074 Please set RUNAS_ID to some UID which exists on MDS and client or
3075 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3078 # Run multiop in the background, but wait for it to print
3079 # "PAUSING" to its stdout before returning from this function.
3080 multiop_bg_pause() {
3081 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3085 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3088 echo "$MULTIOP_PROG $FILE v$ARGS"
3089 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3091 echo "TMPPIPE=${TMPPIPE}"
3092 local multiop_output
3094 read -t 60 multiop_output < $TMPPIPE
3095 if [ $? -ne 0 ]; then
3100 if [ "$multiop_output" != "PAUSING" ]; then
3101 echo "Incorrect multiop output: $multiop_output"
3116 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3122 inodes_available () {
3123 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3127 mdsrate_inodes_available () {
3128 echo $(($(inodes_available) - 1))
3131 # reset llite stat counters
3132 clear_llite_stats(){
3133 lctl set_param -n llite.*.stats 0
3136 # sum llite stat items
3137 calc_llite_stats() {
3138 local res=$(lctl get_param -n llite.*.stats |
3139 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3144 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3147 calc_osc_kbytes () {
3148 df $MOUNT > /dev/null
3149 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
3152 # save_lustre_params(node, parameter_mask)
3153 # generate a stream of formatted strings (<node> <param name>=<param value>)
3154 save_lustre_params() {
3156 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3159 # restore lustre parameters from input stream, produces by save_lustre_params
3160 restore_lustre_params() {
3164 while IFS=" =" read node name val; do
3165 do_node ${node//:/} "lctl set_param -n $name $val"
3169 check_catastrophe() {
3170 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3171 local C=$CATASTROPHE
3172 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3174 if [ $rnodes ]; then
3175 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3176 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3192 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3194 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3195 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3196 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3200 mdsrate_cleanup () {
3201 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3204 delayed_recovery_enabled () {
3205 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
3208 ################################################################################
3209 # The following functions are used to enable interop testing between
3210 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
3212 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
3213 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
3214 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
3215 ################################################################################
3217 get_lustre_version () {
3218 local node=${1:-"mds"}
3219 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3222 get_mds_version_major () {
3223 local version=$(get_lustre_version mds)
3224 echo $version | awk -F. '{print $1}'
3227 get_mds_version_minor () {
3228 local version=$(get_lustre_version mds)
3229 echo $version | awk -F. '{print $2}'
3232 get_mds_version_patch () {
3233 local version=$(get_lustre_version mds)
3234 echo $version | awk -F. '{print $3}'
3237 get_mds_version_fix () {
3238 local version=$(get_lustre_version mds)
3239 echo $version | awk -F. '{print $4}'
3242 get_kernel_version () {
3243 local facet=${1:-"mds"}
3244 do_facet $facet uname -r | awk -F "-" '{print $1}'
3247 get_mds_kernel_major () {
3248 local version=$(get_kernel_version mds)
3249 echo $version | awk -F. '{print $1"."$2}'
3252 get_mds_kernel_minor () {
3253 local version=$(get_kernel_version mds)
3254 echo $version | awk -F. '{print $3}'
3257 get_mds_fsstat_proc_path() {
3258 local major=$(get_mds_version_major)
3259 local minor=$(get_mds_version_minor)
3260 if [ $major -le 1 -a $minor -le 8 ] ; then
3267 get_mds_mntdev_proc_path() {
3268 local fsstat_dev=$(get_mds_fsstat_proc_path)
3269 echo "$fsstat_dev.*.mntdev"
3272 get_mdtlov_proc_path() {
3274 local major=$(get_mds_version_major)
3275 local minor=$(get_mds_version_minor)
3276 if [ $major -le 1 -a $minor -le 8 ] ; then
3277 echo "${fsname}-mdtlov"
3279 echo "${fsname}-MDT0000-mdtlov"
3283 get_mdtosc_proc_path() {
3285 local major=$(get_mds_version_major)
3286 local minor=$(get_mds_version_minor)
3287 if [ $major -le 1 -a $minor -le 8 ] ; then
3290 echo "${ost}-osc-MDT0000"
3294 get_mds_mdt_device_proc_path() {
3295 local major=$(get_mds_version_major)
3296 local minor=$(get_mds_version_minor)
3297 if [ $major -le 1 -a $minor -le 8 ] ; then
3305 local major=$(get_mds_version_major)
3306 local minor=$(get_mds_version_minor)
3307 if [ $major -le 1 -a $minor -le 8 ] ; then
3314 ########################
3316 convert_facet2label() {
3319 if [ x$facet = xost ]; then
3323 local varsvc=${facet}_svc
3325 if [ -n ${!varsvc} ]; then
3328 error "No lablel for $facet!"
3332 get_clientosc_proc_path() {
3338 get_osc_import_name() {
3341 local label=$(convert_facet2label $ost)
3343 if [ "$facet" == "mds" ]; then
3344 get_mdtosc_proc_path $label
3348 get_clientosc_proc_path $label
3352 _wait_import_state () {
3355 local maxtime=${3:-max_recovery_time}
3359 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3360 while [ "${CONN_STATE}" != "${expected}" ]; do
3361 [ $i -ge $maxtime ] && \
3362 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3365 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3369 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3373 wait_import_state() {
3376 local maxtime=${3:-max_recovery_time}
3379 for param in ${params//,/ }; do
3380 _wait_import_state $state $param $maxtime || return
3383 wait_osc_import_state() {
3387 local ost=$(get_osc_import_name $facet $ost_facet)
3392 CONN_PROC="osc.${ost}.ost_server_uuid"
3393 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3394 while [ "${CONN_STATE}" != "${expected}" ]; do
3395 if [ "${expected}" == "DISCONN" ]; then
3396 # for disconn we can check after proc entry is removed
3397 [ "x${CONN_STATE}" == "x" ] && return 0
3398 # with AT enabled, we can have connect request timeout near of
3399 # reconnect timeout and test can't see real disconnect
3400 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3402 # disconnect rpc should be wait not more obd_timeout
3403 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3404 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3406 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3410 log "${ost_facet} now in ${CONN_STATE} state"
3414 get_clientmdc_proc_path() {
3422 local RPATH="PATH=$LUSTRE/tests/:$PATH"
3423 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3426 wait_clients_import_state () {
3433 if [ "$FAILURE_MODE" = HARD ]; then
3434 facets=$(facets_on_host $(facet_active_host $facet))
3437 for facet in ${facets//,/ }; do
3438 local label=$(convert_facet2label $facet)
3441 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3442 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3443 *) error "unknown facet!" ;;
3445 local params=$(expand_list $params $proc_path)
3448 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3449 error "import is not in ${expected} state"
3454 destroy_pool_int() {
3456 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
3457 for ost in $OSTS; do
3458 do_facet mgs lctl pool_remove $1 $ost
3460 do_facet mgs lctl pool_destroy $1
3463 # <fsname>.<poolname> or <poolname>
3465 local fsname=${1%%.*}
3466 local poolname=${1##$fsname.}
3468 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3472 pool_list $fsname.$poolname || return $?
3474 destroy_pool_int $fsname.$poolname
3476 [[ $RC -ne 0 ]] && return $RC
3478 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3479 2>/dev/null || echo foo" "foo" || RC=1
3481 if [[ $RC -eq 0 ]]; then
3482 remove_pool_from_list $fsname.$poolname
3484 error "destroy pool failed $1"
3490 local fsname=${1:-$FSNAME}
3492 local listvar=${fsname}_CREATED_POOLS
3496 [ x${!listvar} = x ] && return 0
3498 echo destroy the created pools: ${!listvar}
3499 for poolname in ${!listvar//,/ }; do
3500 destroy_pool $fsname.$poolname
3505 local fsname=${1:-$FSNAME}
3507 destroy_pools $fsname
3513 local ts=$(date +%s)
3515 # bug 20237, comment 11
3516 # It would also be useful to provide the option
3517 # of writing the file to an NFS directory so it doesn't need to be copied.
3520 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3522 # dump lustre logs, dmesg
3523 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3524 lctl dk \\\$log >/dev/null;
3525 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3528 # FIXME: does it make sense to collect the logs for $ts only, but all
3530 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3531 local logs=$TMP/'*'${TESTSUITE}'*'
3533 logs=$logs' '$tmp/'*'$ts'*'
3535 for node in ${list//,/ }; do
3536 rsync -az $node:"$logs" $TMP
3539 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3540 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3546 local list=${1:-$(comma_list $(nodes_list))}
3548 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3560 for i in $(seq 0 $num_mntpts); do
3561 cmd="ls -laf ${mntpt_root}$i/$dir"
3567 for pid in $pids; do
3574 # target_start_and_reset_recovery_timer()
3575 # service_time = at_est2timeout(service_time);
3576 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3577 # INITIAL_CONNECT_TIMEOUT);
3578 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3579 #define CONNECTION_SWITCH_INC 1
3580 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3581 #define CONNECTION_SWITCH_MIN 5U
3583 max_recovery_time () {
3584 local init_connect_timeout=$(( TIMEOUT / 20 ))
3585 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
3587 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
3592 remove_mdt_files() {
3597 local mntpt=${MOUNT%/*}/$facet
3599 echo "removing files from $mdtdev on $facet: $files"
3600 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3603 rm $mntpt/ROOT/$f || { rc=$?; break; }
3605 umount -f $mntpt || return $?
3609 duplicate_mdt_files() {
3614 local mntpt=${MOUNT%/*}/$facet
3616 echo "duplicating files on $mdtdev on $facet: $files"
3617 mkdir -p $mntpt || return $?
3618 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3628 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
3629 pushd $mntpt/ROOT > /dev/null || return $?
3632 touch $f.bad || return $?
3633 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
3635 [ $rc -eq 0 ] || return $rc
3636 setfattr --restore $tmp || return $?
3642 local devs=${1//,/ }
3645 local rslt=$TMP/sgpdd_survey
3647 # sgpdd-survey cleanups ${rslt}.* files
3649 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
3655 # returns the canonical name for an ldiskfs device
3660 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
3661 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
3662 echo dm-\\\${foo##*:};
3664 echo \\\$(basename \\\$dv);
3668 is_sanity_benchmark() {
3669 local benchmarks="dbench bonnie iozone fsx"
3671 for b in $benchmarks; do
3672 if [ "$b" == "$suite" ]; then
3680 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1