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 # This is used by a small number of tests to share state between the client
129 # running the tests, or in some cases between the servers (e.g. lfsck.sh).
130 # It needs to be a non-lustre filesystem that is available on all the nodes.
131 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
132 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
133 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
135 #[ -d /r ] && export ROOT=${ROOT:-/r}
136 export TMP=${TMP:-$ROOT/tmp}
137 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
138 if [[ -z $LOGDIRSET ]]; then
139 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
140 export LOGDIRSET=true
142 export HOSTNAME=${HOSTNAME:-$(hostname -s)}
143 if ! echo $PATH | grep -q $LUSTRE/utils; then
144 export PATH=$LUSTRE/utils:$PATH
146 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
147 export PATH=$LUSTRE/utils/gss:$PATH
149 if ! echo $PATH | grep -q $LUSTRE/tests; then
150 export PATH=$LUSTRE/tests:$PATH
152 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
153 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
155 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
156 [ ! -f "$LST" ] && export LST=$(which lst)
157 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
158 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
159 # Ubuntu, at least, has a truncate command in /usr/bin
160 # so fully path our truncate command.
161 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
162 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
163 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
164 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
165 export PATH=$LUSTRE/tests/racer:$PATH:
167 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
168 export PATH=$LUSTRE/tests/mpi:$PATH
170 export RSYNC_RSH=${RSYNC_RSH:-rsh}
171 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
172 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
173 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
174 [ ! -f "$LFS" ] && export LFS=$(which lfs)
175 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
176 if [ ! -f "$L_GETIDENTITY" ]; then
177 if `which l_getidentity > /dev/null 2>&1`; then
178 export L_GETIDENTITY=$(which l_getidentity)
180 export L_GETIDENTITY=NONE
183 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
184 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID=$(which ll_decode_filter_fid)
185 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
186 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
187 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
188 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
189 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
190 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
191 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
192 export FSTYPE=${FSTYPE:-"ldiskfs"}
193 export NAME=${NAME:-local}
194 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
195 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
196 export LGSSD=$(which lgssd)
197 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
198 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
199 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
201 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
204 if [ "$ACCEPTOR_PORT" ]; then
205 export PORT_OPT="--port $ACCEPTOR_PORT"
210 echo "Using GSS/krb5 ptlrpc security flavor"
211 which lgss_keyring > /dev/null 2>&1 || \
212 error_exit "built with gss disabled! SEC=$SEC"
223 IDENTITY_UPCALL=false
226 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
228 # Paths on remote nodes, if different
229 export RLUSTRE=${RLUSTRE:-$LUSTRE}
230 export RPWD=${RPWD:-$PWD}
231 export I_MOUNTED=${I_MOUNTED:-"no"}
232 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
233 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
234 ! -f `dirname $0`/../mds/mds.ko ]; then
235 export CLIENTMODSONLY=yes
238 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
242 while getopts "rvwf:" opt $*; do
245 r) REFORMAT=--reformat;;
247 w) WRITECONF=writeconf;;
252 shift $((OPTIND - 1))
255 # print the durations of each test if "true"
256 DDETAILS=${DDETAILS:-false}
257 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
262 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
263 *) EXT=".ko"; USE_QUOTA=yes;;
268 /sbin/lsmod | grep -q "^\<$1\>"
271 # Load a module on the system where this is running.
273 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
275 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
276 # will be used as the arguments. Otherwise arguments will be obtained from
277 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
284 BASE=`basename $module $EXT`
286 module_loaded ${BASE} && return
288 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
290 if [ $# -eq 0 ]; then
291 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
292 # Bash until 4.x, so we resort to eval.
293 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
294 eval set -- \$$optvar
295 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
296 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
297 set -- $(grep -P "^options\\s+${BASE}" $MODPROBECONF)
298 # Get rid of "options $module"
299 (($# > 0)) && shift 2
301 # Ensure we have accept=all for lnet
302 if [ $(basename $module) = lnet ]; then
303 # OK, this is a bit wordy...
304 local arg accept_all_present=false
306 [ "$arg" = accept=all ] && accept_all_present=true
308 $accept_all_present || set -- "$@" accept=all
313 [ $# -gt 0 ] && echo "${module} options: '$*'"
315 # Note that insmod will ignore anything in modprobe.conf, which is why we're
316 # passing options on the command-line.
317 if [ "$BASE" == "lnet_selftest" ] && \
318 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
319 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
320 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
321 insmod ${LUSTRE}/${module}${EXT} "$@"
323 # must be testing a "make install" or "rpm" installation
324 # note failed to load ptlrpc_gss is considered not fatal
325 if [ "$BASE" == "ptlrpc_gss" ]; then
326 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
333 llite_lloop_enabled() {
334 local n1=$(uname -r | cut -d. -f1)
335 local n2=$(uname -r | cut -d. -f2)
336 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
338 # load the llite_lloop module for < 2.6.32 kernels
339 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
340 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
347 load_modules_local() {
348 if [ -n "$MODPROBE" ]; then
350 echo "Using modprobe to load modules"
354 echo Loading modules from $LUSTRE
355 load_module ../libcfs/libcfs/libcfs
356 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
357 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
358 load_module ../lnet/lnet/lnet
359 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
360 load_module ../lnet/klnds/$LNETLND
361 load_module lvfs/lvfs
362 load_module obdclass/obdclass
363 load_module ptlrpc/ptlrpc
364 load_module ptlrpc/gss/ptlrpc_gss
365 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
373 if ! client_only; then
374 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
375 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
376 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
377 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
382 load_module lvfs/fsfilt_$FSTYPE
384 load_module osd-ldiskfs/osd_ldiskfs
386 load_module obdfilter/obdfilter
390 load_module llite/lustre
391 llite_lloop_enabled && load_module llite/llite_lloop
392 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
394 rm -f $OGDB/ogdb-$HOSTNAME
395 $LCTL modules > $OGDB/ogdb-$HOSTNAME
397 # 'mount' doesn't look in $PATH, just sbin
398 if [ -f $LUSTRE/utils/mount.lustre ] && \
399 ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
400 [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
401 mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
408 # load modules on remote nodes optionally
409 # lustre-tests have to be installed on these nodes
410 if $LOAD_MODULES_REMOTE ; then
411 local list=$(comma_list $(remote_nodes_list))
412 echo loading modules on $list
413 do_rpc_nodes $list load_modules
418 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
419 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
420 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
421 echo "$LEAK_LUSTRE" 1>&2
422 echo "$LEAK_PORTALS" 1>&2
423 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
424 echo "Memory leaks detected"
425 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
431 wait_exit_ST client # bug 12845
433 $LUSTRE_RMMOD $FSTYPE || return 2
435 if $LOAD_MODULES_REMOTE ; then
436 local list=$(comma_list $(remote_nodes_list))
437 if [ ! -z $list ]; then
438 echo unloading modules on $list
439 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
440 do_rpc_nodes $list check_mem_leak
444 if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
445 umount /sbin/mount.lustre || true
446 [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
447 rm -f /sbin/mount.lustre || true
450 check_mem_leak || return 254
452 echo "modules unloaded."
456 check_gss_daemon_nodes() {
460 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
461 if [ \\\"\\\$num\\\" -ne 1 ]; then
462 echo \\\$num instance of $dname;
467 check_gss_daemon_facet() {
471 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
472 if [ $num -ne 1 ]; then
473 echo "$num instance of $dname on $facet"
482 echo Stopping $@ on $list
483 do_nodes $list "killall -2 $@ 2>/dev/null || true"
486 # start gss daemons on all nodes, or
487 # "daemon" on "list" if set
488 start_gss_daemons() {
492 if [ "$list" ] && [ "$daemon" ] ; then
493 echo "Starting gss daemon on nodes: $list"
494 do_nodes $list "$daemon" || return 8
498 local list=$(comma_list $(mdts_nodes))
500 echo "Starting gss daemon on mds: $list"
501 do_nodes $list "$LSVCGSSD -v" || return 1
503 do_nodes $list "$LGSSD -v" || return 2
506 list=$(comma_list $(osts_nodes))
507 echo "Starting gss daemon on ost: $list"
508 do_nodes $list "$LSVCGSSD -v" || return 3
509 # starting on clients
511 local clients=${CLIENTS:-`hostname`}
513 echo "Starting $LGSSD on clients $clients "
514 do_nodes $clients "$LGSSD -v" || return 4
517 # wait daemons entering "stable" status
521 # check daemons are running
523 list=$(comma_list $(mdts_nodes) $(osts_nodes))
524 check_gss_daemon_nodes $list lsvcgssd || return 5
526 list=$(comma_list $(mdts_nodes))
527 check_gss_daemon_nodes $list lgssd || return 6
530 check_gss_daemon_nodes $clients lgssd || return 7
535 local list=$(comma_list $(mdts_nodes))
537 send_sigint $list lsvcgssd lgssd
539 list=$(comma_list $(osts_nodes))
540 send_sigint $list lsvcgssd
542 list=${CLIENTS:-`hostname`}
543 send_sigint $list lgssd
548 if ! module_loaded ptlrpc_gss; then
549 load_module ptlrpc/gss/ptlrpc_gss
550 module_loaded ptlrpc_gss ||
551 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
553 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
555 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
556 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
564 # maybe cleanup credential cache?
570 local device=`mdsdevname $num`
571 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
577 local device=`ostdevname $num`
578 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
583 local dz=${1:-$DEBUG_SIZE}
584 local cpus=$(getconf _NPROCESSORS_CONF)
586 # bug 19944, adjust size to be -gt num_possible_cpus()
587 # promise 2MB for every cpu at least
588 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
591 lctl set_param debug_mb=$dz
594 set_default_debug () {
595 local debug=${1:-"$PTLDEBUG"}
596 local subsystem_debug=${2:-"$SUBSYSTEM"}
597 local debug_size=${3:-$DEBUG_SIZE}
599 lctl set_param debug="$debug"
600 lctl set_param subsystem_debug="${subsystem_debug# }"
602 set_debug_size $debug_size
606 set_default_debug_nodes () {
609 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
610 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
614 [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
615 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
618 set_default_debug_facet () {
620 local node=$(facet_active_host $facet)
621 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
623 set_default_debug_nodes $node
628 local facets=${1:-$(get_facets)}
631 for facet in ${facets//,/ }; do
632 mount_facet $facet || error "Restart of $facet failed!"
639 local dev=$(facet_active $facet)_dev
640 local opt=${facet}_opt
641 local mntpt=$(facet_mntpt $facet)
643 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
644 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
646 if [ $RC -ne 0 ]; then
647 echo "mount -t lustre $@ ${!dev} $mntpt"
648 echo "Start of ${!dev} on ${facet} failed ${RC}"
650 set_default_debug_facet $facet
652 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
653 [ -z "$label" ] && echo no label for ${!dev} && exit 1
654 eval export ${facet}_svc=${label}
655 echo Started ${label}
660 # start facet device options
666 eval export ${facet}_dev=${device}
667 eval export ${facet}_opt=\"$@\"
669 local varname=${facet}failover_dev
670 if [ -n "${!varname}" ] ; then
671 eval export ${facet}failover_dev=${!varname}
673 eval export ${facet}failover_dev=$device
676 local mntpt=$(facet_mntpt $facet)
677 do_facet ${facet} mkdir -p $mntpt
678 eval export ${facet}_MOUNT=$mntpt
688 local HOST=`facet_active_host $facet`
689 [ -z $HOST ] && echo stop: no host for $facet && return 0
691 local mntpt=$(facet_mntpt $facet)
692 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
693 if [ ${running} -ne 0 ]; then
694 echo "Stopping $mntpt (opts:$@) on $HOST"
695 do_facet ${facet} umount -d $@ $mntpt
698 # umount should block, but we should wait for unrelated obd's
699 # like the MGS or MGC to also stop.
700 wait_exit_ST ${facet}
703 # save quota version (both administrative and operational quotas)
704 # add an additional parameter if mountpoint is ever different from $MOUNT
705 quota_save_version() {
706 local fsname=${2:-$FSNAME}
708 local ver=$(tr -c -d "123" <<< $spec)
709 local type=$(tr -c -d "ug" <<< $spec)
711 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
713 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
715 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
717 local osts=$(get_facets OST)
718 for ost in ${osts//,/ }; do
720 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
724 # client could mount several lustre
726 local fsname=${1:-$FSNAME}
728 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
729 do_nodes $(comma_list $(osts_nodes)) \
730 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
734 restore_quota_type () {
735 local mntpt=${1:-$MOUNT}
736 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
737 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
740 quota_save_version $old_QUOTA_TYPE
746 # We need save the original quota_type params, and restore them after testing
748 # Suppose that quota type the same on mds and ost
749 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
750 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
751 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
752 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
753 export old_QUOTA_TYPE=$quota_type
754 quota_save_version $QUOTA_TYPE
756 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
757 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
760 local quota_usrs=$QUOTA_USERS
762 # get_filesystem_size
763 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
764 local blk_soft=$((disksz + 1024))
765 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
767 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
769 local i_hard=$((i_soft + i_soft / 20))
771 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
772 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
775 for usr in $quota_usrs; do
776 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
778 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
780 eval $cmd || error "$cmd FAILED!"
782 # display the quota status
783 echo "Quota settings for $usr : "
784 $LFS quota -v -u $usr $mntpt || true
791 local OPTIONS=${3:-$MOUNTOPT}
793 local device=$MGSNID:/$FSNAME
794 if [ -z "$mnt" -o -z "$FSNAME" ]; then
795 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
799 echo "Starting client: $client: $OPTIONS $device $mnt"
800 do_node $client mkdir -p $mnt
801 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
803 set_default_debug_nodes $client
816 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
817 if [ $running -ne 0 ]; then
818 echo "Stopping client $client $mnt (opts:$force)"
819 do_node $client lsof -t $mnt || need_kill=no
820 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
821 pids=$(do_node $client lsof -t $mnt | sort -u);
822 if [ -n $pids ]; then
823 do_node $client kill -9 $pids || true
827 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
828 if [ $busy -ne 0 ] ; then
829 echo "$mnt is still busy, wait one second" && sleep 1
830 do_node $client umount $force $mnt
835 # nodes is comma list
836 sanity_mount_check_nodes () {
842 # FIXME: assume that all cluster nodes run the same os
843 [ "$(uname)" = Linux ] || return 0
846 for mnt in $mnts ; do
847 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
848 mpts=\\\$(mount | grep -w -c $mnt);
849 if [ \\\$running -ne \\\$mpts ]; then
850 echo \\\$(hostname) env are INSANE!;
858 sanity_mount_check_servers () {
860 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
861 echo Checking servers environments
863 # FIXME: modify get_facets to display all facets wo params
864 local facets="$(get_facets OST),$(get_facets MDS),mgs"
868 for facet in ${facets//,/ }; do
869 node=$(facet_host ${facet})
870 mntpt=$(facet_mntpt $facet)
871 sanity_mount_check_nodes $node $mntpt ||
872 { error "server $node environments are insane!"; return 1; }
876 sanity_mount_check_clients () {
877 local clients=${1:-$CLIENTS}
878 local mntpt=${2:-$MOUNT}
879 local mntpt2=${3:-$MOUNT2}
881 [ -z $clients ] && clients=$(hostname)
882 echo Checking clients $clients environments
884 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
885 error "clients environments are insane!"
888 sanity_mount_check () {
889 sanity_mount_check_servers || return 1
890 sanity_mount_check_clients || return 2
893 # mount clients if not mouted
894 zconf_mount_clients() {
897 local OPTIONS=${3:-$MOUNTOPT}
899 local device=$MGSNID:/$FSNAME
900 if [ -z "$mnt" -o -z "$FSNAME" ]; then
901 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
905 echo "Starting client $clients: $OPTIONS $device $mnt"
908 running=\\\$(mount | grep -c $mnt' ');
910 if [ \\\$running -eq 0 ] ; then
912 mount -t lustre $OPTIONS $device $mnt;
915 exit \\\$rc" || return ${PIPESTATUS[0]}
917 echo "Started clients $clients: "
918 do_nodes $clients "mount | grep -w $mnt"
920 set_default_debug_nodes $clients
925 zconf_umount_clients() {
932 echo "Stopping clients: $clients $mnt (opts:$force)"
933 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
934 if [ \\\$running -ne 0 ] ; then
935 echo Stopping client \\\$(hostname) $mnt opts:$force;
936 lsof -t $mnt || need_kill=no;
937 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
938 pids=\\\$(lsof -t $mnt | sort -u);
939 if [ -n \\\"\\\$pids\\\" ]; then
943 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
944 if [ \\\$busy -ne 0 ] ; then
945 echo "$mnt is still busy, wait one second" && sleep 1;
953 echo + $POWER_DOWN $node
957 shutdown_node_hard () {
959 local attempts=$SHUTDOWN_ATTEMPTS
961 for i in $(seq $attempts) ; do
964 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
965 echo "waiting for $host to fail attempts=$attempts"
966 [ $i -lt $attempts ] || \
967 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
973 local mnt=${2:-$MOUNT}
976 if [ "$FAILURE_MODE" = HARD ]; then
977 shutdown_node_hard $client
979 zconf_umount_clients $client $mnt -f
985 local facets="$(get_facets OST),$(get_facets MDS)"
988 combined_mgs_mds || facets="$facets,mgs"
990 for facet in ${facets//,/ }; do
991 if [ $(facet_active_host $facet) == $host ]; then
992 affected="$affected $facet"
996 echo $(comma_list $affected)
1001 local host=${2:-$(facet_host $facet)}
1003 local label=$(convert_facet2label $facet)
1004 do_node $host lctl dl | awk '{print $4}' | grep -q $label
1007 facets_up_on_host () {
1009 local facets=$(facets_on_host $host)
1012 for facet in ${facets//,/ }; do
1013 if $(facet_up $facet $host); then
1014 affected_up="$affected_up $facet"
1018 echo $(comma_list $affected_up)
1024 if [ "$FAILURE_MODE" = HARD ]; then
1025 shutdown_node_hard $(facet_active_host $facet)
1033 echo + $POWER_UP $node
1046 if [ "$FAILURE_MODE" = HARD ]; then
1047 reboot_node $(facet_active_host $facet)
1055 if [ "$FAILURE_MODE" = HARD ]; then
1065 for facet in ${facets//,/ }; do
1066 hosts=$(expand_list $hosts $(facet_host $facet) )
1072 _check_progs_installed () {
1076 for prog in $progs; do
1077 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1078 echo $prog missing on $(hostname)
1085 check_progs_installed () {
1089 do_rpc_nodes $nodes _check_progs_installed $@
1092 # recovery-scale functions
1094 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1097 start_client_load() {
1100 local var=$(node_var_name $client)_load
1101 eval export ${var}=$load
1103 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1104 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1105 END_RUN_FILE=$END_RUN_FILE \
1106 LOAD_PID_FILE=$LOAD_PID_FILE \
1107 TESTSUITELOG=$TESTSUITELOG \
1109 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1110 log "Started client load: ${load} on $client"
1115 start_client_loads () {
1116 local -a clients=(${1//,/ })
1117 local numloads=${#CLIENT_LOADS[@]}
1120 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1121 testnum=$((nodenum % numloads))
1122 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1124 # bug 22169: wait the background threads to start
1128 # only for remote client
1129 check_client_load () {
1131 local var=$(node_var_name $client)_load
1132 local TESTLOAD=run_${!var}.sh
1134 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1136 # bug 18914: try to connect several times not only when
1137 # check ps, but while check_catastrophe also
1140 while [ $RC = 254 -a $tries -gt 0 ]; do
1144 if ! check_catastrophe $client; then
1146 if [ $RC -eq 254 ]; then
1147 # FIXME: not sure how long we shuold sleep here
1151 echo "check catastrophe failed: RC=$RC "
1155 # We can continue try to connect if RC=254
1156 # Just print the warning about this
1157 if [ $RC = 254 ]; then
1158 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1161 # see if the load is still on the client
1164 while [ $RC = 254 -a $tries -gt 0 ]; do
1168 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1173 if [ $RC = 254 ]; then
1174 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1175 # see if we can diagnose a bit why this is
1180 check_client_loads () {
1181 local clients=${1//,/ }
1185 for client in $clients; do
1186 check_client_load $client
1188 if [ "$rc" != 0 ]; then
1189 log "Client load failed on node $client, rc=$rc"
1195 restart_client_loads () {
1196 local clients=${1//,/ }
1197 local expectedfail=${2:-""}
1201 for client in $clients; do
1202 check_client_load $client
1204 if [ "$rc" != 0 -a "$expectedfail" ]; then
1205 local var=$(node_var_name $client)_load
1206 start_client_load $client ${!var}
1207 echo "Restarted client load ${!var}: on $client. Checking ..."
1208 check_client_load $client
1210 if [ "$rc" != 0 ]; then
1211 log "Client load failed to restart on node $client, rc=$rc"
1212 # failure one client load means test fail
1213 # we do not need to check other
1221 # End recovery-scale functions
1223 # verify that lustre actually cleaned up properly
1225 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1226 error "LBUG/LASSERT detected"
1227 BUSY=`dmesg | grep -i destruct || true`
1228 if [ "$BUSY" ]; then
1230 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1234 check_mem_leak || exit 204
1236 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1237 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1239 if module_loaded lnet || module_loaded libcfs; then
1240 echo "$0: modules still loaded..." 1>&2
1257 RESULT=$(do_node $node "$TEST")
1258 if [ "$RESULT" == "$FINAL" ]; then
1259 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1262 [ $WAIT -ge $MAX ] && break
1263 echo "Waiting $((MAX - WAIT)) secs for update"
1264 WAIT=$((WAIT + sleep))
1267 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1271 wait_update_facet () {
1273 wait_update $(facet_active_host $facet) "$@"
1276 wait_delete_completed () {
1277 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1278 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1282 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1284 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1285 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1286 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1287 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1291 echo "Delete is not completed in $MAX_WAIT sec"
1298 # we can use "for" here because we are waiting the slowest
1299 for host in ${hostlist//,/ }; do
1300 check_network "$host" 900
1302 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1309 for facet in ${facetlist//,/ }; do
1310 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1312 wait_for_host $hostlist
1315 _wait_recovery_complete () {
1318 # Use default policy if $2 is not passed by caller.
1319 local MAX=${2:-$(max_recovery_time)}
1324 while [ $WAIT -lt $MAX ]; do
1325 STATUS=$(lctl get_param -n $param | grep status)
1327 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1330 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1332 echo "$param recovery not done in $MAX sec. $STATUS"
1336 wait_recovery_complete () {
1339 # with an assumption that at_max is the same on all nodes
1340 local MAX=${2:-$(max_recovery_time)}
1343 if [ "$FAILURE_MODE" = HARD ]; then
1344 facets=$(facets_on_host $(facet_active_host $facet))
1346 echo affected facets: $facets
1348 # we can use "for" here because we are waiting the slowest
1349 for facet in ${facets//,/ }; do
1350 local var_svc=${facet}_svc
1351 local param="*.${!var_svc}.recovery_status"
1353 local host=$(facet_active_host $facet)
1354 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1358 wait_mds_ost_sync () {
1359 # just because recovery is done doesn't mean we've finished
1360 # orphan cleanup. Wait for llogs to get synchronized.
1361 echo "Waiting for orphan cleanup..."
1362 # MAX value includes time needed for MDS-OST reconnection
1363 local MAX=$(( TIMEOUT * 2 ))
1365 while [ $WAIT -lt $MAX ]; do
1366 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1367 "$LCTL get_param -n obdfilter.*.mds_sync"))
1370 for ((i=0; i<${#sync[@]}; i++)); do
1371 [ ${sync[$i]} -eq 0 ] && continue
1372 # there is a not finished MDS-OST synchronization
1376 sleep 2 # increase waiting time and cover statfs cache
1377 [ ${con} -eq 1 ] && return 0
1378 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1381 echo "$facet recovery not done in $MAX sec. $STATUS"
1385 wait_destroy_complete () {
1386 echo "Waiting for destroy to be done..."
1387 # MAX value shouldn't be big as this mean server responsiveness
1388 # never increase this just to make test pass but investigate
1389 # why it takes so long time
1392 while [ $WAIT -lt $MAX ]; do
1393 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1395 for ((i=0; i<${#RPCs[@]}; i++)); do
1396 [ ${RPCs[$i]} -eq 0 ] && continue
1397 # there are still some destroy RPCs in flight
1402 [ ${con} -eq 1 ] && return 0 # done waiting
1403 echo "Waiting $WAIT secs for destroys to be done."
1406 echo "Destroys weren't done in $MAX sec."
1416 # conf-sanity 31 takes a long time cleanup
1417 while [ $WAIT -lt 300 ]; do
1418 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1419 [ -z "${running}" ] && return 0
1420 echo "waited $WAIT for${running}"
1421 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1423 WAIT=$((WAIT + INTERVAL))
1425 echo "service didn't stop after $WAIT seconds. Still running:"
1430 wait_remote_prog () {
1436 [ "$PDSH" = "no_dsh" ] && return 0
1438 while [ $WAIT -lt $2 ]; do
1439 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1440 [ -z "${running}" ] && return 0 || true
1441 echo "waited $WAIT for: "
1443 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1445 WAIT=$((WAIT + INTERVAL))
1447 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1448 [ -z "$pids" ] && return 0
1449 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1450 # FIXME: not portable
1451 for pid in $pids; do
1452 cat /proc/${pid}/status || true
1453 cat /proc/${pid}/wchan || true
1455 kill -9 $pid || true
1464 # not every config has many clients
1466 if [ ! -z "$CLIENTS" ]; then
1467 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1469 stat -f $MOUNT > /dev/null
1475 # usually checked on particular client or locally
1477 if [ ! -z "$client" ]; then
1478 $PDSH $client "stat -f $MOUNT" > /dev/null
1480 stat -f $MOUNT > /dev/null
1488 client_reconnect() {
1489 uname -n >> $MOUNT/recon
1490 if [ -z "$CLIENTS" ]; then
1491 df $MOUNT; uname -n >> $MOUNT/recon
1493 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1495 echo Connected clients:
1497 ls -l $MOUNT/recon > /dev/null
1501 affected_facets () {
1504 local host=$(facet_active_host $facet)
1505 local affected=$facet
1507 if [ "$FAILURE_MODE" = HARD ]; then
1508 affected=$(facets_up_on_host $host)
1516 local host=$(facet_active_host $facet)
1518 echo "Failing $facet on node $host"
1520 local affected=$(affected_facets $facet)
1522 shutdown_facet $facet
1524 echo affected facets: $affected
1526 [ -n "$sleep_time" ] && sleep $sleep_time
1530 change_active $affected
1532 wait_for_facet $affected
1533 # start mgs first if it is affected
1534 if ! combined_mgs_mds && list_member $affected mgs; then
1535 mount_facet mgs || error "Restart of mgs failed"
1537 # FIXME; has to be changed to mount all facets concurrently
1538 affected=$(exclude_items_from_list $affected mgs)
1539 mount_facets $affected
1548 do_facet $facet "sync; sync; sync"
1551 # make sure there will be no seq change
1552 local clients=${CLIENTS:-$HOSTNAME}
1553 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1555 local svc=${facet}_svc
1556 do_facet $facet $LCTL --device %${!svc} notransno
1557 do_facet $facet $LCTL --device %${!svc} readonly
1558 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1559 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1562 replay_barrier_nodf() {
1563 local facet=$1 echo running=${running}
1564 do_facet $facet "sync; sync; sync"
1565 local svc=${facet}_svc
1566 echo Replay barrier on ${!svc}
1567 do_facet $facet $LCTL --device %${!svc} notransno
1568 do_facet $facet $LCTL --device %${!svc} readonly
1569 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1570 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1573 replay_barrier_nosync() {
1574 local facet=$1 echo running=${running}
1575 local svc=${facet}_svc
1576 echo Replay barrier on ${!svc}
1577 do_facet $facet $LCTL --device %${!svc} notransno
1578 do_facet $facet $LCTL --device %${!svc} readonly
1579 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1580 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1583 mds_evict_client() {
1584 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1585 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1588 ost_evict_client() {
1589 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1590 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1594 facet_failover $* || error "failover: $?"
1595 clients_up || error "post-failover df: $?"
1600 facet_failover $facet
1606 change_active $facet
1607 wait_for_facet $facet
1608 mount_facet $facet -o abort_recovery
1609 clients_up || echo "first df failed: $?"
1610 clients_up || error "post-failover df: $?"
1614 echo There is no lmc. This is mountconf, baby.
1618 host_nids_address() {
1622 if [ -n "$kind" ]; then
1623 nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'")
1625 nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'")
1631 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1637 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1638 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1639 if [ -z "$ID" ]; then
1640 echo "Could not get a ptl id for $1..."
1649 h2name_or_ip "$1" "tcp"
1654 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1655 if type __h2elan >/dev/null 2>&1; then
1658 ID=`echo $1 | sed 's/[^0-9]*//g'`
1666 h2name_or_ip "$1" "o2ib"
1670 # This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST
1671 # expressions format. As a bonus we can then just pass in those variables
1672 # to pdsh. What this function does is take a HOSTLIST type string and
1673 # expand it into a space deliminated list for us.
1681 [ -z "$hostlist" ] && return
1683 # Translate the case of [..],..,[..] to [..] .. [..]
1684 list="${hostlist/],/] }"
1686 [[ "$front" == *,* ]] && {
1689 list=${list/${old}/${new}}
1692 for item in $list; do
1693 # Test if we have any []'s at all
1694 if [ "$item" != "${item/\[/}" ]; then {
1695 # Expand the [*] into list
1699 if [ "$name" != "$item" ]; then
1700 group=${item#$name[*}
1703 for range in ${group//,/ }; do
1707 # Number of leading zeros
1710 end=$(echo $end | sed 's/0*//')
1711 [[ -z "$end" ]] && end=0
1712 [[ $padlen2 -gt $padlen ]] && {
1713 [[ $padlen2 -eq ${#end} ]] && padlen2=0
1716 begin=$(echo $begin | sed 's/0*//')
1717 [ -z $begin ] && begin=0
1719 for num in $(seq -f "%0${padlen}g" $begin $end); do
1720 value="${name#*,}${num}${back}"
1721 [ "$value" != "${value/\[/}" ] && {
1722 value=$(hostlist_expand "$value")
1724 myList="$myList $value"
1729 myList="$myList $item"
1732 myList=${myList//,/ }
1733 myList=${myList:1} # Remove first character which is a space
1735 # Filter any duplicates without sorting
1737 myList="${list%% *}"
1739 while [[ "$list" != ${myList##* } ]]; do
1740 list=${list//${list%% *} /}
1741 myList="$myList ${list%% *}"
1743 myList="${myList%* }";
1745 # We can select an object at a offset in the list
1748 for item in $myList; do
1750 [ $cnt -eq $offset ] && {
1754 [ $(get_node_count $myList) -ne 1 ] && myList=""
1762 [ "$facet" == client ] && echo -n $HOSTNAME && return
1763 varname=${facet}_HOST
1764 if [ -z "${!varname}" ]; then
1765 if [ "${facet:0:3}" == "ost" ]; then
1766 eval ${facet}_HOST=${ost_HOST}
1774 local activevar=${facet}active
1776 if [ -f $TMP/${facet}active ] ; then
1777 source $TMP/${facet}active
1780 active=${!activevar}
1781 if [ -z "$active" ] ; then
1788 facet_active_host() {
1790 local active=`facet_active $facet`
1791 if [ "$facet" == client ]; then
1794 echo `facet_host $active`
1802 facetlist=$(exclude_items_from_list $facetlist mgs)
1804 for facet in ${facetlist//,/ }; do
1805 local failover=${facet}failover
1806 local host=`facet_host $failover`
1807 [ -z "$host" ] && return
1809 local curactive=`facet_active $facet`
1810 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1811 eval export ${facet}active=$facet
1813 eval export ${facet}active=$failover
1815 # save the active host for this facet
1816 local activevar=${facet}active
1817 echo "$activevar=${!activevar}" > $TMP/$activevar
1818 [[ $facet = mds1 ]] && combined_mgs_mds && \
1819 echo "mgsactive=${!activevar}" > $TMP/mgsactive
1820 local TO=`facet_active_host $facet`
1821 echo "Failover $facet to $TO"
1827 # do not stripe off hostname if verbose, bug 19215
1828 if [ x$1 = x--verbose ]; then
1836 if [ "$HOST" = "$HOSTNAME" ]; then
1838 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1839 echo "cannot run remote command on $HOST with $myPDSH"
1843 echo "CMD: $HOST $@" >&2
1844 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1847 if [ "$myPDSH" = "rsh" ]; then
1848 # we need this because rsh does not return exit code of an executed command
1849 local command_status="$TMP/cs"
1850 rsh $HOST ":> $command_status"
1851 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1852 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1853 echo command failed >$command_status"
1854 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1859 # print HOSTNAME for myPDSH="no_dsh"
1860 if [[ $myPDSH = no_dsh ]]; then
1861 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1863 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1866 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1868 return ${PIPESTATUS[0]}
1872 do_node --verbose "$@"
1875 single_local_node () {
1876 [ "$1" = "$HOSTNAME" ]
1879 # Outputs environment variable assignments that should be passed to remote nodes
1884 for var in ${!MODOPTS_*}; do
1886 echo "${var}=\"$value\""
1892 # do not stripe off hostname if verbose, bug 19215
1893 if [ x$1 = x--verbose ]; then
1901 if single_local_node $rnodes; then
1903 do_nodev $rnodes "$@"
1905 do_node $rnodes "$@"
1910 # This is part from do_node
1913 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1914 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1917 echo "CMD: $rnodes $@" >&2
1918 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1921 # do not replace anything from pdsh output if -N is used
1922 # -N Disable hostname: prefix on lines of output.
1923 if $verbose || [[ $myPDSH = *-N* ]]; then
1924 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1926 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1928 return ${PIPESTATUS[0]}
1934 local HOST=`facet_active_host $facet`
1935 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1940 do_nodes --verbose "$@"
1946 # make sure its not already running
1948 rm -f $TMP/${facet}active
1949 [[ $facet = mds1 ]] && combined_mgs_mds && rm -f $TMP/mgsactive
1950 do_facet ${facet} $MKFS $*
1956 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1957 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1964 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1965 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1971 [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
1973 local var=${facet}_MOUNT
1974 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1983 # make sure we are using the primary server, so test-framework will
1984 # be able to clean up properly.
1985 activemds=`facet_active mds1`
1986 if [ $activemds != "mds1" ]; then
1990 local clients=$CLIENTS
1991 [ -z $clients ] && clients=$(hostname)
1993 zconf_umount_clients $clients $MOUNT "$*" || true
1994 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1996 [ "$CLIENTONLY" ] && return
1997 # The add fn does rm ${facet}active file, this would be enough
1998 # if we use do_facet <facet> only after the facet added, but
1999 # currently we use do_facet mds in local.sh
2000 for num in `seq $MDSCOUNT`; do
2002 rm -f ${TMP}/mds${num}active
2004 combined_mgs_mds && rm -f $TMP/mgsactive
2006 for num in `seq $OSTCOUNT`; do
2008 rm -f $TMP/ost${num}active
2011 if ! combined_mgs_mds ; then
2018 cleanup_echo_devs () {
2019 local devs=$($LCTL dl | grep echo | awk '{print $4}')
2021 for dev in $devs; do
2022 $LCTL --device $dev cleanup
2023 $LCTL --device $dev detach
2028 nfs_client_mode && return
2037 combined_mgs_mds () {
2038 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
2044 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
2045 local optvar=${tgt}_MKFS_OPTS
2046 local opt=${!optvar}
2048 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
2049 [[ $facet = mgs ]] && echo $opt && return
2052 # --failnode options
2053 local var=${facet}failover_HOST
2054 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
2055 local failnode=$(h2$NETTYPE ${!var})
2056 failnode="--failnode=$failnode"
2057 # options does not contain
2058 # or contains wrong --failnode=
2059 if [[ $opt != *${failnode}* ]]; then
2060 opt=$(echo $opt | sed 's/--failnode=.* / /')
2061 opt="$opt $failnode"
2067 # no additional mkfs mds "--mgsnode" option for this configuration
2068 if [[ $facet = mds ]] && combined_mgs_mds; then
2073 # additional mkfs "--mgsnode"
2074 local mgsnode="--mgsnode=$MGSNID"
2075 opt=${opt//$mgsnode }
2076 for nid in ${MGSNID//:/ }; do
2077 local mgsnode="--mgsnode=$nid"
2078 # options does not contain
2080 if [[ $opt != *${mgsnode}" "* ]]; then
2081 opt="$opt --mgsnode=$nid"
2089 if [ "$IAMDIR" == "yes" ]; then
2090 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
2093 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
2096 # We need ldiskfs here, may as well load them all
2098 [ "$CLIENTONLY" ] && return
2099 echo Formatting mgs, mds, osts
2100 if ! combined_mgs_mds ; then
2101 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
2104 for num in `seq $MDSCOUNT`; do
2105 echo "Format mds$num: $(mdsdevname $num)"
2107 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
2109 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
2113 # the ost-s could have different OST_MKFS_OPTS
2114 # because of different failnode-s
2115 for num in `seq $OSTCOUNT`; do
2116 echo "Format ost$num: $(ostdevname $num)"
2118 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
2120 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
2126 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
2130 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
2134 # 0: success, the old identity set already.
2135 # 1: success, the old identity does not set.
2140 local j=`expr $num - 1`
2141 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
2143 if [ -z "$MDT" ]; then
2147 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
2150 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
2152 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
2155 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
2157 if [ $old = "NONE" ]; then
2166 zconf_umount `hostname` $1 || error "umount failed"
2167 zconf_mount `hostname` $1 || error "mount failed"
2170 writeconf_facet () {
2174 do_facet $facet "$TUNEFS --writeconf $dev"
2178 for num in `seq $MDSCOUNT`; do
2179 DEVNAME=$(mdsdevname $num)
2180 writeconf_facet mds$num $DEVNAME
2183 for num in `seq $OSTCOUNT`; do
2184 DEVNAME=$(ostdevname $num)
2185 writeconf_facet ost$num $DEVNAME
2190 nfs_client_mode && return
2192 sanity_mount_check ||
2193 error "environments are insane!"
2197 if [ -z "$CLIENTONLY" ]; then
2198 echo Setup mgs, mdt, osts
2199 echo $WRITECONF | grep -q "writeconf" && \
2201 if ! combined_mgs_mds ; then
2202 start mgs $MGSDEV $MGS_MOUNT_OPTS
2205 for num in `seq $MDSCOUNT`; do
2206 DEVNAME=$(mdsdevname $num)
2207 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2209 # We started mds, now we should set failover variables properly.
2210 # Set mds${num}failover_HOST if it is not set (the default failnode).
2211 local varname=mds${num}failover_HOST
2212 if [ -z "${!varname}" ]; then
2213 eval mds${num}failover_HOST=$(facet_host mds$num)
2216 if [ $IDENTITY_UPCALL != "default" ]; then
2217 switch_identity $num $IDENTITY_UPCALL
2220 for num in `seq $OSTCOUNT`; do
2221 DEVNAME=$(ostdevname $num)
2222 start ost$num $DEVNAME $OST_MOUNT_OPTS
2224 # We started ost$num, now we should set ost${num}failover variable properly.
2225 # Set ost${num}failover_HOST if it is not set (the default failnode).
2226 varname=ost${num}failover_HOST
2227 if [ -z "${!varname}" ]; then
2228 eval ost${num}failover_HOST=$(facet_host ost${num})
2236 # wait a while to allow sptlrpc configuration be propogated to targets,
2237 # only needed when mounting new target devices.
2242 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2244 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2246 if [ "$MOUNT_2" ]; then
2247 mount_client $MOUNT2
2248 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2253 # by remounting mdt before ost, initial connect from mdt to ost might
2254 # timeout because ost is not ready yet. wait some time to its fully
2255 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2256 # by a context negotiation rpc with $TIMEOUT.
2257 # FIXME better by monitoring import status.
2260 sleep $((TIMEOUT + 5))
2266 mounted_lustre_filesystems() {
2267 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2270 init_facet_vars () {
2271 [ "$CLIENTONLY" ] && return 0
2278 eval export ${facet}_dev=${device}
2279 eval export ${facet}_opt=\"$@\"
2281 local dev=${facet}_dev
2282 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2283 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2285 eval export ${facet}_svc=${label}
2287 local varname=${facet}failover_HOST
2288 if [ -z "${!varname}" ]; then
2289 eval $varname=$(facet_host $facet)
2292 # ${facet}failover_dev is set in cfg file
2293 varname=${facet}failover_dev
2294 if [ -n "${!varname}" ] ; then
2295 eval export ${facet}failover_dev=${!varname}
2297 eval export ${facet}failover_dev=$device
2300 # get mount point of already mounted device
2301 # is facet_dev is already mounted then use the real
2302 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2303 # i.e. ${facet}_MOUNT if specified by user or default
2304 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2305 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2306 if [ -z $mntpt ]; then
2307 mntpt=$(facet_mntpt $facet)
2309 eval export ${facet}_MOUNT=$mntpt
2312 init_facets_vars () {
2315 if ! remote_mds_nodsh; then
2316 for num in `seq $MDSCOUNT`; do
2317 DEVNAME=`mdsdevname $num`
2318 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2322 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2324 remote_ost_nodsh && return
2326 for num in `seq $OSTCOUNT`; do
2327 DEVNAME=`ostdevname $num`
2328 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2332 osc_ensure_active () {
2337 while [ $period -lt $timeout ]; do
2338 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2339 if [ $count -eq 0 ]; then
2343 echo "There are $count OST are inactive, wait $period seconds, and try again"
2345 period=$((period+3))
2348 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2351 init_param_vars () {
2352 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2353 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2354 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2355 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2359 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2361 log "Using TIMEOUT=$TIMEOUT"
2363 osc_ensure_active $SINGLEMDS $TIMEOUT
2364 osc_ensure_active client $TIMEOUT
2366 if [ $QUOTA_AUTO -ne 0 ]; then
2367 if [ "$ENABLE_QUOTA" ]; then
2368 echo "enable quota as required"
2369 setup_quota $MOUNT || return 2
2371 echo "disable quota as required"
2372 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2379 nfs_client_mode () {
2380 if [ "$NFSCLIENT" ]; then
2381 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2382 local clients=$CLIENTS
2383 [ -z $clients ] && clients=$(hostname)
2385 # FIXME: remove hostname when 19215 fixed
2386 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2387 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2388 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2389 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2391 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2397 check_config_client () {
2400 local mounted=$(mount | grep " $mntpt ")
2401 if [ "$CLIENTONLY" ]; then
2403 # CLIENTONLY should not depend on *_HOST settings
2404 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2405 # in theory someone could create a new,
2406 # client-only config file that assumed lustre was already
2407 # configured and didn't set the MGSNID. If MGSNID is not set,
2408 # then we should use the mgs nid currently being used
2409 # as the default value. bug 18021
2410 [[ x$MGSNID = x ]] &&
2413 if [[ x$mgc != xMGC$MGSNID ]]; then
2414 if [ "$mgs_HOST" ]; then
2415 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2416 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2417 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2423 local myMGS_host=$mgs_HOST
2424 if [ "$NETTYPE" = "ptl" ]; then
2425 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2428 echo Checking config lustre mounted on $mntpt
2429 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2430 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2432 # if [ "$mgshost" != "$myMGS_host" ]; then
2433 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2434 # Please use correct config or set mds_HOST correctly!"
2439 check_config_clients () {
2440 local clients=${CLIENTS:-$HOSTNAME}
2443 nfs_client_mode && return
2445 do_rpc_nodes $clients check_config_client $mntpt
2447 sanity_mount_check ||
2448 error "environments are insane!"
2452 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2453 local cltimeout=$(lctl get_param -n timeout)
2454 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2455 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2462 [ -z $mntpt ] && return 1
2463 local mounted=$(mounted_lustre_filesystems)
2465 echo $mounted' ' | grep -w -q $mntpt' '
2469 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2473 # empty lustre filesystem may have empty directories lost+found and .lustre
2475 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2476 -print | wc -l) = 1 ] || return 1
2477 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2478 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2482 check_and_setup_lustre() {
2483 nfs_client_mode && return
2485 local MOUNTED=$(mounted_lustre_filesystems)
2489 # both MOUNT and MOUNT2 are not mounted
2490 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2491 [ "$REFORMAT" ] && formatall
2492 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2494 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2495 export I_MOUNTED=yes
2499 elif is_mounted $MOUNT2; then
2501 # MOUNT2 is mounted, while MOUNT_2 is not set
2502 if ! [ "$MOUNT_2" ]; then
2503 cleanup_mount $MOUNT2
2504 export I_UMOUNTED2=yes
2507 # MOUNT2 is mounted, MOUNT_2 is set
2509 # FIXME: what to do if check_config failed?
2511 # 1) remote client has mounted other Lustre fs ?
2512 # 2) it has insane env ?
2513 # let's try umount MOUNT2 on all clients and mount it again:
2514 if ! check_config_clients $MOUNT2; then
2515 cleanup_mount $MOUNT2
2516 restore_mount $MOUNT2
2517 export I_MOUNTED2=yes
2522 # MOUNT is mounted MOUNT2 is not mounted
2523 elif [ "$MOUNT_2" ]; then
2524 restore_mount $MOUNT2
2525 export I_MOUNTED2=yes
2529 # FIXME: what to do if check_config failed?
2531 # 1) remote client has mounted other Lustre fs?
2532 # 2) lustre is mounted on remote_clients atall ?
2533 check_config_clients $MOUNT
2537 set_default_debug_nodes $(comma_list $(nodes_list))
2543 if [ "$ONLY" == "setup" ]; then
2549 local clients=${CLIENTS:-$HOSTNAME}
2552 zconf_mount_clients $clients $mntpt
2556 local clients=${CLIENTS:-$HOSTNAME}
2559 zconf_umount_clients $clients $mntpt
2562 cleanup_and_setup_lustre() {
2563 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2564 lctl set_param debug=0 || true
2566 if [ "$ONLY" == "cleanup" ]; then
2570 check_and_setup_lustre
2573 # Get all of the server target devices from a given server node and type.
2582 mdt) obd_type="osd" ;;
2583 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2584 *) echo "invalid server type" && return 1 ;;
2587 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2588 for dev in $devs; do
2590 *loop*) do_node $node "losetup $dev" | \
2591 sed -e "s/.*(//" -e "s/).*//" ;;
2597 # Get all of the server target devices.
2602 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2606 for node in $(osts_nodes); do
2607 OSTDEVS[i]=$(get_mnt_devs $node ost)
2612 # Run e2fsck on MDT or OST device.
2618 df > /dev/null # update statfs data on disk
2619 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2622 do_node $node $cmd || rc=$?
2623 [ $rc -le $FSCK_MAX_ERR ] || \
2624 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2628 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2635 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2636 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2637 error "fail to create file in $SHARED_DIRECTORY")
2639 # make sure everything gets to the backing store
2640 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2641 do_nodes $list "sync; sleep 2; sync"
2643 do_nodes $list ls $tmp_file || \
2644 error "$SHARED_DIRECTORY is not a shared directory"
2647 run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
2652 for node in $(osts_nodes); do
2653 for dev in ${OSTDEVS[i]}; do
2654 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
2655 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2656 ostidx=$((ostidx + 1))
2663 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2667 [ $rc -le $FSCK_MAX_ERR ] || \
2668 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2669 echo "lfsck finished with rc=$rc"
2671 rm -rvf $MDSDB* $OSTDB* || true
2675 check_and_cleanup_lustre() {
2676 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
2682 if is_mounted $MOUNT; then
2683 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2684 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2687 if [ "$I_UMOUNTED2" = "yes" ]; then
2688 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2691 if [ "$I_MOUNTED2" = "yes" ]; then
2692 cleanup_mount $MOUNT2
2695 if [ "$I_MOUNTED" = "yes" ]; then
2696 cleanupall -f || error "cleanup failed"
2704 wait_for_function () {
2707 # suppress fn both stderr and stdout
2708 if [ "$1" = "--quiet" ]; then
2710 quiet=" > /dev/null 2>&1"
2722 eval $fn $quiet && return 0
2724 wait=$((wait + sleep))
2725 [ $wait -lt $max ] || return 1
2726 echo waiting $fn, $((max - wait)) secs left ...
2736 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2737 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2738 echo "Network not available!"
2742 echo `date +"%H:%M:%S (%s)"` network interface is UP
2751 # the sed converts spaces to commas, but leaves the last space
2752 # alone, so the line doesn't end with a comma.
2753 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2759 echo $list | grep -qw $item
2762 # list, excluded are the comma separated lists
2763 exclude_items_from_list () {
2769 for item in ${excluded//,/ }; do
2770 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2772 echo $(comma_list $list)
2775 # list, expand are the comma separated lists
2777 local list=${1//,/ }
2778 local expand=${2//,/ }
2781 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2782 echo $(comma_list $expanded)
2785 testslist_filter () {
2786 local script=$LUSTRE/tests/${TESTSUITE}.sh
2788 [ -f $script ] || return 0
2790 local start_at=$START_AT
2791 local stop_at=$STOP_AT
2793 local var=${TESTSUITE//-/_}_START_AT
2794 [ x"${!var}" != x ] && start_at=${!var}
2795 var=${TESTSUITE//-/_}_STOP_AT
2796 [ x"${!var}" != x ] && stop_at=${!var}
2798 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2799 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2800 /^'${start_at}'$/ {flag = 0}
2801 {if (flag == 1) print $0}
2802 /^'${stop_at}'$/ { flag = 1 }'
2806 (cd `dirname $1`; echo $PWD/`basename $1`)
2810 local types=${1:-"OST MDS MGS"}
2814 for entry in $types; do
2815 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2816 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2819 MGS ) list="$list $name";;
2820 MDS|OST ) local count=${type}COUNT
2821 for ((i=1; i<=${!count}; i++)) do
2822 list="$list ${name}$i"
2824 * ) error "Invalid facet type"
2828 echo $(comma_list $list)
2831 ##################################
2832 # Adaptive Timeouts funcs
2835 # only check mds, we assume at_max is the same on all nodes
2836 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2837 if [ $at_max -eq 0 ]; then
2848 # suppose that all ost-s have the same $at value set
2849 [ $facet != "ost" ] || facet=ost1
2851 do_facet $facet "lctl get_param -n $at"
2865 if [ $facet == "ost" ]; then
2866 facet=$(get_facets OST)
2867 elif [ $facet == "mds" ]; then
2868 facet=$(get_facets MDS)
2870 hosts=$(expand_list $hosts $(facets_hosts $facet))
2873 do_nodes $hosts lctl set_param at_max=$at_max
2876 ##################################
2880 # OBD_FAIL_MDS_ALL_REQUEST_NET
2882 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2883 do_facet client "$1" || RC=$?
2884 do_facet $SINGLEMDS lctl set_param fail_loc=0
2889 # OBD_FAIL_MDS_ALL_REPLY_NET
2891 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2892 do_facet client "$@" || RC=$?
2893 do_facet $SINGLEMDS lctl set_param fail_loc=0
2897 drop_reint_reply() {
2898 # OBD_FAIL_MDS_REINT_NET_REP
2900 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2901 do_facet client "$@" || RC=$?
2902 do_facet $SINGLEMDS lctl set_param fail_loc=0
2907 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2909 do_facet ost1 lctl set_param fail_loc=0x214
2910 do_facet client "$1" || RC=$?
2911 do_facet client "sync"
2912 do_facet ost1 lctl set_param fail_loc=0
2916 drop_ldlm_cancel() {
2917 #define OBD_FAIL_LDLM_CANCEL 0x304
2919 do_facet client lctl set_param fail_loc=0x304
2920 do_facet client "$@" || RC=$?
2921 do_facet client lctl set_param fail_loc=0
2925 drop_bl_callback() {
2926 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2928 do_facet client lctl set_param fail_loc=0x305
2929 do_facet client "$@" || RC=$?
2930 do_facet client lctl set_param fail_loc=0
2935 #define OBD_FAIL_LDLM_REPLY 0x30c
2937 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2938 do_facet client "$@" || RC=$?
2939 do_facet $SINGLEMDS lctl set_param fail_loc=0
2947 echo "clearing fail_loc on $facet"
2948 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2951 set_nodes_failloc () {
2952 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2955 cancel_lru_locks() {
2956 $LCTL mark "cancel_lru_locks $1 start"
2957 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2958 $LCTL set_param -n $d=clear
2960 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2961 $LCTL mark "cancel_lru_locks $1 stop"
2966 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2967 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2968 echo "$DEFAULT_LRU_SIZE"
2973 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2976 lru_resize_disable()
2978 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2983 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2984 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2985 echo there is still data in page cache $FILE ?
2986 lctl get_param -n $FILE
2994 DEBUGSAVE="$(lctl get_param -n debug)"
2998 [ -n "$DEBUGSAVE" ] && \
2999 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
3004 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
3007 debug_size_restore() {
3008 [ -n "$DEBUG_SIZE_SAVED" ] && \
3009 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
3013 start_full_debug_logging() {
3018 local DEBUG_SIZE=150
3020 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
3021 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
3024 stop_full_debug_logging() {
3029 ##################################
3031 ##################################
3034 local TYPE=${TYPE:-"FAIL"}
3037 # do not dump logs if $1=false
3038 if [ "x$1" = "xfalse" ]; then
3043 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
3045 # We need to dump the logs on all nodes
3047 gather_logs $(comma_list $(nodes_list))
3051 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
3052 echo "$@" > $LOGDIR/err
3057 local log=$TESTSUITELOG
3059 [ -f "$log" ] && grep -q FAIL: $log && status=1
3072 # use only if we are ignoring failures for this test, bugno required.
3073 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
3074 # e.g. error_ignore 5494 "your message"
3076 local TYPE="IGNORE (bz$1)"
3082 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
3087 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
3088 [ "$ALWAYS_SKIPPED" ] && \
3089 skip_logged ${TESTNAME} "$@" || true
3090 [ "$TESTSUITELOG" ] && \
3091 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
3094 build_test_filter() {
3095 EXCEPT="$EXCEPT $(testslist_filter)"
3097 [ "$ONLY" ] && log "only running test `echo $ONLY`"
3101 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
3102 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
3103 [ "$EXCEPT_SLOW" ] && \
3104 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
3105 for E in $EXCEPT; do
3106 eval EXCEPT_${E}=true
3108 for E in $ALWAYS_EXCEPT; do
3109 eval EXCEPT_ALWAYS_${E}=true
3111 for E in $EXCEPT_SLOW; do
3112 eval EXCEPT_SLOW_${E}=true
3114 for G in $GRANT_CHECK_LIST; do
3115 eval GCHECK_ONLY_${G}=true
3120 if [[ $1 = [a-z]* ]]; then
3127 # print a newline if the last test was skipped
3128 export LAST_SKIPPED=
3129 export ALWAYS_SKIPPED=
3131 # Main entry into test-framework. This is called with the name and
3132 # description of a test. The name is used to find the function to run
3133 # the test using "test_$name".
3135 # This supports a variety of methods of specifying specific test to
3136 # run or not run. These need to be documented...
3141 export base=`basetest $1`
3142 if [ ! -z "$ONLY" ]; then
3144 if [ ${!testname}x != x ]; then
3145 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3146 run_one_logged $1 "$2"
3150 if [ ${!testname}x != x ]; then
3151 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3152 run_one_logged $1 "$2"
3160 if [ ${!testname}x != x ]; then
3162 TESTNAME=test_$1 skip "skipping excluded test $1"
3165 testname=EXCEPT_$base
3166 if [ ${!testname}x != x ]; then
3168 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3171 testname=EXCEPT_ALWAYS_$1
3172 if [ ${!testname}x != x ]; then
3175 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3178 testname=EXCEPT_ALWAYS_$base
3179 if [ ${!testname}x != x ]; then
3182 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3185 testname=EXCEPT_SLOW_$1
3186 if [ ${!testname}x != x ]; then
3188 TESTNAME=test_$1 skip "skipping SLOW test $1"
3191 testname=EXCEPT_SLOW_$base
3192 if [ ${!testname}x != x ]; then
3194 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3200 run_one_logged $1 "$2"
3211 module_loaded lnet || load_modules
3223 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3228 strace -o $TMP/$1.strace -ttt $*
3230 log "FINISHED: $*: rc $RC"
3235 equals_msg $1 test complete, duration $2 sec
3236 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3237 echo duration $2 >>$TESTSUITELOG
3241 # Set TEST_STATUS here; will be used for logging the result
3242 if [ -f $LOGDIR/err ]; then
3247 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3251 local FFREE=$(do_node $SINGLEMDS \
3252 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3253 local FTOTAL=$(do_node $SINGLEMDS \
3254 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3256 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3260 echo -n "Resetting fail_loc on all nodes..."
3261 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3267 # Log a message (on all nodes) padded with "=" before and after.
3268 # Also appends a timestamp and prepends the testsuite name.
3271 EQUALS="===================================================================================================="
3273 msg="== ${TESTSUITE} $*"
3275 [[ $last != "=" && $last != " " ]] && msg="$msg "
3276 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3277 # always include at least == after the message
3278 log "$msg== $(date +"%H:%M:%S (%s)")"
3282 # Run a single test function and cleanup after it.
3284 # This function should be run in a subshell so the test func can
3285 # exit() without stopping the whole script.
3291 export tdir=d0.${TESTSUITE}/d${base}
3292 export TESTNAME=test_$testnum
3293 local SAVE_UMASK=`umask`
3296 banner "test $testnum: $message"
3297 test_${testnum} || error "test_$testnum failed with $?"
3300 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3301 check_catastrophe || error "LBUG/LASSERT detected"
3302 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3310 # Wrapper around run_one to ensure:
3311 # - test runs in subshell
3312 # - output of test is saved to separate log file for error reporting
3313 # - test result is saved to data file
3316 local BEFORE=`date +%s`
3318 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
3319 local test_log=$LOGDIR/$name
3321 local SAVE_UMASK=`umask`
3325 log_sub_test_begin test_${1}
3326 (run_one $1 "$2") 2>&1 | tee $test_log
3327 local RC=${PIPESTATUS[0]}
3329 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3330 echo "test_$1 returned $RC" | tee $LOGDIR/err
3332 duration=$((`date +%s` - $BEFORE))
3333 pass "$1" "(${duration}s)"
3334 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3335 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3337 if [ -f $LOGDIR/err ]; then
3338 $FAIL_ON_ERROR && exit $RC
3347 # Print information of skipped tests to result.yml
3350 log_sub_test_begin $1
3351 log_sub_test_end "SKIP" "0" "0" "\"$2\""
3355 (cd `dirname $1`; echo $PWD/`basename $1`)
3360 export base=`basetest $1`
3361 [ "$CHECK_GRANT" == "no" ] && return 0
3363 testname=GCHECK_ONLY_${base}
3364 [ ${!testname}x == x ] && return 0
3366 echo -n "checking grant......"
3368 local clients=$CLIENTS
3369 [ -z $clients ] && clients=$(hostname)
3371 # sync all the data and make sure no pending data on server
3372 do_nodes $clients sync
3375 client_grant=`do_nodes $clients \
3376 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3377 awk '{total += $1} END{print total}'`
3380 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3381 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3382 awk '{total += $1} END{print total}'`
3384 # check whether client grant == server grant
3385 if [ $client_grant -ne $server_grant ]; then
3386 echo "failed: client:${client_grant} server: ${server_grant}."
3387 do_nodes $(comma_list $(osts_nodes)) \
3388 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3389 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3392 echo "pass: client:${client_grant} server: ${server_grant}"
3397 ########################
3403 ost=`echo $1 | awk -F_ '{print $3}'`
3404 if [ -z $ost ]; then
3405 ost=`echo $1 | sed 's/-osc.*//'`
3410 ostuuid_from_index()
3412 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
3415 ostname_from_index() {
3416 local uuid=$(ostuuid_from_index $1)
3420 index_from_ostuuid()
3422 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
3427 [ "$node" != "$(hostname)" ]
3433 for node in $(mdts_nodes); do
3434 remote_node $node && return 0
3441 [ "$CLIENTONLY" ] && return 0 || true
3442 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3447 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3448 MSKIPPED=1 && return 1
3455 for node in $(osts_nodes) ; do
3456 remote_node $node && return 0
3463 [ "$CLIENTONLY" ] && return 0 || true
3464 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3469 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3470 OSKIPPED=1 && return 1
3477 MGS=$(facet_host mgs)
3478 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3483 remote_mds_nodsh || remote_ost_nodsh || \
3484 $(single_local_node $(comma_list $(nodes_list)))
3490 for num in `seq $MDSCOUNT`; do
3491 MDSNODES="$MDSNODES $(facet_host mds$num)"
3493 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3499 remote_ost && remote_mds
3507 for facet in ${facets//,/ }; do
3508 if [ "$FAILURE_MODE" = HARD ]; then
3509 nodes="$nodes $(facet_active_host $facet)"
3511 nodes="$nodes $(facet_host $facet)"
3514 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3520 local facets=$(get_facets OST)
3521 local nodes=$(facets_nodes $facets)
3527 # FIXME. We need a list of clients
3528 local myNODES=$HOSTNAME
3531 # CLIENTS (if specified) contains the local client
3532 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3534 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3535 myNODES="$myNODES $(facets_nodes $(get_facets))"
3538 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3543 remote_nodes_list () {
3544 local rnodes=$(nodes_list)
3545 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3549 init_clients_lists () {
3550 # Sanity check: exclude the local client from RCLIENTS
3551 local clients=$(hostlist_expand "$RCLIENTS")
3552 local rclients=$(exclude_items_from_list "$clients" $HOSTNAME)
3554 # Sanity check: exclude the dup entries
3555 RCLIENTS=$(for i in ${rclients//,/ }; do echo $i; done | sort -u)
3557 clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
3559 # Sanity check: exclude the dup entries from CLIENTS
3560 # for those configs which has SINGLCLIENT set to local client
3561 clients=$(for i in $clients; do echo $i; done | sort -u)
3563 CLIENTS=$(comma_list $clients)
3564 local -a remoteclients=($RCLIENTS)
3565 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3566 varname=CLIENT$((i + 2))
3567 eval $varname=${remoteclients[i]}
3570 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3573 get_random_entry () {
3576 rnodes=${rnodes//,/ }
3578 local -a nodes=($rnodes)
3579 local num=${#nodes[@]}
3580 local i=$((RANDOM * num * 2 / 65536))
3586 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3591 lctl get_param version | grep -q patchless
3595 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3600 echo $nodes | wc -w || true
3604 local nodes=$(osts_nodes)
3605 local osscount=$(get_node_count "$nodes")
3606 [ ! "$OSTCOUNT" = "$osscount" ]
3610 local nodes=$(mdts_nodes)
3611 local mdtcount=$(get_node_count "$nodes")
3612 [ ! "$MDSCOUNT" = "$mdtcount" ]
3615 generate_machine_file() {
3616 local nodes=${1//,/ }
3617 local machinefile=$2
3619 for node in $nodes; do
3620 echo $node >>$machinefile || \
3621 { echo "can not generate machinefile $machinefile" && return 1; }
3626 local file=$1/stripe
3628 $LFS getstripe -v $file || error
3632 setstripe_nfsserver () {
3635 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3636 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3638 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3640 do_nodev $nfsserver lfs setstripe "$@"
3643 check_runas_id_ret() {
3645 local myRUNAS_UID=$1
3646 local myRUNAS_GID=$2
3649 if [ -z "$myRUNAS" ]; then
3650 error_exit "myRUNAS command must be specified for check_runas_id"
3653 $myRUNAS krb5_login.sh || \
3654 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3656 mkdir $DIR/d0_runas_test
3658 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3659 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3660 rm -rf $DIR/d0_runas_test
3665 local myRUNAS_UID=$1
3666 local myRUNAS_GID=$2
3669 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3670 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3671 Please set RUNAS_ID to some UID which exists on MDS and client or
3672 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3675 # obtain the UID/GID for MPI_USER
3679 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3680 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3682 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3683 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3686 # obtain and cache Kerberos ticket-granting ticket
3687 refresh_krb5_tgt() {
3688 local myRUNAS_UID=$1
3689 local myRUNAS_GID=$2
3692 if [ -z "$myRUNAS" ]; then
3693 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3696 CLIENTS=${CLIENTS:-$HOSTNAME}
3697 do_nodes $CLIENTS "set -x
3698 if ! $myRUNAS krb5_login.sh; then
3699 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3704 # Run multiop in the background, but wait for it to print
3705 # "PAUSING" to its stdout before returning from this function.
3706 multiop_bg_pause() {
3707 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3711 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3714 echo "$MULTIOP_PROG $FILE v$ARGS"
3715 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3717 echo "TMPPIPE=${TMPPIPE}"
3718 read -t 60 multiop_output < $TMPPIPE
3719 if [ $? -ne 0 ]; then
3724 if [ "$multiop_output" != "PAUSING" ]; then
3725 echo "Incorrect multiop output: $multiop_output"
3740 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3746 inodes_available () {
3747 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3751 mdsrate_inodes_available () {
3752 local min_inodes=$(inodes_available)
3753 echo $((min_inodes * 99 / 100))
3756 # reset llite stat counters
3757 clear_llite_stats(){
3758 lctl set_param -n llite.*.stats 0
3761 # sum llite stat items
3762 calc_llite_stats() {
3763 local res=$(lctl get_param -n llite.*.stats |
3764 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3768 # reset osc stat counters
3770 lctl set_param -n osc.*.osc_stats 0
3773 # sum osc stat items
3775 local res=$(lctl get_param -n osc.*.osc_stats |
3776 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3781 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3784 calc_osc_kbytes () {
3785 df $MOUNT > /dev/null
3786 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3789 # save_lustre_params(node, parameter_mask)
3790 # generate a stream of formatted strings (<node> <param name>=<param value>)
3791 save_lustre_params() {
3793 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3796 # restore lustre parameters from input stream, produces by save_lustre_params
3797 restore_lustre_params() {
3801 while IFS=" =" read node name val; do
3802 do_node ${node//:/} "lctl set_param -n $name $val"
3806 check_catastrophe() {
3807 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3808 local C=$CATASTROPHE
3809 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3811 if [ $rnodes ]; then
3812 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3813 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3829 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3831 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3832 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3833 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3837 # CMD: determine mds index where directory inode presents
3840 local file=$dir/f0.get_mds_dir_tmpfile
3845 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3846 local -a oldused=($iused)
3848 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3850 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3851 local -a newused=($iused)
3854 for ((i=0; i<${#newused[@]}; i++)); do
3855 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3861 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3864 mdsrate_cleanup () {
3866 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3871 delayed_recovery_enabled () {
3872 local var=${SINGLEMDS}_svc
3873 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3876 ########################
3878 convert_facet2label() {
3881 if [ x$facet = xost ]; then
3885 local varsvc=${facet}_svc
3887 if [ -n ${!varsvc} ]; then
3890 error "No lablel for $facet!"
3894 get_clientosc_proc_path() {
3895 echo "${1}-osc-[^M]*"
3898 get_lustre_version () {
3899 local facet=${1:-"$SINGLEMDS"}
3900 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3903 get_mds_version_major () {
3904 local facet=${1:-"$SINGLEMDS"}
3905 local version=$(get_lustre_version $facet)
3906 echo $version | awk -F. '{print $1}'
3909 get_mds_version_minor () {
3910 local facet=${1:-"$SINGLEMDS"}
3911 local version=$(get_lustre_version $facet)
3912 echo $version | awk -F. '{print $2}'
3915 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3916 # used by MDT would not be changed.
3917 # mdt lov: fsname-mdtlov
3918 # mdt osc: fsname-OSTXXXX-osc
3919 mds_on_old_device() {
3920 local mds=${1:-"$SINGLEMDS"}
3921 local major=$(get_mds_version_major $mds)
3922 local minor=$(get_mds_version_minor $mds)
3924 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3925 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3926 > /dev/null 2>&1" && return 0
3931 get_mdtosc_proc_path() {
3933 local ost_label=${2:-"*OST*"}
3935 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3936 local mdt_label=$(convert_facet2label $mds_facet)
3937 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3939 local major=$(get_mds_version_major $mds_facet)
3940 local minor=$(get_mds_version_minor $mds_facet)
3941 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3942 echo "${ost_label}-osc"
3944 echo "${ost_label}-osc-${mdt_index}"
3948 get_osc_import_name() {
3951 local label=$(convert_facet2label $ost)
3953 if [ "${facet:0:3}" = "mds" ]; then
3954 get_mdtosc_proc_path $facet $label
3958 get_clientosc_proc_path $label
3962 _wait_import_state () {
3965 local maxtime=${3:-$(max_recovery_time)}
3969 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3970 while [ "${CONN_STATE}" != "${expected}" ]; do
3971 if [ "${expected}" == "DISCONN" ]; then
3972 # for disconn we can check after proc entry is removed
3973 [ "x${CONN_STATE}" == "x" ] && return 0
3974 # with AT enabled, we can have connect request timeout near of
3975 # reconnect timeout and test can't see real disconnect
3976 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3978 [ $i -ge $maxtime ] && \
3979 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3982 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3986 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3990 wait_import_state() {
3993 local maxtime=${3:-$(max_recovery_time)}
3996 for param in ${params//,/ }; do
3997 _wait_import_state $state $param $maxtime || return
4001 # One client request could be timed out because server was not ready
4002 # when request was sent by client.
4003 # The request timeout calculation details :
4005 # /* We give the server rq_timeout secs to process the req, and
4006 # add the network latency for our local timeout. */
4007 # request->rq_deadline = request->rq_sent + request->rq_timeout +
4008 # ptlrpc_at_get_net_latency(request) ;
4010 # ptlrpc_connect_import ()
4011 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
4014 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
4015 # ptlrpc_at_get_net_latency(request) ->
4016 # at_get (max (iat_net_latency=0, at_min)) = at_min
4019 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
4020 # INITIAL_CONNECT_TIMEOUT + at_min
4022 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
4023 # because we can not get this value in runtime,
4024 # the value depends on configure options, and it is not stored in /proc.
4026 # #define CONNECTION_SWITCH_MIN 5U
4028 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4030 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/2)
4032 request_timeout () {
4035 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
4036 local init_connect_timeout=$TIMEOUT
4037 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
4039 local at_min=$(at_get $facet at_min)
4041 echo $(( init_connect_timeout + at_min ))
4044 wait_osc_import_state() {
4048 local ost=$(get_osc_import_name $facet $ost_facet)
4050 local param="osc.${ost}.ost_server_uuid"
4052 # 1. wait the deadline of client 1st request (it could be skipped)
4053 # 2. wait the deadline of client 2nd request
4054 local maxtime=$(( 2 * $(request_timeout $facet)))
4056 if ! do_rpc_nodes $(facet_host $facet) \
4057 _wait_import_state $expected $param $maxtime; then
4058 error "import is not in ${expected} state"
4065 get_clientmdc_proc_path() {
4073 # Add paths to lustre tests for 32 and 64 bit systems.
4074 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
4075 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
4078 wait_clients_import_state () {
4085 if [ "$FAILURE_MODE" = HARD ]; then
4086 facets=$(facets_on_host $(facet_active_host $facet))
4089 for facet in ${facets//,/ }; do
4090 local label=$(convert_facet2label $facet)
4093 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
4094 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
4095 *) error "unknown facet!" ;;
4097 local params=$(expand_list $params $proc_path)
4100 if ! do_rpc_nodes $list wait_import_state $expected $params; then
4101 error "import is not in ${expected} state"
4110 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
4111 $LCTL get_param obdfilter.*.kbytesavail))
4112 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
4113 $LCTL get_param -n obdfilter.*.tot_granted))
4114 for ((i=0; i<${#AVAILA[@]}; i++)); do
4115 local -a AVAIL1=(${AVAILA[$i]//=/ })
4116 GRANT=$((${GRANTA[$i]}/1024))
4117 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
4118 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
4124 do_facet mgs lctl pool_list $1
4128 local fsname=${1%%.*}
4129 local poolname=${1##$fsname.}
4131 do_facet mgs lctl pool_new $1
4133 # get param should return err unless pool is created
4134 [[ $RC -ne 0 ]] && return $RC
4136 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
4137 2>/dev/null || echo foo" "" || RC=1
4138 if [[ $RC -eq 0 ]]; then
4141 error "pool_new failed $1"
4146 add_pool_to_list () {
4147 local fsname=${1%%.*}
4148 local poolname=${1##$fsname.}
4150 local listvar=${fsname}_CREATED_POOLS
4151 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
4154 remove_pool_from_list () {
4155 local fsname=${1%%.*}
4156 local poolname=${1##$fsname.}
4158 local listvar=${fsname}_CREATED_POOLS
4159 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
4162 destroy_pool_int() {
4164 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
4165 awk '$1 !~ /^Pool:/ {print $1}')
4166 for ost in $OSTS; do
4167 do_facet mgs lctl pool_remove $1 $ost
4169 do_facet mgs lctl pool_destroy $1
4172 # <fsname>.<poolname> or <poolname>
4174 local fsname=${1%%.*}
4175 local poolname=${1##$fsname.}
4177 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
4181 pool_list $fsname.$poolname || return $?
4183 destroy_pool_int $fsname.$poolname
4185 [[ $RC -ne 0 ]] && return $RC
4187 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
4188 2>/dev/null || echo foo" "foo" || RC=1
4190 if [[ $RC -eq 0 ]]; then
4191 remove_pool_from_list $fsname.$poolname
4193 error "destroy pool failed $1"
4199 local fsname=${1:-$FSNAME}
4201 local listvar=${fsname}_CREATED_POOLS
4205 [ x${!listvar} = x ] && return 0
4207 echo destroy the created pools: ${!listvar}
4208 for poolname in ${!listvar//,/ }; do
4209 destroy_pool $fsname.$poolname
4214 local fsname=${1:-$FSNAME}
4216 destroy_pools $fsname
4222 local ts=$(date +%s)
4224 [ -f $LOGDIR/shared ] && docp=false
4226 # dump lustre logs, dmesg
4228 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4230 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4232 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4233 echo "Dumping logs only on local client."
4234 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
4235 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
4240 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
4241 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
4242 if [ ! -f $LOGDIR/shared ]; then
4243 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4246 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
4247 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
4253 local list=${1:-$(comma_list $(nodes_list))}
4255 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
4267 for i in $(seq 0 $num_mntpts); do
4268 cmd="ls -laf ${mntpt_root}$i/$dir"
4274 for pid in $pids; do
4281 # target_start_and_reset_recovery_timer()
4282 # service_time = at_est2timeout(service_time);
4283 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4284 # INITIAL_CONNECT_TIMEOUT);
4285 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4286 #define CONNECTION_SWITCH_INC 1
4287 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4288 #define CONNECTION_SWITCH_MIN 5U
4290 max_recovery_time () {
4291 local init_connect_timeout=$(( TIMEOUT / 20 ))
4292 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
4294 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4299 get_clients_mount_count () {
4300 local clients=${CLIENTS:-`hostname`}
4302 # we need to take into account the clients mounts and
4303 # exclude mds/ost mounts if any;
4304 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4308 PROC_CLI="srpc_info"
4316 if [ $M -lt $N ]; then
4320 while [ $N -lt $M ]; do
4330 calc_connection_cnt() {
4333 # MDT->MDT = 2 * C(M, 2)
4337 comb_m2=$(combination $MDSCOUNT 2)
4339 local num_clients=$(get_clients_mount_count)
4341 local cnt_mdt2mdt=$((comb_m2 * 2))
4342 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4343 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4344 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4345 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4346 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4347 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4361 local cmd="$tgt.srpc.flavor"
4363 if [ $net == "any" ]; then
4368 if [ $dir != "any" ]; then
4373 log "Setting sptlrpc rule: $cmd"
4374 do_facet mgs "$LCTL conf_param $cmd"
4383 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4384 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4386 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4388 if [ "x$bulkspec" != "x" ]; then
4389 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4391 if [ "x$algs" != "x" ]; then
4392 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4394 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4395 if [ $bulk == "bulkn" ]; then
4396 bulk_count=`echo "$output" | grep "bulk flavor" \
4397 | grep "null/null" | wc -l`
4398 elif [ $bulk == "bulki" ]; then
4399 bulk_count=`echo "$output" | grep "bulk flavor" \
4400 | grep "/null" | grep -v "null/" | wc -l`
4402 bulk_count=`echo "$output" | grep "bulk flavor" \
4403 | grep -v "/null" | grep -v "null/" | wc -l`
4407 [ $bulk_count -lt $count ] && count=$bulk_count
4418 local clients=${CLIENTS:-`hostname`}
4420 for c in ${clients//,/ }; do
4421 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4422 tmpcnt=`count_flvr "$output" $flavor`
4423 cnt=$((cnt + tmpcnt))
4433 local clients=${CLIENTS:-`hostname`}
4435 for c in ${clients//,/ }; do
4436 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4437 tmpcnt=`count_flvr "$output" $flavor`
4438 cnt=$((cnt + tmpcnt))
4448 if [ $MDSCOUNT -le 1 ]; then
4453 for num in `seq $MDSCOUNT`; do
4454 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4455 tmpcnt=`count_flvr "$output" $flavor`
4456 cnt=$((cnt + tmpcnt))
4467 for num in `seq $MDSCOUNT`; do
4468 mdtosc=$(get_mdtosc_proc_path mds$num)
4469 mdtosc=${mdtosc/-MDT*/-MDT\*}
4470 output=$(do_facet mds$num lctl get_param -n \
4471 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4472 tmpcnt=`count_flvr "$output" $flavor`
4473 cnt=$((cnt + tmpcnt))
4482 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4483 count_flvr "$output" $flavor
4488 local dir=$1 # from to
4489 local flavor=$2 # flavor expected
4492 if [ $dir == "cli2mdt" ]; then
4493 res=`flvr_cnt_cli2mdt $flavor`
4494 elif [ $dir == "cli2ost" ]; then
4495 res=`flvr_cnt_cli2ost $flavor`
4496 elif [ $dir == "mdt2mdt" ]; then
4497 res=`flvr_cnt_mdt2mdt $flavor`
4498 elif [ $dir == "mdt2ost" ]; then
4499 res=`flvr_cnt_mdt2ost $flavor`
4500 elif [ $dir == "all2ost" ]; then
4501 res1=`flvr_cnt_mdt2ost $flavor`
4502 res2=`flvr_cnt_cli2ost $flavor`
4503 res=$((res1 + res2))
4504 elif [ $dir == "all2mdt" ]; then
4505 res1=`flvr_cnt_mdt2mdt $flavor`
4506 res2=`flvr_cnt_cli2mdt $flavor`
4507 res=$((res1 + res2))
4508 elif [ $dir == "all2all" ]; then
4509 res1=`flvr_cnt_mdt2ost $flavor`
4510 res2=`flvr_cnt_cli2ost $flavor`
4511 res3=`flvr_cnt_mdt2mdt $flavor`
4512 res4=`flvr_cnt_cli2mdt $flavor`
4513 res=$((res1 + res2 + res3 + res4))
4521 local dir=$1 # from to
4522 local flavor=$2 # flavor expected
4523 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4527 for ((i=0;i<20;i++)); do
4528 echo -n "checking $dir..."
4529 res=$(do_check_flavor $dir $flavor)
4530 echo "found $res/$expect $flavor connections"
4531 [ $res -eq $expect ] && return 0
4535 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4539 restore_to_default_flavor()
4541 local proc="mgs.MGS.live.$FSNAME"
4543 echo "restoring to default flavor..."
4545 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4547 # remove all existing rules if any
4548 if [ $nrule -ne 0 ]; then
4549 echo "$nrule existing rules"
4550 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4551 echo "remove rule: $rule"
4552 spec=`echo $rule | awk -F = '{print $1}'`
4553 do_facet mgs "$LCTL conf_param -d $spec"
4557 # verify no rules left
4558 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4559 [ $nrule -ne 0 ] && error "still $nrule rules left"
4561 # wait for default flavor to be applied
4562 # currently default flavor for all connections are 'null'
4563 wait_flavor all2all null
4564 echo "now at default flavor settings"
4569 local flavor=${1:-null}
4571 echo "setting all flavor to $flavor"
4573 # FIXME need parameter to this fn
4574 # and remove global vars
4575 local cnt_all2all=$(calc_connection_cnt all2all)
4577 local res=$(do_check_flavor all2all $flavor)
4578 if [ $res -eq $cnt_all2all ]; then
4579 echo "already have total $res $flavor connections"
4583 echo "found $res $flavor out of total $cnt_all2all connections"
4584 restore_to_default_flavor
4586 [[ $flavor = null ]] && return 0
4588 set_rule $FSNAME any any $flavor
4589 wait_flavor all2all $flavor
4595 # Checking for shared logdir
4596 if [ ! -d $dir ]; then
4597 # Not found. Create local logdir
4600 touch $dir/node.$(hostname -s).yml
4605 check_write_access() {
4607 for node in $(nodes_list); do
4608 if [ ! -f "$dir/node.$(short_hostname ${node}).yml" ]; then
4609 # Logdir not accessible/writable from this node.
4617 if [[ -n $YAML_LOG ]]; then
4620 local SAVE_UMASK=`umask`
4623 export YAML_LOG=${LOGDIR}/results.yml
4627 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4628 if check_write_access $LOGDIR; then
4629 touch $LOGDIR/shared
4630 echo "Logging to shared log directory: $LOGDIR"
4632 echo "Logging to local directory: $LOGDIR"
4635 yml_nodes_file $LOGDIR >> $YAML_LOG
4636 yml_results_file >> $YAML_LOG
4642 yml_log_test $1 >> $YAML_LOG
4646 yml_log_test_status $@ >> $YAML_LOG
4649 log_sub_test_begin() {
4650 yml_log_sub_test_begin "$@" >> $YAML_LOG
4653 log_sub_test_end() {
4654 yml_log_sub_test_end "$@" >> $YAML_LOG
4660 local llverdev_opts=$2
4661 local devname=$(basename $1)
4662 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4663 # loop devices aren't in /proc/partitions
4664 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4666 size=$(($size / 1024 / 1024)) # Gb
4668 local partial_arg=""
4669 # Run in partial (fast) mode if the size
4670 # of a partition > 1 GB
4671 [ $size -gt 1 ] && partial_arg="-p"
4673 llverdev --force $partial_arg $llverdev_opts $dev
4679 local llverfs_opts=$2
4680 local partial_arg=""
4681 local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
4683 # Run in partial (fast) mode if the size
4684 # of a partition > 1 GB
4685 [ $size -gt 1 ] && partial_arg="-p"
4687 llverfs $partial_arg $llverfs_opts $dir
4690 remove_mdt_files() {
4695 local mntpt=$(facet_mntpt $facet)
4697 echo "removing files from $mdtdev on $facet: $files"
4698 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4701 rm $mntpt/ROOT/$f || { rc=$?; break; }
4703 umount -f $mntpt || return $?
4707 duplicate_mdt_files() {
4712 local mntpt=$(facet_mntpt $facet)
4714 echo "duplicating files on $mdtdev on $facet: $files"
4715 mkdir -p $mntpt || return $?
4716 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4726 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4727 pushd $mntpt/ROOT > /dev/null || return $?
4730 touch $f.bad || return $?
4731 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4733 [ $rc -eq 0 ] || return $rc
4734 setfattr --restore $tmp || return $?
4740 local devs=${1//,/ }
4743 local rslt=$TMP/sgpdd_survey
4745 # sgpdd-survey cleanups ${rslt}.* files
4747 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4753 # returns the canonical name for an ldiskfs device
4758 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4759 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4760 echo dm-\\\${foo##*:};
4762 echo \\\$(basename \\\$dv);
4766 is_sanity_benchmark() {
4767 local benchmarks="dbench bonnie iozone fsx"
4769 for b in $benchmarks; do
4770 if [ "$b" == "$suite" ]; then
4778 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1