2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && touch $TF_FAIL && \
5 echo "test-framework exiting on error"' ERR
10 export REFORMAT=${REFORMAT:-""}
11 export WRITECONF=${WRITECONF:-""}
12 export VERBOSE=${VERBOSE:-false}
13 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
14 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 #export PDSH="pdsh -S -Rssh -w"
17 # function used by scripts run on remote nodes
18 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
19 . $LUSTRE/tests/functions.sh
20 . $LUSTRE/tests/yaml.sh
22 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
24 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
26 if [ -f "$EXCEPT_LIST_FILE" ]; then
27 echo "Reading test skip list from $EXCEPT_LIST_FILE"
32 # check config files for options in decreasing order of preference
33 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/lustre.conf ] &&
34 MODPROBECONF=/etc/modprobe.d/lustre.conf
35 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] &&
36 MODPROBECONF=/etc/modprobe.d/Lustre
37 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] &&
38 MODPROBECONF=/etc/modprobe.conf
42 [[ $DIR/ = $MOUNT/* ]] || \
43 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
44 [[ $DIR1/ = $MOUNT1/* ]] || \
45 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
46 [[ $DIR2/ = $MOUNT2/* ]] || \
47 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
49 [ -n "$failed" ] && exit 99 || true
53 echo "usage: $0 [-r] [-f cfgfile]"
61 [ "$TESTSUITE" == "lfsck" ] && return 0
62 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
64 local form="%-13s %-17s %-9s %s %s\n"
65 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
66 echo "------------------------------------------------------------------------------------"
67 for O in $DEFAULT_SUITES; do
68 [ "${!O}" = "no" ] && continue || true
69 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
70 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
72 local log=${TMP}/${o}.log
73 if is_sanity_benchmark $o; then
74 log=${TMP}/sanity-benchmark.log
79 local status=Unfinished
81 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
82 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | sort -nr -k 3 | head -5 | awk '{ print $2":"$3"s" }')
83 total=$(grep duration $log | awk '{ print $2}')
84 if [ "${!O}" = "done" ]; then
88 local durations=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | awk '{ print $2":"$3"|" }')
89 details=$(printf "%s\n%s %s %s\n" "$details" "DDETAILS" "$O" "$(echo $durations)")
92 printf "$form" $status "$O" "${total}" "E=$skipped"
93 printf "$form" "-" "-" "-" "S=$(echo $slow)"
96 for O in $DEFAULT_SUITES; do
97 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
98 if [ "${!O}" = "no" ]; then
100 # only for those tests suits which are run directly from acc-sm script:
101 # bonnie, iozone, etc.
102 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
103 printf "$form" "UNFINISHED" "$O" ""
105 printf "$form" "Skipped" "$O" ""
110 for O in $DEFAULT_SUITES; do
111 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
112 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
113 printf "$form" "UNFINISHED" "$O" ""
118 export LUSTRE=`absolute_path $LUSTRE`
119 export TESTSUITE=`basename $0 .sh`
120 export TEST_FAILED=false
121 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
123 export MKE2FS=${MKE2FS:-mke2fs}
124 export DEBUGFS=${DEBUGFS:-debugfs}
125 export TUNE2FS=${TUNE2FS:-tune2fs}
126 export E2LABEL=${E2LABEL:-e2label}
127 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
128 export E2FSCK=${E2FSCK:-e2fsck}
129 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
131 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
132 export FSCK_MAX_ERR=4 # File system errors left uncorrected
135 #[ -d /r ] && export ROOT=${ROOT:-/r}
136 export TMP=${TMP:-$ROOT/tmp}
137 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
138 export LOGDIR=${LOGDIR:-${TMP}/test_logs/$(date +%s)}
139 export TESTLOG_PREFIX=$LOGDIR/$TESTSUITE
141 export HOSTNAME=${HOSTNAME:-`hostname -s`}
142 if ! echo $PATH | grep -q $LUSTRE/utils; then
143 export PATH=$PATH:$LUSTRE/utils
145 if ! echo ":$PATH:" | grep -q ":$LUSTRE/tests:"; then
146 export PATH=$LUSTRE/tests:$PATH
148 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
149 export PATH=$PATH:$LUSTRE/../lustre-iokit/sgpdd-survey
151 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
152 [ ! -f "$LST" ] && export LST=$(which lst)
153 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
154 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
155 # Ubuntu, at least, has a truncate command in /usr/bin
156 # so fully path our truncate command.
157 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
158 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
159 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
160 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
161 export PATH=$LUSTRE/tests/racer:$PATH:
163 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
164 export PATH=$PATH:$LUSTRE/tests/mpi
166 export RSYNC_RSH=${RSYNC_RSH:-rsh}
167 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
168 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
169 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
170 [ ! -f "$LFS" ] && export LFS=$(which lfs)
171 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
172 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
173 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
174 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
175 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
176 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
177 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
178 export FSTYPE=${FSTYPE:-"ldiskfs"}
179 export NAME=${NAME:-local}
181 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
183 if [ "$ACCEPTOR_PORT" ]; then
184 export PORT_OPT="--port $ACCEPTOR_PORT"
187 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
189 # Paths on remote nodes, if different
190 export RLUSTRE=${RLUSTRE:-$LUSTRE}
191 export RPWD=${RPWD:-$PWD}
192 export I_MOUNTED=${I_MOUNTED:-"no"}
193 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
194 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
195 ! -f `dirname $0`/../mds/mds.ko ]; then
196 export CLIENTMODSONLY=yes
199 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
203 while getopts "rvwf:" opt $*; do
206 r) REFORMAT=--reformat;;
208 w) WRITECONF=writeconf;;
213 shift $((OPTIND - 1))
216 # print the durations of each test if "true"
217 DDETAILS=${DDETAILS:-false}
218 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
224 *) EXT=".ko"; USE_QUOTA=yes;;
228 do_facet mgs lctl pool_list $1
232 local fsname=${1%%.*}
233 local poolname=${1##$fsname.}
235 do_facet mgs lctl pool_new $1
237 # get param should return err unless pool is created
238 [[ $RC -ne 0 ]] && return $RC
240 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
241 2>/dev/null || echo foo" "" || RC=1
242 if [[ $RC -eq 0 ]]; then
245 error "pool_new failed $1"
250 add_pool_to_list () {
251 local fsname=${1%%.*}
252 local poolname=${1##$fsname.}
254 local listvar=${fsname}_CREATED_POOLS
255 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
258 remove_pool_from_list () {
259 local fsname=${1%%.*}
260 local poolname=${1##$fsname.}
262 local listvar=${fsname}_CREATED_POOLS
263 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
267 /sbin/lsmod | grep -q $1
273 BASE=`basename $module $EXT`
275 module_loaded ${BASE} && return
277 if [ "$BASE" == "lnet_selftest" ] && \
278 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
279 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
281 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
282 insmod ${LUSTRE}/${module}${EXT} $@
284 # must be testing a "make install" or "rpm" installation
289 load_module_llite_lloop() {
290 local n1=$(uname -r | cut -d. -f1)
291 local n2=$(uname -r | cut -d. -f2)
292 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
294 # load the llite_lloop module for < 2.6.32 kernels
295 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
296 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]]; then
297 load_module llite/llite_lloop
301 load_modules_local() {
302 if [ -n "$MODPROBE" ]; then
306 if [ "$HAVE_MODULES" = true ]; then
312 echo Loading modules from $LUSTRE
313 load_module ../lnet/libcfs/libcfs
314 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
315 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
316 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
317 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
318 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
320 # disable it for now since it only hides the stack overflow upon test w/
322 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
323 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
324 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
326 echo "lnet options: '$LNETOPTS'"
327 # note that insmod will ignore anything in modprobe.conf
328 load_module ../lnet/lnet/lnet $LNETOPTS
329 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
330 load_module ../lnet/klnds/$LNETLND
331 load_module lvfs/lvfs
332 load_module obdclass/obdclass
333 load_module ptlrpc/ptlrpc
334 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota $LQUOTAOPTS
339 if ! client_only; then
342 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
343 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
344 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
345 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
346 load_module lvfs/fsfilt_$FSTYPE
348 load_module obdfilter/obdfilter
351 load_module llite/lustre
352 load_module_llite_lloop
353 rm -f $TMP/ogdb-$HOSTNAME
355 [ -d /r ] && OGDB="/r/tmp"
356 $LCTL modules > $OGDB/ogdb-$HOSTNAME
357 # 'mount' doesn't look in $PATH, just sbin
358 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
364 # load modules on remote nodes optionally
365 # lustre-tests have to be installed on these nodes
366 if $LOAD_MODULES_REMOTE ; then
367 local list=$(comma_list $(remote_nodes_list))
368 echo loading modules on $list
369 do_rpc_nodes $list load_modules
374 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
375 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
376 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
377 echo "$LEAK_LUSTRE" 1>&2
378 echo "$LEAK_PORTALS" 1>&2
379 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
380 echo "Memory leaks detected"
381 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
387 wait_exit_ST client # bug 12845
389 if $LOAD_MODULES_REMOTE ; then
390 local list=$(comma_list $(remote_nodes_list))
391 if [ ! -z $list ]; then
392 echo unloading modules on $list
393 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
394 do_rpc_nodes $list check_mem_leak
398 $LUSTRE_RMMOD $FSTYPE || return 2
402 check_mem_leak || return 254
404 echo "modules unloaded."
409 local dz=${1:-$DEBUG_SIZE}
410 local cpus=$(getconf _NPROCESSORS_CONF)
412 # bug 19944, adjust size to be -gt num_possible_cpus()
413 # promise 2MB for every cpu at least
414 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
417 lctl set_param debug_mb=$dz
420 set_default_debug () {
421 local debug=${1:-"$PTLDEBUG"}
422 local subsystem_debug=${2:-"$SUBSYSTEM"}
423 local debug_size=${3:-$DEBUG_SIZE}
425 lctl set_param debug="$debug"
426 lctl set_param subsystem_debug="${subsystem_debug# }"
428 set_debug_size $debug_size
432 set_default_debug_nodes () {
435 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
436 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
440 [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
441 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
444 set_default_debug_facet () {
446 local node=$(facet_active_host $facet)
447 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
449 set_default_debug_nodes $node
454 local facets=${1:-$(get_facets)}
457 for facet in ${facets//,/ }; do
458 mount_facet $facet || error "Restart of $facet failed!"
465 local dev=$(facet_active $facet)_dev
466 local opt=${facet}_opt
467 local mntpt=$(facet_mntpt $facet)
469 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
470 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
472 if [ $RC -ne 0 ]; then
473 echo "mount -t lustre $@ ${!dev} $mntpt"
474 echo "Start of ${!dev} on ${facet} failed ${RC}"
476 set_default_debug_facet $facet
478 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
479 [ -z "$label" ] && echo no label for ${!dev} && exit 1
480 eval export ${facet}_svc=${label}
481 echo Started ${label}
486 # start facet device options
492 eval export ${facet}_dev=${device}
493 eval export ${facet}_opt=\"$@\"
495 local varname=${facet}failover_dev
496 if [ -n "${!varname}" ] ; then
497 eval export ${facet}failover_dev=${!varname}
499 eval export ${facet}failover_dev=$device
502 local mntpt=$(facet_mntpt $facet)
503 do_facet ${facet} mkdir -p $mntpt
504 eval export ${facet}_MOUNT=$mntpt
514 local HOST=`facet_active_host $facet`
515 [ -z $HOST ] && echo stop: no host for $facet && return 0
517 local mntpt=$(facet_mntpt $facet)
518 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
519 if [ ${running} -ne 0 ]; then
520 echo "Stopping $mntpt (opts:$@)"
521 do_facet ${facet} umount -d $@ $mntpt
524 # umount should block, but we should wait for unrelated obd's
525 # like the MGS or MGC to also stop.
527 wait_exit_ST ${facet}
530 # set quota version (both administrative and operational quotas)
531 quota_set_version() {
532 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
534 local osts=$(get_facets OST)
535 for ost in ${osts//,/ }; do
537 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
541 # save quota version (both administrative and operational quotas)
542 # the function will also switch to the new version and the new type
543 quota_save_version() {
545 local ver=$(tr -c -d "123" <<< $spec)
546 local type=$(tr -c -d "ug" <<< $spec)
548 local lustre_version=$(get_lustre_version mds)
549 if [[ $lustre_version = 1.8* ]] ; then
550 $LFS quotaoff -ug $MOUNT # just in case
551 [ -n "$ver" ] && quota_set_version $ver
553 echo mds running $lustre_version
554 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
557 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
559 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.$(get_md_name).quota_type=$spec"
561 local osts=$(get_facets OST)
562 for ost in ${osts//,/ }; do
564 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
568 # client could mount several lustre
570 local fsname=${1:-$FSNAME}
572 do_facet mgs lctl get_param md*.${fsname}-MDT*.quota_type || rc=$?
573 do_nodes $(comma_list $(osts_nodes)) \
574 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
578 restore_quota_type () {
579 local mntpt=${1:-$MOUNT}
580 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
581 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
584 quota_save_version $old_QUOTA_TYPE
591 # 1. run quotacheck only if quota is off
592 # 2. save the original quota_type params, restore them after testing
594 # Suppose that quota type the same on mds and ost
595 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
596 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
597 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
598 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
599 export old_QUOTA_TYPE=$quota_type
600 quota_save_version $QUOTA_TYPE
603 local quota_usrs=$QUOTA_USERS
605 # get_filesystem_size
606 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
607 local blk_soft=$((disksz + 1024))
608 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
610 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
612 local i_hard=$((i_soft + i_soft / 20))
614 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
615 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
618 for usr in $quota_usrs; do
619 echo "Setting up quota on $client:$mntpt for $usr..."
621 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
623 eval $cmd || error "$cmd FAILED!"
625 # display the quota status
626 echo "Quota settings for $usr : "
627 $LFS quota -v -u $usr $mntpt || true
634 local OPTIONS=${3:-$MOUNTOPT}
636 local device=$MGSNID:/$FSNAME
637 if [ -z "$mnt" -o -z "$FSNAME" ]; then
638 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
642 echo "Starting client: $client: $OPTIONS $device $mnt"
643 do_node $client mkdir -p $mnt
644 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
645 set_default_debug_nodes $client
658 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
659 if [ $running -ne 0 ]; then
660 echo "Stopping client $client $mnt (opts:$force)"
661 do_node $client lsof -t $mnt || need_kill=no
662 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
663 pids=$(do_node $client lsof -t $mnt | sort -u);
664 if [ -n $pids ]; then
665 do_node $client kill -9 $pids || true
669 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
670 if [ $busy -ne 0 ] ; then
671 echo "$mnt is still busy, wait one second" && sleep 1
672 do_node $client umount $force $mnt
677 # nodes is comma list
678 sanity_mount_check_nodes () {
684 # FIXME: assume that all cluster nodes run the same os
685 [ "$(uname)" = Linux ] || return 0
688 for mnt in $mnts ; do
689 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
690 mpts=\\\$(mount | grep -c $mnt' ');
691 if [ \\\$running -ne \\\$mpts ]; then
692 echo \\\$(hostname) env are INSANE!;
700 sanity_mount_check_servers () {
702 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
703 echo Checking servers environments
705 # FIXME: modify get_facets to display all facets wo params
706 local facets="$(get_facets OST),$(get_facets MDS),mgs"
710 for facet in ${facets//,/ }; do
711 node=$(facet_host ${facet})
712 mntpt=$(facet_mntpt $facet)
713 sanity_mount_check_nodes $node $mntpt ||
714 { error "server $node environments are insane!"; return 1; }
718 sanity_mount_check_clients () {
719 local clients=${1:-$CLIENTS}
720 local mntpt=${2:-$MOUNT}
721 local mntpt2=${3:-$MOUNT2}
723 [ -z $clients ] && clients=$(hostname)
724 echo Checking clients $clients environments
726 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
727 error "clients environments are insane!"
730 sanity_mount_check () {
731 sanity_mount_check_servers || return 1
732 sanity_mount_check_clients || return 2
735 # mount clients if not mouted
736 zconf_mount_clients() {
739 local OPTIONS=${3:-$MOUNTOPT}
741 local device=$MGSNID:/$FSNAME
742 if [ -z "$mnt" -o -z "$FSNAME" ]; then
743 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
747 echo "Starting client $clients: $OPTIONS $device $mnt"
750 running=\\\$(mount | grep -c $mnt' ');
752 if [ \\\$running -eq 0 ] ; then
754 mount -t lustre $OPTIONS $device $mnt;
759 echo "Started clients $clients: "
760 do_nodes $clients "mount | grep $mnt' '"
762 set_default_debug_nodes $clients
767 zconf_umount_clients() {
774 echo "Stopping clients: $clients $mnt (opts:$force)"
775 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
776 if [ \\\$running -ne 0 ] ; then
777 echo Stopping client \\\$(hostname) $mnt opts:$force;
778 lsof -t $mnt || need_kill=no;
779 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
780 pids=\\\$(lsof -t $mnt | sort -u);
781 if [ -n \\\"\\\$pids\\\" ]; then
785 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
786 if [ \\\$busy -ne 0 ] ; then
787 echo "$mnt is still busy, wait one second" && sleep 1;
795 echo + $POWER_DOWN $node
799 shutdown_node_hard () {
801 local attempts=$SHUTDOWN_ATTEMPTS
803 for i in $(seq $attempts) ; do
806 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
807 echo "waiting for $host to fail attempts=$attempts"
808 [ $i -lt $attempts ] || \
809 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
815 local mnt=${2:-$MOUNT}
818 if [ "$FAILURE_MODE" = HARD ]; then
819 shutdown_node_hard $client
821 zconf_umount_clients $client $mnt -f
827 local facets="$(get_facets OST),$(get_facets MDS)"
830 combined_mgs_mds || facets="$facets,mgs"
832 for facet in ${facets//,/ }; do
833 if [ $(facet_active_host $facet) == $host ]; then
834 affected="$affected $facet"
838 echo $(comma_list $affected)
843 local host=${2:-$(facet_host $facet)}
845 local label=$(convert_facet2label $facet)
846 do_node $host lctl dl | awk '{print $4}' | grep -q $label
849 facets_up_on_host () {
851 local facets=$(facets_on_host $host)
854 for facet in ${facets//,/ }; do
855 if $(facet_up $facet $host); then
856 affected_up="$affected_up $facet"
860 echo $(comma_list $affected_up)
866 if [ "$FAILURE_MODE" = HARD ]; then
867 shutdown_node_hard $(facet_active_host $facet)
875 echo + $POWER_UP $node
888 if [ "$FAILURE_MODE" = HARD ]; then
889 reboot_node $(facet_active_host $facet)
897 if [ "$FAILURE_MODE" = HARD ]; then
907 for facet in ${facets//,/ }; do
908 hosts=$(expand_list $hosts $(facet_host $facet) )
914 _check_progs_installed () {
918 for prog in $progs; do
919 if ! [ "$(which $prog)" -o "${!prog}" ]; then
920 echo $prog missing on $(hostname)
927 check_progs_installed () {
931 do_rpc_nodes $nodes _check_progs_installed $@
939 start_client_load() {
942 local var=$(node_var_name $client)_load
943 eval export ${var}=$load
945 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
946 BREAK_ON_ERROR=$BREAK_ON_ERROR \
947 END_RUN_FILE=$END_RUN_FILE \
948 LOAD_PID_FILE=$LOAD_PID_FILE \
949 TESTLOG_PREFIX=$TESTLOG_PREFIX \
951 DBENCH_LIB=$DBENCH_LIB \
952 DBENCH_SRC=$DBENCH_SRC \
955 log "Started client load: ${load} on $client"
957 # get the children process IDs
958 local pids=$(ps --ppid $ppid -o pid= | xargs)
959 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
963 start_client_loads () {
964 local -a clients=(${1//,/ })
965 local numloads=${#CLIENT_LOADS[@]}
968 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
969 testnum=$((nodenum % numloads))
970 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
972 # bug 22169: wait the background threads to start
976 # only for remote client
977 check_client_load () {
979 local var=$(node_var_name $client)_load
980 local TESTLOAD=run_${!var}.sh
982 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
984 # bug 18914: try to connect several times not only when
985 # check ps, but while check_catastrophe also
988 while [ $RC = 254 -a $tries -gt 0 ]; do
992 if ! check_catastrophe $client; then
994 if [ $RC -eq 254 ]; then
995 # FIXME: not sure how long we shuold sleep here
999 echo "check catastrophe failed: RC=$RC "
1004 # We can continue try to connect if RC=254
1005 # Just print the warning about this
1006 if [ $RC = 254 ]; then
1007 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1010 # see if the load is still on the client
1013 while [ $RC = 254 -a $tries -gt 0 ]; do
1017 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1022 if [ $RC = 254 ]; then
1023 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1024 # see if we can diagnose a bit why this is
1029 check_client_loads () {
1030 local clients=${1//,/ }
1034 for client in $clients; do
1035 check_client_load $client
1037 if [ "$rc" != 0 ]; then
1038 log "Client load failed on node $client, rc=$rc"
1044 restart_client_loads () {
1045 local clients=${1//,/ }
1046 local expectedfail=${2:-""}
1050 for client in $clients; do
1051 check_client_load $client
1053 if [ "$rc" != 0 -a "$expectedfail" ]; then
1054 local var=$(node_var_name $client)_load
1055 start_client_load $client ${!var}
1056 echo "Restarted client load ${!var}: on $client. Checking ..."
1057 check_client_load $client
1059 if [ "$rc" != 0 ]; then
1060 log "Client load failed to restart on node $client, rc=$rc"
1061 # failure one client load means test fail
1062 # we do not need to check other
1071 # Start vmstat and save its process ID in a file.
1076 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1079 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
1080 2>/dev/null </dev/null & echo \\\$! > $pid_file"
1083 # Display the nodes on which client loads failed.
1084 print_end_run_file() {
1088 [ -s $file ] || return 0
1090 echo "Found the END_RUN_FILE file: $file"
1093 # A client load will stop if it finds the END_RUN_FILE file.
1094 # That does not mean the client load actually failed though.
1095 # The first node in END_RUN_FILE is the one we are interested in.
1098 if [ -n "$node" ]; then
1099 local var=$(node_var_name $node)_load
1101 local prefix=$TESTLOG_PREFIX
1102 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
1103 local stdout_log=$prefix.run_${!var}_stdout.$node.log
1104 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
1106 echo "Client load ${!var} failed on node $node:"
1112 # Stop the process which had its PID saved in a file.
1117 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1119 do_nodes $nodes "test -f $pid_file &&
1120 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
1123 # Stop all client loads.
1124 stop_client_loads() {
1125 local nodes=${1:-$CLIENTS}
1128 # stop the client loads
1129 stop_process $nodes $pid_file
1131 # clean up the processes that started them
1132 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
1135 # verify that lustre actually cleaned up properly
1137 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1138 error "LBUG/LASSERT detected"
1139 BUSY=`dmesg | grep -i destruct || true`
1140 if [ "$BUSY" ]; then
1142 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1146 check_mem_leak || exit 204
1148 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1149 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1151 if module_loaded lnet || module_loaded libcfs; then
1152 echo "$0: modules still loaded..." 1>&2
1169 RESULT=$(do_node $node "$TEST")
1170 if [ "$RESULT" == "$FINAL" ]; then
1171 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1174 [ $WAIT -ge $MAX ] && break
1175 echo "Waiting $((MAX - WAIT)) secs for update"
1176 WAIT=$((WAIT + sleep))
1179 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1183 wait_update_facet () {
1186 wait_update $(facet_active_host $facet) "$@"
1189 wait_delete_completed_mds() {
1190 [[ $(lustre_version_code mds) -lt $(version_code 2.2.58) ]] &&
1193 local MAX_WAIT=${1:-20}
1195 local stime=`date +%s`
1200 # find MDS with pending deletions
1201 for node in $(mdts_nodes); do
1202 changes=$(do_node $node "lctl get_param -n osc.*MDT*.sync_*" \
1203 2>/dev/null | calc_sum)
1204 if [ -z "$changes" ] || [ $changes -eq 0 ]; then
1207 mds2sync="$mds2sync $node"
1209 if [ "$mds2sync" == "" ]; then
1212 mds2sync=$(comma_list $mds2sync)
1214 # sync MDS transactions
1215 do_nodes $mds2sync "lctl set_param -n osd*.*MD*.force_sync 1"
1217 # wait till all changes are sent and commmitted by OSTs
1218 # for ldiskfs space is released upon execution, but DMU
1219 # do this upon commit
1222 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1223 changes=$(do_nodes $mds2sync "lctl get_param -n osc.*MDT*.sync_*" \
1225 #echo "$node: $changes changes on all"
1226 if [ "$changes" -eq "0" ]; then
1228 #echo "delete took $((etime - stime)) seconds"
1236 echo "Delete is not completed in $((etime - stime)) seconds"
1237 do_nodes $mds2sync "lctl get_param osc.*MDT*.sync_*"
1243 # we can use "for" here because we are waiting the slowest
1244 for host in ${hostlist//,/ }; do
1245 check_network "$host" 900
1247 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1254 for facet in ${facetlist//,/ }; do
1255 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1257 wait_for_host $hostlist
1260 _wait_recovery_complete () {
1263 # Use default policy if $2 is not passed by caller.
1264 local MAX=${2:-$(max_recovery_time)}
1269 while [ $WAIT -lt $MAX ]; do
1270 STATUS=$(lctl get_param -n $param | grep status)
1272 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1275 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1277 echo "$param recovery not done in $MAX sec. $STATUS"
1281 wait_recovery_complete () {
1284 # with an assumption that at_max is the same on all nodes
1285 local MAX=${2:-$(max_recovery_time)}
1288 if [ "$FAILURE_MODE" = HARD ]; then
1289 facets=$(facets_on_host $(facet_active_host $facet))
1291 echo affected facets: $facets
1293 # we can use "for" here because we are waiting the slowest
1294 for facet in ${facets//,/ }; do
1295 local var_svc=${facet}_svc
1296 local param="*.${!var_svc}.recovery_status"
1298 local host=$(facet_active_host $facet)
1299 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1303 wait_mds_ost_sync () {
1304 # just because recovery is done doesn't mean we've finished
1305 # orphan cleanup. Wait for llogs to get synchronized.
1306 echo "Waiting for orphan cleanup..."
1307 # MAX value includes time needed for MDS-OST reconnection
1308 local MAX=$(( TIMEOUT * 2 ))
1310 while [ $WAIT -lt $MAX ]; do
1311 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1312 "$LCTL get_param -n obdfilter.*.mds_sync"))
1314 for ((i=0; i<${#sync[@]}; i++)); do
1315 [ ${sync[$i]} -eq 0 ] && continue
1316 # there is a not finished MDS-OST synchronization
1320 sleep 2 # increase waiting time and cover statfs cache
1321 [ ${con} -eq 1 ] && return 0
1322 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1325 echo "$facet recovery not done in $MAX sec. $STATUS"
1329 wait_destroy_complete () {
1330 echo "Waiting for local destroys to complete"
1331 # MAX value shouldn't be big as this mean server responsiveness
1332 # never increase this just to make test pass but investigate
1333 # why it takes so long time
1336 while [ $WAIT -lt $MAX ]; do
1337 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1341 for ((i=0; i<${#RPCs[@]}; i++)); do
1342 [ ${RPCs[$i]} -eq 0 ] && continue
1343 # there are still some destroy RPCs in flight
1348 [ ${con} -eq 1 ] && return 0 # done waiting
1349 echo "Waiting ${WAIT}s for local destroys to complete"
1352 echo "Local destroys weren't done in $MAX sec."
1356 wait_delete_completed() {
1357 wait_delete_completed_mds $1 || return $?
1358 wait_destroy_complete
1367 # conf-sanity 31 takes a long time cleanup
1368 while [ $WAIT -lt 300 ]; do
1369 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1370 [ -z "${running}" ] && return 0
1371 echo "waited $WAIT for${running}"
1372 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1374 WAIT=$((WAIT + INTERVAL))
1376 echo "service didn't stop after $WAIT seconds. Still running:"
1381 wait_remote_prog () {
1387 [ "$PDSH" = "no_dsh" ] && return 0
1389 while [ $WAIT -lt $2 ]; do
1390 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1391 [ -z "${running}" ] && return 0 || true
1392 echo "waited $WAIT for: "
1394 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1396 WAIT=$((WAIT + INTERVAL))
1398 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1399 [ -z "$pids" ] && return 0
1400 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1401 # FIXME: not portable
1402 for pid in $pids; do
1403 cat /proc/${pid}/status || true
1404 cat /proc/${pid}/wchan || true
1406 kill -9 $pid || true
1415 # not every config has many clients
1417 if [ -n "$CLIENTS" ]; then
1418 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1420 stat -f $MOUNT > /dev/null
1426 # usually checked on particular client or locally
1428 if [ ! -z "$client" ]; then
1429 $PDSH $client "stat -f $MOUNT" > /dev/null
1431 stat -f $MOUNT > /dev/null
1439 client_reconnect() {
1440 uname -n >> $MOUNT/recon
1441 if [ -z "$CLIENTS" ]; then
1442 df $MOUNT; uname -n >> $MOUNT/recon
1444 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1446 echo Connected clients:
1448 ls -l $MOUNT/recon > /dev/null
1452 affected_facets () {
1455 local host=$(facet_active_host $facet)
1456 local affected=$facet
1458 if [ "$FAILURE_MODE" = HARD ]; then
1459 affected=$(facets_up_on_host $host)
1467 local host=$(facet_active_host $facet)
1469 echo "Failing $facet on node $host"
1471 local affected=$(affected_facets $facet)
1473 shutdown_facet $facet
1475 echo affected facets: $affected
1477 [ -n "$sleep_time" ] && sleep $sleep_time
1482 RECOVERY_START_TIME=`date +%s`
1483 echo "df pid is $dfpid"
1485 change_active $affected
1487 wait_for_facet $affected
1488 # start mgs first if it is affected
1489 if ! combined_mgs_mds && list_member $affected mgs; then
1490 mount_facet mgs || error "Restart of mgs failed"
1492 # FIXME; has to be changed to mount all facets concurrently
1493 affected=$(exclude_items_from_list $affected mgs)
1494 mount_facets $affected
1503 do_facet $facet sync
1505 local svc=${facet}_svc
1506 do_facet $facet $LCTL --device %${!svc} notransno
1507 do_facet $facet $LCTL --device %${!svc} readonly
1508 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1509 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1512 replay_barrier_nodf() {
1513 local facet=$1 echo running=${running}
1514 do_facet $facet sync
1515 local svc=${facet}_svc
1516 echo Replay barrier on ${!svc}
1517 do_facet $facet $LCTL --device %${!svc} notransno
1518 do_facet $facet $LCTL --device %${!svc} readonly
1519 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1520 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1523 mds_evict_client() {
1524 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1525 local mdtdevice=$(get_mds_mdt_device_proc_path)
1526 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1529 ost_evict_client() {
1530 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1531 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1535 facet_failover $* || error "failover: $?"
1536 clients_up || error "post-failover df: $?"
1541 facet_failover $facet
1547 change_active $facet
1548 wait_for_facet $facet
1549 mount_facet $facet -o abort_recovery
1550 clients_up || echo "first df failed: $?"
1551 clients_up || error "post-failover df: $?"
1555 echo There is no lmc. This is mountconf, baby.
1560 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1561 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1567 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1573 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1574 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1575 if [ -z "$ID" ]; then
1576 echo "Could not get a ptl id for $1..."
1585 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1592 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1593 if type __h2elan >/dev/null 2>&1; then
1596 ID=`echo $1 | sed 's/[^0-9]*//g'`
1604 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1605 ID=`echo $1 | sed 's/[^0-9]*//g'`
1609 declare -fx h2openib
1612 h2name_or_ip "$1" "o2ib"
1619 [ "$facet" == client ] && echo -n $HOSTNAME && return
1620 varname=${facet}_HOST
1621 if [ -z "${!varname}" ]; then
1622 if [ "${facet:0:3}" == "ost" ]; then
1623 eval ${facet}_HOST=${ost_HOST}
1631 local activevar=${facet}active
1633 if [ -f $TMP/${facet}active ] ; then
1634 source $TMP/${facet}active
1637 active=${!activevar}
1638 if [ -z "$active" ] ; then
1645 facet_active_host() {
1647 local active=`facet_active $facet`
1648 if [ "$facet" == client ]; then
1651 echo `facet_host $active`
1659 facetlist=$(exclude_items_from_list $facetlist mgs)
1661 for facet in ${facetlist//,/ }; do
1662 local failover=${facet}failover
1663 local host=`facet_host $failover`
1664 [ -z "$host" ] && return
1666 local curactive=`facet_active $facet`
1667 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1668 eval export ${facet}active=$facet
1670 eval export ${facet}active=$failover
1672 # save the active host for this facet
1673 local activevar=${facet}active
1674 echo "$activevar=${!activevar}" > $TMP/$activevar
1675 [[ $facet = mds ]] && combined_mgs_mds && \
1676 echo "mgsactive=${!activevar}" > $TMP/mgsactive
1677 local TO=`facet_active_host $facet`
1678 echo "Failover $facet to $TO"
1684 # do not stripe off hostname if verbose, bug 19215
1685 if [ x$1 = x--verbose ]; then
1693 if [ "$HOST" = "$HOSTNAME" ]; then
1695 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1696 echo "cannot run remote command on $HOST with $myPDSH"
1700 echo "CMD: $HOST $@" >&2
1701 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1704 if [ "$myPDSH" = "rsh" ]; then
1705 # we need this because rsh does not return exit code of an executed command
1706 local command_status="$TMP/cs"
1707 rsh $HOST ":> $command_status"
1708 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1709 cd $RPWD; sh -c \"$@\") ||
1710 echo command failed >$command_status"
1711 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1716 # print HOSTNAME for myPDSH="no_dsh"
1717 if [[ $myPDSH = no_dsh ]]; then
1718 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1720 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1723 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1725 return ${PIPESTATUS[0]}
1729 do_node --verbose "$@"
1732 single_local_node () {
1733 [ "$1" = "$HOSTNAME" ]
1738 # do not stripe off hostname if verbose, bug 19215
1739 if [ x$1 = x--verbose ]; then
1747 if single_local_node $rnodes; then
1749 do_nodev $rnodes "$@"
1751 do_node $rnodes "$@"
1756 # This is part from do_node
1759 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1760 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1762 export FANOUT=$(get_node_count "${rnodes//,/ }")
1764 echo "CMD: $rnodes $@" >&2
1765 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1768 # do not replace anything from pdsh output if -N is used
1769 # -N Disable hostname: prefix on lines of output.
1770 if $verbose || [[ $myPDSH = *-N* ]]; then
1771 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1773 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1775 return ${PIPESTATUS[0]}
1781 local HOST=`facet_active_host $facet`
1782 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1787 do_nodes --verbose "$@"
1793 # make sure its not already running
1795 rm -f $TMP/${facet}active
1796 [[ $facet = mds ]] && combined_mgs_mds && rm -f $TMP/mgsactive
1797 do_facet ${facet} $MKFS $*
1803 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1804 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1810 if combined_mgs_mds && [[ $facet = "mgs" ]] ; then
1813 local var=${facet}_MOUNT
1814 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1823 # make sure we are using the primary server, so test-framework will
1824 # be able to clean up properly.
1825 activemds=`facet_active mds`
1826 if [ $activemds != "mds" ]; then
1830 local clients=$CLIENTS
1831 [ -z $clients ] && clients=$(hostname)
1833 zconf_umount_clients $clients $MOUNT "$*" || true
1834 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1836 [ "$CLIENTONLY" ] && return
1837 # The add fn does rm ${facet}active file, this would be enough
1838 # if we use do_facet <facet> only after the facet added, but
1839 # currently we use do_facet mds in local.sh
1841 rm -f ${TMP}/mdsactive
1842 combined_mgs_mds && rm -f $TMP/mgsactive
1843 for num in `seq $OSTCOUNT`; do
1845 rm -f $TMP/ost${num}active
1847 if ! combined_mgs_mds ; then
1854 cleanup_echo_devs () {
1855 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1857 for dev in $devs; do
1858 $LCTL --device $dev cleanup
1859 $LCTL --device $dev detach
1864 nfs_client_mode && return
1872 combined_mgs_mds () {
1873 [[ $MDSDEV = $MGSDEV ]] && [[ $mds_HOST = $mgs_HOST ]]
1879 local number=$(echo -n $facet | sed -e 's/^fs[0-9]\+//' |
1880 sed -e 's/^[a-z]\+//')
1882 [[ -z $number ]] && number=1
1890 local index=$(($(facet_number $facet) - 1))
1891 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1892 local optvar=${tgt}_MKFS_OPTS
1893 local opt=${!optvar}
1895 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1896 [[ $facet = mgs ]] && echo $opt && return
1899 [[ $opt != *--index* ]] && opt+=" --index=$index"
1902 # --failnode options
1903 local var=${facet}failover_HOST
1904 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1905 local failnode=$(h2$NETTYPE ${!var})
1906 failnode="--failnode=$failnode"
1907 # options does not contain
1908 # or contains wrong --failnode=
1909 if [[ $opt != *${failnode}* ]]; then
1910 opt=$(echo $opt | sed 's/--failnode=.* / /')
1911 opt="$opt $failnode"
1917 # no additional mkfs mds "--mgsnode" option for this configuration
1918 if [[ $facet = mds ]] && combined_mgs_mds; then
1923 # additional mkfs "--mgsnode"
1924 local mgsnode="--mgsnode=$MGSNID"
1925 opt=${opt//$mgsnode }
1926 for nid in ${MGSNID//:/ }; do
1927 local mgsnode="--mgsnode=$nid"
1928 # options does not contain
1930 if [[ $opt != *${mgsnode}" "* ]]; then
1931 opt="$opt --mgsnode=$nid"
1939 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1942 # We need ldiskfs here, may as well load them all
1944 [ "$CLIENTONLY" ] && return
1945 echo Formatting mgs, mds, osts
1946 if ! combined_mgs_mds ; then
1947 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1951 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV || exit 10
1953 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1956 # the ost-s could have different OST_MKFS_OPTS
1957 # because of different failnode-s
1958 for num in `seq $OSTCOUNT`; do
1960 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1962 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1968 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1973 zconf_umount `hostname` $1 || error "umount failed"
1974 zconf_mount `hostname` $1 || error "mount failed"
1977 writeconf_facet () {
1981 do_facet $facet "$TUNEFS --writeconf $dev"
1985 writeconf_facet mds $MDSDEV
1987 for num in `seq $OSTCOUNT`; do
1988 DEVNAME=`ostdevname $num`
1989 writeconf_facet ost$num $DEVNAME
1994 nfs_client_mode && return
1996 sanity_mount_check ||
1997 error "environments are insane!"
2000 if [ -z "$CLIENTONLY" ]; then
2001 echo Setup mgs, mdt, osts
2003 echo $WRITECONF | grep -q "writeconf" && \
2006 if ! combined_mgs_mds ; then
2007 start mgs $MGSDEV $MGS_MOUNT_OPTS
2010 start mds $MDSDEV $MDS_MOUNT_OPTS
2011 # We started mds, now we should set failover variable properly.
2012 # Set mdsfailover_HOST if it is not set (the default failnode).
2013 if [ -z "$mdsfailover_HOST" ]; then
2014 mdsfailover_HOST=$(facet_host mds)
2017 for num in `seq $OSTCOUNT`; do
2018 DEVNAME=`ostdevname $num`
2019 start ost$num $DEVNAME $OST_MOUNT_OPTS
2021 # We started ost$num, now we should set ost${num}failover variable properly.
2022 # Set ost${num}failover_HOST if it is not set (the default failnode).
2023 varname=ost${num}failover_HOST
2024 if [ -z "${!varname}" ]; then
2025 eval ost${num}failover_HOST=$(facet_host ost${num})
2030 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2032 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2035 if [ "$MOUNT_2" ]; then
2036 mount_client $MOUNT2
2037 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2043 mounted_lustre_filesystems() {
2044 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2047 init_facet_vars () {
2048 [ "$CLIENTONLY" ] && return 0
2055 eval export ${facet}_dev=${device}
2056 eval export ${facet}_opt=\"$@\"
2058 local dev=${facet}_dev
2059 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2060 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2062 eval export ${facet}_svc=${label}
2064 local varname=${facet}failover_HOST
2065 if [ -z "${!varname}" ]; then
2066 eval $varname=$(facet_host $facet)
2069 # ${facet}failover_dev is set in cfg file
2070 varname=${facet}failover_dev
2071 if [ -n "${!varname}" ] ; then
2072 eval export ${facet}failover_dev=${!varname}
2074 eval export ${facet}failover_dev=$device
2077 # get mount point of already mounted device
2078 # is facet_dev is already mounted then use the real
2079 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2080 # i.e. ${facet}_MOUNT if specified by user or default
2081 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2082 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2083 if [ -z $mntpt ]; then
2084 mntpt=$(facet_mntpt $facet)
2086 eval export ${facet}_MOUNT=$mntpt
2089 init_facets_vars () {
2091 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
2093 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2095 remote_ost_nodsh && return
2097 for num in `seq $OSTCOUNT`; do
2098 DEVNAME=`ostdevname $num`
2099 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2103 init_param_vars () {
2104 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2105 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
2106 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2107 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2111 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
2113 log "Using TIMEOUT=$TIMEOUT"
2115 if [ "$ENABLE_QUOTA" ]; then
2116 setup_quota $MOUNT || return 2
2120 nfs_client_mode () {
2121 if [ "$NFSCLIENT" ]; then
2122 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2123 local clients=$CLIENTS
2124 [ -z $clients ] && clients=$(hostname)
2126 do_nodesv $clients "grep ' '$MOUNT' ' /proc/mounts"
2127 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2128 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2129 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2131 do_nodesv ${nfsexport[0]} "df -T ${nfsexport[1]}"
2137 check_config_client () {
2140 local mounted=$(mount | grep " $mntpt ")
2141 if [ "$CLIENTONLY" ]; then
2143 # CLIENTONLY should not depend on *_HOST settings
2144 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2145 # in theory someone could create a new,
2146 # client-only config file that assumed lustre was already
2147 # configured and didn't set the MGSNID. If MGSNID is not set,
2148 # then we should use the mgs nid currently being used
2149 # as the default value. bug 18021
2150 [[ x$MGSNID = x ]] &&
2153 if [[ x$mgc != xMGC$MGSNID ]]; then
2154 if [ "$mgs_HOST" ]; then
2155 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2156 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2157 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2163 local myMGS_host=$mgs_HOST
2164 if [ "$NETTYPE" = "ptl" ]; then
2165 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2168 echo Checking config lustre mounted on $mntpt
2169 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2170 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2172 # if [ "$mgshost" != "$myMGS_host" ]; then
2173 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2174 # Please use correct config or set mds_HOST correctly!"
2179 check_config_clients () {
2180 local clients=${CLIENTS:-$HOSTNAME}
2183 nfs_client_mode && return
2185 do_rpc_nodes $clients check_config_client $mntpt
2187 sanity_mount_check ||
2188 error "environments are insane!"
2192 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
2193 local cltimeout=$(lctl get_param -n timeout)
2194 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2195 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2202 local mounted=$(mounted_lustre_filesystems)
2204 echo $mounted' ' | grep -w -q $mntpt' '
2208 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2212 # empty lustre filesystem may have empty directories lost+found and .lustre
2214 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2215 -print | wc -l) = 1 ] || return 1
2216 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2217 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2221 check_and_setup_lustre() {
2222 nfs_client_mode && return
2224 local MOUNTED=$(mounted_lustre_filesystems)
2228 # both MOUNT and MOUNT2 are not mounted
2229 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2230 [ "$REFORMAT" ] && formatall
2231 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2233 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2234 export I_MOUNTED=yes
2238 elif is_mounted $MOUNT2; then
2240 # MOUNT2 is mounted, while MOUNT_2 is not set
2241 if ! [ "$MOUNT_2" ]; then
2242 cleanup_mount $MOUNT2
2243 export I_UMOUNTED2=yes
2246 # MOUNT2 is mounted, MOUNT_2 is set
2248 # FIXME: what to do if check_config failed?
2250 # 1) remote client has mounted other Lustre fs ?
2251 # 2) it has insane env ?
2252 # let's try umount MOUNT2 on all clients and mount it again:
2253 if ! check_config_clients $MOUNT2; then
2254 cleanup_mount $MOUNT2
2255 restore_mount $MOUNT2
2256 export I_MOUNTED2=yes
2261 # MOUNT is mounted MOUNT2 is not mounted
2262 elif [ "$MOUNT_2" ]; then
2263 restore_mount $MOUNT2
2264 export I_MOUNTED2=yes
2268 # FIXME: what to do if check_config failed?
2270 # 1) remote client has mounted other Lustre fs?
2271 # 2) lustre is mounted on remote_clients atall ?
2272 check_config_clients $MOUNT
2276 set_default_debug_nodes $(comma_list $(nodes_list))
2278 if [ "$ONLY" == "setup" ]; then
2284 local clients=${CLIENTS:-$HOSTNAME}
2287 zconf_mount_clients $clients $mntpt
2291 local clients=${CLIENTS:-$HOSTNAME}
2294 zconf_umount_clients $clients $mntpt
2297 cleanup_and_setup_lustre() {
2298 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2299 lctl set_param debug=0 || true
2301 if [ "$ONLY" == "cleanup" ]; then
2305 check_and_setup_lustre
2308 # Get all of the server target devices from a given server node and type.
2317 mdt) obd_type="osd" ;;
2318 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2319 *) echo "invalid server type" && return 1 ;;
2322 devs=$(do_node $node "lctl get_param -n $obd_type.*.mntdev")
2323 for dev in $devs; do
2325 *loop*) do_node $node "losetup $dev" | \
2326 sed -e "s/.*(//" -e "s/).*//" ;;
2332 # Get all of the server target devices.
2338 for node in $(osts_nodes); do
2339 OSTDEVS[i]=$(get_mnt_devs $node ost)
2344 # Run e2fsck on MDT or OST device.
2350 df > /dev/null # update statfs data on disk
2351 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2354 do_node $node $cmd || rc=$?
2355 [ $rc -le $FSCK_MAX_ERR ] || \
2356 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2360 # verify a directory is shared among nodes.
2361 check_shared_dir() {
2364 [ -z "$dir" ] && return 1
2365 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $dir
2366 check_write_access $dir || return 1
2370 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2376 check_shared_dir $SHARED_DIRECTORY ||
2377 error "$SHARED_DIRECTORY isn't a shared directory"
2379 export MDSDB=$SHARED_DIRECTORY/mdsdb
2380 export OSTDB=$SHARED_DIRECTORY/ostdb
2382 run_e2fsck $(facet_host mds) $MDSDEV "--mdsdb $MDSDB"
2387 for node in $(osts_nodes); do
2388 for dev in ${OSTDEVS[i]}; do
2389 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
2390 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2391 ostidx=$((ostidx + 1))
2398 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2402 [ $rc -le $FSCK_MAX_ERR ] || \
2403 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2404 echo "lfsck finished with rc=$rc"
2406 rm -rvf $MDSDB* $OSTDB* || true
2410 check_and_cleanup_lustre() {
2411 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
2417 if is_mounted $MOUNT; then
2418 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
2419 error "remove sub-test dirs failed"
2420 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2423 if [ "$I_UMOUNTED2" = "yes" ]; then
2424 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2427 if [ "$I_MOUNTED2" = "yes" ]; then
2428 cleanup_mount $MOUNT2
2431 if [ "$I_MOUNTED" = "yes" ]; then
2432 cleanupall -f || error "cleanup failed"
2440 wait_for_function () {
2443 # suppress fn both stderr and stdout
2444 if [ "$1" = "--quiet" ]; then
2446 quiet=" > /dev/null 2>&1"
2457 eval $fn $quiet && return 0
2459 wait=$((wait + sleep))
2460 [ $wait -lt $max ] || return 1
2461 echo waiting $fn, $((max - wait)) secs left ...
2471 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2472 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2473 echo "Network not available!"
2477 echo `date +"%H:%M:%S (%s)"` network interface is UP
2486 # the sed converts spaces to commas, but leaves the last space
2487 # alone, so the line doesn't end with a comma.
2488 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2494 echo $list | grep -qw $item
2497 # list, excluded are the comma separated lists
2498 exclude_items_from_list () {
2504 for item in ${excluded//,/ }; do
2505 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2507 echo $(comma_list $list)
2510 # list, expand are the comma separated lists
2512 local list=${1//,/ }
2513 local expand=${2//,/ }
2516 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2517 echo $(comma_list $expanded)
2520 testslist_filter () {
2521 local script=$LUSTRE/tests/${TESTSUITE}.sh
2523 [ -f $script ] || return 0
2525 local start_at=$START_AT
2526 local stop_at=$STOP_AT
2528 local var=${TESTSUITE//-/_}_START_AT
2529 [ x"${!var}" != x ] && start_at=${!var}
2530 var=${TESTSUITE//-/_}_STOP_AT
2531 [ x"${!var}" != x ] && stop_at=${!var}
2533 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2534 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2535 /^'${start_at}'$/ {flag = 0}
2536 {if (flag == 1) print $0}
2537 /^'${stop_at}'$/ { flag = 1 }'
2541 (cd `dirname $1`; echo $PWD/`basename $1`)
2545 local types=${1:-"OST MDS MGS"}
2548 for entry in $types; do
2549 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2550 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2553 MDS|MGS ) list="$list $name";;
2554 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
2555 list="$list ${name}$i"
2557 * ) error "Invalid facet type"
2561 echo $(comma_list $list)
2564 ##################################
2565 # Adaptive Timeouts funcs
2568 # only check mds, we assume at_max is the same on all nodes
2569 local at_max=$(do_facet mds "lctl get_param -n at_max")
2570 if [ $at_max -eq 0 ]; then
2581 # suppose that all ost-s have the same $at value set
2582 [ $facet != "ost" ] || facet=ost1
2584 do_facet $facet "lctl get_param -n $at"
2598 if [ $facet == "ost" ]; then
2599 facet=$(get_facets OST)
2601 hosts=$(expand_list $hosts $(facets_hosts $facet))
2604 do_nodes $hosts lctl set_param at_max=$at_max
2607 ##################################
2611 # OBD_FAIL_MDS_ALL_REQUEST_NET
2613 do_facet mds lctl set_param fail_loc=0x123
2614 do_facet client "$1" || RC=$?
2615 do_facet mds lctl set_param fail_loc=0
2620 # OBD_FAIL_MDS_ALL_REPLY_NET
2622 do_facet mds lctl set_param fail_loc=0x122
2623 do_facet client "$@" || RC=$?
2624 do_facet mds lctl set_param fail_loc=0
2628 drop_reint_reply() {
2629 # OBD_FAIL_MDS_REINT_NET_REP
2631 do_facet mds lctl set_param fail_loc=0x119
2632 do_facet client "$@" || RC=$?
2633 do_facet mds lctl set_param fail_loc=0
2638 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2640 do_facet ost1 lctl set_param fail_loc=0x214
2641 do_facet client "$1" || RC=$?
2642 do_facet client "sync"
2643 do_facet ost1 lctl set_param fail_loc=0
2647 drop_ldlm_cancel() {
2648 #define OBD_FAIL_LDLM_CANCEL 0x304
2650 do_facet client lctl set_param fail_loc=0x304
2651 do_facet client "$@" || RC=$?
2652 do_facet client lctl set_param fail_loc=0
2656 drop_bl_callback() {
2657 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2659 do_facet client lctl set_param fail_loc=0x305
2660 do_facet client "$@" || RC=$?
2661 do_facet client lctl set_param fail_loc=0
2666 #define OBD_FAIL_LDLM_REPLY 0x30c
2668 do_facet mds lctl set_param fail_loc=0x30c
2669 do_facet client "$@" || RC=$?
2670 do_facet mds lctl set_param fail_loc=0
2678 echo "clearing fail_loc on $facet"
2679 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2682 set_nodes_failloc () {
2683 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2686 cancel_lru_locks() {
2687 $LCTL mark "cancel_lru_locks $1 start"
2688 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2689 $LCTL set_param -n $d=clear
2691 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2692 $LCTL mark "cancel_lru_locks $1 stop"
2697 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2698 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2699 echo "$DEFAULT_LRU_SIZE"
2704 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2707 lru_resize_disable()
2709 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2714 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2715 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2716 echo there is still data in page cache $FILE ?
2717 lctl get_param -n $FILE
2724 create_fake_exports () {
2727 #obd_fail_val = num;
2728 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2729 do_facet $facet "lctl set_param fail_val=$num"
2730 do_facet $facet "lctl set_param fail_loc=0x80000708"
2735 DEBUGSAVE="$(lctl get_param -n debug)"
2739 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2743 ##################################
2745 ##################################
2748 local TYPE=${TYPE:-"FAIL"}
2751 # do not dump logs if $1=false
2752 if [ "x$1" = "xfalse" ]; then
2757 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2760 # We need to dump the logs on all nodes
2762 gather_logs $(comma_list $(nodes_list))
2766 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2767 echo "$@" > $LOGDIR/err
2772 local log=$TESTSUITELOG
2774 [ -f "$log" ] && egrep -q .FAIL: $log && status=1
2780 if $FAIL_ON_ERROR; then
2791 # use only if we are ignoring failures for this test, bugno required.
2792 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2793 # e.g. error_ignore 5494 "your message"
2795 local TYPE="IGNORE (bz$1)"
2801 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2805 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2806 [ "$TESTSUITELOG" ] && \
2807 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2810 build_test_filter() {
2811 EXCEPT="$EXCEPT $(testslist_filter)"
2813 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2817 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2818 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2819 [ "$EXCEPT_SLOW" ] && \
2820 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2821 for E in $EXCEPT $ALWAYS_EXCEPT; do
2822 eval EXCEPT_${E}=true
2824 for E in $EXCEPT_SLOW; do
2825 eval EXCEPT_SLOW_${E}=true
2827 for G in $GRANT_CHECK_LIST; do
2828 eval GCHECK_ONLY_${G}=true
2833 if [[ $1 = [a-z]* ]]; then
2840 # print a newline if the last test was skipped
2841 export LAST_SKIPPED=
2845 export base=`basetest $1`
2846 if [ ! -z "$ONLY" ]; then
2848 if [ ${!testname}x != x ]; then
2849 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2850 run_one_logged $1 "$2"
2854 if [ ${!testname}x != x ]; then
2855 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2856 run_one_logged $1 "$2"
2864 if [ ${!testname}x != x ]; then
2866 TESTNAME=test_$1 skip "skipping excluded test $1"
2869 testname=EXCEPT_$base
2870 if [ ${!testname}x != x ]; then
2872 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2875 testname=EXCEPT_SLOW_$1
2876 if [ ${!testname}x != x ]; then
2878 TESTNAME=test_$1 skip "skipping SLOW test $1"
2881 testname=EXCEPT_SLOW_$base
2882 if [ ${!testname}x != x ]; then
2884 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2889 run_one_logged $1 "$2"
2894 EQUALS="======================================================================"
2898 local suffixlen=$((${#EQUALS} - ${#msg}))
2899 [ $suffixlen -lt 5 ] && suffixlen=5
2900 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2905 module_loaded lnet || load_modules
2917 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2922 strace -o $TMP/$1.strace -ttt $*
2924 log "FINISHED: $*: rc $RC"
2929 equals_msg $1 test complete, duration $2 sec
2930 [ -f "$TESTSUITELOG" ] && grep ".IGNORE\|.FAIL" $TESTSUITELOG || true
2931 echo duration $2 >>$TESTSUITELOG
2935 # Set TEST_STATUS here; will be used for logging the result
2936 if [ -f $LOGDIR/err ]; then
2941 echo $TEST_STATUS " " $@
2945 FFREE=`lctl get_param -n mds.*.filesfree`
2946 FTOTAL=`lctl get_param -n mds.*.filestotal`
2947 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2951 echo -n "Resetting fail_loc on all nodes..."
2952 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2960 export tdir=d0.${TESTSUITE}/d${base}
2961 export TESTNAME=test_$testnum
2962 local SAVE_UMASK=`umask`
2966 log "== test $testnum: $message == `date +%H:%M:%S`"
2967 test_${testnum} || error "test_$testnum failed with $?"
2970 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2971 check_catastrophe || error "LBUG/LASSERT detected"
2972 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2980 local BEFORE=`date +%s`
2982 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
2983 local test_log=$LOGDIR/$name
2985 local SAVE_UMASK=`umask`
2988 log_sub_test_begin test_${1}
2989 (run_one $1 "$2") 2>&1 | tee $test_log
2990 local RC=${PIPESTATUS[0]}
2992 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2993 echo "test_$1 returned $RC" | tee $LOGDIR/err
2995 duration=$((`date +%s` - $BEFORE))
2996 pass "(${duration}s)"
2997 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2998 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3000 if [ -f $LOGDIR/err ]; then
3001 $FAIL_ON_ERROR && exit $RC
3010 (cd `dirname $1`; echo $PWD/`basename $1`)
3014 export base=`basetest $1`
3015 [ "$CHECK_GRANT" == "no" ] && return 0
3017 testname=GCHECK_ONLY_${base}
3018 [ ${!testname}x == x ] && return 0
3020 echo -n "checking grant......"
3022 local clients=$CLIENTS
3023 [ -z $clients ] && clients=$(hostname)
3025 # sync all the data and make sure no pending data on server
3026 do_nodes $clients sync
3029 client_grant=`do_nodes $clients \
3030 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3031 awk '{total += $1} END{print total}'`
3034 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3035 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3036 awk '{total += $1} END{print total}'`
3038 # check whether client grant == server grant
3039 if [ $client_grant -ne $server_grant ]; then
3040 echo "failed: client:${client_grant} server: ${server_grant}."
3041 do_nodes $(comma_list $(osts_nodes)) \
3042 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3043 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3046 echo "pass: client:${client_grant} server: ${server_grant}"
3050 ########################
3056 ost=`echo $1 | awk -F_ '{print $3}'`
3057 if [ -z $ost ]; then
3058 ost=`echo $1 | sed 's/-osc.*//'`
3063 ostuuid_from_index()
3065 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
3068 ostname_from_index() {
3069 local uuid=$(ostuuid_from_index $1)
3073 index_from_ostuuid()
3075 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
3080 [[ $node != $HOSTNAME ]]
3085 remote_node $mds_HOST
3090 [ "$CLIENTONLY" ] && return 0 || true
3091 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3096 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3097 MSKIPPED=1 && return 1
3104 for node in $(osts_nodes) ; do
3105 remote_node $node && return 0
3112 [ "$CLIENTONLY" ] && return 0 || true
3113 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3118 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3119 OSKIPPED=1 && return 1
3126 MGS=$(facet_host mgs)
3127 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3131 remote_ost && remote_mds
3136 remote_mds_nodsh || remote_ost_nodsh || \
3137 $(single_local_node $(comma_list $(nodes_list)))
3145 for facet in ${facets//,/ }; do
3146 if [ "$FAILURE_MODE" = HARD ]; then
3147 nodes="$nodes $(facet_active_host $facet)"
3149 nodes="$nodes $(facet_host $facet)"
3152 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3158 local facets=$(get_facets OST)
3159 local nodes=$(facets_nodes $facets)
3165 # FIXME. We need a list of clients
3166 local myNODES=$HOSTNAME
3169 # CLIENTS (if specified) contains the local client
3170 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3172 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3173 myNODES="$myNODES $(facets_nodes $(get_facets))"
3176 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3181 remote_nodes_list () {
3182 local rnodes=$(nodes_list)
3183 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3187 init_clients_lists () {
3188 # Sanity check: exclude the local client from RCLIENTS
3189 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3191 # Sanity check: exclude the dup entries
3192 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3194 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3196 # Sanity check: exclude the dup entries from CLIENTS
3197 # for those configs which has SINGLCLIENT set to local client
3198 clients=$(for i in $clients; do echo $i; done | sort -u)
3200 CLIENTS=`comma_list $clients`
3201 local -a remoteclients=($rclients)
3202 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3203 varname=CLIENT$((i + 2))
3204 eval $varname=${remoteclients[i]}
3207 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3210 get_random_entry () {
3213 rnodes=${rnodes//,/ }
3215 local -a nodes=($rnodes)
3216 local num=${#nodes[@]}
3217 local i=$((RANDOM * num * 2 / 65536))
3223 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3228 lctl get_param version | grep -q patchless
3232 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3237 echo $nodes | wc -w || true
3241 local nodes=$(osts_nodes)
3242 local osscount=$(get_node_count "$nodes")
3243 [ ! "$OSTCOUNT" = "$osscount" ]
3246 generate_machine_file() {
3247 local nodes=${1//,/ }
3248 local machinefile=$2
3250 for node in $nodes; do
3251 echo $node >>$machinefile || \
3252 { echo "can not generate machinefile $machinefile" && return 1; }
3257 local file=$1/stripe
3259 $LFS getstripe -v $file || error
3266 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3267 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3271 setstripe_nfsserver () {
3273 local nfsserver=$(nfs_server $dir)
3275 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3277 do_nodev $nfsserver lfs setstripe "$@"
3280 check_runas_id_ret() {
3282 local myRUNAS_UID=$1
3283 local myRUNAS_GID=$2
3286 if [ -z "$myRUNAS" ]; then
3287 error_exit "myRUNAS command must be specified for check_runas_id"
3289 mkdir $DIR/d0_runas_test
3291 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3292 if ! $myRUNAS touch $DIR/d0_runas_test/f$$ ; then
3293 do_nodesv $(comma_list $(nodes_list)) grep -w $myRUNAS_UID /etc/passwd
3296 rm -rf $DIR/d0_runas_test
3301 local myRUNAS_UID=$1
3302 local myRUNAS_GID=$2
3305 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3306 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3307 Please set RUNAS_ID to some UID which exists on MDS and client or
3308 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3311 # Run multiop in the background, but wait for it to print
3312 # "PAUSING" to its stdout before returning from this function.
3313 multiop_bg_pause() {
3314 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3318 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3321 echo "$MULTIOP_PROG $FILE v$ARGS"
3322 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3324 echo "TMPPIPE=${TMPPIPE}"
3325 local multiop_output
3327 read -t 60 multiop_output < $TMPPIPE
3328 if [ $? -ne 0 ]; then
3333 if [ "$multiop_output" != "PAUSING" ]; then
3334 echo "Incorrect multiop output: $multiop_output"
3344 if [ x$1 = x--uniq ]; then
3354 # We need to run do_node in bg, because pdsh does not exit
3355 # if child process of run script exists.
3356 # I.e. pdsh does not exit when runmultiop_bg_pause exited,
3357 # because of multiop_bg_pause -> $MULTIOP_PROG &
3358 # By the same reason we need sleep a bit after do_nodes starts
3359 # to let runmultiop_bg_pause start muliop and
3360 # update /tmp/multiop_bg.pid ;
3361 # The rm /tmp/multiop_bg.pid guarantees here that
3362 # we have the updated by runmultiop_bg_pause
3363 # /tmp/multiop_bg.pid file
3365 local pid_file=$TMP/multiop_bg.pid.$uniq
3366 do_node $client "rm -f $pid_file && MULTIOP_PID_FILE=$pid_file LUSTRE= runmultiop_bg_pause $file $cmds" &
3370 multiop_pid=$(do_node $client cat $pid_file)
3371 [ -n "$multiop_pid" ] || error "$client : Can not get multiop_pid from $pid_file "
3372 eval export $(node_var_name $client)_multiop_pid$uniq=$multiop_pid
3373 eval export $(node_var_name $client)_do_node_pid$uniq=$pid
3374 local var=$(node_var_name $client)_multiop_pid$uniq
3375 echo node $client multiop_bg started multiop_pid=${!var}
3381 if [ x$1 = x--uniq ]; then
3388 local multiop_pid=$(node_var_name $client)_multiop_pid$uniq
3389 local do_node_pid=$(node_var_name $client)_do_node_pid$uniq
3391 echo "Stopping multiop_pid=${!multiop_pid} (kill ${!multiop_pid} on $client)"
3392 do_node $client kill -USR1 ${!multiop_pid}
3394 wait ${!do_node_pid}
3404 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3410 inodes_available () {
3411 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3415 mdsrate_inodes_available () {
3416 local min_inodes=$(inodes_available)
3417 echo $((min_inodes * 99 / 100))
3420 # reset llite stat counters
3421 clear_llite_stats(){
3422 lctl set_param -n llite.*.stats 0
3425 # sum llite stat items
3426 calc_llite_stats() {
3427 local res=$(lctl get_param -n llite.*.stats |
3428 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3433 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3436 calc_osc_kbytes () {
3437 df $MOUNT > /dev/null
3438 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
3441 # save_lustre_params(node, parameter_mask)
3442 # generate a stream of formatted strings (<node> <param name>=<param value>)
3443 save_lustre_params() {
3445 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3448 # restore lustre parameters from input stream, produces by save_lustre_params
3449 restore_lustre_params() {
3453 while IFS=" =" read node name val; do
3454 do_node ${node//:/} "lctl set_param -n $name $val"
3458 check_catastrophe() {
3459 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3460 local C=$CATASTROPHE
3461 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3463 if [ $rnodes ]; then
3464 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3465 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3481 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3483 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3484 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3485 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3489 mdsrate_cleanup () {
3490 mpi_run -np $1 ${MACHINEFILE_OPTION} $2 ${MDSRATE} --unlink --nfiles $3 \
3491 --dir $4 --filefmt $5 $6
3494 delayed_recovery_enabled () {
3495 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
3498 ################################################################################
3499 # The following functions are used to enable interop testing between
3500 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
3502 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
3503 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
3504 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
3505 ################################################################################
3507 get_lustre_version () {
3508 local node=${1:-"mds"}
3509 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3512 get_mds_version_major () {
3513 local version=$(get_lustre_version mds)
3514 echo $version | awk -F. '{print $1}'
3517 get_mds_version_minor () {
3518 local version=$(get_lustre_version mds)
3519 echo $version | awk -F. '{print $2}'
3522 get_mds_version_patch () {
3523 local version=$(get_lustre_version mds)
3524 echo $version | awk -F. '{print $3}'
3527 get_mds_version_fix () {
3528 local version=$(get_lustre_version mds)
3529 echo $version | awk -F. '{print $4}'
3532 get_kernel_version () {
3533 local facet=${1:-"mds"}
3534 do_facet $facet uname -r | awk -F "-" '{print $1}'
3537 get_mds_kernel_major () {
3538 local version=$(get_kernel_version mds)
3539 echo $version | awk -F. '{print $1"."$2}'
3542 get_mds_kernel_minor () {
3543 local version=$(get_kernel_version mds)
3544 echo $version | awk -F. '{print $3}'
3547 get_mds_fsstat_proc_path() {
3548 local major=$(get_mds_version_major)
3549 local minor=$(get_mds_version_minor)
3550 if [ $major -le 1 -a $minor -le 8 ] ; then
3557 get_mds_mntdev_proc_path() {
3558 local fsstat_dev=$(get_mds_fsstat_proc_path)
3559 echo "$fsstat_dev.*.mntdev"
3562 get_mdtlov_proc_path() {
3564 local major=$(get_mds_version_major)
3565 local minor=$(get_mds_version_minor)
3566 if [ $major -le 1 -a $minor -le 8 ] ; then
3567 echo "${fsname}-mdtlov"
3569 echo "${fsname}-MDT0000-mdtlov"
3573 get_mdtosc_proc_path() {
3575 local major=$(get_mds_version_major)
3576 local minor=$(get_mds_version_minor)
3577 if [ $major -le 1 -a $minor -le 8 ] ; then
3580 echo "${ost}-osc-MDT0000"
3584 get_mds_mdt_device_proc_path() {
3585 local major=$(get_mds_version_major)
3586 local minor=$(get_mds_version_minor)
3587 if [ $major -le 1 -a $minor -le 8 ] ; then
3595 local major=$(get_mds_version_major)
3596 local minor=$(get_mds_version_minor)
3597 if [ $major -le 1 -a $minor -le 8 ] ; then
3604 ########################
3606 convert_facet2label() {
3609 if [ x$facet = xost ]; then
3613 local varsvc=${facet}_svc
3615 if [ -n ${!varsvc} ]; then
3618 error "No lablel for $facet!"
3622 get_clientosc_proc_path() {
3628 get_osc_import_name() {
3631 local label=$(convert_facet2label $ost)
3633 if [ "$facet" == "mds" ]; then
3634 get_mdtosc_proc_path $label
3638 get_clientosc_proc_path $label
3642 _wait_import_state () {
3645 local maxtime=${3:-$(max_recovery_time)}
3649 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3650 while [ "${CONN_STATE}" != "${expected}" ]; do
3651 if [ "${expected}" == "DISCONN" ]; then
3652 # for disconn we can check after proc entry is removed
3653 [ "x${CONN_STATE}" == "x" ] && return 0
3654 # with AT enabled, we can have connect request timeout near of
3655 # reconnect timeout and test can't see real disconnect
3656 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3658 [ $i -ge $maxtime ] && \
3659 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3662 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3666 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3670 wait_import_state() {
3673 local maxtime=${3:-$(max_recovery_time)}
3676 for param in ${params//,/ }; do
3677 _wait_import_state $state $param $maxtime || return
3681 # One client request could be timeouted because server was not ready
3682 # when request was sent by client.
3683 # The request timeout calculation details :
3685 # /* We give the server rq_timeout secs to process the req, and
3686 # add the network latency for our local timeout. */
3687 # request->rq_deadline = request->rq_sent + request->rq_timeout +
3688 # ptlrpc_at_get_net_latency(request) ;
3690 # ptlrpc_connect_import ()
3691 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
3694 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
3695 # ptlrpc_at_get_net_latency(request) ->
3696 # at_get (max (iat_net_latency=0, at_min)) = at_min
3699 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
3700 # INITIAL_CONNECT_TIMEOUT + at_min
3702 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
3703 # because we can not get this value in runtime,
3704 # the value depends on configure options, and it is not stored in /proc.
3706 # #define CONNECTION_SWITCH_MIN 5U
3708 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3710 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/2)
3712 request_timeout () {
3715 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
3716 local init_connect_timeout=$TIMEOUT
3717 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
3719 local at_min=$(at_get $facet at_min)
3721 echo $(( init_connect_timeout + at_min ))
3724 wait_osc_import_state() {
3728 local ost=$(get_osc_import_name $facet $ost_facet)
3730 local param="osc.${ost}.ost_server_uuid"
3732 # 1. wait the deadline of client 1st request (it could be skipped)
3733 # 2. wait the deadline of client 2nd request
3734 local maxtime=$(( 2 * $(request_timeout $facet)))
3736 if ! do_rpc_nodes $(facet_host $facet) \
3737 _wait_import_state $expected $param $maxtime; then
3738 error "import is not in ${expected} state"
3745 get_clientmdc_proc_path() {
3753 # Add paths to lustre tests for 32 and 64 bit systems.
3754 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3755 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3758 wait_clients_import_state () {
3765 if [ "$FAILURE_MODE" = HARD ]; then
3766 facets=$(facets_on_host $(facet_active_host $facet))
3769 for facet in ${facets//,/ }; do
3770 local label=$(convert_facet2label $facet)
3773 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3774 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3775 *) error "unknown facet!" ;;
3777 local params=$(expand_list $params $proc_path)
3780 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3781 error "import is not in ${expected} state"
3786 destroy_pool_int() {
3788 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
3789 for ost in $OSTS; do
3790 do_facet mgs lctl pool_remove $1 $ost
3792 do_facet mgs lctl pool_destroy $1
3795 # <fsname>.<poolname> or <poolname>
3797 local fsname=${1%%.*}
3798 local poolname=${1##$fsname.}
3800 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3804 pool_list $fsname.$poolname || return $?
3806 destroy_pool_int $fsname.$poolname
3808 [[ $RC -ne 0 ]] && return $RC
3810 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3811 2>/dev/null || echo foo" "foo" || RC=1
3813 if [[ $RC -eq 0 ]]; then
3814 remove_pool_from_list $fsname.$poolname
3816 error "destroy pool failed $1"
3822 local fsname=${1:-$FSNAME}
3824 local listvar=${fsname}_CREATED_POOLS
3828 [ x${!listvar} = x ] && return 0
3830 echo destroy the created pools: ${!listvar}
3831 for poolname in ${!listvar//,/ }; do
3832 destroy_pool $fsname.$poolname
3837 local fsname=${1:-$FSNAME}
3839 destroy_pools $fsname
3845 local ts=$(date +%s)
3848 if [[ ! -f "$YAML_LOG" ]]; then
3849 # init_logging is not performed before gather_logs,
3850 # so the $LOGDIR needs to be checked here
3851 check_shared_dir $LOGDIR && touch $LOGDIR/shared
3854 # bug 20237, comment 11
3855 # It would also be useful to provide the option
3856 # of writing the file to an NFS directory so it doesn't need to be copied.
3857 [ -f $LOGDIR/shared ] && docp=false
3859 # dump lustre logs, dmesg
3861 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3863 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3865 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3866 echo "Dumping logs only on local client."
3867 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
3868 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
3872 do_nodes --verbose $list \
3873 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
3874 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
3876 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3889 for i in $(seq 0 $num_mntpts); do
3890 cmd="ls -laf ${mntpt_root}$i/$dir"
3896 for pid in $pids; do
3903 # target_start_and_reset_recovery_timer()
3904 # service_time = at_est2timeout(service_time);
3905 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3906 # INITIAL_CONNECT_TIMEOUT);
3907 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3908 #define CONNECTION_SWITCH_INC 1
3909 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3910 #define CONNECTION_SWITCH_MIN 5U
3912 max_recovery_time () {
3913 local init_connect_timeout=$(( TIMEOUT / 20 ))
3914 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
3916 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
3921 remove_mdt_files() {
3926 local mntpt=${MOUNT%/*}/$facet
3928 echo "removing files from $mdtdev on $facet: $files"
3929 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3932 rm $mntpt/ROOT/$f || { rc=$?; break; }
3934 umount -f $mntpt || return $?
3938 duplicate_mdt_files() {
3943 local mntpt=${MOUNT%/*}/$facet
3945 echo "duplicating files on $mdtdev on $facet: $files"
3946 mkdir -p $mntpt || return $?
3947 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3957 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
3958 pushd $mntpt/ROOT > /dev/null || return $?
3961 touch $f.bad || return $?
3962 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
3964 [ $rc -eq 0 ] || return $rc
3965 setfattr --restore $tmp || return $?
3971 local devs=${1//,/ }
3974 local rslt=$TMP/sgpdd_survey
3976 # sgpdd-survey cleanups ${rslt}.* files
3978 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
3984 # returns the canonical name for an ldiskfs device
3989 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
3990 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
3991 echo dm-\\\${foo##*:};
3993 echo \\\$(basename \\\$dv);
3997 is_sanity_benchmark() {
3998 local benchmarks="dbench bonnie iozone fsx"
4000 for b in $benchmarks; do
4001 if [ "$b" == "$suite" ]; then
4009 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
4014 # Checking for shared logdir
4015 if [ ! -d $dir ]; then
4016 # Not found. Create local logdir
4019 touch $dir/check_file.$(hostname -s)
4024 check_write_access() {
4029 for node in $(nodes_list); do
4030 file=$dir/check_file.$(short_hostname $node)
4031 if [[ ! -f $file ]]; then
4032 # Logdir not accessible/writable from this node.
4035 rm -f $file || return 1
4041 if [[ -n $YAML_LOG ]]; then
4044 local SAVE_UMASK=`umask`
4047 export YAML_LOG=${LOGDIR}/results.yml
4051 # If the yaml log already exists then we will just append to it.
4052 [[ -f $YAML_LOG ]] && return 0
4054 if check_shared_dir $LOGDIR; then
4055 touch $LOGDIR/shared
4056 echo "Logging to shared log directory: $LOGDIR"
4058 echo "Logging to local directory: $LOGDIR"
4061 yml_nodes_file $LOGDIR >> $YAML_LOG
4062 yml_results_file >> $YAML_LOG
4068 yml_log_test $1 >> $YAML_LOG
4072 yml_log_sub_test $@ >> $YAML_LOG
4076 yml_log_test_status $@ >> $YAML_LOG
4079 log_sub_test_begin() {
4080 yml_log_sub_test_begin $@ >> $YAML_LOG
4083 log_sub_test_end() {
4084 yml_log_sub_test_end $@ >> $YAML_LOG