2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && touch $TF_FAIL && \
5 echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # function used by scripts run on remote nodes
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/functions.sh
24 . $LUSTRE/tests/yaml.sh
26 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
28 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
30 if [ -f "$EXCEPT_LIST_FILE" ]; then
31 echo "Reading test skip list from $EXCEPT_LIST_FILE"
36 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
37 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
41 [[ $DIR/ = $MOUNT/* ]] || \
42 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
43 [[ $DIR1/ = $MOUNT1/* ]] || \
44 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
45 [[ $DIR2/ = $MOUNT2/* ]] || \
46 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
48 [ -n "$failed" ] && exit 99 || true
52 echo "usage: $0 [-r] [-f cfgfile]"
60 [ "$TESTSUITE" == "lfsck" ] && return 0
61 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
63 local form="%-13s %-17s %-9s %s %s\n"
64 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
65 echo "------------------------------------------------------------------------------------"
66 for O in $DEFAULT_SUITES; do
67 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
68 [ "${!O}" = "no" ] && continue || true
69 local o=$(echo $O | tr "[:upper:]_" "[:lower:]-")
70 local log=${TMP}/${o}.log
71 if is_sanity_benchmark $o; then
72 log=${TMP}/sanity-benchmark.log
77 local status=Unfinished
79 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
80 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | sort -nr -k 3 | head -5 | awk '{ print $2":"$3"s" }')
81 total=$(grep duration $log | awk '{ print $2}')
82 if [ "${!O}" = "done" ]; then
86 local durations=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | awk '{ print $2":"$3"|" }')
87 details=$(printf "%s\n%s %s %s\n" "$details" "DDETAILS" "$O" "$(echo $durations)")
90 printf "$form" $status "$O" "${total}" "E=$skipped"
91 printf "$form" "-" "-" "-" "S=$(echo $slow)"
94 for O in $DEFAULT_SUITES; do
95 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
96 if [ "${!O}" = "no" ]; then
97 printf "$form" "Skipped" "$O" ""
101 # print the detailed tests durations if DDETAILS=true
108 export LUSTRE=`absolute_path $LUSTRE`
109 export TESTSUITE=`basename $0 .sh`
110 export TEST_FAILED=false
111 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
113 export MKE2FS=${MKE2FS:-mke2fs}
114 export DEBUGFS=${DEBUGFS:-debugfs}
115 export TUNE2FS=${TUNE2FS:-tune2fs}
116 export E2LABEL=${E2LABEL:-e2label}
117 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
118 export E2FSCK=${E2FSCK:-e2fsck}
119 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
120 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
121 export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
122 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
123 export FSCK_MAX_ERR=4 # File system errors left uncorrected
124 if [ "$SKIP_LFSCK" == "no" ]; then
125 if [ ! -x `which $LFSCK_BIN` ]; then
127 error_exit "$E2FSCK does not support lfsck"
130 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
131 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
132 export MDSDB_OPT="--mdsdb $MDSDB"
133 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 if [[ -z $LOGDIRSET ]]; then
139 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
140 export LOGDIRSET=true
142 export HOSTNAME=${HOSTNAME:-`hostname`}
143 if ! echo $PATH | grep -q $LUSTRE/utils; then
144 export PATH=$PATH:$LUSTRE/utils
146 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
147 export PATH=$PATH:$LUSTRE/utils/gss
149 if ! echo $PATH | grep -q $LUSTRE/tests; then
150 export PATH=$LUSTRE/tests:$PATH
152 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
153 export PATH=$PATH:$LUSTRE/../lustre-iokit/sgpdd-survey
155 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
156 [ ! -f "$LST" ] && export LST=$(which lst)
157 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
158 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
159 # Ubuntu, at least, has a truncate command in /usr/bin
160 # so fully path our truncate command.
161 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
162 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
163 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
164 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
165 export PATH=$LUSTRE/tests/racer:$PATH:
167 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
168 export PATH=$PATH:$LUSTRE/tests/mpi
170 export RSYNC_RSH=${RSYNC_RSH:-rsh}
171 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
172 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
173 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
174 [ ! -f "$LFS" ] && export LFS=$(which lfs)
175 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
176 if [ ! -f "$L_GETIDENTITY" ]; then
177 if `which l_getidentity > /dev/null 2>&1`; then
178 export L_GETIDENTITY=$(which l_getidentity)
180 export L_GETIDENTITY=NONE
183 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
184 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
185 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
186 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
187 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
188 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
189 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
190 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
191 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
192 export FSTYPE=${FSTYPE:-"ldiskfs"}
193 export NAME=${NAME:-local}
194 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
195 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
196 export LGSSD=$(which lgssd)
197 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
198 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
199 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
201 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
204 if [ "$ACCEPTOR_PORT" ]; then
205 export PORT_OPT="--port $ACCEPTOR_PORT"
210 echo "Using GSS/krb5 ptlrpc security flavor"
211 which lgss_keyring > /dev/null 2>&1 || \
212 error_exit "built with gss disabled! SEC=$SEC"
223 IDENTITY_UPCALL=false
226 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
228 # Paths on remote nodes, if different
229 export RLUSTRE=${RLUSTRE:-$LUSTRE}
230 export RPWD=${RPWD:-$PWD}
231 export I_MOUNTED=${I_MOUNTED:-"no"}
232 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
233 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
234 ! -f `dirname $0`/../mds/mds.ko ]; then
235 export CLIENTMODSONLY=yes
238 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
242 while getopts "rvwf:" opt $*; do
245 r) REFORMAT=--reformat;;
247 w) WRITECONF=writeconf;;
252 shift $((OPTIND - 1))
255 # print the durations of each test if "true"
256 DDETAILS=${DDETAILS:-false}
257 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
262 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
263 *) EXT=".ko"; USE_QUOTA=yes;;
268 /sbin/lsmod | grep -q $1
271 # Load a module on the system where this is running.
273 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
275 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
276 # will be used as the arguments. Otherwise arguments will be obtained from
277 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
284 BASE=`basename $module $EXT`
286 module_loaded ${BASE} && return
288 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
290 if [ $# -eq 0 ]; then
291 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
292 # Bash until 4.x, so we resort to eval.
293 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
294 eval set -- \$$optvar
295 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
296 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
297 set -- $(grep -P "^options\\s+${BASE}" $MODPROBECONF)
298 # Get rid of "options $module"
299 (($# > 0)) && shift 2
301 # Ensure we have accept=all for lnet
302 if [ $(basename $module) = lnet ]; then
303 # OK, this is a bit wordy...
304 local arg accept_all_present=false
306 [ "$arg" = accept=all ] && accept_all_present=true
308 $accept_all_present || set -- "$@" accept=all
313 [ $# -gt 0 ] && echo "${module} options: '$*'"
315 # Note that insmod will ignore anything in modprobe.conf, which is why we're
316 # passing options on the command-line.
317 if [ "$BASE" == "lnet_selftest" ] && \
318 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
319 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
320 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
321 insmod ${LUSTRE}/${module}${EXT} "$@"
323 # must be testing a "make install" or "rpm" installation
324 # note failed to load ptlrpc_gss is considered not fatal
325 if [ "$BASE" == "ptlrpc_gss" ]; then
326 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
333 load_modules_local() {
334 if [ -n "$MODPROBE" ]; then
336 echo "Using modprobe to load modules"
340 echo Loading modules from $LUSTRE
341 load_module ../libcfs/libcfs/libcfs
342 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
343 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
344 load_module ../lnet/lnet/lnet
345 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
346 load_module ../lnet/klnds/$LNETLND
347 load_module lvfs/lvfs
348 load_module obdclass/obdclass
349 load_module ptlrpc/ptlrpc
350 load_module ptlrpc/gss/ptlrpc_gss
351 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
359 if ! client_only; then
360 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
361 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
362 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
363 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
368 load_module lvfs/fsfilt_$FSTYPE
370 load_module osd-ldiskfs/osd_ldiskfs
372 load_module obdfilter/obdfilter
375 load_module llite/lustre
376 load_module llite/llite_lloop
377 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
379 rm -f $OGDB/ogdb-$HOSTNAME
380 $LCTL modules > $OGDB/ogdb-$HOSTNAME
382 # 'mount' doesn't look in $PATH, just sbin
383 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
389 # load modules on remote nodes optionally
390 # lustre-tests have to be installed on these nodes
391 if $LOAD_MODULES_REMOTE ; then
392 local list=$(comma_list $(remote_nodes_list))
393 echo loading modules on $list
394 do_rpc_nodes $list load_modules
399 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
400 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
401 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
402 echo "$LEAK_LUSTRE" 1>&2
403 echo "$LEAK_PORTALS" 1>&2
404 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
405 echo "Memory leaks detected"
406 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
412 wait_exit_ST client # bug 12845
414 $LUSTRE_RMMOD $FSTYPE || return 2
416 if $LOAD_MODULES_REMOTE ; then
417 local list=$(comma_list $(remote_nodes_list))
418 if [ ! -z $list ]; then
419 echo unloading modules on $list
420 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
421 do_rpc_nodes $list check_mem_leak
425 check_mem_leak || return 254
427 echo "modules unloaded."
431 check_gss_daemon_nodes() {
435 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
436 if [ \\\"\\\$num\\\" -ne 1 ]; then
437 echo \\\$num instance of $dname;
442 check_gss_daemon_facet() {
446 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
447 if [ $num -ne 1 ]; then
448 echo "$num instance of $dname on $facet"
457 echo Stopping $@ on $list
458 do_nodes $list "killall -2 $@ 2>/dev/null || true"
461 # start gss daemons on all nodes, or
462 # "daemon" on "list" if set
463 start_gss_daemons() {
467 if [ "$list" ] && [ "$daemon" ] ; then
468 echo "Starting gss daemon on nodes: $list"
469 do_nodes $list "$daemon" || return 8
473 local list=$(comma_list $(mdts_nodes))
475 echo "Starting gss daemon on mds: $list"
476 do_nodes $list "$LSVCGSSD -v" || return 1
478 do_nodes $list "$LGSSD -v" || return 2
481 list=$(comma_list $(osts_nodes))
482 echo "Starting gss daemon on ost: $list"
483 do_nodes $list "$LSVCGSSD -v" || return 3
484 # starting on clients
486 local clients=${CLIENTS:-`hostname`}
488 echo "Starting $LGSSD on clients $clients "
489 do_nodes $clients "$LGSSD -v" || return 4
492 # wait daemons entering "stable" status
496 # check daemons are running
498 list=$(comma_list $(mdts_nodes) $(osts_nodes))
499 check_gss_daemon_nodes $list lsvcgssd || return 5
501 list=$(comma_list $(mdts_nodes))
502 check_gss_daemon_nodes $list lgssd || return 6
505 check_gss_daemon_nodes $clients lgssd || return 7
510 local list=$(comma_list $(mdts_nodes))
512 send_sigint $list lsvcgssd lgssd
514 list=$(comma_list $(osts_nodes))
515 send_sigint $list lsvcgssd
517 list=${CLIENTS:-`hostname`}
518 send_sigint $list lgssd
523 if ! module_loaded ptlrpc_gss; then
524 load_module ptlrpc/gss/ptlrpc_gss
525 module_loaded ptlrpc_gss ||
526 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
528 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
530 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
531 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
539 # maybe cleanup credential cache?
545 local device=`mdsdevname $num`
546 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
552 local device=`ostdevname $num`
553 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
559 local facets=${1:-$(get_facets)}
562 for facet in ${facets//,/ }; do
563 mount_facet $facet || error "Restart of $facet failed!"
570 local dev=$(facet_active $facet)_dev
571 local opt=${facet}_opt
572 local mntpt=$(facet_mntpt $facet)
574 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
575 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
577 if [ $RC -ne 0 ]; then
578 echo "mount -t lustre $@ ${!dev} $mntpt"
579 echo "Start of ${!dev} on ${facet} failed ${RC}"
581 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
582 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
583 lctl set_param debug_mb=${DEBUG_SIZE}; \
586 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
587 [ -z "$label" ] && echo no label for ${!dev} && exit 1
588 eval export ${facet}_svc=${label}
589 echo Started ${label}
594 # start facet device options
600 eval export ${facet}_dev=${device}
601 eval export ${facet}_opt=\"$@\"
603 local varname=${facet}failover_dev
604 if [ -n "${!varname}" ] ; then
605 eval export ${facet}failover_dev=${!varname}
607 eval export ${facet}failover_dev=$device
610 local mntpt=$(facet_mntpt $facet)
611 do_facet ${facet} mkdir -p $mntpt
612 eval export ${facet}_MOUNT=$mntpt
622 local HOST=`facet_active_host $facet`
623 [ -z $HOST ] && echo stop: no host for $facet && return 0
625 local mntpt=$(facet_mntpt $facet)
626 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
627 if [ ${running} -ne 0 ]; then
628 echo "Stopping $mntpt (opts:$@)"
629 do_facet ${facet} umount -d $@ $mntpt
632 # umount should block, but we should wait for unrelated obd's
633 # like the MGS or MGC to also stop.
634 wait_exit_ST ${facet}
637 # save quota version (both administrative and operational quotas)
638 # add an additional parameter if mountpoint is ever different from $MOUNT
639 quota_save_version() {
640 local fsname=${2:-$FSNAME}
642 local ver=$(tr -c -d "123" <<< $spec)
643 local type=$(tr -c -d "ug" <<< $spec)
645 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
647 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
649 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
651 local osts=$(get_facets OST)
652 for ost in ${osts//,/ }; do
654 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
658 # client could mount several lustre
660 local fsname=${1:-$FSNAME}
662 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
663 do_nodes $(comma_list $(osts_nodes)) \
664 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
668 restore_quota_type () {
669 local mntpt=${1:-$MOUNT}
670 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
671 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
674 quota_save_version $old_QUOTA_TYPE
680 # We need save the original quota_type params, and restore them after testing
682 # Suppose that quota type the same on mds and ost
683 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
684 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
685 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
686 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
687 export old_QUOTA_TYPE=$quota_type
688 quota_save_version $QUOTA_TYPE
690 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
691 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
694 local quota_usrs=$QUOTA_USERS
696 # get_filesystem_size
697 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
698 local blk_soft=$((disksz + 1024))
699 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
701 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
703 local i_hard=$((i_soft + i_soft / 20))
705 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
706 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
709 for usr in $quota_usrs; do
710 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
712 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
714 eval $cmd || error "$cmd FAILED!"
716 # display the quota status
717 echo "Quota settings for $usr : "
718 $LFS quota -v -u $usr $mntpt || true
725 local OPTIONS=${3:-$MOUNTOPT}
727 local device=$MGSNID:/$FSNAME
728 if [ -z "$mnt" -o -z "$FSNAME" ]; then
729 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
733 echo "Starting client: $client: $OPTIONS $device $mnt"
734 do_node $client mkdir -p $mnt
735 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
737 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
738 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
739 lctl set_param debug_mb=${DEBUG_SIZE}"
752 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
753 if [ $running -ne 0 ]; then
754 echo "Stopping client $client $mnt (opts:$force)"
755 do_node $client lsof -t $mnt || need_kill=no
756 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
757 pids=$(do_node $client lsof -t $mnt | sort -u);
758 if [ -n $pids ]; then
759 do_node $client kill -9 $pids || true
763 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
764 if [ $busy -ne 0 ] ; then
765 echo "$mnt is still busy, wait one second" && sleep 1
766 do_node $client umount $force $mnt
771 # nodes is comma list
772 sanity_mount_check_nodes () {
778 # FIXME: assume that all cluster nodes run the same os
779 [ "$(uname)" = Linux ] || return 0
782 for mnt in $mnts ; do
783 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
784 mpts=\\\$(mount | grep -w -c $mnt);
785 if [ \\\$running -ne \\\$mpts ]; then
786 echo \\\$(hostname) env are INSANE!;
794 sanity_mount_check_servers () {
796 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
797 echo Checking servers environments
799 # FIXME: modify get_facets to display all facets wo params
800 local facets="$(get_facets OST),$(get_facets MDS),mgs"
804 for facet in ${facets//,/ }; do
805 node=$(facet_host ${facet})
806 mntpt=$(facet_mntpt $facet)
807 sanity_mount_check_nodes $node $mntpt ||
808 { error "server $node environments are insane!"; return 1; }
812 sanity_mount_check_clients () {
813 local clients=${1:-$CLIENTS}
814 local mntpt=${2:-$MOUNT}
815 local mntpt2=${3:-$MOUNT2}
817 [ -z $clients ] && clients=$(hostname)
818 echo Checking clients $clients environments
820 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
821 error "clients environments are insane!"
824 sanity_mount_check () {
825 sanity_mount_check_servers || return 1
826 sanity_mount_check_clients || return 2
829 # mount clients if not mouted
830 zconf_mount_clients() {
833 local OPTIONS=${3:-$MOUNTOPT}
835 local device=$MGSNID:/$FSNAME
836 if [ -z "$mnt" -o -z "$FSNAME" ]; then
837 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
841 echo "Starting client $clients: $OPTIONS $device $mnt"
844 running=\\\$(mount | grep -c $mnt' ');
846 if [ \\\$running -eq 0 ] ; then
848 mount -t lustre $OPTIONS $device $mnt;
851 exit \\\$rc" || return ${PIPESTATUS[0]}
853 echo "Started clients $clients: "
854 do_nodes $clients "mount | grep -w $mnt"
856 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
857 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
858 lctl set_param debug_mb=${DEBUG_SIZE};"
863 zconf_umount_clients() {
870 echo "Stopping clients: $clients $mnt (opts:$force)"
871 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
872 if [ \\\$running -ne 0 ] ; then
873 echo Stopping client \\\$(hostname) $mnt opts:$force;
874 lsof -t $mnt || need_kill=no;
875 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
876 pids=\\\$(lsof -t $mnt | sort -u);
877 if [ -n \\\"\\\$pids\\\" ]; then
881 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
882 if [ \\\$busy -ne 0 ] ; then
883 echo "$mnt is still busy, wait one second" && sleep 1;
891 echo + $POWER_DOWN $node
895 shutdown_node_hard () {
897 local attempts=$SHUTDOWN_ATTEMPTS
899 for i in $(seq $attempts) ; do
902 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
903 echo "waiting for $host to fail attempts=$attempts"
904 [ $i -lt $attempts ] || \
905 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
911 local mnt=${2:-$MOUNT}
914 if [ "$FAILURE_MODE" = HARD ]; then
915 shutdown_node_hard $client
917 zconf_umount_clients $client $mnt -f
923 local facets="$(get_facets OST),$(get_facets MDS)"
926 combined_mgs_mds || facets="$facets,mgs"
928 for facet in ${facets//,/ }; do
929 if [ $(facet_active_host $facet) == $host ]; then
930 affected="$affected $facet"
934 echo $(comma_list $affected)
939 local host=${2:-$(facet_host $facet)}
941 local label=$(convert_facet2label $facet)
942 do_node $host lctl dl | awk '{print $4}' | grep -q $label
945 facets_up_on_host () {
947 local facets=$(facets_on_host $host)
950 for facet in ${facets//,/ }; do
951 if $(facet_up $facet $host); then
952 affected_up="$affected_up $facet"
956 echo $(comma_list $affected_up)
962 if [ "$FAILURE_MODE" = HARD ]; then
963 shutdown_node_hard $(facet_active_host $facet)
971 echo + $POWER_UP $node
984 if [ "$FAILURE_MODE" = HARD ]; then
985 reboot_node $(facet_active_host $facet)
993 if [ "$FAILURE_MODE" = HARD ]; then
1003 for facet in ${facets//,/ }; do
1004 hosts=$(expand_list $hosts $(facet_host $facet) )
1010 _check_progs_installed () {
1014 for prog in $progs; do
1015 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1016 echo $prog missing on $(hostname)
1023 check_progs_installed () {
1027 do_rpc_nodes $nodes _check_progs_installed $@
1030 # recovery-scale functions
1032 echo __$(echo $1 | tr '-' 'X')
1035 start_client_load() {
1038 local var=$(client_var_name $client)_load
1039 eval export ${var}=$load
1041 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1042 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1043 END_RUN_FILE=$END_RUN_FILE \
1044 LOAD_PID_FILE=$LOAD_PID_FILE \
1045 TESTSUITELOG=$TESTSUITELOG \
1047 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1048 log "Started client load: ${load} on $client"
1053 start_client_loads () {
1054 local -a clients=(${1//,/ })
1055 local numloads=${#CLIENT_LOADS[@]}
1058 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1059 testnum=$((nodenum % numloads))
1060 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1062 # bug 22169: wait the background threads to start
1066 # only for remote client
1067 check_client_load () {
1069 local var=$(client_var_name $client)_load
1070 local TESTLOAD=run_${!var}.sh
1072 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1074 # bug 18914: try to connect several times not only when
1075 # check ps, but while check_catastrophe also
1078 while [ $RC = 254 -a $tries -gt 0 ]; do
1082 if ! check_catastrophe $client; then
1084 if [ $RC -eq 254 ]; then
1085 # FIXME: not sure how long we shuold sleep here
1089 echo "check catastrophe failed: RC=$RC "
1093 # We can continue try to connect if RC=254
1094 # Just print the warning about this
1095 if [ $RC = 254 ]; then
1096 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1099 # see if the load is still on the client
1102 while [ $RC = 254 -a $tries -gt 0 ]; do
1106 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1111 if [ $RC = 254 ]; then
1112 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1113 # see if we can diagnose a bit why this is
1118 check_client_loads () {
1119 local clients=${1//,/ }
1123 for client in $clients; do
1124 check_client_load $client
1126 if [ "$rc" != 0 ]; then
1127 log "Client load failed on node $client, rc=$rc"
1133 restart_client_loads () {
1134 local clients=${1//,/ }
1135 local expectedfail=${2:-""}
1139 for client in $clients; do
1140 check_client_load $client
1142 if [ "$rc" != 0 -a "$expectedfail" ]; then
1143 local var=$(client_var_name $client)_load
1144 start_client_load $client ${!var}
1145 echo "Restarted client load ${!var}: on $client. Checking ..."
1146 check_client_load $client
1148 if [ "$rc" != 0 ]; then
1149 log "Client load failed to restart on node $client, rc=$rc"
1150 # failure one client load means test fail
1151 # we do not need to check other
1159 # End recovery-scale functions
1161 # verify that lustre actually cleaned up properly
1163 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1164 error "LBUG/LASSERT detected"
1165 BUSY=`dmesg | grep -i destruct || true`
1166 if [ "$BUSY" ]; then
1168 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1172 check_mem_leak || exit 204
1174 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1175 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1177 if module_loaded lnet || module_loaded libcfs; then
1178 echo "$0: modules still loaded..." 1>&2
1195 RESULT=$(do_node $node "$TEST")
1196 if [ "$RESULT" == "$FINAL" ]; then
1197 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1200 [ $WAIT -ge $MAX ] && break
1201 echo "Waiting $((MAX - WAIT)) secs for update"
1202 WAIT=$((WAIT + sleep))
1205 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1209 wait_update_facet () {
1211 wait_update $(facet_active_host $facet) "$@"
1214 wait_delete_completed () {
1215 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1216 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1220 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1222 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1223 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1224 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1225 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1229 echo "Delete is not completed in $MAX_WAIT sec"
1236 # we can use "for" here because we are waiting the slowest
1237 for host in ${hostlist//,/ }; do
1238 check_network "$host" 900
1240 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1247 for facet in ${facetlist//,/ }; do
1248 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1250 wait_for_host $hostlist
1253 _wait_recovery_complete () {
1256 # Use default policy if $2 is not passed by caller.
1257 local MAX=${2:-$(max_recovery_time)}
1262 while [ $WAIT -lt $MAX ]; do
1263 STATUS=$(lctl get_param -n $param | grep status)
1265 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1268 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1270 echo "$param recovery not done in $MAX sec. $STATUS"
1274 wait_recovery_complete () {
1277 # with an assumption that at_max is the same on all nodes
1278 local MAX=${2:-$(max_recovery_time)}
1281 if [ "$FAILURE_MODE" = HARD ]; then
1282 facets=$(facets_on_host $(facet_active_host $facet))
1284 echo affected facets: $facets
1286 # we can use "for" here because we are waiting the slowest
1287 for facet in ${facets//,/ }; do
1288 local var_svc=${facet}_svc
1289 local param="*.${!var_svc}.recovery_status"
1291 local host=$(facet_active_host $facet)
1292 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1296 wait_mds_ost_sync () {
1297 # just because recovery is done doesn't mean we've finished
1298 # orphan cleanup. Wait for llogs to get synchronized.
1299 echo "Waiting for orphan cleanup..."
1300 # MAX value includes time needed for MDS-OST reconnection
1301 local MAX=$(( TIMEOUT * 2 ))
1303 while [ $WAIT -lt $MAX ]; do
1304 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1305 "$LCTL get_param -n obdfilter.*.mds_sync"))
1308 for ((i=0; i<${#sync[@]}; i++)); do
1309 [ ${sync[$i]} -eq 0 ] && continue
1310 # there is a not finished MDS-OST synchronization
1314 sleep 2 # increase waiting time and cover statfs cache
1315 [ ${con} -eq 1 ] && return 0
1316 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1319 echo "$facet recovery not done in $MAX sec. $STATUS"
1323 wait_destroy_complete () {
1324 echo "Waiting for destroy to be done..."
1325 # MAX value shouldn't be big as this mean server responsiveness
1326 # never increase this just to make test pass but investigate
1327 # why it takes so long time
1330 while [ $WAIT -lt $MAX ]; do
1331 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1333 for ((i=0; i<${#RPCs[@]}; i++)); do
1334 [ ${RPCs[$i]} -eq 0 ] && continue
1335 # there are still some destroy RPCs in flight
1340 [ ${con} -eq 1 ] && return 0 # done waiting
1341 echo "Waiting $WAIT secs for destroys to be done."
1344 echo "Destroys weren't done in $MAX sec."
1354 # conf-sanity 31 takes a long time cleanup
1355 while [ $WAIT -lt 300 ]; do
1356 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1357 [ -z "${running}" ] && return 0
1358 echo "waited $WAIT for${running}"
1359 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1361 WAIT=$((WAIT + INTERVAL))
1363 echo "service didn't stop after $WAIT seconds. Still running:"
1368 wait_remote_prog () {
1374 [ "$PDSH" = "no_dsh" ] && return 0
1376 while [ $WAIT -lt $2 ]; do
1377 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1378 [ -z "${running}" ] && return 0 || true
1379 echo "waited $WAIT for: "
1381 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1383 WAIT=$((WAIT + INTERVAL))
1385 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1386 [ -z "$pids" ] && return 0
1387 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1388 # FIXME: not portable
1389 for pid in $pids; do
1390 cat /proc/${pid}/status || true
1391 cat /proc/${pid}/wchan || true
1393 kill -9 $pid || true
1402 # not every config has many clients
1404 if [ ! -z "$CLIENTS" ]; then
1405 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1407 stat -f $MOUNT > /dev/null
1413 # usually checked on particular client or locally
1415 if [ ! -z "$client" ]; then
1416 $PDSH $client "stat -f $MOUNT" > /dev/null
1418 stat -f $MOUNT > /dev/null
1426 client_reconnect() {
1427 uname -n >> $MOUNT/recon
1428 if [ -z "$CLIENTS" ]; then
1429 df $MOUNT; uname -n >> $MOUNT/recon
1431 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1433 echo Connected clients:
1435 ls -l $MOUNT/recon > /dev/null
1439 affected_facets () {
1442 local host=$(facet_active_host $facet)
1443 local affected=$facet
1445 if [ "$FAILURE_MODE" = HARD ]; then
1446 affected=$(facets_up_on_host $host)
1454 local host=$(facet_active_host $facet)
1456 echo "Failing $facet on node $host"
1458 local affected=$(affected_facets $facet)
1460 shutdown_facet $facet
1462 echo affected facets: $affected
1464 [ -n "$sleep_time" ] && sleep $sleep_time
1468 change_active $affected
1470 wait_for_facet $affected
1471 # start mgs first if it is affected
1472 if ! combined_mgs_mds && list_member $affected mgs; then
1473 mount_facet mgs || error "Restart of mgs failed"
1475 # FIXME; has to be changed to mount all facets concurrently
1476 affected=$(exclude_items_from_list $affected mgs)
1477 mount_facets $affected
1486 do_facet $facet sync
1489 # make sure there will be no seq change
1490 local clients=${CLIENTS:-$HOSTNAME}
1491 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1493 local svc=${facet}_svc
1494 do_facet $facet $LCTL --device %${!svc} notransno
1495 do_facet $facet $LCTL --device %${!svc} readonly
1496 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1497 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1500 replay_barrier_nodf() {
1501 local facet=$1 echo running=${running}
1502 do_facet $facet sync
1503 local svc=${facet}_svc
1504 echo Replay barrier on ${!svc}
1505 do_facet $facet $LCTL --device %${!svc} notransno
1506 do_facet $facet $LCTL --device %${!svc} readonly
1507 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1508 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1511 replay_barrier_nosync() {
1512 local facet=$1 echo running=${running}
1513 local svc=${facet}_svc
1514 echo Replay barrier on ${!svc}
1515 do_facet $facet $LCTL --device %${!svc} notransno
1516 do_facet $facet $LCTL --device %${!svc} readonly
1517 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1518 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1521 mds_evict_client() {
1522 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1523 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1526 ost_evict_client() {
1527 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1528 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1532 facet_failover $* || error "failover: $?"
1533 clients_up || error "post-failover df: $?"
1538 facet_failover $facet
1544 change_active $facet
1545 mount_facet $facet -o abort_recovery
1546 clients_up || echo "first df failed: $?"
1547 clients_up || error "post-failover df: $?"
1551 echo There is no lmc. This is mountconf, baby.
1556 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1562 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1563 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1564 if [ -z "$ID" ]; then
1565 echo "Could not get a ptl id for $1..."
1574 h2name_or_ip "$1" "tcp"
1579 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1580 if type __h2elan >/dev/null 2>&1; then
1583 ID=`echo $1 | sed 's/[^0-9]*//g'`
1591 h2name_or_ip "$1" "o2ib"
1598 [ "$facet" == client ] && echo -n $HOSTNAME && return
1599 varname=${facet}_HOST
1600 if [ -z "${!varname}" ]; then
1601 if [ "${facet:0:3}" == "ost" ]; then
1602 eval ${facet}_HOST=${ost_HOST}
1610 local activevar=${facet}active
1612 if [ -f $TMP/${facet}active ] ; then
1613 source $TMP/${facet}active
1616 active=${!activevar}
1617 if [ -z "$active" ] ; then
1624 facet_active_host() {
1626 local active=`facet_active $facet`
1627 if [ "$facet" == client ]; then
1630 echo `facet_host $active`
1638 facetlist=$(exclude_items_from_list $facetlist mgs)
1640 for facet in ${facetlist//,/ }; do
1641 local failover=${facet}failover
1642 local host=`facet_host $failover`
1643 [ -z "$host" ] && return
1645 local curactive=`facet_active $facet`
1646 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1647 eval export ${facet}active=$facet
1649 eval export ${facet}active=$failover
1651 # save the active host for this facet
1652 local activevar=${facet}active
1653 echo "$activevar=${!activevar}" > $TMP/$activevar
1654 local TO=`facet_active_host $facet`
1655 echo "Failover $facet to $TO"
1661 # do not stripe off hostname if verbose, bug 19215
1662 if [ x$1 = x--verbose ]; then
1670 if [ "$HOST" = "$HOSTNAME" ]; then
1672 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1673 echo "cannot run remote command on $HOST with $myPDSH"
1677 echo "CMD: $HOST $@" >&2
1678 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1681 if [ "$myPDSH" = "rsh" ]; then
1682 # we need this because rsh does not return exit code of an executed command
1683 local command_status="$TMP/cs"
1684 rsh $HOST ":> $command_status"
1685 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1686 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1687 echo command failed >$command_status"
1688 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1693 # print HOSTNAME for myPDSH="no_dsh"
1694 if [[ $myPDSH = no_dsh ]]; then
1695 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1697 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1700 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1702 return ${PIPESTATUS[0]}
1706 do_node --verbose "$@"
1709 single_local_node () {
1710 [ "$1" = "$HOSTNAME" ]
1713 # Outputs environment variable assignments that should be passed to remote nodes
1718 for var in ${!MODOPTS_*}; do
1720 echo "${var}=\"$value\""
1726 # do not stripe off hostname if verbose, bug 19215
1727 if [ x$1 = x--verbose ]; then
1735 if single_local_node $rnodes; then
1737 do_nodev $rnodes "$@"
1739 do_node $rnodes "$@"
1744 # This is part from do_node
1747 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1748 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1751 echo "CMD: $rnodes $@" >&2
1752 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1755 # do not replace anything from pdsh output if -N is used
1756 # -N Disable hostname: prefix on lines of output.
1757 if $verbose || [[ $myPDSH = *-N* ]]; then
1758 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1760 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1762 return ${PIPESTATUS[0]}
1768 local HOST=`facet_active_host $facet`
1769 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1774 do_nodes --verbose "$@"
1780 # make sure its not already running
1782 rm -f $TMP/${facet}active
1783 do_facet ${facet} $MKFS $*
1789 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1790 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1797 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1798 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1804 local var=${facet}_MOUNT
1805 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1814 # make sure we are using the primary server, so test-framework will
1815 # be able to clean up properly.
1816 activemds=`facet_active mds1`
1817 if [ $activemds != "mds1" ]; then
1821 local clients=$CLIENTS
1822 [ -z $clients ] && clients=$(hostname)
1824 zconf_umount_clients $clients $MOUNT "$*" || true
1825 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1827 [ "$CLIENTONLY" ] && return
1828 # The add fn does rm ${facet}active file, this would be enough
1829 # if we use do_facet <facet> only after the facet added, but
1830 # currently we use do_facet mds in local.sh
1831 for num in `seq $MDSCOUNT`; do
1833 rm -f ${TMP}/mds${num}active
1836 for num in `seq $OSTCOUNT`; do
1838 rm -f $TMP/ost${num}active
1841 if ! combined_mgs_mds ; then
1848 cleanup_echo_devs () {
1849 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1851 for dev in $devs; do
1852 $LCTL --device $dev cleanup
1853 $LCTL --device $dev detach
1858 nfs_client_mode && return
1867 combined_mgs_mds () {
1868 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1874 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1875 local optvar=${tgt}_MKFS_OPTS
1876 local opt=${!optvar}
1878 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1879 [[ $facet = mgs ]] && echo $opt && return
1882 # --failnode options
1883 local var=${facet}failover_HOST
1884 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1885 local failnode=$(h2$NETTYPE ${!var})
1886 failnode="--failnode=$failnode"
1887 # options does not contain
1888 # or contains wrong --failnode=
1889 if [[ $opt != *${failnode}* ]]; then
1890 opt=$(echo $opt | sed 's/--failnode=.* / /')
1891 opt="$opt $failnode"
1897 # no additional mkfs mds "--mgsnode" option for this configuration
1898 if [[ $facet = mds ]] && combined_mgs_mds; then
1903 # additional mkfs "--mgsnode"
1904 local mgsnode="--mgsnode=$MGSNID"
1905 opt=${opt//$mgsnode }
1906 for nid in ${MGSNID//:/ }; do
1907 local mgsnode="--mgsnode=$nid"
1908 # options does not contain
1910 if [[ $opt != *${mgsnode}" "* ]]; then
1911 opt="$opt --mgsnode=$nid"
1919 if [ "$IAMDIR" == "yes" ]; then
1920 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1923 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1926 # We need ldiskfs here, may as well load them all
1928 [ "$CLIENTONLY" ] && return
1929 echo Formatting mgs, mds, osts
1930 if ! combined_mgs_mds ; then
1931 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1934 for num in `seq $MDSCOUNT`; do
1935 echo "Format mds$num: $(mdsdevname $num)"
1937 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
1939 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
1943 # the ost-s could have different OST_MKFS_OPTS
1944 # because of different failnode-s
1945 for num in `seq $OSTCOUNT`; do
1946 echo "Format ost$num: $(ostdevname $num)"
1948 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1950 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1956 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1960 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1964 # 0: success, the old identity set already.
1965 # 1: success, the old identity does not set.
1970 local j=`expr $num - 1`
1971 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1973 if [ -z "$MDT" ]; then
1977 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1980 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1982 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1985 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
1987 if [ $old = "NONE" ]; then
1996 zconf_umount `hostname` $1 || error "umount failed"
1997 zconf_mount `hostname` $1 || error "mount failed"
2000 writeconf_facet () {
2004 do_facet $facet "$TUNEFS --writeconf $dev"
2008 for num in `seq $MDSCOUNT`; do
2009 DEVNAME=$(mdsdevname $num)
2010 writeconf_facet mds$num $DEVNAME
2013 for num in `seq $OSTCOUNT`; do
2014 DEVNAME=$(ostdevname $num)
2015 writeconf_facet ost$num $DEVNAME
2020 nfs_client_mode && return
2022 sanity_mount_check ||
2023 error "environments are insane!"
2027 if [ -z "$CLIENTONLY" ]; then
2028 echo Setup mgs, mdt, osts
2029 echo $WRITECONF | grep -q "writeconf" && \
2031 if ! combined_mgs_mds ; then
2032 start mgs $MGSDEV $MGS_MOUNT_OPTS
2035 for num in `seq $MDSCOUNT`; do
2036 DEVNAME=$(mdsdevname $num)
2037 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2039 # We started mds, now we should set failover variables properly.
2040 # Set mds${num}failover_HOST if it is not set (the default failnode).
2041 local varname=mds${num}failover_HOST
2042 if [ -z "${!varname}" ]; then
2043 eval mds${num}failover_HOST=$(facet_host mds$num)
2046 if [ $IDENTITY_UPCALL != "default" ]; then
2047 switch_identity $num $IDENTITY_UPCALL
2050 for num in `seq $OSTCOUNT`; do
2051 DEVNAME=$(ostdevname $num)
2052 start ost$num $DEVNAME $OST_MOUNT_OPTS
2054 # We started ost$num, now we should set ost${num}failover variable properly.
2055 # Set ost${num}failover_HOST if it is not set (the default failnode).
2056 varname=ost${num}failover_HOST
2057 if [ -z "${!varname}" ]; then
2058 eval ost${num}failover_HOST=$(facet_host ost${num})
2066 # wait a while to allow sptlrpc configuration be propogated to targets,
2067 # only needed when mounting new target devices.
2072 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2074 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2076 if [ "$MOUNT_2" ]; then
2077 mount_client $MOUNT2
2078 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2083 # by remounting mdt before ost, initial connect from mdt to ost might
2084 # timeout because ost is not ready yet. wait some time to its fully
2085 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2086 # by a context negotiation rpc with $TIMEOUT.
2087 # FIXME better by monitoring import status.
2090 sleep $((TIMEOUT + 5))
2096 mounted_lustre_filesystems() {
2097 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2100 init_facet_vars () {
2101 [ "$CLIENTONLY" ] && return 0
2108 eval export ${facet}_dev=${device}
2109 eval export ${facet}_opt=\"$@\"
2111 local dev=${facet}_dev
2112 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2113 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2115 eval export ${facet}_svc=${label}
2117 local varname=${facet}failover_HOST
2118 if [ -z "${!varname}" ]; then
2119 eval $varname=$(facet_host $facet)
2122 # ${facet}failover_dev is set in cfg file
2123 varname=${facet}failover_dev
2124 if [ -n "${!varname}" ] ; then
2125 eval export ${facet}failover_dev=${!varname}
2127 eval export ${facet}failover_dev=$device
2130 # get mount point of already mounted device
2131 # is facet_dev is already mounted then use the real
2132 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2133 # i.e. ${facet}_MOUNT if specified by user or default
2134 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2135 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2136 if [ -z $mntpt ]; then
2137 mntpt=$(facet_mntpt $facet)
2139 eval export ${facet}_MOUNT=$mntpt
2142 init_facets_vars () {
2145 if ! remote_mds_nodsh; then
2146 for num in `seq $MDSCOUNT`; do
2147 DEVNAME=`mdsdevname $num`
2148 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2152 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2154 remote_ost_nodsh && return
2156 for num in `seq $OSTCOUNT`; do
2157 DEVNAME=`ostdevname $num`
2158 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2162 osc_ensure_active () {
2167 while [ $period -lt $timeout ]; do
2168 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2169 if [ $count -eq 0 ]; then
2173 echo "There are $count OST are inactive, wait $period seconds, and try again"
2175 period=$((period+3))
2178 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2181 init_param_vars () {
2182 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2183 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2184 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2185 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2189 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2191 log "Using TIMEOUT=$TIMEOUT"
2193 osc_ensure_active $SINGLEMDS $TIMEOUT
2194 osc_ensure_active client $TIMEOUT
2196 if [ $QUOTA_AUTO -ne 0 ]; then
2197 if [ "$ENABLE_QUOTA" ]; then
2198 echo "enable quota as required"
2199 setup_quota $MOUNT || return 2
2201 echo "disable quota as required"
2202 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2209 nfs_client_mode () {
2210 if [ "$NFSCLIENT" ]; then
2211 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2212 local clients=$CLIENTS
2213 [ -z $clients ] && clients=$(hostname)
2215 # FIXME: remove hostname when 19215 fixed
2216 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2217 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2218 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2219 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2221 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2227 check_config_client () {
2230 local mounted=$(mount | grep " $mntpt ")
2231 if [ "$CLIENTONLY" ]; then
2233 # CLIENTONLY should not depend on *_HOST settings
2234 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2235 # in theory someone could create a new,
2236 # client-only config file that assumed lustre was already
2237 # configured and didn't set the MGSNID. If MGSNID is not set,
2238 # then we should use the mgs nid currently being used
2239 # as the default value. bug 18021
2240 [[ x$MGSNID = x ]] &&
2243 if [[ x$mgc != xMGC$MGSNID ]]; then
2244 if [ "$mgs_HOST" ]; then
2245 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2246 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2247 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2253 local myMGS_host=$mgs_HOST
2254 if [ "$NETTYPE" = "ptl" ]; then
2255 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2258 echo Checking config lustre mounted on $mntpt
2259 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2260 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2262 # if [ "$mgshost" != "$myMGS_host" ]; then
2263 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2264 # Please use correct config or set mds_HOST correctly!"
2269 check_config_clients () {
2270 local clients=${CLIENTS:-$HOSTNAME}
2273 nfs_client_mode && return
2275 do_rpc_nodes $clients check_config_client $mntpt
2277 sanity_mount_check ||
2278 error "environments are insane!"
2282 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2283 local cltimeout=$(lctl get_param -n timeout)
2284 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2285 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2292 [ -z $mntpt ] && return 1
2293 local mounted=$(mounted_lustre_filesystems)
2295 echo $mounted' ' | grep -w -q $mntpt' '
2299 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2303 # empty lustre filesystem may have empty directories lost+found and .lustre
2305 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2306 -print | wc -l) = 1 ] || return 1
2307 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2308 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2312 check_and_setup_lustre() {
2313 nfs_client_mode && return
2315 local MOUNTED=$(mounted_lustre_filesystems)
2319 # both MOUNT and MOUNT2 are not mounted
2320 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2321 [ "$REFORMAT" ] && formatall
2322 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2324 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2325 export I_MOUNTED=yes
2329 elif is_mounted $MOUNT2; then
2331 # MOUNT2 is mounted, while MOUNT_2 is not set
2332 if ! [ "$MOUNT_2" ]; then
2333 cleanup_mount $MOUNT2
2334 export I_UMOUNTED2=yes
2337 # MOUNT2 is mounted, MOUNT_2 is set
2339 # FIXME: what to do if check_config failed?
2341 # 1) remote client has mounted other Lustre fs ?
2342 # 2) it has insane env ?
2343 # let's try umount MOUNT2 on all clients and mount it again:
2344 if ! check_config_clients $MOUNT2; then
2345 cleanup_mount $MOUNT2
2346 restore_mount $MOUNT2
2347 export I_MOUNTED2=yes
2352 # MOUNT is mounted MOUNT2 is not mounted
2353 elif [ "$MOUNT_2" ]; then
2354 restore_mount $MOUNT2
2355 export I_MOUNTED2=yes
2359 # FIXME: what to do if check_config failed?
2361 # 1) remote client has mounted other Lustre fs?
2362 # 2) lustre is mounted on remote_clients atall ?
2363 check_config_clients $MOUNT
2367 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2368 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2369 lctl set_param debug_mb=${DEBUG_SIZE};
2376 if [ "$ONLY" == "setup" ]; then
2382 local clients=${CLIENTS:-$HOSTNAME}
2385 zconf_mount_clients $clients $mntpt
2389 local clients=${CLIENTS:-$HOSTNAME}
2392 zconf_umount_clients $clients $mntpt
2395 cleanup_and_setup_lustre() {
2396 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2397 lctl set_param debug=0 || true
2399 if [ "$ONLY" == "cleanup" ]; then
2403 check_and_setup_lustre
2406 # Get all of the server target devices from a given server node and type.
2415 mdt) obd_type="osd" ;;
2416 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2417 *) echo "invalid server type" && return 1 ;;
2420 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2421 for dev in $devs; do
2423 *loop*) do_node $node "losetup $dev" | \
2424 sed -e "s/.*(//" -e "s/).*//" ;;
2430 # Get all of the server target devices.
2435 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2439 for node in $(osts_nodes); do
2440 OSTDEVS[i]=$(get_mnt_devs $node ost)
2445 # Run e2fsck on MDT or OST device.
2452 df > /dev/null # update statfs data on disk
2453 local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
2456 do_node $node $cmd || rc=$?
2457 [ $rc -le $FSCK_MAX_ERR ] || \
2458 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2462 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2469 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2470 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2471 error "fail to create file in $SHARED_DIRECTORY")
2473 # make sure everything gets to the backing store
2474 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2475 do_nodes $list "sync; sleep 2; sync"
2477 do_nodes $list ls $tmp_file || \
2478 error "$SHARED_DIRECTORY is not a shared directory"
2481 run_e2fsck $(mdts_nodes) $MDTDEV
2486 for node in $(osts_nodes); do
2487 for dev in ${OSTDEVS[i]}; do
2488 local ostdb_opt=`eval echo $OSTDB_OPT`
2489 run_e2fsck $node $dev $ostidx "$ostdb_opt"
2490 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2491 ostidx=$((ostidx + 1))
2498 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2502 [ $rc -le $FSCK_MAX_ERR ] || \
2503 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2504 echo "lfsck finished with rc=$rc"
2506 rm -rvf $MDSDB* $OSTDB* || true
2510 check_and_cleanup_lustre() {
2511 if [ "$LFSCK_ALWAYS" = "yes" ]; then
2514 if [ "$SKIP_LFSCK" == "no" ]; then
2521 if is_mounted $MOUNT; then
2522 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2523 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2526 if [ "$I_UMOUNTED2" = "yes" ]; then
2527 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2530 if [ "$I_MOUNTED2" = "yes" ]; then
2531 cleanup_mount $MOUNT2
2534 if [ "$I_MOUNTED" = "yes" ]; then
2535 cleanupall -f || error "cleanup failed"
2543 wait_for_function () {
2546 # suppress fn both stderr and stdout
2547 if [ "$1" = "--quiet" ]; then
2549 quiet=" > /dev/null 2>&1"
2561 eval $fn $quiet && return 0
2563 wait=$((wait + sleep))
2564 [ $wait -lt $max ] || return 1
2565 echo waiting $fn, $((max - wait)) secs left ...
2575 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2576 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2577 echo "Network not available!"
2581 echo `date +"%H:%M:%S (%s)"` network interface is UP
2590 # the sed converts spaces to commas, but leaves the last space
2591 # alone, so the line doesn't end with a comma.
2592 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2598 echo $list | grep -qw $item
2601 # list, excluded are the comma separated lists
2602 exclude_items_from_list () {
2608 for item in ${excluded//,/ }; do
2609 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2611 echo $(comma_list $list)
2614 # list, expand are the comma separated lists
2616 local list=${1//,/ }
2617 local expand=${2//,/ }
2620 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2621 echo $(comma_list $expanded)
2624 testslist_filter () {
2625 local script=$LUSTRE/tests/${TESTSUITE}.sh
2627 [ -f $script ] || return 0
2629 local start_at=$START_AT
2630 local stop_at=$STOP_AT
2632 local var=${TESTSUITE//-/_}_START_AT
2633 [ x"${!var}" != x ] && start_at=${!var}
2634 var=${TESTSUITE//-/_}_STOP_AT
2635 [ x"${!var}" != x ] && stop_at=${!var}
2637 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2638 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2639 /^'${start_at}'$/ {flag = 0}
2640 {if (flag == 1) print $0}
2641 /^'${stop_at}'$/ { flag = 1 }'
2645 (cd `dirname $1`; echo $PWD/`basename $1`)
2649 local types=${1:-"OST MDS MGS"}
2653 for entry in $types; do
2654 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2655 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2658 MGS ) list="$list $name";;
2659 MDS|OST ) local count=${type}COUNT
2660 for ((i=1; i<=${!count}; i++)) do
2661 list="$list ${name}$i"
2663 * ) error "Invalid facet type"
2667 echo $(comma_list $list)
2670 ##################################
2671 # Adaptive Timeouts funcs
2674 # only check mds, we assume at_max is the same on all nodes
2675 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2676 if [ $at_max -eq 0 ]; then
2686 # suppose that all ost-s has the same at_max set
2687 if [ $facet == "ost" ]; then
2688 do_facet ost1 "lctl get_param -n at_max"
2690 do_facet $facet "lctl get_param -n at_max"
2700 if [ $facet == "ost" ]; then
2701 for i in `seq $OSTCOUNT`; do
2702 do_facet ost$i "lctl set_param at_max=$at_max"
2705 elif [ $facet == "mds" ]; then
2706 for i in `seq $MDSCOUNT`; do
2707 do_facet mds$i "lctl set_param at_max=$at_max"
2710 do_facet $facet "lctl set_param at_max=$at_max"
2715 ##################################
2719 # OBD_FAIL_MDS_ALL_REQUEST_NET
2721 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2722 do_facet client "$1" || RC=$?
2723 do_facet $SINGLEMDS lctl set_param fail_loc=0
2728 # OBD_FAIL_MDS_ALL_REPLY_NET
2730 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2731 do_facet client "$@" || RC=$?
2732 do_facet $SINGLEMDS lctl set_param fail_loc=0
2736 drop_reint_reply() {
2737 # OBD_FAIL_MDS_REINT_NET_REP
2739 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2740 do_facet client "$@" || RC=$?
2741 do_facet $SINGLEMDS lctl set_param fail_loc=0
2746 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2748 do_facet ost1 lctl set_param fail_loc=0x214
2749 do_facet client "$1" || RC=$?
2750 do_facet client "sync"
2751 do_facet ost1 lctl set_param fail_loc=0
2755 drop_ldlm_cancel() {
2756 #define OBD_FAIL_LDLM_CANCEL 0x304
2758 do_facet client lctl set_param fail_loc=0x304
2759 do_facet client "$@" || RC=$?
2760 do_facet client lctl set_param fail_loc=0
2764 drop_bl_callback() {
2765 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2767 do_facet client lctl set_param fail_loc=0x305
2768 do_facet client "$@" || RC=$?
2769 do_facet client lctl set_param fail_loc=0
2774 #define OBD_FAIL_LDLM_REPLY 0x30c
2776 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2777 do_facet client "$@" || RC=$?
2778 do_facet $SINGLEMDS lctl set_param fail_loc=0
2786 echo "clearing fail_loc on $facet"
2787 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2790 set_nodes_failloc () {
2791 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2794 cancel_lru_locks() {
2795 $LCTL mark "cancel_lru_locks $1 start"
2796 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2797 $LCTL set_param -n $d=clear
2799 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2800 $LCTL mark "cancel_lru_locks $1 stop"
2805 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2806 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2807 echo "$DEFAULT_LRU_SIZE"
2812 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2815 lru_resize_disable()
2817 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2822 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2823 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2824 echo there is still data in page cache $FILE ?
2825 lctl get_param -n $FILE
2833 DEBUGSAVE="$(lctl get_param -n debug)"
2837 [ -n "$DEBUGSAVE" ] && \
2838 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2843 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2846 debug_size_restore() {
2847 [ -n "$DEBUG_SIZE_SAVED" ] && \
2848 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2852 start_full_debug_logging() {
2857 local DEBUG_SIZE=150
2859 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2860 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2863 stop_full_debug_logging() {
2868 ##################################
2870 ##################################
2873 local TYPE=${TYPE:-"FAIL"}
2876 # do not dump logs if $1=false
2877 if [ "x$1" = "xfalse" ]; then
2882 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2884 # We need to dump the logs on all nodes
2886 gather_logs $(comma_list $(nodes_list))
2890 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2891 echo "$@" > $LOGDIR/err
2896 local log=$TESTSUITELOG
2898 [ -f "$log" ] && grep -q FAIL $log && status=1
2911 # use only if we are ignoring failures for this test, bugno required.
2912 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2913 # e.g. error_ignore 5494 "your message"
2915 local TYPE="IGNORE (bz$1)"
2921 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2926 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2927 [ "$ALWAYS_SKIPPED" ] && \
2928 skip_logged ${TESTNAME} "$@" || true
2929 [ "$TESTSUITELOG" ] && \
2930 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2933 build_test_filter() {
2934 EXCEPT="$EXCEPT $(testslist_filter)"
2936 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2940 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2941 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2942 [ "$EXCEPT_SLOW" ] && \
2943 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2944 for E in $EXCEPT; do
2945 eval EXCEPT_${E}=true
2947 for E in $ALWAYS_EXCEPT; do
2948 eval EXCEPT_ALWAYS_${E}=true
2950 for E in $EXCEPT_SLOW; do
2951 eval EXCEPT_SLOW_${E}=true
2953 for G in $GRANT_CHECK_LIST; do
2954 eval GCHECK_ONLY_${G}=true
2959 if [[ $1 = [a-z]* ]]; then
2966 # print a newline if the last test was skipped
2967 export LAST_SKIPPED=
2968 export ALWAYS_SKIPPED=
2970 # Main entry into test-framework. This is called with the name and
2971 # description of a test. The name is used to find the function to run
2972 # the test using "test_$name".
2974 # This supports a variety of methods of specifying specific test to
2975 # run or not run. These need to be documented...
2980 export base=`basetest $1`
2981 if [ ! -z "$ONLY" ]; then
2983 if [ ${!testname}x != x ]; then
2984 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2985 run_one_logged $1 "$2"
2989 if [ ${!testname}x != x ]; then
2990 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2991 run_one_logged $1 "$2"
2999 if [ ${!testname}x != x ]; then
3001 TESTNAME=test_$1 skip "skipping excluded test $1"
3004 testname=EXCEPT_$base
3005 if [ ${!testname}x != x ]; then
3007 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3010 testname=EXCEPT_ALWAYS_$1
3011 if [ ${!testname}x != x ]; then
3014 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3017 testname=EXCEPT_ALWAYS_$base
3018 if [ ${!testname}x != x ]; then
3021 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3024 testname=EXCEPT_SLOW_$1
3025 if [ ${!testname}x != x ]; then
3027 TESTNAME=test_$1 skip "skipping SLOW test $1"
3030 testname=EXCEPT_SLOW_$base
3031 if [ ${!testname}x != x ]; then
3033 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3039 run_one_logged $1 "$2"
3050 module_loaded lnet || load_modules
3062 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3067 strace -o $TMP/$1.strace -ttt $*
3069 log "FINISHED: $*: rc $RC"
3074 equals_msg $1 test complete, duration $2 sec
3075 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3076 echo duration $2 >>$TESTSUITELOG
3080 # Set TEST_STATUS here; will be used for logging the result
3081 if [ -f $LOGDIR/err ]; then
3086 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3090 local FFREE=$(do_node $SINGLEMDS \
3091 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3092 local FTOTAL=$(do_node $SINGLEMDS \
3093 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3095 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3099 echo -n "Resetting fail_loc on all nodes..."
3100 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3106 # Log a message (on all nodes) padded with "=" before and after.
3107 # Also appends a timestamp and prepends the testsuite name.
3110 EQUALS="===================================================================================================="
3112 msg="== ${TESTSUITE} $*"
3114 [[ $last != "=" && $last != " " ]] && msg="$msg "
3115 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3116 # always include at least == after the message
3117 log "$msg== $(date +"%H:%M:%S (%s)")"
3121 # Run a single test function and cleanup after it.
3123 # This function should be run in a subshell so the test func can
3124 # exit() without stopping the whole script.
3130 export tdir=d0.${TESTSUITE}/d${base}
3131 export TESTNAME=test_$testnum
3132 local SAVE_UMASK=`umask`
3135 banner "test $testnum: $message"
3136 test_${testnum} || error "test_$testnum failed with $?"
3139 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3140 check_catastrophe || error "LBUG/LASSERT detected"
3141 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3149 # Wrapper around run_one to ensure:
3150 # - test runs in subshell
3151 # - output of test is saved to separate log file for error reporting
3152 # - test result is saved to data file
3155 local BEFORE=`date +%s`
3157 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
3158 local test_log=$LOGDIR/$name
3162 log_sub_test_begin test_${1}
3163 (run_one $1 "$2") 2>&1 | tee $test_log
3164 local RC=${PIPESTATUS[0]}
3166 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3167 echo "test_$1 returned $RC" | tee $LOGDIR/err
3169 duration=$((`date +%s` - $BEFORE))
3170 pass "$1" "(${duration}s)"
3171 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3172 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3174 if [ -f $LOGDIR/err ]; then
3175 $FAIL_ON_ERROR && exit $RC
3182 # Print information of skipped tests to result.yml
3185 log_sub_test_begin $1
3186 log_sub_test_end "SKIP" "0" "0" "\"$2\""
3190 (cd `dirname $1`; echo $PWD/`basename $1`)
3195 export base=`basetest $1`
3196 [ "$CHECK_GRANT" == "no" ] && return 0
3198 testname=GCHECK_ONLY_${base}
3199 [ ${!testname}x == x ] && return 0
3201 echo -n "checking grant......"
3203 local clients=$CLIENTS
3204 [ -z $clients ] && clients=$(hostname)
3206 # sync all the data and make sure no pending data on server
3207 do_nodes $clients sync
3210 client_grant=`do_nodes $clients \
3211 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3212 awk '{total += $1} END{print total}'`
3215 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3216 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3217 awk '{total += $1} END{print total}'`
3219 # check whether client grant == server grant
3220 if [ $client_grant -ne $server_grant ]; then
3221 echo "failed: client:${client_grant} server: ${server_grant}."
3222 do_nodes $(comma_list $(osts_nodes)) \
3223 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3224 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3227 echo "pass: client:${client_grant} server: ${server_grant}"
3232 ########################
3238 ost=`echo $1 | awk -F_ '{print $3}'`
3239 if [ -z $ost ]; then
3240 ost=`echo $1 | sed 's/-osc.*//'`
3245 ostuuid_from_index()
3247 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
3252 [ "$node" != "$(hostname)" ]
3258 for node in $(mdts_nodes); do
3259 remote_node $node && return 0
3266 [ "$CLIENTONLY" ] && return 0 || true
3267 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3272 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3273 MSKIPPED=1 && return 1
3280 for node in $(osts_nodes) ; do
3281 remote_node $node && return 0
3288 [ "$CLIENTONLY" ] && return 0 || true
3289 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3294 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3295 OSKIPPED=1 && return 1
3302 MGS=$(facet_host mgs)
3303 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3308 remote_mds_nodsh || remote_ost_nodsh || \
3309 $(single_local_node $(comma_list $(nodes_list)))
3315 for num in `seq $MDSCOUNT`; do
3316 MDSNODES="$MDSNODES $(facet_host mds$num)"
3318 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3324 remote_ost && remote_mds
3332 for facet in ${facets//,/ }; do
3333 if [ "$FAILURE_MODE" = HARD ]; then
3334 nodes="$nodes $(facet_active_host $facet)"
3336 nodes="$nodes $(facet_host $facet)"
3339 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3345 local facets=$(get_facets OST)
3346 local nodes=$(facets_nodes $facets)
3352 # FIXME. We need a list of clients
3353 local myNODES=$HOSTNAME
3356 # CLIENTS (if specified) contains the local client
3357 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3359 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3360 myNODES="$myNODES $(facets_nodes $(get_facets))"
3363 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3368 remote_nodes_list () {
3369 local rnodes=$(nodes_list)
3370 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3374 init_clients_lists () {
3375 # Sanity check: exclude the local client from RCLIENTS
3376 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3378 # Sanity check: exclude the dup entries
3379 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3381 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3383 # Sanity check: exclude the dup entries from CLIENTS
3384 # for those configs which has SINGLCLIENT set to local client
3385 clients=$(for i in $clients; do echo $i; done | sort -u)
3387 CLIENTS=`comma_list $clients`
3388 local -a remoteclients=($rclients)
3389 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3390 varname=CLIENT$((i + 2))
3391 eval $varname=${remoteclients[i]}
3394 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3397 get_random_entry () {
3400 rnodes=${rnodes//,/ }
3402 local -a nodes=($rnodes)
3403 local num=${#nodes[@]}
3404 local i=$((RANDOM * num * 2 / 65536))
3410 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3415 lctl get_param version | grep -q patchless
3419 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3424 echo $nodes | wc -w || true
3428 local nodes=$(osts_nodes)
3429 local osscount=$(get_node_count "$nodes")
3430 [ ! "$OSTCOUNT" = "$osscount" ]
3434 local nodes=$(mdts_nodes)
3435 local mdtcount=$(get_node_count "$nodes")
3436 [ ! "$MDSCOUNT" = "$mdtcount" ]
3439 generate_machine_file() {
3440 local nodes=${1//,/ }
3441 local machinefile=$2
3443 for node in $nodes; do
3444 echo $node >>$machinefile || \
3445 { echo "can not generate machinefile $machinefile" && return 1; }
3450 local file=$1/stripe
3452 $LFS getstripe -v $file || error
3456 setstripe_nfsserver () {
3459 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3460 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3462 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3464 do_nodev $nfsserver lfs setstripe "$@"
3467 check_runas_id_ret() {
3469 local myRUNAS_UID=$1
3470 local myRUNAS_GID=$2
3473 if [ -z "$myRUNAS" ]; then
3474 error_exit "myRUNAS command must be specified for check_runas_id"
3477 $myRUNAS krb5_login.sh || \
3478 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3480 mkdir $DIR/d0_runas_test
3482 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3483 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3484 rm -rf $DIR/d0_runas_test
3489 local myRUNAS_UID=$1
3490 local myRUNAS_GID=$2
3493 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3494 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3495 Please set RUNAS_ID to some UID which exists on MDS and client or
3496 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3499 # obtain the UID/GID for MPI_USER
3503 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3504 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3506 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3507 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3510 # obtain and cache Kerberos ticket-granting ticket
3511 refresh_krb5_tgt() {
3512 local myRUNAS_UID=$1
3513 local myRUNAS_GID=$2
3516 if [ -z "$myRUNAS" ]; then
3517 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3520 CLIENTS=${CLIENTS:-$HOSTNAME}
3521 do_nodes $CLIENTS "set -x
3522 if ! $myRUNAS krb5_login.sh; then
3523 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3528 # Run multiop in the background, but wait for it to print
3529 # "PAUSING" to its stdout before returning from this function.
3530 multiop_bg_pause() {
3531 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3535 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3538 echo "$MULTIOP_PROG $FILE v$ARGS"
3539 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3541 echo "TMPPIPE=${TMPPIPE}"
3542 read -t 60 multiop_output < $TMPPIPE
3543 if [ $? -ne 0 ]; then
3548 if [ "$multiop_output" != "PAUSING" ]; then
3549 echo "Incorrect multiop output: $multiop_output"
3564 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3570 inodes_available () {
3571 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3575 mdsrate_inodes_available () {
3576 echo $(($(inodes_available) - 1))
3579 # reset llite stat counters
3580 clear_llite_stats(){
3581 lctl set_param -n llite.*.stats 0
3584 # sum llite stat items
3585 calc_llite_stats() {
3586 local res=$(lctl get_param -n llite.*.stats |
3587 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3591 # reset osc stat counters
3593 lctl set_param -n osc.*.osc_stats 0
3596 # sum osc stat items
3598 local res=$(lctl get_param -n osc.*.osc_stats |
3599 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3604 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3607 calc_osc_kbytes () {
3608 df $MOUNT > /dev/null
3609 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3612 # save_lustre_params(node, parameter_mask)
3613 # generate a stream of formatted strings (<node> <param name>=<param value>)
3614 save_lustre_params() {
3616 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3619 # restore lustre parameters from input stream, produces by save_lustre_params
3620 restore_lustre_params() {
3624 while IFS=" =" read node name val; do
3625 do_node ${node//:/} "lctl set_param -n $name $val"
3629 check_catastrophe() {
3630 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3631 local C=$CATASTROPHE
3632 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3634 if [ $rnodes ]; then
3635 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3636 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3652 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3654 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3655 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3656 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3660 # CMD: determine mds index where directory inode presents
3663 local file=$dir/f0.get_mds_dir_tmpfile
3668 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3669 local -a oldused=($iused)
3671 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3673 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3674 local -a newused=($iused)
3677 for ((i=0; i<${#newused[@]}; i++)); do
3678 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3684 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3687 mdsrate_cleanup () {
3689 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3694 delayed_recovery_enabled () {
3695 local var=${SINGLEMDS}_svc
3696 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3699 ########################
3701 convert_facet2label() {
3704 if [ x$facet = xost ]; then
3708 local varsvc=${facet}_svc
3710 if [ -n ${!varsvc} ]; then
3713 error "No lablel for $facet!"
3717 get_clientosc_proc_path() {
3723 get_lustre_version () {
3724 local facet=${1:-"$SINGLEMDS"}
3725 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3728 get_mds_version_major () {
3729 local facet=${1:-"$SINGLEMDS"}
3730 local version=$(get_lustre_version $facet)
3731 echo $version | awk -F. '{print $1}'
3734 get_mds_version_minor () {
3735 local facet=${1:-"$SINGLEMDS"}
3736 local version=$(get_lustre_version $facet)
3737 echo $version | awk -F. '{print $2}'
3740 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3741 # used by MDT would not be changed.
3742 # mdt lov: fsname-mdtlov
3743 # mdt osc: fsname-OSTXXXX-osc
3744 mds_on_old_device() {
3745 local mds=${1:-"$SINGLEMDS"}
3746 local major=$(get_mds_version_major $mds)
3747 local minor=$(get_mds_version_minor $mds)
3749 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3750 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3751 > /dev/null 2>&1" && return 0
3756 get_mdtosc_proc_path() {
3758 local ost_label=${2:-"*OST*"}
3760 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3761 local mdt_label=$(convert_facet2label $mds_facet)
3762 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3764 local major=$(get_mds_version_major $mds_facet)
3765 local minor=$(get_mds_version_minor $mds_facet)
3766 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3767 echo "${ost_label}-osc"
3769 echo "${ost_label}-osc-${mdt_index}"
3773 get_osc_import_name() {
3776 local label=$(convert_facet2label $ost)
3778 if [ "${facet:0:3}" = "mds" ]; then
3779 get_mdtosc_proc_path $facet $label
3783 get_clientosc_proc_path $label
3787 _wait_import_state () {
3790 local maxtime=${3:-max_recovery_time}
3794 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3795 while [ "${CONN_STATE}" != "${expected}" ]; do
3796 [ $i -ge $maxtime ] && \
3797 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3800 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3804 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3808 wait_import_state() {
3811 local maxtime=${3:-max_recovery_time}
3814 for param in ${params//,/ }; do
3815 _wait_import_state $state $param $maxtime || return
3818 wait_osc_import_state() {
3822 local ost=$(get_osc_import_name $facet $ost_facet)
3827 CONN_PROC="osc.${ost}.ost_server_uuid"
3828 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3829 while [ "${CONN_STATE}" != "${expected}" ]; do
3830 if [ "${expected}" == "DISCONN" ]; then
3831 # for disconn we can check after proc entry is removed
3832 [ "x${CONN_STATE}" == "x" ] && return 0
3833 # with AT we can have connect request timeout ~ reconnect timeout
3834 # and test can't see real disconnect
3835 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3837 # disconnect rpc should be wait not more obd_timeout
3838 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3839 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3841 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3845 log "${ost_facet} now in ${CONN_STATE} state"
3848 get_clientmdc_proc_path() {
3856 # Add paths to lustre tests for 32 and 64 bit systems.
3857 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3858 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3861 wait_clients_import_state () {
3868 if [ "$FAILURE_MODE" = HARD ]; then
3869 facets=$(facets_on_host $(facet_active_host $facet))
3872 for facet in ${facets//,/ }; do
3873 local label=$(convert_facet2label $facet)
3876 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3877 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3878 *) error "unknown facet!" ;;
3880 local params=$(expand_list $params $proc_path)
3883 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3884 error "import is not in ${expected} state"
3893 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3894 $LCTL get_param obdfilter.*.kbytesavail))
3895 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3896 $LCTL get_param -n obdfilter.*.tot_granted))
3897 for ((i=0; i<${#AVAILA[@]}; i++)); do
3898 local -a AVAIL1=(${AVAILA[$i]//=/ })
3899 GRANT=$((${GRANTA[$i]}/1024))
3900 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3901 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3907 do_facet mgs lctl pool_list $1
3911 local fsname=${1%%.*}
3912 local poolname=${1##$fsname.}
3914 do_facet mgs lctl pool_new $1
3916 # get param should return err unless pool is created
3917 [[ $RC -ne 0 ]] && return $RC
3919 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3920 2>/dev/null || echo foo" "" || RC=1
3921 if [[ $RC -eq 0 ]]; then
3924 error "pool_new failed $1"
3929 add_pool_to_list () {
3930 local fsname=${1%%.*}
3931 local poolname=${1##$fsname.}
3933 local listvar=${fsname}_CREATED_POOLS
3934 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3937 remove_pool_from_list () {
3938 local fsname=${1%%.*}
3939 local poolname=${1##$fsname.}
3941 local listvar=${fsname}_CREATED_POOLS
3942 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3945 destroy_pool_int() {
3947 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3948 awk '$1 !~ /^Pool:/ {print $1}')
3949 for ost in $OSTS; do
3950 do_facet mgs lctl pool_remove $1 $ost
3952 do_facet mgs lctl pool_destroy $1
3955 # <fsname>.<poolname> or <poolname>
3957 local fsname=${1%%.*}
3958 local poolname=${1##$fsname.}
3960 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3964 pool_list $fsname.$poolname || return $?
3966 destroy_pool_int $fsname.$poolname
3968 [[ $RC -ne 0 ]] && return $RC
3970 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3971 2>/dev/null || echo foo" "foo" || RC=1
3973 if [[ $RC -eq 0 ]]; then
3974 remove_pool_from_list $fsname.$poolname
3976 error "destroy pool failed $1"
3982 local fsname=${1:-$FSNAME}
3984 local listvar=${fsname}_CREATED_POOLS
3988 [ x${!listvar} = x ] && return 0
3990 echo destroy the created pools: ${!listvar}
3991 for poolname in ${!listvar//,/ }; do
3992 destroy_pool $fsname.$poolname
3997 local fsname=${1:-$FSNAME}
3999 destroy_pools $fsname
4005 local ts=$(date +%s)
4007 [ -f $LOGDIR/shared ] && docp=false
4009 # dump lustre logs, dmesg
4011 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4013 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4015 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4016 echo "Dumping logs only on local client."
4017 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
4018 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
4023 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
4024 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
4025 if [ ! -f $LOGDIR/shared ]; then
4026 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4029 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
4030 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
4036 local list=${1:-$(comma_list $(nodes_list))}
4038 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
4050 for i in $(seq 0 $num_mntpts); do
4051 cmd="ls -laf ${mntpt_root}$i/$dir"
4057 for pid in $pids; do
4064 # target_start_and_reset_recovery_timer()
4065 # service_time = at_est2timeout(service_time);
4066 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4067 # INITIAL_CONNECT_TIMEOUT);
4068 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4069 #define CONNECTION_SWITCH_INC 1
4070 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4071 #define CONNECTION_SWITCH_MIN 5U
4073 max_recovery_time () {
4074 local init_connect_timeout=$(( TIMEOUT / 20 ))
4075 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
4077 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4082 get_clients_mount_count () {
4083 local clients=${CLIENTS:-`hostname`}
4085 # we need to take into account the clients mounts and
4086 # exclude mds/ost mounts if any;
4087 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4091 PROC_CLI="srpc_info"
4099 if [ $M -lt $N ]; then
4103 while [ $N -lt $M ]; do
4113 calc_connection_cnt() {
4116 # MDT->MDT = 2 * C(M, 2)
4120 comb_m2=$(combination $MDSCOUNT 2)
4122 local num_clients=$(get_clients_mount_count)
4124 local cnt_mdt2mdt=$((comb_m2 * 2))
4125 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4126 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4127 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4128 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4129 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4130 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4144 local cmd="$tgt.srpc.flavor"
4146 if [ $net == "any" ]; then
4151 if [ $dir != "any" ]; then
4156 log "Setting sptlrpc rule: $cmd"
4157 do_facet mgs "$LCTL conf_param $cmd"
4166 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4167 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4169 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4171 if [ "x$bulkspec" != "x" ]; then
4172 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4174 if [ "x$algs" != "x" ]; then
4175 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4177 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4178 if [ $bulk == "bulkn" ]; then
4179 bulk_count=`echo "$output" | grep "bulk flavor" \
4180 | grep "null/null" | wc -l`
4181 elif [ $bulk == "bulki" ]; then
4182 bulk_count=`echo "$output" | grep "bulk flavor" \
4183 | grep "/null" | grep -v "null/" | wc -l`
4185 bulk_count=`echo "$output" | grep "bulk flavor" \
4186 | grep -v "/null" | grep -v "null/" | wc -l`
4190 [ $bulk_count -lt $count ] && count=$bulk_count
4201 local clients=${CLIENTS:-`hostname`}
4203 for c in ${clients//,/ }; do
4204 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4205 tmpcnt=`count_flvr "$output" $flavor`
4206 cnt=$((cnt + tmpcnt))
4216 local clients=${CLIENTS:-`hostname`}
4218 for c in ${clients//,/ }; do
4219 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4220 tmpcnt=`count_flvr "$output" $flavor`
4221 cnt=$((cnt + tmpcnt))
4231 if [ $MDSCOUNT -le 1 ]; then
4236 for num in `seq $MDSCOUNT`; do
4237 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4238 tmpcnt=`count_flvr "$output" $flavor`
4239 cnt=$((cnt + tmpcnt))
4250 for num in `seq $MDSCOUNT`; do
4251 mdtosc=$(get_mdtosc_proc_path mds$num)
4252 mdtosc=${mdtosc/-MDT*/-MDT\*}
4253 output=$(do_facet mds$num lctl get_param -n \
4254 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4255 tmpcnt=`count_flvr "$output" $flavor`
4256 cnt=$((cnt + tmpcnt))
4265 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4266 count_flvr "$output" $flavor
4271 local dir=$1 # from to
4272 local flavor=$2 # flavor expected
4275 if [ $dir == "cli2mdt" ]; then
4276 res=`flvr_cnt_cli2mdt $flavor`
4277 elif [ $dir == "cli2ost" ]; then
4278 res=`flvr_cnt_cli2ost $flavor`
4279 elif [ $dir == "mdt2mdt" ]; then
4280 res=`flvr_cnt_mdt2mdt $flavor`
4281 elif [ $dir == "mdt2ost" ]; then
4282 res=`flvr_cnt_mdt2ost $flavor`
4283 elif [ $dir == "all2ost" ]; then
4284 res1=`flvr_cnt_mdt2ost $flavor`
4285 res2=`flvr_cnt_cli2ost $flavor`
4286 res=$((res1 + res2))
4287 elif [ $dir == "all2mdt" ]; then
4288 res1=`flvr_cnt_mdt2mdt $flavor`
4289 res2=`flvr_cnt_cli2mdt $flavor`
4290 res=$((res1 + res2))
4291 elif [ $dir == "all2all" ]; then
4292 res1=`flvr_cnt_mdt2ost $flavor`
4293 res2=`flvr_cnt_cli2ost $flavor`
4294 res3=`flvr_cnt_mdt2mdt $flavor`
4295 res4=`flvr_cnt_cli2mdt $flavor`
4296 res=$((res1 + res2 + res3 + res4))
4304 local dir=$1 # from to
4305 local flavor=$2 # flavor expected
4306 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4310 for ((i=0;i<20;i++)); do
4311 echo -n "checking $dir..."
4312 res=$(do_check_flavor $dir $flavor)
4313 echo "found $res/$expect $flavor connections"
4314 [ $res -eq $expect ] && return 0
4318 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4322 restore_to_default_flavor()
4324 local proc="mgs.MGS.live.$FSNAME"
4326 echo "restoring to default flavor..."
4328 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4330 # remove all existing rules if any
4331 if [ $nrule -ne 0 ]; then
4332 echo "$nrule existing rules"
4333 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4334 echo "remove rule: $rule"
4335 spec=`echo $rule | awk -F = '{print $1}'`
4336 do_facet mgs "$LCTL conf_param -d $spec"
4340 # verify no rules left
4341 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4342 [ $nrule -ne 0 ] && error "still $nrule rules left"
4344 # wait for default flavor to be applied
4345 # currently default flavor for all connections are 'null'
4346 wait_flavor all2all null
4347 echo "now at default flavor settings"
4352 local flavor=${1:-null}
4354 echo "setting all flavor to $flavor"
4356 # FIXME need parameter to this fn
4357 # and remove global vars
4358 local cnt_all2all=$(calc_connection_cnt all2all)
4360 local res=$(do_check_flavor all2all $flavor)
4361 if [ $res -eq $cnt_all2all ]; then
4362 echo "already have total $res $flavor connections"
4366 echo "found $res $flavor out of total $cnt_all2all connections"
4367 restore_to_default_flavor
4369 [[ $flavor = null ]] && return 0
4371 set_rule $FSNAME any any $flavor
4372 wait_flavor all2all $flavor
4378 # Checking for shared logdir
4379 if [ ! -d $dir ]; then
4380 # Not found. Create local logdir
4383 touch $dir/node.$(hostname).yml
4388 check_write_access() {
4390 for node in $(nodes_list); do
4391 if [ ! -f "$dir/node.${node}.yml" ]; then
4392 # Logdir not accessible/writable from this node.
4400 if [[ -n $YAML_LOG ]]; then
4403 export YAML_LOG=${LOGDIR}/results.yml
4407 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4408 if check_write_access $LOGDIR; then
4409 touch $LOGDIR/shared
4410 echo "Logging to shared log directory: $LOGDIR"
4412 echo "Logging to local directory: $LOGDIR"
4415 yml_nodes_file $LOGDIR >> $YAML_LOG
4416 yml_results_file >> $YAML_LOG
4420 yml_log_test $1 >> $YAML_LOG
4424 yml_log_test_status $@ >> $YAML_LOG
4427 log_sub_test_begin() {
4428 yml_log_sub_test_begin "$@" >> $YAML_LOG
4431 log_sub_test_end() {
4432 yml_log_sub_test_end "$@" >> $YAML_LOG
4438 local devname=$(basename $1)
4439 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4440 # loop devices aren't in /proc/partitions
4441 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4443 size=$(($size / 1024 / 1024)) # Gb
4445 local partial_arg=""
4446 # Run in partial (fast) mode if the size
4447 # of a partition > 10 GB
4448 [ $size -gt 10 ] && partial_arg="-p"
4450 llverdev --force $partial_arg $dev
4453 remove_mdt_files() {
4458 local mntpt=${MOUNT%/*}/$facet
4460 echo "removing files from $mdtdev on $facet: $files"
4461 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4464 rm $mntpt/ROOT/$f || { rc=$?; break; }
4466 umount -f $mntpt || return $?
4470 duplicate_mdt_files() {
4475 local mntpt=${MOUNT%/*}/$facet
4477 echo "duplicating files on $mdtdev on $facet: $files"
4478 mkdir -p $mntpt || return $?
4479 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4489 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4490 pushd $mntpt/ROOT > /dev/null || return $?
4493 touch $f.bad || return $?
4494 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4496 [ $rc -eq 0 ] || return $rc
4497 setfattr --restore $tmp || return $?
4503 local devs=${1//,/ }
4506 local rslt=$TMP/sgpdd_survey
4508 # sgpdd-survey cleanups ${rslt}.* files
4510 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4516 # returns the canonical name for an ldiskfs device
4521 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4522 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4523 echo dm-\\\${foo##*:};
4525 echo \\\$(basename \\\$dv);
4529 is_sanity_benchmark() {
4530 local benchmarks="dbench bonnie iozone fsx"
4532 for b in $benchmarks; do
4533 if [ "$b" == "$suite" ]; then
4541 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1