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
128 #[ -d /r ] && export ROOT=${ROOT:-/r}
129 export TMP=${TMP:-$ROOT/tmp}
130 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
131 export LOGDIR=${LOGDIR:-${TMP}/test_logs/$(date +%s)}
132 export TESTLOG_PREFIX=$LOGDIR/$TESTSUITE
134 export HOSTNAME=${HOSTNAME:-$(hostname -s)}
135 if ! echo $PATH | grep -q $LUSTRE/utils; then
136 export PATH=$LUSTRE/utils:$PATH
138 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
139 export PATH=$LUSTRE/utils/gss:$PATH
141 if ! echo $PATH | grep -q $LUSTRE/tests; then
142 export PATH=$LUSTRE/tests:$PATH
144 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
145 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
147 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
148 [ ! -f "$LST" ] && export LST=$(which lst)
149 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
150 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
151 # Ubuntu, at least, has a truncate command in /usr/bin
152 # so fully path our truncate command.
153 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
154 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
155 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
156 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
157 export PATH=$LUSTRE/tests/racer:$PATH:
159 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
160 export PATH=$LUSTRE/tests/mpi:$PATH
162 export RSYNC_RSH=${RSYNC_RSH:-rsh}
163 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
164 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
165 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
166 [ ! -f "$LFS" ] && export LFS=$(which lfs)
167 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
168 if [ ! -f "$L_GETIDENTITY" ]; then
169 if `which l_getidentity > /dev/null 2>&1`; then
170 export L_GETIDENTITY=$(which l_getidentity)
172 export L_GETIDENTITY=NONE
175 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
176 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
177 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
178 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
179 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
180 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
181 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
182 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
183 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
184 export FSTYPE=${FSTYPE:-"ldiskfs"}
185 export NAME=${NAME:-local}
186 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
187 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
188 export LGSSD=$(which lgssd)
189 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
190 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
191 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
193 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
196 if [ "$ACCEPTOR_PORT" ]; then
197 export PORT_OPT="--port $ACCEPTOR_PORT"
202 echo "Using GSS/krb5 ptlrpc security flavor"
203 which lgss_keyring > /dev/null 2>&1 || \
204 error_exit "built with gss disabled! SEC=$SEC"
215 IDENTITY_UPCALL=false
218 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
220 # Paths on remote nodes, if different
221 export RLUSTRE=${RLUSTRE:-$LUSTRE}
222 export RPWD=${RPWD:-$PWD}
223 export I_MOUNTED=${I_MOUNTED:-"no"}
224 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
225 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
226 ! -f `dirname $0`/../mds/mds.ko ]; then
227 export CLIENTMODSONLY=yes
230 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
234 while getopts "rvwf:" opt $*; do
237 r) REFORMAT=--reformat;;
239 w) WRITECONF=writeconf;;
244 shift $((OPTIND - 1))
247 # print the durations of each test if "true"
248 DDETAILS=${DDETAILS:-false}
249 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
254 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
255 *) EXT=".ko"; USE_QUOTA=yes;;
260 /sbin/lsmod | grep -q "^\<$1\>"
263 # Load a module on the system where this is running.
265 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
267 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
268 # will be used as the arguments. Otherwise arguments will be obtained from
269 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
276 BASE=`basename $module $EXT`
278 module_loaded ${BASE} && return
280 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
282 if [ $# -eq 0 ]; then
283 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
284 # Bash until 4.x, so we resort to eval.
285 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
286 eval set -- \$$optvar
287 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
288 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
289 set -- $(grep -P "^options\\s+${BASE}" $MODPROBECONF)
290 # Get rid of "options $module"
291 (($# > 0)) && shift 2
293 # Ensure we have accept=all for lnet
294 if [ $(basename $module) = lnet ]; then
295 # OK, this is a bit wordy...
296 local arg accept_all_present=false
298 [ "$arg" = accept=all ] && accept_all_present=true
300 $accept_all_present || set -- "$@" accept=all
305 [ $# -gt 0 ] && echo "${module} options: '$*'"
307 # Note that insmod will ignore anything in modprobe.conf, which is why we're
308 # passing options on the command-line.
309 if [ "$BASE" == "lnet_selftest" ] && \
310 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
311 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
312 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
313 insmod ${LUSTRE}/${module}${EXT} "$@"
315 # must be testing a "make install" or "rpm" installation
316 # note failed to load ptlrpc_gss is considered not fatal
317 if [ "$BASE" == "ptlrpc_gss" ]; then
318 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
325 llite_lloop_enabled() {
326 local n1=$(uname -r | cut -d. -f1)
327 local n2=$(uname -r | cut -d. -f2)
328 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
330 # load the llite_lloop module for < 2.6.32 kernels
331 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
332 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
339 load_modules_local() {
340 if [ -n "$MODPROBE" ]; then
342 echo "Using modprobe to load modules"
346 echo Loading modules from $LUSTRE
347 load_module ../libcfs/libcfs/libcfs
348 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
349 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
350 load_module ../lnet/lnet/lnet
351 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
352 load_module ../lnet/klnds/$LNETLND
353 load_module lvfs/lvfs
354 load_module obdclass/obdclass
355 load_module ptlrpc/ptlrpc
356 load_module ptlrpc/gss/ptlrpc_gss
357 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
365 if ! client_only; then
366 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
367 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
368 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
369 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
374 load_module lvfs/fsfilt_$FSTYPE
376 load_module osd-ldiskfs/osd_ldiskfs
378 load_module obdfilter/obdfilter
382 load_module llite/lustre
383 llite_lloop_enabled && load_module llite/llite_lloop
384 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
386 rm -f $OGDB/ogdb-$HOSTNAME
387 $LCTL modules > $OGDB/ogdb-$HOSTNAME
389 # 'mount' doesn't look in $PATH, just sbin
390 if [ -f $LUSTRE/utils/mount.lustre ] && \
391 ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
392 [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
393 mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
400 # load modules on remote nodes optionally
401 # lustre-tests have to be installed on these nodes
402 if $LOAD_MODULES_REMOTE ; then
403 local list=$(comma_list $(remote_nodes_list))
404 echo loading modules on $list
405 do_rpc_nodes $list load_modules
410 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
411 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
412 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
413 echo "$LEAK_LUSTRE" 1>&2
414 echo "$LEAK_PORTALS" 1>&2
415 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
416 echo "Memory leaks detected"
417 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
423 wait_exit_ST client # bug 12845
425 $LUSTRE_RMMOD $FSTYPE || return 2
427 if $LOAD_MODULES_REMOTE ; then
428 local list=$(comma_list $(remote_nodes_list))
429 if [ ! -z $list ]; then
430 echo unloading modules on $list
431 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
432 do_rpc_nodes $list check_mem_leak
436 if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
437 umount /sbin/mount.lustre || true
438 [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
439 rm -f /sbin/mount.lustre || true
442 check_mem_leak || return 254
444 echo "modules unloaded."
448 check_gss_daemon_nodes() {
452 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
453 if [ \\\"\\\$num\\\" -ne 1 ]; then
454 echo \\\$num instance of $dname;
459 check_gss_daemon_facet() {
463 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
464 if [ $num -ne 1 ]; then
465 echo "$num instance of $dname on $facet"
474 echo Stopping $@ on $list
475 do_nodes $list "killall -2 $@ 2>/dev/null || true"
478 # start gss daemons on all nodes, or
479 # "daemon" on "list" if set
480 start_gss_daemons() {
484 if [ "$list" ] && [ "$daemon" ] ; then
485 echo "Starting gss daemon on nodes: $list"
486 do_nodes $list "$daemon" || return 8
490 local list=$(comma_list $(mdts_nodes))
492 echo "Starting gss daemon on mds: $list"
493 do_nodes $list "$LSVCGSSD -v" || return 1
495 do_nodes $list "$LGSSD -v" || return 2
498 list=$(comma_list $(osts_nodes))
499 echo "Starting gss daemon on ost: $list"
500 do_nodes $list "$LSVCGSSD -v" || return 3
501 # starting on clients
503 local clients=${CLIENTS:-`hostname`}
505 echo "Starting $LGSSD on clients $clients "
506 do_nodes $clients "$LGSSD -v" || return 4
509 # wait daemons entering "stable" status
513 # check daemons are running
515 list=$(comma_list $(mdts_nodes) $(osts_nodes))
516 check_gss_daemon_nodes $list lsvcgssd || return 5
518 list=$(comma_list $(mdts_nodes))
519 check_gss_daemon_nodes $list lgssd || return 6
522 check_gss_daemon_nodes $clients lgssd || return 7
527 local list=$(comma_list $(mdts_nodes))
529 send_sigint $list lsvcgssd lgssd
531 list=$(comma_list $(osts_nodes))
532 send_sigint $list lsvcgssd
534 list=${CLIENTS:-`hostname`}
535 send_sigint $list lgssd
540 if ! module_loaded ptlrpc_gss; then
541 load_module ptlrpc/gss/ptlrpc_gss
542 module_loaded ptlrpc_gss ||
543 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
545 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
547 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
548 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
556 # maybe cleanup credential cache?
562 local device=`mdsdevname $num`
563 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
569 local device=`ostdevname $num`
570 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
575 # This and set_obdfilter_param() shall be used to access OSD parameters
576 # once existed under "obdfilter":
581 # writethrough_cache_enable
583 get_obdfilter_param() {
585 local device=${2:-$FSNAME-OST*}
588 do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
589 osd-*.$device.$name 2>&1" | grep -v 'Found no match'
592 set_obdfilter_param() {
594 local device=${2:-$FSNAME-OST*}
598 do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
599 osd-*.$device.$name=$value 2>&1" | grep -v 'Found no match'
603 local dz=${1:-$DEBUG_SIZE}
605 if [ -f /sys/devices/system/cpu/possible ]; then
606 local cpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/possible)+1))
608 local cpus=$(getconf _NPROCESSORS_CONF)
611 # bug 19944, adjust size to be -gt num_possible_cpus()
612 # promise 2MB for every cpu at least
613 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
616 lctl set_param debug_mb=$dz
619 set_default_debug () {
620 local debug=${1:-"$PTLDEBUG"}
621 local subsystem_debug=${2:-"$SUBSYSTEM"}
622 local debug_size=${3:-$DEBUG_SIZE}
624 lctl set_param debug="$debug"
625 lctl set_param subsystem_debug="${subsystem_debug# }"
627 set_debug_size $debug_size
631 set_default_debug_nodes () {
634 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
635 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
639 [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
640 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
643 set_default_debug_facet () {
645 local node=$(facet_active_host $facet)
646 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
648 set_default_debug_nodes $node
653 local facets=${1:-$(get_facets)}
656 for facet in ${facets//,/ }; do
657 mount_facet $facet || error "Restart of $facet failed!"
664 local dev=$(facet_active $facet)_dev
665 local opt=${facet}_opt
666 local mntpt=$(facet_mntpt $facet)
668 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
669 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
671 if [ $RC -ne 0 ]; then
672 echo "mount -t lustre $@ ${!dev} $mntpt"
673 echo "Start of ${!dev} on ${facet} failed ${RC}"
675 set_default_debug_facet $facet
677 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
678 [ -z "$label" ] && echo no label for ${!dev} && exit 1
679 eval export ${facet}_svc=${label}
680 echo Started ${label}
685 # start facet device options
691 eval export ${facet}_dev=${device}
692 eval export ${facet}_opt=\"$@\"
694 local varname=${facet}failover_dev
695 if [ -n "${!varname}" ] ; then
696 eval export ${facet}failover_dev=${!varname}
698 eval export ${facet}failover_dev=$device
701 local mntpt=$(facet_mntpt $facet)
702 do_facet ${facet} mkdir -p $mntpt
703 eval export ${facet}_MOUNT=$mntpt
713 local HOST=`facet_active_host $facet`
714 [ -z $HOST ] && echo stop: no host for $facet && return 0
716 local mntpt=$(facet_mntpt $facet)
717 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
718 if [ ${running} -ne 0 ]; then
719 echo "Stopping $mntpt (opts:$@)"
720 do_facet ${facet} umount -d $@ $mntpt
723 # umount should block, but we should wait for unrelated obd's
724 # like the MGS or MGC to also stop.
725 wait_exit_ST ${facet}
729 # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
730 eval set -- $(tr "[:punct:]" " " <<< $*)
732 echo -n $((($1 << 16) | ($2 << 8) | $3))
735 get_lustre_version() {
736 local facet=${1:-"$SINGLEMDS"}
737 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
740 lustre_version_code() {
741 local facet=${1:-"$SINGLEMDS"}
742 version_code $(get_lustre_version $1)
745 # save quota version (both administrative and operational quotas)
746 # add an additional parameter if mountpoint is ever different from $MOUNT
748 # XXX This function is kept for interoperability with old server (< 2.3.50),
749 # it should be removed whenever we drop the interoperability for such
751 quota_save_version() {
752 local fsname=${2:-$FSNAME}
754 local ver=$(tr -c -d "123" <<< $spec)
755 local type=$(tr -c -d "ug" <<< $spec)
757 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
759 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
761 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
763 local osts=$(get_facets OST)
764 for ost in ${osts//,/ }; do
766 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
770 # client could mount several lustre
772 # XXX This function is kept for interoperability with old server (< 2.3.50),
773 # it should be removed whenever we drop the interoperability for such
776 local fsname=${1:-$FSNAME}
778 do_facet $SINGLEMDS lctl get_param mdd.${fsname}-MDT*.quota_type ||
780 do_nodes $(comma_list $(osts_nodes)) \
781 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
785 # XXX This function is kept for interoperability with old server (< 2.3.50),
786 # it should be removed whenever we drop the interoperability for such
788 restore_quota_old() {
789 local mntpt=${1:-$MOUNT}
790 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
791 if [ ! "$old_QUOTA_TYPE" ] ||
792 [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
795 quota_save_version $old_QUOTA_TYPE
798 # XXX This function is kept for interoperability with old server (< 2.3.50),
799 # it should be removed whenever we drop the interoperability for such
804 # We need save the original quota_type params, and restore them after testing
806 # Suppose that quota type the same on mds and ost
807 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
808 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
809 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
810 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
811 export old_QUOTA_TYPE=$quota_type
812 quota_save_version $QUOTA_TYPE
814 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
815 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
818 local quota_usrs=$QUOTA_USERS
820 # get_filesystem_size
821 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
822 local blk_soft=$((disksz + 1024))
823 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
825 local Inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
827 local i_hard=$((i_soft + i_soft / 20))
829 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
830 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
833 for usr in $quota_usrs; do
834 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
836 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
838 eval $cmd || error "$cmd FAILED!"
840 # display the quota status
841 echo "Quota settings for $usr : "
842 $LFS quota -v -u $usr $mntpt || true
848 local varsvc=${SINGLEMDS}_svc
849 do_facet $SINGLEMDS $LCTL get_param -n \
850 osd-$FSTYPE.${!varsvc}.quota_slave.enabled
855 # All OSTs should have same quota type
856 local varsvc=ost1_svc
857 do_facet ost1 $LCTL get_param -n \
858 osd-$FSTYPE.${!varsvc}.quota_slave.enabled
861 # restore old quota type settings
863 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
868 if [ "$old_MDT_QUOTA_TYPE" ]; then
869 do_facet mgs $LCTL conf_param \
870 $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
872 if [ "$old_OST_QUOTA_TYPE" ]; then
873 do_facet mgs $LCTL conf_param \
874 $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
878 # Handle the case when there is a space in the lfs df
879 # "filesystem summary" line the same as when there is no space.
880 # This will allow fixing the "lfs df" summary line in the future.
882 $LFS df $* | sed -e 's/filesystem /filesystem_/'
886 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
893 # save old quota type & set new quota type
894 local mdt_qtype=$(mdt_quota_type)
895 local ost_qtype=$(ost_quota_type)
897 echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
898 "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
900 export old_MDT_QUOTA_TYPE=$mdt_qtype
901 export old_OST_QUOTA_TYPE=$ost_qtype
903 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$QUOTA_TYPE ||
904 error "set mdt quota type failed"
905 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$QUOTA_TYPE ||
906 error "set ost quota type failed"
908 local quota_usrs=$QUOTA_USERS
910 # get_filesystem_size
911 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
912 local blk_soft=$((disksz + 1024))
913 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
915 local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
917 local i_hard=$((i_soft + i_soft / 20))
919 echo "Total disk size: $disksz block-softlimit: $blk_soft" \
920 "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
921 "inode-hardlimit: $i_hard"
924 for usr in $quota_usrs; do
925 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
927 cmd="$LFS setquota -$type $usr -b $blk_soft"
928 cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
930 eval $cmd || error "$cmd FAILED!"
932 # display the quota status
933 echo "Quota settings for $usr : "
934 $LFS quota -v -u $usr $mntpt || true
941 local OPTIONS=${3:-$MOUNTOPT}
943 local device=$MGSNID:/$FSNAME
944 if [ -z "$mnt" -o -z "$FSNAME" ]; then
945 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
949 echo "Starting client: $client: $OPTIONS $device $mnt"
950 do_node $client mkdir -p $mnt
951 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
953 set_default_debug_nodes $client
966 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
967 if [ $running -ne 0 ]; then
968 echo "Stopping client $client $mnt (opts:$force)"
969 do_node $client lsof -t $mnt || need_kill=no
970 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
971 pids=$(do_node $client lsof -t $mnt | sort -u);
972 if [ -n $pids ]; then
973 do_node $client kill -9 $pids || true
977 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
978 if [ $busy -ne 0 ] ; then
979 echo "$mnt is still busy, wait one second" && sleep 1
980 do_node $client umount $force $mnt
985 # nodes is comma list
986 sanity_mount_check_nodes () {
992 # FIXME: assume that all cluster nodes run the same os
993 [ "$(uname)" = Linux ] || return 0
996 for mnt in $mnts ; do
997 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
998 mpts=\\\$(mount | grep -c $mnt' ');
999 if [ \\\$running -ne \\\$mpts ]; then
1000 echo \\\$(hostname) env are INSANE!;
1003 [ $? -eq 0 ] || rc=1
1008 sanity_mount_check_servers () {
1009 [ "$CLIENTONLY" ] &&
1010 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
1011 echo Checking servers environments
1013 # FIXME: modify get_facets to display all facets wo params
1014 local facets="$(get_facets OST),$(get_facets MDS),mgs"
1018 for facet in ${facets//,/ }; do
1019 node=$(facet_host ${facet})
1020 mntpt=$(facet_mntpt $facet)
1021 sanity_mount_check_nodes $node $mntpt ||
1022 { error "server $node environments are insane!"; return 1; }
1026 sanity_mount_check_clients () {
1027 local clients=${1:-$CLIENTS}
1028 local mntpt=${2:-$MOUNT}
1029 local mntpt2=${3:-$MOUNT2}
1031 [ -z $clients ] && clients=$(hostname)
1032 echo Checking clients $clients environments
1034 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
1035 error "clients environments are insane!"
1038 sanity_mount_check () {
1039 sanity_mount_check_servers || return 1
1040 sanity_mount_check_clients || return 2
1043 # mount clients if not mouted
1044 zconf_mount_clients() {
1047 local OPTIONS=${3:-$MOUNTOPT}
1049 local device=$MGSNID:/$FSNAME
1050 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1051 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
1055 echo "Starting client $clients: $OPTIONS $device $mnt"
1058 running=\\\$(mount | grep -c $mnt' ');
1060 if [ \\\$running -eq 0 ] ; then
1062 mount -t lustre $OPTIONS $device $mnt;
1065 exit \\\$rc" || return ${PIPESTATUS[0]}
1067 echo "Started clients $clients: "
1068 do_nodes $clients "mount | grep $mnt' '"
1070 set_default_debug_nodes $clients
1075 zconf_umount_clients() {
1080 [ "$3" ] && force=-f
1082 echo "Stopping clients: $clients $mnt (opts:$force)"
1083 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
1084 if [ \\\$running -ne 0 ] ; then
1085 echo Stopping client \\\$(hostname) $mnt opts:$force;
1086 lsof -t $mnt || need_kill=no;
1087 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
1088 pids=\\\$(lsof -t $mnt | sort -u);
1089 if [ -n \\\"\\\$pids\\\" ]; then
1093 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
1094 if [ \\\$busy -ne 0 ] ; then
1095 echo "$mnt is still busy, wait one second" && sleep 1;
1103 echo + $POWER_DOWN $node
1107 shutdown_node_hard () {
1109 local attempts=$SHUTDOWN_ATTEMPTS
1111 for i in $(seq $attempts) ; do
1114 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
1115 echo "waiting for $host to fail attempts=$attempts"
1116 [ $i -lt $attempts ] || \
1117 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
1123 local mnt=${2:-$MOUNT}
1126 if [ "$FAILURE_MODE" = HARD ]; then
1127 shutdown_node_hard $client
1129 zconf_umount_clients $client $mnt -f
1135 local facets="$(get_facets OST),$(get_facets MDS)"
1138 combined_mgs_mds || facets="$facets,mgs"
1140 for facet in ${facets//,/ }; do
1141 if [ $(facet_active_host $facet) == $host ]; then
1142 affected="$affected $facet"
1146 echo $(comma_list $affected)
1151 local host=${2:-$(facet_host $facet)}
1153 local label=$(convert_facet2label $facet)
1154 do_node $host $LCTL dl | awk '{print $4}' | grep -q -x $label
1157 facets_up_on_host () {
1159 local facets=$(facets_on_host $host)
1162 for facet in ${facets//,/ }; do
1163 if $(facet_up $facet $host); then
1164 affected_up="$affected_up $facet"
1168 echo $(comma_list $affected_up)
1174 if [ "$FAILURE_MODE" = HARD ]; then
1175 shutdown_node_hard $(facet_active_host $facet)
1183 echo + $POWER_UP $node
1196 if [ "$FAILURE_MODE" = HARD ]; then
1197 reboot_node $(facet_active_host $facet)
1205 if [ "$FAILURE_MODE" = HARD ]; then
1215 for facet in ${facets//,/ }; do
1216 hosts=$(expand_list $hosts $(facet_host $facet) )
1222 _check_progs_installed () {
1226 for prog in $progs; do
1227 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1228 echo $prog missing on $(hostname)
1235 check_progs_installed () {
1239 do_rpc_nodes $nodes _check_progs_installed $@
1242 # recovery-scale functions
1244 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1247 start_client_load() {
1250 local var=$(node_var_name $client)_load
1251 eval export ${var}=$load
1253 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1254 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1255 END_RUN_FILE=$END_RUN_FILE \
1256 LOAD_PID_FILE=$LOAD_PID_FILE \
1257 TESTLOG_PREFIX=$TESTLOG_PREFIX \
1258 TESTNAME=$TESTNAME \
1259 DBENCH_LIB=$DBENCH_LIB \
1260 DBENCH_SRC=$DBENCH_SRC \
1263 log "Started client load: ${load} on $client"
1265 # get the children process IDs
1266 local pids=$(ps --ppid $ppid -o pid= | xargs)
1267 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
1271 start_client_loads () {
1272 local -a clients=(${1//,/ })
1273 local numloads=${#CLIENT_LOADS[@]}
1276 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1277 testnum=$((nodenum % numloads))
1278 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1280 # bug 22169: wait the background threads to start
1284 # only for remote client
1285 check_client_load () {
1287 local var=$(node_var_name $client)_load
1288 local TESTLOAD=run_${!var}.sh
1290 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1292 # bug 18914: try to connect several times not only when
1293 # check ps, but while check_catastrophe also
1296 while [ $RC = 254 -a $tries -gt 0 ]; do
1300 if ! check_catastrophe $client; then
1302 if [ $RC -eq 254 ]; then
1303 # FIXME: not sure how long we shuold sleep here
1307 echo "check catastrophe failed: RC=$RC "
1311 # We can continue try to connect if RC=254
1312 # Just print the warning about this
1313 if [ $RC = 254 ]; then
1314 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1317 # see if the load is still on the client
1320 while [ $RC = 254 -a $tries -gt 0 ]; do
1324 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1329 if [ $RC = 254 ]; then
1330 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1331 # see if we can diagnose a bit why this is
1336 check_client_loads () {
1337 local clients=${1//,/ }
1341 for client in $clients; do
1342 check_client_load $client
1344 if [ "$rc" != 0 ]; then
1345 log "Client load failed on node $client, rc=$rc"
1351 restart_client_loads () {
1352 local clients=${1//,/ }
1353 local expectedfail=${2:-""}
1357 for client in $clients; do
1358 check_client_load $client
1360 if [ "$rc" != 0 -a "$expectedfail" ]; then
1361 local var=$(node_var_name $client)_load
1362 start_client_load $client ${!var}
1363 echo "Restarted client load ${!var}: on $client. Checking ..."
1364 check_client_load $client
1366 if [ "$rc" != 0 ]; then
1367 log "Client load failed to restart on node $client, rc=$rc"
1368 # failure one client load means test fail
1369 # we do not need to check other
1378 # Start vmstat and save its process ID in a file.
1383 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1386 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
1387 2>/dev/null </dev/null & echo \\\$! > $pid_file"
1390 # Display the nodes on which client loads failed.
1391 print_end_run_file() {
1395 [ -s $file ] || return 0
1397 echo "Found the END_RUN_FILE file: $file"
1400 # A client load will stop if it finds the END_RUN_FILE file.
1401 # That does not mean the client load actually failed though.
1402 # The first node in END_RUN_FILE is the one we are interested in.
1405 if [ -n "$node" ]; then
1406 local var=$(node_var_name $node)_load
1408 local prefix=$TESTLOG_PREFIX
1409 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
1410 local stdout_log=$prefix.run_${!var}_stdout.$node.log
1411 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
1413 echo "Client load ${!var} failed on node $node:"
1419 # Stop the process which had its PID saved in a file.
1424 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1426 do_nodes $nodes "test -f $pid_file &&
1427 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
1430 # Stop all client loads.
1431 stop_client_loads() {
1432 local nodes=${1:-$CLIENTS}
1435 # stop the client loads
1436 stop_process $nodes $pid_file
1438 # clean up the processes that started them
1439 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
1441 # End recovery-scale functions
1443 # verify that lustre actually cleaned up properly
1445 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1446 error "LBUG/LASSERT detected"
1447 BUSY=`dmesg | grep -i destruct || true`
1448 if [ "$BUSY" ]; then
1450 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1454 check_mem_leak || exit 204
1456 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1457 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1459 if module_loaded lnet || module_loaded libcfs; then
1460 echo "$0: modules still loaded..." 1>&2
1477 RESULT=$(do_node $node "$TEST")
1478 if [ "$RESULT" == "$FINAL" ]; then
1479 [ -z "$RESULT" -o $WAIT -le $sleep ] ||
1480 echo "Updated after ${WAIT}s: wanted '$FINAL' got '$RESULT'"
1483 [ $WAIT -ge $MAX ] && break
1484 echo "Waiting $((MAX - WAIT)) secs for update"
1485 WAIT=$((WAIT + sleep))
1488 echo "Update not seen after ${MAX}s: wanted '$FINAL' got '$RESULT'"
1492 wait_update_facet() {
1495 wait_update $(facet_active_host $facet) "$@"
1498 wait_delete_completed () {
1499 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1500 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1504 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1506 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1507 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1508 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1509 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1513 echo "Delete is not completed in $MAX_WAIT sec"
1520 # we can use "for" here because we are waiting the slowest
1521 for host in ${hostlist//,/ }; do
1522 check_network "$host" 900
1524 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1531 for facet in ${facetlist//,/ }; do
1532 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1534 wait_for_host $hostlist
1537 _wait_recovery_complete () {
1540 # Use default policy if $2 is not passed by caller.
1541 local MAX=${2:-$(max_recovery_time)}
1546 while [ $WAIT -lt $MAX ]; do
1547 STATUS=$(lctl get_param -n $param | grep status)
1549 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1552 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1554 echo "$param recovery not done in $MAX sec. $STATUS"
1558 wait_recovery_complete () {
1561 # with an assumption that at_max is the same on all nodes
1562 local MAX=${2:-$(max_recovery_time)}
1565 if [ "$FAILURE_MODE" = HARD ]; then
1566 facets=$(facets_on_host $(facet_active_host $facet))
1568 echo affected facets: $facets
1570 # we can use "for" here because we are waiting the slowest
1571 for facet in ${facets//,/ }; do
1572 local var_svc=${facet}_svc
1573 local param="*.${!var_svc}.recovery_status"
1575 local host=$(facet_active_host $facet)
1576 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1580 wait_mds_ost_sync () {
1581 # just because recovery is done doesn't mean we've finished
1582 # orphan cleanup. Wait for llogs to get synchronized.
1583 echo "Waiting for orphan cleanup..."
1584 # MAX value includes time needed for MDS-OST reconnection
1585 local MAX=$(( TIMEOUT * 2 ))
1587 while [ $WAIT -lt $MAX ]; do
1588 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1589 "$LCTL get_param -n obdfilter.*.mds_sync"))
1592 for ((i=0; i<${#sync[@]}; i++)); do
1593 [ ${sync[$i]} -eq 0 ] && continue
1594 # there is a not finished MDS-OST synchronization
1598 sleep 2 # increase waiting time and cover statfs cache
1599 [ ${con} -eq 1 ] && return 0
1600 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1603 echo "$facet recovery not done in $MAX sec. $STATUS"
1607 wait_destroy_complete () {
1608 echo "Waiting for destroy to be done..."
1609 # MAX value shouldn't be big as this mean server responsiveness
1610 # never increase this just to make test pass but investigate
1611 # why it takes so long time
1614 while [ $WAIT -lt $MAX ]; do
1615 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1617 for ((i=0; i<${#RPCs[@]}; i++)); do
1618 [ ${RPCs[$i]} -eq 0 ] && continue
1619 # there are still some destroy RPCs in flight
1624 [ ${con} -eq 1 ] && return 0 # done waiting
1625 echo "Waiting $WAIT secs for destroys to be done."
1628 echo "Destroys weren't done in $MAX sec."
1638 # conf-sanity 31 takes a long time cleanup
1639 while [ $WAIT -lt 300 ]; do
1640 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1641 [ -z "${running}" ] && return 0
1642 echo "waited $WAIT for${running}"
1643 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1645 WAIT=$((WAIT + INTERVAL))
1647 echo "service didn't stop after $WAIT seconds. Still running:"
1652 wait_remote_prog () {
1658 [ "$PDSH" = "no_dsh" ] && return 0
1660 while [ $WAIT -lt $2 ]; do
1661 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1662 [ -z "${running}" ] && return 0 || true
1663 echo "waited $WAIT for: "
1665 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1667 WAIT=$((WAIT + INTERVAL))
1669 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1670 [ -z "$pids" ] && return 0
1671 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1672 # FIXME: not portable
1673 for pid in $pids; do
1674 cat /proc/${pid}/status || true
1675 cat /proc/${pid}/wchan || true
1677 kill -9 $pid || true
1686 # not every config has many clients
1688 if [ ! -z "$CLIENTS" ]; then
1689 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1691 stat -f $MOUNT > /dev/null
1697 # usually checked on particular client or locally
1699 if [ ! -z "$client" ]; then
1700 $PDSH $client "stat -f $MOUNT" > /dev/null
1702 stat -f $MOUNT > /dev/null
1710 client_reconnect() {
1711 uname -n >> $MOUNT/recon
1712 if [ -z "$CLIENTS" ]; then
1713 df $MOUNT; uname -n >> $MOUNT/recon
1715 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1717 echo Connected clients:
1719 ls -l $MOUNT/recon > /dev/null
1723 affected_facets () {
1726 local host=$(facet_active_host $facet)
1727 local affected=$facet
1729 if [ "$FAILURE_MODE" = HARD ]; then
1730 affected=$(facets_up_on_host $host)
1738 local host=$(facet_active_host $facet)
1740 echo "Failing $facet on node $host"
1742 local affected=$(affected_facets $facet)
1744 shutdown_facet $facet
1746 echo affected facets: $affected
1748 [ -n "$sleep_time" ] && sleep $sleep_time
1752 change_active $affected
1754 wait_for_facet $affected
1755 # start mgs first if it is affected
1756 if ! combined_mgs_mds && list_member $affected mgs; then
1757 mount_facet mgs || error "Restart of mgs failed"
1759 # FIXME; has to be changed to mount all facets concurrently
1760 affected=$(exclude_items_from_list $affected mgs)
1761 mount_facets $affected
1770 do_facet $facet sync
1773 # make sure there will be no seq change
1774 local clients=${CLIENTS:-$HOSTNAME}
1775 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1777 local svc=${facet}_svc
1778 do_facet $facet $LCTL --device %${!svc} notransno
1779 do_facet $facet $LCTL --device %${!svc} readonly
1780 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1781 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1784 replay_barrier_nodf() {
1785 local facet=$1 echo running=${running}
1786 do_facet $facet sync
1787 local svc=${facet}_svc
1788 echo Replay barrier on ${!svc}
1789 do_facet $facet $LCTL --device %${!svc} notransno
1790 do_facet $facet $LCTL --device %${!svc} readonly
1791 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1792 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1795 replay_barrier_nosync() {
1796 local facet=$1 echo running=${running}
1797 local svc=${facet}_svc
1798 echo Replay barrier on ${!svc}
1799 do_facet $facet $LCTL --device %${!svc} notransno
1800 do_facet $facet $LCTL --device %${!svc} readonly
1801 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1802 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1805 mds_evict_client() {
1806 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1807 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1810 ost_evict_client() {
1811 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1812 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1816 facet_failover $* || error "failover: $?"
1817 clients_up || error "post-failover df: $?"
1822 facet_failover $facet
1828 change_active $facet
1829 wait_for_facet $facet
1830 mount_facet $facet -o abort_recovery
1831 clients_up || echo "first df failed: $?"
1832 clients_up || error "post-failover df: $?"
1836 echo There is no lmc. This is mountconf, baby.
1841 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1847 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1848 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1849 if [ -z "$ID" ]; then
1850 echo "Could not get a ptl id for $1..."
1859 h2name_or_ip "$1" "tcp"
1864 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1865 if type __h2elan >/dev/null 2>&1; then
1868 ID=`echo $1 | sed 's/[^0-9]*//g'`
1876 h2name_or_ip "$1" "o2ib"
1883 [ "$facet" == client ] && echo -n $HOSTNAME && return
1884 varname=${facet}_HOST
1885 if [ -z "${!varname}" ]; then
1886 if [ "${facet:0:3}" == "ost" ]; then
1887 eval ${facet}_HOST=${ost_HOST}
1895 local activevar=${facet}active
1897 if [ -f $TMP/${facet}active ] ; then
1898 source $TMP/${facet}active
1901 active=${!activevar}
1902 if [ -z "$active" ] ; then
1909 facet_active_host() {
1911 local active=`facet_active $facet`
1912 if [ "$facet" == client ]; then
1915 echo `facet_host $active`
1923 facetlist=$(exclude_items_from_list $facetlist mgs)
1925 for facet in ${facetlist//,/ }; do
1926 local failover=${facet}failover
1927 local host=`facet_host $failover`
1928 [ -z "$host" ] && return
1930 local curactive=`facet_active $facet`
1931 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1932 eval export ${facet}active=$facet
1934 eval export ${facet}active=$failover
1936 # save the active host for this facet
1937 local activevar=${facet}active
1938 echo "$activevar=${!activevar}" > $TMP/$activevar
1939 [[ $facet = mds1 ]] && combined_mgs_mds && \
1940 echo "mgsactive=${!activevar}" > $TMP/mgsactive
1941 local TO=`facet_active_host $facet`
1942 echo "Failover $facet to $TO"
1948 # do not stripe off hostname if verbose, bug 19215
1949 if [ x$1 = x--verbose ]; then
1957 if [ "$HOST" = "$HOSTNAME" ]; then
1959 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1960 echo "cannot run remote command on $HOST with $myPDSH"
1964 echo "CMD: $HOST $@" >&2
1965 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1968 if [ "$myPDSH" = "rsh" ]; then
1969 # we need this because rsh does not return exit code of an executed command
1970 local command_status="$TMP/cs"
1971 rsh $HOST ":> $command_status"
1972 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1973 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1974 echo command failed >$command_status"
1975 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1980 # print HOSTNAME for myPDSH="no_dsh"
1981 if [[ $myPDSH = no_dsh ]]; then
1982 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1984 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1987 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1989 return ${PIPESTATUS[0]}
1993 do_node --verbose "$@"
1996 single_local_node () {
1997 [ "$1" = "$HOSTNAME" ]
2000 # Outputs environment variable assignments that should be passed to remote nodes
2005 for var in ${!MODOPTS_*}; do
2007 echo "${var}=\"$value\""
2013 # do not stripe off hostname if verbose, bug 19215
2014 if [ x$1 = x--verbose ]; then
2022 if single_local_node $rnodes; then
2024 do_nodev $rnodes "$@"
2026 do_node $rnodes "$@"
2031 # This is part from do_node
2034 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
2035 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
2037 export FANOUT=$(get_node_count "${rnodes//,/ }")
2039 echo "CMD: $rnodes $@" >&2
2040 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2043 # do not replace anything from pdsh output if -N is used
2044 # -N Disable hostname: prefix on lines of output.
2045 if $verbose || [[ $myPDSH = *-N* ]]; then
2046 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
2048 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
2050 return ${PIPESTATUS[0]}
2056 local HOST=`facet_active_host $facet`
2057 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
2062 do_nodes --verbose "$@"
2068 # make sure its not already running
2070 rm -f $TMP/${facet}active
2071 [[ $facet = mds1 ]] && combined_mgs_mds && rm -f $TMP/mgsactive
2072 do_facet ${facet} $MKFS $*
2078 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
2079 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
2086 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
2087 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
2093 [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
2095 local var=${facet}_MOUNT
2096 eval mntpt=${!var:-${MOUNT%/*}/$facet}
2105 # make sure we are using the primary server, so test-framework will
2106 # be able to clean up properly.
2107 activemds=`facet_active mds1`
2108 if [ $activemds != "mds1" ]; then
2112 local clients=$CLIENTS
2113 [ -z $clients ] && clients=$(hostname)
2115 zconf_umount_clients $clients $MOUNT "$*" || true
2116 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
2118 [ "$CLIENTONLY" ] && return
2119 # The add fn does rm ${facet}active file, this would be enough
2120 # if we use do_facet <facet> only after the facet added, but
2121 # currently we use do_facet mds in local.sh
2122 for num in `seq $MDSCOUNT`; do
2124 rm -f ${TMP}/mds${num}active
2126 combined_mgs_mds && rm -f $TMP/mgsactive
2128 for num in `seq $OSTCOUNT`; do
2130 rm -f $TMP/ost${num}active
2133 if ! combined_mgs_mds ; then
2140 cleanup_echo_devs () {
2141 local devs=$($LCTL dl | grep echo | awk '{print $4}')
2143 for dev in $devs; do
2144 $LCTL --device $dev cleanup
2145 $LCTL --device $dev detach
2150 nfs_client_mode && return
2159 combined_mgs_mds () {
2160 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
2166 local number=$(echo -n $facet | sed -e 's/^fs[0-9]\+//' |
2167 sed -e 's/^[a-z]\+//')
2169 [[ -z $number ]] && number=1
2177 local index=$(($(facet_number $facet) - 1))
2178 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
2179 local optvar=${tgt}_MKFS_OPTS
2180 local opt=${!optvar}
2182 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
2183 [[ $facet = mgs ]] && echo $opt && return
2186 [[ $opt != *--index* ]] && opt+=" --index=$index"
2189 # --failnode options
2190 local var=${facet}failover_HOST
2191 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
2192 local failnode=$(h2$NETTYPE ${!var})
2193 failnode="--failnode=$failnode"
2194 # options does not contain
2195 # or contains wrong --failnode=
2196 if [[ $opt != *${failnode}* ]]; then
2197 opt=$(echo $opt | sed 's/--failnode=.* / /')
2198 opt="$opt $failnode"
2204 # no additional mkfs mds "--mgsnode" option for this configuration
2205 if [[ $facet = mds ]] && combined_mgs_mds; then
2210 # additional mkfs "--mgsnode"
2211 local mgsnode="--mgsnode=$MGSNID"
2212 opt=${opt//$mgsnode }
2213 for nid in ${MGSNID//:/ }; do
2214 local mgsnode="--mgsnode=$nid"
2215 # options does not contain
2217 if [[ $opt != *${mgsnode}" "* ]]; then
2218 opt="$opt --mgsnode=$nid"
2226 if [ "$IAMDIR" == "yes" ]; then
2227 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
2230 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
2233 # We need ldiskfs here, may as well load them all
2235 [ "$CLIENTONLY" ] && return
2236 echo Formatting mgs, mds, osts
2237 if ! combined_mgs_mds ; then
2238 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
2241 for num in `seq $MDSCOUNT`; do
2242 echo "Format mds$num: $(mdsdevname $num)"
2244 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
2246 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
2250 # the ost-s could have different OST_MKFS_OPTS
2251 # because of different failnode-s
2252 for num in `seq $OSTCOUNT`; do
2253 echo "Format ost$num: $(ostdevname $num)"
2255 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
2257 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
2263 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
2267 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
2271 # 0: success, the old identity set already.
2272 # 1: success, the old identity does not set.
2277 local j=`expr $num - 1`
2278 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
2280 if [ -z "$MDT" ]; then
2284 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
2287 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
2289 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
2292 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
2294 if [ $old = "NONE" ]; then
2303 zconf_umount `hostname` $1 || error "umount failed"
2304 zconf_mount `hostname` $1 || error "mount failed"
2307 writeconf_facet () {
2311 do_facet $facet "$TUNEFS --writeconf $dev"
2315 for num in `seq $MDSCOUNT`; do
2316 DEVNAME=$(mdsdevname $num)
2317 writeconf_facet mds$num $DEVNAME
2320 for num in `seq $OSTCOUNT`; do
2321 DEVNAME=$(ostdevname $num)
2322 writeconf_facet ost$num $DEVNAME
2327 nfs_client_mode && return
2329 sanity_mount_check ||
2330 error "environments are insane!"
2334 if [ -z "$CLIENTONLY" ]; then
2335 echo Setup mgs, mdt, osts
2336 echo $WRITECONF | grep -q "writeconf" && \
2338 if ! combined_mgs_mds ; then
2339 start mgs $MGSDEV $MGS_MOUNT_OPTS
2342 for num in `seq $MDSCOUNT`; do
2343 DEVNAME=$(mdsdevname $num)
2344 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2346 # We started mds, now we should set failover variables properly.
2347 # Set mds${num}failover_HOST if it is not set (the default failnode).
2348 local varname=mds${num}failover_HOST
2349 if [ -z "${!varname}" ]; then
2350 eval mds${num}failover_HOST=$(facet_host mds$num)
2353 if [ $IDENTITY_UPCALL != "default" ]; then
2354 switch_identity $num $IDENTITY_UPCALL
2357 for num in `seq $OSTCOUNT`; do
2358 DEVNAME=$(ostdevname $num)
2359 start ost$num $DEVNAME $OST_MOUNT_OPTS
2361 # We started ost$num, now we should set ost${num}failover variable properly.
2362 # Set ost${num}failover_HOST if it is not set (the default failnode).
2363 varname=ost${num}failover_HOST
2364 if [ -z "${!varname}" ]; then
2365 eval ost${num}failover_HOST=$(facet_host ost${num})
2373 # wait a while to allow sptlrpc configuration be propogated to targets,
2374 # only needed when mounting new target devices.
2379 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2381 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2384 if [ "$MOUNT_2" ]; then
2385 mount_client $MOUNT2
2386 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2391 # by remounting mdt before ost, initial connect from mdt to ost might
2392 # timeout because ost is not ready yet. wait some time to its fully
2393 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2394 # by a context negotiation rpc with $TIMEOUT.
2395 # FIXME better by monitoring import status.
2398 sleep $((TIMEOUT + 5))
2404 mounted_lustre_filesystems() {
2405 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2408 init_facet_vars () {
2409 [ "$CLIENTONLY" ] && return 0
2416 eval export ${facet}_dev=${device}
2417 eval export ${facet}_opt=\"$@\"
2419 local dev=${facet}_dev
2420 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2421 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2423 eval export ${facet}_svc=${label}
2425 local varname=${facet}failover_HOST
2426 if [ -z "${!varname}" ]; then
2427 eval $varname=$(facet_host $facet)
2430 # ${facet}failover_dev is set in cfg file
2431 varname=${facet}failover_dev
2432 if [ -n "${!varname}" ] ; then
2433 eval export ${facet}failover_dev=${!varname}
2435 eval export ${facet}failover_dev=$device
2438 # get mount point of already mounted device
2439 # is facet_dev is already mounted then use the real
2440 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2441 # i.e. ${facet}_MOUNT if specified by user or default
2442 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2443 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2444 if [ -z $mntpt ]; then
2445 mntpt=$(facet_mntpt $facet)
2447 eval export ${facet}_MOUNT=$mntpt
2450 init_facets_vars () {
2453 if ! remote_mds_nodsh; then
2454 for num in `seq $MDSCOUNT`; do
2455 DEVNAME=`mdsdevname $num`
2456 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2460 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2462 remote_ost_nodsh && return
2464 for num in `seq $OSTCOUNT`; do
2465 DEVNAME=`ostdevname $num`
2466 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2470 osc_ensure_active () {
2475 while [ $period -lt $timeout ]; do
2476 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2477 if [ $count -eq 0 ]; then
2481 echo "There are $count OST are inactive, wait $period seconds, and try again"
2483 period=$((period+3))
2486 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2489 init_param_vars () {
2491 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2493 log "Using TIMEOUT=$TIMEOUT"
2495 osc_ensure_active $SINGLEMDS $TIMEOUT
2496 osc_ensure_active client $TIMEOUT
2498 if [ $QUOTA_AUTO -ne 0 ]; then
2499 if [ "$ENABLE_QUOTA" ]; then
2500 echo "enable quota as required"
2501 setup_quota $MOUNT || return 2
2503 echo "disable quota as required"
2504 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ] &&
2505 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2512 nfs_client_mode () {
2513 if [ "$NFSCLIENT" ]; then
2514 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2515 local clients=$CLIENTS
2516 [ -z $clients ] && clients=$(hostname)
2518 # FIXME: remove hostname when 19215 fixed
2519 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2520 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2521 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2522 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2524 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2530 check_config_client () {
2533 local mounted=$(mount | grep " $mntpt ")
2534 if [ "$CLIENTONLY" ]; then
2536 # CLIENTONLY should not depend on *_HOST settings
2537 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2538 # in theory someone could create a new,
2539 # client-only config file that assumed lustre was already
2540 # configured and didn't set the MGSNID. If MGSNID is not set,
2541 # then we should use the mgs nid currently being used
2542 # as the default value. bug 18021
2543 [[ x$MGSNID = x ]] &&
2546 if [[ x$mgc != xMGC$MGSNID ]]; then
2547 if [ "$mgs_HOST" ]; then
2548 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2549 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2550 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2556 local myMGS_host=$mgs_HOST
2557 if [ "$NETTYPE" = "ptl" ]; then
2558 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2561 echo Checking config lustre mounted on $mntpt
2562 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2563 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2565 # if [ "$mgshost" != "$myMGS_host" ]; then
2566 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2567 # Please use correct config or set mds_HOST correctly!"
2572 check_config_clients () {
2573 local clients=${CLIENTS:-$HOSTNAME}
2576 nfs_client_mode && return
2578 do_rpc_nodes $clients check_config_client $mntpt
2580 sanity_mount_check ||
2581 error "environments are insane!"
2585 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2586 local cltimeout=$(lctl get_param -n timeout)
2587 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2588 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2595 [ -z $mntpt ] && return 1
2596 local mounted=$(mounted_lustre_filesystems)
2598 echo $mounted' ' | grep -w -q $mntpt' '
2602 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2606 # empty lustre filesystem may have empty directories lost+found and .lustre
2608 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2609 -print | wc -l) = 1 ] || return 1
2610 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2611 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2615 check_and_setup_lustre() {
2616 nfs_client_mode && return
2618 local MOUNTED=$(mounted_lustre_filesystems)
2622 # both MOUNT and MOUNT2 are not mounted
2623 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2624 [ "$REFORMAT" ] && formatall
2625 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2627 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2628 export I_MOUNTED=yes
2632 elif is_mounted $MOUNT2; then
2634 # MOUNT2 is mounted, while MOUNT_2 is not set
2635 if ! [ "$MOUNT_2" ]; then
2636 cleanup_mount $MOUNT2
2637 export I_UMOUNTED2=yes
2640 # MOUNT2 is mounted, MOUNT_2 is set
2642 # FIXME: what to do if check_config failed?
2644 # 1) remote client has mounted other Lustre fs ?
2645 # 2) it has insane env ?
2646 # let's try umount MOUNT2 on all clients and mount it again:
2647 if ! check_config_clients $MOUNT2; then
2648 cleanup_mount $MOUNT2
2649 restore_mount $MOUNT2
2650 export I_MOUNTED2=yes
2655 # MOUNT is mounted MOUNT2 is not mounted
2656 elif [ "$MOUNT_2" ]; then
2657 restore_mount $MOUNT2
2658 export I_MOUNTED2=yes
2662 # FIXME: what to do if check_config failed?
2664 # 1) remote client has mounted other Lustre fs?
2665 # 2) lustre is mounted on remote_clients atall ?
2666 check_config_clients $MOUNT
2670 set_default_debug_nodes $(comma_list $(nodes_list))
2678 if [ "$ONLY" == "setup" ]; then
2684 local clients=${CLIENTS:-$HOSTNAME}
2687 zconf_mount_clients $clients $mntpt
2691 local clients=${CLIENTS:-$HOSTNAME}
2694 zconf_umount_clients $clients $mntpt
2697 cleanup_and_setup_lustre() {
2698 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2699 lctl set_param debug=0 || true
2701 if [ "$ONLY" == "cleanup" ]; then
2705 check_and_setup_lustre
2708 # Get all of the server target devices from a given server node and type.
2715 if [ "$type" == ost ]; then
2716 devs=$(get_obdfilter_param $node "" mntdev)
2718 devs=$(do_node $node \
2719 "lctl get_param -n osd-*.$FSNAME-M*.mntdev")
2721 for dev in $devs; do
2723 *loop*) do_node $node "losetup $dev" | \
2724 sed -e "s/.*(//" -e "s/).*//" ;;
2730 # Get all of the server target devices.
2735 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2739 for node in $(osts_nodes); do
2740 OSTDEVS[i]=$(get_mnt_devs $node ost)
2745 # Run e2fsck on MDT or OST device.
2751 df > /dev/null # update statfs data on disk
2752 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2755 do_node $node $cmd || rc=$?
2756 [ $rc -le $FSCK_MAX_ERR ] || \
2757 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2761 # verify a directory is shared among nodes.
2762 check_shared_dir() {
2765 [ -z "$dir" ] && return 1
2766 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $dir
2767 check_write_access $dir || return 1
2771 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2777 check_shared_dir $SHARED_DIRECTORY ||
2778 error "$SHARED_DIRECTORY isn't a shared directory"
2780 export MDSDB=$SHARED_DIRECTORY/mdsdb
2781 export OSTDB=$SHARED_DIRECTORY/ostdb
2783 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2785 run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
2790 for node in $(osts_nodes); do
2791 for dev in ${OSTDEVS[i]}; do
2792 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
2793 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2794 ostidx=$((ostidx + 1))
2801 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2805 [ $rc -le $FSCK_MAX_ERR ] || \
2806 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2807 echo "lfsck finished with rc=$rc"
2809 rm -rvf $MDSDB* $OSTDB* || true
2813 check_and_cleanup_lustre() {
2814 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
2820 if is_mounted $MOUNT; then
2821 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
2822 error "remove sub-test dirs failed"
2823 [ "$ENABLE_QUOTA" ] && restore_quota || true
2826 if [ "$I_UMOUNTED2" = "yes" ]; then
2827 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2830 if [ "$I_MOUNTED2" = "yes" ]; then
2831 cleanup_mount $MOUNT2
2834 if [ "$I_MOUNTED" = "yes" ]; then
2835 cleanupall -f || error "cleanup failed"
2843 wait_for_function () {
2846 # suppress fn both stderr and stdout
2847 if [ "$1" = "--quiet" ]; then
2849 quiet=" > /dev/null 2>&1"
2861 eval $fn $quiet && return 0
2863 wait=$((wait + sleep))
2864 [ $wait -lt $max ] || return 1
2865 echo waiting $fn, $((max - wait)) secs left ...
2875 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2876 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2877 echo "Network not available!"
2881 echo `date +"%H:%M:%S (%s)"` network interface is UP
2890 # the sed converts spaces to commas, but leaves the last space
2891 # alone, so the line doesn't end with a comma.
2892 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2898 echo $list | grep -qw $item
2901 # list, excluded are the comma separated lists
2902 exclude_items_from_list () {
2908 for item in ${excluded//,/ }; do
2909 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2911 echo $(comma_list $list)
2914 # list, expand are the comma separated lists
2916 local list=${1//,/ }
2917 local expand=${2//,/ }
2920 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2921 echo $(comma_list $expanded)
2924 testslist_filter () {
2925 local script=$LUSTRE/tests/${TESTSUITE}.sh
2927 [ -f $script ] || return 0
2929 local start_at=$START_AT
2930 local stop_at=$STOP_AT
2932 local var=${TESTSUITE//-/_}_START_AT
2933 [ x"${!var}" != x ] && start_at=${!var}
2934 var=${TESTSUITE//-/_}_STOP_AT
2935 [ x"${!var}" != x ] && stop_at=${!var}
2937 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2938 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2939 /^'${start_at}'$/ {flag = 0}
2940 {if (flag == 1) print $0}
2941 /^'${stop_at}'$/ { flag = 1 }'
2945 (cd `dirname $1`; echo $PWD/`basename $1`)
2949 local types=${1:-"OST MDS MGS"}
2953 for entry in $types; do
2954 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2955 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2958 MGS ) list="$list $name";;
2959 MDS|OST ) local count=${type}COUNT
2960 for ((i=1; i<=${!count}; i++)) do
2961 list="$list ${name}$i"
2963 * ) error "Invalid facet type"
2967 echo $(comma_list $list)
2970 ##################################
2971 # Adaptive Timeouts funcs
2974 # only check mds, we assume at_max is the same on all nodes
2975 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2976 if [ $at_max -eq 0 ]; then
2987 # suppose that all ost-s have the same $at value set
2988 [[ $facet = ost ]] && facet=ost1
2990 do_facet $facet "lctl get_param -n $at"
3008 if [ $facet == "ost" ]; then
3009 facet=$(get_facets OST)
3010 elif [ $facet == "mds" ]; then
3011 facet=$(get_facets MDS)
3013 hosts=$(expand_list $hosts $(facets_hosts $facet))
3016 do_nodes $hosts lctl set_param at_max=$at_max
3019 ##################################
3023 # OBD_FAIL_MDS_ALL_REQUEST_NET
3025 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
3026 do_facet client "$1" || RC=$?
3027 do_facet $SINGLEMDS lctl set_param fail_loc=0
3032 # OBD_FAIL_MDS_ALL_REPLY_NET
3034 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
3035 do_facet client "$@" || RC=$?
3036 do_facet $SINGLEMDS lctl set_param fail_loc=0
3040 drop_reint_reply() {
3041 # OBD_FAIL_MDS_REINT_NET_REP
3043 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
3044 do_facet client "$@" || RC=$?
3045 do_facet $SINGLEMDS lctl set_param fail_loc=0
3050 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
3052 do_facet ost1 lctl set_param fail_loc=0x214
3053 do_facet client "$1" || RC=$?
3054 do_facet client "sync"
3055 do_facet ost1 lctl set_param fail_loc=0
3059 drop_ldlm_cancel() {
3060 #define OBD_FAIL_LDLM_CANCEL 0x304
3062 do_facet client lctl set_param fail_loc=0x304
3063 do_facet client "$@" || RC=$?
3064 do_facet client lctl set_param fail_loc=0
3068 drop_bl_callback() {
3069 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
3071 do_facet client lctl set_param fail_loc=0x305
3072 do_facet client "$@" || RC=$?
3073 do_facet client lctl set_param fail_loc=0
3078 #define OBD_FAIL_LDLM_REPLY 0x30c
3080 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
3081 do_facet client "$@" || RC=$?
3082 do_facet $SINGLEMDS lctl set_param fail_loc=0
3090 echo "clearing fail_loc on $facet"
3091 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
3094 set_nodes_failloc () {
3095 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
3098 cancel_lru_locks() {
3099 $LCTL mark "cancel_lru_locks $1 start"
3100 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
3101 $LCTL set_param -n $d=clear
3103 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
3104 $LCTL mark "cancel_lru_locks $1 stop"
3109 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
3110 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
3111 echo "$DEFAULT_LRU_SIZE"
3116 lctl set_param ldlm.namespaces.*$1*.lru_size=0
3119 lru_resize_disable()
3121 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
3126 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
3127 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
3128 echo there is still data in page cache $FILE ?
3129 lctl get_param -n $FILE
3137 DEBUGSAVE="$(lctl get_param -n debug)"
3141 [ -n "$DEBUGSAVE" ] && \
3142 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
3147 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
3150 debug_size_restore() {
3151 [ -n "$DEBUG_SIZE_SAVED" ] && \
3152 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
3156 start_full_debug_logging() {
3161 local DEBUG_SIZE=150
3163 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
3164 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
3167 stop_full_debug_logging() {
3172 ##################################
3174 ##################################
3177 local TYPE=${TYPE:-"FAIL"}
3180 # do not dump logs if $1=false
3181 if [ "x$1" = "xfalse" ]; then
3186 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
3189 # We need to dump the logs on all nodes
3191 gather_logs $(comma_list $(nodes_list))
3195 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
3196 echo "$@" > $LOGDIR/err
3201 local log=$TESTSUITELOG
3203 [ -f "$log" ] && grep -q FAIL: $log && status=1
3216 # use only if we are ignoring failures for this test, bugno required.
3217 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
3218 # e.g. error_ignore 5494 "your message"
3220 local TYPE="IGNORE (bz$1)"
3226 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
3231 log " SKIP: $TESTSUITE $TESTNAME $@"
3233 if [[ -n "$ALWAYS_SKIPPED" ]]; then
3234 skip_logged $TESTNAME "$@"
3237 echo "$@" > $LOGDIR/skip
3240 [[ -n "$TESTSUITELOG" ]] &&
3241 echo "$TESTSUITE: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
3244 build_test_filter() {
3245 EXCEPT="$EXCEPT $(testslist_filter)"
3247 [ "$ONLY" ] && log "only running test `echo $ONLY`"
3251 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
3252 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
3253 [ "$EXCEPT_SLOW" ] && \
3254 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
3255 for E in $EXCEPT; do
3256 eval EXCEPT_${E}=true
3258 for E in $ALWAYS_EXCEPT; do
3259 eval EXCEPT_ALWAYS_${E}=true
3261 for E in $EXCEPT_SLOW; do
3262 eval EXCEPT_SLOW_${E}=true
3264 for G in $GRANT_CHECK_LIST; do
3265 eval GCHECK_ONLY_${G}=true
3270 if [[ $1 = [a-z]* ]]; then
3277 # print a newline if the last test was skipped
3278 export LAST_SKIPPED=
3279 export ALWAYS_SKIPPED=
3281 # Main entry into test-framework. This is called with the name and
3282 # description of a test. The name is used to find the function to run
3283 # the test using "test_$name".
3285 # This supports a variety of methods of specifying specific test to
3286 # run or not run. These need to be documented...
3291 export base=`basetest $1`
3292 if [ ! -z "$ONLY" ]; then
3294 if [ ${!testname}x != x ]; then
3295 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3296 run_one_logged $1 "$2"
3300 if [ ${!testname}x != x ]; then
3301 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3302 run_one_logged $1 "$2"
3313 if [ ${!testname}x != x ]; then
3314 TESTNAME=test_$1 skip "skipping excluded test $1"
3317 testname=EXCEPT_$base
3318 if [ ${!testname}x != x ]; then
3319 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3322 testname=EXCEPT_ALWAYS_$1
3323 if [ ${!testname}x != x ]; then
3324 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3327 testname=EXCEPT_ALWAYS_$base
3328 if [ ${!testname}x != x ]; then
3329 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3332 testname=EXCEPT_SLOW_$1
3333 if [ ${!testname}x != x ]; then
3334 TESTNAME=test_$1 skip "skipping SLOW test $1"
3337 testname=EXCEPT_SLOW_$base
3338 if [ ${!testname}x != x ]; then
3339 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3345 run_one_logged $1 "$2"
3356 module_loaded lnet || load_modules
3368 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3373 strace -o $TMP/$1.strace -ttt $*
3375 log "FINISHED: $*: rc $RC"
3380 equals_msg $1 test complete, duration $2 sec
3381 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3382 echo duration $2 >>$TESTSUITELOG
3386 # Set TEST_STATUS here. It will be used for logging the result.
3389 if [[ -f $LOGDIR/err ]]; then
3391 elif [[ -f $LOGDIR/skip ]]; then
3394 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3398 local FFREE=$(do_node $SINGLEMDS \
3399 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3400 local FTOTAL=$(do_node $SINGLEMDS \
3401 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3403 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3407 echo -n "Resetting fail_loc on all nodes..."
3408 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3414 # Log a message (on all nodes) padded with "=" before and after.
3415 # Also appends a timestamp and prepends the testsuite name.
3418 EQUALS="===================================================================================================="
3420 msg="== ${TESTSUITE} $*"
3422 [[ $last != "=" && $last != " " ]] && msg="$msg "
3423 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3424 # always include at least == after the message
3425 log "$msg== $(date +"%H:%M:%S (%s)")"
3429 # Run a single test function and cleanup after it.
3431 # This function should be run in a subshell so the test func can
3432 # exit() without stopping the whole script.
3438 export tdir=d0.${TESTSUITE}/d${base}
3439 export TESTNAME=test_$testnum
3440 local SAVE_UMASK=`umask`
3443 banner "test $testnum: $message"
3444 test_${testnum} || error "test_$testnum failed with $?"
3447 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3448 check_catastrophe || error "LBUG/LASSERT detected"
3449 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3457 # Wrapper around run_one to ensure:
3458 # - test runs in subshell
3459 # - output of test is saved to separate log file for error reporting
3460 # - test result is saved to data file
3463 local BEFORE=`date +%s`
3465 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
3466 local test_log=$LOGDIR/$name
3469 local SAVE_UMASK=`umask`
3473 log_sub_test_begin test_${1}
3474 (run_one $1 "$2") 2>&1 | tee $test_log
3475 local RC=${PIPESTATUS[0]}
3477 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3478 echo "test_$1 returned $RC" | tee $LOGDIR/err
3480 duration=$((`date +%s` - $BEFORE))
3481 pass "$1" "(${duration}s)"
3483 if [[ -f $LOGDIR/err ]]; then
3484 TEST_ERROR=$(cat $LOGDIR/err)
3485 elif [[ -f $LOGDIR/skip ]]; then
3486 TEST_ERROR=$(cat $LOGDIR/skip)
3488 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3490 if [ -f $LOGDIR/err ]; then
3491 $FAIL_ON_ERROR && exit $RC
3500 # Print information of skipped tests to result.yml
3503 log_sub_test_begin $1
3505 log_sub_test_end "SKIP" "0" "0" "$@"
3509 (cd `dirname $1`; echo $PWD/`basename $1`)
3514 export base=`basetest $1`
3515 [ "$CHECK_GRANT" == "no" ] && return 0
3517 testname=GCHECK_ONLY_${base}
3518 [ ${!testname}x == x ] && return 0
3520 echo -n "checking grant......"
3522 local clients=$CLIENTS
3523 [ -z $clients ] && clients=$(hostname)
3525 # sync all the data and make sure no pending data on server
3526 do_nodes $clients sync
3529 client_grant=`do_nodes $clients \
3530 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3531 awk '{total += $1} END{print total}'`
3534 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3535 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3536 awk '{total += $1} END{print total}'`
3538 # check whether client grant == server grant
3539 if [ $client_grant -ne $server_grant ]; then
3540 echo "failed: client:${client_grant} server: ${server_grant}."
3541 do_nodes $(comma_list $(osts_nodes)) \
3542 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3543 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3546 echo "pass: client:${client_grant} server: ${server_grant}"
3551 ########################
3557 ost=`echo $1 | awk -F_ '{print $3}'`
3558 if [ -z $ost ]; then
3559 ost=`echo $1 | sed 's/-osc.*//'`
3564 ostuuid_from_index()
3566 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
3569 ostname_from_index() {
3570 local uuid=$(ostuuid_from_index $1)
3574 index_from_ostuuid()
3576 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
3581 [ "$node" != "$(hostname)" ]
3587 for node in $(mdts_nodes); do
3588 remote_node $node && return 0
3595 [ "$CLIENTONLY" ] && return 0 || true
3596 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3601 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3602 MSKIPPED=1 && return 1
3609 for node in $(osts_nodes) ; do
3610 remote_node $node && return 0
3617 [ "$CLIENTONLY" ] && return 0 || true
3618 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3623 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3624 OSKIPPED=1 && return 1
3631 MGS=$(facet_host mgs)
3632 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3637 remote_mds_nodsh || remote_ost_nodsh || \
3638 $(single_local_node $(comma_list $(nodes_list)))
3644 for num in `seq $MDSCOUNT`; do
3645 MDSNODES="$MDSNODES $(facet_host mds$num)"
3647 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3653 remote_ost && remote_mds
3661 for facet in ${facets//,/ }; do
3662 if [ "$FAILURE_MODE" = HARD ]; then
3663 nodes="$nodes $(facet_active_host $facet)"
3665 nodes="$nodes $(facet_host $facet)"
3668 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3674 local facets=$(get_facets OST)
3675 local nodes=$(facets_nodes $facets)
3681 # FIXME. We need a list of clients
3682 local myNODES=$HOSTNAME
3685 # CLIENTS (if specified) contains the local client
3686 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3688 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3689 myNODES="$myNODES $(facets_nodes $(get_facets))"
3692 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3697 remote_nodes_list () {
3698 local rnodes=$(nodes_list)
3699 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3703 init_clients_lists () {
3704 # Sanity check: exclude the local client from RCLIENTS
3705 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3707 # Sanity check: exclude the dup entries
3708 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3710 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3712 # Sanity check: exclude the dup entries from CLIENTS
3713 # for those configs which has SINGLCLIENT set to local client
3714 clients=$(for i in $clients; do echo $i; done | sort -u)
3716 CLIENTS=`comma_list $clients`
3717 local -a remoteclients=($rclients)
3718 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3719 varname=CLIENT$((i + 2))
3720 eval $varname=${remoteclients[i]}
3723 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3726 get_random_entry () {
3729 rnodes=${rnodes//,/ }
3731 local -a nodes=($rnodes)
3732 local num=${#nodes[@]}
3733 local i=$((RANDOM * num * 2 / 65536))
3739 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3744 lctl get_param version | grep -q patchless
3748 [ "$(lustre_version_code client)" = "$(lustre_version_code $SINGLEMDS)" -a \
3749 "$(lustre_version_code client)" = "$(lustre_version_code ost1)" ]
3754 echo $nodes | wc -w || true
3758 local nodes=$(osts_nodes)
3759 local osscount=$(get_node_count "$nodes")
3760 [ ! "$OSTCOUNT" = "$osscount" ]
3764 local nodes=$(mdts_nodes)
3765 local mdtcount=$(get_node_count "$nodes")
3766 [ ! "$MDSCOUNT" = "$mdtcount" ]
3769 generate_machine_file() {
3770 local nodes=${1//,/ }
3771 local machinefile=$2
3773 for node in $nodes; do
3774 echo $node >>$machinefile || \
3775 { echo "can not generate machinefile $machinefile" && return 1; }
3780 local file=$1/stripe
3782 $LFS getstripe -v $file || error
3786 setstripe_nfsserver () {
3789 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3790 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3792 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3794 do_nodev $nfsserver lfs setstripe "$@"
3797 # Check and add a test group.
3803 local gid=$(getent group $group_name | cut -d: -f3)
3804 if [[ -n "$gid" ]]; then
3805 [[ "$gid" -eq "$group_id" ]] || {
3806 error_noexit "inconsistent group ID:" \
3807 "new: $group_id, old: $gid"
3811 groupadd -g $group_id $group_name
3818 # Check and add a test user.
3831 local uid=$(getent passwd $user_name | cut -d: -f3)
3832 if [[ -n "$uid" ]]; then
3833 if [[ "$uid" -eq "$user_id" ]]; then
3834 local dir=$(getent passwd $user_name | cut -d: -f6)
3835 if [[ "$dir" != "$home" ]]; then
3837 usermod -d $home $user_name
3841 error_noexit "inconsistent user ID:" \
3842 "new: $user_id, old: $uid"
3847 useradd -M -u $user_id -d $home -g $group_name $opts $user_name
3854 check_runas_id_ret() {
3856 local myRUNAS_UID=$1
3857 local myRUNAS_GID=$2
3860 if [ -z "$myRUNAS" ]; then
3861 error_exit "myRUNAS command must be specified for check_runas_id"
3864 $myRUNAS krb5_login.sh || \
3865 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3867 mkdir $DIR/d0_runas_test
3869 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3870 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3871 rm -rf $DIR/d0_runas_test
3876 local myRUNAS_UID=$1
3877 local myRUNAS_GID=$2
3880 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3881 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3882 Please set RUNAS_ID to some UID which exists on MDS and client or
3883 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3886 # obtain the UID/GID for MPI_USER
3890 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3891 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3893 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3894 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3897 # obtain and cache Kerberos ticket-granting ticket
3898 refresh_krb5_tgt() {
3899 local myRUNAS_UID=$1
3900 local myRUNAS_GID=$2
3903 if [ -z "$myRUNAS" ]; then
3904 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3907 CLIENTS=${CLIENTS:-$HOSTNAME}
3908 do_nodes $CLIENTS "set -x
3909 if ! $myRUNAS krb5_login.sh; then
3910 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3915 # Run multiop in the background, but wait for it to print
3916 # "PAUSING" to its stdout before returning from this function.
3917 multiop_bg_pause() {
3918 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3922 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3925 echo "$MULTIOP_PROG $FILE v$ARGS"
3926 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3928 echo "TMPPIPE=${TMPPIPE}"
3929 read -t 60 multiop_output < $TMPPIPE
3930 if [ $? -ne 0 ]; then
3935 if [ "$multiop_output" != "PAUSING" ]; then
3936 echo "Incorrect multiop output: $multiop_output"
3951 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3957 inodes_available () {
3958 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3962 mdsrate_inodes_available () {
3963 local min_inodes=$(inodes_available)
3964 echo $((min_inodes * 99 / 100))
3967 # reset llite stat counters
3968 clear_llite_stats(){
3969 lctl set_param -n llite.*.stats 0
3972 # sum llite stat items
3973 calc_llite_stats() {
3974 local res=$(lctl get_param -n llite.*.stats |
3975 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3979 # reset osc stat counters
3981 lctl set_param -n osc.*.osc_stats 0
3984 # sum osc stat items
3986 local res=$(lctl get_param -n osc.*.osc_stats |
3987 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3992 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3995 calc_osc_kbytes () {
3996 df $MOUNT > /dev/null
3997 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
4000 # save_lustre_params(node, parameter_mask)
4001 # generate a stream of formatted strings (<node> <param name>=<param value>)
4002 save_lustre_params() {
4004 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
4007 # restore lustre parameters from input stream, produces by save_lustre_params
4008 restore_lustre_params() {
4012 while IFS=" =" read node name val; do
4013 do_node ${node//:/} "lctl set_param -n $name $val"
4017 check_catastrophe() {
4018 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
4019 local C=$CATASTROPHE
4020 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
4022 if [ $rnodes ]; then
4023 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
4024 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
4040 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
4042 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
4043 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
4044 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
4048 # CMD: determine mds index where directory inode presents
4051 local file=$dir/f0.get_mds_dir_tmpfile
4056 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
4057 local -a oldused=($iused)
4059 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
4061 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
4062 local -a newused=($iused)
4065 for ((i=0; i<${#newused[@]}; i++)); do
4066 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
4072 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
4075 mdsrate_cleanup () {
4077 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
4082 delayed_recovery_enabled () {
4083 local var=${SINGLEMDS}_svc
4084 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
4087 ########################
4089 convert_facet2label() {
4092 if [ x$facet = xost ]; then
4096 local varsvc=${facet}_svc
4098 if [ -n ${!varsvc} ]; then
4101 error "No lablel for $facet!"
4105 get_clientosc_proc_path() {
4109 echo "${1}-osc-[!M]*"
4112 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
4113 # used by MDT would not be changed.
4114 # mdt lov: fsname-mdtlov
4115 # mdt osc: fsname-OSTXXXX-osc
4116 mds_on_old_device() {
4117 local mds=${1:-"$SINGLEMDS"}
4119 if [ $(lustre_version_code $mds) -gt $(version_code 1.9.0) ]; then
4120 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
4121 > /dev/null 2>&1" && return 0
4126 get_mdtosc_proc_path() {
4128 local ost_label=${2:-"*OST*"}
4130 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
4131 local mdt_label=$(convert_facet2label $mds_facet)
4132 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
4134 if [ $(lustre_version_code $mds_facet) -le $(version_code 1.8.0) ] ||
4135 mds_on_old_device $mds_facet; then
4136 echo "${ost_label}-osc"
4138 echo "${ost_label}-osc-${mdt_index}"
4142 get_osc_import_name() {
4145 local label=$(convert_facet2label $ost)
4147 if [ "${facet:0:3}" = "mds" ]; then
4148 get_mdtosc_proc_path $facet $label
4152 get_clientosc_proc_path $label
4156 _wait_import_state () {
4159 local maxtime=${3:-$(max_recovery_time)}
4163 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
4164 while [ "${CONN_STATE}" != "${expected}" ]; do
4165 if [ "${expected}" == "DISCONN" ]; then
4166 # for disconn we can check after proc entry is removed
4167 [ "x${CONN_STATE}" == "x" ] && return 0
4168 # with AT enabled, we can have connect request timeout near of
4169 # reconnect timeout and test can't see real disconnect
4170 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
4172 [ $i -ge $maxtime ] && \
4173 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
4176 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
4180 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
4184 wait_import_state() {
4187 local maxtime=${3:-$(max_recovery_time)}
4190 for param in ${params//,/ }; do
4191 _wait_import_state $state $param $maxtime || return
4195 # One client request could be timed out because server was not ready
4196 # when request was sent by client.
4197 # The request timeout calculation details :
4199 # /* We give the server rq_timeout secs to process the req, and
4200 # add the network latency for our local timeout. */
4201 # request->rq_deadline = request->rq_sent + request->rq_timeout +
4202 # ptlrpc_at_get_net_latency(request) ;
4204 # ptlrpc_connect_import ()
4205 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
4208 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
4209 # ptlrpc_at_get_net_latency(request) ->
4210 # at_get (max (iat_net_latency=0, at_min)) = at_min
4213 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
4214 # INITIAL_CONNECT_TIMEOUT + at_min
4216 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
4217 # because we can not get this value in runtime,
4218 # the value depends on configure options, and it is not stored in /proc.
4220 # #define CONNECTION_SWITCH_MIN 5U
4222 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4224 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/2)
4226 request_timeout () {
4229 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
4230 local init_connect_timeout=$TIMEOUT
4231 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
4233 local at_min=$(at_get $facet at_min)
4235 echo $((init_connect_timeout + at_min))
4238 wait_osc_import_state() {
4242 local ost=$(get_osc_import_name $facet $ost_facet)
4244 local param="osc.${ost}.ost_server_uuid"
4246 # 1. wait the deadline of client 1st request (it could be skipped)
4247 # 2. wait the deadline of client 2nd request
4248 local maxtime=$(( 2 * $(request_timeout $facet)))
4250 if ! do_rpc_nodes $(facet_host $facet) \
4251 _wait_import_state $expected $param $maxtime; then
4252 error "import is not in ${expected} state"
4259 get_clientmdc_proc_path() {
4267 # Add paths to lustre tests for 32 and 64 bit systems.
4268 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
4269 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
4272 wait_clients_import_state () {
4279 if [ "$FAILURE_MODE" = HARD ]; then
4280 facets=$(facets_on_host $(facet_active_host $facet))
4283 for facet in ${facets//,/ }; do
4284 local label=$(convert_facet2label $facet)
4287 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
4288 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
4289 *) error "unknown facet!" ;;
4291 local params=$(expand_list $params $proc_path)
4294 if ! do_rpc_nodes $list wait_import_state $expected $params; then
4295 error "import is not in ${expected} state"
4304 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
4305 $LCTL get_param obdfilter.*.kbytesavail))
4306 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
4307 $LCTL get_param -n obdfilter.*.tot_granted))
4308 for ((i=0; i<${#AVAILA[@]}; i++)); do
4309 local -a AVAIL1=(${AVAILA[$i]//=/ })
4310 GRANT=$((${GRANTA[$i]}/1024))
4311 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
4312 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
4318 do_facet mgs lctl pool_list $1
4322 local fsname=${1%%.*}
4323 local poolname=${1##$fsname.}
4325 do_facet mgs lctl pool_new $1
4327 # get param should return err unless pool is created
4328 [[ $RC -ne 0 ]] && return $RC
4330 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
4331 2>/dev/null || echo foo" "" || RC=1
4332 if [[ $RC -eq 0 ]]; then
4335 error "pool_new failed $1"
4340 add_pool_to_list () {
4341 local fsname=${1%%.*}
4342 local poolname=${1##$fsname.}
4344 local listvar=${fsname}_CREATED_POOLS
4345 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
4348 remove_pool_from_list () {
4349 local fsname=${1%%.*}
4350 local poolname=${1##$fsname.}
4352 local listvar=${fsname}_CREATED_POOLS
4353 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
4356 destroy_pool_int() {
4358 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
4359 awk '$1 !~ /^Pool:/ {print $1}')
4360 for ost in $OSTS; do
4361 do_facet mgs lctl pool_remove $1 $ost
4363 do_facet mgs lctl pool_destroy $1
4366 # <fsname>.<poolname> or <poolname>
4368 local fsname=${1%%.*}
4369 local poolname=${1##$fsname.}
4371 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
4375 pool_list $fsname.$poolname || return $?
4377 destroy_pool_int $fsname.$poolname
4379 [[ $RC -ne 0 ]] && return $RC
4381 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
4382 2>/dev/null || echo foo" "foo" || RC=1
4384 if [[ $RC -eq 0 ]]; then
4385 remove_pool_from_list $fsname.$poolname
4387 error "destroy pool failed $1"
4393 local fsname=${1:-$FSNAME}
4395 local listvar=${fsname}_CREATED_POOLS
4399 [ x${!listvar} = x ] && return 0
4401 echo destroy the created pools: ${!listvar}
4402 for poolname in ${!listvar//,/ }; do
4403 destroy_pool $fsname.$poolname
4408 local fsname=${1:-$FSNAME}
4410 destroy_pools $fsname
4416 local ts=$(date +%s)
4419 if [[ ! -f "$YAML_LOG" ]]; then
4420 # init_logging is not performed before gather_logs,
4421 # so the $LOGDIR needs to be checked here
4422 check_shared_dir $LOGDIR && touch $LOGDIR/shared
4425 [ -f $LOGDIR/shared ] && docp=false
4427 # dump lustre logs, dmesg
4429 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4431 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4433 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4434 echo "Dumping logs only on local client."
4435 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
4436 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
4441 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
4442 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
4444 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4457 for i in $(seq 0 $num_mntpts); do
4458 cmd="ls -laf ${mntpt_root}$i/$dir"
4464 for pid in $pids; do
4471 # target_start_and_reset_recovery_timer()
4472 # service_time = at_est2timeout(service_time);
4473 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4474 # INITIAL_CONNECT_TIMEOUT);
4475 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4476 #define CONNECTION_SWITCH_INC 1
4477 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4478 #define CONNECTION_SWITCH_MIN 5U
4480 max_recovery_time () {
4481 local init_connect_timeout=$((TIMEOUT / 20))
4482 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
4484 local service_time=$(($(at_max_get client) +
4485 $((2 * $((25 + 1 + init_connect_timeout))))))
4490 get_clients_mount_count () {
4491 local clients=${CLIENTS:-`hostname`}
4493 # we need to take into account the clients mounts and
4494 # exclude mds/ost mounts if any;
4495 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4499 PROC_CLI="srpc_info"
4507 if [ $M -lt $N ]; then
4511 while [ $N -lt $M ]; do
4521 calc_connection_cnt() {
4524 # MDT->MDT = 2 * C(M, 2)
4528 comb_m2=$(combination $MDSCOUNT 2)
4530 local num_clients=$(get_clients_mount_count)
4532 local cnt_mdt2mdt=$((comb_m2 * 2))
4533 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4534 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4535 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4536 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4537 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4538 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4552 local cmd="$tgt.srpc.flavor"
4554 if [ $net == "any" ]; then
4559 if [ $dir != "any" ]; then
4564 log "Setting sptlrpc rule: $cmd"
4565 do_facet mgs "$LCTL conf_param $cmd"
4574 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4575 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4577 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4579 if [ "x$bulkspec" != "x" ]; then
4580 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4582 if [ "x$algs" != "x" ]; then
4583 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4585 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4586 if [ $bulk == "bulkn" ]; then
4587 bulk_count=`echo "$output" | grep "bulk flavor" \
4588 | grep "null/null" | wc -l`
4589 elif [ $bulk == "bulki" ]; then
4590 bulk_count=`echo "$output" | grep "bulk flavor" \
4591 | grep "/null" | grep -v "null/" | wc -l`
4593 bulk_count=`echo "$output" | grep "bulk flavor" \
4594 | grep -v "/null" | grep -v "null/" | wc -l`
4598 [ $bulk_count -lt $count ] && count=$bulk_count
4609 local clients=${CLIENTS:-`hostname`}
4611 for c in ${clients//,/ }; do
4612 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4613 tmpcnt=`count_flvr "$output" $flavor`
4614 cnt=$((cnt + tmpcnt))
4624 local clients=${CLIENTS:-`hostname`}
4626 for c in ${clients//,/ }; do
4627 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4628 tmpcnt=`count_flvr "$output" $flavor`
4629 cnt=$((cnt + tmpcnt))
4639 if [ $MDSCOUNT -le 1 ]; then
4644 for num in `seq $MDSCOUNT`; do
4645 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4646 tmpcnt=`count_flvr "$output" $flavor`
4647 cnt=$((cnt + tmpcnt))
4658 for num in `seq $MDSCOUNT`; do
4659 mdtosc=$(get_mdtosc_proc_path mds$num)
4660 mdtosc=${mdtosc/-MDT*/-MDT\*}
4661 output=$(do_facet mds$num lctl get_param -n \
4662 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4663 tmpcnt=`count_flvr "$output" $flavor`
4664 cnt=$((cnt + tmpcnt))
4673 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4674 count_flvr "$output" $flavor
4679 local dir=$1 # from to
4680 local flavor=$2 # flavor expected
4683 if [ $dir == "cli2mdt" ]; then
4684 res=`flvr_cnt_cli2mdt $flavor`
4685 elif [ $dir == "cli2ost" ]; then
4686 res=`flvr_cnt_cli2ost $flavor`
4687 elif [ $dir == "mdt2mdt" ]; then
4688 res=`flvr_cnt_mdt2mdt $flavor`
4689 elif [ $dir == "mdt2ost" ]; then
4690 res=`flvr_cnt_mdt2ost $flavor`
4691 elif [ $dir == "all2ost" ]; then
4692 res1=`flvr_cnt_mdt2ost $flavor`
4693 res2=`flvr_cnt_cli2ost $flavor`
4694 res=$((res1 + res2))
4695 elif [ $dir == "all2mdt" ]; then
4696 res1=`flvr_cnt_mdt2mdt $flavor`
4697 res2=`flvr_cnt_cli2mdt $flavor`
4698 res=$((res1 + res2))
4699 elif [ $dir == "all2all" ]; then
4700 res1=`flvr_cnt_mdt2ost $flavor`
4701 res2=`flvr_cnt_cli2ost $flavor`
4702 res3=`flvr_cnt_mdt2mdt $flavor`
4703 res4=`flvr_cnt_cli2mdt $flavor`
4704 res=$((res1 + res2 + res3 + res4))
4712 local dir=$1 # from to
4713 local flavor=$2 # flavor expected
4714 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4718 for ((i=0;i<20;i++)); do
4719 echo -n "checking $dir..."
4720 res=$(do_check_flavor $dir $flavor)
4721 echo "found $res/$expect $flavor connections"
4722 [ $res -ge $expect ] && return 0
4726 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4730 restore_to_default_flavor()
4732 local proc="mgs.MGS.live.$FSNAME"
4734 echo "restoring to default flavor..."
4736 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4738 # remove all existing rules if any
4739 if [ $nrule -ne 0 ]; then
4740 echo "$nrule existing rules"
4741 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4742 echo "remove rule: $rule"
4743 spec=`echo $rule | awk -F = '{print $1}'`
4744 do_facet mgs "$LCTL conf_param -d $spec"
4748 # verify no rules left
4749 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4750 [ $nrule -ne 0 ] && error "still $nrule rules left"
4752 # wait for default flavor to be applied
4753 # currently default flavor for all connections are 'null'
4754 wait_flavor all2all null
4755 echo "now at default flavor settings"
4760 local flavor=${1:-null}
4762 echo "setting all flavor to $flavor"
4764 # FIXME need parameter to this fn
4765 # and remove global vars
4766 local cnt_all2all=$(calc_connection_cnt all2all)
4768 local res=$(do_check_flavor all2all $flavor)
4769 if [ $res -eq $cnt_all2all ]; then
4770 echo "already have total $res $flavor connections"
4774 echo "found $res $flavor out of total $cnt_all2all connections"
4775 restore_to_default_flavor
4777 [[ $flavor = null ]] && return 0
4779 set_rule $FSNAME any any $flavor
4780 wait_flavor all2all $flavor
4786 # Checking for shared logdir
4787 if [ ! -d $dir ]; then
4788 # Not found. Create local logdir
4791 touch $dir/check_file.$(hostname -s)
4796 check_write_access() {
4801 for node in $(nodes_list); do
4802 file=$dir/check_file.$(short_hostname $node)
4803 if [[ ! -f "$file" ]]; then
4804 # Logdir not accessible/writable from this node.
4807 rm -f $file || return 1
4813 if [[ -n $YAML_LOG ]]; then
4816 local SAVE_UMASK=`umask`
4819 export YAML_LOG=${LOGDIR}/results.yml
4823 if check_shared_dir $LOGDIR; then
4824 touch $LOGDIR/shared
4825 echo "Logging to shared log directory: $LOGDIR"
4827 echo "Logging to local directory: $LOGDIR"
4830 yml_nodes_file $LOGDIR >> $YAML_LOG
4831 yml_results_file >> $YAML_LOG
4837 yml_log_test $1 >> $YAML_LOG
4841 yml_log_test_status $@ >> $YAML_LOG
4844 log_sub_test_begin() {
4845 yml_log_sub_test_begin "$@" >> $YAML_LOG
4848 log_sub_test_end() {
4849 yml_log_sub_test_end "$@" >> $YAML_LOG
4855 local llverdev_opts=$2
4856 local devname=$(basename $1)
4857 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4858 # loop devices aren't in /proc/partitions
4859 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4861 size=$(($size / 1024 / 1024)) # Gb
4863 local partial_arg=""
4864 # Run in partial (fast) mode if the size
4865 # of a partition > 1 GB
4866 [ $size -gt 1 ] && partial_arg="-p"
4868 llverdev --force $partial_arg $llverdev_opts $dev
4874 local llverfs_opts=$2
4875 local partial_arg=""
4876 local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
4878 # Run in partial (fast) mode if the size
4879 # of a partition > 1 GB
4880 [ $size -gt 1 ] && partial_arg="-p"
4882 llverfs $partial_arg $llverfs_opts $dir
4885 remove_mdt_files() {
4890 local mntpt=${MOUNT%/*}/$facet
4892 echo "removing files from $mdtdev on $facet: $files"
4893 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4896 rm $mntpt/ROOT/$f || { rc=$?; break; }
4898 umount -f $mntpt || return $?
4902 duplicate_mdt_files() {
4907 local mntpt=${MOUNT%/*}/$facet
4909 echo "duplicating files on $mdtdev on $facet: $files"
4910 mkdir -p $mntpt || return $?
4911 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4921 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4922 pushd $mntpt/ROOT > /dev/null || return $?
4925 touch $f.bad || return $?
4926 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4928 [ $rc -eq 0 ] || return $rc
4929 setfattr --restore $tmp || return $?
4935 local devs=${1//,/ }
4938 local rslt=$TMP/sgpdd_survey
4940 # sgpdd-survey cleanups ${rslt}.* files
4942 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4948 # returns the canonical name for an ldiskfs device
4953 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4954 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4955 echo dm-\\\${foo##*:};
4957 echo \\\$(basename \\\$dv);
4961 is_sanity_benchmark() {
4962 local benchmarks="dbench bonnie iozone fsx"
4964 for b in $benchmarks; do
4965 if [ "$b" == "$suite" ]; then
4973 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1