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`}
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 load_modules_local() {
334 if [ -n "$MODPROBE" ]; then
336 echo "Using modprobe to load modules"
340 echo Loading modules from $LUSTRE
341 load_module ../libcfs/libcfs/libcfs
342 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
343 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
344 load_module ../lnet/lnet/lnet
345 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
346 load_module ../lnet/klnds/$LNETLND
347 load_module lvfs/lvfs
348 load_module obdclass/obdclass
349 load_module ptlrpc/ptlrpc
350 load_module ptlrpc/gss/ptlrpc_gss
351 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
359 if ! client_only; then
360 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
361 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
362 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
363 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
368 load_module lvfs/fsfilt_$FSTYPE
370 load_module osd-ldiskfs/osd_ldiskfs
372 load_module obdfilter/obdfilter
375 load_module_llite_lloop() {
376 local n1=$(uname -r | cut -d. -f1)
377 local n2=$(uname -r | cut -d. -f2)
378 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
380 # load the llite_lloop module for < 2.6.32 kernels
381 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
382 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
384 load_module llite/llite_lloop
388 load_module llite/lustre
389 load_module_llite_lloop
390 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
392 rm -f $OGDB/ogdb-$HOSTNAME
393 $LCTL modules > $OGDB/ogdb-$HOSTNAME
395 # 'mount' doesn't look in $PATH, just sbin
396 if [ -f $LUSTRE/utils/mount.lustre ] && \
397 ! grep -qe "/sbin/mount\.lustre " /proc/mounts; then
398 [ ! -f /sbin/mount.lustre ] && touch /sbin/mount.lustre
399 mount --bind $LUSTRE/utils/mount.lustre /sbin/mount.lustre || true
406 # load modules on remote nodes optionally
407 # lustre-tests have to be installed on these nodes
408 if $LOAD_MODULES_REMOTE ; then
409 local list=$(comma_list $(remote_nodes_list))
410 echo loading modules on $list
411 do_rpc_nodes $list load_modules
416 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
417 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
418 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
419 echo "$LEAK_LUSTRE" 1>&2
420 echo "$LEAK_PORTALS" 1>&2
421 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
422 echo "Memory leaks detected"
423 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
429 wait_exit_ST client # bug 12845
431 $LUSTRE_RMMOD $FSTYPE || return 2
433 if $LOAD_MODULES_REMOTE ; then
434 local list=$(comma_list $(remote_nodes_list))
435 if [ ! -z $list ]; then
436 echo unloading modules on $list
437 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
438 do_rpc_nodes $list check_mem_leak
442 if grep -qe "/sbin/mount\.lustre" /proc/mounts; then
443 umount /sbin/mount.lustre || true
444 [ -w /sbin/mount.lustre -a ! -s /sbin/mount.lustre ] && \
445 rm -f /sbin/mount.lustre || true
448 check_mem_leak || return 254
450 echo "modules unloaded."
454 check_gss_daemon_nodes() {
458 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
459 if [ \\\"\\\$num\\\" -ne 1 ]; then
460 echo \\\$num instance of $dname;
465 check_gss_daemon_facet() {
469 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
470 if [ $num -ne 1 ]; then
471 echo "$num instance of $dname on $facet"
480 echo Stopping $@ on $list
481 do_nodes $list "killall -2 $@ 2>/dev/null || true"
484 # start gss daemons on all nodes, or
485 # "daemon" on "list" if set
486 start_gss_daemons() {
490 if [ "$list" ] && [ "$daemon" ] ; then
491 echo "Starting gss daemon on nodes: $list"
492 do_nodes $list "$daemon" || return 8
496 local list=$(comma_list $(mdts_nodes))
498 echo "Starting gss daemon on mds: $list"
499 do_nodes $list "$LSVCGSSD -v" || return 1
501 do_nodes $list "$LGSSD -v" || return 2
504 list=$(comma_list $(osts_nodes))
505 echo "Starting gss daemon on ost: $list"
506 do_nodes $list "$LSVCGSSD -v" || return 3
507 # starting on clients
509 local clients=${CLIENTS:-`hostname`}
511 echo "Starting $LGSSD on clients $clients "
512 do_nodes $clients "$LGSSD -v" || return 4
515 # wait daemons entering "stable" status
519 # check daemons are running
521 list=$(comma_list $(mdts_nodes) $(osts_nodes))
522 check_gss_daemon_nodes $list lsvcgssd || return 5
524 list=$(comma_list $(mdts_nodes))
525 check_gss_daemon_nodes $list lgssd || return 6
528 check_gss_daemon_nodes $clients lgssd || return 7
533 local list=$(comma_list $(mdts_nodes))
535 send_sigint $list lsvcgssd lgssd
537 list=$(comma_list $(osts_nodes))
538 send_sigint $list lsvcgssd
540 list=${CLIENTS:-`hostname`}
541 send_sigint $list lgssd
546 if ! module_loaded ptlrpc_gss; then
547 load_module ptlrpc/gss/ptlrpc_gss
548 module_loaded ptlrpc_gss ||
549 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
551 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
553 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
554 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
562 # maybe cleanup credential cache?
568 local device=`mdsdevname $num`
569 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
575 local device=`ostdevname $num`
576 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
581 local dz=${1:-$DEBUG_SIZE}
582 local cpus=$(getconf _NPROCESSORS_CONF)
584 # bug 19944, adjust size to be -gt num_possible_cpus()
585 # promise 2MB for every cpu at least
586 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
589 lctl set_param debug_mb=$dz
592 set_default_debug () {
593 local debug=${1:-"$PTLDEBUG"}
594 local subsystem_debug=${2:-"$SUBSYSTEM"}
595 local debug_size=${3:-$DEBUG_SIZE}
597 lctl set_param debug="$debug"
598 lctl set_param subsystem_debug="${subsystem_debug# }"
600 set_debug_size $debug_size
604 set_default_debug_nodes () {
607 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
608 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
612 [[ -n $nodes ]] && do_rpc_nodes $nodes set_default_debug \
613 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
616 set_default_debug_facet () {
618 local node=$(facet_active_host $facet)
619 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
621 set_default_debug_nodes $node
626 local facets=${1:-$(get_facets)}
629 for facet in ${facets//,/ }; do
630 mount_facet $facet || error "Restart of $facet failed!"
637 local dev=$(facet_active $facet)_dev
638 local opt=${facet}_opt
639 local mntpt=$(facet_mntpt $facet)
641 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
642 do_facet ${facet} "mkdir -p $mntpt; mount -t lustre ${!opt} $@ ${!dev} $mntpt"
644 if [ $RC -ne 0 ]; then
645 echo "mount -t lustre $@ ${!dev} $mntpt"
646 echo "Start of ${!dev} on ${facet} failed ${RC}"
648 set_default_debug_facet $facet
650 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
651 [ -z "$label" ] && echo no label for ${!dev} && exit 1
652 eval export ${facet}_svc=${label}
653 echo Started ${label}
658 # start facet device options
664 eval export ${facet}_dev=${device}
665 eval export ${facet}_opt=\"$@\"
667 local varname=${facet}failover_dev
668 if [ -n "${!varname}" ] ; then
669 eval export ${facet}failover_dev=${!varname}
671 eval export ${facet}failover_dev=$device
674 local mntpt=$(facet_mntpt $facet)
675 do_facet ${facet} mkdir -p $mntpt
676 eval export ${facet}_MOUNT=$mntpt
686 local HOST=`facet_active_host $facet`
687 [ -z $HOST ] && echo stop: no host for $facet && return 0
689 local mntpt=$(facet_mntpt $facet)
690 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
691 if [ ${running} -ne 0 ]; then
692 echo "Stopping $mntpt (opts:$@)"
693 do_facet ${facet} umount -d $@ $mntpt
696 # umount should block, but we should wait for unrelated obd's
697 # like the MGS or MGC to also stop.
698 wait_exit_ST ${facet}
701 # save quota version (both administrative and operational quotas)
702 # add an additional parameter if mountpoint is ever different from $MOUNT
703 quota_save_version() {
704 local fsname=${2:-$FSNAME}
706 local ver=$(tr -c -d "123" <<< $spec)
707 local type=$(tr -c -d "ug" <<< $spec)
709 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
711 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
713 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
715 local osts=$(get_facets OST)
716 for ost in ${osts//,/ }; do
718 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
722 # client could mount several lustre
724 local fsname=${1:-$FSNAME}
726 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
727 do_nodes $(comma_list $(osts_nodes)) \
728 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
732 restore_quota_type () {
733 local mntpt=${1:-$MOUNT}
734 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
735 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
738 quota_save_version $old_QUOTA_TYPE
744 # We need save the original quota_type params, and restore them after testing
746 # Suppose that quota type the same on mds and ost
747 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
748 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
749 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
750 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
751 export old_QUOTA_TYPE=$quota_type
752 quota_save_version $QUOTA_TYPE
754 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
755 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
758 local quota_usrs=$QUOTA_USERS
760 # get_filesystem_size
761 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
762 local blk_soft=$((disksz + 1024))
763 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
765 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
767 local i_hard=$((i_soft + i_soft / 20))
769 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
770 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
773 for usr in $quota_usrs; do
774 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
776 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
778 eval $cmd || error "$cmd FAILED!"
780 # display the quota status
781 echo "Quota settings for $usr : "
782 $LFS quota -v -u $usr $mntpt || true
789 local OPTIONS=${3:-$MOUNTOPT}
791 local device=$MGSNID:/$FSNAME
792 if [ -z "$mnt" -o -z "$FSNAME" ]; then
793 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
797 echo "Starting client: $client: $OPTIONS $device $mnt"
798 do_node $client mkdir -p $mnt
799 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
801 set_default_debug_nodes $client
814 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
815 if [ $running -ne 0 ]; then
816 echo "Stopping client $client $mnt (opts:$force)"
817 do_node $client lsof -t $mnt || need_kill=no
818 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
819 pids=$(do_node $client lsof -t $mnt | sort -u);
820 if [ -n $pids ]; then
821 do_node $client kill -9 $pids || true
825 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
826 if [ $busy -ne 0 ] ; then
827 echo "$mnt is still busy, wait one second" && sleep 1
828 do_node $client umount $force $mnt
833 # nodes is comma list
834 sanity_mount_check_nodes () {
840 # FIXME: assume that all cluster nodes run the same os
841 [ "$(uname)" = Linux ] || return 0
844 for mnt in $mnts ; do
845 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
846 mpts=\\\$(mount | grep -w -c $mnt);
847 if [ \\\$running -ne \\\$mpts ]; then
848 echo \\\$(hostname) env are INSANE!;
856 sanity_mount_check_servers () {
858 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
859 echo Checking servers environments
861 # FIXME: modify get_facets to display all facets wo params
862 local facets="$(get_facets OST),$(get_facets MDS),mgs"
866 for facet in ${facets//,/ }; do
867 node=$(facet_host ${facet})
868 mntpt=$(facet_mntpt $facet)
869 sanity_mount_check_nodes $node $mntpt ||
870 { error "server $node environments are insane!"; return 1; }
874 sanity_mount_check_clients () {
875 local clients=${1:-$CLIENTS}
876 local mntpt=${2:-$MOUNT}
877 local mntpt2=${3:-$MOUNT2}
879 [ -z $clients ] && clients=$(hostname)
880 echo Checking clients $clients environments
882 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
883 error "clients environments are insane!"
886 sanity_mount_check () {
887 sanity_mount_check_servers || return 1
888 sanity_mount_check_clients || return 2
891 # mount clients if not mouted
892 zconf_mount_clients() {
895 local OPTIONS=${3:-$MOUNTOPT}
897 local device=$MGSNID:/$FSNAME
898 if [ -z "$mnt" -o -z "$FSNAME" ]; then
899 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
903 echo "Starting client $clients: $OPTIONS $device $mnt"
906 running=\\\$(mount | grep -c $mnt' ');
908 if [ \\\$running -eq 0 ] ; then
910 mount -t lustre $OPTIONS $device $mnt;
913 exit \\\$rc" || return ${PIPESTATUS[0]}
915 echo "Started clients $clients: "
916 do_nodes $clients "mount | grep -w $mnt"
918 set_default_debug_nodes $clients
923 zconf_umount_clients() {
930 echo "Stopping clients: $clients $mnt (opts:$force)"
931 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
932 if [ \\\$running -ne 0 ] ; then
933 echo Stopping client \\\$(hostname) $mnt opts:$force;
934 lsof -t $mnt || need_kill=no;
935 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
936 pids=\\\$(lsof -t $mnt | sort -u);
937 if [ -n \\\"\\\$pids\\\" ]; then
941 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
942 if [ \\\$busy -ne 0 ] ; then
943 echo "$mnt is still busy, wait one second" && sleep 1;
951 echo + $POWER_DOWN $node
955 shutdown_node_hard () {
957 local attempts=$SHUTDOWN_ATTEMPTS
959 for i in $(seq $attempts) ; do
962 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
963 echo "waiting for $host to fail attempts=$attempts"
964 [ $i -lt $attempts ] || \
965 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
971 local mnt=${2:-$MOUNT}
974 if [ "$FAILURE_MODE" = HARD ]; then
975 shutdown_node_hard $client
977 zconf_umount_clients $client $mnt -f
983 local facets="$(get_facets OST),$(get_facets MDS)"
986 combined_mgs_mds || facets="$facets,mgs"
988 for facet in ${facets//,/ }; do
989 if [ $(facet_active_host $facet) == $host ]; then
990 affected="$affected $facet"
994 echo $(comma_list $affected)
999 local host=${2:-$(facet_host $facet)}
1001 local label=$(convert_facet2label $facet)
1002 do_node $host lctl dl | awk '{print $4}' | grep -q $label
1005 facets_up_on_host () {
1007 local facets=$(facets_on_host $host)
1010 for facet in ${facets//,/ }; do
1011 if $(facet_up $facet $host); then
1012 affected_up="$affected_up $facet"
1016 echo $(comma_list $affected_up)
1022 if [ "$FAILURE_MODE" = HARD ]; then
1023 shutdown_node_hard $(facet_active_host $facet)
1031 echo + $POWER_UP $node
1044 if [ "$FAILURE_MODE" = HARD ]; then
1045 reboot_node $(facet_active_host $facet)
1053 if [ "$FAILURE_MODE" = HARD ]; then
1063 for facet in ${facets//,/ }; do
1064 hosts=$(expand_list $hosts $(facet_host $facet) )
1070 _check_progs_installed () {
1074 for prog in $progs; do
1075 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1076 echo $prog missing on $(hostname)
1083 check_progs_installed () {
1087 do_rpc_nodes $nodes _check_progs_installed $@
1090 # recovery-scale functions
1092 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1095 start_client_load() {
1098 local var=$(node_var_name $client)_load
1099 eval export ${var}=$load
1101 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1102 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1103 END_RUN_FILE=$END_RUN_FILE \
1104 LOAD_PID_FILE=$LOAD_PID_FILE \
1105 TESTSUITELOG=$TESTSUITELOG \
1107 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
1108 log "Started client load: ${load} on $client"
1113 start_client_loads () {
1114 local -a clients=(${1//,/ })
1115 local numloads=${#CLIENT_LOADS[@]}
1118 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1119 testnum=$((nodenum % numloads))
1120 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1122 # bug 22169: wait the background threads to start
1126 # only for remote client
1127 check_client_load () {
1129 local var=$(node_var_name $client)_load
1130 local TESTLOAD=run_${!var}.sh
1132 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1134 # bug 18914: try to connect several times not only when
1135 # check ps, but while check_catastrophe also
1138 while [ $RC = 254 -a $tries -gt 0 ]; do
1142 if ! check_catastrophe $client; then
1144 if [ $RC -eq 254 ]; then
1145 # FIXME: not sure how long we shuold sleep here
1149 echo "check catastrophe failed: RC=$RC "
1153 # We can continue try to connect if RC=254
1154 # Just print the warning about this
1155 if [ $RC = 254 ]; then
1156 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1159 # see if the load is still on the client
1162 while [ $RC = 254 -a $tries -gt 0 ]; do
1166 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1171 if [ $RC = 254 ]; then
1172 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1173 # see if we can diagnose a bit why this is
1178 check_client_loads () {
1179 local clients=${1//,/ }
1183 for client in $clients; do
1184 check_client_load $client
1186 if [ "$rc" != 0 ]; then
1187 log "Client load failed on node $client, rc=$rc"
1193 restart_client_loads () {
1194 local clients=${1//,/ }
1195 local expectedfail=${2:-""}
1199 for client in $clients; do
1200 check_client_load $client
1202 if [ "$rc" != 0 -a "$expectedfail" ]; then
1203 local var=$(node_var_name $client)_load
1204 start_client_load $client ${!var}
1205 echo "Restarted client load ${!var}: on $client. Checking ..."
1206 check_client_load $client
1208 if [ "$rc" != 0 ]; then
1209 log "Client load failed to restart on node $client, rc=$rc"
1210 # failure one client load means test fail
1211 # we do not need to check other
1219 # End recovery-scale functions
1221 # verify that lustre actually cleaned up properly
1223 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1224 error "LBUG/LASSERT detected"
1225 BUSY=`dmesg | grep -i destruct || true`
1226 if [ "$BUSY" ]; then
1228 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1232 check_mem_leak || exit 204
1234 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1235 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1237 if module_loaded lnet || module_loaded libcfs; then
1238 echo "$0: modules still loaded..." 1>&2
1255 RESULT=$(do_node $node "$TEST")
1256 if [ "$RESULT" == "$FINAL" ]; then
1257 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1260 [ $WAIT -ge $MAX ] && break
1261 echo "Waiting $((MAX - WAIT)) secs for update"
1262 WAIT=$((WAIT + sleep))
1265 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1269 wait_update_facet () {
1271 wait_update $(facet_active_host $facet) "$@"
1274 wait_delete_completed () {
1275 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1276 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1280 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1282 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1283 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1284 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1285 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1289 echo "Delete is not completed in $MAX_WAIT sec"
1296 # we can use "for" here because we are waiting the slowest
1297 for host in ${hostlist//,/ }; do
1298 check_network "$host" 900
1300 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1307 for facet in ${facetlist//,/ }; do
1308 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1310 wait_for_host $hostlist
1313 _wait_recovery_complete () {
1316 # Use default policy if $2 is not passed by caller.
1317 local MAX=${2:-$(max_recovery_time)}
1322 while [ $WAIT -lt $MAX ]; do
1323 STATUS=$(lctl get_param -n $param | grep status)
1325 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1328 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1330 echo "$param recovery not done in $MAX sec. $STATUS"
1334 wait_recovery_complete () {
1337 # with an assumption that at_max is the same on all nodes
1338 local MAX=${2:-$(max_recovery_time)}
1341 if [ "$FAILURE_MODE" = HARD ]; then
1342 facets=$(facets_on_host $(facet_active_host $facet))
1344 echo affected facets: $facets
1346 # we can use "for" here because we are waiting the slowest
1347 for facet in ${facets//,/ }; do
1348 local var_svc=${facet}_svc
1349 local param="*.${!var_svc}.recovery_status"
1351 local host=$(facet_active_host $facet)
1352 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1356 wait_mds_ost_sync () {
1357 # just because recovery is done doesn't mean we've finished
1358 # orphan cleanup. Wait for llogs to get synchronized.
1359 echo "Waiting for orphan cleanup..."
1360 # MAX value includes time needed for MDS-OST reconnection
1361 local MAX=$(( TIMEOUT * 2 ))
1363 while [ $WAIT -lt $MAX ]; do
1364 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1365 "$LCTL get_param -n obdfilter.*.mds_sync"))
1368 for ((i=0; i<${#sync[@]}; i++)); do
1369 [ ${sync[$i]} -eq 0 ] && continue
1370 # there is a not finished MDS-OST synchronization
1374 sleep 2 # increase waiting time and cover statfs cache
1375 [ ${con} -eq 1 ] && return 0
1376 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1379 echo "$facet recovery not done in $MAX sec. $STATUS"
1383 wait_destroy_complete () {
1384 echo "Waiting for destroy to be done..."
1385 # MAX value shouldn't be big as this mean server responsiveness
1386 # never increase this just to make test pass but investigate
1387 # why it takes so long time
1390 while [ $WAIT -lt $MAX ]; do
1391 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1393 for ((i=0; i<${#RPCs[@]}; i++)); do
1394 [ ${RPCs[$i]} -eq 0 ] && continue
1395 # there are still some destroy RPCs in flight
1400 [ ${con} -eq 1 ] && return 0 # done waiting
1401 echo "Waiting $WAIT secs for destroys to be done."
1404 echo "Destroys weren't done in $MAX sec."
1414 # conf-sanity 31 takes a long time cleanup
1415 while [ $WAIT -lt 300 ]; do
1416 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1417 [ -z "${running}" ] && return 0
1418 echo "waited $WAIT for${running}"
1419 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1421 WAIT=$((WAIT + INTERVAL))
1423 echo "service didn't stop after $WAIT seconds. Still running:"
1428 wait_remote_prog () {
1434 [ "$PDSH" = "no_dsh" ] && return 0
1436 while [ $WAIT -lt $2 ]; do
1437 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1438 [ -z "${running}" ] && return 0 || true
1439 echo "waited $WAIT for: "
1441 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1443 WAIT=$((WAIT + INTERVAL))
1445 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1446 [ -z "$pids" ] && return 0
1447 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1448 # FIXME: not portable
1449 for pid in $pids; do
1450 cat /proc/${pid}/status || true
1451 cat /proc/${pid}/wchan || true
1453 kill -9 $pid || true
1462 # not every config has many clients
1464 if [ ! -z "$CLIENTS" ]; then
1465 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1467 stat -f $MOUNT > /dev/null
1473 # usually checked on particular client or locally
1475 if [ ! -z "$client" ]; then
1476 $PDSH $client "stat -f $MOUNT" > /dev/null
1478 stat -f $MOUNT > /dev/null
1486 client_reconnect() {
1487 uname -n >> $MOUNT/recon
1488 if [ -z "$CLIENTS" ]; then
1489 df $MOUNT; uname -n >> $MOUNT/recon
1491 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1493 echo Connected clients:
1495 ls -l $MOUNT/recon > /dev/null
1499 affected_facets () {
1502 local host=$(facet_active_host $facet)
1503 local affected=$facet
1505 if [ "$FAILURE_MODE" = HARD ]; then
1506 affected=$(facets_up_on_host $host)
1514 local host=$(facet_active_host $facet)
1516 echo "Failing $facet on node $host"
1518 local affected=$(affected_facets $facet)
1520 shutdown_facet $facet
1522 echo affected facets: $affected
1524 [ -n "$sleep_time" ] && sleep $sleep_time
1528 change_active $affected
1530 wait_for_facet $affected
1531 # start mgs first if it is affected
1532 if ! combined_mgs_mds && list_member $affected mgs; then
1533 mount_facet mgs || error "Restart of mgs failed"
1535 # FIXME; has to be changed to mount all facets concurrently
1536 affected=$(exclude_items_from_list $affected mgs)
1537 mount_facets $affected
1546 do_facet $facet sync
1549 # make sure there will be no seq change
1550 local clients=${CLIENTS:-$HOSTNAME}
1551 do_nodes $clients "f=${MOUNT}/fsa-\\\$(hostname); mcreate \\\$f; rm \\\$f"
1553 local svc=${facet}_svc
1554 do_facet $facet $LCTL --device %${!svc} notransno
1555 do_facet $facet $LCTL --device %${!svc} readonly
1556 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1557 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1560 replay_barrier_nodf() {
1561 local facet=$1 echo running=${running}
1562 do_facet $facet sync
1563 local svc=${facet}_svc
1564 echo Replay barrier on ${!svc}
1565 do_facet $facet $LCTL --device %${!svc} notransno
1566 do_facet $facet $LCTL --device %${!svc} readonly
1567 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1568 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1571 replay_barrier_nosync() {
1572 local facet=$1 echo running=${running}
1573 local svc=${facet}_svc
1574 echo Replay barrier on ${!svc}
1575 do_facet $facet $LCTL --device %${!svc} notransno
1576 do_facet $facet $LCTL --device %${!svc} readonly
1577 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1578 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1581 mds_evict_client() {
1582 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1583 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1586 ost_evict_client() {
1587 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1588 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1592 facet_failover $* || error "failover: $?"
1593 clients_up || error "post-failover df: $?"
1598 facet_failover $facet
1604 change_active $facet
1605 mount_facet $facet -o abort_recovery
1606 clients_up || echo "first df failed: $?"
1607 clients_up || error "post-failover df: $?"
1611 echo There is no lmc. This is mountconf, baby.
1616 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1622 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1623 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1624 if [ -z "$ID" ]; then
1625 echo "Could not get a ptl id for $1..."
1634 h2name_or_ip "$1" "tcp"
1639 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1640 if type __h2elan >/dev/null 2>&1; then
1643 ID=`echo $1 | sed 's/[^0-9]*//g'`
1651 h2name_or_ip "$1" "o2ib"
1658 [ "$facet" == client ] && echo -n $HOSTNAME && return
1659 varname=${facet}_HOST
1660 if [ -z "${!varname}" ]; then
1661 if [ "${facet:0:3}" == "ost" ]; then
1662 eval ${facet}_HOST=${ost_HOST}
1670 local activevar=${facet}active
1672 if [ -f $TMP/${facet}active ] ; then
1673 source $TMP/${facet}active
1676 active=${!activevar}
1677 if [ -z "$active" ] ; then
1684 facet_active_host() {
1686 local active=`facet_active $facet`
1687 if [ "$facet" == client ]; then
1690 echo `facet_host $active`
1698 facetlist=$(exclude_items_from_list $facetlist mgs)
1700 for facet in ${facetlist//,/ }; do
1701 local failover=${facet}failover
1702 local host=`facet_host $failover`
1703 [ -z "$host" ] && return
1705 local curactive=`facet_active $facet`
1706 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1707 eval export ${facet}active=$facet
1709 eval export ${facet}active=$failover
1711 # save the active host for this facet
1712 local activevar=${facet}active
1713 echo "$activevar=${!activevar}" > $TMP/$activevar
1714 local TO=`facet_active_host $facet`
1715 echo "Failover $facet to $TO"
1721 # do not stripe off hostname if verbose, bug 19215
1722 if [ x$1 = x--verbose ]; then
1730 if [ "$HOST" = "$HOSTNAME" ]; then
1732 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1733 echo "cannot run remote command on $HOST with $myPDSH"
1737 echo "CMD: $HOST $@" >&2
1738 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1741 if [ "$myPDSH" = "rsh" ]; then
1742 # we need this because rsh does not return exit code of an executed command
1743 local command_status="$TMP/cs"
1744 rsh $HOST ":> $command_status"
1745 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1746 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1747 echo command failed >$command_status"
1748 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1753 # print HOSTNAME for myPDSH="no_dsh"
1754 if [[ $myPDSH = no_dsh ]]; then
1755 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1757 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1760 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1762 return ${PIPESTATUS[0]}
1766 do_node --verbose "$@"
1769 single_local_node () {
1770 [ "$1" = "$HOSTNAME" ]
1773 # Outputs environment variable assignments that should be passed to remote nodes
1778 for var in ${!MODOPTS_*}; do
1780 echo "${var}=\"$value\""
1786 # do not stripe off hostname if verbose, bug 19215
1787 if [ x$1 = x--verbose ]; then
1795 if single_local_node $rnodes; then
1797 do_nodev $rnodes "$@"
1799 do_node $rnodes "$@"
1804 # This is part from do_node
1807 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1808 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1811 echo "CMD: $rnodes $@" >&2
1812 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
1815 # do not replace anything from pdsh output if -N is used
1816 # -N Disable hostname: prefix on lines of output.
1817 if $verbose || [[ $myPDSH = *-N* ]]; then
1818 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1820 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1822 return ${PIPESTATUS[0]}
1828 local HOST=`facet_active_host $facet`
1829 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1834 do_nodes --verbose "$@"
1840 # make sure its not already running
1842 rm -f $TMP/${facet}active
1843 do_facet ${facet} $MKFS $*
1849 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1850 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1857 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1858 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1864 local var=${facet}_MOUNT
1865 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1874 # make sure we are using the primary server, so test-framework will
1875 # be able to clean up properly.
1876 activemds=`facet_active mds1`
1877 if [ $activemds != "mds1" ]; then
1881 local clients=$CLIENTS
1882 [ -z $clients ] && clients=$(hostname)
1884 zconf_umount_clients $clients $MOUNT "$*" || true
1885 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1887 [ "$CLIENTONLY" ] && return
1888 # The add fn does rm ${facet}active file, this would be enough
1889 # if we use do_facet <facet> only after the facet added, but
1890 # currently we use do_facet mds in local.sh
1891 for num in `seq $MDSCOUNT`; do
1893 rm -f ${TMP}/mds${num}active
1896 for num in `seq $OSTCOUNT`; do
1898 rm -f $TMP/ost${num}active
1901 if ! combined_mgs_mds ; then
1908 cleanup_echo_devs () {
1909 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1911 for dev in $devs; do
1912 $LCTL --device $dev cleanup
1913 $LCTL --device $dev detach
1918 nfs_client_mode && return
1927 combined_mgs_mds () {
1928 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1934 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1935 local optvar=${tgt}_MKFS_OPTS
1936 local opt=${!optvar}
1938 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1939 [[ $facet = mgs ]] && echo $opt && return
1942 # --failnode options
1943 local var=${facet}failover_HOST
1944 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1945 local failnode=$(h2$NETTYPE ${!var})
1946 failnode="--failnode=$failnode"
1947 # options does not contain
1948 # or contains wrong --failnode=
1949 if [[ $opt != *${failnode}* ]]; then
1950 opt=$(echo $opt | sed 's/--failnode=.* / /')
1951 opt="$opt $failnode"
1957 # no additional mkfs mds "--mgsnode" option for this configuration
1958 if [[ $facet = mds ]] && combined_mgs_mds; then
1963 # additional mkfs "--mgsnode"
1964 local mgsnode="--mgsnode=$MGSNID"
1965 opt=${opt//$mgsnode }
1966 for nid in ${MGSNID//:/ }; do
1967 local mgsnode="--mgsnode=$nid"
1968 # options does not contain
1970 if [[ $opt != *${mgsnode}" "* ]]; then
1971 opt="$opt --mgsnode=$nid"
1979 if [ "$IAMDIR" == "yes" ]; then
1980 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1983 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1986 # We need ldiskfs here, may as well load them all
1988 [ "$CLIENTONLY" ] && return
1989 echo Formatting mgs, mds, osts
1990 if ! combined_mgs_mds ; then
1991 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1994 for num in `seq $MDSCOUNT`; do
1995 echo "Format mds$num: $(mdsdevname $num)"
1997 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) || exit 10
1999 add mds$num $(mkfs_opts mds) $FSTYPE_OPT --reformat $(mdsdevname $num) > /dev/null || exit 10
2003 # the ost-s could have different OST_MKFS_OPTS
2004 # because of different failnode-s
2005 for num in `seq $OSTCOUNT`; do
2006 echo "Format ost$num: $(ostdevname $num)"
2008 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
2010 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
2016 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
2020 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
2024 # 0: success, the old identity set already.
2025 # 1: success, the old identity does not set.
2030 local j=`expr $num - 1`
2031 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
2033 if [ -z "$MDT" ]; then
2037 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
2040 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
2042 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
2045 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
2047 if [ $old = "NONE" ]; then
2056 zconf_umount `hostname` $1 || error "umount failed"
2057 zconf_mount `hostname` $1 || error "mount failed"
2060 writeconf_facet () {
2064 do_facet $facet "$TUNEFS --writeconf $dev"
2068 for num in `seq $MDSCOUNT`; do
2069 DEVNAME=$(mdsdevname $num)
2070 writeconf_facet mds$num $DEVNAME
2073 for num in `seq $OSTCOUNT`; do
2074 DEVNAME=$(ostdevname $num)
2075 writeconf_facet ost$num $DEVNAME
2080 nfs_client_mode && return
2082 sanity_mount_check ||
2083 error "environments are insane!"
2087 if [ -z "$CLIENTONLY" ]; then
2088 echo Setup mgs, mdt, osts
2089 echo $WRITECONF | grep -q "writeconf" && \
2091 if ! combined_mgs_mds ; then
2092 start mgs $MGSDEV $MGS_MOUNT_OPTS
2095 for num in `seq $MDSCOUNT`; do
2096 DEVNAME=$(mdsdevname $num)
2097 start mds$num $DEVNAME $MDS_MOUNT_OPTS
2099 # We started mds, now we should set failover variables properly.
2100 # Set mds${num}failover_HOST if it is not set (the default failnode).
2101 local varname=mds${num}failover_HOST
2102 if [ -z "${!varname}" ]; then
2103 eval mds${num}failover_HOST=$(facet_host mds$num)
2106 if [ $IDENTITY_UPCALL != "default" ]; then
2107 switch_identity $num $IDENTITY_UPCALL
2110 for num in `seq $OSTCOUNT`; do
2111 DEVNAME=$(ostdevname $num)
2112 start ost$num $DEVNAME $OST_MOUNT_OPTS
2114 # We started ost$num, now we should set ost${num}failover variable properly.
2115 # Set ost${num}failover_HOST if it is not set (the default failnode).
2116 varname=ost${num}failover_HOST
2117 if [ -z "${!varname}" ]; then
2118 eval ost${num}failover_HOST=$(facet_host ost${num})
2126 # wait a while to allow sptlrpc configuration be propogated to targets,
2127 # only needed when mounting new target devices.
2132 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
2134 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
2136 if [ "$MOUNT_2" ]; then
2137 mount_client $MOUNT2
2138 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
2143 # by remounting mdt before ost, initial connect from mdt to ost might
2144 # timeout because ost is not ready yet. wait some time to its fully
2145 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
2146 # by a context negotiation rpc with $TIMEOUT.
2147 # FIXME better by monitoring import status.
2150 sleep $((TIMEOUT + 5))
2156 mounted_lustre_filesystems() {
2157 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
2160 init_facet_vars () {
2161 [ "$CLIENTONLY" ] && return 0
2168 eval export ${facet}_dev=${device}
2169 eval export ${facet}_opt=\"$@\"
2171 local dev=${facet}_dev
2172 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
2173 [ -z "$label" ] && echo no label for ${!dev} && exit 1
2175 eval export ${facet}_svc=${label}
2177 local varname=${facet}failover_HOST
2178 if [ -z "${!varname}" ]; then
2179 eval $varname=$(facet_host $facet)
2182 # ${facet}failover_dev is set in cfg file
2183 varname=${facet}failover_dev
2184 if [ -n "${!varname}" ] ; then
2185 eval export ${facet}failover_dev=${!varname}
2187 eval export ${facet}failover_dev=$device
2190 # get mount point of already mounted device
2191 # is facet_dev is already mounted then use the real
2192 # mount point of this facet; otherwise use $(facet_mntpt $facet)
2193 # i.e. ${facet}_MOUNT if specified by user or default
2194 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
2195 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
2196 if [ -z $mntpt ]; then
2197 mntpt=$(facet_mntpt $facet)
2199 eval export ${facet}_MOUNT=$mntpt
2202 init_facets_vars () {
2205 if ! remote_mds_nodsh; then
2206 for num in `seq $MDSCOUNT`; do
2207 DEVNAME=`mdsdevname $num`
2208 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
2212 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
2214 remote_ost_nodsh && return
2216 for num in `seq $OSTCOUNT`; do
2217 DEVNAME=`ostdevname $num`
2218 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
2222 osc_ensure_active () {
2227 while [ $period -lt $timeout ]; do
2228 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
2229 if [ $count -eq 0 ]; then
2233 echo "There are $count OST are inactive, wait $period seconds, and try again"
2235 period=$((period+3))
2238 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
2241 init_param_vars () {
2242 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
2243 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
2244 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
2245 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
2249 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2251 log "Using TIMEOUT=$TIMEOUT"
2253 osc_ensure_active $SINGLEMDS $TIMEOUT
2254 osc_ensure_active client $TIMEOUT
2256 if [ $QUOTA_AUTO -ne 0 ]; then
2257 if [ "$ENABLE_QUOTA" ]; then
2258 echo "enable quota as required"
2259 setup_quota $MOUNT || return 2
2261 echo "disable quota as required"
2262 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
2269 nfs_client_mode () {
2270 if [ "$NFSCLIENT" ]; then
2271 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
2272 local clients=$CLIENTS
2273 [ -z $clients ] && clients=$(hostname)
2275 # FIXME: remove hostname when 19215 fixed
2276 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
2277 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
2278 if [[ ${#nfsexport[@]} -eq 0 ]]; then
2279 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
2281 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
2287 check_config_client () {
2290 local mounted=$(mount | grep " $mntpt ")
2291 if [ "$CLIENTONLY" ]; then
2293 # CLIENTONLY should not depend on *_HOST settings
2294 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2295 # in theory someone could create a new,
2296 # client-only config file that assumed lustre was already
2297 # configured and didn't set the MGSNID. If MGSNID is not set,
2298 # then we should use the mgs nid currently being used
2299 # as the default value. bug 18021
2300 [[ x$MGSNID = x ]] &&
2303 if [[ x$mgc != xMGC$MGSNID ]]; then
2304 if [ "$mgs_HOST" ]; then
2305 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2306 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2307 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2313 local myMGS_host=$mgs_HOST
2314 if [ "$NETTYPE" = "ptl" ]; then
2315 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2318 echo Checking config lustre mounted on $mntpt
2319 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2320 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2322 # if [ "$mgshost" != "$myMGS_host" ]; then
2323 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2324 # Please use correct config or set mds_HOST correctly!"
2329 check_config_clients () {
2330 local clients=${CLIENTS:-$HOSTNAME}
2333 nfs_client_mode && return
2335 do_rpc_nodes $clients check_config_client $mntpt
2337 sanity_mount_check ||
2338 error "environments are insane!"
2342 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2343 local cltimeout=$(lctl get_param -n timeout)
2344 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2345 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2352 [ -z $mntpt ] && return 1
2353 local mounted=$(mounted_lustre_filesystems)
2355 echo $mounted' ' | grep -w -q $mntpt' '
2359 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
2363 # empty lustre filesystem may have empty directories lost+found and .lustre
2365 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
2366 -print | wc -l) = 1 ] || return 1
2367 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
2368 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
2372 check_and_setup_lustre() {
2373 nfs_client_mode && return
2375 local MOUNTED=$(mounted_lustre_filesystems)
2379 # both MOUNT and MOUNT2 are not mounted
2380 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2381 [ "$REFORMAT" ] && formatall
2382 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2384 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2385 export I_MOUNTED=yes
2389 elif is_mounted $MOUNT2; then
2391 # MOUNT2 is mounted, while MOUNT_2 is not set
2392 if ! [ "$MOUNT_2" ]; then
2393 cleanup_mount $MOUNT2
2394 export I_UMOUNTED2=yes
2397 # MOUNT2 is mounted, MOUNT_2 is set
2399 # FIXME: what to do if check_config failed?
2401 # 1) remote client has mounted other Lustre fs ?
2402 # 2) it has insane env ?
2403 # let's try umount MOUNT2 on all clients and mount it again:
2404 if ! check_config_clients $MOUNT2; then
2405 cleanup_mount $MOUNT2
2406 restore_mount $MOUNT2
2407 export I_MOUNTED2=yes
2412 # MOUNT is mounted MOUNT2 is not mounted
2413 elif [ "$MOUNT_2" ]; then
2414 restore_mount $MOUNT2
2415 export I_MOUNTED2=yes
2419 # FIXME: what to do if check_config failed?
2421 # 1) remote client has mounted other Lustre fs?
2422 # 2) lustre is mounted on remote_clients atall ?
2423 check_config_clients $MOUNT
2427 set_default_debug_nodes $(comma_list $(nodes_list))
2433 if [ "$ONLY" == "setup" ]; then
2439 local clients=${CLIENTS:-$HOSTNAME}
2442 zconf_mount_clients $clients $mntpt
2446 local clients=${CLIENTS:-$HOSTNAME}
2449 zconf_umount_clients $clients $mntpt
2452 cleanup_and_setup_lustre() {
2453 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2454 lctl set_param debug=0 || true
2456 if [ "$ONLY" == "cleanup" ]; then
2460 check_and_setup_lustre
2463 # Get all of the server target devices from a given server node and type.
2472 mdt) obd_type="osd" ;;
2473 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2474 *) echo "invalid server type" && return 1 ;;
2477 devs=$(do_node $node "lctl get_param -n $obd_type*.*.mntdev")
2478 for dev in $devs; do
2480 *loop*) do_node $node "losetup $dev" | \
2481 sed -e "s/.*(//" -e "s/).*//" ;;
2487 # Get all of the server target devices.
2492 MDTDEV=$(get_mnt_devs $(mdts_nodes) mdt)
2496 for node in $(osts_nodes); do
2497 OSTDEVS[i]=$(get_mnt_devs $node ost)
2502 # Run e2fsck on MDT or OST device.
2508 df > /dev/null # update statfs data on disk
2509 local cmd="$E2FSCK -d -v -t -t -f -n $extra_opts $target_dev"
2512 do_node $node $cmd || rc=$?
2513 [ $rc -le $FSCK_MAX_ERR ] || \
2514 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2518 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2525 [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
2526 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2527 error "fail to create file in $SHARED_DIRECTORY")
2529 # make sure everything gets to the backing store
2530 local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
2531 do_nodes $list "sync; sleep 2; sync"
2533 do_nodes $list ls $tmp_file || \
2534 error "$SHARED_DIRECTORY is not a shared directory"
2537 run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
2542 for node in $(osts_nodes); do
2543 for dev in ${OSTDEVS[i]}; do
2544 run_e2fsck $node $dev "--mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
2545 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2546 ostidx=$((ostidx + 1))
2553 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2557 [ $rc -le $FSCK_MAX_ERR ] || \
2558 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2559 echo "lfsck finished with rc=$rc"
2561 rm -rvf $MDSDB* $OSTDB* || true
2565 check_and_cleanup_lustre() {
2566 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
2572 if is_mounted $MOUNT; then
2573 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2574 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2577 if [ "$I_UMOUNTED2" = "yes" ]; then
2578 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2581 if [ "$I_MOUNTED2" = "yes" ]; then
2582 cleanup_mount $MOUNT2
2585 if [ "$I_MOUNTED" = "yes" ]; then
2586 cleanupall -f || error "cleanup failed"
2594 wait_for_function () {
2597 # suppress fn both stderr and stdout
2598 if [ "$1" = "--quiet" ]; then
2600 quiet=" > /dev/null 2>&1"
2612 eval $fn $quiet && return 0
2614 wait=$((wait + sleep))
2615 [ $wait -lt $max ] || return 1
2616 echo waiting $fn, $((max - wait)) secs left ...
2626 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
2627 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
2628 echo "Network not available!"
2632 echo `date +"%H:%M:%S (%s)"` network interface is UP
2641 # the sed converts spaces to commas, but leaves the last space
2642 # alone, so the line doesn't end with a comma.
2643 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2649 echo $list | grep -qw $item
2652 # list, excluded are the comma separated lists
2653 exclude_items_from_list () {
2659 for item in ${excluded//,/ }; do
2660 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2662 echo $(comma_list $list)
2665 # list, expand are the comma separated lists
2667 local list=${1//,/ }
2668 local expand=${2//,/ }
2671 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2672 echo $(comma_list $expanded)
2675 testslist_filter () {
2676 local script=$LUSTRE/tests/${TESTSUITE}.sh
2678 [ -f $script ] || return 0
2680 local start_at=$START_AT
2681 local stop_at=$STOP_AT
2683 local var=${TESTSUITE//-/_}_START_AT
2684 [ x"${!var}" != x ] && start_at=${!var}
2685 var=${TESTSUITE//-/_}_STOP_AT
2686 [ x"${!var}" != x ] && stop_at=${!var}
2688 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2689 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2690 /^'${start_at}'$/ {flag = 0}
2691 {if (flag == 1) print $0}
2692 /^'${stop_at}'$/ { flag = 1 }'
2696 (cd `dirname $1`; echo $PWD/`basename $1`)
2700 local types=${1:-"OST MDS MGS"}
2704 for entry in $types; do
2705 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2706 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2709 MGS ) list="$list $name";;
2710 MDS|OST ) local count=${type}COUNT
2711 for ((i=1; i<=${!count}; i++)) do
2712 list="$list ${name}$i"
2714 * ) error "Invalid facet type"
2718 echo $(comma_list $list)
2721 ##################################
2722 # Adaptive Timeouts funcs
2725 # only check mds, we assume at_max is the same on all nodes
2726 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2727 if [ $at_max -eq 0 ]; then
2737 # suppose that all ost-s has the same at_max set
2738 if [ $facet == "ost" ]; then
2739 do_facet ost1 "lctl get_param -n at_max"
2741 do_facet $facet "lctl get_param -n at_max"
2751 if [ $facet == "ost" ]; then
2752 for i in `seq $OSTCOUNT`; do
2753 do_facet ost$i "lctl set_param at_max=$at_max"
2756 elif [ $facet == "mds" ]; then
2757 for i in `seq $MDSCOUNT`; do
2758 do_facet mds$i "lctl set_param at_max=$at_max"
2761 do_facet $facet "lctl set_param at_max=$at_max"
2766 ##################################
2770 # OBD_FAIL_MDS_ALL_REQUEST_NET
2772 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2773 do_facet client "$1" || RC=$?
2774 do_facet $SINGLEMDS lctl set_param fail_loc=0
2779 # OBD_FAIL_MDS_ALL_REPLY_NET
2781 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2782 do_facet client "$@" || RC=$?
2783 do_facet $SINGLEMDS lctl set_param fail_loc=0
2787 drop_reint_reply() {
2788 # OBD_FAIL_MDS_REINT_NET_REP
2790 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2791 do_facet client "$@" || RC=$?
2792 do_facet $SINGLEMDS lctl set_param fail_loc=0
2797 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2799 do_facet ost1 lctl set_param fail_loc=0x214
2800 do_facet client "$1" || RC=$?
2801 do_facet client "sync"
2802 do_facet ost1 lctl set_param fail_loc=0
2806 drop_ldlm_cancel() {
2807 #define OBD_FAIL_LDLM_CANCEL 0x304
2809 do_facet client lctl set_param fail_loc=0x304
2810 do_facet client "$@" || RC=$?
2811 do_facet client lctl set_param fail_loc=0
2815 drop_bl_callback() {
2816 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2818 do_facet client lctl set_param fail_loc=0x305
2819 do_facet client "$@" || RC=$?
2820 do_facet client lctl set_param fail_loc=0
2825 #define OBD_FAIL_LDLM_REPLY 0x30c
2827 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2828 do_facet client "$@" || RC=$?
2829 do_facet $SINGLEMDS lctl set_param fail_loc=0
2837 echo "clearing fail_loc on $facet"
2838 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2841 set_nodes_failloc () {
2842 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2845 cancel_lru_locks() {
2846 $LCTL mark "cancel_lru_locks $1 start"
2847 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2848 $LCTL set_param -n $d=clear
2850 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2851 $LCTL mark "cancel_lru_locks $1 stop"
2856 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2857 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2858 echo "$DEFAULT_LRU_SIZE"
2863 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2866 lru_resize_disable()
2868 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2873 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2874 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2875 echo there is still data in page cache $FILE ?
2876 lctl get_param -n $FILE
2884 DEBUGSAVE="$(lctl get_param -n debug)"
2888 [ -n "$DEBUGSAVE" ] && \
2889 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2894 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2897 debug_size_restore() {
2898 [ -n "$DEBUG_SIZE_SAVED" ] && \
2899 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2903 start_full_debug_logging() {
2908 local DEBUG_SIZE=150
2910 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2911 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2914 stop_full_debug_logging() {
2919 ##################################
2921 ##################################
2924 local TYPE=${TYPE:-"FAIL"}
2927 # do not dump logs if $1=false
2928 if [ "x$1" = "xfalse" ]; then
2933 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2935 # We need to dump the logs on all nodes
2937 gather_logs $(comma_list $(nodes_list))
2941 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2942 echo "$@" > $LOGDIR/err
2947 local log=$TESTSUITELOG
2949 [ -f "$log" ] && grep -q FAIL: $log && status=1
2962 # use only if we are ignoring failures for this test, bugno required.
2963 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2964 # e.g. error_ignore 5494 "your message"
2966 local TYPE="IGNORE (bz$1)"
2972 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2977 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2978 [ "$ALWAYS_SKIPPED" ] && \
2979 skip_logged ${TESTNAME} "$@" || true
2980 [ "$TESTSUITELOG" ] && \
2981 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2984 build_test_filter() {
2985 EXCEPT="$EXCEPT $(testslist_filter)"
2987 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2991 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2992 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2993 [ "$EXCEPT_SLOW" ] && \
2994 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2995 for E in $EXCEPT; do
2996 eval EXCEPT_${E}=true
2998 for E in $ALWAYS_EXCEPT; do
2999 eval EXCEPT_ALWAYS_${E}=true
3001 for E in $EXCEPT_SLOW; do
3002 eval EXCEPT_SLOW_${E}=true
3004 for G in $GRANT_CHECK_LIST; do
3005 eval GCHECK_ONLY_${G}=true
3010 if [[ $1 = [a-z]* ]]; then
3017 # print a newline if the last test was skipped
3018 export LAST_SKIPPED=
3019 export ALWAYS_SKIPPED=
3021 # Main entry into test-framework. This is called with the name and
3022 # description of a test. The name is used to find the function to run
3023 # the test using "test_$name".
3025 # This supports a variety of methods of specifying specific test to
3026 # run or not run. These need to be documented...
3031 export base=`basetest $1`
3032 if [ ! -z "$ONLY" ]; then
3034 if [ ${!testname}x != x ]; then
3035 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3036 run_one_logged $1 "$2"
3040 if [ ${!testname}x != x ]; then
3041 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
3042 run_one_logged $1 "$2"
3050 if [ ${!testname}x != x ]; then
3052 TESTNAME=test_$1 skip "skipping excluded test $1"
3055 testname=EXCEPT_$base
3056 if [ ${!testname}x != x ]; then
3058 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
3061 testname=EXCEPT_ALWAYS_$1
3062 if [ ${!testname}x != x ]; then
3065 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
3068 testname=EXCEPT_ALWAYS_$base
3069 if [ ${!testname}x != x ]; then
3072 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
3075 testname=EXCEPT_SLOW_$1
3076 if [ ${!testname}x != x ]; then
3078 TESTNAME=test_$1 skip "skipping SLOW test $1"
3081 testname=EXCEPT_SLOW_$base
3082 if [ ${!testname}x != x ]; then
3084 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
3090 run_one_logged $1 "$2"
3101 module_loaded lnet || load_modules
3113 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
3118 strace -o $TMP/$1.strace -ttt $*
3120 log "FINISHED: $*: rc $RC"
3125 equals_msg $1 test complete, duration $2 sec
3126 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
3127 echo duration $2 >>$TESTSUITELOG
3131 # Set TEST_STATUS here; will be used for logging the result
3132 if [ -f $LOGDIR/err ]; then
3137 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
3141 local FFREE=$(do_node $SINGLEMDS \
3142 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
3143 local FTOTAL=$(do_node $SINGLEMDS \
3144 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
3146 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
3150 echo -n "Resetting fail_loc on all nodes..."
3151 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
3157 # Log a message (on all nodes) padded with "=" before and after.
3158 # Also appends a timestamp and prepends the testsuite name.
3161 EQUALS="===================================================================================================="
3163 msg="== ${TESTSUITE} $*"
3165 [[ $last != "=" && $last != " " ]] && msg="$msg "
3166 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
3167 # always include at least == after the message
3168 log "$msg== $(date +"%H:%M:%S (%s)")"
3172 # Run a single test function and cleanup after it.
3174 # This function should be run in a subshell so the test func can
3175 # exit() without stopping the whole script.
3181 export tdir=d0.${TESTSUITE}/d${base}
3182 export TESTNAME=test_$testnum
3183 local SAVE_UMASK=`umask`
3186 banner "test $testnum: $message"
3187 test_${testnum} || error "test_$testnum failed with $?"
3190 check_grant ${testnum} || error "check_grant $testnum failed with $?"
3191 check_catastrophe || error "LBUG/LASSERT detected"
3192 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
3200 # Wrapper around run_one to ensure:
3201 # - test runs in subshell
3202 # - output of test is saved to separate log file for error reporting
3203 # - test result is saved to data file
3206 local BEFORE=`date +%s`
3208 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
3209 local test_log=$LOGDIR/$name
3211 local SAVE_UMASK=`umask`
3215 log_sub_test_begin test_${1}
3216 (run_one $1 "$2") 2>&1 | tee $test_log
3217 local RC=${PIPESTATUS[0]}
3219 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
3220 echo "test_$1 returned $RC" | tee $LOGDIR/err
3222 duration=$((`date +%s` - $BEFORE))
3223 pass "$1" "(${duration}s)"
3224 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
3225 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
3227 if [ -f $LOGDIR/err ]; then
3228 $FAIL_ON_ERROR && exit $RC
3237 # Print information of skipped tests to result.yml
3240 log_sub_test_begin $1
3241 log_sub_test_end "SKIP" "0" "0" "\"$2\""
3245 (cd `dirname $1`; echo $PWD/`basename $1`)
3250 export base=`basetest $1`
3251 [ "$CHECK_GRANT" == "no" ] && return 0
3253 testname=GCHECK_ONLY_${base}
3254 [ ${!testname}x == x ] && return 0
3256 echo -n "checking grant......"
3258 local clients=$CLIENTS
3259 [ -z $clients ] && clients=$(hostname)
3261 # sync all the data and make sure no pending data on server
3262 do_nodes $clients sync
3265 client_grant=`do_nodes $clients \
3266 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
3267 awk '{total += $1} END{print total}'`
3270 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
3271 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
3272 awk '{total += $1} END{print total}'`
3274 # check whether client grant == server grant
3275 if [ $client_grant -ne $server_grant ]; then
3276 echo "failed: client:${client_grant} server: ${server_grant}."
3277 do_nodes $(comma_list $(osts_nodes)) \
3278 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
3279 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
3282 echo "pass: client:${client_grant} server: ${server_grant}"
3287 ########################
3293 ost=`echo $1 | awk -F_ '{print $3}'`
3294 if [ -z $ost ]; then
3295 ost=`echo $1 | sed 's/-osc.*//'`
3300 ostuuid_from_index()
3302 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
3307 [ "$node" != "$(hostname)" ]
3313 for node in $(mdts_nodes); do
3314 remote_node $node && return 0
3321 [ "$CLIENTONLY" ] && return 0 || true
3322 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
3327 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
3328 MSKIPPED=1 && return 1
3335 for node in $(osts_nodes) ; do
3336 remote_node $node && return 0
3343 [ "$CLIENTONLY" ] && return 0 || true
3344 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3349 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
3350 OSKIPPED=1 && return 1
3357 MGS=$(facet_host mgs)
3358 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
3363 remote_mds_nodsh || remote_ost_nodsh || \
3364 $(single_local_node $(comma_list $(nodes_list)))
3370 for num in `seq $MDSCOUNT`; do
3371 MDSNODES="$MDSNODES $(facet_host mds$num)"
3373 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
3379 remote_ost && remote_mds
3387 for facet in ${facets//,/ }; do
3388 if [ "$FAILURE_MODE" = HARD ]; then
3389 nodes="$nodes $(facet_active_host $facet)"
3391 nodes="$nodes $(facet_host $facet)"
3394 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
3400 local facets=$(get_facets OST)
3401 local nodes=$(facets_nodes $facets)
3407 # FIXME. We need a list of clients
3408 local myNODES=$HOSTNAME
3411 # CLIENTS (if specified) contains the local client
3412 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
3414 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
3415 myNODES="$myNODES $(facets_nodes $(get_facets))"
3418 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
3423 remote_nodes_list () {
3424 local rnodes=$(nodes_list)
3425 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3429 init_clients_lists () {
3430 # Sanity check: exclude the local client from RCLIENTS
3431 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
3433 # Sanity check: exclude the dup entries
3434 rclients=$(for i in $rclients; do echo $i; done | sort -u)
3436 local clients="$SINGLECLIENT $HOSTNAME $rclients"
3438 # Sanity check: exclude the dup entries from CLIENTS
3439 # for those configs which has SINGLCLIENT set to local client
3440 clients=$(for i in $clients; do echo $i; done | sort -u)
3442 CLIENTS=`comma_list $clients`
3443 local -a remoteclients=($rclients)
3444 for ((i=0; $i<${#remoteclients[@]}; i++)); do
3445 varname=CLIENT$((i + 2))
3446 eval $varname=${remoteclients[i]}
3449 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
3452 get_random_entry () {
3455 rnodes=${rnodes//,/ }
3457 local -a nodes=($rnodes)
3458 local num=${#nodes[@]}
3459 local i=$((RANDOM * num * 2 / 65536))
3465 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
3470 lctl get_param version | grep -q patchless
3474 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
3479 echo $nodes | wc -w || true
3483 local nodes=$(osts_nodes)
3484 local osscount=$(get_node_count "$nodes")
3485 [ ! "$OSTCOUNT" = "$osscount" ]
3489 local nodes=$(mdts_nodes)
3490 local mdtcount=$(get_node_count "$nodes")
3491 [ ! "$MDSCOUNT" = "$mdtcount" ]
3494 generate_machine_file() {
3495 local nodes=${1//,/ }
3496 local machinefile=$2
3498 for node in $nodes; do
3499 echo $node >>$machinefile || \
3500 { echo "can not generate machinefile $machinefile" && return 1; }
3505 local file=$1/stripe
3507 $LFS getstripe -v $file || error
3511 setstripe_nfsserver () {
3514 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3515 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3517 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3519 do_nodev $nfsserver lfs setstripe "$@"
3522 check_runas_id_ret() {
3524 local myRUNAS_UID=$1
3525 local myRUNAS_GID=$2
3528 if [ -z "$myRUNAS" ]; then
3529 error_exit "myRUNAS command must be specified for check_runas_id"
3532 $myRUNAS krb5_login.sh || \
3533 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3535 mkdir $DIR/d0_runas_test
3537 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3538 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3539 rm -rf $DIR/d0_runas_test
3544 local myRUNAS_UID=$1
3545 local myRUNAS_GID=$2
3548 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3549 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3550 Please set RUNAS_ID to some UID which exists on MDS and client or
3551 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3554 # obtain the UID/GID for MPI_USER
3558 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3559 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3561 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3562 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3565 # obtain and cache Kerberos ticket-granting ticket
3566 refresh_krb5_tgt() {
3567 local myRUNAS_UID=$1
3568 local myRUNAS_GID=$2
3571 if [ -z "$myRUNAS" ]; then
3572 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3575 CLIENTS=${CLIENTS:-$HOSTNAME}
3576 do_nodes $CLIENTS "set -x
3577 if ! $myRUNAS krb5_login.sh; then
3578 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3583 # Run multiop in the background, but wait for it to print
3584 # "PAUSING" to its stdout before returning from this function.
3585 multiop_bg_pause() {
3586 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3590 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3593 echo "$MULTIOP_PROG $FILE v$ARGS"
3594 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3596 echo "TMPPIPE=${TMPPIPE}"
3597 read -t 60 multiop_output < $TMPPIPE
3598 if [ $? -ne 0 ]; then
3603 if [ "$multiop_output" != "PAUSING" ]; then
3604 echo "Incorrect multiop output: $multiop_output"
3619 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3625 inodes_available () {
3626 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3630 mdsrate_inodes_available () {
3631 local min_inodes=$(inodes_available)
3632 echo $((min_inodes * 99 / 100))
3635 # reset llite stat counters
3636 clear_llite_stats(){
3637 lctl set_param -n llite.*.stats 0
3640 # sum llite stat items
3641 calc_llite_stats() {
3642 local res=$(lctl get_param -n llite.*.stats |
3643 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3647 # reset osc stat counters
3649 lctl set_param -n osc.*.osc_stats 0
3652 # sum osc stat items
3654 local res=$(lctl get_param -n osc.*.osc_stats |
3655 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3660 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3663 calc_osc_kbytes () {
3664 df $MOUNT > /dev/null
3665 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3668 # save_lustre_params(node, parameter_mask)
3669 # generate a stream of formatted strings (<node> <param name>=<param value>)
3670 save_lustre_params() {
3672 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3675 # restore lustre parameters from input stream, produces by save_lustre_params
3676 restore_lustre_params() {
3680 while IFS=" =" read node name val; do
3681 do_node ${node//:/} "lctl set_param -n $name $val"
3685 check_catastrophe() {
3686 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3687 local C=$CATASTROPHE
3688 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3690 if [ $rnodes ]; then
3691 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3692 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3708 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3710 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3711 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3712 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3716 # CMD: determine mds index where directory inode presents
3719 local file=$dir/f0.get_mds_dir_tmpfile
3724 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3725 local -a oldused=($iused)
3727 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3729 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3730 local -a newused=($iused)
3733 for ((i=0; i<${#newused[@]}; i++)); do
3734 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3740 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3743 mdsrate_cleanup () {
3745 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3750 delayed_recovery_enabled () {
3751 local var=${SINGLEMDS}_svc
3752 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3755 ########################
3757 convert_facet2label() {
3760 if [ x$facet = xost ]; then
3764 local varsvc=${facet}_svc
3766 if [ -n ${!varsvc} ]; then
3769 error "No lablel for $facet!"
3773 get_clientosc_proc_path() {
3777 echo "${1}-osc-[!M]*"
3780 get_lustre_version () {
3781 local facet=${1:-"$SINGLEMDS"}
3782 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3785 get_mds_version_major () {
3786 local facet=${1:-"$SINGLEMDS"}
3787 local version=$(get_lustre_version $facet)
3788 echo $version | awk -F. '{print $1}'
3791 get_mds_version_minor () {
3792 local facet=${1:-"$SINGLEMDS"}
3793 local version=$(get_lustre_version $facet)
3794 echo $version | awk -F. '{print $2}'
3797 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
3798 # used by MDT would not be changed.
3799 # mdt lov: fsname-mdtlov
3800 # mdt osc: fsname-OSTXXXX-osc
3801 mds_on_old_device() {
3802 local mds=${1:-"$SINGLEMDS"}
3803 local major=$(get_mds_version_major $mds)
3804 local minor=$(get_mds_version_minor $mds)
3806 if [ $major -ge 2 ] || [ $major -eq 1 -a $minor -gt 8 ]; then
3807 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
3808 > /dev/null 2>&1" && return 0
3813 get_mdtosc_proc_path() {
3815 local ost_label=${2:-"*OST*"}
3817 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
3818 local mdt_label=$(convert_facet2label $mds_facet)
3819 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
3821 local major=$(get_mds_version_major $mds_facet)
3822 local minor=$(get_mds_version_minor $mds_facet)
3823 if [ $major -le 1 -a $minor -le 8 ] || mds_on_old_device $mds_facet; then
3824 echo "${ost_label}-osc"
3826 echo "${ost_label}-osc-${mdt_index}"
3830 get_osc_import_name() {
3833 local label=$(convert_facet2label $ost)
3835 if [ "${facet:0:3}" = "mds" ]; then
3836 get_mdtosc_proc_path $facet $label
3840 get_clientosc_proc_path $label
3844 _wait_import_state () {
3847 local maxtime=${3:-max_recovery_time}
3851 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3852 while [ "${CONN_STATE}" != "${expected}" ]; do
3853 [ $i -ge $maxtime ] && \
3854 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3857 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3861 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3865 wait_import_state() {
3868 local maxtime=${3:-max_recovery_time}
3871 for param in ${params//,/ }; do
3872 _wait_import_state $state $param $maxtime || return
3875 wait_osc_import_state() {
3879 local ost=$(get_osc_import_name $facet $ost_facet)
3884 CONN_PROC="osc.${ost}.ost_server_uuid"
3885 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3886 while [ "${CONN_STATE}" != "${expected}" ]; do
3887 if [ "${expected}" == "DISCONN" ]; then
3888 # for disconn we can check after proc entry is removed
3889 [ "x${CONN_STATE}" == "x" ] && return 0
3890 # with AT we can have connect request timeout ~ reconnect timeout
3891 # and test can't see real disconnect
3892 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3894 # disconnect rpc should be wait not more obd_timeout
3895 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3896 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3898 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3902 log "${ost_facet} now in ${CONN_STATE} state"
3905 get_clientmdc_proc_path() {
3913 # Add paths to lustre tests for 32 and 64 bit systems.
3914 local RPATH="PATH=$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3915 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3918 wait_clients_import_state () {
3925 if [ "$FAILURE_MODE" = HARD ]; then
3926 facets=$(facets_on_host $(facet_active_host $facet))
3929 for facet in ${facets//,/ }; do
3930 local label=$(convert_facet2label $facet)
3933 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3934 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3935 *) error "unknown facet!" ;;
3937 local params=$(expand_list $params $proc_path)
3940 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3941 error "import is not in ${expected} state"
3950 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3951 $LCTL get_param obdfilter.*.kbytesavail))
3952 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3953 $LCTL get_param -n obdfilter.*.tot_granted))
3954 for ((i=0; i<${#AVAILA[@]}; i++)); do
3955 local -a AVAIL1=(${AVAILA[$i]//=/ })
3956 GRANT=$((${GRANTA[$i]}/1024))
3957 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3958 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3964 do_facet mgs lctl pool_list $1
3968 local fsname=${1%%.*}
3969 local poolname=${1##$fsname.}
3971 do_facet mgs lctl pool_new $1
3973 # get param should return err unless pool is created
3974 [[ $RC -ne 0 ]] && return $RC
3976 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3977 2>/dev/null || echo foo" "" || RC=1
3978 if [[ $RC -eq 0 ]]; then
3981 error "pool_new failed $1"
3986 add_pool_to_list () {
3987 local fsname=${1%%.*}
3988 local poolname=${1##$fsname.}
3990 local listvar=${fsname}_CREATED_POOLS
3991 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3994 remove_pool_from_list () {
3995 local fsname=${1%%.*}
3996 local poolname=${1##$fsname.}
3998 local listvar=${fsname}_CREATED_POOLS
3999 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
4002 destroy_pool_int() {
4004 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
4005 awk '$1 !~ /^Pool:/ {print $1}')
4006 for ost in $OSTS; do
4007 do_facet mgs lctl pool_remove $1 $ost
4009 do_facet mgs lctl pool_destroy $1
4012 # <fsname>.<poolname> or <poolname>
4014 local fsname=${1%%.*}
4015 local poolname=${1##$fsname.}
4017 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
4021 pool_list $fsname.$poolname || return $?
4023 destroy_pool_int $fsname.$poolname
4025 [[ $RC -ne 0 ]] && return $RC
4027 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
4028 2>/dev/null || echo foo" "foo" || RC=1
4030 if [[ $RC -eq 0 ]]; then
4031 remove_pool_from_list $fsname.$poolname
4033 error "destroy pool failed $1"
4039 local fsname=${1:-$FSNAME}
4041 local listvar=${fsname}_CREATED_POOLS
4045 [ x${!listvar} = x ] && return 0
4047 echo destroy the created pools: ${!listvar}
4048 for poolname in ${!listvar//,/ }; do
4049 destroy_pool $fsname.$poolname
4054 local fsname=${1:-$FSNAME}
4056 destroy_pools $fsname
4062 local ts=$(date +%s)
4064 [ -f $LOGDIR/shared ] && docp=false
4066 # dump lustre logs, dmesg
4068 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
4070 echo "Dumping lctl log to ${prefix}.*.${suffix}"
4072 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
4073 echo "Dumping logs only on local client."
4074 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
4075 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
4080 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
4081 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
4082 if [ ! -f $LOGDIR/shared ]; then
4083 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
4086 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
4087 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
4093 local list=${1:-$(comma_list $(nodes_list))}
4095 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
4107 for i in $(seq 0 $num_mntpts); do
4108 cmd="ls -laf ${mntpt_root}$i/$dir"
4114 for pid in $pids; do
4121 # target_start_and_reset_recovery_timer()
4122 # service_time = at_est2timeout(service_time);
4123 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
4124 # INITIAL_CONNECT_TIMEOUT);
4125 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
4126 #define CONNECTION_SWITCH_INC 1
4127 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
4128 #define CONNECTION_SWITCH_MIN 5U
4130 max_recovery_time () {
4131 local init_connect_timeout=$(( TIMEOUT / 20 ))
4132 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
4134 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
4139 get_clients_mount_count () {
4140 local clients=${CLIENTS:-`hostname`}
4142 # we need to take into account the clients mounts and
4143 # exclude mds/ost mounts if any;
4144 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
4148 PROC_CLI="srpc_info"
4156 if [ $M -lt $N ]; then
4160 while [ $N -lt $M ]; do
4170 calc_connection_cnt() {
4173 # MDT->MDT = 2 * C(M, 2)
4177 comb_m2=$(combination $MDSCOUNT 2)
4179 local num_clients=$(get_clients_mount_count)
4181 local cnt_mdt2mdt=$((comb_m2 * 2))
4182 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
4183 local cnt_cli2ost=$((num_clients * OSTCOUNT))
4184 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
4185 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
4186 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
4187 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
4201 local cmd="$tgt.srpc.flavor"
4203 if [ $net == "any" ]; then
4208 if [ $dir != "any" ]; then
4213 log "Setting sptlrpc rule: $cmd"
4214 do_facet mgs "$LCTL conf_param $cmd"
4223 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
4224 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
4226 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
4228 if [ "x$bulkspec" != "x" ]; then
4229 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
4231 if [ "x$algs" != "x" ]; then
4232 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
4234 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
4235 if [ $bulk == "bulkn" ]; then
4236 bulk_count=`echo "$output" | grep "bulk flavor" \
4237 | grep "null/null" | wc -l`
4238 elif [ $bulk == "bulki" ]; then
4239 bulk_count=`echo "$output" | grep "bulk flavor" \
4240 | grep "/null" | grep -v "null/" | wc -l`
4242 bulk_count=`echo "$output" | grep "bulk flavor" \
4243 | grep -v "/null" | grep -v "null/" | wc -l`
4247 [ $bulk_count -lt $count ] && count=$bulk_count
4258 local clients=${CLIENTS:-`hostname`}
4260 for c in ${clients//,/ }; do
4261 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
4262 tmpcnt=`count_flvr "$output" $flavor`
4263 cnt=$((cnt + tmpcnt))
4273 local clients=${CLIENTS:-`hostname`}
4275 for c in ${clients//,/ }; do
4276 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
4277 tmpcnt=`count_flvr "$output" $flavor`
4278 cnt=$((cnt + tmpcnt))
4288 if [ $MDSCOUNT -le 1 ]; then
4293 for num in `seq $MDSCOUNT`; do
4294 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
4295 tmpcnt=`count_flvr "$output" $flavor`
4296 cnt=$((cnt + tmpcnt))
4307 for num in `seq $MDSCOUNT`; do
4308 mdtosc=$(get_mdtosc_proc_path mds$num)
4309 mdtosc=${mdtosc/-MDT*/-MDT\*}
4310 output=$(do_facet mds$num lctl get_param -n \
4311 osc.$mdtosc.$PROC_CLI 2>/dev/null)
4312 tmpcnt=`count_flvr "$output" $flavor`
4313 cnt=$((cnt + tmpcnt))
4322 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
4323 count_flvr "$output" $flavor
4328 local dir=$1 # from to
4329 local flavor=$2 # flavor expected
4332 if [ $dir == "cli2mdt" ]; then
4333 res=`flvr_cnt_cli2mdt $flavor`
4334 elif [ $dir == "cli2ost" ]; then
4335 res=`flvr_cnt_cli2ost $flavor`
4336 elif [ $dir == "mdt2mdt" ]; then
4337 res=`flvr_cnt_mdt2mdt $flavor`
4338 elif [ $dir == "mdt2ost" ]; then
4339 res=`flvr_cnt_mdt2ost $flavor`
4340 elif [ $dir == "all2ost" ]; then
4341 res1=`flvr_cnt_mdt2ost $flavor`
4342 res2=`flvr_cnt_cli2ost $flavor`
4343 res=$((res1 + res2))
4344 elif [ $dir == "all2mdt" ]; then
4345 res1=`flvr_cnt_mdt2mdt $flavor`
4346 res2=`flvr_cnt_cli2mdt $flavor`
4347 res=$((res1 + res2))
4348 elif [ $dir == "all2all" ]; then
4349 res1=`flvr_cnt_mdt2ost $flavor`
4350 res2=`flvr_cnt_cli2ost $flavor`
4351 res3=`flvr_cnt_mdt2mdt $flavor`
4352 res4=`flvr_cnt_cli2mdt $flavor`
4353 res=$((res1 + res2 + res3 + res4))
4361 local dir=$1 # from to
4362 local flavor=$2 # flavor expected
4363 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
4367 for ((i=0;i<20;i++)); do
4368 echo -n "checking $dir..."
4369 res=$(do_check_flavor $dir $flavor)
4370 echo "found $res/$expect $flavor connections"
4371 [ $res -eq $expect ] && return 0
4375 echo "Error checking $flavor of $dir: expect $expect, actual $res"
4379 restore_to_default_flavor()
4381 local proc="mgs.MGS.live.$FSNAME"
4383 echo "restoring to default flavor..."
4385 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4387 # remove all existing rules if any
4388 if [ $nrule -ne 0 ]; then
4389 echo "$nrule existing rules"
4390 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
4391 echo "remove rule: $rule"
4392 spec=`echo $rule | awk -F = '{print $1}'`
4393 do_facet mgs "$LCTL conf_param -d $spec"
4397 # verify no rules left
4398 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
4399 [ $nrule -ne 0 ] && error "still $nrule rules left"
4401 # wait for default flavor to be applied
4402 # currently default flavor for all connections are 'null'
4403 wait_flavor all2all null
4404 echo "now at default flavor settings"
4409 local flavor=${1:-null}
4411 echo "setting all flavor to $flavor"
4413 # FIXME need parameter to this fn
4414 # and remove global vars
4415 local cnt_all2all=$(calc_connection_cnt all2all)
4417 local res=$(do_check_flavor all2all $flavor)
4418 if [ $res -eq $cnt_all2all ]; then
4419 echo "already have total $res $flavor connections"
4423 echo "found $res $flavor out of total $cnt_all2all connections"
4424 restore_to_default_flavor
4426 [[ $flavor = null ]] && return 0
4428 set_rule $FSNAME any any $flavor
4429 wait_flavor all2all $flavor
4435 # Checking for shared logdir
4436 if [ ! -d $dir ]; then
4437 # Not found. Create local logdir
4440 touch $dir/node.$(hostname -s).yml
4445 check_write_access() {
4447 for node in $(nodes_list); do
4448 if [ ! -f "$dir/node.$(short_hostname ${node}).yml" ]; then
4449 # Logdir not accessible/writable from this node.
4457 if [[ -n $YAML_LOG ]]; then
4460 local SAVE_UMASK=`umask`
4463 export YAML_LOG=${LOGDIR}/results.yml
4467 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
4468 if check_write_access $LOGDIR; then
4469 touch $LOGDIR/shared
4470 echo "Logging to shared log directory: $LOGDIR"
4472 echo "Logging to local directory: $LOGDIR"
4475 yml_nodes_file $LOGDIR >> $YAML_LOG
4476 yml_results_file >> $YAML_LOG
4482 yml_log_test $1 >> $YAML_LOG
4486 yml_log_test_status $@ >> $YAML_LOG
4489 log_sub_test_begin() {
4490 yml_log_sub_test_begin "$@" >> $YAML_LOG
4493 log_sub_test_end() {
4494 yml_log_sub_test_end "$@" >> $YAML_LOG
4500 local devname=$(basename $1)
4501 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
4502 # loop devices aren't in /proc/partitions
4503 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
4505 size=$(($size / 1024 / 1024)) # Gb
4507 local partial_arg=""
4508 # Run in partial (fast) mode if the size
4509 # of a partition > 10 GB
4510 [ $size -gt 10 ] && partial_arg="-p"
4512 llverdev --force $partial_arg $dev
4515 remove_mdt_files() {
4520 local mntpt=${MOUNT%/*}/$facet
4522 echo "removing files from $mdtdev on $facet: $files"
4523 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4526 rm $mntpt/ROOT/$f || { rc=$?; break; }
4528 umount -f $mntpt || return $?
4532 duplicate_mdt_files() {
4537 local mntpt=${MOUNT%/*}/$facet
4539 echo "duplicating files on $mdtdev on $facet: $files"
4540 mkdir -p $mntpt || return $?
4541 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
4551 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
4552 pushd $mntpt/ROOT > /dev/null || return $?
4555 touch $f.bad || return $?
4556 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
4558 [ $rc -eq 0 ] || return $rc
4559 setfattr --restore $tmp || return $?
4565 local devs=${1//,/ }
4568 local rslt=$TMP/sgpdd_survey
4570 # sgpdd-survey cleanups ${rslt}.* files
4572 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
4578 # returns the canonical name for an ldiskfs device
4583 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
4584 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
4585 echo dm-\\\${foo##*:};
4587 echo \\\$(basename \\\$dv);
4591 is_sanity_benchmark() {
4592 local benchmarks="dbench bonnie iozone fsx"
4594 for b in $benchmarks; do
4595 if [ "$b" == "$suite" ]; then
4603 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1