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:-""}
11 export VERBOSE=${VERBOSE:-false}
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}
121 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
122 export FSCK_MAX_ERR=4 # File system errors left uncorrected
123 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
124 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
125 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
127 #[ -d /r ] && export ROOT=${ROOT:-/r}
128 export TMP=${TMP:-$ROOT/tmp}
129 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
130 if [[ -z $LOGDIRSET ]]; then
131 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
132 export LOGDIRSET=true
134 export HOSTNAME=${HOSTNAME:-`hostname`}
135 if ! echo $PATH | grep -q $LUSTRE/utils; then
136 export PATH=$LUSTRE/utils:$PATH
138 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
139 export PATH=$LUSTRE/utils/gss:$PATH
141 if ! echo $PATH | grep -q $LUSTRE/tests; then
142 export PATH=$LUSTRE/tests:$PATH
144 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
145 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
147 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
148 [ ! -f "$LST" ] && export LST=$(which lst)
149 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
150 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
151 # Ubuntu, at least, has a truncate command in /usr/bin
152 # so fully path our truncate command.
153 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
154 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
155 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
156 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
157 export PATH=$LUSTRE/tests/racer:$PATH:
159 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
160 export PATH=$LUSTRE/tests/mpi:$PATH
162 export RSYNC_RSH=${RSYNC_RSH:-rsh}
163 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
164 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
165 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
166 [ ! -f "$LFS" ] && export LFS=$(which lfs)
167 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
168 if [ ! -f "$L_GETIDENTITY" ]; then
169 if `which l_getidentity > /dev/null 2>&1`; then
170 export L_GETIDENTITY=$(which l_getidentity)
172 export L_GETIDENTITY=NONE
175 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
176 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
177 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
178 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
179 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
180 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
181 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
182 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
183 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
184 export FSTYPE=${FSTYPE:-"ldiskfs"}
185 export NAME=${NAME:-local}
186 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
187 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
188 export LGSSD=$(which lgssd)
189 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
190 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
191 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
193 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
196 if [ "$ACCEPTOR_PORT" ]; then
197 export PORT_OPT="--port $ACCEPTOR_PORT"
202 echo "Using GSS/krb5 ptlrpc security flavor"
203 which lgss_keyring > /dev/null 2>&1 || \
204 error_exit "built with gss disabled! SEC=$SEC"
215 IDENTITY_UPCALL=false
218 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
220 # Paths on remote nodes, if different
221 export RLUSTRE=${RLUSTRE:-$LUSTRE}
222 export RPWD=${RPWD:-$PWD}
223 export I_MOUNTED=${I_MOUNTED:-"no"}
224 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
225 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
226 ! -f `dirname $0`/../mds/mds.ko ]; then
227 export CLIENTMODSONLY=yes
230 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
234 while getopts "rvwf:" opt $*; do
237 r) REFORMAT=--reformat;;
239 w) WRITECONF=writeconf;;
244 shift $((OPTIND - 1))
247 # print the durations of each test if "true"
248 DDETAILS=${DDETAILS:-false}
249 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
254 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
255 *) EXT=".ko"; USE_QUOTA=yes;;
260 /sbin/lsmod | grep -q "^\<$1\>"
263 # Load a module on the system where this is running.
265 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
267 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
268 # will be used as the arguments. Otherwise arguments will be obtained from
269 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
276 BASE=`basename $module $EXT`
278 module_loaded ${BASE} && return
280 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
282 if [ $# -eq 0 ]; then
283 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
284 # Bash until 4.x, so we resort to eval.
285 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
286 eval set -- \$$optvar
287 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
288 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
289 set -- $(grep -P "^options\\s+${BASE}" $MODPROBECONF)
290 # Get rid of "options $module"
291 (($# > 0)) && shift 2
293 # Ensure we have accept=all for lnet
294 if [ $(basename $module) = lnet ]; then
295 # OK, this is a bit wordy...
296 local arg accept_all_present=false
298 [ "$arg" = accept=all ] && accept_all_present=true
300 $accept_all_present || set -- "$@" accept=all
305 [ $# -gt 0 ] && echo "${module} options: '$*'"
307 # Note that insmod will ignore anything in modprobe.conf, which is why we're
308 # passing options on the command-line.
309 if [ "$BASE" == "lnet_selftest" ] && \
310 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
311 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
312 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
313 insmod ${LUSTRE}/${module}${EXT} "$@"
315 # must be testing a "make install" or "rpm" installation
316 # note failed to load ptlrpc_gss is considered not fatal
317 if [ "$BASE" == "ptlrpc_gss" ]; then
318 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
325 load_modules_local() {
326 if [ -n "$MODPROBE" ]; then
328 echo "Using modprobe to load modules"
332 echo Loading modules from $LUSTRE
333 load_module ../libcfs/libcfs/libcfs
334 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
335 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
336 load_module ../lnet/lnet/lnet
337 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
338 load_module ../lnet/klnds/$LNETLND
339 load_module lvfs/lvfs
340 load_module obdclass/obdclass
341 load_module ptlrpc/ptlrpc
342 load_module ptlrpc/gss/ptlrpc_gss
343 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
351 if ! client_only; then
352 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
353 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
354 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
355 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
360 load_module lvfs/fsfilt_$FSTYPE
362 load_module osd-ldiskfs/osd_ldiskfs
364 load_module obdfilter/obdfilter
367 load_module llite/lustre
368 load_module llite/llite_lloop
369 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
371 rm -f $OGDB/ogdb-$HOSTNAME
372 $LCTL modules > $OGDB/ogdb-$HOSTNAME
374 # 'mount' doesn't look in $PATH, just sbin
375 if [ -f $LUSTRE/utils/mount.lustre ] && \
376 ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
377 [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
378 mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
385 # load modules on remote nodes optionally
386 # lustre-tests have to be installed on these nodes
387 if $LOAD_MODULES_REMOTE ; then
388 local list=$(comma_list $(remote_nodes_list))
389 echo loading modules on $list
390 do_rpc_nodes $list load_modules
395 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
396 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
397 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
398 echo "$LEAK_LUSTRE" 1>&2
399 echo "$LEAK_PORTALS" 1>&2
400 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
401 echo "Memory leaks detected"
402 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
408 wait_exit_ST client # bug 12845
410 $LUSTRE_RMMOD $FSTYPE || return 2
412 if $LOAD_MODULES_REMOTE ; then
413 local list=$(comma_list $(remote_nodes_list))
414 if [ ! -z $list ]; then
415 echo unloading modules on $list
416 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
417 do_rpc_nodes $list check_mem_leak
421 if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
422 umount /sbin/mount.lustre || true
423 [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
424 rm -f /sbin/mount.lustre || true
427 check_mem_leak || return 254
429 echo "modules unloaded."
433 check_gss_daemon_nodes() {
437 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
438 if [ \\\"\\\$num\\\" -ne 1 ]; then
439 echo \\\$num instance of $dname;
444 check_gss_daemon_facet() {
448 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
449 if [ $num -ne 1 ]; then
450 echo "$num instance of $dname on $facet"
459 echo Stopping $@ on $list
460 do_nodes $list "killall -2 $@ 2>/dev/null || true"
463 # start gss daemons on all nodes, or
464 # "daemon" on "list" if set
465 start_gss_daemons() {
469 if [ "$list" ] && [ "$daemon" ] ; then
470 echo "Starting gss daemon on nodes: $list"
471 do_nodes $list "$daemon" || return 8
475 local list=$(comma_list $(mdts_nodes))
477 echo "Starting gss daemon on mds: $list"
478 do_nodes $list "$LSVCGSSD -v" || return 1
480 do_nodes $list "$LGSSD -v" || return 2
483 list=$(comma_list $(osts_nodes))
484 echo "Starting gss daemon on ost: $list"
485 do_nodes $list "$LSVCGSSD -v" || return 3
486 # starting on clients
488 local clients=${CLIENTS:-`hostname`}
490 echo "Starting $LGSSD on clients $clients "
491 do_nodes $clients "$LGSSD -v" || return 4
494 # wait daemons entering "stable" status
498 # check daemons are running
500 list=$(comma_list $(mdts_nodes) $(osts_nodes))
501 check_gss_daemon_nodes $list lsvcgssd || return 5
503 list=$(comma_list $(mdts_nodes))
504 check_gss_daemon_nodes $list lgssd || return 6
507 check_gss_daemon_nodes $clients lgssd || return 7
512 local list=$(comma_list $(mdts_nodes))
514 send_sigint $list lsvcgssd lgssd
516 list=$(comma_list $(osts_nodes))
517 send_sigint $list lsvcgssd
519 list=${CLIENTS:-`hostname`}
520 send_sigint $list lgssd
525 if ! module_loaded ptlrpc_gss; then
526 load_module ptlrpc/gss/ptlrpc_gss
527 module_loaded ptlrpc_gss ||
528 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
530 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
532 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
533 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
541 # maybe cleanup credential cache?
547 local device=`mdsdevname $num`
548 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
554 local device=`ostdevname $num`
555 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
561 local facets=${1:-$(get_facets)}
564 for facet in ${facets//,/ }; do
565 mount_facet $facet || error "Restart of $facet failed!"
572 local dev=$(facet_active $facet)_dev
573 local opt=${facet}_opt
574 local mntpt=$(facet_mntpt $facet)
576 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
577 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
579 if [ $RC -ne 0 ]; then
580 echo "mount -t lustre $@ ${!dev} $mntpt"
581 echo "Start of ${!dev} on ${facet} failed ${RC}"
583 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
584 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
585 lctl set_param debug_mb=${DEBUG_SIZE}; \
588 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
589 [ -z "$label" ] && echo no label for ${!dev} && exit 1
590 eval export ${facet}_svc=${label}
591 echo Started ${label}
596 # start facet device options
602 eval export ${facet}_dev=${device}
603 eval export ${facet}_opt=\"$@\"
605 local varname=${facet}failover_dev
606 if [ -n "${!varname}" ] ; then
607 eval export ${facet}failover_dev=${!varname}
609 eval export ${facet}failover_dev=$device
612 local mntpt=$(facet_mntpt $facet)
613 do_facet ${facet} mkdir -p $mntpt
614 eval export ${facet}_MOUNT=$mntpt
624 local HOST=`facet_active_host $facet`
625 [ -z $HOST ] && echo stop: no host for $facet && return 0
627 local mntpt=$(facet_mntpt $facet)
628 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
629 if [ ${running} -ne 0 ]; then
630 echo "Stopping $mntpt (opts:$@)"
631 do_facet ${facet} umount -d $@ $mntpt
634 # umount should block, but we should wait for unrelated obd's
635 # like the MGS or MGC to also stop.
636 wait_exit_ST ${facet}
639 # save quota version (both administrative and operational quotas)
640 # add an additional parameter if mountpoint is ever different from $MOUNT
641 quota_save_version() {
642 local fsname=${2:-$FSNAME}
644 local ver=$(tr -c -d "123" <<< $spec)
645 local type=$(tr -c -d "ug" <<< $spec)
647 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
649 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
651 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
653 local osts=$(get_facets OST)
654 for ost in ${osts//,/ }; do
656 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
660 # client could mount several lustre
662 local fsname=${1:-$FSNAME}
664 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
665 do_nodes $(comma_list $(osts_nodes)) \
666 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
670 restore_quota_type () {
671 local mntpt=${1:-$MOUNT}
672 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
673 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
676 quota_save_version $old_QUOTA_TYPE
682 # We need save the original quota_type params, and restore them after testing
684 # Suppose that quota type the same on mds and ost
685 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
686 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
687 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
688 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
689 export old_QUOTA_TYPE=$quota_type
690 quota_save_version $QUOTA_TYPE
692 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
693 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
696 local quota_usrs=$QUOTA_USERS
698 # get_filesystem_size
699 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
700 local blk_soft=$((disksz + 1024))
701 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
703 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
705 local i_hard=$((i_soft + i_soft / 20))
707 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
708 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
711 for usr in $quota_usrs; do
712 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
714 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
716 eval $cmd || error "$cmd FAILED!"
718 # display the quota status
719 echo "Quota settings for $usr : "
720 $LFS quota -v -u $usr $mntpt || true
727 local OPTIONS=${3:-$MOUNTOPT}
729 local device=$MGSNID:/$FSNAME
730 if [ -z "$mnt" -o -z "$FSNAME" ]; then
731 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
735 echo "Starting client: $client: $OPTIONS $device $mnt"
736 do_node $client mkdir -p $mnt
737 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
739 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
740 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
741 lctl set_param debug_mb=${DEBUG_SIZE}"
754 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
755 if [ $running -ne 0 ]; then
756 echo "Stopping client $client $mnt (opts:$force)"
757 do_node $client lsof -t $mnt || need_kill=no
758 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
759 pids=$(do_node $client lsof -t $mnt | sort -u);
760 if [ -n $pids ]; then
761 do_node $client kill -9 $pids || true
765 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
766 if [ $busy -ne 0 ] ; then
767 echo "$mnt is still busy, wait one second" && sleep 1
768 do_node $client umount $force $mnt
773 # nodes is comma list
774 sanity_mount_check_nodes () {
780 # FIXME: assume that all cluster nodes run the same os
781 [ "$(uname)" = Linux ] || return 0
784 for mnt in $mnts ; do
785 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
786 mpts=\\\$(mount | grep -w -c $mnt);
787 if [ \\\$running -ne \\\$mpts ]; then
788 echo \\\$(hostname) env are INSANE!;
796 sanity_mount_check_servers () {
798 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
799 echo Checking servers environments
801 # FIXME: modify get_facets to display all facets wo params
802 local facets="$(get_facets OST),$(get_facets MDS),mgs"
806 for facet in ${facets//,/ }; do
807 node=$(facet_host ${facet})
808 mntpt=$(facet_mntpt $facet)
809 sanity_mount_check_nodes $node $mntpt ||
810 { error "server $node environments are insane!"; return 1; }
814 sanity_mount_check_clients () {
815 local clients=${1:-$CLIENTS}
816 local mntpt=${2:-$MOUNT}
817 local mntpt2=${3:-$MOUNT2}
819 [ -z $clients ] && clients=$(hostname)
820 echo Checking clients $clients environments
822 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
823 error "clients environments are insane!"
826 sanity_mount_check () {
827 sanity_mount_check_servers || return 1
828 sanity_mount_check_clients || return 2
831 # mount clients if not mouted
832 zconf_mount_clients() {
835 local OPTIONS=${3:-$MOUNTOPT}
837 local device=$MGSNID:/$FSNAME
838 if [ -z "$mnt" -o -z "$FSNAME" ]; then
839 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
843 echo "Starting client $clients: $OPTIONS $device $mnt"
846 running=\\\$(mount | grep -c $mnt' ');
848 if [ \\\$running -eq 0 ] ; then
850 mount -t lustre $OPTIONS $device $mnt;
853 exit \\\$rc" || return ${PIPESTATUS[0]}
855 echo "Started clients $clients: "
856 do_nodes $clients "mount | grep -w $mnt"
858 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
859 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
860 lctl set_param debug_mb=${DEBUG_SIZE};"
865 zconf_umount_clients() {
872 echo "Stopping clients: $clients $mnt (opts:$force)"
873 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
874 if [ \\\$running -ne 0 ] ; then
875 echo Stopping client \\\$(hostname) $mnt opts:$force;
876 lsof -t $mnt || need_kill=no;
877 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
878 pids=\\\$(lsof -t $mnt | sort -u);
879 if [ -n \\\"\\\$pids\\\" ]; then
883 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
884 if [ \\\$busy -ne 0 ] ; then
885 echo "$mnt is still busy, wait one second" && sleep 1;
893 echo + $POWER_DOWN $node
897 shutdown_node_hard () {
899 local attempts=$SHUTDOWN_ATTEMPTS
901 for i in $(seq $attempts) ; do
904 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
905 echo "waiting for $host to fail attempts=$attempts"
906 [ $i -lt $attempts ] || \
907 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
913 local mnt=${2:-$MOUNT}
916 if [ "$FAILURE_MODE" = HARD ]; then
917 shutdown_node_hard $client
919 zconf_umount_clients $client $mnt -f
925 local facets="$(get_facets OST),$(get_facets MDS)"
928 combined_mgs_mds || facets="$facets,mgs"
930 for facet in ${facets//,/ }; do
931 if [ $(facet_active_host $facet) == $host ]; then
932 affected="$affected $facet"
936 echo $(comma_list $affected)
941 local host=${2:-$(facet_host $facet)}
943 local label=$(convert_facet2label $facet)
944 do_node $host lctl dl | awk '{print $4}' | grep -q $label
947 facets_up_on_host () {
949 local facets=$(facets_on_host $host)
952 for facet in ${facets//,/ }; do
953 if $(facet_up $facet $host); then
954 affected_up="$affected_up $facet"
958 echo $(comma_list $affected_up)
964 if [ "$FAILURE_MODE" = HARD ]; then
965 shutdown_node_hard $(facet_active_host $facet)
973 echo + $POWER_UP $node
986 if [ "$FAILURE_MODE" = HARD ]; then
987 reboot_node $(facet_active_host $facet)
995 if [ "$FAILURE_MODE" = HARD ]; then
1005 for facet in ${facets//,/ }; do
1006 hosts=$(expand_list $hosts $(facet_host $facet) )
1012 _check_progs_installed () {
1016 for prog in $progs; do
1017 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1018 echo $prog missing on $(hostname)
1025 check_progs_installed () {
1029 do_rpc_nodes $nodes _check_progs_installed $@
1032 # recovery-scale functions
1034 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1037 start_client_load() {
1040 local var=$(node_var_name $client)_load
1041 eval export ${var}=$load
1043 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1044 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1045 END_RUN_FILE=$END_RUN_FILE \
1046 LOAD_PID_FILE=$LOAD_PID_FILE \
1047 TESTSUITELOG=$TESTSUITELOG \
1049 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1050 log "Started client load: ${load} on $client"
1055 start_client_loads () {
1056 local -a clients=(${1//,/ })
1057 local numloads=${#CLIENT_LOADS[@]}
1060 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1061 testnum=$((nodenum % numloads))
1062 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1064 # bug 22169: wait the background threads to start
1068 # only for remote client
1069 check_client_load () {
1071 local var=$(node_var_name $client)_load
1072 local TESTLOAD=run_${!var}.sh
1074 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1076 # bug 18914: try to connect several times not only when
1077 # check ps, but while check_catastrophe also
1080 while [ $RC = 254 -a $tries -gt 0 ]; do
1084 if ! check_catastrophe $client; then
1086 if [ $RC -eq 254 ]; then
1087 # FIXME: not sure how long we shuold sleep here
1091 echo "check catastrophe failed: RC=$RC "
1095 # We can continue try to connect if RC=254
1096 # Just print the warning about this
1097 if [ $RC = 254 ]; then
1098 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1101 # see if the load is still on the client
1104 while [ $RC = 254 -a $tries -gt 0 ]; do
1108 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1113 if [ $RC = 254 ]; then
1114 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1115 # see if we can diagnose a bit why this is
1120 check_client_loads () {
1121 local clients=${1//,/ }
1125 for client in $clients; do
1126 check_client_load $client
1128 if [ "$rc" != 0 ]; then
1129 log "Client load failed on node $client, rc=$rc"
1135 restart_client_loads () {
1136 local clients=${1//,/ }
1137 local expectedfail=${2:-""}
1141 for client in $clients; do
1142 check_client_load $client
1144 if [ "$rc" != 0 -a "$expectedfail" ]; then
1145 local var=$(node_var_name $client)_load
1146 start_client_load $client ${!var}
1147 echo "Restarted client load ${!var}: on $client. Checking ..."
1148 check_client_load $client
1150 if [ "$rc" != 0 ]; then
1151 log "Client load failed to restart on node $client, rc=$rc"
1152 # failure one client load means test fail
1153 # we do not need to check other
1161 # End recovery-scale functions
1163 # verify that lustre actually cleaned up properly
1165 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1166 error "LBUG/LASSERT detected"
1167 BUSY=`dmesg | grep -i destruct || true`
1168 if [ "$BUSY" ]; then
1170 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1174 check_mem_leak || exit 204
1176 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1177 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1179 if module_loaded lnet || module_loaded libcfs; then
1180 echo "$0: modules still loaded..." 1>&2
1197 RESULT=$(do_node $node "$TEST")
1198 if [ "$RESULT" == "$FINAL" ]; then
1199 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1202 [ $WAIT -ge $MAX ] && break
1203 echo "Waiting $((MAX - WAIT)) secs for update"
1204 WAIT=$((WAIT + sleep))
1207 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1211 wait_update_facet () {
1213 wait_update $(facet_active_host $facet) "$@"
1216 wait_delete_completed () {
1217 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1218 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1222 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1224 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1225 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1226 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1227 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1231 echo "Delete is not completed in $MAX_WAIT sec"
1238 # we can use "for" here because we are waiting the slowest
1239 for host in ${hostlist//,/ }; do
1240 check_network "$host" 900
1242 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1249 for facet in ${facetlist//,/ }; do
1250 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1252 wait_for_host $hostlist
1255 _wait_recovery_complete () {
1258 # Use default policy if $2 is not passed by caller.
1259 local MAX=${2:-$(max_recovery_time)}
1264 while [ $WAIT -lt $MAX ]; do
1265 STATUS=$(lctl get_param -n $param | grep status)
1267 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1270 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1272 echo "$param recovery not done in $MAX sec. $STATUS"
1276 wait_recovery_complete () {
1279 # with an assumption that at_max is the same on all nodes
1280 local MAX=${2:-$(max_recovery_time)}
1283 if [ "$FAILURE_MODE" = HARD ]; then
1284 facets=$(facets_on_host $(facet_active_host $facet))
1286 echo affected facets: $facets
1288 # we can use "for" here because we are waiting the slowest
1289 for facet in ${facets//,/ }; do
1290 local var_svc=${facet}_svc
1291 local param="*.${!var_svc}.recovery_status"
1293 local host=$(facet_active_host $facet)
1294 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1298 wait_mds_ost_sync () {
1299 # just because recovery is done doesn't mean we've finished
1300 # orphan cleanup. Wait for llogs to get synchronized.
1301 echo "Waiting for orphan cleanup..."
1302 # MAX value includes time needed for MDS-OST reconnection
1303 local MAX=$(( TIMEOUT * 2 ))
1305 while [ $WAIT -lt $MAX ]; do
1306 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1307 "$LCTL get_param -n obdfilter.*.mds_sync"))
1310 for ((i=0; i<${#sync[@]}; i++)); do
1311 [ ${sync[$i]} -eq 0 ] && continue
1312 # there is a not finished MDS-OST synchronization
1316 sleep 2 # increase waiting time and cover statfs cache
1317 [ ${con} -eq 1 ] && return 0
1318 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1321 echo "$facet recovery not done in $MAX sec. $STATUS"
1325 wait_destroy_complete () {
1326 echo "Waiting for destroy to be done..."
1327 # MAX value shouldn't be big as this mean server responsiveness
1328 # never increase this just to make test pass but investigate
1329 # why it takes so long time
1332 while [ $WAIT -lt $MAX ]; do
1333 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1335 for ((i=0; i<${#RPCs[@]}; i++)); do
1336 [ ${RPCs[$i]} -eq 0 ] && continue
1337 # there are still some destroy RPCs in flight
1342 [ ${con} -eq 1 ] && return 0 # done waiting
1343 echo "Waiting $WAIT secs for destroys to be done."
1346 echo "Destroys weren't done in $MAX sec."
1356 # conf-sanity 31 takes a long time cleanup
1357 while [ $WAIT -lt 300 ]; do
1358 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1359 [ -z "${running}" ] && return 0
1360 echo "waited $WAIT for${running}"
1361 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1363 WAIT=$((WAIT + INTERVAL))
1365 echo "service didn't stop after $WAIT seconds. Still running:"
1370 wait_remote_prog () {
1376 [ "$PDSH" = "no_dsh" ] && return 0
1378 while [ $WAIT -lt $2 ]; do
1379 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1380 [ -z "${running}" ] && return 0 || true
1381 echo "waited $WAIT for: "
1383 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1385 WAIT=$((WAIT + INTERVAL))
1387 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1388 [ -z "$pids" ] && return 0
1389 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1390 # FIXME: not portable
1391 for pid in $pids; do
1392 cat /proc/${pid}/status || true
1393 cat /proc/${pid}/wchan || true
1395 kill -9 $pid || true
1404 # not every config has many clients
1406 if [ ! -z "$CLIENTS" ]; then
1407 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1409 stat -f $MOUNT > /dev/null
1415 # usually checked on particular client or locally
1417 if [ ! -z "$client" ]; then
1418 $PDSH $client "stat -f $MOUNT" > /dev/null
1420 stat -f $MOUNT > /dev/null
1428 client_reconnect() {
1429 uname -n >> $MOUNT/recon
1430 if [ -z "$CLIENTS" ]; then
1431 df $MOUNT; uname -n >> $MOUNT/recon
1433 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1435 echo Connected clients:
1437 ls -l $MOUNT/recon > /dev/null
1441 affected_facets () {
1444 local host=$(facet_active_host $facet)
1445 local affected=$facet
1447 if [ "$FAILURE_MODE" = HARD ]; then
1448 affected=$(facets_up_on_host $host)
1456 local host=$(facet_active_host $facet)
1458 echo "Failing $facet on node $host"
1460 local affected=$(affected_facets $facet)
1462 shutdown_facet $facet
1464 echo affected facets: $affected
1466 [ -n "$sleep_time" ] && sleep $sleep_time
1470 change_active $affected
1472 wait_for_facet $affected
1473 # start mgs first if it is affected
1474 if ! combined_mgs_mds && list_member $affected mgs; then
1475 mount_facet mgs || error "Restart of mgs failed"
1477 # FIXME; has to be changed to mount all facets concurrently
1478 affected=$(exclude_items_from_list $affected mgs)
1479 mount_facets $affected
1488 do_facet $facet sync
1491 # make sure there will be no seq change
1492 local clients=${CLIENTS:-$HOSTNAME}
1493 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1495 local svc=${facet}_svc
1496 do_facet $facet $LCTL --device %${!svc} notransno
1497 do_facet $facet $LCTL --device %${!svc} readonly
1498 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1499 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1502 replay_barrier_nodf() {
1503 local facet=$1 echo running=${running}
1504 do_facet $facet sync
1505 local svc=${facet}_svc
1506 echo Replay barrier on ${!svc}
1507 do_facet $facet $LCTL --device %${!svc} notransno
1508 do_facet $facet $LCTL --device %${!svc} readonly
1509 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1510 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1513 replay_barrier_nosync() {
1514 local facet=$1 echo running=${running}
1515 local svc=${facet}_svc
1516 echo Replay barrier on ${!svc}
1517 do_facet $facet $LCTL --device %${!svc} notransno
1518 do_facet $facet $LCTL --device %${!svc} readonly
1519 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1520 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1523 mds_evict_client() {
1524 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1525 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1528 ost_evict_client() {
1529 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1530 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1534 facet_failover $* || error "failover: $?"
1535 clients_up || error "post-failover df: $?"
1540 facet_failover $facet
1546 change_active $facet
1547 mount_facet $facet -o abort_recovery
1548 clients_up || echo "first df failed: $?"
1549 clients_up || error "post-failover df: $?"
1553 echo There is no lmc. This is mountconf, baby.
1558 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1564 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1565 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1566 if [ -z "$ID" ]; then
1567 echo "Could not get a ptl id for $1..."
1576 h2name_or_ip "$1" "tcp"
1581 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1582 if type __h2elan >/dev/null 2>&1; then
1585 ID=`echo $1 | sed 's/[^0-9]*//g'`
1593 h2name_or_ip "$1" "o2ib"
1600 [ "$facet" == client ] && echo -n $HOSTNAME && return
1601 varname=${facet}_HOST
1602 if [ -z "${!varname}" ]; then
1603 if [ "${facet:0:3}" == "ost" ]; then
1604 eval ${facet}_HOST=${ost_HOST}
1612 local activevar=${facet}active
1614 if [ -f $TMP/${facet}active ] ; then
1615 source $TMP/${facet}active
1618 active=${!activevar}
1619 if [ -z "$active" ] ; then
1626 facet_active_host() {
1628 local active=`facet_active $facet`
1629 if [ "$facet" == client ]; then
1632 echo `facet_host $active`
1640 facetlist=$(exclude_items_from_list $facetlist mgs)
1642 for facet in ${facetlist//,/ }; do
1643 local failover=${facet}failover
1644 local host=`facet_host $failover`
1645 [ -z "$host" ] && return
1647 local curactive=`facet_active $facet`
1648 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1649 eval export ${facet}active=$facet
1651 eval export ${facet}active=$failover
1653 # save the active host for this facet
1654 local activevar=${facet}active
1655 echo "$activevar=${!activevar}" > $TMP/$activevar
1656 local TO=`facet_active_host $facet`
1657 echo "Failover $facet to $TO"
1663 # do not stripe off hostname if verbose, bug 19215
1664 if [ x$1 = x--verbose ]; then
1672 if [ "$HOST" = "$HOSTNAME" ]; then
1674 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1675 echo "cannot run remote command on $HOST with $myPDSH"
1679 echo "CMD: $HOST $@" >&2
1680 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1683 if [ "$myPDSH" = "rsh" ]; then
1684 # we need this because rsh does not return exit code of an executed command
1685 local command_status="$TMP/cs"
1686 rsh $HOST ":> $command_status"
1687 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1688 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1689 echo command failed >$command_status"
1690 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1695 # print HOSTNAME for myPDSH="no_dsh"
1696 if [[ $myPDSH = no_dsh ]]; then
1697 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1699 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1702 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1704 return ${PIPESTATUS[0]}
1708 do_node --verbose "$@"
1711 single_local_node () {
1712 [ "$1" = "$HOSTNAME" ]
1715 # Outputs environment variable assignments that should be passed to remote nodes
1720 for var in ${!MODOPTS_*}; do
1722 echo "${var}=\"$value\""
1728 # do not stripe off hostname if verbose, bug 19215
1729 if [ x$1 = x--verbose ]; then
1737 if single_local_node $rnodes; then
1739 do_nodev $rnodes "$@"
1741 do_node $rnodes "$@"
1746 # This is part from do_node
1749 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1750 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1753 echo "CMD: $rnodes $@" >&2
1754 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1757 # do not replace anything from pdsh output if -N is used
1758 # -N Disable hostname: prefix on lines of output.
1759 if $verbose || [[ $myPDSH = *-N* ]]; then
1760 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1762 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1764 return ${PIPESTATUS[0]}
1770 local HOST=`facet_active_host $facet`
1771 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1776 do_nodes --verbose "$@"
1782 # make sure its not already running
1784 rm -f $TMP/${facet}active
1785 do_facet ${facet} $MKFS $*
1791 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1792 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1799 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1800 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1806 local var=${facet}_MOUNT
1807 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1816 # make sure we are using the primary server, so test-framework will
1817 # be able to clean up properly.
1818 activemds=`facet_active mds1`
1819 if [ $activemds != "mds1" ]; then
1823 local clients=$CLIENTS
1824 [ -z $clients ] && clients=$(hostname)
1826 zconf_umount_clients $clients $MOUNT "$*" || true
1827 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1829 [ "$CLIENTONLY" ] && return
1830 # The add fn does rm ${facet}active file, this would be enough
1831 # if we use do_facet <facet> only after the facet added, but
1832 # currently we use do_facet mds in local.sh
1833 for num in `seq $MDSCOUNT`; do
1835 rm -f ${TMP}/mds${num}active
1838 for num in `seq $OSTCOUNT`; do
1840 rm -f $TMP/ost${num}active
1843 if ! combined_mgs_mds ; then
1850 cleanup_echo_devs () {
1851 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1853 for dev in $devs; do
1854 $LCTL --device $dev cleanup
1855 $LCTL --device $dev detach
1860 nfs_client_mode && return
1869 combined_mgs_mds () {
1870 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1876 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1877 local optvar=${tgt}_MKFS_OPTS
1878 local opt=${!optvar}
1880 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1881 [[ $facet = mgs ]] && echo $opt && return
1884 # --failnode options
1885 local var=${facet}failover_HOST
1886 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1887 local failnode=$(h2$NETTYPE ${!var})
1888 failnode="--failnode=$failnode"
1889 # options does not contain
1890 # or contains wrong --failnode=
1891 if [[ $opt != *${failnode}* ]]; then
1892 opt=$(echo $opt | sed 's/--failnode=.* / /')
1893 opt="$opt $failnode"
1899 # no additional mkfs mds "--mgsnode" option for this configuration
1900 if [[ $facet = mds ]] && combined_mgs_mds; then
1905 # additional mkfs "--mgsnode"
1906 local mgsnode="--mgsnode=$MGSNID"
1907 opt=${opt//$mgsnode }
1908 for nid in ${MGSNID//:/ }; do
1909 local mgsnode="--mgsnode=$nid"
1910 # options does not contain
1912 if [[ $opt != *${mgsnode}" "* ]]; then
1913 opt="$opt --mgsnode=$nid"
1921 if [ "$IAMDIR" == "yes" ]; then
1922 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1925 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1928 # We need ldiskfs here, may as well load them all
1930 [ "$CLIENTONLY" ] && return
1931 echo Formatting mgs, mds, osts
1932 if ! combined_mgs_mds ; then
1933 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1936 for num in `seq $MDSCOUNT`; do
1937 echo "Format mds$num: $(mdsdevname $num)"
1939 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
1941 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
1945 # the ost-s could have different OST_MKFS_OPTS
1946 # because of different failnode-s
1947 for num in `seq $OSTCOUNT`; do
1948 echo "Format ost$num: $(ostdevname $num)"
1950 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1952 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1958 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1962 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1966 # 0: success, the old identity set already.
1967 # 1: success, the old identity does not set.
1972 local j=`expr $num - 1`
1973 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1975 if [ -z "$MDT" ]; then
1979 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1982 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1984 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1987 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
1989 if [ $old = "NONE" ]; then
1998 zconf_umount `hostname` $1 || error "umount failed"
1999 zconf_mount `hostname` $1 || error "mount failed"
2002 writeconf_facet () {
2006 do_facet $facet "$TUNEFS --writeconf $dev"
2010 for num in `seq $MDSCOUNT`; do
2011 DEVNAME=$(mdsdevname $num)
2012 writeconf_facet mds$num $DEVNAME
2015 for num in `seq $OSTCOUNT`; do
2016 DEVNAME=$(ostdevname $num)
2017 writeconf_facet ost$num $DEVNAME
2022 nfs_client_mode && return
2024 sanity_mount_check ||
2025 error "environments are insane!"
2029 if [ -z "$CLIENTONLY" ]; then
2030 echo Setup mgs, mdt, osts
2031 echo $WRITECONF | grep -q "writeconf" && \
2033 if ! combined_mgs_mds ; then
2034 start mgs $MGSDEV $MGS_MOUNT_OPTS
2037 for num in `seq $MDSCOUNT`; do
2038 DEVNAME=$(mdsdevname $num)
2039 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2041 # We started mds, now we should set failover variables properly.
2042 # Set mds${num}failover_HOST if it is not set (the default failnode).
2043 local varname=mds${num}failover_HOST
2044 if [ -z "${!varname}" ]; then
2045 eval mds${num}failover_HOST=$(facet_host mds$num)
2048 if [ $IDENTITY_UPCALL != "default" ]; then
2049 switch_identity $num $IDENTITY_UPCALL
2052 for num in `seq $OSTCOUNT`; do
2053 DEVNAME=$(ostdevname $num)
2054 start ost$num $DEVNAME $OST_MOUNT_OPTS
2056 # We started ost$num, now we should set ost${num}failover variable properly.
2057 # Set ost${num}failover_HOST if it is not set (the default failnode).
2058 varname=ost${num}failover_HOST
2059 if [ -z "${!varname}" ]; then
2060 eval ost${num}failover_HOST=$(facet_host ost${num})
2068 # wait a while to allow sptlrpc configuration be propogated to targets,
2069 # only needed when mounting new target devices.
2074 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2076 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2078 if [ "$MOUNT_2" ]; then
2079 mount_client $MOUNT2
2080 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2085 # by remounting mdt before ost, initial connect from mdt to ost might
2086 # timeout because ost is not ready yet. wait some time to its fully
2087 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2088 # by a context negotiation rpc with $TIMEOUT.
2089 # FIXME better by monitoring import status.
2092 sleep $((TIMEOUT + 5))
2098 mounted_lustre_filesystems() {
2099 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2102 init_facet_vars () {
2103 [ "$CLIENTONLY" ] && return 0
2110 eval export ${facet}_dev=${device}
2111 eval export ${facet}_opt=\"$@\"
2113 local dev=${facet}_dev
2114 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2115 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2117 eval export ${facet}_svc=${label}
2119 local varname=${facet}failover_HOST
2120 if [ -z "${!varname}" ]; then
2121 eval $varname=$(facet_host $facet)
2124 # ${facet}failover_dev is set in cfg file
2125 varname=${facet}failover_dev
2126 if [ -n "${!varname}" ] ; then
2127 eval export ${facet}failover_dev=${!varname}
2129 eval export ${facet}failover_dev=$device
2132 # get mount point of already mounted device
2133 # is facet_dev is already mounted then use the real
2134 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2135 # i.e. ${facet}_MOUNT if specified by user or default
2136 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2137 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2138 if [ -z $mntpt ]; then
2139 mntpt=$(facet_mntpt $facet)
2141 eval export ${facet}_MOUNT=$mntpt
2144 init_facets_vars () {
2147 if ! remote_mds_nodsh; then
2148 for num in `seq $MDSCOUNT`; do
2149 DEVNAME=`mdsdevname $num`
2150 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2154 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2156 remote_ost_nodsh && return
2158 for num in `seq $OSTCOUNT`; do
2159 DEVNAME=`ostdevname $num`
2160 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2164 osc_ensure_active () {
2169 while [ $period -lt $timeout ]; do
2170 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2171 if [ $count -eq 0 ]; then
2175 echo "There are $count OST are inactive, wait $period seconds, and try again"
2177 period=$((period+3))
2180 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2183 init_param_vars () {
2184 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2185 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2186 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2187 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2191 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2193 log "Using TIMEOUT=$TIMEOUT"
2195 osc_ensure_active $SINGLEMDS $TIMEOUT
2196 osc_ensure_active client $TIMEOUT
2198 if [ $QUOTA_AUTO -ne 0 ]; then
2199 if [ "$ENABLE_QUOTA" ]; then
2200 echo "enable quota as required"
2201 setup_quota $MOUNT || return 2
2203 echo "disable quota as required"
2204 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2211 nfs_client_mode () {
2212 if [ "$NFSCLIENT" ]; then
2213 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2214 local clients=$CLIENTS
2215 [ -z $clients ] && clients=$(hostname)
2217 # FIXME: remove hostname when 19215 fixed
2218 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2219 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2220 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2221 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2223 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2229 check_config_client () {
2232 local mounted=$(mount | grep " $mntpt ")
2233 if [ "$CLIENTONLY" ]; then
2235 # CLIENTONLY should not depend on *_HOST settings
2236 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2237 # in theory someone could create a new,
2238 # client-only config file that assumed lustre was already
2239 # configured and didn't set the MGSNID. If MGSNID is not set,
2240 # then we should use the mgs nid currently being used
2241 # as the default value. bug 18021
2242 [[ x$MGSNID = x ]] &&
2245 if [[ x$mgc != xMGC$MGSNID ]]; then
2246 if [ "$mgs_HOST" ]; then
2247 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2248 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2249 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2255 local myMGS_host=$mgs_HOST
2256 if [ "$NETTYPE" = "ptl" ]; then
2257 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2260 echo Checking config lustre mounted on $mntpt
2261 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2262 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2264 # if [ "$mgshost" != "$myMGS_host" ]; then
2265 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2266 # Please use correct config or set mds_HOST correctly!"
2271 check_config_clients () {
2272 local clients=${CLIENTS:-$HOSTNAME}
2275 nfs_client_mode && return
2277 do_rpc_nodes $clients check_config_client $mntpt
2279 sanity_mount_check ||
2280 error "environments are insane!"
2284 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2285 local cltimeout=$(lctl get_param -n timeout)
2286 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2287 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2294 [ -z $mntpt ] && return 1
2295 local mounted=$(mounted_lustre_filesystems)
2297 echo $mounted' ' | grep -w -q $mntpt' '
2301 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2305 # empty lustre filesystem may have empty directories lost+found and .lustre
2307 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2308 -print | wc -l) = 1 ] || return 1
2309 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2310 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2314 check_and_setup_lustre() {
2315 nfs_client_mode && return
2317 local MOUNTED=$(mounted_lustre_filesystems)
2321 # both MOUNT and MOUNT2 are not mounted
2322 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2323 [ "$REFORMAT" ] && formatall
2324 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2326 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2327 export I_MOUNTED=yes
2331 elif is_mounted $MOUNT2; then
2333 # MOUNT2 is mounted, while MOUNT_2 is not set
2334 if ! [ "$MOUNT_2" ]; then
2335 cleanup_mount $MOUNT2
2336 export I_UMOUNTED2=yes
2339 # MOUNT2 is mounted, MOUNT_2 is set
2341 # FIXME: what to do if check_config failed?
2343 # 1) remote client has mounted other Lustre fs ?
2344 # 2) it has insane env ?
2345 # let's try umount MOUNT2 on all clients and mount it again:
2346 if ! check_config_clients $MOUNT2; then
2347 cleanup_mount $MOUNT2
2348 restore_mount $MOUNT2
2349 export I_MOUNTED2=yes
2354 # MOUNT is mounted MOUNT2 is not mounted
2355 elif [ "$MOUNT_2" ]; then
2356 restore_mount $MOUNT2
2357 export I_MOUNTED2=yes
2361 # FIXME: what to do if check_config failed?
2363 # 1) remote client has mounted other Lustre fs?
2364 # 2) lustre is mounted on remote_clients atall ?
2365 check_config_clients $MOUNT
2369 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2370 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2371 lctl set_param debug_mb=${DEBUG_SIZE};
2378 if [ "$ONLY" == "setup" ]; then
2384 local clients=${CLIENTS:-$HOSTNAME}
2387 zconf_mount_clients $clients $mntpt
2391 local clients=${CLIENTS:-$HOSTNAME}
2394 zconf_umount_clients $clients $mntpt
2397 cleanup_and_setup_lustre() {
2398 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2399 lctl set_param debug=0 || true
2401 if [ "$ONLY" == "cleanup" ]; then
2405 check_and_setup_lustre
2408 # Get all of the server target devices from a given server node and type.
2417 mdt) obd_type="osd" ;;
2418 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2419 *) echo "invalid server type" && return 1 ;;
2422 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2423 for dev in $devs; do
2425 *loop*) do_node $node "losetup $dev" | \
2426 sed -e "s/.*(//" -e "s/).*//" ;;
2432 # Get all of the server target devices.
2437 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2441 for node in $(osts_nodes); do
2442 OSTDEVS[i]=$(get_mnt_devs $node ost)
2447 # Run e2fsck on MDT or OST device.
2453 df > /dev/null # update statfs data on disk
2454 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2457 do_node $node $cmd || rc=$?
2458 [ $rc -le $FSCK_MAX_ERR ] || \
2459 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2463 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2470 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2471 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2472 error "fail to create file in $SHARED_DIRECTORY")
2474 # make sure everything gets to the backing store
2475 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2476 do_nodes $list "sync; sleep 2; sync"
2478 do_nodes $list ls $tmp_file || \
2479 error "$SHARED_DIRECTORY is not a shared directory"
2482 run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
2487 for node in $(osts_nodes); do
2488 for dev in ${OSTDEVS[i]}; do
2489 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
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" -a "$TESTSUITE" != "lfsck" ]; then
2517 if is_mounted $MOUNT; then
2518 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2519 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2522 if [ "$I_UMOUNTED2" = "yes" ]; then
2523 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2526 if [ "$I_MOUNTED2" = "yes" ]; then
2527 cleanup_mount $MOUNT2
2530 if [ "$I_MOUNTED" = "yes" ]; then
2531 cleanupall -f || error "cleanup failed"
2539 wait_for_function () {
2542 # suppress fn both stderr and stdout
2543 if [ "$1" = "--quiet" ]; then
2545 quiet=" > /dev/null 2>&1"
2557 eval $fn $quiet && return 0
2559 wait=$((wait + sleep))
2560 [ $wait -lt $max ] || return 1
2561 echo waiting $fn, $((max - wait)) secs left ...
2571 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2572 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2573 echo "Network not available!"
2577 echo `date +"%H:%M:%S (%s)"` network interface is UP
2586 # the sed converts spaces to commas, but leaves the last space
2587 # alone, so the line doesn't end with a comma.
2588 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2594 echo $list | grep -qw $item
2597 # list, excluded are the comma separated lists
2598 exclude_items_from_list () {
2604 for item in ${excluded//,/ }; do
2605 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2607 echo $(comma_list $list)
2610 # list, expand are the comma separated lists
2612 local list=${1//,/ }
2613 local expand=${2//,/ }
2616 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2617 echo $(comma_list $expanded)
2620 testslist_filter () {
2621 local script=$LUSTRE/tests/${TESTSUITE}.sh
2623 [ -f $script ] || return 0
2625 local start_at=$START_AT
2626 local stop_at=$STOP_AT
2628 local var=${TESTSUITE//-/_}_START_AT
2629 [ x"${!var}" != x ] && start_at=${!var}
2630 var=${TESTSUITE//-/_}_STOP_AT
2631 [ x"${!var}" != x ] && stop_at=${!var}
2633 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2634 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2635 /^'${start_at}'$/ {flag = 0}
2636 {if (flag == 1) print $0}
2637 /^'${stop_at}'$/ { flag = 1 }'
2641 (cd `dirname $1`; echo $PWD/`basename $1`)
2645 local types=${1:-"OST MDS MGS"}
2649 for entry in $types; do
2650 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2651 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2654 MGS ) list="$list $name";;
2655 MDS|OST ) local count=${type}COUNT
2656 for ((i=1; i<=${!count}; i++)) do
2657 list="$list ${name}$i"
2659 * ) error "Invalid facet type"
2663 echo $(comma_list $list)
2666 ##################################
2667 # Adaptive Timeouts funcs
2670 # only check mds, we assume at_max is the same on all nodes
2671 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2672 if [ $at_max -eq 0 ]; then
2682 # suppose that all ost-s has the same at_max set
2683 if [ $facet == "ost" ]; then
2684 do_facet ost1 "lctl get_param -n at_max"
2686 do_facet $facet "lctl get_param -n at_max"
2696 if [ $facet == "ost" ]; then
2697 for i in `seq $OSTCOUNT`; do
2698 do_facet ost$i "lctl set_param at_max=$at_max"
2701 elif [ $facet == "mds" ]; then
2702 for i in `seq $MDSCOUNT`; do
2703 do_facet mds$i "lctl set_param at_max=$at_max"
2706 do_facet $facet "lctl set_param at_max=$at_max"
2711 ##################################
2715 # OBD_FAIL_MDS_ALL_REQUEST_NET
2717 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2718 do_facet client "$1" || RC=$?
2719 do_facet $SINGLEMDS lctl set_param fail_loc=0
2724 # OBD_FAIL_MDS_ALL_REPLY_NET
2726 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2727 do_facet client "$@" || RC=$?
2728 do_facet $SINGLEMDS lctl set_param fail_loc=0
2732 drop_reint_reply() {
2733 # OBD_FAIL_MDS_REINT_NET_REP
2735 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2736 do_facet client "$@" || RC=$?
2737 do_facet $SINGLEMDS lctl set_param fail_loc=0
2742 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2744 do_facet ost1 lctl set_param fail_loc=0x214
2745 do_facet client "$1" || RC=$?
2746 do_facet client "sync"
2747 do_facet ost1 lctl set_param fail_loc=0
2751 drop_ldlm_cancel() {
2752 #define OBD_FAIL_LDLM_CANCEL 0x304
2754 do_facet client lctl set_param fail_loc=0x304
2755 do_facet client "$@" || RC=$?
2756 do_facet client lctl set_param fail_loc=0
2760 drop_bl_callback() {
2761 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2763 do_facet client lctl set_param fail_loc=0x305
2764 do_facet client "$@" || RC=$?
2765 do_facet client lctl set_param fail_loc=0
2770 #define OBD_FAIL_LDLM_REPLY 0x30c
2772 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2773 do_facet client "$@" || RC=$?
2774 do_facet $SINGLEMDS lctl set_param fail_loc=0
2782 echo "clearing fail_loc on $facet"
2783 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2786 set_nodes_failloc () {
2787 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2790 cancel_lru_locks() {
2791 $LCTL mark "cancel_lru_locks $1 start"
2792 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2793 $LCTL set_param -n $d=clear
2795 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2796 $LCTL mark "cancel_lru_locks $1 stop"
2801 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2802 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2803 echo "$DEFAULT_LRU_SIZE"
2808 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2811 lru_resize_disable()
2813 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2818 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2819 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2820 echo there is still data in page cache $FILE ?
2821 lctl get_param -n $FILE
2829 DEBUGSAVE="$(lctl get_param -n debug)"
2833 [ -n "$DEBUGSAVE" ] && \
2834 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2839 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2842 debug_size_restore() {
2843 [ -n "$DEBUG_SIZE_SAVED" ] && \
2844 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2848 start_full_debug_logging() {
2853 local DEBUG_SIZE=150
2855 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2856 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2859 stop_full_debug_logging() {
2864 ##################################
2866 ##################################
2869 local TYPE=${TYPE:-"FAIL"}
2872 # do not dump logs if $1=false
2873 if [ "x$1" = "xfalse" ]; then
2878 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2880 # We need to dump the logs on all nodes
2882 gather_logs $(comma_list $(nodes_list))
2886 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2887 echo "$@" > $LOGDIR/err
2892 local log=$TESTSUITELOG
2894 [ -f "$log" ] && grep -q FAIL: $log && status=1
2907 # use only if we are ignoring failures for this test, bugno required.
2908 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2909 # e.g. error_ignore 5494 "your message"
2911 local TYPE="IGNORE (bz$1)"
2917 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2922 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2923 [ "$ALWAYS_SKIPPED" ] && \
2924 skip_logged ${TESTNAME} "$@" || true
2925 [ "$TESTSUITELOG" ] && \
2926 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2929 build_test_filter() {
2930 EXCEPT="$EXCEPT $(testslist_filter)"
2932 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2936 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2937 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2938 [ "$EXCEPT_SLOW" ] && \
2939 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2940 for E in $EXCEPT; do
2941 eval EXCEPT_${E}=true
2943 for E in $ALWAYS_EXCEPT; do
2944 eval EXCEPT_ALWAYS_${E}=true
2946 for E in $EXCEPT_SLOW; do
2947 eval EXCEPT_SLOW_${E}=true
2949 for G in $GRANT_CHECK_LIST; do
2950 eval GCHECK_ONLY_${G}=true
2955 if [[ $1 = [a-z]* ]]; then
2962 # print a newline if the last test was skipped
2963 export LAST_SKIPPED=
2964 export ALWAYS_SKIPPED=
2966 # Main entry into test-framework. This is called with the name and
2967 # description of a test. The name is used to find the function to run
2968 # the test using "test_$name".
2970 # This supports a variety of methods of specifying specific test to
2971 # run or not run. These need to be documented...
2976 export base=`basetest $1`
2977 if [ ! -z "$ONLY" ]; then
2979 if [ ${!testname}x != x ]; then
2980 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2981 run_one_logged $1 "$2"
2985 if [ ${!testname}x != x ]; then
2986 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2987 run_one_logged $1 "$2"
2995 if [ ${!testname}x != x ]; then
2997 TESTNAME=test_$1 skip "skipping excluded test $1"
3000 testname=EXCEPT_$base
3001 if [ ${!testname}x != x ]; then
3003 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3006 testname=EXCEPT_ALWAYS_$1
3007 if [ ${!testname}x != x ]; then
3010 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3013 testname=EXCEPT_ALWAYS_$base
3014 if [ ${!testname}x != x ]; then
3017 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3020 testname=EXCEPT_SLOW_$1
3021 if [ ${!testname}x != x ]; then
3023 TESTNAME=test_$1 skip "skipping SLOW test $1"
3026 testname=EXCEPT_SLOW_$base
3027 if [ ${!testname}x != x ]; then
3029 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3035 run_one_logged $1 "$2"
3046 module_loaded lnet || load_modules
3058 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3063 strace -o $TMP/$1.strace -ttt $*
3065 log "FINISHED: $*: rc $RC"
3070 equals_msg $1 test complete, duration $2 sec
3071 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3072 echo duration $2 >>$TESTSUITELOG
3076 # Set TEST_STATUS here; will be used for logging the result
3077 if [ -f $LOGDIR/err ]; then
3082 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3086 local FFREE=$(do_node $SINGLEMDS \
3087 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3088 local FTOTAL=$(do_node $SINGLEMDS \
3089 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3091 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3095 echo -n "Resetting fail_loc on all nodes..."
3096 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3102 # Log a message (on all nodes) padded with "=" before and after.
3103 # Also appends a timestamp and prepends the testsuite name.
3106 EQUALS="===================================================================================================="
3108 msg="== ${TESTSUITE} $*"
3110 [[ $last != "=" && $last != " " ]] && msg="$msg "
3111 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3112 # always include at least == after the message
3113 log "$msg== $(date +"%H:%M:%S (%s)")"
3117 # Run a single test function and cleanup after it.
3119 # This function should be run in a subshell so the test func can
3120 # exit() without stopping the whole script.
3126 export tdir=d0.${TESTSUITE}/d${base}
3127 export TESTNAME=test_$testnum
3128 local SAVE_UMASK=`umask`
3131 banner "test $testnum: $message"
3132 test_${testnum} || error "test_$testnum failed with $?"
3135 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3136 check_catastrophe || error "LBUG/LASSERT detected"
3137 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3145 # Wrapper around run_one to ensure:
3146 # - test runs in subshell
3147 # - output of test is saved to separate log file for error reporting
3148 # - test result is saved to data file
3151 local BEFORE=`date +%s`
3153 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
3154 local test_log=$LOGDIR/$name
3158 log_sub_test_begin test_${1}
3159 (run_one $1 "$2") 2>&1 | tee $test_log
3160 local RC=${PIPESTATUS[0]}
3162 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3163 echo "test_$1 returned $RC" | tee $LOGDIR/err
3165 duration=$((`date +%s` - $BEFORE))
3166 pass "$1" "(${duration}s)"
3167 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3168 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3170 if [ -f $LOGDIR/err ]; then
3171 $FAIL_ON_ERROR && exit $RC
3178 # Print information of skipped tests to result.yml
3181 log_sub_test_begin $1
3182 log_sub_test_end "SKIP" "0" "0" "\"$2\""
3186 (cd `dirname $1`; echo $PWD/`basename $1`)
3191 export base=`basetest $1`
3192 [ "$CHECK_GRANT" == "no" ] && return 0
3194 testname=GCHECK_ONLY_${base}
3195 [ ${!testname}x == x ] && return 0
3197 echo -n "checking grant......"
3199 local clients=$CLIENTS
3200 [ -z $clients ] && clients=$(hostname)
3202 # sync all the data and make sure no pending data on server
3203 do_nodes $clients sync
3206 client_grant=`do_nodes $clients \
3207 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3208 awk '{total += $1} END{print total}'`
3211 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3212 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3213 awk '{total += $1} END{print total}'`
3215 # check whether client grant == server grant
3216 if [ $client_grant -ne $server_grant ]; then
3217 echo "failed: client:${client_grant} server: ${server_grant}."
3218 do_nodes $(comma_list $(osts_nodes)) \
3219 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3220 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3223 echo "pass: client:${client_grant} server: ${server_grant}"
3228 ########################
3234 ost=`echo $1 | awk -F_ '{print $3}'`
3235 if [ -z $ost ]; then
3236 ost=`echo $1 | sed 's/-osc.*//'`
3241 ostuuid_from_index()
3243 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
3248 [ "$node" != "$(hostname)" ]
3254 for node in $(mdts_nodes); do
3255 remote_node $node && return 0
3262 [ "$CLIENTONLY" ] && return 0 || true
3263 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3268 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3269 MSKIPPED=1 && return 1
3276 for node in $(osts_nodes) ; do
3277 remote_node $node && return 0
3284 [ "$CLIENTONLY" ] && return 0 || true
3285 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3290 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3291 OSKIPPED=1 && return 1
3298 MGS=$(facet_host mgs)
3299 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3304 remote_mds_nodsh || remote_ost_nodsh || \
3305 $(single_local_node $(comma_list $(nodes_list)))
3311 for num in `seq $MDSCOUNT`; do
3312 MDSNODES="$MDSNODES $(facet_host mds$num)"
3314 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3320 remote_ost && remote_mds
3328 for facet in ${facets//,/ }; do
3329 if [ "$FAILURE_MODE" = HARD ]; then
3330 nodes="$nodes $(facet_active_host $facet)"
3332 nodes="$nodes $(facet_host $facet)"
3335 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3341 local facets=$(get_facets OST)
3342 local nodes=$(facets_nodes $facets)
3348 # FIXME. We need a list of clients
3349 local myNODES=$HOSTNAME
3352 # CLIENTS (if specified) contains the local client
3353 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3355 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3356 myNODES="$myNODES $(facets_nodes $(get_facets))"
3359 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3364 remote_nodes_list () {
3365 local rnodes=$(nodes_list)
3366 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3370 init_clients_lists () {
3371 # Sanity check: exclude the local client from RCLIENTS
3372 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3374 # Sanity check: exclude the dup entries
3375 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3377 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3379 # Sanity check: exclude the dup entries from CLIENTS
3380 # for those configs which has SINGLCLIENT set to local client
3381 clients=$(for i in $clients; do echo $i; done | sort -u)
3383 CLIENTS=`comma_list $clients`
3384 local -a remoteclients=($rclients)
3385 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3386 varname=CLIENT$((i + 2))
3387 eval $varname=${remoteclients[i]}
3390 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3393 get_random_entry () {
3396 rnodes=${rnodes//,/ }
3398 local -a nodes=($rnodes)
3399 local num=${#nodes[@]}
3400 local i=$((RANDOM * num * 2 / 65536))
3406 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3411 lctl get_param version | grep -q patchless
3415 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3420 echo $nodes | wc -w || true
3424 local nodes=$(osts_nodes)
3425 local osscount=$(get_node_count "$nodes")
3426 [ ! "$OSTCOUNT" = "$osscount" ]
3430 local nodes=$(mdts_nodes)
3431 local mdtcount=$(get_node_count "$nodes")
3432 [ ! "$MDSCOUNT" = "$mdtcount" ]
3435 generate_machine_file() {
3436 local nodes=${1//,/ }
3437 local machinefile=$2
3439 for node in $nodes; do
3440 echo $node >>$machinefile || \
3441 { echo "can not generate machinefile $machinefile" && return 1; }
3446 local file=$1/stripe
3448 $LFS getstripe -v $file || error
3452 setstripe_nfsserver () {
3455 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3456 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3458 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3460 do_nodev $nfsserver lfs setstripe "$@"
3463 check_runas_id_ret() {
3465 local myRUNAS_UID=$1
3466 local myRUNAS_GID=$2
3469 if [ -z "$myRUNAS" ]; then
3470 error_exit "myRUNAS command must be specified for check_runas_id"
3473 $myRUNAS krb5_login.sh || \
3474 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3476 mkdir $DIR/d0_runas_test
3478 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3479 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3480 rm -rf $DIR/d0_runas_test
3485 local myRUNAS_UID=$1
3486 local myRUNAS_GID=$2
3489 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3490 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3491 Please set RUNAS_ID to some UID which exists on MDS and client or
3492 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3495 # obtain the UID/GID for MPI_USER
3499 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3500 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3502 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3503 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3506 # obtain and cache Kerberos ticket-granting ticket
3507 refresh_krb5_tgt() {
3508 local myRUNAS_UID=$1
3509 local myRUNAS_GID=$2
3512 if [ -z "$myRUNAS" ]; then
3513 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3516 CLIENTS=${CLIENTS:-$HOSTNAME}
3517 do_nodes $CLIENTS "set -x
3518 if ! $myRUNAS krb5_login.sh; then
3519 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3524 # Run multiop in the background, but wait for it to print
3525 # "PAUSING" to its stdout before returning from this function.
3526 multiop_bg_pause() {
3527 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3531 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3534 echo "$MULTIOP_PROG $FILE v$ARGS"
3535 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3537 echo "TMPPIPE=${TMPPIPE}"
3538 read -t 60 multiop_output < $TMPPIPE
3539 if [ $? -ne 0 ]; then
3544 if [ "$multiop_output" != "PAUSING" ]; then
3545 echo "Incorrect multiop output: $multiop_output"
3560 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3566 inodes_available () {
3567 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3571 mdsrate_inodes_available () {
3572 echo $(($(inodes_available) - 1))
3575 # reset llite stat counters
3576 clear_llite_stats(){
3577 lctl set_param -n llite.*.stats 0
3580 # sum llite stat items
3581 calc_llite_stats() {
3582 local res=$(lctl get_param -n llite.*.stats |
3583 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3587 # reset osc stat counters
3589 lctl set_param -n osc.*.osc_stats 0
3592 # sum osc stat items
3594 local res=$(lctl get_param -n osc.*.osc_stats |
3595 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3600 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3603 calc_osc_kbytes () {
3604 df $MOUNT > /dev/null
3605 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3608 # save_lustre_params(node, parameter_mask)
3609 # generate a stream of formatted strings (<node> <param name>=<param value>)
3610 save_lustre_params() {
3612 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3615 # restore lustre parameters from input stream, produces by save_lustre_params
3616 restore_lustre_params() {
3620 while IFS=" =" read node name val; do
3621 do_node ${node//:/} "lctl set_param -n $name $val"
3625 check_catastrophe() {
3626 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3627 local C=$CATASTROPHE
3628 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3630 if [ $rnodes ]; then
3631 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3632 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3648 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3650 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3651 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3652 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3656 # CMD: determine mds index where directory inode presents
3659 local file=$dir/f0.get_mds_dir_tmpfile
3664 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3665 local -a oldused=($iused)
3667 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3669 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3670 local -a newused=($iused)
3673 for ((i=0; i<${#newused[@]}; i++)); do
3674 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3680 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3683 mdsrate_cleanup () {
3685 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3690 delayed_recovery_enabled () {
3691 local var=${SINGLEMDS}_svc
3692 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3695 ########################
3697 convert_facet2label() {
3700 if [ x$facet = xost ]; then
3704 local varsvc=${facet}_svc
3706 if [ -n ${!varsvc} ]; then
3709 error "No lablel for $facet!"
3713 get_clientosc_proc_path() {
3719 get_lustre_version () {
3720 local facet=${1:-"$SINGLEMDS"}
3721 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3724 get_mds_version_major () {
3725 local facet=${1:-"$SINGLEMDS"}
3726 local version=$(get_lustre_version $facet)
3727 echo $version | awk -F. '{print $1}'
3730 get_mds_version_minor () {
3731 local facet=${1:-"$SINGLEMDS"}
3732 local version=$(get_lustre_version $facet)
3733 echo $version | awk -F. '{print $2}'
3736 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3737 # used by MDT would not be changed.
3738 # mdt lov: fsname-mdtlov
3739 # mdt osc: fsname-OSTXXXX-osc
3740 mds_on_old_device() {
3741 local mds=${1:-"$SINGLEMDS"}
3742 local major=$(get_mds_version_major $mds)
3743 local minor=$(get_mds_version_minor $mds)
3745 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3746 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3747 > /dev/null 2>&1" && return 0
3752 get_mdtosc_proc_path() {
3754 local ost_label=${2:-"*OST*"}
3756 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3757 local mdt_label=$(convert_facet2label $mds_facet)
3758 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3760 local major=$(get_mds_version_major $mds_facet)
3761 local minor=$(get_mds_version_minor $mds_facet)
3762 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3763 echo "${ost_label}-osc"
3765 echo "${ost_label}-osc-${mdt_index}"
3769 get_osc_import_name() {
3772 local label=$(convert_facet2label $ost)
3774 if [ "${facet:0:3}" = "mds" ]; then
3775 get_mdtosc_proc_path $facet $label
3779 get_clientosc_proc_path $label
3783 _wait_import_state () {
3786 local maxtime=${3:-max_recovery_time}
3790 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3791 while [ "${CONN_STATE}" != "${expected}" ]; do
3792 [ $i -ge $maxtime ] && \
3793 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3796 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3800 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3804 wait_import_state() {
3807 local maxtime=${3:-max_recovery_time}
3810 for param in ${params//,/ }; do
3811 _wait_import_state $state $param $maxtime || return
3814 wait_osc_import_state() {
3818 local ost=$(get_osc_import_name $facet $ost_facet)
3823 CONN_PROC="osc.${ost}.ost_server_uuid"
3824 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3825 while [ "${CONN_STATE}" != "${expected}" ]; do
3826 if [ "${expected}" == "DISCONN" ]; then
3827 # for disconn we can check after proc entry is removed
3828 [ "x${CONN_STATE}" == "x" ] && return 0
3829 # with AT we can have connect request timeout ~ reconnect timeout
3830 # and test can't see real disconnect
3831 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3833 # disconnect rpc should be wait not more obd_timeout
3834 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3835 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3837 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3841 log "${ost_facet} now in ${CONN_STATE} state"
3844 get_clientmdc_proc_path() {
3852 # Add paths to lustre tests for 32 and 64 bit systems.
3853 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3854 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3857 wait_clients_import_state () {
3864 if [ "$FAILURE_MODE" = HARD ]; then
3865 facets=$(facets_on_host $(facet_active_host $facet))
3868 for facet in ${facets//,/ }; do
3869 local label=$(convert_facet2label $facet)
3872 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3873 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3874 *) error "unknown facet!" ;;
3876 local params=$(expand_list $params $proc_path)
3879 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3880 error "import is not in ${expected} state"
3889 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3890 $LCTL get_param obdfilter.*.kbytesavail))
3891 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3892 $LCTL get_param -n obdfilter.*.tot_granted))
3893 for ((i=0; i<${#AVAILA[@]}; i++)); do
3894 local -a AVAIL1=(${AVAILA[$i]//=/ })
3895 GRANT=$((${GRANTA[$i]}/1024))
3896 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3897 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3903 do_facet mgs lctl pool_list $1
3907 local fsname=${1%%.*}
3908 local poolname=${1##$fsname.}
3910 do_facet mgs lctl pool_new $1
3912 # get param should return err unless pool is created
3913 [[ $RC -ne 0 ]] && return $RC
3915 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3916 2>/dev/null || echo foo" "" || RC=1
3917 if [[ $RC -eq 0 ]]; then
3920 error "pool_new failed $1"
3925 add_pool_to_list () {
3926 local fsname=${1%%.*}
3927 local poolname=${1##$fsname.}
3929 local listvar=${fsname}_CREATED_POOLS
3930 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3933 remove_pool_from_list () {
3934 local fsname=${1%%.*}
3935 local poolname=${1##$fsname.}
3937 local listvar=${fsname}_CREATED_POOLS
3938 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3941 destroy_pool_int() {
3943 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3944 awk '$1 !~ /^Pool:/ {print $1}')
3945 for ost in $OSTS; do
3946 do_facet mgs lctl pool_remove $1 $ost
3948 do_facet mgs lctl pool_destroy $1
3951 # <fsname>.<poolname> or <poolname>
3953 local fsname=${1%%.*}
3954 local poolname=${1##$fsname.}
3956 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3960 pool_list $fsname.$poolname || return $?
3962 destroy_pool_int $fsname.$poolname
3964 [[ $RC -ne 0 ]] && return $RC
3966 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3967 2>/dev/null || echo foo" "foo" || RC=1
3969 if [[ $RC -eq 0 ]]; then
3970 remove_pool_from_list $fsname.$poolname
3972 error "destroy pool failed $1"
3978 local fsname=${1:-$FSNAME}
3980 local listvar=${fsname}_CREATED_POOLS
3984 [ x${!listvar} = x ] && return 0
3986 echo destroy the created pools: ${!listvar}
3987 for poolname in ${!listvar//,/ }; do
3988 destroy_pool $fsname.$poolname
3993 local fsname=${1:-$FSNAME}
3995 destroy_pools $fsname
4001 local ts=$(date +%s)
4003 [ -f $LOGDIR/shared ] && docp=false
4005 # dump lustre logs, dmesg
4007 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4009 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4011 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4012 echo "Dumping logs only on local client."
4013 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
4014 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
4019 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
4020 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
4021 if [ ! -f $LOGDIR/shared ]; then
4022 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4025 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
4026 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
4032 local list=${1:-$(comma_list $(nodes_list))}
4034 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
4046 for i in $(seq 0 $num_mntpts); do
4047 cmd="ls -laf ${mntpt_root}$i/$dir"
4053 for pid in $pids; do
4060 # target_start_and_reset_recovery_timer()
4061 # service_time = at_est2timeout(service_time);
4062 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4063 # INITIAL_CONNECT_TIMEOUT);
4064 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4065 #define CONNECTION_SWITCH_INC 1
4066 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4067 #define CONNECTION_SWITCH_MIN 5U
4069 max_recovery_time () {
4070 local init_connect_timeout=$(( TIMEOUT / 20 ))
4071 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
4073 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4078 get_clients_mount_count () {
4079 local clients=${CLIENTS:-`hostname`}
4081 # we need to take into account the clients mounts and
4082 # exclude mds/ost mounts if any;
4083 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4087 PROC_CLI="srpc_info"
4095 if [ $M -lt $N ]; then
4099 while [ $N -lt $M ]; do
4109 calc_connection_cnt() {
4112 # MDT->MDT = 2 * C(M, 2)
4116 comb_m2=$(combination $MDSCOUNT 2)
4118 local num_clients=$(get_clients_mount_count)
4120 local cnt_mdt2mdt=$((comb_m2 * 2))
4121 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4122 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4123 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4124 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4125 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4126 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4140 local cmd="$tgt.srpc.flavor"
4142 if [ $net == "any" ]; then
4147 if [ $dir != "any" ]; then
4152 log "Setting sptlrpc rule: $cmd"
4153 do_facet mgs "$LCTL conf_param $cmd"
4162 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4163 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4165 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4167 if [ "x$bulkspec" != "x" ]; then
4168 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4170 if [ "x$algs" != "x" ]; then
4171 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4173 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4174 if [ $bulk == "bulkn" ]; then
4175 bulk_count=`echo "$output" | grep "bulk flavor" \
4176 | grep "null/null" | wc -l`
4177 elif [ $bulk == "bulki" ]; then
4178 bulk_count=`echo "$output" | grep "bulk flavor" \
4179 | grep "/null" | grep -v "null/" | wc -l`
4181 bulk_count=`echo "$output" | grep "bulk flavor" \
4182 | grep -v "/null" | grep -v "null/" | wc -l`
4186 [ $bulk_count -lt $count ] && count=$bulk_count
4197 local clients=${CLIENTS:-`hostname`}
4199 for c in ${clients//,/ }; do
4200 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4201 tmpcnt=`count_flvr "$output" $flavor`
4202 cnt=$((cnt + tmpcnt))
4212 local clients=${CLIENTS:-`hostname`}
4214 for c in ${clients//,/ }; do
4215 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4216 tmpcnt=`count_flvr "$output" $flavor`
4217 cnt=$((cnt + tmpcnt))
4227 if [ $MDSCOUNT -le 1 ]; then
4232 for num in `seq $MDSCOUNT`; do
4233 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4234 tmpcnt=`count_flvr "$output" $flavor`
4235 cnt=$((cnt + tmpcnt))
4246 for num in `seq $MDSCOUNT`; do
4247 mdtosc=$(get_mdtosc_proc_path mds$num)
4248 mdtosc=${mdtosc/-MDT*/-MDT\*}
4249 output=$(do_facet mds$num lctl get_param -n \
4250 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4251 tmpcnt=`count_flvr "$output" $flavor`
4252 cnt=$((cnt + tmpcnt))
4261 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4262 count_flvr "$output" $flavor
4267 local dir=$1 # from to
4268 local flavor=$2 # flavor expected
4271 if [ $dir == "cli2mdt" ]; then
4272 res=`flvr_cnt_cli2mdt $flavor`
4273 elif [ $dir == "cli2ost" ]; then
4274 res=`flvr_cnt_cli2ost $flavor`
4275 elif [ $dir == "mdt2mdt" ]; then
4276 res=`flvr_cnt_mdt2mdt $flavor`
4277 elif [ $dir == "mdt2ost" ]; then
4278 res=`flvr_cnt_mdt2ost $flavor`
4279 elif [ $dir == "all2ost" ]; then
4280 res1=`flvr_cnt_mdt2ost $flavor`
4281 res2=`flvr_cnt_cli2ost $flavor`
4282 res=$((res1 + res2))
4283 elif [ $dir == "all2mdt" ]; then
4284 res1=`flvr_cnt_mdt2mdt $flavor`
4285 res2=`flvr_cnt_cli2mdt $flavor`
4286 res=$((res1 + res2))
4287 elif [ $dir == "all2all" ]; then
4288 res1=`flvr_cnt_mdt2ost $flavor`
4289 res2=`flvr_cnt_cli2ost $flavor`
4290 res3=`flvr_cnt_mdt2mdt $flavor`
4291 res4=`flvr_cnt_cli2mdt $flavor`
4292 res=$((res1 + res2 + res3 + res4))
4300 local dir=$1 # from to
4301 local flavor=$2 # flavor expected
4302 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4306 for ((i=0;i<20;i++)); do
4307 echo -n "checking $dir..."
4308 res=$(do_check_flavor $dir $flavor)
4309 echo "found $res/$expect $flavor connections"
4310 [ $res -eq $expect ] && return 0
4314 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4318 restore_to_default_flavor()
4320 local proc="mgs.MGS.live.$FSNAME"
4322 echo "restoring to default flavor..."
4324 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4326 # remove all existing rules if any
4327 if [ $nrule -ne 0 ]; then
4328 echo "$nrule existing rules"
4329 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4330 echo "remove rule: $rule"
4331 spec=`echo $rule | awk -F = '{print $1}'`
4332 do_facet mgs "$LCTL conf_param -d $spec"
4336 # verify no rules left
4337 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4338 [ $nrule -ne 0 ] && error "still $nrule rules left"
4340 # wait for default flavor to be applied
4341 # currently default flavor for all connections are 'null'
4342 wait_flavor all2all null
4343 echo "now at default flavor settings"
4348 local flavor=${1:-null}
4350 echo "setting all flavor to $flavor"
4352 # FIXME need parameter to this fn
4353 # and remove global vars
4354 local cnt_all2all=$(calc_connection_cnt all2all)
4356 local res=$(do_check_flavor all2all $flavor)
4357 if [ $res -eq $cnt_all2all ]; then
4358 echo "already have total $res $flavor connections"
4362 echo "found $res $flavor out of total $cnt_all2all connections"
4363 restore_to_default_flavor
4365 [[ $flavor = null ]] && return 0
4367 set_rule $FSNAME any any $flavor
4368 wait_flavor all2all $flavor
4374 # Checking for shared logdir
4375 if [ ! -d $dir ]; then
4376 # Not found. Create local logdir
4379 touch $dir/node.$(hostname).yml
4384 check_write_access() {
4386 for node in $(nodes_list); do
4387 if [ ! -f "$dir/node.${node}.yml" ]; then
4388 # Logdir not accessible/writable from this node.
4396 if [[ -n $YAML_LOG ]]; then
4399 export YAML_LOG=${LOGDIR}/results.yml
4403 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4404 if check_write_access $LOGDIR; then
4405 touch $LOGDIR/shared
4406 echo "Logging to shared log directory: $LOGDIR"
4408 echo "Logging to local directory: $LOGDIR"
4411 yml_nodes_file $LOGDIR >> $YAML_LOG
4412 yml_results_file >> $YAML_LOG
4416 yml_log_test $1 >> $YAML_LOG
4420 yml_log_test_status $@ >> $YAML_LOG
4423 log_sub_test_begin() {
4424 yml_log_sub_test_begin "$@" >> $YAML_LOG
4427 log_sub_test_end() {
4428 yml_log_sub_test_end "$@" >> $YAML_LOG
4434 local devname=$(basename $1)
4435 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4436 # loop devices aren't in /proc/partitions
4437 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4439 size=$(($size / 1024 / 1024)) # Gb
4441 local partial_arg=""
4442 # Run in partial (fast) mode if the size
4443 # of a partition > 10 GB
4444 [ $size -gt 10 ] && partial_arg="-p"
4446 llverdev --force $partial_arg $dev
4449 remove_mdt_files() {
4454 local mntpt=${MOUNT%/*}/$facet
4456 echo "removing files from $mdtdev on $facet: $files"
4457 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4460 rm $mntpt/ROOT/$f || { rc=$?; break; }
4462 umount -f $mntpt || return $?
4466 duplicate_mdt_files() {
4471 local mntpt=${MOUNT%/*}/$facet
4473 echo "duplicating files on $mdtdev on $facet: $files"
4474 mkdir -p $mntpt || return $?
4475 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4485 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4486 pushd $mntpt/ROOT > /dev/null || return $?
4489 touch $f.bad || return $?
4490 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4492 [ $rc -eq 0 ] || return $rc
4493 setfattr --restore $tmp || return $?
4499 local devs=${1//,/ }
4502 local rslt=$TMP/sgpdd_survey
4504 # sgpdd-survey cleanups ${rslt}.* files
4506 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4512 # returns the canonical name for an ldiskfs device
4517 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4518 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4519 echo dm-\\\${foo##*:};
4521 echo \\\$(basename \\\$dv);
4525 is_sanity_benchmark() {
4526 local benchmarks="dbench bonnie iozone fsx"
4528 for b in $benchmarks; do
4529 if [ "$b" == "$suite" ]; then
4537 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1