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 module_loaded ${BASE} && return
253 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
255 if [ $# -eq 0 ]; then
256 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
257 # Bash until 4.x, so we resort to eval.
258 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
259 eval set -- \$$optvar
260 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
261 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
262 set -- $(grep "^options\\s*\<${module}\>" $MODPROBECONF)
263 # Get rid of "options $module"
264 (($# > 0)) && shift 2
266 # Ensure we have accept=all for lnet
267 if [ $(basename $module) = lnet ]; then
268 # OK, this is a bit wordy...
269 local arg accept_all_present=false
271 [ "$arg" = accept=all ] && accept_all_present=true
273 $accept_all_present || set -- "$@" accept=all
278 [ $# -gt 0 ] && echo "${module} options: '$*'"
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"
305 echo Loading modules from $LUSTRE
306 load_module ../libcfs/libcfs/libcfs
307 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
308 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
309 load_module ../lnet/lnet/lnet
310 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
311 load_module ../lnet/klnds/$LNETLND
312 load_module lvfs/lvfs
313 load_module obdclass/obdclass
314 load_module ptlrpc/ptlrpc
315 load_module ptlrpc/gss/ptlrpc_gss
316 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
324 if ! client_only; then
325 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
326 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
327 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
332 load_module lvfs/fsfilt_$FSTYPE
336 load_module obdfilter/obdfilter
339 load_module llite/lustre
340 load_module llite/llite_lloop
341 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
343 rm -f $OGDB/ogdb-$HOSTNAME
344 $LCTL modules > $OGDB/ogdb-$HOSTNAME
346 # 'mount' doesn't look in $PATH, just sbin
347 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
353 # load modules on remote nodes optionally
354 # lustre-tests have to be installed on these nodes
355 if $LOAD_MODULES_REMOTE ; then
356 local list=$(comma_list $(remote_nodes_list))
357 echo loading modules on $list
358 do_rpc_nodes $list load_modules
363 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
364 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
365 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
366 echo "$LEAK_LUSTRE" 1>&2
367 echo "$LEAK_PORTALS" 1>&2
368 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
369 echo "Memory leaks detected"
370 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
376 wait_exit_ST client # bug 12845
378 $LUSTRE_RMMOD $FSTYPE || return 2
380 if $LOAD_MODULES_REMOTE ; then
381 local list=$(comma_list $(remote_nodes_list))
382 if [ ! -z $list ]; then
383 echo unloading modules on $list
384 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
385 do_rpc_nodes $list check_mem_leak
389 check_mem_leak || return 254
391 echo "modules unloaded."
395 check_gss_daemon_nodes() {
399 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
400 if [ \\\"\\\$num\\\" -ne 1 ]; then
401 echo \\\$num instance of $dname;
406 check_gss_daemon_facet() {
410 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
411 if [ $num -ne 1 ]; then
412 echo "$num instance of $dname on $facet"
421 echo Stopping $@ on $list
422 do_nodes $list "killall -2 $@ 2>/dev/null || true"
425 # start gss daemons on all nodes, or
426 # "daemon" on "list" if set
427 start_gss_daemons() {
431 if [ "$list" ] && [ "$daemon" ] ; then
432 echo "Starting gss daemon on nodes: $list"
433 do_nodes $list "$daemon" || return 8
437 local list=$(comma_list $(mdts_nodes))
439 echo "Starting gss daemon on mds: $list"
440 do_nodes $list "$LSVCGSSD -v" || return 1
442 do_nodes $list "$LGSSD -v" || return 2
445 list=$(comma_list $(osts_nodes))
446 echo "Starting gss daemon on ost: $list"
447 do_nodes $list "$LSVCGSSD -v" || return 3
448 # starting on clients
450 local clients=${CLIENTS:-`hostname`}
452 echo "Starting $LGSSD on clients $clients "
453 do_nodes $clients "$LGSSD -v" || return 4
456 # wait daemons entering "stable" status
460 # check daemons are running
462 list=$(comma_list $(mdts_nodes) $(osts_nodes))
463 check_gss_daemon_nodes $list lsvcgssd || return 5
465 list=$(comma_list $(mdts_nodes))
466 check_gss_daemon_nodes $list lgssd || return 6
469 check_gss_daemon_nodes $clients lgssd || return 7
474 local list=$(comma_list $(mdts_nodes))
476 send_sigint $list lsvcgssd lgssd
478 list=$(comma_list $(osts_nodes))
479 send_sigint $list lsvcgssd
481 list=${CLIENTS:-`hostname`}
482 send_sigint $list lgssd
487 if ! module_loaded ptlrpc_gss; then
488 load_module ptlrpc/gss/ptlrpc_gss
489 module_loaded ptlrpc_gss ||
490 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
492 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
494 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
495 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
503 # maybe cleanup credential cache?
509 local device=`mdsdevname $num`
510 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
516 local device=`ostdevname $num`
517 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
525 local dev=$(facet_active $facet)_dev
526 local opt=${facet}_opt
527 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
528 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
530 if [ $RC -ne 0 ]; then
531 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
532 echo "Start of ${!dev} on ${facet} failed ${RC}"
534 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
535 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
536 lctl set_param debug_mb=${DEBUG_SIZE}; \
539 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
540 [ -z "$label" ] && echo no label for ${!dev} && exit 1
541 eval export ${facet}_svc=${label}
542 echo Started ${label}
547 # start facet device options
553 eval export ${facet}_dev=${device}
554 eval export ${facet}_opt=\"$@\"
556 local varname=${facet}failover_dev
557 if [ -n "${!varname}" ] ; then
558 eval export ${facet}failover_dev=${!varname}
560 eval export ${facet}failover_dev=$device
563 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
573 HOST=`facet_active_host $facet`
574 [ -z $HOST ] && echo stop: no host for $facet && return 0
576 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
577 if [ ${running} -ne 0 ]; then
578 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
579 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
582 # umount should block, but we should wait for unrelated obd's
583 # like the MGS or MGC to also stop.
584 wait_exit_ST ${facet}
587 # save quota version (both administrative and operational quotas)
588 # add an additional parameter if mountpoint is ever different from $MOUNT
589 quota_save_version() {
590 local fsname=${2:-$FSNAME}
592 local ver=$(tr -c -d "123" <<< $spec)
593 local type=$(tr -c -d "ug" <<< $spec)
595 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
597 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
599 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
601 local osts=$(get_facets OST)
602 for ost in ${osts//,/ }; do
604 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
608 # client could mount several lustre
610 local fsname=${1:-$FSNAME}
612 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
613 do_nodes $(comma_list $(osts_nodes)) \
614 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
618 restore_quota_type () {
619 local mntpt=${1:-$MOUNT}
620 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
621 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
624 quota_save_version $old_QUOTA_TYPE
630 # We need save the original quota_type params, and restore them after testing
632 # Suppose that quota type the same on mds and ost
633 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
634 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
635 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
636 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
637 export old_QUOTA_TYPE=$quota_type
638 quota_save_version $QUOTA_TYPE
640 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
641 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
644 local quota_usrs=$QUOTA_USERS
646 # get_filesystem_size
647 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
648 local blk_soft=$((disksz + 1024))
649 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
651 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
653 local i_hard=$((i_soft + i_soft / 20))
655 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
656 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
659 for usr in $quota_usrs; do
660 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
662 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
664 eval $cmd || error "$cmd FAILED!"
666 # display the quota status
667 echo "Quota settings for $usr : "
668 $LFS quota -v -u $usr $mntpt || true
676 # Only supply -o to mount if we have options
677 if [ -n "$MOUNTOPT" ]; then
678 OPTIONS="-o $MOUNTOPT"
680 local device=$MGSNID:/$FSNAME
681 if [ -z "$mnt" -o -z "$FSNAME" ]; then
682 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
686 echo "Starting client: $client: $OPTIONS $device $mnt"
687 do_node $client mkdir -p $mnt
688 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
690 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
691 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
692 lctl set_param debug_mb=${DEBUG_SIZE}"
705 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
706 if [ $running -ne 0 ]; then
707 echo "Stopping client $client $mnt (opts:$force)"
708 do_node $client lsof -t $mnt || need_kill=no
709 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
710 pids=$(do_node $client lsof -t $mnt | sort -u);
711 if [ -n $pids ]; then
712 do_node $client kill -9 $pids || true
716 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
717 if [ $busy -ne 0 ] ; then
718 echo "$mnt is still busy, wait one second" && sleep 1
719 do_node $client umount $force $mnt
724 # nodes is comma list
725 sanity_mount_check_nodes () {
731 # FIXME: assume that all cluster nodes run the same os
732 [ "$(uname)" = Linux ] || return 0
735 for mnt in $mnts ; do
736 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
737 mpts=\\\$(mount | grep -w -c $mnt);
738 if [ \\\$running -ne \\\$mpts ]; then
739 echo \\\$(hostname) env are INSANE!;
747 sanity_mount_check_servers () {
749 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
750 echo Checking servers environments
752 # FIXME: modify get_facets to display all facets wo params
753 local facets="$(get_facets OST),$(get_facets MDS),mgs"
757 for facet in ${facets//,/ }; do
758 node=$(facet_host ${facet})
759 mnt=${MOUNT%/*}/${facet}
760 sanity_mount_check_nodes $node $mnt ||
761 { error "server $node environments are insane!"; return 1; }
765 sanity_mount_check_clients () {
766 local clients=${1:-$CLIENTS}
767 local mntpt=${2:-$MOUNT}
768 local mntpt2=${3:-$MOUNT2}
770 [ -z $clients ] && clients=$(hostname)
771 echo Checking clients $clients environments
773 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
774 error "clients environments are insane!"
777 sanity_mount_check () {
778 sanity_mount_check_servers || return 1
779 sanity_mount_check_clients || return 2
782 # mount clients if not mouted
783 zconf_mount_clients() {
786 local OPTIONS=${3:-$MOUNTOPT}
788 # Only supply -o to mount if we have options
789 if [ "$OPTIONS" ]; then
790 OPTIONS="-o $OPTIONS"
792 local device=$MGSNID:/$FSNAME
793 if [ -z "$mnt" -o -z "$FSNAME" ]; then
794 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
798 echo "Starting client $clients: $OPTIONS $device $mnt"
801 running=\\\$(mount | grep -c $mnt' ');
803 if [ \\\$running -eq 0 ] ; then
805 mount -t lustre $OPTIONS $device $mnt;
808 exit \\\$rc" || return ${PIPESTATUS[0]}
810 echo "Started clients $clients: "
811 do_nodes $clients "mount | grep -w $mnt"
813 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
814 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
815 lctl set_param debug_mb=${DEBUG_SIZE};"
820 zconf_umount_clients() {
827 echo "Stopping clients: $clients $mnt (opts:$force)"
828 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
829 if [ \\\$running -ne 0 ] ; then
830 echo Stopping client \\\$(hostname) $mnt opts:$force;
831 lsof -t $mnt || need_kill=no;
832 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
833 pids=\\\$(lsof -t $mnt | sort -u);
834 if [ -n \\\"\\\$pids\\\" ]; then
838 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
839 if [ \\\$busy -ne 0 ] ; then
840 echo "$mnt is still busy, wait one second" && sleep 1;
846 shudown_node_hard () {
850 for i in $(seq $attempts) ; do
853 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
854 echo "waiting for $host to fail attempts=$attempts"
855 [ $i -lt $attempts ] || \
856 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
862 local mnt=${2:-$MOUNT}
865 if [ "$FAILURE_MODE" = HARD ]; then
866 shudown_node_hard $client
868 zconf_umount_clients $client $mnt -f
874 if [ "$FAILURE_MODE" = HARD ]; then
875 shudown_node_hard $(facet_active_host $facet)
876 elif [ "$FAILURE_MODE" = SOFT ]; then
883 if [ "$FAILURE_MODE" = HARD ]; then
884 $POWER_UP `facet_active_host $facet`
892 if [ "$FAILURE_MODE" = HARD ]; then
898 # recovery-scale functions
899 check_progs_installed () {
904 do_nodes $clients "PATH=:$PATH; status=true;
905 for prog in $progs; do
906 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
907 echo \\\$prog missing on \\\$(hostname);
915 echo __$(echo $1 | tr '-' 'X')
918 start_client_load() {
921 local var=$(client_var_name $client)_load
922 eval export ${var}=$load
924 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
925 BREAK_ON_ERROR=$BREAK_ON_ERROR \
926 END_RUN_FILE=$END_RUN_FILE \
927 LOAD_PID_FILE=$LOAD_PID_FILE \
928 TESTSUITELOG=$TESTSUITELOG \
930 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
931 log "Started client load: ${load} on $client"
936 start_client_loads () {
937 local -a clients=(${1//,/ })
938 local numloads=${#CLIENT_LOADS[@]}
941 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
942 testnum=$((nodenum % numloads))
943 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
945 # bug 22169: wait the background threads to start
949 # only for remote client
950 check_client_load () {
952 local var=$(client_var_name $client)_load
953 local TESTLOAD=run_${!var}.sh
955 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
957 # bug 18914: try to connect several times not only when
958 # check ps, but while check_catastrophe also
961 while [ $RC = 254 -a $tries -gt 0 ]; do
965 if ! check_catastrophe $client; then
967 if [ $RC -eq 254 ]; then
968 # FIXME: not sure how long we shuold sleep here
972 echo "check catastrophe failed: RC=$RC "
976 # We can continue try to connect if RC=254
977 # Just print the warning about this
978 if [ $RC = 254 ]; then
979 echo "got a return status of $RC from do_node while checking catastrophe on $client"
982 # see if the load is still on the client
985 while [ $RC = 254 -a $tries -gt 0 ]; do
989 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
994 if [ $RC = 254 ]; then
995 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
996 # see if we can diagnose a bit why this is
1001 check_client_loads () {
1002 local clients=${1//,/ }
1006 for client in $clients; do
1007 check_client_load $client
1009 if [ "$rc" != 0 ]; then
1010 log "Client load failed on node $client, rc=$rc"
1016 restart_client_loads () {
1017 local clients=${1//,/ }
1018 local expectedfail=${2:-""}
1022 for client in $clients; do
1023 check_client_load $client
1025 if [ "$rc" != 0 -a "$expectedfail" ]; then
1026 local var=$(client_var_name $client)_load
1027 start_client_load $client ${!var}
1028 echo "Restarted client load ${!var}: on $client. Checking ..."
1029 check_client_load $client
1031 if [ "$rc" != 0 ]; then
1032 log "Client load failed to restart on node $client, rc=$rc"
1033 # failure one client load means test fail
1034 # we do not need to check other
1042 # End recovery-scale functions
1044 # verify that lustre actually cleaned up properly
1046 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1047 error "LBUG/LASSERT detected"
1048 BUSY=`dmesg | grep -i destruct || true`
1049 if [ "$BUSY" ]; then
1051 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1055 check_mem_leak || exit 204
1057 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1058 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1060 if module_loaded lnet || module_loaded libcfs; then
1061 echo "$0: modules still loaded..." 1>&2
1078 RESULT=$(do_node $node "$TEST")
1079 if [ "$RESULT" == "$FINAL" ]; then
1080 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1083 [ $WAIT -ge $MAX ] && break
1084 echo "Waiting $((MAX - WAIT)) secs for update"
1085 WAIT=$((WAIT + sleep))
1088 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1092 wait_update_facet () {
1094 wait_update $(facet_active_host $facet) "$@"
1097 wait_delete_completed () {
1098 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1099 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1103 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1105 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1106 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1107 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1108 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1112 echo "Delete is not completed in $MAX_WAIT sec"
1118 check_network "$host" 900
1119 while ! do_node $host hostname > /dev/null; do sleep 5; done
1124 local host=`facet_active_host $facet`
1128 wait_recovery_complete () {
1131 # Use default policy if $2 is not passed by caller.
1132 local MAX=${2:-$(max_recovery_time)}
1134 local var_svc=${facet}_svc
1135 local procfile="*.${!var_svc}.recovery_status"
1139 while [ $WAIT -lt $MAX ]; do
1140 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1141 [[ $STATUS = "status: COMPLETE" ]] && return 0
1144 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1146 echo "$facet recovery not done in $MAX sec. $STATUS"
1150 wait_mds_ost_sync () {
1151 # just because recovery is done doesn't mean we've finished
1152 # orphan cleanup. Wait for llogs to get synchronized.
1153 echo "Waiting for orphan cleanup..."
1154 # MAX value includes time needed for MDS-OST reconnection
1155 local MAX=$(( TIMEOUT * 2 ))
1157 while [ $WAIT -lt $MAX ]; do
1158 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1159 "$LCTL get_param -n obdfilter.*.mds_sync"))
1161 for ((i=0; i<${#sync[@]}; i++)); do
1162 [ ${sync[$i]} -eq 0 ] && continue
1163 # there is a not finished MDS-OST synchronization
1167 sleep 2 # increase waiting time and cover statfs cache
1168 [ ${con} -eq 1 ] && return 0
1169 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1172 echo "$facet recovery not done in $MAX sec. $STATUS"
1176 wait_destroy_complete () {
1177 echo "Waiting for destroy to be done..."
1178 # MAX value shouldn't be big as this mean server responsiveness
1179 # never increase this just to make test pass but investigate
1180 # why it takes so long time
1183 while [ $WAIT -lt $MAX ]; do
1184 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1186 for ((i=0; i<${#RPCs[@]}; i++)); do
1187 [ ${RPCs[$i]} -eq 0 ] && continue
1188 # there are still some destroy RPCs in flight
1193 [ ${con} -eq 1 ] && return 0 # done waiting
1194 echo "Waiting $WAIT secs for destroys to be done."
1197 echo "Destroys weren't done in $MAX sec."
1207 # conf-sanity 31 takes a long time cleanup
1208 while [ $WAIT -lt 300 ]; do
1209 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1210 [ -z "${running}" ] && return 0
1211 echo "waited $WAIT for${running}"
1212 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1214 WAIT=$((WAIT + INTERVAL))
1216 echo "service didn't stop after $WAIT seconds. Still running:"
1221 wait_remote_prog () {
1227 [ "$PDSH" = "no_dsh" ] && return 0
1229 while [ $WAIT -lt $2 ]; do
1230 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1231 [ -z "${running}" ] && return 0 || true
1232 echo "waited $WAIT for: "
1234 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1236 WAIT=$((WAIT + INTERVAL))
1238 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1239 [ -z "$pids" ] && return 0
1240 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1241 # FIXME: not portable
1242 for pid in $pids; do
1243 cat /proc/${pid}/status || true
1244 cat /proc/${pid}/wchan || true
1246 kill -9 $pid || true
1255 # not every config has many clients
1257 if [ ! -z "$CLIENTS" ]; then
1258 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1260 stat -f $MOUNT > /dev/null
1266 # usually checked on particular client or locally
1268 if [ ! -z "$client" ]; then
1269 $PDSH $client "stat -f $MOUNT" > /dev/null
1271 stat -f $MOUNT > /dev/null
1279 client_reconnect() {
1280 uname -n >> $MOUNT/recon
1281 if [ -z "$CLIENTS" ]; then
1282 df $MOUNT; uname -n >> $MOUNT/recon
1284 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1286 echo Connected clients:
1288 ls -l $MOUNT/recon > /dev/null
1295 echo "Failing $facet on node `facet_active_host $facet`"
1296 shutdown_facet $facet
1297 [ -n "$sleep_time" ] && sleep $sleep_time
1299 change_active $facet
1300 local TO=`facet_active_host $facet`
1301 echo "Failover $facet to $TO"
1303 mount_facet $facet || error "Restart of $facet failed"
1312 do_facet $facet sync
1314 local svc=${facet}_svc
1315 do_facet $facet $LCTL --device %${!svc} notransno
1316 do_facet $facet $LCTL --device %${!svc} readonly
1317 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1318 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1321 replay_barrier_nodf() {
1322 local facet=$1 echo running=${running}
1323 do_facet $facet sync
1324 local svc=${facet}_svc
1325 echo Replay barrier on ${!svc}
1326 do_facet $facet $LCTL --device %${!svc} notransno
1327 do_facet $facet $LCTL --device %${!svc} readonly
1328 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1329 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1332 replay_barrier_nosync() {
1333 local facet=$1 echo running=${running}
1334 local svc=${facet}_svc
1335 echo Replay barrier on ${!svc}
1336 do_facet $facet $LCTL --device %${!svc} notransno
1337 do_facet $facet $LCTL --device %${!svc} readonly
1338 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1339 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1342 mds_evict_client() {
1343 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1344 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1347 ost_evict_client() {
1348 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1349 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1353 facet_failover $* || error "failover: $?"
1354 clients_up || error "post-failover df: $?"
1359 facet_failover $facet
1365 change_active $facet
1366 mount_facet $facet -o abort_recovery
1367 clients_up || echo "first df failed: $?"
1368 clients_up || error "post-failover df: $?"
1372 echo There is no lmc. This is mountconf, baby.
1377 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1378 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1384 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1390 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1391 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1392 if [ -z "$ID" ]; then
1393 echo "Could not get a ptl id for $1..."
1402 h2name_or_ip "$1" "tcp"
1407 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1408 if type __h2elan >/dev/null 2>&1; then
1411 ID=`echo $1 | sed 's/[^0-9]*//g'`
1419 h2name_or_ip "$1" "openib"
1421 declare -fx h2openib
1424 h2name_or_ip "$1" "o2ib"
1431 [ "$facet" == client ] && echo -n $HOSTNAME && return
1432 varname=${facet}_HOST
1433 if [ -z "${!varname}" ]; then
1434 if [ "${facet:0:3}" == "ost" ]; then
1435 eval ${facet}_HOST=${ost_HOST}
1443 local activevar=${facet}active
1445 if [ -f $TMP/${facet}active ] ; then
1446 source $TMP/${facet}active
1449 active=${!activevar}
1450 if [ -z "$active" ] ; then
1457 facet_active_host() {
1459 local active=`facet_active $facet`
1460 if [ "$facet" == client ]; then
1463 echo `facet_host $active`
1469 local failover=${facet}failover
1470 host=`facet_host $failover`
1471 [ -z "$host" ] && return
1472 local curactive=`facet_active $facet`
1473 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1474 eval export ${facet}active=$facet
1476 eval export ${facet}active=$failover
1478 # save the active host for this facet
1479 local activevar=${facet}active
1480 echo "$activevar=${!activevar}" > $TMP/$activevar
1485 # do not stripe off hostname if verbose, bug 19215
1486 if [ x$1 = x--verbose ]; then
1494 if [ "$HOST" = "$HOSTNAME" ]; then
1496 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1497 echo "cannot run remote command on $HOST with $myPDSH"
1501 echo "CMD: $HOST $@" >&2
1502 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1505 if [ "$myPDSH" = "rsh" ]; then
1506 # we need this because rsh does not return exit code of an executed command
1507 local command_status="$TMP/cs"
1508 rsh $HOST ":> $command_status"
1509 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1510 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1511 echo command failed >$command_status"
1512 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1517 # print HOSTNAME for myPDSH="no_dsh"
1518 if [[ $myPDSH = no_dsh ]]; then
1519 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1521 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1524 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1526 return ${PIPESTATUS[0]}
1530 do_node --verbose "$@"
1533 single_local_node () {
1534 [ "$1" = "$HOSTNAME" ]
1537 # Outputs environment variable assignments that should be passed to remote nodes
1542 for var in ${!MODOPTS_*}; do
1544 echo "${var}=\"$value\""
1550 # do not stripe off hostname if verbose, bug 19215
1551 if [ x$1 = x--verbose ]; then
1559 if single_local_node $rnodes; then
1561 do_nodev $rnodes "$@"
1563 do_node $rnodes "$@"
1568 # This is part from do_node
1571 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1572 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1575 echo "CMD: $rnodes $@" >&2
1576 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1580 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1582 $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"
1584 return ${PIPESTATUS[0]}
1590 local HOST=`facet_active_host $facet`
1591 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1596 do_nodes --verbose "$@"
1602 # make sure its not already running
1604 rm -f $TMP/${facet}active
1605 do_facet ${facet} $MKFS $*
1611 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1612 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1619 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1620 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1628 # make sure we are using the primary server, so test-framework will
1629 # be able to clean up properly.
1630 activemds=`facet_active mds1`
1631 if [ $activemds != "mds1" ]; then
1635 local clients=$CLIENTS
1636 [ -z $clients ] && clients=$(hostname)
1638 zconf_umount_clients $clients $MOUNT "$*" || true
1639 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1641 [ "$CLIENTONLY" ] && return
1642 # The add fn does rm ${facet}active file, this would be enough
1643 # if we use do_facet <facet> only after the facet added, but
1644 # currently we use do_facet mds in local.sh
1645 for num in `seq $MDSCOUNT`; do
1647 rm -f ${TMP}/mds${num}active
1650 for num in `seq $OSTCOUNT`; do
1652 rm -f $TMP/ost${num}active
1655 if ! combined_mgs_mds ; then
1663 nfs_client_mode && return
1673 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1676 combined_mgs_mds () {
1677 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1681 if [ "$IAMDIR" == "yes" ]; then
1682 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1683 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1686 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1689 # We need ldiskfs here, may as well load them all
1691 [ "$CLIENTONLY" ] && return
1692 echo Formatting mgs, mds, osts
1693 if ! combined_mgs_mds ; then
1694 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1697 for num in `seq $MDSCOUNT`; do
1698 echo "Format mds$num: $(mdsdevname $num)"
1700 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1702 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1706 for num in `seq $OSTCOUNT`; do
1707 echo "Format ost$num: $(ostdevname $num)"
1709 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1711 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1717 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1721 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1725 # 0: success, the old identity set already.
1726 # 1: success, the old identity does not set.
1731 local j=`expr $num - 1`
1732 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1734 if [ -z "$MDT" ]; then
1738 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1741 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1743 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1746 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1748 if [ $old = "NONE" ]; then
1757 zconf_umount `hostname` $1 || error "umount failed"
1758 zconf_mount `hostname` $1 || error "mount failed"
1761 writeconf_facet () {
1765 do_facet $facet "$TUNEFS --writeconf $dev"
1769 for num in `seq $MDSCOUNT`; do
1770 DEVNAME=$(mdsdevname $num)
1771 writeconf_facet mds$num $DEVNAME
1774 for num in `seq $OSTCOUNT`; do
1775 DEVNAME=$(ostdevname $num)
1776 writeconf_facet ost$num $DEVNAME
1781 nfs_client_mode && return
1783 sanity_mount_check ||
1784 error "environments are insane!"
1788 if [ -z "$CLIENTONLY" ]; then
1789 echo Setup mgs, mdt, osts
1790 echo $WRITECONF | grep -q "writeconf" && \
1792 if ! combined_mgs_mds ; then
1793 start mgs $MGSDEV $mgs_MOUNT_OPTS
1796 for num in `seq $MDSCOUNT`; do
1797 DEVNAME=$(mdsdevname $num)
1798 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1800 # We started mds, now we should set failover variables properly.
1801 # Set mds${num}failover_HOST if it is not set (the default failnode).
1802 local varname=mds${num}failover_HOST
1803 if [ -z "${!varname}" ]; then
1804 eval mds${num}failover_HOST=$(facet_host mds$num)
1807 if [ $IDENTITY_UPCALL != "default" ]; then
1808 switch_identity $num $IDENTITY_UPCALL
1811 for num in `seq $OSTCOUNT`; do
1812 DEVNAME=$(ostdevname $num)
1813 start ost$num $DEVNAME $OST_MOUNT_OPTS
1815 # We started ost$num, now we should set ost${num}failover variable properly.
1816 # Set ost${num}failover_HOST if it is not set (the default failnode).
1817 varname=ost${num}failover_HOST
1818 if [ -z "${!varname}" ]; then
1819 eval ost${num}failover_HOST=$(facet_host ost${num})
1827 # wait a while to allow sptlrpc configuration be propogated to targets,
1828 # only needed when mounting new target devices.
1833 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1835 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1837 if [ "$MOUNT_2" ]; then
1838 mount_client $MOUNT2
1839 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1844 # by remounting mdt before ost, initial connect from mdt to ost might
1845 # timeout because ost is not ready yet. wait some time to its fully
1846 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1847 # by a context negotiation rpc with $TIMEOUT.
1848 # FIXME better by monitoring import status.
1851 sleep $((TIMEOUT + 5))
1857 mounted_lustre_filesystems() {
1858 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1861 init_facet_vars () {
1862 [ "$CLIENTONLY" ] && return 0
1869 eval export ${facet}_dev=${device}
1870 eval export ${facet}_opt=\"$@\"
1872 local dev=${facet}_dev
1873 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1874 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1876 eval export ${facet}_svc=${label}
1878 local varname=${facet}failover_HOST
1879 if [ -z "${!varname}" ]; then
1880 eval $varname=$(facet_host $facet)
1883 # ${facet}failover_dev is set in cfg file
1884 varname=${facet}failover_dev
1885 if [ -n "${!varname}" ] ; then
1886 eval export ${facet}failover_dev=${!varname}
1888 eval export ${facet}failover_dev=$device
1892 init_facets_vars () {
1895 if ! remote_mds_nodsh; then
1896 for num in `seq $MDSCOUNT`; do
1897 DEVNAME=`mdsdevname $num`
1898 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1902 remote_ost_nodsh && return
1904 for num in `seq $OSTCOUNT`; do
1905 DEVNAME=`ostdevname $num`
1906 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1910 osc_ensure_active () {
1916 while [ $period -lt $timeout ]; do
1917 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1918 if [ $count -eq 0 ]; then
1922 echo "There are $count OST are inactive, wait $period seconds, and try again"
1924 period=$((period+3))
1927 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1930 init_param_vars () {
1931 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1932 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1933 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1934 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1938 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1940 log "Using TIMEOUT=$TIMEOUT"
1942 osc_ensure_active $SINGLEMDS M $TIMEOUT
1943 osc_ensure_active client c $TIMEOUT
1945 if [ $QUOTA_AUTO -ne 0 ]; then
1946 if [ "$ENABLE_QUOTA" ]; then
1947 echo "enable quota as required"
1948 setup_quota $MOUNT || return 2
1950 echo "disable quota as required"
1951 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1958 nfs_client_mode () {
1959 if [ "$NFSCLIENT" ]; then
1960 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1961 local clients=$CLIENTS
1962 [ -z $clients ] && clients=$(hostname)
1964 # FIXME: remove hostname when 19215 fixed
1965 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1966 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1967 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1973 check_config_client () {
1976 local mounted=$(mount | grep " $mntpt ")
1977 if [ "$CLIENTONLY" ]; then
1979 # CLIENTONLY should not depend on *_HOST settings
1980 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1981 # in theory someone could create a new,
1982 # client-only config file that assumed lustre was already
1983 # configured and didn't set the MGSNID. If MGSNID is not set,
1984 # then we should use the mgs nid currently being used
1985 # as the default value. bug 18021
1986 [[ x$MGSNID = x ]] &&
1989 if [[ x$mgc != xMGC$MGSNID ]]; then
1990 if [ "$mgs_HOST" ]; then
1991 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1992 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1993 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1999 local myMGS_host=$mgs_HOST
2000 if [ "$NETTYPE" = "ptl" ]; then
2001 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2004 echo Checking config lustre mounted on $mntpt
2005 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2006 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2008 # if [ "$mgshost" != "$myMGS_host" ]; then
2009 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2010 # Please use correct config or set mds_HOST correctly!"
2015 check_config_clients () {
2016 local clients=${CLIENTS:-$HOSTNAME}
2019 nfs_client_mode && return
2021 do_rpc_nodes $clients check_config_client $mntpt
2023 sanity_mount_check ||
2024 error "environments are insane!"
2028 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2029 local cltimeout=$(lctl get_param -n timeout)
2030 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2031 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2038 local mounted=$(mounted_lustre_filesystems)
2040 echo $mounted' ' | grep -w -q $mntpt' '
2043 check_and_setup_lustre() {
2044 nfs_client_mode && return
2046 local MOUNTED=$(mounted_lustre_filesystems)
2050 # both MOUNT and MOUNT2 are not mounted
2051 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2052 [ "$REFORMAT" ] && formatall
2053 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2055 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2056 export I_MOUNTED=yes
2060 elif is_mounted $MOUNT2; then
2062 # MOUNT2 is mounted, while MOUNT_2 is not set
2063 if ! [ "$MOUNT_2" ]; then
2064 cleanup_mount $MOUNT2
2065 export I_UMOUNTED2=yes
2068 # MOUNT2 is mounted, MOUNT_2 is set
2070 # FIXME: what to do if check_config failed?
2072 # 1) remote client has mounted other Lustre fs ?
2073 # 2) it has insane env ?
2074 # let's try umount MOUNT2 on all clients and mount it again:
2075 if ! check_config_clients $MOUNT2; then
2076 cleanup_mount $MOUNT2
2077 restore_mount $MOUNT2
2078 export I_MOUNTED2=yes
2083 # MOUNT is mounted MOUNT2 is not mounted
2084 elif [ "$MOUNT_2" ]; then
2085 restore_mount $MOUNT2
2086 export I_MOUNTED2=yes
2090 # FIXME: what to do if check_config failed?
2092 # 1) remote client has mounted other Lustre fs?
2093 # 2) lustre is mounted on remote_clients atall ?
2094 check_config_clients $MOUNT
2098 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2099 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2100 lctl set_param debug_mb=${DEBUG_SIZE};
2107 if [ "$ONLY" == "setup" ]; then
2113 local clients=${CLIENTS:-$HOSTNAME}
2116 zconf_mount_clients $clients $mntpt
2120 local clients=${CLIENTS:-$HOSTNAME}
2123 zconf_umount_clients $clients $mntpt
2126 cleanup_and_setup_lustre() {
2127 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2128 lctl set_param debug=0 || true
2130 if [ "$ONLY" == "cleanup" ]; then
2134 check_and_setup_lustre
2137 check_and_cleanup_lustre() {
2138 if is_mounted $MOUNT; then
2139 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2140 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2143 if [ "$I_UMOUNTED2" = "yes" ]; then
2144 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2147 if [ "$I_MOUNTED2" = "yes" ]; then
2148 cleanup_mount $MOUNT2
2151 if [ "$I_MOUNTED" = "yes" ]; then
2152 cleanupall -f || error "cleanup failed"
2164 while [ $NETWORK -eq 0 ]; do
2165 if ping -c 1 -w 3 $1 > /dev/null; then
2169 echo "waiting for $1, $((MAX - WAIT)) secs left"
2172 if [ $WAIT -gt $MAX ]; then
2173 echo "Network not available"
2179 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2190 # the sed converts spaces to commas, but leaves the last space
2191 # alone, so the line doesn't end with a comma.
2192 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2195 # list, excluded are the comma separated lists
2196 exclude_items_from_list () {
2202 for item in ${excluded//,/ }; do
2203 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2205 echo $(comma_list $list)
2208 # list, expand are the comma separated lists
2210 local list=${1//,/ }
2211 local expand=${2//,/ }
2214 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2215 echo $(comma_list $expanded)
2218 testslist_filter () {
2219 local script=$LUSTRE/tests/${TESTSUITE}.sh
2221 [ -f $script ] || return 0
2223 local start_at=$START_AT
2224 local stop_at=$STOP_AT
2226 local var=${TESTSUITE//-/_}_START_AT
2227 [ x"${!var}" != x ] && start_at=${!var}
2228 var=${TESTSUITE//-/_}_STOP_AT
2229 [ x"${!var}" != x ] && stop_at=${!var}
2231 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2232 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2233 /^'${start_at}'$/ {flag = 0}
2234 {if (flag == 1) print $0}
2235 /^'${stop_at}'$/ { flag = 1 }'
2239 (cd `dirname $1`; echo $PWD/`basename $1`)
2243 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2244 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2247 local count=${type}COUNT
2248 for ((i=1; i<=${!count}; i++)) do
2249 list="$list ${name}$i"
2251 echo $(comma_list $list)
2254 ##################################
2255 # Adaptive Timeouts funcs
2258 # only check mds, we assume at_max is the same on all nodes
2259 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2260 if [ $at_max -eq 0 ]; then
2270 # suppose that all ost-s has the same at_max set
2271 if [ $facet == "ost" ]; then
2272 do_facet ost1 "lctl get_param -n at_max"
2274 do_facet $facet "lctl get_param -n at_max"
2284 if [ $facet == "ost" ]; then
2285 for i in `seq $OSTCOUNT`; do
2286 do_facet ost$i "lctl set_param at_max=$at_max"
2289 elif [ $facet == "mds" ]; then
2290 for i in `seq $MDSCOUNT`; do
2291 do_facet mds$i "lctl set_param at_max=$at_max"
2294 do_facet $facet "lctl set_param at_max=$at_max"
2299 ##################################
2303 # OBD_FAIL_MDS_ALL_REQUEST_NET
2305 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2306 do_facet client "$1" || RC=$?
2307 do_facet $SINGLEMDS lctl set_param fail_loc=0
2312 # OBD_FAIL_MDS_ALL_REPLY_NET
2314 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2315 do_facet client "$@" || RC=$?
2316 do_facet $SINGLEMDS lctl set_param fail_loc=0
2320 drop_reint_reply() {
2321 # OBD_FAIL_MDS_REINT_NET_REP
2323 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2324 do_facet client "$@" || RC=$?
2325 do_facet $SINGLEMDS lctl set_param fail_loc=0
2330 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2332 do_facet ost1 lctl set_param fail_loc=0x214
2333 do_facet client "$1" || RC=$?
2334 do_facet client "sync"
2335 do_facet ost1 lctl set_param fail_loc=0
2339 drop_ldlm_cancel() {
2340 #define OBD_FAIL_LDLM_CANCEL 0x304
2342 do_facet client lctl set_param fail_loc=0x304
2343 do_facet client "$@" || RC=$?
2344 do_facet client lctl set_param fail_loc=0
2348 drop_bl_callback() {
2349 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2351 do_facet client lctl set_param fail_loc=0x305
2352 do_facet client "$@" || RC=$?
2353 do_facet client lctl set_param fail_loc=0
2358 #define OBD_FAIL_LDLM_REPLY 0x30c
2360 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2361 do_facet client "$@" || RC=$?
2362 do_facet $SINGLEMDS lctl set_param fail_loc=0
2370 echo "clearing fail_loc on $facet"
2371 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2374 set_nodes_failloc () {
2375 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2378 cancel_lru_locks() {
2379 $LCTL mark "cancel_lru_locks $1 start"
2380 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2381 $LCTL set_param -n $d=clear
2383 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2384 $LCTL mark "cancel_lru_locks $1 stop"
2389 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2390 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2391 echo "$DEFAULT_LRU_SIZE"
2396 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2399 lru_resize_disable()
2401 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2406 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2407 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2408 echo there is still data in page cache $FILE ?
2409 lctl get_param -n $FILE
2417 DEBUGSAVE="$(lctl get_param -n debug)"
2421 [ -n "$DEBUGSAVE" ] && \
2422 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2427 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2430 debug_size_restore() {
2431 [ -n "$DEBUG_SIZE_SAVED" ] && \
2432 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2436 start_full_debug_logging() {
2441 local DEBUG_SIZE=150
2443 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2444 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2447 stop_full_debug_logging() {
2452 ##################################
2454 ##################################
2457 local TYPE=${TYPE:-"FAIL"}
2460 # do not dump logs if $1=false
2461 if [ "x$1" = "xfalse" ]; then
2466 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2468 # We need to dump the logs on all nodes
2470 gather_logs $(comma_list $(nodes_list))
2474 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2475 echo "$@" > $LOGDIR/err
2487 # use only if we are ignoring failures for this test, bugno required.
2488 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2489 # e.g. error_ignore 5494 "your message"
2491 local TYPE="IGNORE (bz$1)"
2497 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2502 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2503 [ "$TESTSUITELOG" ] && \
2504 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2507 build_test_filter() {
2508 EXCEPT="$EXCEPT $(testslist_filter)"
2510 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2514 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2515 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2516 [ "$EXCEPT_SLOW" ] && \
2517 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2518 for E in $EXCEPT $ALWAYS_EXCEPT; do
2519 eval EXCEPT_${E}=true
2521 for E in $EXCEPT_SLOW; do
2522 eval EXCEPT_SLOW_${E}=true
2524 for G in $GRANT_CHECK_LIST; do
2525 eval GCHECK_ONLY_${G}=true
2530 if [[ $1 = [a-z]* ]]; then
2537 # print a newline if the last test was skipped
2538 export LAST_SKIPPED=
2540 # Main entry into test-framework. This is called with the name and
2541 # description of a test. The name is used to find the function to run
2542 # the test using "test_$name".
2544 # This supports a variety of methods of specifying specific test to
2545 # run or not run. These need to be documented...
2550 export base=`basetest $1`
2551 if [ ! -z "$ONLY" ]; then
2553 if [ ${!testname}x != x ]; then
2554 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2555 run_one_logged $1 "$2"
2559 if [ ${!testname}x != x ]; then
2560 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2561 run_one_logged $1 "$2"
2569 if [ ${!testname}x != x ]; then
2571 TESTNAME=test_$1 skip "skipping excluded test $1"
2574 testname=EXCEPT_$base
2575 if [ ${!testname}x != x ]; then
2577 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2580 testname=EXCEPT_SLOW_$1
2581 if [ ${!testname}x != x ]; then
2583 TESTNAME=test_$1 skip "skipping SLOW test $1"
2586 testname=EXCEPT_SLOW_$base
2587 if [ ${!testname}x != x ]; then
2589 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2594 run_one_logged $1 "$2"
2605 module_loaded lnet || load_modules
2617 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2622 strace -o $TMP/$1.strace -ttt $*
2624 log "FINISHED: $*: rc $RC"
2629 # Set TEST_STATUS here; will be used for logging the result
2630 if [ -f $LOGDIR/err ]; then
2635 echo $TEST_STATUS " " $@
2639 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2640 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2641 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2645 echo -n "Resetting fail_loc on all nodes..."
2646 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2652 # Log a message (on all nodes) padded with "=" before and after.
2653 # Also appends a timestamp and prepends the testsuite name.
2656 EQUALS="===================================================================================================="
2658 msg="== ${TESTSUITE} $*"
2660 [[ $last != "=" && $last != " " ]] && msg="$msg "
2661 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
2662 # always include at least == after the message
2663 log "$msg== $(date +"%H:%M:%S (%s)")"
2667 # Run a single test function and cleanup after it.
2669 # This function should be run in a subshell so the test func can
2670 # exit() without stopping the whole script.
2676 export tdir=d0.${TESTSUITE}/d${base}
2677 export TESTNAME=test_$testnum
2678 local SAVE_UMASK=`umask`
2681 banner "test $testnum: $message"
2682 test_${testnum} || error "test_$testnum failed with $?"
2685 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2686 check_catastrophe || error "LBUG/LASSERT detected"
2687 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2695 # Wrapper around run_one to ensure:
2696 # - test runs in subshell
2697 # - output of test is saved to separate log file for error reporting
2698 # - test result is saved to data file
2701 local BEFORE=`date +%s`
2703 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
2704 local test_log=$LOGDIR/$name
2708 log_sub_test_begin test_${1}
2709 (run_one $1 "$2") 2>&1 | tee $test_log
2710 local RC=${PIPESTATUS[0]}
2712 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2713 echo "test_$1 returned $RC" | tee $LOGDIR/err
2715 duration=$((`date +%s` - $BEFORE))
2716 pass "(${duration}s)"
2717 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2718 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
2720 if [ -f $LOGDIR/err ]; then
2721 $FAIL_ON_ERROR && exit $RC
2728 (cd `dirname $1`; echo $PWD/`basename $1`)
2732 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2733 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2738 export base=`basetest $1`
2739 [ "$CHECK_GRANT" == "no" ] && return 0
2741 testname=GCHECK_ONLY_${base}
2742 [ ${!testname}x == x ] && return 0
2744 echo -n "checking grant......"
2746 # write some data to sync client lost_grant
2747 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2748 for i in `seq $OSTCOUNT`; do
2749 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2750 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2751 count=1 > /dev/null 2>&1
2753 # sync all the data and make sure no pending data on server
2756 #get client grant and server grant
2758 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2759 client_grant=$((client_grant + $d))
2762 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2763 server_grant=$((server_grant + $d))
2766 # cleanup the check_grant file
2767 for i in `seq $OSTCOUNT`; do
2768 rm $DIR1/${tfile}_check_grant_$i
2771 #check whether client grant == server grant
2772 if [ $client_grant != $server_grant ]; then
2773 echo "failed: client:${client_grant} server: ${server_grant}"
2780 ########################
2786 ost=`echo $1 | awk -F_ '{print $3}'`
2787 if [ -z $ost ]; then
2788 ost=`echo $1 | sed 's/-osc.*//'`
2795 [ "$node" != "$(hostname)" ]
2801 for node in $(mdts_nodes); do
2802 remote_node $node && return 0
2809 [ "$CLIENTONLY" ] && return 0 || true
2810 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2815 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
2816 MSKIPPED=1 && return 1
2823 for node in $(osts_nodes) ; do
2824 remote_node $node && return 0
2831 [ "$CLIENTONLY" ] && return 0 || true
2832 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2837 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
2838 OSKIPPED=1 && return 1
2845 MGS=$(facet_host mgs)
2846 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2851 remote_mds_nodsh || remote_ost_nodsh || \
2852 $(single_local_node $(comma_list $(nodes_list)))
2858 for num in `seq $MDSCOUNT`; do
2859 MDSNODES="$MDSNODES $(facet_host mds$num)"
2861 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2867 remote_ost && remote_mds
2871 local OSTNODES=$(facet_host ost1)
2874 for num in `seq $OSTCOUNT`; do
2875 local myOST=$(facet_host ost$num)
2876 OSTNODES="$OSTNODES $myOST"
2878 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2884 # FIXME. We need a list of clients
2885 local myNODES=$HOSTNAME
2888 # CLIENTS (if specified) contains the local client
2889 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2891 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2892 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2895 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2900 remote_nodes_list () {
2901 local rnodes=$(nodes_list)
2902 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2906 init_clients_lists () {
2907 # Sanity check: exclude the local client from RCLIENTS
2908 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2910 # Sanity check: exclude the dup entries
2911 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2913 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2915 # Sanity check: exclude the dup entries from CLIENTS
2916 # for those configs which has SINGLCLIENT set to local client
2917 clients=$(for i in $clients; do echo $i; done | sort -u)
2919 CLIENTS=`comma_list $clients`
2920 local -a remoteclients=($rclients)
2921 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2922 varname=CLIENT$((i + 2))
2923 eval $varname=${remoteclients[i]}
2926 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2929 get_random_entry () {
2932 rnodes=${rnodes//,/ }
2934 local -a nodes=($rnodes)
2935 local num=${#nodes[@]}
2936 local i=$((RANDOM * num * 2 / 65536))
2942 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2947 lctl get_param version | grep -q patchless
2951 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2956 echo $nodes | wc -w || true
2960 local nodes=$(osts_nodes)
2961 local osscount=$(get_node_count "$nodes")
2962 [ ! "$OSTCOUNT" = "$osscount" ]
2966 local nodes=$(mdts_nodes)
2967 local mdtcount=$(get_node_count "$nodes")
2968 [ ! "$MDSCOUNT" = "$mdtcount" ]
2971 generate_machine_file() {
2972 local nodes=${1//,/ }
2973 local machinefile=$2
2975 for node in $nodes; do
2976 echo $node >>$machinefile || \
2977 { echo "can not generate machinefile $machinefile" && return 1; }
2982 local file=$1/stripe
2984 $LFS getstripe -v $file || error
2988 setstripe_nfsserver () {
2991 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
2992 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
2994 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
2996 do_nodev $nfsserver lfs setstripe "$@"
2999 check_runas_id_ret() {
3001 local myRUNAS_UID=$1
3002 local myRUNAS_GID=$2
3005 if [ -z "$myRUNAS" ]; then
3006 error_exit "myRUNAS command must be specified for check_runas_id"
3009 $myRUNAS krb5_login.sh || \
3010 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3012 mkdir $DIR/d0_runas_test
3014 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3015 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3016 rm -rf $DIR/d0_runas_test
3021 local myRUNAS_UID=$1
3022 local myRUNAS_GID=$2
3025 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3026 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3027 Please set RUNAS_ID to some UID which exists on MDS and client or
3028 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3031 # obtain the UID/GID for MPI_USER
3035 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3036 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3038 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3039 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3042 # obtain and cache Kerberos ticket-granting ticket
3043 refresh_krb5_tgt() {
3044 local myRUNAS_UID=$1
3045 local myRUNAS_GID=$2
3048 if [ -z "$myRUNAS" ]; then
3049 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3052 CLIENTS=${CLIENTS:-$HOSTNAME}
3053 do_nodes $CLIENTS "set -x
3054 if ! $myRUNAS krb5_login.sh; then
3055 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3060 # Run multiop in the background, but wait for it to print
3061 # "PAUSING" to its stdout before returning from this function.
3062 multiop_bg_pause() {
3063 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3067 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3070 echo "$MULTIOP_PROG $FILE v$ARGS"
3071 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3073 echo "TMPPIPE=${TMPPIPE}"
3074 read -t 60 multiop_output < $TMPPIPE
3075 if [ $? -ne 0 ]; then
3080 if [ "$multiop_output" != "PAUSING" ]; then
3081 echo "Incorrect multiop output: $multiop_output"
3096 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3102 inodes_available () {
3103 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3107 mdsrate_inodes_available () {
3108 echo $(($(inodes_available) - 1))
3111 # reset llite stat counters
3112 clear_llite_stats(){
3113 lctl set_param -n llite.*.stats 0
3116 # sum llite stat items
3117 calc_llite_stats() {
3118 local res=$(lctl get_param -n llite.*.stats |
3119 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3123 # reset osc stat counters
3125 lctl set_param -n osc.*.osc_stats 0
3128 # sum osc stat items
3130 local res=$(lctl get_param -n osc.*.osc_stats |
3131 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3136 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3139 calc_osc_kbytes () {
3140 df $MOUNT > /dev/null
3141 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3144 # save_lustre_params(node, parameter_mask)
3145 # generate a stream of formatted strings (<node> <param name>=<param value>)
3146 save_lustre_params() {
3148 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3151 # restore lustre parameters from input stream, produces by save_lustre_params
3152 restore_lustre_params() {
3156 while IFS=" =" read node name val; do
3157 do_node ${node//:/} "lctl set_param -n $name $val"
3161 check_catastrophe() {
3162 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3163 local C=$CATASTROPHE
3164 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3166 if [ $rnodes ]; then
3167 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3168 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3184 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3186 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3187 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3188 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3192 # CMD: determine mds index where directory inode presents
3195 local file=$dir/f0.get_mds_dir_tmpfile
3200 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3201 local -a oldused=($iused)
3203 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3205 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3206 local -a newused=($iused)
3209 for ((i=0; i<${#newused[@]}; i++)); do
3210 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3216 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3219 mdsrate_cleanup () {
3221 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3226 delayed_recovery_enabled () {
3227 local var=${SINGLEMDS}_svc
3228 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3231 ########################
3233 convert_facet2label() {
3236 if [ x$facet = xost ]; then
3240 local varsvc=${facet}_svc
3242 if [ -n ${!varsvc} ]; then
3245 error "No lablel for $facet!"
3249 get_clientosc_proc_path() {
3255 get_lustre_version () {
3256 local node=${1:-"mds"}
3257 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3260 get_mds_version_major () {
3261 local version=$(get_lustre_version mds)
3262 echo $version | awk -F. '{print $1}'
3265 get_mds_version_minor () {
3266 local version=$(get_lustre_version mds)
3267 echo $version | awk -F. '{print $2}'
3270 get_mdtosc_proc_path() {
3272 local major=$(get_mds_version_major)
3273 local minor=$(get_mds_version_minor)
3274 if [ $major -le 1 -a $minor -le 8 ] ; then
3277 echo "${ost}-osc-MDT0000"
3281 get_osc_import_name() {
3284 local label=$(convert_facet2label $ost)
3286 if [ "$facet" == "mds" ]; then
3287 get_mdtosc_proc_path $label
3291 get_clientosc_proc_path $label
3295 wait_import_state () {
3301 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3302 while [ "${CONN_STATE}" != "${expected}" ]; do
3303 if [ "${expected}" == "DISCONN" ]; then
3304 # for disconn we can check after proc entry is removed
3305 [ "x${CONN_STATE}" == "x" ] && return 0
3306 # with AT we can have connect request timeout ~ reconnect timeout
3307 # and test can't see real disconnect
3308 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3310 # disconnect rpc should be wait not more obd_timeout
3311 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3312 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3314 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3318 log "$CONN_PROC now in ${CONN_STATE} state"
3322 wait_osc_import_state() {
3326 local ost=$(get_osc_import_name $facet $ost_facet)
3331 CONN_PROC="osc.${ost}.ost_server_uuid"
3332 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3333 while [ "${CONN_STATE}" != "${expected}" ]; do
3334 if [ "${expected}" == "DISCONN" ]; then
3335 # for disconn we can check after proc entry is removed
3336 [ "x${CONN_STATE}" == "x" ] && return 0
3337 # with AT we can have connect request timeout ~ reconnect timeout
3338 # and test can't see real disconnect
3339 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3341 # disconnect rpc should be wait not more obd_timeout
3342 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3343 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3345 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3349 log "${ost_facet} now in ${CONN_STATE} state"
3352 get_clientmdc_proc_path() {
3360 # Add paths to lustre tests for 32 and 64 bit systems.
3361 local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3362 do_nodesv $list "PATH=$RPATH sh rpc.sh $@ "
3365 wait_clients_import_state () {
3371 local label=$(convert_facet2label $facet)
3374 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3375 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3376 *) error "unknown facet!" ;;
3379 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3380 error "import is not in ${expected} state"
3389 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3390 $LCTL get_param obdfilter.*.kbytesavail))
3391 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3392 $LCTL get_param -n obdfilter.*.tot_granted))
3393 for ((i=0; i<${#AVAILA[@]}; i++)); do
3394 local -a AVAIL1=(${AVAILA[$i]//=/ })
3395 GRANT=$((${GRANTA[$i]}/1024))
3396 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3397 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3403 do_facet mgs lctl pool_list $1
3407 local fsname=${1%%.*}
3408 local poolname=${1##$fsname.}
3410 do_facet mgs lctl pool_new $1
3412 # get param should return err unless pool is created
3413 [[ $RC -ne 0 ]] && return $RC
3415 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3416 2>/dev/null || echo foo" "" || RC=1
3417 if [[ $RC -eq 0 ]]; then
3420 error "pool_new failed $1"
3425 add_pool_to_list () {
3426 local fsname=${1%%.*}
3427 local poolname=${1##$fsname.}
3429 local listvar=${fsname}_CREATED_POOLS
3430 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3433 remove_pool_from_list () {
3434 local fsname=${1%%.*}
3435 local poolname=${1##$fsname.}
3437 local listvar=${fsname}_CREATED_POOLS
3438 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3441 destroy_pool_int() {
3443 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3444 awk '$1 !~ /^Pool:/ {print $1}')
3445 for ost in $OSTS; do
3446 do_facet mgs lctl pool_remove $1 $ost
3448 do_facet mgs lctl pool_destroy $1
3451 # <fsname>.<poolname> or <poolname>
3453 local fsname=${1%%.*}
3454 local poolname=${1##$fsname.}
3456 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3460 pool_list $fsname.$poolname || return $?
3462 destroy_pool_int $fsname.$poolname
3464 [[ $RC -ne 0 ]] && return $RC
3466 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3467 2>/dev/null || echo foo" "foo" || RC=1
3469 if [[ $RC -eq 0 ]]; then
3470 remove_pool_from_list $fsname.$poolname
3472 error "destroy pool failed $1"
3478 local fsname=${1:-$FSNAME}
3480 local listvar=${fsname}_CREATED_POOLS
3484 [ x${!listvar} = x ] && return 0
3486 echo destroy the created pools: ${!listvar}
3487 for poolname in ${!listvar//,/ }; do
3488 destroy_pool $fsname.$poolname
3493 local fsname=${1:-$FSNAME}
3495 destroy_pools $fsname
3501 local ts=$(date +%s)
3503 # bug 20237, comment 11
3504 # It would also be useful to provide the option
3505 # of writing the file to an NFS directory so it doesn't need to be copied.
3508 [ -f $LOGDIR/shared ] && docp=false
3510 # dump lustre logs, dmesg
3512 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3514 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3516 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3517 echo "Dumping logs only on local client."
3518 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3519 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3524 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3525 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3526 if [ ! -f $LOGDIR/shared ]; then
3527 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3530 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3531 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3537 local list=${1:-$(comma_list $(nodes_list))}
3539 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3551 for i in $(seq 0 $num_mntpts); do
3552 cmd="ls -laf ${mntpt_root}$i/$dir"
3558 for pid in $pids; do
3565 # target_start_and_reset_recovery_timer()
3566 # service_time = at_est2timeout(service_time);
3567 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3568 # INITIAL_CONNECT_TIMEOUT);
3569 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3570 #define CONNECTION_SWITCH_INC 1
3571 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3572 #define CONNECTION_SWITCH_MIN 5U
3574 max_recovery_time () {
3575 local init_connect_timeout=$(( TIMEOUT / 20 ))
3576 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
3578 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
3583 get_clients_mount_count () {
3584 local clients=${CLIENTS:-`hostname`}
3586 # we need to take into account the clients mounts and
3587 # exclude mds/ost mounts if any;
3588 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
3592 PROC_CLI="srpc_info"
3600 if [ $M -lt $N ]; then
3604 while [ $N -le $M ]; do
3614 calc_connection_cnt() {
3617 # MDT->MDT = 2 * C(M, 2)
3621 comb_m2=$(combination $MDSCOUNT 2)
3623 local num_clients=$(get_clients_mount_count)
3625 local cnt_mdt2mdt=$((comb_m2 * 2))
3626 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
3627 local cnt_cli2ost=$((num_clients * OSTCOUNT))
3628 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
3629 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
3630 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
3631 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
3645 local cmd="$tgt.srpc.flavor"
3647 if [ $net == "any" ]; then
3652 if [ $dir != "any" ]; then
3657 log "Setting sptlrpc rule: $cmd"
3658 do_facet mgs "$LCTL conf_param $cmd"
3667 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
3668 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
3670 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
3672 if [ "x$bulkspec" != "x" ]; then
3673 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
3675 if [ "x$algs" != "x" ]; then
3676 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
3678 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
3679 if [ $bulk == "bulkn" ]; then
3680 bulk_count=`echo "$output" | grep "bulk flavor" \
3681 | grep "null/null" | wc -l`
3682 elif [ $bulk == "bulki" ]; then
3683 bulk_count=`echo "$output" | grep "bulk flavor" \
3684 | grep "/null" | grep -v "null/" | wc -l`
3686 bulk_count=`echo "$output" | grep "bulk flavor" \
3687 | grep -v "/null" | grep -v "null/" | wc -l`
3691 [ $bulk_count -lt $count ] && count=$bulk_count
3702 local clients=${CLIENTS:-`hostname`}
3704 for c in ${clients//,/ }; do
3705 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
3706 tmpcnt=`count_flvr "$output" $flavor`
3707 cnt=$((cnt + tmpcnt))
3717 local clients=${CLIENTS:-`hostname`}
3719 for c in ${clients//,/ }; do
3720 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
3721 tmpcnt=`count_flvr "$output" $flavor`
3722 cnt=$((cnt + tmpcnt))
3732 if [ $MDSCOUNT -le 1 ]; then
3737 for num in `seq $MDSCOUNT`; do
3738 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
3739 tmpcnt=`count_flvr "$output" $flavor`
3740 cnt=$((cnt + tmpcnt))
3750 for num in `seq $MDSCOUNT`; do
3751 output=`do_facet mds$num lctl get_param -n osc.*OST*-osc-MDT*.$PROC_CLI 2>/dev/null`
3752 tmpcnt=`count_flvr "$output" $flavor`
3753 cnt=$((cnt + tmpcnt))
3762 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
3763 count_flvr "$output" $flavor
3768 local dir=$1 # from to
3769 local flavor=$2 # flavor expected
3772 if [ $dir == "cli2mdt" ]; then
3773 res=`flvr_cnt_cli2mdt $flavor`
3774 elif [ $dir == "cli2ost" ]; then
3775 res=`flvr_cnt_cli2ost $flavor`
3776 elif [ $dir == "mdt2mdt" ]; then
3777 res=`flvr_cnt_mdt2mdt $flavor`
3778 elif [ $dir == "mdt2ost" ]; then
3779 res=`flvr_cnt_mdt2ost $flavor`
3780 elif [ $dir == "all2ost" ]; then
3781 res1=`flvr_cnt_mdt2ost $flavor`
3782 res2=`flvr_cnt_cli2ost $flavor`
3783 res=$((res1 + res2))
3784 elif [ $dir == "all2mdt" ]; then
3785 res1=`flvr_cnt_mdt2mdt $flavor`
3786 res2=`flvr_cnt_cli2mdt $flavor`
3787 res=$((res1 + res2))
3788 elif [ $dir == "all2all" ]; then
3789 res1=`flvr_cnt_mdt2ost $flavor`
3790 res2=`flvr_cnt_cli2ost $flavor`
3791 res3=`flvr_cnt_mdt2mdt $flavor`
3792 res4=`flvr_cnt_cli2mdt $flavor`
3793 res=$((res1 + res2 + res3 + res4))
3801 local dir=$1 # from to
3802 local flavor=$2 # flavor expected
3803 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
3807 for ((i=0;i<20;i++)); do
3808 echo -n "checking..."
3809 res=$(do_check_flavor $dir $flavor)
3810 if [ $res -eq $expect ]; then
3811 echo "found $res $flavor connections of $dir, OK"
3814 echo "found $res $flavor connections of $dir, not ready ($expect)"
3819 echo "Error checking $flavor of $dir: expect $expect, actual $res"
3823 restore_to_default_flavor()
3825 local proc="mgs.MGS.live.$FSNAME"
3827 echo "restoring to default flavor..."
3829 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3831 # remove all existing rules if any
3832 if [ $nrule -ne 0 ]; then
3833 echo "$nrule existing rules"
3834 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
3835 echo "remove rule: $rule"
3836 spec=`echo $rule | awk -F = '{print $1}'`
3837 do_facet mgs "$LCTL conf_param $spec="
3841 # verify no rules left
3842 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3843 [ $nrule -ne 0 ] && error "still $nrule rules left"
3845 # wait for default flavor to be applied
3846 # currently default flavor for all connections are 'null'
3847 wait_flavor all2all null
3848 echo "now at default flavor settings"
3853 local flavor=${1:-null}
3855 echo "setting all flavor to $flavor"
3857 # FIXME need parameter to this fn
3858 # and remove global vars
3859 local cnt_all2all=$(calc_connection_cnt all2all)
3861 local res=$(do_check_flavor all2all $flavor)
3862 if [ $res -eq $cnt_all2all ]; then
3863 echo "already have total $res $flavor connections"
3867 echo "found $res $flavor out of total $cnt_all2all connections"
3868 restore_to_default_flavor
3870 [[ $flavor = null ]] && return 0
3872 set_rule $FSNAME any any $flavor
3873 wait_flavor all2all $flavor
3879 # Checking for shared logdir
3880 if [ ! -d $dir ]; then
3881 # Not found. Create local logdir
3884 touch $dir/node.$(hostname).yml
3889 check_write_access() {
3891 for node in $(nodes_list); do
3892 if [ ! -f "$dir/node.${node}.yml" ]; then
3893 # Logdir not accessible/writable from this node.
3901 if [[ -n $YAML_LOG ]]; then
3904 export YAML_LOG=${LOGDIR}/results.yml
3908 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
3909 if check_write_access $LOGDIR; then
3910 touch $LOGDIR/shared
3911 echo "Logging to shared log directory: $LOGDIR"
3913 echo "Logging to local directory: $LOGDIR"
3916 yml_nodes_file $LOGDIR
3917 yml_results_file >> $YAML_LOG
3921 yml_log_test $1 >> $YAML_LOG
3924 log_sub_test_begin() {
3925 yml_log_sub_test_begin $@ >> $YAML_LOG
3928 log_sub_test_end() {
3929 yml_log_sub_test_end $@ >> $YAML_LOG
3935 local devname=$(basename $1)
3936 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
3937 # loop devices aren't in /proc/partitions
3938 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
3940 size=$(($size / 1024 / 1024)) # Gb
3942 local partial_arg=""
3943 # Run in partial (fast) mode if the size
3944 # of a partition > 10 GB
3945 [ $size -gt 10 ] && partial_arg="-p"
3947 llverdev --force $partial_arg $dev