2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
20 #export PDSH="pdsh -S -Rssh -w"
22 # function used by scripts run on remote nodes
23 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
24 . $LUSTRE/tests/functions.sh
25 . $LUSTRE/tests/yaml.sh
27 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
29 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
31 if [ -f "$EXCEPT_LIST_FILE" ]; then
32 echo "Reading test skip list from $EXCEPT_LIST_FILE"
37 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
38 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
42 [[ $DIR/ = $MOUNT/* ]] || \
43 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
44 [[ $DIR1/ = $MOUNT1/* ]] || \
45 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
46 [[ $DIR2/ = $MOUNT2/* ]] || \
47 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
49 [ -n "$failed" ] && exit 99 || true
53 echo "usage: $0 [-r] [-f cfgfile]"
61 [ "$TESTSUITE" == "lfsck" ] && return 0
62 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
63 local form="%-13s %-17s %s\n"
64 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
65 echo "------------------------------------------------------------------------------------"
66 for O in $DEFAULT_SUITES; do
69 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
70 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
72 local log=${TMP}/${o}.log
73 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
74 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
75 [ "${!O}" = "done" ] && \
76 printf "$form" "Done" "$O" "E=$skipped" && \
77 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
81 for O in $DEFAULT_SUITES; do
82 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
83 if [ "${!O}" = "no" ]; then
85 # only for those tests suits which are run directly from acc-sm script:
86 # bonnie, iozone, etc.
87 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
88 printf "$form" "UNFINISHED" "$O" ""
90 printf "$form" "Skipped" "$O" ""
95 for O in $DEFAULT_SUITES; do
96 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
97 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
98 printf "$form" "UNFINISHED" "$O" ""
103 export LUSTRE=`absolute_path $LUSTRE`
104 export TESTSUITE=`basename $0 .sh`
105 export TEST_FAILED=false
106 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
108 export MKE2FS=${MKE2FS:-mke2fs}
109 export DEBUGFS=${DEBUGFS:-debugfs}
110 export TUNE2FS=${TUNE2FS:-tune2fs}
111 export E2LABEL=${E2LABEL:-e2label}
112 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
113 export E2FSCK=${E2FSCK:-e2fsck}
115 #[ -d /r ] && export ROOT=${ROOT:-/r}
116 export TMP=${TMP:-$ROOT/tmp}
117 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
118 if [[ -z $LOGDIRSET ]]; then
119 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
120 export LOGDIRSET=true
122 export HOSTNAME=${HOSTNAME:-`hostname`}
123 if ! echo $PATH | grep -q $LUSTRE/utils; then
124 export PATH=$PATH:$LUSTRE/utils
126 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
127 export PATH=$PATH:$LUSTRE/utils/gss
129 if ! echo $PATH | grep -q $LUSTRE/tests; then
130 export PATH=$PATH:$LUSTRE/tests
132 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
133 [ ! -f "$LST" ] && export LST=$(which lst)
134 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
135 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
136 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
137 export PATH=$LUSTRE/tests/racer:$PATH:
139 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
140 export PATH=$PATH:$LUSTRE/tests/mpi
142 export RSYNC_RSH=${RSYNC_RSH:-rsh}
143 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
144 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
145 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
146 [ ! -f "$LFS" ] && export LFS=$(which lfs)
147 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
148 if [ ! -f "$L_GETIDENTITY" ]; then
149 if `which l_getidentity > /dev/null 2>&1`; then
150 export L_GETIDENTITY=$(which l_getidentity)
152 export L_GETIDENTITY=NONE
155 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
156 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
157 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
158 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
159 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
160 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
161 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
162 export FSTYPE=${FSTYPE:-"ldiskfs"}
163 export NAME=${NAME:-local}
164 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
165 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
166 export LGSSD=$(which lgssd)
167 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
168 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
169 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
171 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
174 if [ "$ACCEPTOR_PORT" ]; then
175 export PORT_OPT="--port $ACCEPTOR_PORT"
180 echo "Using GSS/krb5 ptlrpc security flavor"
181 which lgss_keyring > /dev/null 2>&1 || \
182 error_exit "built with gss disabled! SEC=$SEC"
193 IDENTITY_UPCALL=false
196 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
198 # Paths on remote nodes, if different
199 export RLUSTRE=${RLUSTRE:-$LUSTRE}
200 export RPWD=${RPWD:-$PWD}
201 export I_MOUNTED=${I_MOUNTED:-"no"}
202 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
203 ! -f `dirname $0`/../mds/mds.ko ]; then
204 export CLIENTMODSONLY=yes
209 while getopts "rvwf:" opt $*; do
212 r) REFORMAT=--reformat;;
214 w) WRITECONF=writeconf;;
219 shift $((OPTIND - 1))
222 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
227 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
228 *) EXT=".ko"; USE_QUOTA=yes;;
233 /sbin/lsmod | grep -q $1
236 # Load a module on the system where this is running.
238 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
240 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
241 # will be used as the arguments. Otherwise arguments will be obtained from
242 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
249 BASE=`basename $module $EXT`
251 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
253 if [ $# -eq 0 ]; then
254 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
255 # Bash until 4.x, so we resort to eval.
256 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
257 eval set -- \$$optvar
258 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
259 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
260 set -- $(grep "^options\\s*\<${module}\>" $MODPROBECONF)
261 # Get rid of "options $module"
262 (($# > 0)) && shift 2
264 # Ensure we have accept=all for lnet
265 if [ $module = lnet ]; then
266 # OK, this is a bit wordy...
267 local arg accept_all_present=false
269 [ "$arg" = accept=all ] && accept_all_present=true
271 $accept_all_present || set -- "$@" accept=all
276 [ $# -gt 0 ] && echo "${module} options: '$*'"
278 module_loaded ${BASE} && return
280 # Note that insmod will ignore anything in modprobe.conf, which is why we're
281 # passing options on the command-line.
282 if [ "$BASE" == "lnet_selftest" ] && \
283 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
284 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
285 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
286 insmod ${LUSTRE}/${module}${EXT} "$@"
288 # must be testing a "make install" or "rpm" installation
289 # note failed to load ptlrpc_gss is considered not fatal
290 if [ "$BASE" == "ptlrpc_gss" ]; then
291 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
298 load_modules_local() {
299 if [ -n "$MODPROBE" ]; then
301 echo "Using modprobe to load modules"
304 if [ "$HAVE_MODULES" = true ]; then
306 echo "Modules already loaded"
311 echo Loading modules from $LUSTRE
312 load_module ../libcfs/libcfs/libcfs
313 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
314 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
315 load_module ../lnet/lnet/lnet
316 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
317 load_module ../lnet/klnds/$LNETLND
318 load_module lvfs/lvfs
319 load_module obdclass/obdclass
320 load_module ptlrpc/ptlrpc
321 load_module ptlrpc/gss/ptlrpc_gss
322 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
330 if ! client_only; then
331 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
332 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
333 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
338 load_module lvfs/fsfilt_$FSTYPE
342 load_module obdfilter/obdfilter
345 load_module llite/lustre
346 load_module llite/llite_lloop
347 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
349 rm -f $OGDB/ogdb-$HOSTNAME
350 $LCTL modules > $OGDB/ogdb-$HOSTNAME
352 # 'mount' doesn't look in $PATH, just sbin
353 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
359 # load modules on remote nodes optionally
360 # lustre-tests have to be installed on these nodes
361 if $LOAD_MODULES_REMOTE ; then
362 local list=$(comma_list $(remote_nodes_list))
363 echo loading modules on $list
364 do_rpc_nodes $list load_modules
369 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
370 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
371 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
372 echo "$LEAK_LUSTRE" 1>&2
373 echo "$LEAK_PORTALS" 1>&2
374 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
375 echo "Memory leaks detected"
376 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
382 wait_exit_ST client # bug 12845
384 $LUSTRE_RMMOD $FSTYPE || return 2
386 if $LOAD_MODULES_REMOTE ; then
387 local list=$(comma_list $(remote_nodes_list))
388 if [ ! -z $list ]; then
389 echo unloading modules on $list
390 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
391 do_rpc_nodes $list check_mem_leak
397 check_mem_leak || return 254
399 echo "modules unloaded."
403 check_gss_daemon_nodes() {
407 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
408 if [ \\\"\\\$num\\\" -ne 1 ]; then
409 echo \\\$num instance of $dname;
414 check_gss_daemon_facet() {
418 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
419 if [ $num -ne 1 ]; then
420 echo "$num instance of $dname on $facet"
429 echo Stopping $@ on $list
430 do_nodes $list "killall -2 $@ 2>/dev/null || true"
433 # start gss daemons on all nodes, or
434 # "daemon" on "list" if set
435 start_gss_daemons() {
439 if [ "$list" ] && [ "$daemon" ] ; then
440 echo "Starting gss daemon on nodes: $list"
441 do_nodes $list "$daemon" || return 8
445 local list=$(comma_list $(mdts_nodes))
447 echo "Starting gss daemon on mds: $list"
448 do_nodes $list "$LSVCGSSD -v" || return 1
450 do_nodes $list "$LGSSD -v" || return 2
453 list=$(comma_list $(osts_nodes))
454 echo "Starting gss daemon on ost: $list"
455 do_nodes $list "$LSVCGSSD -v" || return 3
456 # starting on clients
458 local clients=${CLIENTS:-`hostname`}
460 echo "Starting $LGSSD on clients $clients "
461 do_nodes $clients "$LGSSD -v" || return 4
464 # wait daemons entering "stable" status
468 # check daemons are running
470 list=$(comma_list $(mdts_nodes) $(osts_nodes))
471 check_gss_daemon_nodes $list lsvcgssd || return 5
473 list=$(comma_list $(mdts_nodes))
474 check_gss_daemon_nodes $list lgssd || return 6
477 check_gss_daemon_nodes $clients lgssd || return 7
482 local list=$(comma_list $(mdts_nodes))
484 send_sigint $list lsvcgssd lgssd
486 list=$(comma_list $(osts_nodes))
487 send_sigint $list lsvcgssd
489 list=${CLIENTS:-`hostname`}
490 send_sigint $list lgssd
495 if ! module_loaded ptlrpc_gss; then
496 load_module ptlrpc/gss/ptlrpc_gss
497 module_loaded ptlrpc_gss ||
498 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
500 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
502 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
503 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
511 # maybe cleanup credential cache?
517 local device=`mdsdevname $num`
518 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
524 local device=`ostdevname $num`
525 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
533 local dev=$(facet_active $facet)_dev
534 local opt=${facet}_opt
535 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
536 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
538 if [ $RC -ne 0 ]; then
539 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
540 echo "Start of ${!dev} on ${facet} failed ${RC}"
542 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
543 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
544 lctl set_param debug_mb=${DEBUG_SIZE}; \
547 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
548 [ -z "$label" ] && echo no label for ${!dev} && exit 1
549 eval export ${facet}_svc=${label}
550 echo Started ${label}
555 # start facet device options
561 eval export ${facet}_dev=${device}
562 eval export ${facet}_opt=\"$@\"
564 local varname=${facet}failover_dev
565 if [ -n "${!varname}" ] ; then
566 eval export ${facet}failover_dev=${!varname}
568 eval export ${facet}failover_dev=$device
571 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
581 HOST=`facet_active_host $facet`
582 [ -z $HOST ] && echo stop: no host for $facet && return 0
584 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
585 if [ ${running} -ne 0 ]; then
586 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
587 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
590 # umount should block, but we should wait for unrelated obd's
591 # like the MGS or MGC to also stop.
592 wait_exit_ST ${facet}
595 # save quota version (both administrative and operational quotas)
596 # add an additional parameter if mountpoint is ever different from $MOUNT
597 quota_save_version() {
598 local fsname=${2:-$FSNAME}
600 local ver=$(tr -c -d "123" <<< $spec)
601 local type=$(tr -c -d "ug" <<< $spec)
603 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
605 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
607 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
609 local osts=$(get_facets OST)
610 for ost in ${osts//,/ }; do
612 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
616 # client could mount several lustre
618 local fsname=${1:-$FSNAME}
620 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
621 do_nodes $(comma_list $(osts_nodes)) \
622 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
626 restore_quota_type () {
627 local mntpt=${1:-$MOUNT}
628 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
629 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
632 quota_save_version $old_QUOTA_TYPE
638 # We need save the original quota_type params, and restore them after testing
640 # Suppose that quota type the same on mds and ost
641 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
642 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
643 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
644 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
645 export old_QUOTA_TYPE=$quota_type
646 quota_save_version $QUOTA_TYPE
648 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
649 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
652 local quota_usrs=$QUOTA_USERS
654 # get_filesystem_size
655 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
656 local blk_soft=$((disksz + 1024))
657 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
659 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
661 local i_hard=$((i_soft + i_soft / 20))
663 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
664 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
667 for usr in $quota_usrs; do
668 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
670 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
672 eval $cmd || error "$cmd FAILED!"
674 # display the quota status
675 echo "Quota settings for $usr : "
676 $LFS quota -v -u $usr $mntpt || true
684 # Only supply -o to mount if we have options
685 if [ -n "$MOUNTOPT" ]; then
686 OPTIONS="-o $MOUNTOPT"
688 local device=$MGSNID:/$FSNAME
689 if [ -z "$mnt" -o -z "$FSNAME" ]; then
690 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
694 echo "Starting client: $client: $OPTIONS $device $mnt"
695 do_node $client mkdir -p $mnt
696 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
698 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
699 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
700 lctl set_param debug_mb=${DEBUG_SIZE}"
713 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
714 if [ $running -ne 0 ]; then
715 echo "Stopping client $client $mnt (opts:$force)"
716 do_node $client lsof -t $mnt || need_kill=no
717 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
718 pids=$(do_node $client lsof -t $mnt | sort -u);
719 if [ -n $pids ]; then
720 do_node $client kill -9 $pids || true
724 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
725 if [ $busy -ne 0 ] ; then
726 echo "$mnt is still busy, wait one second" && sleep 1
727 do_node $client umount $force $mnt
732 # nodes is comma list
733 sanity_mount_check_nodes () {
739 # FIXME: assume that all cluster nodes run the same os
740 [ "$(uname)" = Linux ] || return 0
743 for mnt in $mnts ; do
744 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
745 mpts=\\\$(mount | grep -w -c $mnt);
746 if [ \\\$running -ne \\\$mpts ]; then
747 echo \\\$(hostname) env are INSANE!;
755 sanity_mount_check_servers () {
757 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
758 echo Checking servers environments
760 # FIXME: modify get_facets to display all facets wo params
761 local facets="$(get_facets OST),$(get_facets MDS),mgs"
765 for facet in ${facets//,/ }; do
766 node=$(facet_host ${facet})
767 mnt=${MOUNT%/*}/${facet}
768 sanity_mount_check_nodes $node $mnt ||
769 { error "server $node environments are insane!"; return 1; }
773 sanity_mount_check_clients () {
774 local clients=${1:-$CLIENTS}
775 local mntpt=${2:-$MOUNT}
776 local mntpt2=${3:-$MOUNT2}
778 [ -z $clients ] && clients=$(hostname)
779 echo Checking clients $clients environments
781 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
782 error "clients environments are insane!"
785 sanity_mount_check () {
786 sanity_mount_check_servers || return 1
787 sanity_mount_check_clients || return 2
790 # mount clients if not mouted
791 zconf_mount_clients() {
794 local OPTIONS=${3:-$MOUNTOPT}
796 # Only supply -o to mount if we have options
797 if [ "$OPTIONS" ]; then
798 OPTIONS="-o $OPTIONS"
800 local device=$MGSNID:/$FSNAME
801 if [ -z "$mnt" -o -z "$FSNAME" ]; then
802 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
806 echo "Starting client $clients: $OPTIONS $device $mnt"
809 running=\\\$(mount | grep -c $mnt' ');
811 if [ \\\$running -eq 0 ] ; then
813 mount -t lustre $OPTIONS $device $mnt;
816 exit \\\$rc" || return ${PIPESTATUS[0]}
818 echo "Started clients $clients: "
819 do_nodes $clients "mount | grep -w $mnt"
821 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
822 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
823 lctl set_param debug_mb=${DEBUG_SIZE};"
828 zconf_umount_clients() {
835 echo "Stopping clients: $clients $mnt (opts:$force)"
836 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
837 if [ \\\$running -ne 0 ] ; then
838 echo Stopping client \\\$(hostname) $mnt opts:$force;
839 lsof -t $mnt || need_kill=no;
840 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
841 pids=\\\$(lsof -t $mnt | sort -u);
842 if [ -n \\\"\\\$pids\\\" ]; then
846 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
847 if [ \\\$busy -ne 0 ] ; then
848 echo "$mnt is still busy, wait one second" && sleep 1;
854 shudown_node_hard () {
858 for i in $(seq $attempts) ; do
861 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
862 echo "waiting for $host to fail attempts=$attempts"
863 [ $i -lt $attempts ] || \
864 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
870 local mnt=${2:-$MOUNT}
873 if [ "$FAILURE_MODE" = HARD ]; then
874 shudown_node_hard $client
876 zconf_umount_clients $client $mnt -f
882 if [ "$FAILURE_MODE" = HARD ]; then
883 shudown_node_hard $(facet_active_host $facet)
884 elif [ "$FAILURE_MODE" = SOFT ]; then
891 if [ "$FAILURE_MODE" = HARD ]; then
892 $POWER_UP `facet_active_host $facet`
900 if [ "$FAILURE_MODE" = HARD ]; then
906 # recovery-scale functions
907 check_progs_installed () {
912 do_nodes $clients "PATH=:$PATH; status=true;
913 for prog in $progs; do
914 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
915 echo \\\$prog missing on \\\$(hostname);
923 echo __$(echo $1 | tr '-' 'X')
926 start_client_load() {
929 local var=$(client_var_name $client)_load
930 eval export ${var}=$load
932 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
933 BREAK_ON_ERROR=$BREAK_ON_ERROR \
934 END_RUN_FILE=$END_RUN_FILE \
935 LOAD_PID_FILE=$LOAD_PID_FILE \
936 TESTSUITELOG=$TESTSUITELOG \
938 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
939 log "Started client load: ${load} on $client"
944 start_client_loads () {
945 local -a clients=(${1//,/ })
946 local numloads=${#CLIENT_LOADS[@]}
949 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
950 testnum=$((nodenum % numloads))
951 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
955 # only for remote client
956 check_client_load () {
958 local var=$(client_var_name $client)_load
959 local TESTLOAD=run_${!var}.sh
961 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
963 # bug 18914: try to connect several times not only when
964 # check ps, but while check_catastrophe also
967 while [ $RC = 254 -a $tries -gt 0 ]; do
971 if ! check_catastrophe $client; then
973 if [ $RC -eq 254 ]; then
974 # FIXME: not sure how long we shuold sleep here
978 echo "check catastrophe failed: RC=$RC "
982 # We can continue try to connect if RC=254
983 # Just print the warning about this
984 if [ $RC = 254 ]; then
985 echo "got a return status of $RC from do_node while checking catastrophe on $client"
988 # see if the load is still on the client
991 while [ $RC = 254 -a $tries -gt 0 ]; do
995 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1000 if [ $RC = 254 ]; then
1001 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1002 # see if we can diagnose a bit why this is
1007 check_client_loads () {
1008 local clients=${1//,/ }
1012 for client in $clients; do
1013 check_client_load $client
1015 if [ "$rc" != 0 ]; then
1016 log "Client load failed on node $client, rc=$rc"
1022 restart_client_loads () {
1023 local clients=${1//,/ }
1024 local expectedfail=${2:-""}
1028 for client in $clients; do
1029 check_client_load $client
1031 if [ "$rc" != 0 -a "$expectedfail" ]; then
1032 local var=$(client_var_name $client)_load
1033 start_client_load $client ${!var}
1034 echo "Restarted client load ${!var}: on $client. Checking ..."
1035 check_client_load $client
1037 if [ "$rc" != 0 ]; then
1038 log "Client load failed to restart on node $client, rc=$rc"
1039 # failure one client load means test fail
1040 # we do not need to check other
1048 # End recovery-scale functions
1050 # verify that lustre actually cleaned up properly
1052 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1053 error "LBUG/LASSERT detected"
1054 BUSY=`dmesg | grep -i destruct || true`
1055 if [ "$BUSY" ]; then
1057 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1061 check_mem_leak || exit 204
1063 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1064 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1066 if module_loaded lnet || module_loaded libcfs; then
1067 echo "$0: modules still loaded..." 1>&2
1084 RESULT=$(do_node $node "$TEST")
1085 if [ "$RESULT" == "$FINAL" ]; then
1086 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1089 [ $WAIT -ge $MAX ] && break
1090 echo "Waiting $((MAX - WAIT)) secs for update"
1091 WAIT=$((WAIT + sleep))
1094 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1098 wait_update_facet () {
1100 wait_update $(facet_active_host $facet) "$@"
1103 wait_delete_completed () {
1104 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1105 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1109 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1111 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1112 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1113 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1114 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1118 echo "Delete is not completed in $MAX_WAIT sec"
1124 check_network "$host" 900
1125 while ! do_node $host hostname > /dev/null; do sleep 5; done
1130 local host=`facet_active_host $facet`
1134 wait_recovery_complete () {
1137 # Use default policy if $2 is not passed by caller.
1138 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1139 # as we are in process of changing obd_timeout in different ways
1140 # let's set MAX longer than that
1141 local MAX=${2:-$(( TIMEOUT * 4 ))}
1143 local var_svc=${facet}_svc
1144 local procfile="*.${!var_svc}.recovery_status"
1148 while [ $WAIT -lt $MAX ]; do
1149 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1150 [[ $STATUS = "status: COMPLETE" ]] && return 0
1153 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1155 echo "$facet recovery not done in $MAX sec. $STATUS"
1159 wait_mds_ost_sync () {
1160 # just because recovery is done doesn't mean we've finished
1161 # orphan cleanup. Wait for llogs to get synchronized.
1162 echo "Waiting for orphan cleanup..."
1163 # MAX value includes time needed for MDS-OST reconnection
1164 local MAX=$(( TIMEOUT * 2 ))
1166 while [ $WAIT -lt $MAX ]; do
1167 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1168 "$LCTL get_param -n obdfilter.*.mds_sync"))
1170 for ((i=0; i<${#sync[@]}; i++)); do
1171 [ ${sync[$i]} -eq 0 ] && continue
1172 # there is a not finished MDS-OST synchronization
1176 sleep 2 # increase waiting time and cover statfs cache
1177 [ ${con} -eq 1 ] && return 0
1178 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1181 echo "$facet recovery not done in $MAX sec. $STATUS"
1185 wait_destroy_complete () {
1186 echo "Waiting for destroy to be done..."
1187 # MAX value shouldn't be big as this mean server responsiveness
1188 # never increase this just to make test pass but investigate
1189 # why it takes so long time
1192 while [ $WAIT -lt $MAX ]; do
1193 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1195 for ((i=0; i<${#RPCs[@]}; i++)); do
1196 [ ${RPCs[$i]} -eq 0 ] && continue
1197 # there are still some destroy RPCs in flight
1202 [ ${con} -eq 1 ] && return 0 # done waiting
1203 echo "Waiting $WAIT secs for destroys to be done."
1206 echo "Destroys weren't done in $MAX sec."
1216 # conf-sanity 31 takes a long time cleanup
1217 while [ $WAIT -lt 300 ]; do
1218 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1219 [ -z "${running}" ] && return 0
1220 echo "waited $WAIT for${running}"
1221 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1223 WAIT=$((WAIT + INTERVAL))
1225 echo "service didn't stop after $WAIT seconds. Still running:"
1230 wait_remote_prog () {
1236 [ "$PDSH" = "no_dsh" ] && return 0
1238 while [ $WAIT -lt $2 ]; do
1239 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1240 [ -z "${running}" ] && return 0 || true
1241 echo "waited $WAIT for: "
1243 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1245 WAIT=$((WAIT + INTERVAL))
1247 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1248 [ -z "$pids" ] && return 0
1249 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1250 # FIXME: not portable
1251 for pid in $pids; do
1252 cat /proc/${pid}/status || true
1253 cat /proc/${pid}/wchan || true
1255 kill -9 $pid || true
1264 # not every config has many clients
1266 if [ ! -z "$CLIENTS" ]; then
1267 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1269 stat -f $MOUNT > /dev/null
1275 # usually checked on particular client or locally
1277 if [ ! -z "$client" ]; then
1278 $PDSH $client "stat -f $MOUNT" > /dev/null
1280 stat -f $MOUNT > /dev/null
1288 client_reconnect() {
1289 uname -n >> $MOUNT/recon
1290 if [ -z "$CLIENTS" ]; then
1291 df $MOUNT; uname -n >> $MOUNT/recon
1293 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1295 echo Connected clients:
1297 ls -l $MOUNT/recon > /dev/null
1304 echo "Failing $facet on node `facet_active_host $facet`"
1305 shutdown_facet $facet
1306 [ -n "$sleep_time" ] && sleep $sleep_time
1308 change_active $facet
1309 local TO=`facet_active_host $facet`
1310 echo "Failover $facet to $TO"
1312 mount_facet $facet || error "Restart of $facet failed"
1321 do_facet $facet sync
1323 local svc=${facet}_svc
1324 do_facet $facet $LCTL --device %${!svc} notransno
1325 do_facet $facet $LCTL --device %${!svc} readonly
1326 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1327 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1330 replay_barrier_nodf() {
1331 local facet=$1 echo running=${running}
1332 do_facet $facet sync
1333 local svc=${facet}_svc
1334 echo Replay barrier on ${!svc}
1335 do_facet $facet $LCTL --device %${!svc} notransno
1336 do_facet $facet $LCTL --device %${!svc} readonly
1337 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1338 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1341 replay_barrier_nosync() {
1342 local facet=$1 echo running=${running}
1343 local svc=${facet}_svc
1344 echo Replay barrier on ${!svc}
1345 do_facet $facet $LCTL --device %${!svc} notransno
1346 do_facet $facet $LCTL --device %${!svc} readonly
1347 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1348 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1351 mds_evict_client() {
1352 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1353 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1356 ost_evict_client() {
1357 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1358 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1362 facet_failover $* || error "failover: $?"
1363 clients_up || error "post-failover df: $?"
1368 facet_failover $facet
1374 change_active $facet
1375 mount_facet $facet -o abort_recovery
1376 clients_up || echo "first df failed: $?"
1377 clients_up || error "post-failover df: $?"
1381 echo There is no lmc. This is mountconf, baby.
1386 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1387 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1393 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1399 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1400 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1401 if [ -z "$ID" ]; then
1402 echo "Could not get a ptl id for $1..."
1411 h2name_or_ip "$1" "tcp"
1416 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1417 if type __h2elan >/dev/null 2>&1; then
1420 ID=`echo $1 | sed 's/[^0-9]*//g'`
1428 h2name_or_ip "$1" "openib"
1430 declare -fx h2openib
1433 h2name_or_ip "$1" "o2ib"
1440 [ "$facet" == client ] && echo -n $HOSTNAME && return
1441 varname=${facet}_HOST
1442 if [ -z "${!varname}" ]; then
1443 if [ "${facet:0:3}" == "ost" ]; then
1444 eval ${facet}_HOST=${ost_HOST}
1452 local activevar=${facet}active
1454 if [ -f $TMP/${facet}active ] ; then
1455 source $TMP/${facet}active
1458 active=${!activevar}
1459 if [ -z "$active" ] ; then
1466 facet_active_host() {
1468 local active=`facet_active $facet`
1469 if [ "$facet" == client ]; then
1472 echo `facet_host $active`
1478 local failover=${facet}failover
1479 host=`facet_host $failover`
1480 [ -z "$host" ] && return
1481 local curactive=`facet_active $facet`
1482 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1483 eval export ${facet}active=$facet
1485 eval export ${facet}active=$failover
1487 # save the active host for this facet
1488 local activevar=${facet}active
1489 echo "$activevar=${!activevar}" > $TMP/$activevar
1494 # do not stripe off hostname if verbose, bug 19215
1495 if [ x$1 = x--verbose ]; then
1503 if [ "$HOST" = "$HOSTNAME" ]; then
1505 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1506 echo "cannot run remote command on $HOST with $myPDSH"
1510 echo "CMD: $HOST $@" >&2
1511 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1514 if [ "$myPDSH" = "rsh" ]; then
1515 # we need this because rsh does not return exit code of an executed command
1516 local command_status="$TMP/cs"
1517 rsh $HOST ":> $command_status"
1518 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1519 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1520 echo command failed >$command_status"
1521 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1526 # print HOSTNAME for myPDSH="no_dsh"
1527 if [[ $myPDSH = no_dsh ]]; then
1528 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1530 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1533 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1535 return ${PIPESTATUS[0]}
1539 do_node --verbose "$@"
1542 single_local_node () {
1543 [ "$1" = "$HOSTNAME" ]
1546 # Outputs environment variable assignments that should be passed to remote nodes
1551 for var in ${!MODOPTS_*}; do
1553 echo "${var}=\"$value\""
1559 # do not stripe off hostname if verbose, bug 19215
1560 if [ x$1 = x--verbose ]; then
1568 if single_local_node $rnodes; then
1570 do_nodev $rnodes "$@"
1572 do_node $rnodes "$@"
1577 # This is part from do_node
1580 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1581 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1584 echo "CMD: $rnodes $@" >&2
1585 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1589 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1591 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1593 return ${PIPESTATUS[0]}
1599 local HOST=`facet_active_host $facet`
1600 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1605 do_nodes --verbose "$@"
1611 # make sure its not already running
1613 rm -f $TMP/${facet}active
1614 do_facet ${facet} $MKFS $*
1620 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1621 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1628 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1629 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1637 # make sure we are using the primary server, so test-framework will
1638 # be able to clean up properly.
1639 activemds=`facet_active mds1`
1640 if [ $activemds != "mds1" ]; then
1644 local clients=$CLIENTS
1645 [ -z $clients ] && clients=$(hostname)
1647 zconf_umount_clients $clients $MOUNT "$*" || true
1648 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1650 [ "$CLIENTONLY" ] && return
1651 # The add fn does rm ${facet}active file, this would be enough
1652 # if we use do_facet <facet> only after the facet added, but
1653 # currently we use do_facet mds in local.sh
1654 for num in `seq $MDSCOUNT`; do
1656 rm -f ${TMP}/mds${num}active
1659 for num in `seq $OSTCOUNT`; do
1661 rm -f $TMP/ost${num}active
1664 if ! combined_mgs_mds ; then
1672 nfs_client_mode && return
1682 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1685 combined_mgs_mds () {
1686 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1690 if [ "$IAMDIR" == "yes" ]; then
1691 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1692 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1695 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1698 # We need ldiskfs here, may as well load them all
1700 [ "$CLIENTONLY" ] && return
1701 echo Formatting mgs, mds, osts
1702 if ! combined_mgs_mds ; then
1703 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1706 for num in `seq $MDSCOUNT`; do
1707 echo "Format mds$num: $(mdsdevname $num)"
1709 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1711 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1715 for num in `seq $OSTCOUNT`; do
1716 echo "Format ost$num: $(ostdevname $num)"
1718 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1720 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1726 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1730 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1734 # 0: success, the old identity set already.
1735 # 1: success, the old identity does not set.
1740 local j=`expr $num - 1`
1741 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1743 if [ -z "$MDT" ]; then
1747 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1750 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1752 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1755 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1757 if [ $old = "NONE" ]; then
1766 zconf_umount `hostname` $1 || error "umount failed"
1767 zconf_mount `hostname` $1 || error "mount failed"
1770 writeconf_facet () {
1774 do_facet $facet "$TUNEFS --writeconf $dev"
1778 for num in `seq $MDSCOUNT`; do
1779 DEVNAME=$(mdsdevname $num)
1780 writeconf_facet mds$num $DEVNAME
1783 for num in `seq $OSTCOUNT`; do
1784 DEVNAME=$(ostdevname $num)
1785 writeconf_facet ost$num $DEVNAME
1790 nfs_client_mode && return
1792 sanity_mount_check ||
1793 error "environments are insane!"
1797 if [ -z "$CLIENTONLY" ]; then
1798 echo Setup mgs, mdt, osts
1799 echo $WRITECONF | grep -q "writeconf" && \
1801 if ! combined_mgs_mds ; then
1802 start mgs $MGSDEV $mgs_MOUNT_OPTS
1805 for num in `seq $MDSCOUNT`; do
1806 DEVNAME=$(mdsdevname $num)
1807 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1809 # We started mds, now we should set failover variables properly.
1810 # Set mds${num}failover_HOST if it is not set (the default failnode).
1811 local varname=mds${num}failover_HOST
1812 if [ -z "${!varname}" ]; then
1813 eval mds${num}failover_HOST=$(facet_host mds$num)
1816 if [ $IDENTITY_UPCALL != "default" ]; then
1817 switch_identity $num $IDENTITY_UPCALL
1820 for num in `seq $OSTCOUNT`; do
1821 DEVNAME=$(ostdevname $num)
1822 start ost$num $DEVNAME $OST_MOUNT_OPTS
1824 # We started ost$num, now we should set ost${num}failover variable properly.
1825 # Set ost${num}failover_HOST if it is not set (the default failnode).
1826 varname=ost${num}failover_HOST
1827 if [ -z "${!varname}" ]; then
1828 eval ost${num}failover_HOST=$(facet_host ost${num})
1836 # wait a while to allow sptlrpc configuration be propogated to targets,
1837 # only needed when mounting new target devices.
1842 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1844 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1846 if [ "$MOUNT_2" ]; then
1847 mount_client $MOUNT2
1848 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1853 # by remounting mdt before ost, initial connect from mdt to ost might
1854 # timeout because ost is not ready yet. wait some time to its fully
1855 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1856 # by a context negotiation rpc with $TIMEOUT.
1857 # FIXME better by monitoring import status.
1860 sleep $((TIMEOUT + 5))
1866 mounted_lustre_filesystems() {
1867 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1870 init_facet_vars () {
1871 [ "$CLIENTONLY" ] && return 0
1878 eval export ${facet}_dev=${device}
1879 eval export ${facet}_opt=\"$@\"
1881 local dev=${facet}_dev
1882 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1883 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1885 eval export ${facet}_svc=${label}
1887 local varname=${facet}failover_HOST
1888 if [ -z "${!varname}" ]; then
1889 eval $varname=$(facet_host $facet)
1892 # ${facet}failover_dev is set in cfg file
1893 varname=${facet}failover_dev
1894 if [ -n "${!varname}" ] ; then
1895 eval export ${facet}failover_dev=${!varname}
1897 eval export ${facet}failover_dev=$device
1901 init_facets_vars () {
1904 if ! remote_mds_nodsh; then
1905 for num in `seq $MDSCOUNT`; do
1906 DEVNAME=`mdsdevname $num`
1907 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1911 remote_ost_nodsh && return
1913 for num in `seq $OSTCOUNT`; do
1914 DEVNAME=`ostdevname $num`
1915 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1919 osc_ensure_active () {
1925 while [ $period -lt $timeout ]; do
1926 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1927 if [ $count -eq 0 ]; then
1931 echo "There are $count OST are inactive, wait $period seconds, and try again"
1933 period=$((period+3))
1936 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1939 init_param_vars () {
1940 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1941 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1942 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1943 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1947 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1949 log "Using TIMEOUT=$TIMEOUT"
1951 osc_ensure_active $SINGLEMDS M $TIMEOUT
1952 osc_ensure_active client c $TIMEOUT
1954 if [ $QUOTA_AUTO -ne 0 ]; then
1955 if [ "$ENABLE_QUOTA" ]; then
1956 echo "enable quota as required"
1957 setup_quota $MOUNT || return 2
1959 echo "disable quota as required"
1960 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1967 nfs_client_mode () {
1968 if [ "$NFSCLIENT" ]; then
1969 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1970 local clients=$CLIENTS
1971 [ -z $clients ] && clients=$(hostname)
1973 # FIXME: remove hostname when 19215 fixed
1974 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1975 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1976 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1982 check_config_client () {
1985 local mounted=$(mount | grep " $mntpt ")
1986 if [ "$CLIENTONLY" ]; then
1988 # CLIENTONLY should not depend on *_HOST settings
1989 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1990 # in theory someone could create a new,
1991 # client-only config file that assumed lustre was already
1992 # configured and didn't set the MGSNID. If MGSNID is not set,
1993 # then we should use the mgs nid currently being used
1994 # as the default value. bug 18021
1995 [[ x$MGSNID = x ]] &&
1998 if [[ x$mgc != xMGC$MGSNID ]]; then
1999 if [ "$mgs_HOST" ]; then
2000 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2001 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2002 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2008 local myMGS_host=$mgs_HOST
2009 if [ "$NETTYPE" = "ptl" ]; then
2010 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2013 echo Checking config lustre mounted on $mntpt
2014 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2015 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2017 # if [ "$mgshost" != "$myMGS_host" ]; then
2018 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2019 # Please use correct config or set mds_HOST correctly!"
2024 check_config_clients () {
2025 local clients=${CLIENTS:-$HOSTNAME}
2028 nfs_client_mode && return
2030 do_rpc_nodes $clients check_config_client $mntpt
2032 sanity_mount_check ||
2033 error "environments are insane!"
2037 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2038 local cltimeout=$(lctl get_param -n timeout)
2039 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2040 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2047 local mounted=$(mounted_lustre_filesystems)
2049 echo $mounted' ' | grep -w -q $mntpt' '
2052 check_and_setup_lustre() {
2053 nfs_client_mode && return
2055 local MOUNTED=$(mounted_lustre_filesystems)
2059 # both MOUNT and MOUNT2 are not mounted
2060 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2061 [ "$REFORMAT" ] && formatall
2062 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2064 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2065 export I_MOUNTED=yes
2069 elif is_mounted $MOUNT2; then
2071 # MOUNT2 is mounted, while MOUNT_2 is not set
2072 if ! [ "$MOUNT_2" ]; then
2073 cleanup_mount $MOUNT2
2074 export I_UMOUNTED2=yes
2077 # MOUNT2 is mounted, MOUNT_2 is set
2079 # FIXME: what to do if check_config failed?
2081 # 1) remote client has mounted other Lustre fs ?
2082 # 2) it has insane env ?
2083 # let's try umount MOUNT2 on all clients and mount it again:
2084 if ! check_config_clients $MOUNT2; then
2085 cleanup_mount $MOUNT2
2086 restore_mount $MOUNT2
2087 export I_MOUNTED2=yes
2092 # MOUNT is mounted MOUNT2 is not mounted
2093 elif [ "$MOUNT_2" ]; then
2094 restore_mount $MOUNT2
2095 export I_MOUNTED2=yes
2099 # FIXME: what to do if check_config failed?
2101 # 1) remote client has mounted other Lustre fs?
2102 # 2) lustre is mounted on remote_clients atall ?
2103 check_config_clients $MOUNT
2107 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2108 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2109 lctl set_param debug_mb=${DEBUG_SIZE};
2116 if [ "$ONLY" == "setup" ]; then
2122 local clients=${CLIENTS:-$HOSTNAME}
2125 zconf_mount_clients $clients $mntpt
2129 local clients=${CLIENTS:-$HOSTNAME}
2132 zconf_umount_clients $clients $mntpt
2135 cleanup_and_setup_lustre() {
2136 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2137 lctl set_param debug=0 || true
2139 if [ "$ONLY" == "cleanup" ]; then
2143 check_and_setup_lustre
2146 check_and_cleanup_lustre() {
2147 if is_mounted $MOUNT; then
2148 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2149 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2152 if [ "$I_UMOUNTED2" = "yes" ]; then
2153 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2156 if [ "$I_MOUNTED2" = "yes" ]; then
2157 cleanup_mount $MOUNT2
2160 if [ "$I_MOUNTED" = "yes" ]; then
2161 cleanupall -f || error "cleanup failed"
2173 while [ $NETWORK -eq 0 ]; do
2174 if ping -c 1 -w 3 $1 > /dev/null; then
2178 echo "waiting for $1, $((MAX - WAIT)) secs left"
2181 if [ $WAIT -gt $MAX ]; then
2182 echo "Network not available"
2188 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2199 # the sed converts spaces to commas, but leaves the last space
2200 # alone, so the line doesn't end with a comma.
2201 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2204 # list, excluded are the comma separated lists
2205 exclude_items_from_list () {
2211 for item in ${excluded//,/ }; do
2212 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2214 echo $(comma_list $list)
2217 # list, expand are the comma separated lists
2219 local list=${1//,/ }
2220 local expand=${2//,/ }
2223 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2224 echo $(comma_list $expanded)
2227 testslist_filter () {
2228 local script=$LUSTRE/tests/${TESTSUITE}.sh
2230 [ -f $script ] || return 0
2232 local start_at=$START_AT
2233 local stop_at=$STOP_AT
2235 local var=${TESTSUITE//-/_}_START_AT
2236 [ x"${!var}" != x ] && start_at=${!var}
2237 var=${TESTSUITE//-/_}_STOP_AT
2238 [ x"${!var}" != x ] && stop_at=${!var}
2240 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2241 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2242 /^'${start_at}'$/ {flag = 0}
2243 {if (flag == 1) print $0}
2244 /^'${stop_at}'$/ { flag = 1 }'
2248 (cd `dirname $1`; echo $PWD/`basename $1`)
2252 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2253 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2256 local count=${type}COUNT
2257 for ((i=1; i<=${!count}; i++)) do
2258 list="$list ${name}$i"
2260 echo $(comma_list $list)
2263 ##################################
2264 # Adaptive Timeouts funcs
2267 # only check mds, we assume at_max is the same on all nodes
2268 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2269 if [ $at_max -eq 0 ]; then
2279 # suppose that all ost-s has the same at_max set
2280 if [ $facet == "ost" ]; then
2281 do_facet ost1 "lctl get_param -n at_max"
2283 do_facet $facet "lctl get_param -n at_max"
2293 if [ $facet == "ost" ]; then
2294 for i in `seq $OSTCOUNT`; do
2295 do_facet ost$i "lctl set_param at_max=$at_max"
2298 elif [ $facet == "mds" ]; then
2299 for i in `seq $MDSCOUNT`; do
2300 do_facet mds$i "lctl set_param at_max=$at_max"
2303 do_facet $facet "lctl set_param at_max=$at_max"
2308 ##################################
2312 # OBD_FAIL_MDS_ALL_REQUEST_NET
2314 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2315 do_facet client "$1" || RC=$?
2316 do_facet $SINGLEMDS lctl set_param fail_loc=0
2321 # OBD_FAIL_MDS_ALL_REPLY_NET
2323 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2324 do_facet client "$@" || RC=$?
2325 do_facet $SINGLEMDS lctl set_param fail_loc=0
2329 drop_reint_reply() {
2330 # OBD_FAIL_MDS_REINT_NET_REP
2332 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2333 do_facet client "$@" || RC=$?
2334 do_facet $SINGLEMDS lctl set_param fail_loc=0
2339 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2341 do_facet ost1 lctl set_param fail_loc=0x214
2342 do_facet client "$1" || RC=$?
2343 do_facet client "sync"
2344 do_facet ost1 lctl set_param fail_loc=0
2348 drop_ldlm_cancel() {
2349 #define OBD_FAIL_LDLM_CANCEL 0x304
2351 do_facet client lctl set_param fail_loc=0x304
2352 do_facet client "$@" || RC=$?
2353 do_facet client lctl set_param fail_loc=0
2357 drop_bl_callback() {
2358 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2360 do_facet client lctl set_param fail_loc=0x305
2361 do_facet client "$@" || RC=$?
2362 do_facet client lctl set_param fail_loc=0
2367 #define OBD_FAIL_LDLM_REPLY 0x30c
2369 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2370 do_facet client "$@" || RC=$?
2371 do_facet $SINGLEMDS lctl set_param fail_loc=0
2379 echo "clearing fail_loc on $facet"
2380 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2383 set_nodes_failloc () {
2384 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2387 cancel_lru_locks() {
2388 $LCTL mark "cancel_lru_locks $1 start"
2389 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2390 $LCTL set_param -n $d=clear
2392 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2393 $LCTL mark "cancel_lru_locks $1 stop"
2398 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2399 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2400 echo "$DEFAULT_LRU_SIZE"
2405 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2408 lru_resize_disable()
2410 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2415 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2416 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2417 echo there is still data in page cache $FILE ?
2418 lctl get_param -n $FILE
2426 DEBUGSAVE="$(lctl get_param -n debug)"
2430 [ -n "$DEBUGSAVE" ] && \
2431 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2436 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2439 debug_size_restore() {
2440 [ -n "$DEBUG_SIZE_SAVED" ] && \
2441 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2445 start_full_debug_logging() {
2450 local DEBUG_SIZE=150
2452 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2453 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2456 stop_full_debug_logging() {
2461 ##################################
2463 ##################################
2466 local TYPE=${TYPE:-"FAIL"}
2469 # do not dump logs if $1=false
2470 if [ "x$1" = "xfalse" ]; then
2475 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2477 # We need to dump the logs on all nodes
2479 gather_logs $(comma_list $(nodes_list))
2483 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2484 echo "$@" > $LOGDIR/err
2496 # use only if we are ignoring failures for this test, bugno required.
2497 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2498 # e.g. error_ignore 5494 "your message"
2500 local TYPE="IGNORE (bz$1)"
2506 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2511 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2512 [ "$TESTSUITELOG" ] && \
2513 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2516 build_test_filter() {
2517 EXCEPT="$EXCEPT $(testslist_filter)"
2519 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2523 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2524 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2525 [ "$EXCEPT_SLOW" ] && \
2526 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2527 for E in $EXCEPT $ALWAYS_EXCEPT; do
2528 eval EXCEPT_${E}=true
2530 for E in $EXCEPT_SLOW; do
2531 eval EXCEPT_SLOW_${E}=true
2533 for G in $GRANT_CHECK_LIST; do
2534 eval GCHECK_ONLY_${G}=true
2539 if [[ $1 = [a-z]* ]]; then
2546 # print a newline if the last test was skipped
2547 export LAST_SKIPPED=
2549 # Main entry into test-framework. This is called with the name and
2550 # description of a test. The name is used to find the function to run
2551 # the test using "test_$name".
2553 # This supports a variety of methods of specifying specific test to
2554 # run or not run. These need to be documented...
2559 export base=`basetest $1`
2560 if [ ! -z "$ONLY" ]; then
2562 if [ ${!testname}x != x ]; then
2563 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2564 run_one_logged $1 "$2"
2568 if [ ${!testname}x != x ]; then
2569 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2570 run_one_logged $1 "$2"
2578 if [ ${!testname}x != x ]; then
2580 TESTNAME=test_$1 skip "skipping excluded test $1"
2583 testname=EXCEPT_$base
2584 if [ ${!testname}x != x ]; then
2586 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2589 testname=EXCEPT_SLOW_$1
2590 if [ ${!testname}x != x ]; then
2592 TESTNAME=test_$1 skip "skipping SLOW test $1"
2595 testname=EXCEPT_SLOW_$base
2596 if [ ${!testname}x != x ]; then
2598 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2603 run_one_logged $1 "$2"
2608 EQUALS="======================================================================"
2612 local suffixlen=$((${#EQUALS} - ${#msg}))
2613 [ $suffixlen -lt 5 ] && suffixlen=5
2614 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2619 module_loaded lnet || load_modules
2631 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2636 strace -o $TMP/$1.strace -ttt $*
2638 log "FINISHED: $*: rc $RC"
2643 # Set TEST_STATUS here; will be used for logging the result
2644 if [ -f $LOGDIR/err ]; then
2649 echo $TEST_STATUS " " $@
2653 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2654 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2655 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2659 echo -n "Resetting fail_loc on all nodes..."
2660 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2666 # Log a message (on all nodes) padded with "=" before and after.
2667 # Also appends a timestamp and prepends the testsuite name.
2670 msg="== ${TESTSUITE} $*"
2671 # pad the message out to 70 with "="
2673 [[ $last != "=" && $last != " " ]] && msg+=" "
2674 for i in $(seq $((68 - ${#msg})) ); do
2677 # always include at least == after the message
2680 log "$msg $(date +"%H:%M:%S (%s)")"
2684 # Run a single test function and cleanup after it.
2686 # This function should be run in a subshell so the test func can
2687 # exit() without stopping the whole script.
2693 export tdir=d0.${TESTSUITE}/d${base}
2694 export TESTNAME=test_$testnum
2695 local SAVE_UMASK=`umask`
2698 banner "test $testnum: $message"
2699 test_${testnum} || error "test_$testnum failed with $?"
2702 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2703 check_catastrophe || error "LBUG/LASSERT detected"
2704 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2712 # Wrapper around run_one to ensure:
2713 # - test runs in subshell
2714 # - output of test is saved to separate log file for error reporting
2715 # - test result is saved to data file
2718 local BEFORE=`date +%s`
2720 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
2721 local test_log=$LOGDIR/$name
2725 run_one $1 "$2" 2>&1 | tee $test_log
2726 local RC=${PIPESTATUS[0]}
2728 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2729 echo "test_$1 returned $RC" | tee $LOGDIR/err
2731 duration=$((`date +%s` - $BEFORE))
2732 pass "(${duration}s)"
2733 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2734 log_sub_test test_${1} $TEST_STATUS $duration "$RC" "$TEST_ERROR"
2736 if [ -f $LOGDIR/err ]; then
2737 $FAIL_ON_ERROR && exit $RC
2744 (cd `dirname $1`; echo $PWD/`basename $1`)
2748 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2749 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2754 export base=`basetest $1`
2755 [ "$CHECK_GRANT" == "no" ] && return 0
2757 testname=GCHECK_ONLY_${base}
2758 [ ${!testname}x == x ] && return 0
2760 echo -n "checking grant......"
2762 # write some data to sync client lost_grant
2763 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2764 for i in `seq $OSTCOUNT`; do
2765 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2766 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2767 count=1 > /dev/null 2>&1
2769 # sync all the data and make sure no pending data on server
2772 #get client grant and server grant
2774 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2775 client_grant=$((client_grant + $d))
2778 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2779 server_grant=$((server_grant + $d))
2782 # cleanup the check_grant file
2783 for i in `seq $OSTCOUNT`; do
2784 rm $DIR1/${tfile}_check_grant_$i
2787 #check whether client grant == server grant
2788 if [ $client_grant != $server_grant ]; then
2789 echo "failed: client:${client_grant} server: ${server_grant}"
2796 ########################
2802 ost=`echo $1 | awk -F_ '{print $3}'`
2803 if [ -z $ost ]; then
2804 ost=`echo $1 | sed 's/-osc.*//'`
2811 [ "$node" != "$(hostname)" ]
2817 for node in $(mdts_nodes); do
2818 remote_node $node && return 0
2825 [ "$CLIENTONLY" ] && return 0 || true
2826 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2831 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
2832 MSKIPPED=1 && return 1
2839 for node in $(osts_nodes) ; do
2840 remote_node $node && return 0
2847 [ "$CLIENTONLY" ] && return 0 || true
2848 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2853 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
2854 OSKIPPED=1 && return 1
2861 MGS=$(facet_host mgs)
2862 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2867 remote_mds_nodsh || remote_ost_nodsh || \
2868 $(single_local_node $(comma_list $(nodes_list)))
2874 for num in `seq $MDSCOUNT`; do
2875 MDSNODES="$MDSNODES $(facet_host mds$num)"
2877 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2883 remote_ost && remote_mds
2887 local OSTNODES=$(facet_host ost1)
2890 for num in `seq $OSTCOUNT`; do
2891 local myOST=$(facet_host ost$num)
2892 OSTNODES="$OSTNODES $myOST"
2894 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2900 # FIXME. We need a list of clients
2901 local myNODES=$HOSTNAME
2904 # CLIENTS (if specified) contains the local client
2905 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2907 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2908 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2911 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2916 remote_nodes_list () {
2917 local rnodes=$(nodes_list)
2918 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2922 init_clients_lists () {
2923 # Sanity check: exclude the local client from RCLIENTS
2924 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2926 # Sanity check: exclude the dup entries
2927 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2929 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2931 # Sanity check: exclude the dup entries from CLIENTS
2932 # for those configs which has SINGLCLIENT set to local client
2933 clients=$(for i in $clients; do echo $i; done | sort -u)
2935 CLIENTS=`comma_list $clients`
2936 local -a remoteclients=($rclients)
2937 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2938 varname=CLIENT$((i + 2))
2939 eval $varname=${remoteclients[i]}
2942 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2945 get_random_entry () {
2948 rnodes=${rnodes//,/ }
2950 local -a nodes=($rnodes)
2951 local num=${#nodes[@]}
2952 local i=$((RANDOM * num * 2 / 65536))
2958 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2963 lctl get_param version | grep -q patchless
2967 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2972 echo $nodes | wc -w || true
2976 local nodes=$(osts_nodes)
2977 local osscount=$(get_node_count "$nodes")
2978 [ ! "$OSTCOUNT" = "$osscount" ]
2982 local nodes=$(mdts_nodes)
2983 local mdtcount=$(get_node_count "$nodes")
2984 [ ! "$MDSCOUNT" = "$mdtcount" ]
2987 generate_machine_file() {
2988 local nodes=${1//,/ }
2989 local machinefile=$2
2991 for node in $nodes; do
2992 echo $node >>$machinefile || \
2993 { echo "can not generate machinefile $machinefile" && return 1; }
2998 local file=$1/stripe
3000 $LFS getstripe -v $file || error
3004 setstripe_nfsserver () {
3007 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3008 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3010 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3012 do_nodev $nfsserver lfs setstripe "$@"
3015 check_runas_id_ret() {
3017 local myRUNAS_UID=$1
3018 local myRUNAS_GID=$2
3021 if [ -z "$myRUNAS" ]; then
3022 error_exit "myRUNAS command must be specified for check_runas_id"
3025 $myRUNAS krb5_login.sh || \
3026 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3028 mkdir $DIR/d0_runas_test
3030 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3031 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3032 rm -rf $DIR/d0_runas_test
3037 local myRUNAS_UID=$1
3038 local myRUNAS_GID=$2
3041 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3042 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3043 Please set RUNAS_ID to some UID which exists on MDS and client or
3044 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3047 # obtain the UID/GID for MPI_USER
3051 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3052 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3054 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3055 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3058 # obtain and cache Kerberos ticket-granting ticket
3059 refresh_krb5_tgt() {
3060 local myRUNAS_UID=$1
3061 local myRUNAS_GID=$2
3064 if [ -z "$myRUNAS" ]; then
3065 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3068 CLIENTS=${CLIENTS:-$HOSTNAME}
3069 do_nodes $CLIENTS "set -x
3070 if ! $myRUNAS krb5_login.sh; then
3071 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3076 # Run multiop in the background, but wait for it to print
3077 # "PAUSING" to its stdout before returning from this function.
3078 multiop_bg_pause() {
3079 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3083 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3086 echo "$MULTIOP_PROG $FILE v$ARGS"
3087 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3089 echo "TMPPIPE=${TMPPIPE}"
3090 read -t 60 multiop_output < $TMPPIPE
3091 if [ $? -ne 0 ]; then
3096 if [ "$multiop_output" != "PAUSING" ]; then
3097 echo "Incorrect multiop output: $multiop_output"
3112 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3118 inodes_available () {
3119 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3123 mdsrate_inodes_available () {
3124 echo $(($(inodes_available) - 1))
3127 # reset llite stat counters
3128 clear_llite_stats(){
3129 lctl set_param -n llite.*.stats 0
3132 # sum llite stat items
3133 calc_llite_stats() {
3134 local res=$(lctl get_param -n llite.*.stats |
3135 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3139 # reset osc stat counters
3141 lctl set_param -n osc.*.osc_stats 0
3144 # sum osc stat items
3146 local res=$(lctl get_param -n osc.*.osc_stats |
3147 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3152 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3155 calc_osc_kbytes () {
3156 df $MOUNT > /dev/null
3157 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3160 # save_lustre_params(node, parameter_mask)
3161 # generate a stream of formatted strings (<node> <param name>=<param value>)
3162 save_lustre_params() {
3164 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3167 # restore lustre parameters from input stream, produces by save_lustre_params
3168 restore_lustre_params() {
3172 while IFS=" =" read node name val; do
3173 do_node ${node//:/} "lctl set_param -n $name $val"
3177 check_catastrophe() {
3178 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3179 local C=$CATASTROPHE
3180 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3182 if [ $rnodes ]; then
3183 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3184 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3200 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3202 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3203 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3204 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3208 # CMD: determine mds index where directory inode presents
3211 local file=$dir/f0.get_mds_dir_tmpfile
3216 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3217 local -a oldused=($iused)
3219 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3221 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3222 local -a newused=($iused)
3225 for ((i=0; i<${#newused[@]}; i++)); do
3226 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3232 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3235 mdsrate_cleanup () {
3237 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3242 delayed_recovery_enabled () {
3243 local var=${SINGLEMDS}_svc
3244 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3247 ########################
3249 convert_facet2label() {
3252 if [ x$facet = xost ]; then
3256 local varsvc=${facet}_svc
3258 if [ -n ${!varsvc} ]; then
3261 error "No lablel for $facet!"
3265 get_clientosc_proc_path() {
3271 get_lustre_version () {
3272 local node=${1:-"mds"}
3273 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3276 get_mds_version_major () {
3277 local version=$(get_lustre_version mds)
3278 echo $version | awk -F. '{print $1}'
3281 get_mds_version_minor () {
3282 local version=$(get_lustre_version mds)
3283 echo $version | awk -F. '{print $2}'
3286 get_mdtosc_proc_path() {
3288 local major=$(get_mds_version_major)
3289 local minor=$(get_mds_version_minor)
3290 if [ $major -le 1 -a $minor -le 8 ] ; then
3293 echo "${ost}-osc-MDT0000"
3297 get_osc_import_name() {
3300 local label=$(convert_facet2label $ost)
3302 if [ "$facet" == "mds" ]; then
3303 get_mdtosc_proc_path $label
3307 get_clientosc_proc_path $label
3311 wait_import_state () {
3317 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3318 while [ "${CONN_STATE}" != "${expected}" ]; do
3319 if [ "${expected}" == "DISCONN" ]; then
3320 # for disconn we can check after proc entry is removed
3321 [ "x${CONN_STATE}" == "x" ] && return 0
3322 # with AT we can have connect request timeout ~ reconnect timeout
3323 # and test can't see real disconnect
3324 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3326 # disconnect rpc should be wait not more obd_timeout
3327 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3328 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3330 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3334 log "$CONN_PROC now in ${CONN_STATE} state"
3338 wait_osc_import_state() {
3342 local ost=$(get_osc_import_name $facet $ost_facet)
3347 CONN_PROC="osc.${ost}.ost_server_uuid"
3348 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3349 while [ "${CONN_STATE}" != "${expected}" ]; do
3350 if [ "${expected}" == "DISCONN" ]; then
3351 # for disconn we can check after proc entry is removed
3352 [ "x${CONN_STATE}" == "x" ] && return 0
3353 # with AT we can have connect request timeout ~ reconnect timeout
3354 # and test can't see real disconnect
3355 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3357 # disconnect rpc should be wait not more obd_timeout
3358 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3359 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3361 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3365 log "${ost_facet} now in ${CONN_STATE} state"
3368 get_clientmdc_proc_path() {
3376 # Add paths to lustre tests for 32 and 64 bit systems.
3377 local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3378 do_nodesv $list "PATH=$RPATH sh rpc.sh $@ "
3381 wait_clients_import_state () {
3387 local label=$(convert_facet2label $facet)
3390 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3391 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3392 *) error "unknown facet!" ;;
3395 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3396 error "import is not in ${expected} state"
3405 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3406 $LCTL get_param obdfilter.*.kbytesavail))
3407 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3408 $LCTL get_param -n obdfilter.*.tot_granted))
3409 for ((i=0; i<${#AVAILA[@]}; i++)); do
3410 local -a AVAIL1=(${AVAILA[$i]//=/ })
3411 GRANT=$((${GRANTA[$i]}/1024))
3412 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3413 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3419 do_facet mgs lctl pool_list $1
3423 local fsname=${1%%.*}
3424 local poolname=${1##$fsname.}
3426 do_facet mgs lctl pool_new $1
3428 # get param should return err unless pool is created
3429 [[ $RC -ne 0 ]] && return $RC
3431 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3432 2>/dev/null || echo foo" "" || RC=1
3433 if [[ $RC -eq 0 ]]; then
3436 error "pool_new failed $1"
3441 add_pool_to_list () {
3442 local fsname=${1%%.*}
3443 local poolname=${1##$fsname.}
3445 local listvar=${fsname}_CREATED_POOLS
3446 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3449 remove_pool_from_list () {
3450 local fsname=${1%%.*}
3451 local poolname=${1##$fsname.}
3453 local listvar=${fsname}_CREATED_POOLS
3454 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3457 destroy_pool_int() {
3459 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3460 awk '$1 !~ /^Pool:/ {print $1}')
3461 for ost in $OSTS; do
3462 do_facet mgs lctl pool_remove $1 $ost
3464 do_facet mgs lctl pool_destroy $1
3467 # <fsname>.<poolname> or <poolname>
3469 local fsname=${1%%.*}
3470 local poolname=${1##$fsname.}
3472 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3476 pool_list $fsname.$poolname || return $?
3478 destroy_pool_int $fsname.$poolname
3480 [[ $RC -ne 0 ]] && return $RC
3482 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3483 2>/dev/null || echo foo" "foo" || RC=1
3485 if [[ $RC -eq 0 ]]; then
3486 remove_pool_from_list $fsname.$poolname
3488 error "destroy pool failed $1"
3494 local fsname=${1:-$FSNAME}
3496 local listvar=${fsname}_CREATED_POOLS
3500 [ x${!listvar} = x ] && return 0
3502 echo destroy the created pools: ${!listvar}
3503 for poolname in ${!listvar//,/ }; do
3504 destroy_pool $fsname.$poolname
3509 local fsname=${1:-$FSNAME}
3511 destroy_pools $fsname
3517 local ts=$(date +%s)
3519 # bug 20237, comment 11
3520 # It would also be useful to provide the option
3521 # of writing the file to an NFS directory so it doesn't need to be copied.
3524 [ -f $LOGDIR/shared ] && docp=false
3526 # dump lustre logs, dmesg
3528 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3530 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3532 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3533 echo "Dumping logs only on local client."
3534 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3535 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3540 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3541 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3542 if [ ! -f $LOGDIR/shared ]; then
3543 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3546 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3547 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3553 local list=${1:-$(comma_list $(nodes_list))}
3555 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3567 for i in $(seq 0 $num_mntpts); do
3568 cmd="ls -laf ${mntpt_root}$i/$dir"
3574 for pid in $pids; do
3581 get_clients_mount_count () {
3582 local clients=${CLIENTS:-`hostname`}
3584 # we need to take into account the clients mounts and
3585 # exclude mds/ost mounts if any;
3586 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
3590 PROC_CLI="srpc_info"
3598 if [ $M -lt $N ]; then
3602 while [ $N -le $M ]; do
3612 calc_connection_cnt() {
3615 # MDT->MDT = 2 * C(M, 2)
3619 comb_m2=$(combination $MDSCOUNT 2)
3621 local num_clients=$(get_clients_mount_count)
3623 local cnt_mdt2mdt=$((comb_m2 * 2))
3624 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
3625 local cnt_cli2ost=$((num_clients * OSTCOUNT))
3626 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
3627 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
3628 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
3629 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
3643 local cmd="$tgt.srpc.flavor"
3645 if [ $net == "any" ]; then
3650 if [ $dir != "any" ]; then
3655 log "Setting sptlrpc rule: $cmd"
3656 do_facet mgs "$LCTL conf_param $cmd"
3665 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
3666 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
3668 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
3670 if [ "x$bulkspec" != "x" ]; then
3671 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
3673 if [ "x$algs" != "x" ]; then
3674 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
3676 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
3677 if [ $bulk == "bulkn" ]; then
3678 bulk_count=`echo "$output" | grep "bulk flavor" \
3679 | grep "null/null" | wc -l`
3680 elif [ $bulk == "bulki" ]; then
3681 bulk_count=`echo "$output" | grep "bulk flavor" \
3682 | grep "/null" | grep -v "null/" | wc -l`
3684 bulk_count=`echo "$output" | grep "bulk flavor" \
3685 | grep -v "/null" | grep -v "null/" | wc -l`
3689 [ $bulk_count -lt $count ] && count=$bulk_count
3700 local clients=${CLIENTS:-`hostname`}
3702 for c in ${clients//,/ }; do
3703 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
3704 tmpcnt=`count_flvr "$output" $flavor`
3705 cnt=$((cnt + tmpcnt))
3715 local clients=${CLIENTS:-`hostname`}
3717 for c in ${clients//,/ }; do
3718 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
3719 tmpcnt=`count_flvr "$output" $flavor`
3720 cnt=$((cnt + tmpcnt))
3730 if [ $MDSCOUNT -le 1 ]; then
3735 for num in `seq $MDSCOUNT`; do
3736 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
3737 tmpcnt=`count_flvr "$output" $flavor`
3738 cnt=$((cnt + tmpcnt))
3748 for num in `seq $MDSCOUNT`; do
3749 output=`do_facet mds$num lctl get_param -n osc.*OST*-osc-MDT*.$PROC_CLI 2>/dev/null`
3750 tmpcnt=`count_flvr "$output" $flavor`
3751 cnt=$((cnt + tmpcnt))
3760 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
3761 count_flvr "$output" $flavor
3766 local dir=$1 # from to
3767 local flavor=$2 # flavor expected
3770 if [ $dir == "cli2mdt" ]; then
3771 res=`flvr_cnt_cli2mdt $flavor`
3772 elif [ $dir == "cli2ost" ]; then
3773 res=`flvr_cnt_cli2ost $flavor`
3774 elif [ $dir == "mdt2mdt" ]; then
3775 res=`flvr_cnt_mdt2mdt $flavor`
3776 elif [ $dir == "mdt2ost" ]; then
3777 res=`flvr_cnt_mdt2ost $flavor`
3778 elif [ $dir == "all2ost" ]; then
3779 res1=`flvr_cnt_mdt2ost $flavor`
3780 res2=`flvr_cnt_cli2ost $flavor`
3781 res=$((res1 + res2))
3782 elif [ $dir == "all2mdt" ]; then
3783 res1=`flvr_cnt_mdt2mdt $flavor`
3784 res2=`flvr_cnt_cli2mdt $flavor`
3785 res=$((res1 + res2))
3786 elif [ $dir == "all2all" ]; then
3787 res1=`flvr_cnt_mdt2ost $flavor`
3788 res2=`flvr_cnt_cli2ost $flavor`
3789 res3=`flvr_cnt_mdt2mdt $flavor`
3790 res4=`flvr_cnt_cli2mdt $flavor`
3791 res=$((res1 + res2 + res3 + res4))
3799 local dir=$1 # from to
3800 local flavor=$2 # flavor expected
3801 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
3805 for ((i=0;i<20;i++)); do
3806 echo -n "checking..."
3807 res=$(do_check_flavor $dir $flavor)
3808 if [ $res -eq $expect ]; then
3809 echo "found $res $flavor connections of $dir, OK"
3812 echo "found $res $flavor connections of $dir, not ready ($expect)"
3817 echo "Error checking $flavor of $dir: expect $expect, actual $res"
3821 restore_to_default_flavor()
3823 local proc="mgs.MGS.live.$FSNAME"
3825 echo "restoring to default flavor..."
3827 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3829 # remove all existing rules if any
3830 if [ $nrule -ne 0 ]; then
3831 echo "$nrule existing rules"
3832 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
3833 echo "remove rule: $rule"
3834 spec=`echo $rule | awk -F = '{print $1}'`
3835 do_facet mgs "$LCTL conf_param $spec="
3839 # verify no rules left
3840 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3841 [ $nrule -ne 0 ] && error "still $nrule rules left"
3843 # wait for default flavor to be applied
3844 # currently default flavor for all connections are 'null'
3845 wait_flavor all2all null
3846 echo "now at default flavor settings"
3851 local flavor=${1:-null}
3853 echo "setting all flavor to $flavor"
3855 # FIXME need parameter to this fn
3856 # and remove global vars
3857 local cnt_all2all=$(calc_connection_cnt all2all)
3859 local res=$(do_check_flavor all2all $flavor)
3860 if [ $res -eq $cnt_all2all ]; then
3861 echo "already have total $res $flavor connections"
3865 echo "found $res $flavor out of total $cnt_all2all connections"
3866 restore_to_default_flavor
3868 [[ $flavor = null ]] && return 0
3870 set_rule $FSNAME any any $flavor
3871 wait_flavor all2all $flavor
3877 # Checking for shared logdir
3878 if [ ! -d $dir ]; then
3879 # Not found. Create local logdir
3882 touch $dir/node.$(hostname).yml
3887 check_write_access() {
3889 for node in $(nodes_list); do
3890 if [ ! -f "$dir/node.${node}.yml" ]; then
3891 # Logdir not accessible/writable from this node.
3899 if [[ -n $YAML_LOG ]]; then
3902 export YAML_LOG=${LOGDIR}/results.yml
3906 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
3907 if check_write_access $LOGDIR; then
3908 touch $LOGDIR/shared
3909 echo "Logging to shared log directory: $LOGDIR"
3911 echo "Logging to local directory: $LOGDIR"
3914 yml_nodes_file $LOGDIR
3915 yml_results_file >> $YAML_LOG
3919 yml_log_test $1 >> $YAML_LOG
3923 yml_log_sub_test $@ >> $YAML_LOG
3929 local devname=$(basename $1)
3930 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
3931 size=$(($size / 1024 / 1024)) # Gb
3933 local partial_arg=""
3934 # Run in partial (fast) mode if the size
3935 # of a partition > 10 GB
3936 [ $size -gt 10 ] && partial_arg="-p"
3938 llverdev --force $partial_arg $dev