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 # LOAD_LLOOP: LU-409: only load llite_lloop module if kernel < 2.6.32 or
20 # LOAD_LLOOP is true. LOAD_LLOOP is false by default.
21 export LOAD_LLOOP=${LOAD_LLOOP:-false}
23 #export PDSH="pdsh -S -Rssh -w"
25 # function used by scripts run on remote nodes
26 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
27 . $LUSTRE/tests/functions.sh
28 . $LUSTRE/tests/yaml.sh
30 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
32 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
34 if [ -f "$EXCEPT_LIST_FILE" ]; then
35 echo "Reading test skip list from $EXCEPT_LIST_FILE"
40 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
41 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
45 [[ $DIR/ = $MOUNT/* ]] || \
46 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
47 [[ $DIR1/ = $MOUNT1/* ]] || \
48 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
49 [[ $DIR2/ = $MOUNT2/* ]] || \
50 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
52 [ -n "$failed" ] && exit 99 || true
56 echo "usage: $0 [-r] [-f cfgfile]"
64 [ "$TESTSUITE" == "lfsck" ] && return 0
65 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
67 local form="%-13s %-17s %-9s %s %s\n"
68 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
69 echo "------------------------------------------------------------------------------------"
70 for O in $DEFAULT_SUITES; do
71 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
72 [ "${!O}" = "no" ] && continue || true
73 local o=$(echo $O | tr "[:upper:]_" "[:lower:]-")
74 local log=${TMP}/${o}.log
75 if is_sanity_benchmark $o; then
76 log=${TMP}/sanity-benchmark.log
81 local status=Unfinished
83 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
84 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | sort -nr -k 3 | head -5 | awk '{ print $2":"$3"s" }')
85 total=$(grep duration $log | awk '{ print $2}')
86 if [ "${!O}" = "done" ]; then
90 local durations=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g | awk '{ print $2":"$3"|" }')
91 details=$(printf "%s\n%s %s %s\n" "$details" "DDETAILS" "$O" "$(echo $durations)")
94 printf "$form" $status "$O" "${total}" "E=$skipped"
95 printf "$form" "-" "-" "-" "S=$(echo $slow)"
98 for O in $DEFAULT_SUITES; do
99 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
100 if [ "${!O}" = "no" ]; then
101 printf "$form" "Skipped" "$O" ""
105 # print the detailed tests durations if DDETAILS=true
112 export LUSTRE=`absolute_path $LUSTRE`
113 export TESTSUITE=`basename $0 .sh`
114 export TEST_FAILED=false
115 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
117 export MKE2FS=${MKE2FS:-mke2fs}
118 export DEBUGFS=${DEBUGFS:-debugfs}
119 export TUNE2FS=${TUNE2FS:-tune2fs}
120 export E2LABEL=${E2LABEL:-e2label}
121 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
122 export E2FSCK=${E2FSCK:-e2fsck}
123 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
125 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
126 export FSCK_MAX_ERR=4 # File system errors left uncorrected
127 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
128 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
129 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
131 #[ -d /r ] && export ROOT=${ROOT:-/r}
132 export TMP=${TMP:-$ROOT/tmp}
133 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
134 if [[ -z $LOGDIRSET ]]; then
135 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
136 export LOGDIRSET=true
138 export HOSTNAME=${HOSTNAME:-`hostname`}
139 if ! echo $PATH | grep -q $LUSTRE/utils; then
140 export PATH=$LUSTRE/utils:$PATH
142 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
143 export PATH=$LUSTRE/utils/gss:$PATH
145 if ! echo $PATH | grep -q $LUSTRE/tests; then
146 export PATH=$LUSTRE/tests:$PATH
148 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
149 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
151 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
152 [ ! -f "$LST" ] && export LST=$(which lst)
153 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
154 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
155 # Ubuntu, at least, has a truncate command in /usr/bin
156 # so fully path our truncate command.
157 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
158 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
159 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
160 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
161 export PATH=$LUSTRE/tests/racer:$PATH:
163 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
164 export PATH=$LUSTRE/tests/mpi:$PATH
166 export RSYNC_RSH=${RSYNC_RSH:-rsh}
167 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
168 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
169 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
170 [ ! -f "$LFS" ] && export LFS=$(which lfs)
171 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
172 if [ ! -f "$L_GETIDENTITY" ]; then
173 if `which l_getidentity > /dev/null 2>&1`; then
174 export L_GETIDENTITY=$(which l_getidentity)
176 export L_GETIDENTITY=NONE
179 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
180 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
181 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
182 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
183 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
184 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
185 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
186 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
187 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
188 export FSTYPE=${FSTYPE:-"ldiskfs"}
189 export NAME=${NAME:-local}
190 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
191 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
192 export LGSSD=$(which lgssd)
193 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
194 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
195 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
197 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
200 if [ "$ACCEPTOR_PORT" ]; then
201 export PORT_OPT="--port $ACCEPTOR_PORT"
206 echo "Using GSS/krb5 ptlrpc security flavor"
207 which lgss_keyring > /dev/null 2>&1 || \
208 error_exit "built with gss disabled! SEC=$SEC"
219 IDENTITY_UPCALL=false
222 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
224 # Paths on remote nodes, if different
225 export RLUSTRE=${RLUSTRE:-$LUSTRE}
226 export RPWD=${RPWD:-$PWD}
227 export I_MOUNTED=${I_MOUNTED:-"no"}
228 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
229 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
230 ! -f `dirname $0`/../mds/mds.ko ]; then
231 export CLIENTMODSONLY=yes
234 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
238 while getopts "rvwf:" opt $*; do
241 r) REFORMAT=--reformat;;
243 w) WRITECONF=writeconf;;
248 shift $((OPTIND - 1))
251 # print the durations of each test if "true"
252 DDETAILS=${DDETAILS:-false}
253 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
258 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
259 *) EXT=".ko"; USE_QUOTA=yes;;
264 /sbin/lsmod | grep -q "^\<$1\>"
267 # Load a module on the system where this is running.
269 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
271 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
272 # will be used as the arguments. Otherwise arguments will be obtained from
273 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
280 BASE=`basename $module $EXT`
282 module_loaded ${BASE} && return
284 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
286 if [ $# -eq 0 ]; then
287 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
288 # Bash until 4.x, so we resort to eval.
289 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
290 eval set -- \$$optvar
291 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
292 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
293 set -- $(grep -P "^options\\s+${BASE}" $MODPROBECONF)
294 # Get rid of "options $module"
295 (($# > 0)) && shift 2
297 # Ensure we have accept=all for lnet
298 if [ $(basename $module) = lnet ]; then
299 # OK, this is a bit wordy...
300 local arg accept_all_present=false
302 [ "$arg" = accept=all ] && accept_all_present=true
304 $accept_all_present || set -- "$@" accept=all
309 [ $# -gt 0 ] && echo "${module} options: '$*'"
311 # Note that insmod will ignore anything in modprobe.conf, which is why we're
312 # passing options on the command-line.
313 if [ "$BASE" == "lnet_selftest" ] && \
314 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
315 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
316 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
317 insmod ${LUSTRE}/${module}${EXT} "$@"
319 # must be testing a "make install" or "rpm" installation
320 # note failed to load ptlrpc_gss is considered not fatal
321 if [ "$BASE" == "ptlrpc_gss" ]; then
322 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
329 load_modules_local() {
330 if [ -n "$MODPROBE" ]; then
332 echo "Using modprobe to load modules"
336 echo Loading modules from $LUSTRE
337 load_module ../libcfs/libcfs/libcfs
338 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
339 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
340 load_module ../lnet/lnet/lnet
341 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
342 load_module ../lnet/klnds/$LNETLND
343 load_module lvfs/lvfs
344 load_module obdclass/obdclass
345 load_module ptlrpc/ptlrpc
346 load_module ptlrpc/gss/ptlrpc_gss
347 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
355 if ! client_only; then
356 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
357 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
358 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
359 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
364 load_module lvfs/fsfilt_$FSTYPE
366 load_module osd-ldiskfs/osd_ldiskfs
368 load_module obdfilter/obdfilter
371 load_module_llite_lloop() {
372 local n1=$(uname -r | cut -d. -f1)
373 local n2=$(uname -r | cut -d. -f2)
374 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
376 # load the llite_lloop module for < 2.6.32 kernels
377 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
378 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
380 load_module llite/llite_lloop
384 load_module llite/lustre
385 load_module_llite/llite_lloop
386 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
388 rm -f $OGDB/ogdb-$HOSTNAME
389 $LCTL modules > $OGDB/ogdb-$HOSTNAME
391 # 'mount' doesn't look in $PATH, just sbin
392 if [ -f $LUSTRE/utils/mount.lustre ] && \
393 ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
394 [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
395 mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
402 # load modules on remote nodes optionally
403 # lustre-tests have to be installed on these nodes
404 if $LOAD_MODULES_REMOTE ; then
405 local list=$(comma_list $(remote_nodes_list))
406 echo loading modules on $list
407 do_rpc_nodes $list load_modules
412 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
413 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
414 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
415 echo "$LEAK_LUSTRE" 1>&2
416 echo "$LEAK_PORTALS" 1>&2
417 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
418 echo "Memory leaks detected"
419 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
425 wait_exit_ST client # bug 12845
427 $LUSTRE_RMMOD $FSTYPE || return 2
429 if $LOAD_MODULES_REMOTE ; then
430 local list=$(comma_list $(remote_nodes_list))
431 if [ ! -z $list ]; then
432 echo unloading modules on $list
433 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
434 do_rpc_nodes $list check_mem_leak
438 if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
439 umount /sbin/mount.lustre || true
440 [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
441 rm -f /sbin/mount.lustre || true
444 check_mem_leak || return 254
446 echo "modules unloaded."
450 check_gss_daemon_nodes() {
454 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
455 if [ \\\"\\\$num\\\" -ne 1 ]; then
456 echo \\\$num instance of $dname;
461 check_gss_daemon_facet() {
465 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
466 if [ $num -ne 1 ]; then
467 echo "$num instance of $dname on $facet"
476 echo Stopping $@ on $list
477 do_nodes $list "killall -2 $@ 2>/dev/null || true"
480 # start gss daemons on all nodes, or
481 # "daemon" on "list" if set
482 start_gss_daemons() {
486 if [ "$list" ] && [ "$daemon" ] ; then
487 echo "Starting gss daemon on nodes: $list"
488 do_nodes $list "$daemon" || return 8
492 local list=$(comma_list $(mdts_nodes))
494 echo "Starting gss daemon on mds: $list"
495 do_nodes $list "$LSVCGSSD -v" || return 1
497 do_nodes $list "$LGSSD -v" || return 2
500 list=$(comma_list $(osts_nodes))
501 echo "Starting gss daemon on ost: $list"
502 do_nodes $list "$LSVCGSSD -v" || return 3
503 # starting on clients
505 local clients=${CLIENTS:-`hostname`}
507 echo "Starting $LGSSD on clients $clients "
508 do_nodes $clients "$LGSSD -v" || return 4
511 # wait daemons entering "stable" status
515 # check daemons are running
517 list=$(comma_list $(mdts_nodes) $(osts_nodes))
518 check_gss_daemon_nodes $list lsvcgssd || return 5
520 list=$(comma_list $(mdts_nodes))
521 check_gss_daemon_nodes $list lgssd || return 6
524 check_gss_daemon_nodes $clients lgssd || return 7
529 local list=$(comma_list $(mdts_nodes))
531 send_sigint $list lsvcgssd lgssd
533 list=$(comma_list $(osts_nodes))
534 send_sigint $list lsvcgssd
536 list=${CLIENTS:-`hostname`}
537 send_sigint $list lgssd
542 if ! module_loaded ptlrpc_gss; then
543 load_module ptlrpc/gss/ptlrpc_gss
544 module_loaded ptlrpc_gss ||
545 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
547 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
549 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
550 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
558 # maybe cleanup credential cache?
564 local device=`mdsdevname $num`
565 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
571 local device=`ostdevname $num`
572 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
578 local facets=${1:-$(get_facets)}
581 for facet in ${facets//,/ }; do
582 mount_facet $facet || error "Restart of $facet failed!"
589 local dev=$(facet_active $facet)_dev
590 local opt=${facet}_opt
591 local mntpt=$(facet_mntpt $facet)
593 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
594 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
596 if [ $RC -ne 0 ]; then
597 echo "mount -t lustre $@ ${!dev} $mntpt"
598 echo "Start of ${!dev} on ${facet} failed ${RC}"
600 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
601 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
602 lctl set_param debug_mb=${DEBUG_SIZE}; \
605 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
606 [ -z "$label" ] && echo no label for ${!dev} && exit 1
607 eval export ${facet}_svc=${label}
608 echo Started ${label}
613 # start facet device options
619 eval export ${facet}_dev=${device}
620 eval export ${facet}_opt=\"$@\"
622 local varname=${facet}failover_dev
623 if [ -n "${!varname}" ] ; then
624 eval export ${facet}failover_dev=${!varname}
626 eval export ${facet}failover_dev=$device
629 local mntpt=$(facet_mntpt $facet)
630 do_facet ${facet} mkdir -p $mntpt
631 eval export ${facet}_MOUNT=$mntpt
641 local HOST=`facet_active_host $facet`
642 [ -z $HOST ] && echo stop: no host for $facet && return 0
644 local mntpt=$(facet_mntpt $facet)
645 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
646 if [ ${running} -ne 0 ]; then
647 echo "Stopping $mntpt (opts:$@)"
648 do_facet ${facet} umount -d $@ $mntpt
651 # umount should block, but we should wait for unrelated obd's
652 # like the MGS or MGC to also stop.
653 wait_exit_ST ${facet}
656 # save quota version (both administrative and operational quotas)
657 # add an additional parameter if mountpoint is ever different from $MOUNT
658 quota_save_version() {
659 local fsname=${2:-$FSNAME}
661 local ver=$(tr -c -d "123" <<< $spec)
662 local type=$(tr -c -d "ug" <<< $spec)
664 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
666 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
668 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
670 local osts=$(get_facets OST)
671 for ost in ${osts//,/ }; do
673 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
677 # client could mount several lustre
679 local fsname=${1:-$FSNAME}
681 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
682 do_nodes $(comma_list $(osts_nodes)) \
683 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
687 restore_quota_type () {
688 local mntpt=${1:-$MOUNT}
689 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
690 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
693 quota_save_version $old_QUOTA_TYPE
699 # We need save the original quota_type params, and restore them after testing
701 # Suppose that quota type the same on mds and ost
702 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
703 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
704 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
705 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
706 export old_QUOTA_TYPE=$quota_type
707 quota_save_version $QUOTA_TYPE
709 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
710 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
713 local quota_usrs=$QUOTA_USERS
715 # get_filesystem_size
716 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
717 local blk_soft=$((disksz + 1024))
718 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
720 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
722 local i_hard=$((i_soft + i_soft / 20))
724 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
725 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
728 for usr in $quota_usrs; do
729 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
731 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
733 eval $cmd || error "$cmd FAILED!"
735 # display the quota status
736 echo "Quota settings for $usr : "
737 $LFS quota -v -u $usr $mntpt || true
744 local OPTIONS=${3:-$MOUNTOPT}
746 local device=$MGSNID:/$FSNAME
747 if [ -z "$mnt" -o -z "$FSNAME" ]; then
748 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
752 echo "Starting client: $client: $OPTIONS $device $mnt"
753 do_node $client mkdir -p $mnt
754 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
756 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
757 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
758 lctl set_param debug_mb=${DEBUG_SIZE}"
771 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
772 if [ $running -ne 0 ]; then
773 echo "Stopping client $client $mnt (opts:$force)"
774 do_node $client lsof -t $mnt || need_kill=no
775 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
776 pids=$(do_node $client lsof -t $mnt | sort -u);
777 if [ -n $pids ]; then
778 do_node $client kill -9 $pids || true
782 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
783 if [ $busy -ne 0 ] ; then
784 echo "$mnt is still busy, wait one second" && sleep 1
785 do_node $client umount $force $mnt
790 # nodes is comma list
791 sanity_mount_check_nodes () {
797 # FIXME: assume that all cluster nodes run the same os
798 [ "$(uname)" = Linux ] || return 0
801 for mnt in $mnts ; do
802 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
803 mpts=\\\$(mount | grep -w -c $mnt);
804 if [ \\\$running -ne \\\$mpts ]; then
805 echo \\\$(hostname) env are INSANE!;
813 sanity_mount_check_servers () {
815 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
816 echo Checking servers environments
818 # FIXME: modify get_facets to display all facets wo params
819 local facets="$(get_facets OST),$(get_facets MDS),mgs"
823 for facet in ${facets//,/ }; do
824 node=$(facet_host ${facet})
825 mntpt=$(facet_mntpt $facet)
826 sanity_mount_check_nodes $node $mntpt ||
827 { error "server $node environments are insane!"; return 1; }
831 sanity_mount_check_clients () {
832 local clients=${1:-$CLIENTS}
833 local mntpt=${2:-$MOUNT}
834 local mntpt2=${3:-$MOUNT2}
836 [ -z $clients ] && clients=$(hostname)
837 echo Checking clients $clients environments
839 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
840 error "clients environments are insane!"
843 sanity_mount_check () {
844 sanity_mount_check_servers || return 1
845 sanity_mount_check_clients || return 2
848 # mount clients if not mouted
849 zconf_mount_clients() {
852 local OPTIONS=${3:-$MOUNTOPT}
854 local device=$MGSNID:/$FSNAME
855 if [ -z "$mnt" -o -z "$FSNAME" ]; then
856 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
860 echo "Starting client $clients: $OPTIONS $device $mnt"
863 running=\\\$(mount | grep -c $mnt' ');
865 if [ \\\$running -eq 0 ] ; then
867 mount -t lustre $OPTIONS $device $mnt;
870 exit \\\$rc" || return ${PIPESTATUS[0]}
872 echo "Started clients $clients: "
873 do_nodes $clients "mount | grep -w $mnt"
875 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
876 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
877 lctl set_param debug_mb=${DEBUG_SIZE};"
882 zconf_umount_clients() {
889 echo "Stopping clients: $clients $mnt (opts:$force)"
890 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
891 if [ \\\$running -ne 0 ] ; then
892 echo Stopping client \\\$(hostname) $mnt opts:$force;
893 lsof -t $mnt || need_kill=no;
894 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
895 pids=\\\$(lsof -t $mnt | sort -u);
896 if [ -n \\\"\\\$pids\\\" ]; then
900 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
901 if [ \\\$busy -ne 0 ] ; then
902 echo "$mnt is still busy, wait one second" && sleep 1;
910 echo + $POWER_DOWN $node
914 shutdown_node_hard () {
916 local attempts=$SHUTDOWN_ATTEMPTS
918 for i in $(seq $attempts) ; do
921 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
922 echo "waiting for $host to fail attempts=$attempts"
923 [ $i -lt $attempts ] || \
924 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
930 local mnt=${2:-$MOUNT}
933 if [ "$FAILURE_MODE" = HARD ]; then
934 shutdown_node_hard $client
936 zconf_umount_clients $client $mnt -f
942 local facets="$(get_facets OST),$(get_facets MDS)"
945 combined_mgs_mds || facets="$facets,mgs"
947 for facet in ${facets//,/ }; do
948 if [ $(facet_active_host $facet) == $host ]; then
949 affected="$affected $facet"
953 echo $(comma_list $affected)
958 local host=${2:-$(facet_host $facet)}
960 local label=$(convert_facet2label $facet)
961 do_node $host lctl dl | awk '{print $4}' | grep -q $label
964 facets_up_on_host () {
966 local facets=$(facets_on_host $host)
969 for facet in ${facets//,/ }; do
970 if $(facet_up $facet $host); then
971 affected_up="$affected_up $facet"
975 echo $(comma_list $affected_up)
981 if [ "$FAILURE_MODE" = HARD ]; then
982 shutdown_node_hard $(facet_active_host $facet)
990 echo + $POWER_UP $node
1003 if [ "$FAILURE_MODE" = HARD ]; then
1004 reboot_node $(facet_active_host $facet)
1012 if [ "$FAILURE_MODE" = HARD ]; then
1022 for facet in ${facets//,/ }; do
1023 hosts=$(expand_list $hosts $(facet_host $facet) )
1029 _check_progs_installed () {
1033 for prog in $progs; do
1034 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1035 echo $prog missing on $(hostname)
1042 check_progs_installed () {
1046 do_rpc_nodes $nodes _check_progs_installed $@
1049 # recovery-scale functions
1051 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1054 start_client_load() {
1057 local var=$(node_var_name $client)_load
1058 eval export ${var}=$load
1060 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1061 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1062 END_RUN_FILE=$END_RUN_FILE \
1063 LOAD_PID_FILE=$LOAD_PID_FILE \
1064 TESTSUITELOG=$TESTSUITELOG \
1066 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1067 log "Started client load: ${load} on $client"
1072 start_client_loads () {
1073 local -a clients=(${1//,/ })
1074 local numloads=${#CLIENT_LOADS[@]}
1077 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1078 testnum=$((nodenum % numloads))
1079 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1081 # bug 22169: wait the background threads to start
1085 # only for remote client
1086 check_client_load () {
1088 local var=$(node_var_name $client)_load
1089 local TESTLOAD=run_${!var}.sh
1091 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1093 # bug 18914: try to connect several times not only when
1094 # check ps, but while check_catastrophe also
1097 while [ $RC = 254 -a $tries -gt 0 ]; do
1101 if ! check_catastrophe $client; then
1103 if [ $RC -eq 254 ]; then
1104 # FIXME: not sure how long we shuold sleep here
1108 echo "check catastrophe failed: RC=$RC "
1112 # We can continue try to connect if RC=254
1113 # Just print the warning about this
1114 if [ $RC = 254 ]; then
1115 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1118 # see if the load is still on the client
1121 while [ $RC = 254 -a $tries -gt 0 ]; do
1125 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1130 if [ $RC = 254 ]; then
1131 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1132 # see if we can diagnose a bit why this is
1137 check_client_loads () {
1138 local clients=${1//,/ }
1142 for client in $clients; do
1143 check_client_load $client
1145 if [ "$rc" != 0 ]; then
1146 log "Client load failed on node $client, rc=$rc"
1152 restart_client_loads () {
1153 local clients=${1//,/ }
1154 local expectedfail=${2:-""}
1158 for client in $clients; do
1159 check_client_load $client
1161 if [ "$rc" != 0 -a "$expectedfail" ]; then
1162 local var=$(node_var_name $client)_load
1163 start_client_load $client ${!var}
1164 echo "Restarted client load ${!var}: on $client. Checking ..."
1165 check_client_load $client
1167 if [ "$rc" != 0 ]; then
1168 log "Client load failed to restart on node $client, rc=$rc"
1169 # failure one client load means test fail
1170 # we do not need to check other
1178 # End recovery-scale functions
1180 # verify that lustre actually cleaned up properly
1182 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1183 error "LBUG/LASSERT detected"
1184 BUSY=`dmesg | grep -i destruct || true`
1185 if [ "$BUSY" ]; then
1187 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1191 check_mem_leak || exit 204
1193 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1194 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1196 if module_loaded lnet || module_loaded libcfs; then
1197 echo "$0: modules still loaded..." 1>&2
1214 RESULT=$(do_node $node "$TEST")
1215 if [ "$RESULT" == "$FINAL" ]; then
1216 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1219 [ $WAIT -ge $MAX ] && break
1220 echo "Waiting $((MAX - WAIT)) secs for update"
1221 WAIT=$((WAIT + sleep))
1224 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1228 wait_update_facet () {
1230 wait_update $(facet_active_host $facet) "$@"
1233 wait_delete_completed () {
1234 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1235 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1239 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1241 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1242 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1243 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1244 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1248 echo "Delete is not completed in $MAX_WAIT sec"
1255 # we can use "for" here because we are waiting the slowest
1256 for host in ${hostlist//,/ }; do
1257 check_network "$host" 900
1259 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1266 for facet in ${facetlist//,/ }; do
1267 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1269 wait_for_host $hostlist
1272 _wait_recovery_complete () {
1275 # Use default policy if $2 is not passed by caller.
1276 local MAX=${2:-$(max_recovery_time)}
1281 while [ $WAIT -lt $MAX ]; do
1282 STATUS=$(lctl get_param -n $param | grep status)
1284 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1287 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1289 echo "$param recovery not done in $MAX sec. $STATUS"
1293 wait_recovery_complete () {
1296 # with an assumption that at_max is the same on all nodes
1297 local MAX=${2:-$(max_recovery_time)}
1300 if [ "$FAILURE_MODE" = HARD ]; then
1301 facets=$(facets_on_host $(facet_active_host $facet))
1303 echo affected facets: $facets
1305 # we can use "for" here because we are waiting the slowest
1306 for facet in ${facets//,/ }; do
1307 local var_svc=${facet}_svc
1308 local param="*.${!var_svc}.recovery_status"
1310 local host=$(facet_active_host $facet)
1311 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1315 wait_mds_ost_sync () {
1316 # just because recovery is done doesn't mean we've finished
1317 # orphan cleanup. Wait for llogs to get synchronized.
1318 echo "Waiting for orphan cleanup..."
1319 # MAX value includes time needed for MDS-OST reconnection
1320 local MAX=$(( TIMEOUT * 2 ))
1322 while [ $WAIT -lt $MAX ]; do
1323 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1324 "$LCTL get_param -n obdfilter.*.mds_sync"))
1327 for ((i=0; i<${#sync[@]}; i++)); do
1328 [ ${sync[$i]} -eq 0 ] && continue
1329 # there is a not finished MDS-OST synchronization
1333 sleep 2 # increase waiting time and cover statfs cache
1334 [ ${con} -eq 1 ] && return 0
1335 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1338 echo "$facet recovery not done in $MAX sec. $STATUS"
1342 wait_destroy_complete () {
1343 echo "Waiting for destroy to be done..."
1344 # MAX value shouldn't be big as this mean server responsiveness
1345 # never increase this just to make test pass but investigate
1346 # why it takes so long time
1349 while [ $WAIT -lt $MAX ]; do
1350 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1352 for ((i=0; i<${#RPCs[@]}; i++)); do
1353 [ ${RPCs[$i]} -eq 0 ] && continue
1354 # there are still some destroy RPCs in flight
1359 [ ${con} -eq 1 ] && return 0 # done waiting
1360 echo "Waiting $WAIT secs for destroys to be done."
1363 echo "Destroys weren't done in $MAX sec."
1373 # conf-sanity 31 takes a long time cleanup
1374 while [ $WAIT -lt 300 ]; do
1375 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1376 [ -z "${running}" ] && return 0
1377 echo "waited $WAIT for${running}"
1378 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1380 WAIT=$((WAIT + INTERVAL))
1382 echo "service didn't stop after $WAIT seconds. Still running:"
1387 wait_remote_prog () {
1393 [ "$PDSH" = "no_dsh" ] && return 0
1395 while [ $WAIT -lt $2 ]; do
1396 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1397 [ -z "${running}" ] && return 0 || true
1398 echo "waited $WAIT for: "
1400 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1402 WAIT=$((WAIT + INTERVAL))
1404 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1405 [ -z "$pids" ] && return 0
1406 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1407 # FIXME: not portable
1408 for pid in $pids; do
1409 cat /proc/${pid}/status || true
1410 cat /proc/${pid}/wchan || true
1412 kill -9 $pid || true
1421 # not every config has many clients
1423 if [ ! -z "$CLIENTS" ]; then
1424 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1426 stat -f $MOUNT > /dev/null
1432 # usually checked on particular client or locally
1434 if [ ! -z "$client" ]; then
1435 $PDSH $client "stat -f $MOUNT" > /dev/null
1437 stat -f $MOUNT > /dev/null
1445 client_reconnect() {
1446 uname -n >> $MOUNT/recon
1447 if [ -z "$CLIENTS" ]; then
1448 df $MOUNT; uname -n >> $MOUNT/recon
1450 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1452 echo Connected clients:
1454 ls -l $MOUNT/recon > /dev/null
1458 affected_facets () {
1461 local host=$(facet_active_host $facet)
1462 local affected=$facet
1464 if [ "$FAILURE_MODE" = HARD ]; then
1465 affected=$(facets_up_on_host $host)
1473 local host=$(facet_active_host $facet)
1475 echo "Failing $facet on node $host"
1477 local affected=$(affected_facets $facet)
1479 shutdown_facet $facet
1481 echo affected facets: $affected
1483 [ -n "$sleep_time" ] && sleep $sleep_time
1487 change_active $affected
1489 wait_for_facet $affected
1490 # start mgs first if it is affected
1491 if ! combined_mgs_mds && list_member $affected mgs; then
1492 mount_facet mgs || error "Restart of mgs failed"
1494 # FIXME; has to be changed to mount all facets concurrently
1495 affected=$(exclude_items_from_list $affected mgs)
1496 mount_facets $affected
1505 do_facet $facet sync
1508 # make sure there will be no seq change
1509 local clients=${CLIENTS:-$HOSTNAME}
1510 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1512 local svc=${facet}_svc
1513 do_facet $facet $LCTL --device %${!svc} notransno
1514 do_facet $facet $LCTL --device %${!svc} readonly
1515 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1516 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1519 replay_barrier_nodf() {
1520 local facet=$1 echo running=${running}
1521 do_facet $facet sync
1522 local svc=${facet}_svc
1523 echo Replay barrier on ${!svc}
1524 do_facet $facet $LCTL --device %${!svc} notransno
1525 do_facet $facet $LCTL --device %${!svc} readonly
1526 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1527 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1530 replay_barrier_nosync() {
1531 local facet=$1 echo running=${running}
1532 local svc=${facet}_svc
1533 echo Replay barrier on ${!svc}
1534 do_facet $facet $LCTL --device %${!svc} notransno
1535 do_facet $facet $LCTL --device %${!svc} readonly
1536 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1537 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1540 mds_evict_client() {
1541 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1542 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1545 ost_evict_client() {
1546 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1547 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1551 facet_failover $* || error "failover: $?"
1552 clients_up || error "post-failover df: $?"
1557 facet_failover $facet
1563 change_active $facet
1564 mount_facet $facet -o abort_recovery
1565 clients_up || echo "first df failed: $?"
1566 clients_up || error "post-failover df: $?"
1570 echo There is no lmc. This is mountconf, baby.
1575 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1581 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1582 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1583 if [ -z "$ID" ]; then
1584 echo "Could not get a ptl id for $1..."
1593 h2name_or_ip "$1" "tcp"
1598 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1599 if type __h2elan >/dev/null 2>&1; then
1602 ID=`echo $1 | sed 's/[^0-9]*//g'`
1610 h2name_or_ip "$1" "o2ib"
1617 [ "$facet" == client ] && echo -n $HOSTNAME && return
1618 varname=${facet}_HOST
1619 if [ -z "${!varname}" ]; then
1620 if [ "${facet:0:3}" == "ost" ]; then
1621 eval ${facet}_HOST=${ost_HOST}
1629 local activevar=${facet}active
1631 if [ -f $TMP/${facet}active ] ; then
1632 source $TMP/${facet}active
1635 active=${!activevar}
1636 if [ -z "$active" ] ; then
1643 facet_active_host() {
1645 local active=`facet_active $facet`
1646 if [ "$facet" == client ]; then
1649 echo `facet_host $active`
1657 facetlist=$(exclude_items_from_list $facetlist mgs)
1659 for facet in ${facetlist//,/ }; do
1660 local failover=${facet}failover
1661 local host=`facet_host $failover`
1662 [ -z "$host" ] && return
1664 local curactive=`facet_active $facet`
1665 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1666 eval export ${facet}active=$facet
1668 eval export ${facet}active=$failover
1670 # save the active host for this facet
1671 local activevar=${facet}active
1672 echo "$activevar=${!activevar}" > $TMP/$activevar
1673 local TO=`facet_active_host $facet`
1674 echo "Failover $facet to $TO"
1680 # do not stripe off hostname if verbose, bug 19215
1681 if [ x$1 = x--verbose ]; then
1689 if [ "$HOST" = "$HOSTNAME" ]; then
1691 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1692 echo "cannot run remote command on $HOST with $myPDSH"
1696 echo "CMD: $HOST $@" >&2
1697 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1700 if [ "$myPDSH" = "rsh" ]; then
1701 # we need this because rsh does not return exit code of an executed command
1702 local command_status="$TMP/cs"
1703 rsh $HOST ":> $command_status"
1704 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1705 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1706 echo command failed >$command_status"
1707 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1712 # print HOSTNAME for myPDSH="no_dsh"
1713 if [[ $myPDSH = no_dsh ]]; then
1714 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1716 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1719 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1721 return ${PIPESTATUS[0]}
1725 do_node --verbose "$@"
1728 single_local_node () {
1729 [ "$1" = "$HOSTNAME" ]
1732 # Outputs environment variable assignments that should be passed to remote nodes
1737 for var in ${!MODOPTS_*}; do
1739 echo "${var}=\"$value\""
1745 # do not stripe off hostname if verbose, bug 19215
1746 if [ x$1 = x--verbose ]; then
1754 if single_local_node $rnodes; then
1756 do_nodev $rnodes "$@"
1758 do_node $rnodes "$@"
1763 # This is part from do_node
1766 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1767 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1770 echo "CMD: $rnodes $@" >&2
1771 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1774 # do not replace anything from pdsh output if -N is used
1775 # -N Disable hostname: prefix on lines of output.
1776 if $verbose || [[ $myPDSH = *-N* ]]; then
1777 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1779 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1781 return ${PIPESTATUS[0]}
1787 local HOST=`facet_active_host $facet`
1788 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1793 do_nodes --verbose "$@"
1799 # make sure its not already running
1801 rm -f $TMP/${facet}active
1802 do_facet ${facet} $MKFS $*
1808 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1809 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1816 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1817 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1823 local var=${facet}_MOUNT
1824 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1833 # make sure we are using the primary server, so test-framework will
1834 # be able to clean up properly.
1835 activemds=`facet_active mds1`
1836 if [ $activemds != "mds1" ]; then
1840 local clients=$CLIENTS
1841 [ -z $clients ] && clients=$(hostname)
1843 zconf_umount_clients $clients $MOUNT "$*" || true
1844 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1846 [ "$CLIENTONLY" ] && return
1847 # The add fn does rm ${facet}active file, this would be enough
1848 # if we use do_facet <facet> only after the facet added, but
1849 # currently we use do_facet mds in local.sh
1850 for num in `seq $MDSCOUNT`; do
1852 rm -f ${TMP}/mds${num}active
1855 for num in `seq $OSTCOUNT`; do
1857 rm -f $TMP/ost${num}active
1860 if ! combined_mgs_mds ; then
1867 cleanup_echo_devs () {
1868 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1870 for dev in $devs; do
1871 $LCTL --device $dev cleanup
1872 $LCTL --device $dev detach
1877 nfs_client_mode && return
1886 combined_mgs_mds () {
1887 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1893 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1894 local optvar=${tgt}_MKFS_OPTS
1895 local opt=${!optvar}
1897 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1898 [[ $facet = mgs ]] && echo $opt && return
1901 # --failnode options
1902 local var=${facet}failover_HOST
1903 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1904 local failnode=$(h2$NETTYPE ${!var})
1905 failnode="--failnode=$failnode"
1906 # options does not contain
1907 # or contains wrong --failnode=
1908 if [[ $opt != *${failnode}* ]]; then
1909 opt=$(echo $opt | sed 's/--failnode=.* / /')
1910 opt="$opt $failnode"
1916 # no additional mkfs mds "--mgsnode" option for this configuration
1917 if [[ $facet = mds ]] && combined_mgs_mds; then
1922 # additional mkfs "--mgsnode"
1923 local mgsnode="--mgsnode=$MGSNID"
1924 opt=${opt//$mgsnode }
1925 for nid in ${MGSNID//:/ }; do
1926 local mgsnode="--mgsnode=$nid"
1927 # options does not contain
1929 if [[ $opt != *${mgsnode}" "* ]]; then
1930 opt="$opt --mgsnode=$nid"
1938 if [ "$IAMDIR" == "yes" ]; then
1939 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1942 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1945 # We need ldiskfs here, may as well load them all
1947 [ "$CLIENTONLY" ] && return
1948 echo Formatting mgs, mds, osts
1949 if ! combined_mgs_mds ; then
1950 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1953 for num in `seq $MDSCOUNT`; do
1954 echo "Format mds$num: $(mdsdevname $num)"
1956 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
1958 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
1962 # the ost-s could have different OST_MKFS_OPTS
1963 # because of different failnode-s
1964 for num in `seq $OSTCOUNT`; do
1965 echo "Format ost$num: $(ostdevname $num)"
1967 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1969 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1975 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1979 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1983 # 0: success, the old identity set already.
1984 # 1: success, the old identity does not set.
1989 local j=`expr $num - 1`
1990 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1992 if [ -z "$MDT" ]; then
1996 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1999 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
2001 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
2004 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
2006 if [ $old = "NONE" ]; then
2015 zconf_umount `hostname` $1 || error "umount failed"
2016 zconf_mount `hostname` $1 || error "mount failed"
2019 writeconf_facet () {
2023 do_facet $facet "$TUNEFS --writeconf $dev"
2027 for num in `seq $MDSCOUNT`; do
2028 DEVNAME=$(mdsdevname $num)
2029 writeconf_facet mds$num $DEVNAME
2032 for num in `seq $OSTCOUNT`; do
2033 DEVNAME=$(ostdevname $num)
2034 writeconf_facet ost$num $DEVNAME
2039 nfs_client_mode && return
2041 sanity_mount_check ||
2042 error "environments are insane!"
2046 if [ -z "$CLIENTONLY" ]; then
2047 echo Setup mgs, mdt, osts
2048 echo $WRITECONF | grep -q "writeconf" && \
2050 if ! combined_mgs_mds ; then
2051 start mgs $MGSDEV $MGS_MOUNT_OPTS
2054 for num in `seq $MDSCOUNT`; do
2055 DEVNAME=$(mdsdevname $num)
2056 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2058 # We started mds, now we should set failover variables properly.
2059 # Set mds${num}failover_HOST if it is not set (the default failnode).
2060 local varname=mds${num}failover_HOST
2061 if [ -z "${!varname}" ]; then
2062 eval mds${num}failover_HOST=$(facet_host mds$num)
2065 if [ $IDENTITY_UPCALL != "default" ]; then
2066 switch_identity $num $IDENTITY_UPCALL
2069 for num in `seq $OSTCOUNT`; do
2070 DEVNAME=$(ostdevname $num)
2071 start ost$num $DEVNAME $OST_MOUNT_OPTS
2073 # We started ost$num, now we should set ost${num}failover variable properly.
2074 # Set ost${num}failover_HOST if it is not set (the default failnode).
2075 varname=ost${num}failover_HOST
2076 if [ -z "${!varname}" ]; then
2077 eval ost${num}failover_HOST=$(facet_host ost${num})
2085 # wait a while to allow sptlrpc configuration be propogated to targets,
2086 # only needed when mounting new target devices.
2091 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2093 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2095 if [ "$MOUNT_2" ]; then
2096 mount_client $MOUNT2
2097 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2102 # by remounting mdt before ost, initial connect from mdt to ost might
2103 # timeout because ost is not ready yet. wait some time to its fully
2104 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2105 # by a context negotiation rpc with $TIMEOUT.
2106 # FIXME better by monitoring import status.
2109 sleep $((TIMEOUT + 5))
2115 mounted_lustre_filesystems() {
2116 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2119 init_facet_vars () {
2120 [ "$CLIENTONLY" ] && return 0
2127 eval export ${facet}_dev=${device}
2128 eval export ${facet}_opt=\"$@\"
2130 local dev=${facet}_dev
2131 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2132 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2134 eval export ${facet}_svc=${label}
2136 local varname=${facet}failover_HOST
2137 if [ -z "${!varname}" ]; then
2138 eval $varname=$(facet_host $facet)
2141 # ${facet}failover_dev is set in cfg file
2142 varname=${facet}failover_dev
2143 if [ -n "${!varname}" ] ; then
2144 eval export ${facet}failover_dev=${!varname}
2146 eval export ${facet}failover_dev=$device
2149 # get mount point of already mounted device
2150 # is facet_dev is already mounted then use the real
2151 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2152 # i.e. ${facet}_MOUNT if specified by user or default
2153 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2154 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2155 if [ -z $mntpt ]; then
2156 mntpt=$(facet_mntpt $facet)
2158 eval export ${facet}_MOUNT=$mntpt
2161 init_facets_vars () {
2164 if ! remote_mds_nodsh; then
2165 for num in `seq $MDSCOUNT`; do
2166 DEVNAME=`mdsdevname $num`
2167 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2171 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2173 remote_ost_nodsh && return
2175 for num in `seq $OSTCOUNT`; do
2176 DEVNAME=`ostdevname $num`
2177 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2181 osc_ensure_active () {
2186 while [ $period -lt $timeout ]; do
2187 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2188 if [ $count -eq 0 ]; then
2192 echo "There are $count OST are inactive, wait $period seconds, and try again"
2194 period=$((period+3))
2197 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2200 init_param_vars () {
2201 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2202 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2203 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2204 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2208 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2210 log "Using TIMEOUT=$TIMEOUT"
2212 osc_ensure_active $SINGLEMDS $TIMEOUT
2213 osc_ensure_active client $TIMEOUT
2215 if [ $QUOTA_AUTO -ne 0 ]; then
2216 if [ "$ENABLE_QUOTA" ]; then
2217 echo "enable quota as required"
2218 setup_quota $MOUNT || return 2
2220 echo "disable quota as required"
2221 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2228 nfs_client_mode () {
2229 if [ "$NFSCLIENT" ]; then
2230 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2231 local clients=$CLIENTS
2232 [ -z $clients ] && clients=$(hostname)
2234 # FIXME: remove hostname when 19215 fixed
2235 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2236 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2237 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2238 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2240 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2246 check_config_client () {
2249 local mounted=$(mount | grep " $mntpt ")
2250 if [ "$CLIENTONLY" ]; then
2252 # CLIENTONLY should not depend on *_HOST settings
2253 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2254 # in theory someone could create a new,
2255 # client-only config file that assumed lustre was already
2256 # configured and didn't set the MGSNID. If MGSNID is not set,
2257 # then we should use the mgs nid currently being used
2258 # as the default value. bug 18021
2259 [[ x$MGSNID = x ]] &&
2262 if [[ x$mgc != xMGC$MGSNID ]]; then
2263 if [ "$mgs_HOST" ]; then
2264 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2265 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2266 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2272 local myMGS_host=$mgs_HOST
2273 if [ "$NETTYPE" = "ptl" ]; then
2274 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2277 echo Checking config lustre mounted on $mntpt
2278 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2279 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2281 # if [ "$mgshost" != "$myMGS_host" ]; then
2282 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2283 # Please use correct config or set mds_HOST correctly!"
2288 check_config_clients () {
2289 local clients=${CLIENTS:-$HOSTNAME}
2292 nfs_client_mode && return
2294 do_rpc_nodes $clients check_config_client $mntpt
2296 sanity_mount_check ||
2297 error "environments are insane!"
2301 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2302 local cltimeout=$(lctl get_param -n timeout)
2303 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2304 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2311 [ -z $mntpt ] && return 1
2312 local mounted=$(mounted_lustre_filesystems)
2314 echo $mounted' ' | grep -w -q $mntpt' '
2318 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2322 # empty lustre filesystem may have empty directories lost+found and .lustre
2324 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2325 -print | wc -l) = 1 ] || return 1
2326 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2327 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2331 check_and_setup_lustre() {
2332 nfs_client_mode && return
2334 local MOUNTED=$(mounted_lustre_filesystems)
2338 # both MOUNT and MOUNT2 are not mounted
2339 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2340 [ "$REFORMAT" ] && formatall
2341 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2343 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2344 export I_MOUNTED=yes
2348 elif is_mounted $MOUNT2; then
2350 # MOUNT2 is mounted, while MOUNT_2 is not set
2351 if ! [ "$MOUNT_2" ]; then
2352 cleanup_mount $MOUNT2
2353 export I_UMOUNTED2=yes
2356 # MOUNT2 is mounted, MOUNT_2 is set
2358 # FIXME: what to do if check_config failed?
2360 # 1) remote client has mounted other Lustre fs ?
2361 # 2) it has insane env ?
2362 # let's try umount MOUNT2 on all clients and mount it again:
2363 if ! check_config_clients $MOUNT2; then
2364 cleanup_mount $MOUNT2
2365 restore_mount $MOUNT2
2366 export I_MOUNTED2=yes
2371 # MOUNT is mounted MOUNT2 is not mounted
2372 elif [ "$MOUNT_2" ]; then
2373 restore_mount $MOUNT2
2374 export I_MOUNTED2=yes
2378 # FIXME: what to do if check_config failed?
2380 # 1) remote client has mounted other Lustre fs?
2381 # 2) lustre is mounted on remote_clients atall ?
2382 check_config_clients $MOUNT
2386 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2387 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2388 lctl set_param debug_mb=${DEBUG_SIZE};
2395 if [ "$ONLY" == "setup" ]; then
2401 local clients=${CLIENTS:-$HOSTNAME}
2404 zconf_mount_clients $clients $mntpt
2408 local clients=${CLIENTS:-$HOSTNAME}
2411 zconf_umount_clients $clients $mntpt
2414 cleanup_and_setup_lustre() {
2415 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2416 lctl set_param debug=0 || true
2418 if [ "$ONLY" == "cleanup" ]; then
2422 check_and_setup_lustre
2425 # Get all of the server target devices from a given server node and type.
2434 mdt) obd_type="osd" ;;
2435 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2436 *) echo "invalid server type" && return 1 ;;
2439 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2440 for dev in $devs; do
2442 *loop*) do_node $node "losetup $dev" | \
2443 sed -e "s/.*(//" -e "s/).*//" ;;
2449 # Get all of the server target devices.
2454 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2458 for node in $(osts_nodes); do
2459 OSTDEVS[i]=$(get_mnt_devs $node ost)
2464 # Run e2fsck on MDT or OST device.
2470 df > /dev/null # update statfs data on disk
2471 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2474 do_node $node $cmd || rc=$?
2475 [ $rc -le $FSCK_MAX_ERR ] || \
2476 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2480 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2487 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2488 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2489 error "fail to create file in $SHARED_DIRECTORY")
2491 # make sure everything gets to the backing store
2492 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2493 do_nodes $list "sync; sleep 2; sync"
2495 do_nodes $list ls $tmp_file || \
2496 error "$SHARED_DIRECTORY is not a shared directory"
2499 run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
2504 for node in $(osts_nodes); do
2505 for dev in ${OSTDEVS[i]}; do
2506 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
2507 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2508 ostidx=$((ostidx + 1))
2515 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2519 [ $rc -le $FSCK_MAX_ERR ] || \
2520 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2521 echo "lfsck finished with rc=$rc"
2523 rm -rvf $MDSDB* $OSTDB* || true
2527 check_and_cleanup_lustre() {
2528 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
2534 if is_mounted $MOUNT; then
2535 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2536 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2539 if [ "$I_UMOUNTED2" = "yes" ]; then
2540 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2543 if [ "$I_MOUNTED2" = "yes" ]; then
2544 cleanup_mount $MOUNT2
2547 if [ "$I_MOUNTED" = "yes" ]; then
2548 cleanupall -f || error "cleanup failed"
2556 wait_for_function () {
2559 # suppress fn both stderr and stdout
2560 if [ "$1" = "--quiet" ]; then
2562 quiet=" > /dev/null 2>&1"
2574 eval $fn $quiet && return 0
2576 wait=$((wait + sleep))
2577 [ $wait -lt $max ] || return 1
2578 echo waiting $fn, $((max - wait)) secs left ...
2588 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2589 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2590 echo "Network not available!"
2594 echo `date +"%H:%M:%S (%s)"` network interface is UP
2603 # the sed converts spaces to commas, but leaves the last space
2604 # alone, so the line doesn't end with a comma.
2605 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2611 echo $list | grep -qw $item
2614 # list, excluded are the comma separated lists
2615 exclude_items_from_list () {
2621 for item in ${excluded//,/ }; do
2622 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2624 echo $(comma_list $list)
2627 # list, expand are the comma separated lists
2629 local list=${1//,/ }
2630 local expand=${2//,/ }
2633 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2634 echo $(comma_list $expanded)
2637 testslist_filter () {
2638 local script=$LUSTRE/tests/${TESTSUITE}.sh
2640 [ -f $script ] || return 0
2642 local start_at=$START_AT
2643 local stop_at=$STOP_AT
2645 local var=${TESTSUITE//-/_}_START_AT
2646 [ x"${!var}" != x ] && start_at=${!var}
2647 var=${TESTSUITE//-/_}_STOP_AT
2648 [ x"${!var}" != x ] && stop_at=${!var}
2650 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2651 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2652 /^'${start_at}'$/ {flag = 0}
2653 {if (flag == 1) print $0}
2654 /^'${stop_at}'$/ { flag = 1 }'
2658 (cd `dirname $1`; echo $PWD/`basename $1`)
2662 local types=${1:-"OST MDS MGS"}
2666 for entry in $types; do
2667 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2668 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2671 MGS ) list="$list $name";;
2672 MDS|OST ) local count=${type}COUNT
2673 for ((i=1; i<=${!count}; i++)) do
2674 list="$list ${name}$i"
2676 * ) error "Invalid facet type"
2680 echo $(comma_list $list)
2683 ##################################
2684 # Adaptive Timeouts funcs
2687 # only check mds, we assume at_max is the same on all nodes
2688 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2689 if [ $at_max -eq 0 ]; then
2699 # suppose that all ost-s has the same at_max set
2700 if [ $facet == "ost" ]; then
2701 do_facet ost1 "lctl get_param -n at_max"
2703 do_facet $facet "lctl get_param -n at_max"
2713 if [ $facet == "ost" ]; then
2714 for i in `seq $OSTCOUNT`; do
2715 do_facet ost$i "lctl set_param at_max=$at_max"
2718 elif [ $facet == "mds" ]; then
2719 for i in `seq $MDSCOUNT`; do
2720 do_facet mds$i "lctl set_param at_max=$at_max"
2723 do_facet $facet "lctl set_param at_max=$at_max"
2728 ##################################
2732 # OBD_FAIL_MDS_ALL_REQUEST_NET
2734 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2735 do_facet client "$1" || RC=$?
2736 do_facet $SINGLEMDS lctl set_param fail_loc=0
2741 # OBD_FAIL_MDS_ALL_REPLY_NET
2743 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2744 do_facet client "$@" || RC=$?
2745 do_facet $SINGLEMDS lctl set_param fail_loc=0
2749 drop_reint_reply() {
2750 # OBD_FAIL_MDS_REINT_NET_REP
2752 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2753 do_facet client "$@" || RC=$?
2754 do_facet $SINGLEMDS lctl set_param fail_loc=0
2759 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2761 do_facet ost1 lctl set_param fail_loc=0x214
2762 do_facet client "$1" || RC=$?
2763 do_facet client "sync"
2764 do_facet ost1 lctl set_param fail_loc=0
2768 drop_ldlm_cancel() {
2769 #define OBD_FAIL_LDLM_CANCEL 0x304
2771 do_facet client lctl set_param fail_loc=0x304
2772 do_facet client "$@" || RC=$?
2773 do_facet client lctl set_param fail_loc=0
2777 drop_bl_callback() {
2778 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2780 do_facet client lctl set_param fail_loc=0x305
2781 do_facet client "$@" || RC=$?
2782 do_facet client lctl set_param fail_loc=0
2787 #define OBD_FAIL_LDLM_REPLY 0x30c
2789 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2790 do_facet client "$@" || RC=$?
2791 do_facet $SINGLEMDS lctl set_param fail_loc=0
2799 echo "clearing fail_loc on $facet"
2800 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2803 set_nodes_failloc () {
2804 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2807 cancel_lru_locks() {
2808 $LCTL mark "cancel_lru_locks $1 start"
2809 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2810 $LCTL set_param -n $d=clear
2812 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2813 $LCTL mark "cancel_lru_locks $1 stop"
2818 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2819 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2820 echo "$DEFAULT_LRU_SIZE"
2825 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2828 lru_resize_disable()
2830 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2835 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2836 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2837 echo there is still data in page cache $FILE ?
2838 lctl get_param -n $FILE
2846 DEBUGSAVE="$(lctl get_param -n debug)"
2850 [ -n "$DEBUGSAVE" ] && \
2851 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2856 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2859 debug_size_restore() {
2860 [ -n "$DEBUG_SIZE_SAVED" ] && \
2861 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2865 start_full_debug_logging() {
2870 local DEBUG_SIZE=150
2872 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2873 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2876 stop_full_debug_logging() {
2881 ##################################
2883 ##################################
2886 local TYPE=${TYPE:-"FAIL"}
2889 # do not dump logs if $1=false
2890 if [ "x$1" = "xfalse" ]; then
2895 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2897 # We need to dump the logs on all nodes
2899 gather_logs $(comma_list $(nodes_list))
2903 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2904 echo "$@" > $LOGDIR/err
2909 local log=$TESTSUITELOG
2911 [ -f "$log" ] && grep -q FAIL: $log && status=1
2924 # use only if we are ignoring failures for this test, bugno required.
2925 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2926 # e.g. error_ignore 5494 "your message"
2928 local TYPE="IGNORE (bz$1)"
2934 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2939 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2940 [ "$ALWAYS_SKIPPED" ] && \
2941 skip_logged ${TESTNAME} "$@" || true
2942 [ "$TESTSUITELOG" ] && \
2943 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2946 build_test_filter() {
2947 EXCEPT="$EXCEPT $(testslist_filter)"
2949 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2953 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2954 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2955 [ "$EXCEPT_SLOW" ] && \
2956 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2957 for E in $EXCEPT; do
2958 eval EXCEPT_${E}=true
2960 for E in $ALWAYS_EXCEPT; do
2961 eval EXCEPT_ALWAYS_${E}=true
2963 for E in $EXCEPT_SLOW; do
2964 eval EXCEPT_SLOW_${E}=true
2966 for G in $GRANT_CHECK_LIST; do
2967 eval GCHECK_ONLY_${G}=true
2972 if [[ $1 = [a-z]* ]]; then
2979 # print a newline if the last test was skipped
2980 export LAST_SKIPPED=
2981 export ALWAYS_SKIPPED=
2983 # Main entry into test-framework. This is called with the name and
2984 # description of a test. The name is used to find the function to run
2985 # the test using "test_$name".
2987 # This supports a variety of methods of specifying specific test to
2988 # run or not run. These need to be documented...
2993 export base=`basetest $1`
2994 if [ ! -z "$ONLY" ]; then
2996 if [ ${!testname}x != x ]; then
2997 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2998 run_one_logged $1 "$2"
3002 if [ ${!testname}x != x ]; then
3003 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3004 run_one_logged $1 "$2"
3012 if [ ${!testname}x != x ]; then
3014 TESTNAME=test_$1 skip "skipping excluded test $1"
3017 testname=EXCEPT_$base
3018 if [ ${!testname}x != x ]; then
3020 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3023 testname=EXCEPT_ALWAYS_$1
3024 if [ ${!testname}x != x ]; then
3027 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3030 testname=EXCEPT_ALWAYS_$base
3031 if [ ${!testname}x != x ]; then
3034 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3037 testname=EXCEPT_SLOW_$1
3038 if [ ${!testname}x != x ]; then
3040 TESTNAME=test_$1 skip "skipping SLOW test $1"
3043 testname=EXCEPT_SLOW_$base
3044 if [ ${!testname}x != x ]; then
3046 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3052 run_one_logged $1 "$2"
3063 module_loaded lnet || load_modules
3075 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3080 strace -o $TMP/$1.strace -ttt $*
3082 log "FINISHED: $*: rc $RC"
3087 equals_msg $1 test complete, duration $2 sec
3088 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3089 echo duration $2 >>$TESTSUITELOG
3093 # Set TEST_STATUS here; will be used for logging the result
3094 if [ -f $LOGDIR/err ]; then
3099 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3103 local FFREE=$(do_node $SINGLEMDS \
3104 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3105 local FTOTAL=$(do_node $SINGLEMDS \
3106 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3108 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3112 echo -n "Resetting fail_loc on all nodes..."
3113 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3119 # Log a message (on all nodes) padded with "=" before and after.
3120 # Also appends a timestamp and prepends the testsuite name.
3123 EQUALS="===================================================================================================="
3125 msg="== ${TESTSUITE} $*"
3127 [[ $last != "=" && $last != " " ]] && msg="$msg "
3128 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3129 # always include at least == after the message
3130 log "$msg== $(date +"%H:%M:%S (%s)")"
3134 # Run a single test function and cleanup after it.
3136 # This function should be run in a subshell so the test func can
3137 # exit() without stopping the whole script.
3143 export tdir=d0.${TESTSUITE}/d${base}
3144 export TESTNAME=test_$testnum
3145 local SAVE_UMASK=`umask`
3148 banner "test $testnum: $message"
3149 test_${testnum} || error "test_$testnum failed with $?"
3152 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3153 check_catastrophe || error "LBUG/LASSERT detected"
3154 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3162 # Wrapper around run_one to ensure:
3163 # - test runs in subshell
3164 # - output of test is saved to separate log file for error reporting
3165 # - test result is saved to data file
3168 local BEFORE=`date +%s`
3170 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
3171 local test_log=$LOGDIR/$name
3175 log_sub_test_begin test_${1}
3176 (run_one $1 "$2") 2>&1 | tee $test_log
3177 local RC=${PIPESTATUS[0]}
3179 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3180 echo "test_$1 returned $RC" | tee $LOGDIR/err
3182 duration=$((`date +%s` - $BEFORE))
3183 pass "$1" "(${duration}s)"
3184 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3185 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3187 if [ -f $LOGDIR/err ]; then
3188 $FAIL_ON_ERROR && exit $RC
3195 # Print information of skipped tests to result.yml
3198 log_sub_test_begin $1
3199 log_sub_test_end "SKIP" "0" "0" "\"$2\""
3203 (cd `dirname $1`; echo $PWD/`basename $1`)
3208 export base=`basetest $1`
3209 [ "$CHECK_GRANT" == "no" ] && return 0
3211 testname=GCHECK_ONLY_${base}
3212 [ ${!testname}x == x ] && return 0
3214 echo -n "checking grant......"
3216 local clients=$CLIENTS
3217 [ -z $clients ] && clients=$(hostname)
3219 # sync all the data and make sure no pending data on server
3220 do_nodes $clients sync
3223 client_grant=`do_nodes $clients \
3224 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3225 awk '{total += $1} END{print total}'`
3228 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3229 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3230 awk '{total += $1} END{print total}'`
3232 # check whether client grant == server grant
3233 if [ $client_grant -ne $server_grant ]; then
3234 echo "failed: client:${client_grant} server: ${server_grant}."
3235 do_nodes $(comma_list $(osts_nodes)) \
3236 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3237 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3240 echo "pass: client:${client_grant} server: ${server_grant}"
3245 ########################
3251 ost=`echo $1 | awk -F_ '{print $3}'`
3252 if [ -z $ost ]; then
3253 ost=`echo $1 | sed 's/-osc.*//'`
3258 ostuuid_from_index()
3260 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
3265 [ "$node" != "$(hostname)" ]
3271 for node in $(mdts_nodes); do
3272 remote_node $node && return 0
3279 [ "$CLIENTONLY" ] && return 0 || true
3280 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3285 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3286 MSKIPPED=1 && return 1
3293 for node in $(osts_nodes) ; do
3294 remote_node $node && return 0
3301 [ "$CLIENTONLY" ] && return 0 || true
3302 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3307 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3308 OSKIPPED=1 && return 1
3315 MGS=$(facet_host mgs)
3316 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3321 remote_mds_nodsh || remote_ost_nodsh || \
3322 $(single_local_node $(comma_list $(nodes_list)))
3328 for num in `seq $MDSCOUNT`; do
3329 MDSNODES="$MDSNODES $(facet_host mds$num)"
3331 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3337 remote_ost && remote_mds
3345 for facet in ${facets//,/ }; do
3346 if [ "$FAILURE_MODE" = HARD ]; then
3347 nodes="$nodes $(facet_active_host $facet)"
3349 nodes="$nodes $(facet_host $facet)"
3352 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3358 local facets=$(get_facets OST)
3359 local nodes=$(facets_nodes $facets)
3365 # FIXME. We need a list of clients
3366 local myNODES=$HOSTNAME
3369 # CLIENTS (if specified) contains the local client
3370 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3372 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3373 myNODES="$myNODES $(facets_nodes $(get_facets))"
3376 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3381 remote_nodes_list () {
3382 local rnodes=$(nodes_list)
3383 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3387 init_clients_lists () {
3388 # Sanity check: exclude the local client from RCLIENTS
3389 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3391 # Sanity check: exclude the dup entries
3392 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3394 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3396 # Sanity check: exclude the dup entries from CLIENTS
3397 # for those configs which has SINGLCLIENT set to local client
3398 clients=$(for i in $clients; do echo $i; done | sort -u)
3400 CLIENTS=`comma_list $clients`
3401 local -a remoteclients=($rclients)
3402 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3403 varname=CLIENT$((i + 2))
3404 eval $varname=${remoteclients[i]}
3407 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3410 get_random_entry () {
3413 rnodes=${rnodes//,/ }
3415 local -a nodes=($rnodes)
3416 local num=${#nodes[@]}
3417 local i=$((RANDOM * num * 2 / 65536))
3423 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3428 lctl get_param version | grep -q patchless
3432 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3437 echo $nodes | wc -w || true
3441 local nodes=$(osts_nodes)
3442 local osscount=$(get_node_count "$nodes")
3443 [ ! "$OSTCOUNT" = "$osscount" ]
3447 local nodes=$(mdts_nodes)
3448 local mdtcount=$(get_node_count "$nodes")
3449 [ ! "$MDSCOUNT" = "$mdtcount" ]
3452 generate_machine_file() {
3453 local nodes=${1//,/ }
3454 local machinefile=$2
3456 for node in $nodes; do
3457 echo $node >>$machinefile || \
3458 { echo "can not generate machinefile $machinefile" && return 1; }
3463 local file=$1/stripe
3465 $LFS getstripe -v $file || error
3469 setstripe_nfsserver () {
3472 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3473 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3475 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3477 do_nodev $nfsserver lfs setstripe "$@"
3480 check_runas_id_ret() {
3482 local myRUNAS_UID=$1
3483 local myRUNAS_GID=$2
3486 if [ -z "$myRUNAS" ]; then
3487 error_exit "myRUNAS command must be specified for check_runas_id"
3490 $myRUNAS krb5_login.sh || \
3491 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3493 mkdir $DIR/d0_runas_test
3495 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3496 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3497 rm -rf $DIR/d0_runas_test
3502 local myRUNAS_UID=$1
3503 local myRUNAS_GID=$2
3506 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3507 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3508 Please set RUNAS_ID to some UID which exists on MDS and client or
3509 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3512 # obtain the UID/GID for MPI_USER
3516 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3517 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3519 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3520 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3523 # obtain and cache Kerberos ticket-granting ticket
3524 refresh_krb5_tgt() {
3525 local myRUNAS_UID=$1
3526 local myRUNAS_GID=$2
3529 if [ -z "$myRUNAS" ]; then
3530 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3533 CLIENTS=${CLIENTS:-$HOSTNAME}
3534 do_nodes $CLIENTS "set -x
3535 if ! $myRUNAS krb5_login.sh; then
3536 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3541 # Run multiop in the background, but wait for it to print
3542 # "PAUSING" to its stdout before returning from this function.
3543 multiop_bg_pause() {
3544 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3548 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3551 echo "$MULTIOP_PROG $FILE v$ARGS"
3552 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3554 echo "TMPPIPE=${TMPPIPE}"
3555 read -t 60 multiop_output < $TMPPIPE
3556 if [ $? -ne 0 ]; then
3561 if [ "$multiop_output" != "PAUSING" ]; then
3562 echo "Incorrect multiop output: $multiop_output"
3577 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3583 inodes_available () {
3584 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3588 mdsrate_inodes_available () {
3589 echo $(($(inodes_available) - 1))
3592 # reset llite stat counters
3593 clear_llite_stats(){
3594 lctl set_param -n llite.*.stats 0
3597 # sum llite stat items
3598 calc_llite_stats() {
3599 local res=$(lctl get_param -n llite.*.stats |
3600 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3604 # reset osc stat counters
3606 lctl set_param -n osc.*.osc_stats 0
3609 # sum osc stat items
3611 local res=$(lctl get_param -n osc.*.osc_stats |
3612 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3617 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3620 calc_osc_kbytes () {
3621 df $MOUNT > /dev/null
3622 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3625 # save_lustre_params(node, parameter_mask)
3626 # generate a stream of formatted strings (<node> <param name>=<param value>)
3627 save_lustre_params() {
3629 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3632 # restore lustre parameters from input stream, produces by save_lustre_params
3633 restore_lustre_params() {
3637 while IFS=" =" read node name val; do
3638 do_node ${node//:/} "lctl set_param -n $name $val"
3642 check_catastrophe() {
3643 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3644 local C=$CATASTROPHE
3645 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3647 if [ $rnodes ]; then
3648 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3649 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3665 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3667 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3668 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3669 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3673 # CMD: determine mds index where directory inode presents
3676 local file=$dir/f0.get_mds_dir_tmpfile
3681 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3682 local -a oldused=($iused)
3684 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3686 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3687 local -a newused=($iused)
3690 for ((i=0; i<${#newused[@]}; i++)); do
3691 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3697 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3700 mdsrate_cleanup () {
3702 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3707 delayed_recovery_enabled () {
3708 local var=${SINGLEMDS}_svc
3709 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3712 ########################
3714 convert_facet2label() {
3717 if [ x$facet = xost ]; then
3721 local varsvc=${facet}_svc
3723 if [ -n ${!varsvc} ]; then
3726 error "No lablel for $facet!"
3730 get_clientosc_proc_path() {
3736 get_lustre_version () {
3737 local facet=${1:-"$SINGLEMDS"}
3738 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3741 get_mds_version_major () {
3742 local facet=${1:-"$SINGLEMDS"}
3743 local version=$(get_lustre_version $facet)
3744 echo $version | awk -F. '{print $1}'
3747 get_mds_version_minor () {
3748 local facet=${1:-"$SINGLEMDS"}
3749 local version=$(get_lustre_version $facet)
3750 echo $version | awk -F. '{print $2}'
3753 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3754 # used by MDT would not be changed.
3755 # mdt lov: fsname-mdtlov
3756 # mdt osc: fsname-OSTXXXX-osc
3757 mds_on_old_device() {
3758 local mds=${1:-"$SINGLEMDS"}
3759 local major=$(get_mds_version_major $mds)
3760 local minor=$(get_mds_version_minor $mds)
3762 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3763 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3764 > /dev/null 2>&1" && return 0
3769 get_mdtosc_proc_path() {
3771 local ost_label=${2:-"*OST*"}
3773 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3774 local mdt_label=$(convert_facet2label $mds_facet)
3775 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3777 local major=$(get_mds_version_major $mds_facet)
3778 local minor=$(get_mds_version_minor $mds_facet)
3779 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3780 echo "${ost_label}-osc"
3782 echo "${ost_label}-osc-${mdt_index}"
3786 get_osc_import_name() {
3789 local label=$(convert_facet2label $ost)
3791 if [ "${facet:0:3}" = "mds" ]; then
3792 get_mdtosc_proc_path $facet $label
3796 get_clientosc_proc_path $label
3800 _wait_import_state () {
3803 local maxtime=${3:-max_recovery_time}
3807 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3808 while [ "${CONN_STATE}" != "${expected}" ]; do
3809 [ $i -ge $maxtime ] && \
3810 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3813 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3817 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3821 wait_import_state() {
3824 local maxtime=${3:-max_recovery_time}
3827 for param in ${params//,/ }; do
3828 _wait_import_state $state $param $maxtime || return
3831 wait_osc_import_state() {
3835 local ost=$(get_osc_import_name $facet $ost_facet)
3840 CONN_PROC="osc.${ost}.ost_server_uuid"
3841 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3842 while [ "${CONN_STATE}" != "${expected}" ]; do
3843 if [ "${expected}" == "DISCONN" ]; then
3844 # for disconn we can check after proc entry is removed
3845 [ "x${CONN_STATE}" == "x" ] && return 0
3846 # with AT we can have connect request timeout ~ reconnect timeout
3847 # and test can't see real disconnect
3848 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3850 # disconnect rpc should be wait not more obd_timeout
3851 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3852 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3854 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3858 log "${ost_facet} now in ${CONN_STATE} state"
3861 get_clientmdc_proc_path() {
3869 # Add paths to lustre tests for 32 and 64 bit systems.
3870 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3871 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3874 wait_clients_import_state () {
3881 if [ "$FAILURE_MODE" = HARD ]; then
3882 facets=$(facets_on_host $(facet_active_host $facet))
3885 for facet in ${facets//,/ }; do
3886 local label=$(convert_facet2label $facet)
3889 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3890 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3891 *) error "unknown facet!" ;;
3893 local params=$(expand_list $params $proc_path)
3896 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3897 error "import is not in ${expected} state"
3906 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3907 $LCTL get_param obdfilter.*.kbytesavail))
3908 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3909 $LCTL get_param -n obdfilter.*.tot_granted))
3910 for ((i=0; i<${#AVAILA[@]}; i++)); do
3911 local -a AVAIL1=(${AVAILA[$i]//=/ })
3912 GRANT=$((${GRANTA[$i]}/1024))
3913 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3914 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3920 do_facet mgs lctl pool_list $1
3924 local fsname=${1%%.*}
3925 local poolname=${1##$fsname.}
3927 do_facet mgs lctl pool_new $1
3929 # get param should return err unless pool is created
3930 [[ $RC -ne 0 ]] && return $RC
3932 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3933 2>/dev/null || echo foo" "" || RC=1
3934 if [[ $RC -eq 0 ]]; then
3937 error "pool_new failed $1"
3942 add_pool_to_list () {
3943 local fsname=${1%%.*}
3944 local poolname=${1##$fsname.}
3946 local listvar=${fsname}_CREATED_POOLS
3947 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3950 remove_pool_from_list () {
3951 local fsname=${1%%.*}
3952 local poolname=${1##$fsname.}
3954 local listvar=${fsname}_CREATED_POOLS
3955 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3958 destroy_pool_int() {
3960 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3961 awk '$1 !~ /^Pool:/ {print $1}')
3962 for ost in $OSTS; do
3963 do_facet mgs lctl pool_remove $1 $ost
3965 do_facet mgs lctl pool_destroy $1
3968 # <fsname>.<poolname> or <poolname>
3970 local fsname=${1%%.*}
3971 local poolname=${1##$fsname.}
3973 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3977 pool_list $fsname.$poolname || return $?
3979 destroy_pool_int $fsname.$poolname
3981 [[ $RC -ne 0 ]] && return $RC
3983 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3984 2>/dev/null || echo foo" "foo" || RC=1
3986 if [[ $RC -eq 0 ]]; then
3987 remove_pool_from_list $fsname.$poolname
3989 error "destroy pool failed $1"
3995 local fsname=${1:-$FSNAME}
3997 local listvar=${fsname}_CREATED_POOLS
4001 [ x${!listvar} = x ] && return 0
4003 echo destroy the created pools: ${!listvar}
4004 for poolname in ${!listvar//,/ }; do
4005 destroy_pool $fsname.$poolname
4010 local fsname=${1:-$FSNAME}
4012 destroy_pools $fsname
4018 local ts=$(date +%s)
4020 [ -f $LOGDIR/shared ] && docp=false
4022 # dump lustre logs, dmesg
4024 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4026 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4028 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4029 echo "Dumping logs only on local client."
4030 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
4031 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
4036 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
4037 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
4038 if [ ! -f $LOGDIR/shared ]; then
4039 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4042 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
4043 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
4049 local list=${1:-$(comma_list $(nodes_list))}
4051 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
4063 for i in $(seq 0 $num_mntpts); do
4064 cmd="ls -laf ${mntpt_root}$i/$dir"
4070 for pid in $pids; do
4077 # target_start_and_reset_recovery_timer()
4078 # service_time = at_est2timeout(service_time);
4079 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4080 # INITIAL_CONNECT_TIMEOUT);
4081 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4082 #define CONNECTION_SWITCH_INC 1
4083 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4084 #define CONNECTION_SWITCH_MIN 5U
4086 max_recovery_time () {
4087 local init_connect_timeout=$(( TIMEOUT / 20 ))
4088 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
4090 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4095 get_clients_mount_count () {
4096 local clients=${CLIENTS:-`hostname`}
4098 # we need to take into account the clients mounts and
4099 # exclude mds/ost mounts if any;
4100 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4104 PROC_CLI="srpc_info"
4112 if [ $M -lt $N ]; then
4116 while [ $N -lt $M ]; do
4126 calc_connection_cnt() {
4129 # MDT->MDT = 2 * C(M, 2)
4133 comb_m2=$(combination $MDSCOUNT 2)
4135 local num_clients=$(get_clients_mount_count)
4137 local cnt_mdt2mdt=$((comb_m2 * 2))
4138 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4139 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4140 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4141 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4142 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4143 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4157 local cmd="$tgt.srpc.flavor"
4159 if [ $net == "any" ]; then
4164 if [ $dir != "any" ]; then
4169 log "Setting sptlrpc rule: $cmd"
4170 do_facet mgs "$LCTL conf_param $cmd"
4179 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4180 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4182 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4184 if [ "x$bulkspec" != "x" ]; then
4185 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4187 if [ "x$algs" != "x" ]; then
4188 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4190 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4191 if [ $bulk == "bulkn" ]; then
4192 bulk_count=`echo "$output" | grep "bulk flavor" \
4193 | grep "null/null" | wc -l`
4194 elif [ $bulk == "bulki" ]; then
4195 bulk_count=`echo "$output" | grep "bulk flavor" \
4196 | grep "/null" | grep -v "null/" | wc -l`
4198 bulk_count=`echo "$output" | grep "bulk flavor" \
4199 | grep -v "/null" | grep -v "null/" | wc -l`
4203 [ $bulk_count -lt $count ] && count=$bulk_count
4214 local clients=${CLIENTS:-`hostname`}
4216 for c in ${clients//,/ }; do
4217 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4218 tmpcnt=`count_flvr "$output" $flavor`
4219 cnt=$((cnt + tmpcnt))
4229 local clients=${CLIENTS:-`hostname`}
4231 for c in ${clients//,/ }; do
4232 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4233 tmpcnt=`count_flvr "$output" $flavor`
4234 cnt=$((cnt + tmpcnt))
4244 if [ $MDSCOUNT -le 1 ]; then
4249 for num in `seq $MDSCOUNT`; do
4250 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4251 tmpcnt=`count_flvr "$output" $flavor`
4252 cnt=$((cnt + tmpcnt))
4263 for num in `seq $MDSCOUNT`; do
4264 mdtosc=$(get_mdtosc_proc_path mds$num)
4265 mdtosc=${mdtosc/-MDT*/-MDT\*}
4266 output=$(do_facet mds$num lctl get_param -n \
4267 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4268 tmpcnt=`count_flvr "$output" $flavor`
4269 cnt=$((cnt + tmpcnt))
4278 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4279 count_flvr "$output" $flavor
4284 local dir=$1 # from to
4285 local flavor=$2 # flavor expected
4288 if [ $dir == "cli2mdt" ]; then
4289 res=`flvr_cnt_cli2mdt $flavor`
4290 elif [ $dir == "cli2ost" ]; then
4291 res=`flvr_cnt_cli2ost $flavor`
4292 elif [ $dir == "mdt2mdt" ]; then
4293 res=`flvr_cnt_mdt2mdt $flavor`
4294 elif [ $dir == "mdt2ost" ]; then
4295 res=`flvr_cnt_mdt2ost $flavor`
4296 elif [ $dir == "all2ost" ]; then
4297 res1=`flvr_cnt_mdt2ost $flavor`
4298 res2=`flvr_cnt_cli2ost $flavor`
4299 res=$((res1 + res2))
4300 elif [ $dir == "all2mdt" ]; then
4301 res1=`flvr_cnt_mdt2mdt $flavor`
4302 res2=`flvr_cnt_cli2mdt $flavor`
4303 res=$((res1 + res2))
4304 elif [ $dir == "all2all" ]; then
4305 res1=`flvr_cnt_mdt2ost $flavor`
4306 res2=`flvr_cnt_cli2ost $flavor`
4307 res3=`flvr_cnt_mdt2mdt $flavor`
4308 res4=`flvr_cnt_cli2mdt $flavor`
4309 res=$((res1 + res2 + res3 + res4))
4317 local dir=$1 # from to
4318 local flavor=$2 # flavor expected
4319 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4323 for ((i=0;i<20;i++)); do
4324 echo -n "checking $dir..."
4325 res=$(do_check_flavor $dir $flavor)
4326 echo "found $res/$expect $flavor connections"
4327 [ $res -eq $expect ] && return 0
4331 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4335 restore_to_default_flavor()
4337 local proc="mgs.MGS.live.$FSNAME"
4339 echo "restoring to default flavor..."
4341 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4343 # remove all existing rules if any
4344 if [ $nrule -ne 0 ]; then
4345 echo "$nrule existing rules"
4346 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4347 echo "remove rule: $rule"
4348 spec=`echo $rule | awk -F = '{print $1}'`
4349 do_facet mgs "$LCTL conf_param -d $spec"
4353 # verify no rules left
4354 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4355 [ $nrule -ne 0 ] && error "still $nrule rules left"
4357 # wait for default flavor to be applied
4358 # currently default flavor for all connections are 'null'
4359 wait_flavor all2all null
4360 echo "now at default flavor settings"
4365 local flavor=${1:-null}
4367 echo "setting all flavor to $flavor"
4369 # FIXME need parameter to this fn
4370 # and remove global vars
4371 local cnt_all2all=$(calc_connection_cnt all2all)
4373 local res=$(do_check_flavor all2all $flavor)
4374 if [ $res -eq $cnt_all2all ]; then
4375 echo "already have total $res $flavor connections"
4379 echo "found $res $flavor out of total $cnt_all2all connections"
4380 restore_to_default_flavor
4382 [[ $flavor = null ]] && return 0
4384 set_rule $FSNAME any any $flavor
4385 wait_flavor all2all $flavor
4391 # Checking for shared logdir
4392 if [ ! -d $dir ]; then
4393 # Not found. Create local logdir
4396 touch $dir/node.$(hostname).yml
4401 check_write_access() {
4403 for node in $(nodes_list); do
4404 if [ ! -f "$dir/node.${node}.yml" ]; then
4405 # Logdir not accessible/writable from this node.
4413 if [[ -n $YAML_LOG ]]; then
4416 export YAML_LOG=${LOGDIR}/results.yml
4420 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4421 if check_write_access $LOGDIR; then
4422 touch $LOGDIR/shared
4423 echo "Logging to shared log directory: $LOGDIR"
4425 echo "Logging to local directory: $LOGDIR"
4428 yml_nodes_file $LOGDIR >> $YAML_LOG
4429 yml_results_file >> $YAML_LOG
4433 yml_log_test $1 >> $YAML_LOG
4437 yml_log_test_status $@ >> $YAML_LOG
4440 log_sub_test_begin() {
4441 yml_log_sub_test_begin "$@" >> $YAML_LOG
4444 log_sub_test_end() {
4445 yml_log_sub_test_end "$@" >> $YAML_LOG
4451 local devname=$(basename $1)
4452 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4453 # loop devices aren't in /proc/partitions
4454 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4456 size=$(($size / 1024 / 1024)) # Gb
4458 local partial_arg=""
4459 # Run in partial (fast) mode if the size
4460 # of a partition > 10 GB
4461 [ $size -gt 10 ] && partial_arg="-p"
4463 llverdev --force $partial_arg $dev
4466 remove_mdt_files() {
4471 local mntpt=${MOUNT%/*}/$facet
4473 echo "removing files from $mdtdev on $facet: $files"
4474 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4477 rm $mntpt/ROOT/$f || { rc=$?; break; }
4479 umount -f $mntpt || return $?
4483 duplicate_mdt_files() {
4488 local mntpt=${MOUNT%/*}/$facet
4490 echo "duplicating files on $mdtdev on $facet: $files"
4491 mkdir -p $mntpt || return $?
4492 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4502 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4503 pushd $mntpt/ROOT > /dev/null || return $?
4506 touch $f.bad || return $?
4507 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4509 [ $rc -eq 0 ] || return $rc
4510 setfattr --restore $tmp || return $?
4516 local devs=${1//,/ }
4519 local rslt=$TMP/sgpdd_survey
4521 # sgpdd-survey cleanups ${rslt}.* files
4523 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4529 # returns the canonical name for an ldiskfs device
4534 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4535 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4536 echo dm-\\\${foo##*:};
4538 echo \\\$(basename \\\$dv);
4542 is_sanity_benchmark() {
4543 local benchmarks="dbench bonnie iozone fsx"
4545 for b in $benchmarks; do
4546 if [ "$b" == "$suite" ]; then
4554 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1