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 if [[ -x $LUSTRE/utils/llobdstat ]]; then
38 LLOBDSTAT=$LUSTRE/utils/llobdstat
39 elif [[ -x /usr/bin/llobdstat ]]; then
40 LLOBDSTAT=/usr/bin/llobdstat
46 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
47 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
51 [[ $DIR/ = $MOUNT/* ]] || \
52 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
53 [[ $DIR1/ = $MOUNT1/* ]] || \
54 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
55 [[ $DIR2/ = $MOUNT2/* ]] || \
56 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
58 [ -n "$failed" ] && exit 99 || true
62 echo "usage: $0 [-r] [-f cfgfile]"
70 [ "$TESTSUITE" == "lfsck" ] && return 0
71 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
72 local form="%-13s %-17s %s\n"
73 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
74 echo "------------------------------------------------------------------------------------"
75 for O in $DEFAULT_SUITES; do
78 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
79 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
81 local log=${TMP}/${o}.log
82 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
83 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
84 [ "${!O}" = "done" ] && \
85 printf "$form" "Done" "$O" "E=$skipped" && \
86 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
90 for O in $DEFAULT_SUITES; do
91 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
92 if [ "${!O}" = "no" ]; then
94 # only for those tests suits which are run directly from acc-sm script:
95 # bonnie, iozone, etc.
96 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
97 printf "$form" "UNFINISHED" "$O" ""
99 printf "$form" "Skipped" "$O" ""
104 for O in $DEFAULT_SUITES; do
105 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
106 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
107 printf "$form" "UNFINISHED" "$O" ""
112 export LUSTRE=`absolute_path $LUSTRE`
113 export TESTSUITE=`basename $0 .sh`
114 export TEST_FAILED=false
115 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
117 export MKE2FS=${MKE2FS:-mke2fs}
118 export DEBUGFS=${DEBUGFS:-debugfs}
119 export TUNE2FS=${TUNE2FS:-tune2fs}
120 export E2LABEL=${E2LABEL:-e2label}
121 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
122 export E2FSCK=${E2FSCK:-e2fsck}
124 #[ -d /r ] && export ROOT=${ROOT:-/r}
125 export TMP=${TMP:-$ROOT/tmp}
126 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
127 if [[ -z $LOGDIRSET ]]; then
128 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
129 export LOGDIRSET=true
131 export HOSTNAME=${HOSTNAME:-`hostname`}
132 if ! echo $PATH | grep -q $LUSTRE/utils; then
133 export PATH=$PATH:$LUSTRE/utils
135 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
136 export PATH=$PATH:$LUSTRE/utils/gss
138 if ! echo $PATH | grep -q $LUSTRE/tests; then
139 export PATH=$PATH:$LUSTRE/tests
141 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
142 [ ! -f "$LST" ] && export LST=$(which lst)
143 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
144 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
145 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
146 export PATH=$LUSTRE/tests/racer:$PATH:
148 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
149 export PATH=$PATH:$LUSTRE/tests/mpi
151 export RSYNC_RSH=${RSYNC_RSH:-rsh}
152 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
153 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
154 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
155 [ ! -f "$LFS" ] && export LFS=$(which lfs)
156 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
157 if [ ! -f "$L_GETIDENTITY" ]; then
158 if `which l_getidentity > /dev/null 2>&1`; then
159 export L_GETIDENTITY=$(which l_getidentity)
161 export L_GETIDENTITY=NONE
164 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
165 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
166 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
167 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
168 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
169 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
170 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
171 export FSTYPE=${FSTYPE:-"ldiskfs"}
172 export NAME=${NAME:-local}
173 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
174 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
175 export LGSSD=$(which lgssd)
176 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
177 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
178 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
180 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
183 if [ "$ACCEPTOR_PORT" ]; then
184 export PORT_OPT="--port $ACCEPTOR_PORT"
189 echo "Using GSS/krb5 ptlrpc security flavor"
190 which lgss_keyring > /dev/null 2>&1 || \
191 error_exit "built with gss disabled! SEC=$SEC"
202 IDENTITY_UPCALL=false
205 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
207 # Paths on remote nodes, if different
208 export RLUSTRE=${RLUSTRE:-$LUSTRE}
209 export RPWD=${RPWD:-$PWD}
210 export I_MOUNTED=${I_MOUNTED:-"no"}
211 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
212 ! -f `dirname $0`/../mds/mds.ko ]; then
213 export CLIENTMODSONLY=yes
218 while getopts "rvwf:" opt $*; do
221 r) REFORMAT=--reformat;;
223 w) WRITECONF=writeconf;;
228 shift $((OPTIND - 1))
231 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
236 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
237 *) EXT=".ko"; USE_QUOTA=yes;;
242 /sbin/lsmod | grep -q $1
245 # Load a module on the system where this is running.
247 # Synopsis: load_module module_name [module arguments for insmod/modprobe]
249 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
250 # will be used as the arguments. Otherwise arguments will be obtained from
251 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
258 BASE=`basename $module $EXT`
260 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
262 if [ $# -eq 0 ]; then
263 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
264 # Bash until 4.x, so we resort to eval.
265 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
266 eval set -- \$$optvar
267 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
268 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
269 set -- $(grep "^options\\s*\<${module}\>" $MODPROBECONF)
270 # Get rid of "options $module"
271 (($# > 0)) && shift 2
273 # Ensure we have accept=all for lnet
274 if [ $module = lnet ]; then
275 # OK, this is a bit wordy...
276 local arg accept_all_present=false
278 [ "$arg" = accept=all ] && accept_all_present=true
280 $accept_all_present || set -- "$@" accept=all
285 [ $# -gt 0 ] && echo "${module} options: '$*'"
287 module_loaded ${BASE} && return
289 # Note that insmod will ignore anything in modprobe.conf, which is why we're
290 # passing options on the command-line.
291 if [ "$BASE" == "lnet_selftest" ] && \
292 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
293 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
294 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
295 insmod ${LUSTRE}/${module}${EXT} "$@"
297 # must be testing a "make install" or "rpm" installation
298 # note failed to load ptlrpc_gss is considered not fatal
299 if [ "$BASE" == "ptlrpc_gss" ]; then
300 modprobe $BASE "$@" 2>/dev/null || echo "gss/krb5 is not supported"
307 load_modules_local() {
308 if [ -n "$MODPROBE" ]; then
310 echo "Using modprobe to load modules"
313 if [ "$HAVE_MODULES" = true ]; then
315 echo "Modules already loaded"
320 echo Loading modules from $LUSTRE
321 load_module ../libcfs/libcfs/libcfs
322 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
323 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
324 load_module ../lnet/lnet/lnet
325 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
326 load_module ../lnet/klnds/$LNETLND
327 load_module lvfs/lvfs
328 load_module obdclass/obdclass
329 load_module ptlrpc/ptlrpc
330 load_module ptlrpc/gss/ptlrpc_gss
331 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
339 if ! client_only; then
340 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
341 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
342 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
347 load_module lvfs/fsfilt_$FSTYPE
351 load_module obdfilter/obdfilter
354 load_module llite/lustre
355 load_module llite/llite_lloop
356 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
358 rm -f $OGDB/ogdb-$HOSTNAME
359 $LCTL modules > $OGDB/ogdb-$HOSTNAME
361 # 'mount' doesn't look in $PATH, just sbin
362 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
368 # load modules on remote nodes optionally
369 # lustre-tests have to be installed on these nodes
370 if $LOAD_MODULES_REMOTE ; then
371 local list=$(comma_list $(remote_nodes_list))
372 echo loading modules on $list
373 do_rpc_nodes $list load_modules
378 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
379 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
380 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
381 echo "$LEAK_LUSTRE" 1>&2
382 echo "$LEAK_PORTALS" 1>&2
383 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
384 echo "Memory leaks detected"
385 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
391 wait_exit_ST client # bug 12845
393 $LUSTRE_RMMOD $FSTYPE || return 2
395 if $LOAD_MODULES_REMOTE ; then
396 local list=$(comma_list $(remote_nodes_list))
397 if [ ! -z $list ]; then
398 echo unloading modules on $list
399 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
400 do_rpc_nodes $list check_mem_leak
406 check_mem_leak || return 254
408 echo "modules unloaded."
412 check_gss_daemon_nodes() {
416 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
417 if [ \\\"\\\$num\\\" -ne 1 ]; then
418 echo \\\$num instance of $dname;
423 check_gss_daemon_facet() {
427 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
428 if [ $num -ne 1 ]; then
429 echo "$num instance of $dname on $facet"
438 echo Stopping $@ on $list
439 do_nodes $list "killall -2 $@ 2>/dev/null || true"
442 # start gss daemons on all nodes, or
443 # "daemon" on "list" if set
444 start_gss_daemons() {
448 if [ "$list" ] && [ "$daemon" ] ; then
449 echo "Starting gss daemon on nodes: $list"
450 do_nodes $list "$daemon" || return 8
454 local list=$(comma_list $(mdts_nodes))
456 echo "Starting gss daemon on mds: $list"
457 do_nodes $list "$LSVCGSSD -v" || return 1
459 do_nodes $list "$LGSSD -v" || return 2
462 list=$(comma_list $(osts_nodes))
463 echo "Starting gss daemon on ost: $list"
464 do_nodes $list "$LSVCGSSD -v" || return 3
465 # starting on clients
467 local clients=${CLIENTS:-`hostname`}
469 echo "Starting $LGSSD on clients $clients "
470 do_nodes $clients "$LGSSD -v" || return 4
473 # wait daemons entering "stable" status
477 # check daemons are running
479 list=$(comma_list $(mdts_nodes) $(osts_nodes))
480 check_gss_daemon_nodes $list lsvcgssd || return 5
482 list=$(comma_list $(mdts_nodes))
483 check_gss_daemon_nodes $list lgssd || return 6
486 check_gss_daemon_nodes $clients lgssd || return 7
491 local list=$(comma_list $(mdts_nodes))
493 send_sigint $list lsvcgssd lgssd
495 list=$(comma_list $(osts_nodes))
496 send_sigint $list lsvcgssd
498 list=${CLIENTS:-`hostname`}
499 send_sigint $list lgssd
504 if ! module_loaded ptlrpc_gss; then
505 load_module ptlrpc/gss/ptlrpc_gss
506 module_loaded ptlrpc_gss ||
507 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
509 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
511 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
512 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
520 # maybe cleanup credential cache?
526 local device=`mdsdevname $num`
527 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
533 local device=`ostdevname $num`
534 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
542 local dev=$(facet_active $facet)_dev
543 local opt=${facet}_opt
544 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
545 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
547 if [ $RC -ne 0 ]; then
548 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
549 echo "Start of ${!dev} on ${facet} failed ${RC}"
551 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
552 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
553 lctl set_param debug_mb=${DEBUG_SIZE}; \
556 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
557 [ -z "$label" ] && echo no label for ${!dev} && exit 1
558 eval export ${facet}_svc=${label}
559 echo Started ${label}
564 # start facet device options
570 eval export ${facet}_dev=${device}
571 eval export ${facet}_opt=\"$@\"
573 local varname=${facet}failover_dev
574 if [ -n "${!varname}" ] ; then
575 eval export ${facet}failover_dev=${!varname}
577 eval export ${facet}failover_dev=$device
580 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
590 HOST=`facet_active_host $facet`
591 [ -z $HOST ] && echo stop: no host for $facet && return 0
593 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
594 if [ ${running} -ne 0 ]; then
595 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
596 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
599 # umount should block, but we should wait for unrelated obd's
600 # like the MGS or MGC to also stop.
601 wait_exit_ST ${facet}
604 # save quota version (both administrative and operational quotas)
605 # add an additional parameter if mountpoint is ever different from $MOUNT
606 quota_save_version() {
607 local fsname=${2:-$FSNAME}
609 local ver=$(tr -c -d "123" <<< $spec)
610 local type=$(tr -c -d "ug" <<< $spec)
612 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
614 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
616 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
618 local osts=$(get_facets OST)
619 for ost in ${osts//,/ }; do
621 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
625 # client could mount several lustre
627 local fsname=${1:-$FSNAME}
629 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
630 do_nodes $(comma_list $(osts_nodes)) \
631 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
635 restore_quota_type () {
636 local mntpt=${1:-$MOUNT}
637 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
638 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
641 quota_save_version $old_QUOTA_TYPE
647 # We need save the original quota_type params, and restore them after testing
649 # Suppose that quota type the same on mds and ost
650 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
651 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
652 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
653 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
654 export old_QUOTA_TYPE=$quota_type
655 quota_save_version $QUOTA_TYPE
657 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
658 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
661 local quota_usrs=$QUOTA_USERS
663 # get_filesystem_size
664 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
665 local blk_soft=$((disksz + 1024))
666 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
668 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
670 local i_hard=$((i_soft + i_soft / 20))
672 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
673 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
676 for usr in $quota_usrs; do
677 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
679 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
681 eval $cmd || error "$cmd FAILED!"
683 # display the quota status
684 echo "Quota settings for $usr : "
685 $LFS quota -v -u $usr $mntpt || true
693 # Only supply -o to mount if we have options
694 if [ -n "$MOUNTOPT" ]; then
695 OPTIONS="-o $MOUNTOPT"
697 local device=$MGSNID:/$FSNAME
698 if [ -z "$mnt" -o -z "$FSNAME" ]; then
699 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
703 echo "Starting client: $client: $OPTIONS $device $mnt"
704 do_node $client mkdir -p $mnt
705 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
707 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
708 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
709 lctl set_param debug_mb=${DEBUG_SIZE}"
722 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
723 if [ $running -ne 0 ]; then
724 echo "Stopping client $client $mnt (opts:$force)"
725 do_node $client lsof -t $mnt || need_kill=no
726 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
727 pids=$(do_node $client lsof -t $mnt | sort -u);
728 if [ -n $pids ]; then
729 do_node $client kill -9 $pids || true
733 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
734 if [ $busy -ne 0 ] ; then
735 echo "$mnt is still busy, wait one second" && sleep 1
736 do_node $client umount $force $mnt
741 # nodes is comma list
742 sanity_mount_check_nodes () {
748 # FIXME: assume that all cluster nodes run the same os
749 [ "$(uname)" = Linux ] || return 0
752 for mnt in $mnts ; do
753 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
754 mpts=\\\$(mount | grep -w -c $mnt);
755 if [ \\\$running -ne \\\$mpts ]; then
756 echo \\\$(hostname) env are INSANE!;
764 sanity_mount_check_servers () {
766 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
767 echo Checking servers environments
769 # FIXME: modify get_facets to display all facets wo params
770 local facets="$(get_facets OST),$(get_facets MDS),mgs"
774 for facet in ${facets//,/ }; do
775 node=$(facet_host ${facet})
776 mnt=${MOUNT%/*}/${facet}
777 sanity_mount_check_nodes $node $mnt ||
778 { error "server $node environments are insane!"; return 1; }
782 sanity_mount_check_clients () {
783 local clients=${1:-$CLIENTS}
784 local mntpt=${2:-$MOUNT}
785 local mntpt2=${3:-$MOUNT2}
787 [ -z $clients ] && clients=$(hostname)
788 echo Checking clients $clients environments
790 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
791 error "clients environments are insane!"
794 sanity_mount_check () {
795 sanity_mount_check_servers || return 1
796 sanity_mount_check_clients || return 2
799 # mount clients if not mouted
800 zconf_mount_clients() {
803 local OPTIONS=${3:-$MOUNTOPT}
805 # Only supply -o to mount if we have options
806 if [ "$OPTIONS" ]; then
807 OPTIONS="-o $OPTIONS"
809 local device=$MGSNID:/$FSNAME
810 if [ -z "$mnt" -o -z "$FSNAME" ]; then
811 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
815 echo "Starting client $clients: $OPTIONS $device $mnt"
818 running=\\\$(mount | grep -c $mnt' ');
820 if [ \\\$running -eq 0 ] ; then
822 mount -t lustre $OPTIONS $device $mnt;
825 exit \\\$rc" || return ${PIPESTATUS[0]}
827 echo "Started clients $clients: "
828 do_nodes $clients "mount | grep -w $mnt"
830 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
831 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
832 lctl set_param debug_mb=${DEBUG_SIZE};"
837 zconf_umount_clients() {
844 echo "Stopping clients: $clients $mnt (opts:$force)"
845 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
846 if [ \\\$running -ne 0 ] ; then
847 echo Stopping client \\\$(hostname) $mnt opts:$force;
848 lsof -t $mnt || need_kill=no;
849 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
850 pids=\\\$(lsof -t $mnt | sort -u);
851 if [ -n \\\"\\\$pids\\\" ]; then
855 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
856 if [ \\\$busy -ne 0 ] ; then
857 echo "$mnt is still busy, wait one second" && sleep 1;
863 shudown_node_hard () {
867 for i in $(seq $attempts) ; do
870 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
871 echo "waiting for $host to fail attempts=$attempts"
872 [ $i -lt $attempts ] || \
873 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
879 local mnt=${2:-$MOUNT}
882 if [ "$FAILURE_MODE" = HARD ]; then
883 shudown_node_hard $client
885 zconf_umount_clients $client $mnt -f
891 if [ "$FAILURE_MODE" = HARD ]; then
892 shudown_node_hard $(facet_active_host $facet)
893 elif [ "$FAILURE_MODE" = SOFT ]; then
900 if [ "$FAILURE_MODE" = HARD ]; then
901 $POWER_UP `facet_active_host $facet`
909 if [ "$FAILURE_MODE" = HARD ]; then
915 # recovery-scale functions
916 check_progs_installed () {
921 do_nodes $clients "PATH=:$PATH; status=true;
922 for prog in $progs; do
923 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
924 echo \\\$prog missing on \\\$(hostname);
932 echo __$(echo $1 | tr '-' 'X')
935 start_client_load() {
938 local var=$(client_var_name $client)_load
939 eval export ${var}=$load
941 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
942 BREAK_ON_ERROR=$BREAK_ON_ERROR \
943 END_RUN_FILE=$END_RUN_FILE \
944 LOAD_PID_FILE=$LOAD_PID_FILE \
945 TESTSUITELOG=$TESTSUITELOG \
947 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
948 log "Started client load: ${load} on $client"
953 start_client_loads () {
954 local -a clients=(${1//,/ })
955 local numloads=${#CLIENT_LOADS[@]}
958 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
959 testnum=$((nodenum % numloads))
960 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
962 # bug 22169: wait the background threads to start
966 # only for remote client
967 check_client_load () {
969 local var=$(client_var_name $client)_load
970 local TESTLOAD=run_${!var}.sh
972 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
974 # bug 18914: try to connect several times not only when
975 # check ps, but while check_catastrophe also
978 while [ $RC = 254 -a $tries -gt 0 ]; do
982 if ! check_catastrophe $client; then
984 if [ $RC -eq 254 ]; then
985 # FIXME: not sure how long we shuold sleep here
989 echo "check catastrophe failed: RC=$RC "
993 # We can continue try to connect if RC=254
994 # Just print the warning about this
995 if [ $RC = 254 ]; then
996 echo "got a return status of $RC from do_node while checking catastrophe on $client"
999 # see if the load is still on the client
1002 while [ $RC = 254 -a $tries -gt 0 ]; do
1006 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1011 if [ $RC = 254 ]; then
1012 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1013 # see if we can diagnose a bit why this is
1018 check_client_loads () {
1019 local clients=${1//,/ }
1023 for client in $clients; do
1024 check_client_load $client
1026 if [ "$rc" != 0 ]; then
1027 log "Client load failed on node $client, rc=$rc"
1033 restart_client_loads () {
1034 local clients=${1//,/ }
1035 local expectedfail=${2:-""}
1039 for client in $clients; do
1040 check_client_load $client
1042 if [ "$rc" != 0 -a "$expectedfail" ]; then
1043 local var=$(client_var_name $client)_load
1044 start_client_load $client ${!var}
1045 echo "Restarted client load ${!var}: on $client. Checking ..."
1046 check_client_load $client
1048 if [ "$rc" != 0 ]; then
1049 log "Client load failed to restart on node $client, rc=$rc"
1050 # failure one client load means test fail
1051 # we do not need to check other
1059 # End recovery-scale functions
1061 # verify that lustre actually cleaned up properly
1063 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1064 error "LBUG/LASSERT detected"
1065 BUSY=`dmesg | grep -i destruct || true`
1066 if [ "$BUSY" ]; then
1068 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1072 check_mem_leak || exit 204
1074 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1075 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1077 if module_loaded lnet || module_loaded libcfs; then
1078 echo "$0: modules still loaded..." 1>&2
1095 RESULT=$(do_node $node "$TEST")
1096 if [ "$RESULT" == "$FINAL" ]; then
1097 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1100 [ $WAIT -ge $MAX ] && break
1101 echo "Waiting $((MAX - WAIT)) secs for update"
1102 WAIT=$((WAIT + sleep))
1105 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1109 wait_update_facet () {
1111 wait_update $(facet_active_host $facet) "$@"
1114 wait_delete_completed () {
1115 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1116 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1120 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1122 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1123 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1124 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1125 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1129 echo "Delete is not completed in $MAX_WAIT sec"
1135 check_network "$host" 900
1136 while ! do_node $host hostname > /dev/null; do sleep 5; done
1141 local host=`facet_active_host $facet`
1145 wait_recovery_complete () {
1148 # Use default policy if $2 is not passed by caller.
1149 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1150 # as we are in process of changing obd_timeout in different ways
1151 # let's set MAX longer than that
1152 local MAX=${2:-$(( TIMEOUT * 4 ))}
1154 local var_svc=${facet}_svc
1155 local procfile="*.${!var_svc}.recovery_status"
1159 while [ $WAIT -lt $MAX ]; do
1160 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1161 [[ $STATUS = "status: COMPLETE" ]] && return 0
1164 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1166 echo "$facet recovery not done in $MAX sec. $STATUS"
1170 wait_mds_ost_sync () {
1171 # just because recovery is done doesn't mean we've finished
1172 # orphan cleanup. Wait for llogs to get synchronized.
1173 echo "Waiting for orphan cleanup..."
1174 # MAX value includes time needed for MDS-OST reconnection
1175 local MAX=$(( TIMEOUT * 2 ))
1177 while [ $WAIT -lt $MAX ]; do
1178 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1179 "$LCTL get_param -n obdfilter.*.mds_sync"))
1181 for ((i=0; i<${#sync[@]}; i++)); do
1182 [ ${sync[$i]} -eq 0 ] && continue
1183 # there is a not finished MDS-OST synchronization
1187 sleep 2 # increase waiting time and cover statfs cache
1188 [ ${con} -eq 1 ] && return 0
1189 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1192 echo "$facet recovery not done in $MAX sec. $STATUS"
1196 wait_destroy_complete () {
1197 echo "Waiting for destroy to be done..."
1198 # MAX value shouldn't be big as this mean server responsiveness
1199 # never increase this just to make test pass but investigate
1200 # why it takes so long time
1203 while [ $WAIT -lt $MAX ]; do
1204 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1206 for ((i=0; i<${#RPCs[@]}; i++)); do
1207 [ ${RPCs[$i]} -eq 0 ] && continue
1208 # there are still some destroy RPCs in flight
1213 [ ${con} -eq 1 ] && return 0 # done waiting
1214 echo "Waiting $WAIT secs for destroys to be done."
1217 echo "Destroys weren't done in $MAX sec."
1227 # conf-sanity 31 takes a long time cleanup
1228 while [ $WAIT -lt 300 ]; do
1229 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1230 [ -z "${running}" ] && return 0
1231 echo "waited $WAIT for${running}"
1232 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1234 WAIT=$((WAIT + INTERVAL))
1236 echo "service didn't stop after $WAIT seconds. Still running:"
1241 wait_remote_prog () {
1247 [ "$PDSH" = "no_dsh" ] && return 0
1249 while [ $WAIT -lt $2 ]; do
1250 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1251 [ -z "${running}" ] && return 0 || true
1252 echo "waited $WAIT for: "
1254 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1256 WAIT=$((WAIT + INTERVAL))
1258 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1259 [ -z "$pids" ] && return 0
1260 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1261 # FIXME: not portable
1262 for pid in $pids; do
1263 cat /proc/${pid}/status || true
1264 cat /proc/${pid}/wchan || true
1266 kill -9 $pid || true
1275 # not every config has many clients
1277 if [ ! -z "$CLIENTS" ]; then
1278 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1280 stat -f $MOUNT > /dev/null
1286 # usually checked on particular client or locally
1288 if [ ! -z "$client" ]; then
1289 $PDSH $client "stat -f $MOUNT" > /dev/null
1291 stat -f $MOUNT > /dev/null
1299 client_reconnect() {
1300 uname -n >> $MOUNT/recon
1301 if [ -z "$CLIENTS" ]; then
1302 df $MOUNT; uname -n >> $MOUNT/recon
1304 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1306 echo Connected clients:
1308 ls -l $MOUNT/recon > /dev/null
1315 echo "Failing $facet on node `facet_active_host $facet`"
1316 shutdown_facet $facet
1317 [ -n "$sleep_time" ] && sleep $sleep_time
1319 change_active $facet
1320 local TO=`facet_active_host $facet`
1321 echo "Failover $facet to $TO"
1323 mount_facet $facet || error "Restart of $facet failed"
1332 do_facet $facet sync
1334 local svc=${facet}_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_nodf() {
1342 local facet=$1 echo running=${running}
1343 do_facet $facet sync
1344 local svc=${facet}_svc
1345 echo Replay barrier on ${!svc}
1346 do_facet $facet $LCTL --device %${!svc} notransno
1347 do_facet $facet $LCTL --device %${!svc} readonly
1348 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1349 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1352 replay_barrier_nosync() {
1353 local facet=$1 echo running=${running}
1354 local svc=${facet}_svc
1355 echo Replay barrier on ${!svc}
1356 do_facet $facet $LCTL --device %${!svc} notransno
1357 do_facet $facet $LCTL --device %${!svc} readonly
1358 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1359 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1362 mds_evict_client() {
1363 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1364 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1367 ost_evict_client() {
1368 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1369 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1373 facet_failover $* || error "failover: $?"
1374 clients_up || error "post-failover df: $?"
1379 facet_failover $facet
1385 change_active $facet
1386 mount_facet $facet -o abort_recovery
1387 clients_up || echo "first df failed: $?"
1388 clients_up || error "post-failover df: $?"
1392 echo There is no lmc. This is mountconf, baby.
1397 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1398 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1404 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1410 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1411 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1412 if [ -z "$ID" ]; then
1413 echo "Could not get a ptl id for $1..."
1422 h2name_or_ip "$1" "tcp"
1427 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1428 if type __h2elan >/dev/null 2>&1; then
1431 ID=`echo $1 | sed 's/[^0-9]*//g'`
1439 h2name_or_ip "$1" "openib"
1441 declare -fx h2openib
1444 h2name_or_ip "$1" "o2ib"
1451 [ "$facet" == client ] && echo -n $HOSTNAME && return
1452 varname=${facet}_HOST
1453 if [ -z "${!varname}" ]; then
1454 if [ "${facet:0:3}" == "ost" ]; then
1455 eval ${facet}_HOST=${ost_HOST}
1463 local activevar=${facet}active
1465 if [ -f $TMP/${facet}active ] ; then
1466 source $TMP/${facet}active
1469 active=${!activevar}
1470 if [ -z "$active" ] ; then
1477 facet_active_host() {
1479 local active=`facet_active $facet`
1480 if [ "$facet" == client ]; then
1483 echo `facet_host $active`
1489 local failover=${facet}failover
1490 host=`facet_host $failover`
1491 [ -z "$host" ] && return
1492 local curactive=`facet_active $facet`
1493 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1494 eval export ${facet}active=$facet
1496 eval export ${facet}active=$failover
1498 # save the active host for this facet
1499 local activevar=${facet}active
1500 echo "$activevar=${!activevar}" > $TMP/$activevar
1505 # do not stripe off hostname if verbose, bug 19215
1506 if [ x$1 = x--verbose ]; then
1514 if [ "$HOST" = "$HOSTNAME" ]; then
1516 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1517 echo "cannot run remote command on $HOST with $myPDSH"
1521 echo "CMD: $HOST $@" >&2
1522 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1525 if [ "$myPDSH" = "rsh" ]; then
1526 # we need this because rsh does not return exit code of an executed command
1527 local command_status="$TMP/cs"
1528 rsh $HOST ":> $command_status"
1529 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1530 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1531 echo command failed >$command_status"
1532 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1537 # print HOSTNAME for myPDSH="no_dsh"
1538 if [[ $myPDSH = no_dsh ]]; then
1539 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1541 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1544 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1546 return ${PIPESTATUS[0]}
1550 do_node --verbose "$@"
1553 single_local_node () {
1554 [ "$1" = "$HOSTNAME" ]
1557 # Outputs environment variable assignments that should be passed to remote nodes
1562 for var in ${!MODOPTS_*}; do
1564 echo "${var}=\"$value\""
1570 # do not stripe off hostname if verbose, bug 19215
1571 if [ x$1 = x--verbose ]; then
1579 if single_local_node $rnodes; then
1581 do_nodev $rnodes "$@"
1583 do_node $rnodes "$@"
1588 # This is part from do_node
1591 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1592 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1595 echo "CMD: $rnodes $@" >&2
1596 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1600 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
1602 $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"
1604 return ${PIPESTATUS[0]}
1610 local HOST=`facet_active_host $facet`
1611 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1616 do_nodes --verbose "$@"
1622 # make sure its not already running
1624 rm -f $TMP/${facet}active
1625 do_facet ${facet} $MKFS $*
1631 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1632 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1639 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1640 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1648 # make sure we are using the primary server, so test-framework will
1649 # be able to clean up properly.
1650 activemds=`facet_active mds1`
1651 if [ $activemds != "mds1" ]; then
1655 local clients=$CLIENTS
1656 [ -z $clients ] && clients=$(hostname)
1658 zconf_umount_clients $clients $MOUNT "$*" || true
1659 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1661 [ "$CLIENTONLY" ] && return
1662 # The add fn does rm ${facet}active file, this would be enough
1663 # if we use do_facet <facet> only after the facet added, but
1664 # currently we use do_facet mds in local.sh
1665 for num in `seq $MDSCOUNT`; do
1667 rm -f ${TMP}/mds${num}active
1670 for num in `seq $OSTCOUNT`; do
1672 rm -f $TMP/ost${num}active
1675 if ! combined_mgs_mds ; then
1683 nfs_client_mode && return
1693 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1696 combined_mgs_mds () {
1697 [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
1701 if [ "$IAMDIR" == "yes" ]; then
1702 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1703 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1706 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1709 # We need ldiskfs here, may as well load them all
1711 [ "$CLIENTONLY" ] && return
1712 echo Formatting mgs, mds, osts
1713 if ! combined_mgs_mds ; then
1714 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1717 for num in `seq $MDSCOUNT`; do
1718 echo "Format mds$num: $(mdsdevname $num)"
1720 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1722 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1726 for num in `seq $OSTCOUNT`; do
1727 echo "Format ost$num: $(ostdevname $num)"
1729 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1731 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1737 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1741 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1745 # 0: success, the old identity set already.
1746 # 1: success, the old identity does not set.
1751 local j=`expr $num - 1`
1752 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1754 if [ -z "$MDT" ]; then
1758 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1761 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1763 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1766 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1768 if [ $old = "NONE" ]; then
1777 zconf_umount `hostname` $1 || error "umount failed"
1778 zconf_mount `hostname` $1 || error "mount failed"
1781 writeconf_facet () {
1785 do_facet $facet "$TUNEFS --writeconf $dev"
1789 for num in `seq $MDSCOUNT`; do
1790 DEVNAME=$(mdsdevname $num)
1791 writeconf_facet mds$num $DEVNAME
1794 for num in `seq $OSTCOUNT`; do
1795 DEVNAME=$(ostdevname $num)
1796 writeconf_facet ost$num $DEVNAME
1801 nfs_client_mode && return
1803 sanity_mount_check ||
1804 error "environments are insane!"
1808 if [ -z "$CLIENTONLY" ]; then
1809 echo Setup mgs, mdt, osts
1810 echo $WRITECONF | grep -q "writeconf" && \
1812 if ! combined_mgs_mds ; then
1813 start mgs $MGSDEV $mgs_MOUNT_OPTS
1816 for num in `seq $MDSCOUNT`; do
1817 DEVNAME=$(mdsdevname $num)
1818 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1820 # We started mds, now we should set failover variables properly.
1821 # Set mds${num}failover_HOST if it is not set (the default failnode).
1822 local varname=mds${num}failover_HOST
1823 if [ -z "${!varname}" ]; then
1824 eval mds${num}failover_HOST=$(facet_host mds$num)
1827 if [ $IDENTITY_UPCALL != "default" ]; then
1828 switch_identity $num $IDENTITY_UPCALL
1831 for num in `seq $OSTCOUNT`; do
1832 DEVNAME=$(ostdevname $num)
1833 start ost$num $DEVNAME $OST_MOUNT_OPTS
1835 # We started ost$num, now we should set ost${num}failover variable properly.
1836 # Set ost${num}failover_HOST if it is not set (the default failnode).
1837 varname=ost${num}failover_HOST
1838 if [ -z "${!varname}" ]; then
1839 eval ost${num}failover_HOST=$(facet_host ost${num})
1847 # wait a while to allow sptlrpc configuration be propogated to targets,
1848 # only needed when mounting new target devices.
1853 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1855 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1857 if [ "$MOUNT_2" ]; then
1858 mount_client $MOUNT2
1859 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1864 # by remounting mdt before ost, initial connect from mdt to ost might
1865 # timeout because ost is not ready yet. wait some time to its fully
1866 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1867 # by a context negotiation rpc with $TIMEOUT.
1868 # FIXME better by monitoring import status.
1871 sleep $((TIMEOUT + 5))
1877 mounted_lustre_filesystems() {
1878 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1881 init_facet_vars () {
1882 [ "$CLIENTONLY" ] && return 0
1889 eval export ${facet}_dev=${device}
1890 eval export ${facet}_opt=\"$@\"
1892 local dev=${facet}_dev
1893 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1894 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1896 eval export ${facet}_svc=${label}
1898 local varname=${facet}failover_HOST
1899 if [ -z "${!varname}" ]; then
1900 eval $varname=$(facet_host $facet)
1903 # ${facet}failover_dev is set in cfg file
1904 varname=${facet}failover_dev
1905 if [ -n "${!varname}" ] ; then
1906 eval export ${facet}failover_dev=${!varname}
1908 eval export ${facet}failover_dev=$device
1912 init_facets_vars () {
1915 if ! remote_mds_nodsh; then
1916 for num in `seq $MDSCOUNT`; do
1917 DEVNAME=`mdsdevname $num`
1918 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1922 remote_ost_nodsh && return
1924 for num in `seq $OSTCOUNT`; do
1925 DEVNAME=`ostdevname $num`
1926 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1930 osc_ensure_active () {
1936 while [ $period -lt $timeout ]; do
1937 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1938 if [ $count -eq 0 ]; then
1942 echo "There are $count OST are inactive, wait $period seconds, and try again"
1944 period=$((period+3))
1947 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1950 init_param_vars () {
1951 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1952 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1953 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1954 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1958 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1960 log "Using TIMEOUT=$TIMEOUT"
1962 osc_ensure_active $SINGLEMDS M $TIMEOUT
1963 osc_ensure_active client c $TIMEOUT
1965 if [ $QUOTA_AUTO -ne 0 ]; then
1966 if [ "$ENABLE_QUOTA" ]; then
1967 echo "enable quota as required"
1968 setup_quota $MOUNT || return 2
1970 echo "disable quota as required"
1971 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1978 nfs_client_mode () {
1979 if [ "$NFSCLIENT" ]; then
1980 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1981 local clients=$CLIENTS
1982 [ -z $clients ] && clients=$(hostname)
1984 # FIXME: remove hostname when 19215 fixed
1985 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1986 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1987 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1993 check_config_client () {
1996 local mounted=$(mount | grep " $mntpt ")
1997 if [ "$CLIENTONLY" ]; then
1999 # CLIENTONLY should not depend on *_HOST settings
2000 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
2001 # in theory someone could create a new,
2002 # client-only config file that assumed lustre was already
2003 # configured and didn't set the MGSNID. If MGSNID is not set,
2004 # then we should use the mgs nid currently being used
2005 # as the default value. bug 18021
2006 [[ x$MGSNID = x ]] &&
2009 if [[ x$mgc != xMGC$MGSNID ]]; then
2010 if [ "$mgs_HOST" ]; then
2011 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
2012 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
2013 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
2019 local myMGS_host=$mgs_HOST
2020 if [ "$NETTYPE" = "ptl" ]; then
2021 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
2024 echo Checking config lustre mounted on $mntpt
2025 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
2026 mgshost=$(echo $mgshost | awk -F: '{print $1}')
2028 # if [ "$mgshost" != "$myMGS_host" ]; then
2029 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
2030 # Please use correct config or set mds_HOST correctly!"
2035 check_config_clients () {
2036 local clients=${CLIENTS:-$HOSTNAME}
2039 nfs_client_mode && return
2041 do_rpc_nodes $clients check_config_client $mntpt
2043 sanity_mount_check ||
2044 error "environments are insane!"
2048 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
2049 local cltimeout=$(lctl get_param -n timeout)
2050 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
2051 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
2058 local mounted=$(mounted_lustre_filesystems)
2060 echo $mounted' ' | grep -w -q $mntpt' '
2063 check_and_setup_lustre() {
2064 nfs_client_mode && return
2066 local MOUNTED=$(mounted_lustre_filesystems)
2070 # both MOUNT and MOUNT2 are not mounted
2071 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2072 [ "$REFORMAT" ] && formatall
2073 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2075 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2076 export I_MOUNTED=yes
2080 elif is_mounted $MOUNT2; then
2082 # MOUNT2 is mounted, while MOUNT_2 is not set
2083 if ! [ "$MOUNT_2" ]; then
2084 cleanup_mount $MOUNT2
2085 export I_UMOUNTED2=yes
2088 # MOUNT2 is mounted, MOUNT_2 is set
2090 # FIXME: what to do if check_config failed?
2092 # 1) remote client has mounted other Lustre fs ?
2093 # 2) it has insane env ?
2094 # let's try umount MOUNT2 on all clients and mount it again:
2095 if ! check_config_clients $MOUNT2; then
2096 cleanup_mount $MOUNT2
2097 restore_mount $MOUNT2
2098 export I_MOUNTED2=yes
2103 # MOUNT is mounted MOUNT2 is not mounted
2104 elif [ "$MOUNT_2" ]; then
2105 restore_mount $MOUNT2
2106 export I_MOUNTED2=yes
2110 # FIXME: what to do if check_config failed?
2112 # 1) remote client has mounted other Lustre fs?
2113 # 2) lustre is mounted on remote_clients atall ?
2114 check_config_clients $MOUNT
2118 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2119 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2120 lctl set_param debug_mb=${DEBUG_SIZE};
2127 if [ "$ONLY" == "setup" ]; then
2133 local clients=${CLIENTS:-$HOSTNAME}
2136 zconf_mount_clients $clients $mntpt
2140 local clients=${CLIENTS:-$HOSTNAME}
2143 zconf_umount_clients $clients $mntpt
2146 cleanup_and_setup_lustre() {
2147 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2148 lctl set_param debug=0 || true
2150 if [ "$ONLY" == "cleanup" ]; then
2154 check_and_setup_lustre
2157 check_and_cleanup_lustre() {
2158 if is_mounted $MOUNT; then
2159 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2160 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2163 if [ "$I_UMOUNTED2" = "yes" ]; then
2164 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2167 if [ "$I_MOUNTED2" = "yes" ]; then
2168 cleanup_mount $MOUNT2
2171 if [ "$I_MOUNTED" = "yes" ]; then
2172 cleanupall -f || error "cleanup failed"
2184 while [ $NETWORK -eq 0 ]; do
2185 if ping -c 1 -w 3 $1 > /dev/null; then
2189 echo "waiting for $1, $((MAX - WAIT)) secs left"
2192 if [ $WAIT -gt $MAX ]; then
2193 echo "Network not available"
2199 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2210 # the sed converts spaces to commas, but leaves the last space
2211 # alone, so the line doesn't end with a comma.
2212 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2215 # list, excluded are the comma separated lists
2216 exclude_items_from_list () {
2222 for item in ${excluded//,/ }; do
2223 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2225 echo $(comma_list $list)
2228 # list, expand are the comma separated lists
2230 local list=${1//,/ }
2231 local expand=${2//,/ }
2234 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2235 echo $(comma_list $expanded)
2238 testslist_filter () {
2239 local script=$LUSTRE/tests/${TESTSUITE}.sh
2241 [ -f $script ] || return 0
2243 local start_at=$START_AT
2244 local stop_at=$STOP_AT
2246 local var=${TESTSUITE//-/_}_START_AT
2247 [ x"${!var}" != x ] && start_at=${!var}
2248 var=${TESTSUITE//-/_}_STOP_AT
2249 [ x"${!var}" != x ] && stop_at=${!var}
2251 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2252 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2253 /^'${start_at}'$/ {flag = 0}
2254 {if (flag == 1) print $0}
2255 /^'${stop_at}'$/ { flag = 1 }'
2259 (cd `dirname $1`; echo $PWD/`basename $1`)
2263 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2264 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2267 local count=${type}COUNT
2268 for ((i=1; i<=${!count}; i++)) do
2269 list="$list ${name}$i"
2271 echo $(comma_list $list)
2274 ##################################
2275 # Adaptive Timeouts funcs
2278 # only check mds, we assume at_max is the same on all nodes
2279 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2280 if [ $at_max -eq 0 ]; then
2290 # suppose that all ost-s has the same at_max set
2291 if [ $facet == "ost" ]; then
2292 do_facet ost1 "lctl get_param -n at_max"
2294 do_facet $facet "lctl get_param -n at_max"
2304 if [ $facet == "ost" ]; then
2305 for i in `seq $OSTCOUNT`; do
2306 do_facet ost$i "lctl set_param at_max=$at_max"
2309 elif [ $facet == "mds" ]; then
2310 for i in `seq $MDSCOUNT`; do
2311 do_facet mds$i "lctl set_param at_max=$at_max"
2314 do_facet $facet "lctl set_param at_max=$at_max"
2319 ##################################
2323 # OBD_FAIL_MDS_ALL_REQUEST_NET
2325 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2326 do_facet client "$1" || RC=$?
2327 do_facet $SINGLEMDS lctl set_param fail_loc=0
2332 # OBD_FAIL_MDS_ALL_REPLY_NET
2334 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2335 do_facet client "$@" || RC=$?
2336 do_facet $SINGLEMDS lctl set_param fail_loc=0
2340 drop_reint_reply() {
2341 # OBD_FAIL_MDS_REINT_NET_REP
2343 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2344 do_facet client "$@" || RC=$?
2345 do_facet $SINGLEMDS lctl set_param fail_loc=0
2350 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2352 do_facet ost1 lctl set_param fail_loc=0x214
2353 do_facet client "$1" || RC=$?
2354 do_facet client "sync"
2355 do_facet ost1 lctl set_param fail_loc=0
2359 drop_ldlm_cancel() {
2360 #define OBD_FAIL_LDLM_CANCEL 0x304
2362 do_facet client lctl set_param fail_loc=0x304
2363 do_facet client "$@" || RC=$?
2364 do_facet client lctl set_param fail_loc=0
2368 drop_bl_callback() {
2369 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2371 do_facet client lctl set_param fail_loc=0x305
2372 do_facet client "$@" || RC=$?
2373 do_facet client lctl set_param fail_loc=0
2378 #define OBD_FAIL_LDLM_REPLY 0x30c
2380 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2381 do_facet client "$@" || RC=$?
2382 do_facet $SINGLEMDS lctl set_param fail_loc=0
2390 echo "clearing fail_loc on $facet"
2391 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2394 set_nodes_failloc () {
2395 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2398 cancel_lru_locks() {
2399 $LCTL mark "cancel_lru_locks $1 start"
2400 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2401 $LCTL set_param -n $d=clear
2403 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2404 $LCTL mark "cancel_lru_locks $1 stop"
2409 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2410 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2411 echo "$DEFAULT_LRU_SIZE"
2416 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2419 lru_resize_disable()
2421 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2426 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2427 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2428 echo there is still data in page cache $FILE ?
2429 lctl get_param -n $FILE
2437 DEBUGSAVE="$(lctl get_param -n debug)"
2441 [ -n "$DEBUGSAVE" ] && \
2442 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2447 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2450 debug_size_restore() {
2451 [ -n "$DEBUG_SIZE_SAVED" ] && \
2452 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2456 start_full_debug_logging() {
2461 local DEBUG_SIZE=150
2463 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2464 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2467 stop_full_debug_logging() {
2472 ##################################
2474 ##################################
2477 local TYPE=${TYPE:-"FAIL"}
2480 # do not dump logs if $1=false
2481 if [ "x$1" = "xfalse" ]; then
2486 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2488 # We need to dump the logs on all nodes
2490 gather_logs $(comma_list $(nodes_list))
2494 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2495 echo "$@" > $LOGDIR/err
2507 # use only if we are ignoring failures for this test, bugno required.
2508 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2509 # e.g. error_ignore 5494 "your message"
2511 local TYPE="IGNORE (bz$1)"
2517 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2522 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2523 [ "$TESTSUITELOG" ] && \
2524 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2527 build_test_filter() {
2528 EXCEPT="$EXCEPT $(testslist_filter)"
2530 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2534 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2535 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2536 [ "$EXCEPT_SLOW" ] && \
2537 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2538 for E in $EXCEPT $ALWAYS_EXCEPT; do
2539 eval EXCEPT_${E}=true
2541 for E in $EXCEPT_SLOW; do
2542 eval EXCEPT_SLOW_${E}=true
2544 for G in $GRANT_CHECK_LIST; do
2545 eval GCHECK_ONLY_${G}=true
2550 if [[ $1 = [a-z]* ]]; then
2557 # print a newline if the last test was skipped
2558 export LAST_SKIPPED=
2560 # Main entry into test-framework. This is called with the name and
2561 # description of a test. The name is used to find the function to run
2562 # the test using "test_$name".
2564 # This supports a variety of methods of specifying specific test to
2565 # run or not run. These need to be documented...
2570 export base=`basetest $1`
2571 if [ ! -z "$ONLY" ]; then
2573 if [ ${!testname}x != x ]; then
2574 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2575 run_one_logged $1 "$2"
2579 if [ ${!testname}x != x ]; then
2580 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2581 run_one_logged $1 "$2"
2589 if [ ${!testname}x != x ]; then
2591 TESTNAME=test_$1 skip "skipping excluded test $1"
2594 testname=EXCEPT_$base
2595 if [ ${!testname}x != x ]; then
2597 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2600 testname=EXCEPT_SLOW_$1
2601 if [ ${!testname}x != x ]; then
2603 TESTNAME=test_$1 skip "skipping SLOW test $1"
2606 testname=EXCEPT_SLOW_$base
2607 if [ ${!testname}x != x ]; then
2609 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2614 run_one_logged $1 "$2"
2625 module_loaded lnet || load_modules
2637 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2642 strace -o $TMP/$1.strace -ttt $*
2644 log "FINISHED: $*: rc $RC"
2649 # Set TEST_STATUS here; will be used for logging the result
2650 if [ -f $LOGDIR/err ]; then
2655 echo $TEST_STATUS " " $@
2659 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2660 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2661 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2665 echo -n "Resetting fail_loc on all nodes..."
2666 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2672 # Log a message (on all nodes) padded with "=" before and after.
2673 # Also appends a timestamp and prepends the testsuite name.
2676 EQUALS="===================================================================================================="
2678 msg="== ${TESTSUITE} $*"
2680 [[ $last != "=" && $last != " " ]] && msg="$msg "
2681 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
2682 # always include at least == after the message
2683 log "$msg== $(date +"%H:%M:%S (%s)")"
2687 # Run a single test function and cleanup after it.
2689 # This function should be run in a subshell so the test func can
2690 # exit() without stopping the whole script.
2696 export tdir=d0.${TESTSUITE}/d${base}
2697 export TESTNAME=test_$testnum
2698 local SAVE_UMASK=`umask`
2701 banner "test $testnum: $message"
2702 test_${testnum} || error "test_$testnum failed with $?"
2705 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2706 check_catastrophe || error "LBUG/LASSERT detected"
2707 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2715 # Wrapper around run_one to ensure:
2716 # - test runs in subshell
2717 # - output of test is saved to separate log file for error reporting
2718 # - test result is saved to data file
2721 local BEFORE=`date +%s`
2723 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
2724 local test_log=$LOGDIR/$name
2728 (run_one $1 "$2") 2>&1 | tee $test_log
2729 local RC=${PIPESTATUS[0]}
2731 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2732 echo "test_$1 returned $RC" | tee $LOGDIR/err
2734 duration=$((`date +%s` - $BEFORE))
2735 pass "(${duration}s)"
2736 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2737 log_sub_test test_${1} $TEST_STATUS $duration "$RC" "$TEST_ERROR"
2739 if [ -f $LOGDIR/err ]; then
2740 $FAIL_ON_ERROR && exit $RC
2747 (cd `dirname $1`; echo $PWD/`basename $1`)
2751 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2752 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2757 export base=`basetest $1`
2758 [ "$CHECK_GRANT" == "no" ] && return 0
2760 testname=GCHECK_ONLY_${base}
2761 [ ${!testname}x == x ] && return 0
2763 echo -n "checking grant......"
2765 # write some data to sync client lost_grant
2766 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2767 for i in `seq $OSTCOUNT`; do
2768 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2769 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2770 count=1 > /dev/null 2>&1
2772 # sync all the data and make sure no pending data on server
2775 #get client grant and server grant
2777 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2778 client_grant=$((client_grant + $d))
2781 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2782 server_grant=$((server_grant + $d))
2785 # cleanup the check_grant file
2786 for i in `seq $OSTCOUNT`; do
2787 rm $DIR1/${tfile}_check_grant_$i
2790 #check whether client grant == server grant
2791 if [ $client_grant != $server_grant ]; then
2792 echo "failed: client:${client_grant} server: ${server_grant}"
2799 ########################
2805 ost=`echo $1 | awk -F_ '{print $3}'`
2806 if [ -z $ost ]; then
2807 ost=`echo $1 | sed 's/-osc.*//'`
2814 [ "$node" != "$(hostname)" ]
2820 for node in $(mdts_nodes); do
2821 remote_node $node && return 0
2828 [ "$CLIENTONLY" ] && return 0 || true
2829 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2834 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
2835 MSKIPPED=1 && return 1
2842 for node in $(osts_nodes) ; do
2843 remote_node $node && return 0
2850 [ "$CLIENTONLY" ] && return 0 || true
2851 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2856 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
2857 OSKIPPED=1 && return 1
2864 MGS=$(facet_host mgs)
2865 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2870 remote_mds_nodsh || remote_ost_nodsh || \
2871 $(single_local_node $(comma_list $(nodes_list)))
2877 for num in `seq $MDSCOUNT`; do
2878 MDSNODES="$MDSNODES $(facet_host mds$num)"
2880 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2886 remote_ost && remote_mds
2890 local OSTNODES=$(facet_host ost1)
2893 for num in `seq $OSTCOUNT`; do
2894 local myOST=$(facet_host ost$num)
2895 OSTNODES="$OSTNODES $myOST"
2897 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2903 # FIXME. We need a list of clients
2904 local myNODES=$HOSTNAME
2907 # CLIENTS (if specified) contains the local client
2908 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2910 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2911 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2914 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2919 remote_nodes_list () {
2920 local rnodes=$(nodes_list)
2921 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2925 init_clients_lists () {
2926 # Sanity check: exclude the local client from RCLIENTS
2927 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2929 # Sanity check: exclude the dup entries
2930 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2932 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2934 # Sanity check: exclude the dup entries from CLIENTS
2935 # for those configs which has SINGLCLIENT set to local client
2936 clients=$(for i in $clients; do echo $i; done | sort -u)
2938 CLIENTS=`comma_list $clients`
2939 local -a remoteclients=($rclients)
2940 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2941 varname=CLIENT$((i + 2))
2942 eval $varname=${remoteclients[i]}
2945 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2948 get_random_entry () {
2951 rnodes=${rnodes//,/ }
2953 local -a nodes=($rnodes)
2954 local num=${#nodes[@]}
2955 local i=$((RANDOM * num * 2 / 65536))
2961 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2966 lctl get_param version | grep -q patchless
2970 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2975 echo $nodes | wc -w || true
2979 local nodes=$(osts_nodes)
2980 local osscount=$(get_node_count "$nodes")
2981 [ ! "$OSTCOUNT" = "$osscount" ]
2985 local nodes=$(mdts_nodes)
2986 local mdtcount=$(get_node_count "$nodes")
2987 [ ! "$MDSCOUNT" = "$mdtcount" ]
2990 generate_machine_file() {
2991 local nodes=${1//,/ }
2992 local machinefile=$2
2994 for node in $nodes; do
2995 echo $node >>$machinefile || \
2996 { echo "can not generate machinefile $machinefile" && return 1; }
3001 local file=$1/stripe
3003 $LFS getstripe -v $file || error
3007 setstripe_nfsserver () {
3010 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
3011 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
3013 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
3015 do_nodev $nfsserver lfs setstripe "$@"
3018 check_runas_id_ret() {
3020 local myRUNAS_UID=$1
3021 local myRUNAS_GID=$2
3024 if [ -z "$myRUNAS" ]; then
3025 error_exit "myRUNAS command must be specified for check_runas_id"
3028 $myRUNAS krb5_login.sh || \
3029 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
3031 mkdir $DIR/d0_runas_test
3033 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
3034 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
3035 rm -rf $DIR/d0_runas_test
3040 local myRUNAS_UID=$1
3041 local myRUNAS_GID=$2
3044 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
3045 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
3046 Please set RUNAS_ID to some UID which exists on MDS and client or
3047 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
3050 # obtain the UID/GID for MPI_USER
3054 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
3055 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
3057 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
3058 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
3061 # obtain and cache Kerberos ticket-granting ticket
3062 refresh_krb5_tgt() {
3063 local myRUNAS_UID=$1
3064 local myRUNAS_GID=$2
3067 if [ -z "$myRUNAS" ]; then
3068 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
3071 CLIENTS=${CLIENTS:-$HOSTNAME}
3072 do_nodes $CLIENTS "set -x
3073 if ! $myRUNAS krb5_login.sh; then
3074 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
3079 # Run multiop in the background, but wait for it to print
3080 # "PAUSING" to its stdout before returning from this function.
3081 multiop_bg_pause() {
3082 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
3086 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
3089 echo "$MULTIOP_PROG $FILE v$ARGS"
3090 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
3092 echo "TMPPIPE=${TMPPIPE}"
3093 read -t 60 multiop_output < $TMPPIPE
3094 if [ $? -ne 0 ]; then
3099 if [ "$multiop_output" != "PAUSING" ]; then
3100 echo "Incorrect multiop output: $multiop_output"
3115 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3121 inodes_available () {
3122 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3126 mdsrate_inodes_available () {
3127 echo $(($(inodes_available) - 1))
3130 # reset llite stat counters
3131 clear_llite_stats(){
3132 lctl set_param -n llite.*.stats 0
3135 # sum llite stat items
3136 calc_llite_stats() {
3137 local res=$(lctl get_param -n llite.*.stats |
3138 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3142 # reset osc stat counters
3144 lctl set_param -n osc.*.osc_stats 0
3147 # sum osc stat items
3149 local res=$(lctl get_param -n osc.*.osc_stats |
3150 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3155 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3158 calc_osc_kbytes () {
3159 df $MOUNT > /dev/null
3160 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3163 # save_lustre_params(node, parameter_mask)
3164 # generate a stream of formatted strings (<node> <param name>=<param value>)
3165 save_lustre_params() {
3167 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3170 # restore lustre parameters from input stream, produces by save_lustre_params
3171 restore_lustre_params() {
3175 while IFS=" =" read node name val; do
3176 do_node ${node//:/} "lctl set_param -n $name $val"
3180 check_catastrophe() {
3181 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3182 local C=$CATASTROPHE
3183 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3185 if [ $rnodes ]; then
3186 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3187 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3203 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3205 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3206 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3207 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3211 # CMD: determine mds index where directory inode presents
3214 local file=$dir/f0.get_mds_dir_tmpfile
3219 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3220 local -a oldused=($iused)
3222 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3224 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3225 local -a newused=($iused)
3228 for ((i=0; i<${#newused[@]}; i++)); do
3229 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3235 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3238 mdsrate_cleanup () {
3240 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3245 delayed_recovery_enabled () {
3246 local var=${SINGLEMDS}_svc
3247 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3250 ########################
3252 convert_facet2label() {
3255 if [ x$facet = xost ]; then
3259 local varsvc=${facet}_svc
3261 if [ -n ${!varsvc} ]; then
3264 error "No lablel for $facet!"
3268 get_clientosc_proc_path() {
3274 get_lustre_version () {
3275 local node=${1:-"mds"}
3276 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3279 get_mds_version_major () {
3280 local version=$(get_lustre_version mds)
3281 echo $version | awk -F. '{print $1}'
3284 get_mds_version_minor () {
3285 local version=$(get_lustre_version mds)
3286 echo $version | awk -F. '{print $2}'
3289 get_mdtosc_proc_path() {
3291 local major=$(get_mds_version_major)
3292 local minor=$(get_mds_version_minor)
3293 if [ $major -le 1 -a $minor -le 8 ] ; then
3296 echo "${ost}-osc-MDT0000"
3300 get_osc_import_name() {
3303 local label=$(convert_facet2label $ost)
3305 if [ "$facet" == "mds" ]; then
3306 get_mdtosc_proc_path $label
3310 get_clientosc_proc_path $label
3314 wait_import_state () {
3320 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3321 while [ "${CONN_STATE}" != "${expected}" ]; do
3322 if [ "${expected}" == "DISCONN" ]; then
3323 # for disconn we can check after proc entry is removed
3324 [ "x${CONN_STATE}" == "x" ] && return 0
3325 # with AT we can have connect request timeout ~ reconnect timeout
3326 # and test can't see real disconnect
3327 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3329 # disconnect rpc should be wait not more obd_timeout
3330 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3331 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3333 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3337 log "$CONN_PROC now in ${CONN_STATE} state"
3341 wait_osc_import_state() {
3345 local ost=$(get_osc_import_name $facet $ost_facet)
3350 CONN_PROC="osc.${ost}.ost_server_uuid"
3351 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3352 while [ "${CONN_STATE}" != "${expected}" ]; do
3353 if [ "${expected}" == "DISCONN" ]; then
3354 # for disconn we can check after proc entry is removed
3355 [ "x${CONN_STATE}" == "x" ] && return 0
3356 # with AT we can have connect request timeout ~ reconnect timeout
3357 # and test can't see real disconnect
3358 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3360 # disconnect rpc should be wait not more obd_timeout
3361 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3362 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3364 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3368 log "${ost_facet} now in ${CONN_STATE} state"
3371 get_clientmdc_proc_path() {
3379 # Add paths to lustre tests for 32 and 64 bit systems.
3380 local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3381 do_nodesv $list "PATH=$RPATH sh rpc.sh $@ "
3384 wait_clients_import_state () {
3390 local label=$(convert_facet2label $facet)
3393 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3394 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3395 *) error "unknown facet!" ;;
3398 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3399 error "import is not in ${expected} state"
3408 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3409 $LCTL get_param obdfilter.*.kbytesavail))
3410 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3411 $LCTL get_param -n obdfilter.*.tot_granted))
3412 for ((i=0; i<${#AVAILA[@]}; i++)); do
3413 local -a AVAIL1=(${AVAILA[$i]//=/ })
3414 GRANT=$((${GRANTA[$i]}/1024))
3415 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3416 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3422 do_facet mgs lctl pool_list $1
3426 local fsname=${1%%.*}
3427 local poolname=${1##$fsname.}
3429 do_facet mgs lctl pool_new $1
3431 # get param should return err unless pool is created
3432 [[ $RC -ne 0 ]] && return $RC
3434 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3435 2>/dev/null || echo foo" "" || RC=1
3436 if [[ $RC -eq 0 ]]; then
3439 error "pool_new failed $1"
3444 add_pool_to_list () {
3445 local fsname=${1%%.*}
3446 local poolname=${1##$fsname.}
3448 local listvar=${fsname}_CREATED_POOLS
3449 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3452 remove_pool_from_list () {
3453 local fsname=${1%%.*}
3454 local poolname=${1##$fsname.}
3456 local listvar=${fsname}_CREATED_POOLS
3457 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3460 destroy_pool_int() {
3462 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3463 awk '$1 !~ /^Pool:/ {print $1}')
3464 for ost in $OSTS; do
3465 do_facet mgs lctl pool_remove $1 $ost
3467 do_facet mgs lctl pool_destroy $1
3470 # <fsname>.<poolname> or <poolname>
3472 local fsname=${1%%.*}
3473 local poolname=${1##$fsname.}
3475 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3479 pool_list $fsname.$poolname || return $?
3481 destroy_pool_int $fsname.$poolname
3483 [[ $RC -ne 0 ]] && return $RC
3485 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3486 2>/dev/null || echo foo" "foo" || RC=1
3488 if [[ $RC -eq 0 ]]; then
3489 remove_pool_from_list $fsname.$poolname
3491 error "destroy pool failed $1"
3497 local fsname=${1:-$FSNAME}
3499 local listvar=${fsname}_CREATED_POOLS
3503 [ x${!listvar} = x ] && return 0
3505 echo destroy the created pools: ${!listvar}
3506 for poolname in ${!listvar//,/ }; do
3507 destroy_pool $fsname.$poolname
3512 local fsname=${1:-$FSNAME}
3514 destroy_pools $fsname
3520 local ts=$(date +%s)
3522 # bug 20237, comment 11
3523 # It would also be useful to provide the option
3524 # of writing the file to an NFS directory so it doesn't need to be copied.
3527 [ -f $LOGDIR/shared ] && docp=false
3529 # dump lustre logs, dmesg
3531 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3533 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3535 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3536 echo "Dumping logs only on local client."
3537 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3538 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3543 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3544 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3545 if [ ! -f $LOGDIR/shared ]; then
3546 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3549 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3550 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3556 local list=${1:-$(comma_list $(nodes_list))}
3558 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3570 for i in $(seq 0 $num_mntpts); do
3571 cmd="ls -laf ${mntpt_root}$i/$dir"
3577 for pid in $pids; do
3584 get_clients_mount_count () {
3585 local clients=${CLIENTS:-`hostname`}
3587 # we need to take into account the clients mounts and
3588 # exclude mds/ost mounts if any;
3589 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
3593 PROC_CLI="srpc_info"
3601 if [ $M -lt $N ]; then
3605 while [ $N -le $M ]; do
3615 calc_connection_cnt() {
3618 # MDT->MDT = 2 * C(M, 2)
3622 comb_m2=$(combination $MDSCOUNT 2)
3624 local num_clients=$(get_clients_mount_count)
3626 local cnt_mdt2mdt=$((comb_m2 * 2))
3627 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
3628 local cnt_cli2ost=$((num_clients * OSTCOUNT))
3629 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
3630 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
3631 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
3632 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
3646 local cmd="$tgt.srpc.flavor"
3648 if [ $net == "any" ]; then
3653 if [ $dir != "any" ]; then
3658 log "Setting sptlrpc rule: $cmd"
3659 do_facet mgs "$LCTL conf_param $cmd"
3668 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
3669 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
3671 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
3673 if [ "x$bulkspec" != "x" ]; then
3674 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
3676 if [ "x$algs" != "x" ]; then
3677 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
3679 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
3680 if [ $bulk == "bulkn" ]; then
3681 bulk_count=`echo "$output" | grep "bulk flavor" \
3682 | grep "null/null" | wc -l`
3683 elif [ $bulk == "bulki" ]; then
3684 bulk_count=`echo "$output" | grep "bulk flavor" \
3685 | grep "/null" | grep -v "null/" | wc -l`
3687 bulk_count=`echo "$output" | grep "bulk flavor" \
3688 | grep -v "/null" | grep -v "null/" | wc -l`
3692 [ $bulk_count -lt $count ] && count=$bulk_count
3703 local clients=${CLIENTS:-`hostname`}
3705 for c in ${clients//,/ }; do
3706 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
3707 tmpcnt=`count_flvr "$output" $flavor`
3708 cnt=$((cnt + tmpcnt))
3718 local clients=${CLIENTS:-`hostname`}
3720 for c in ${clients//,/ }; do
3721 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
3722 tmpcnt=`count_flvr "$output" $flavor`
3723 cnt=$((cnt + tmpcnt))
3733 if [ $MDSCOUNT -le 1 ]; then
3738 for num in `seq $MDSCOUNT`; do
3739 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
3740 tmpcnt=`count_flvr "$output" $flavor`
3741 cnt=$((cnt + tmpcnt))
3751 for num in `seq $MDSCOUNT`; do
3752 output=`do_facet mds$num lctl get_param -n osc.*OST*-osc-MDT*.$PROC_CLI 2>/dev/null`
3753 tmpcnt=`count_flvr "$output" $flavor`
3754 cnt=$((cnt + tmpcnt))
3763 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
3764 count_flvr "$output" $flavor
3769 local dir=$1 # from to
3770 local flavor=$2 # flavor expected
3773 if [ $dir == "cli2mdt" ]; then
3774 res=`flvr_cnt_cli2mdt $flavor`
3775 elif [ $dir == "cli2ost" ]; then
3776 res=`flvr_cnt_cli2ost $flavor`
3777 elif [ $dir == "mdt2mdt" ]; then
3778 res=`flvr_cnt_mdt2mdt $flavor`
3779 elif [ $dir == "mdt2ost" ]; then
3780 res=`flvr_cnt_mdt2ost $flavor`
3781 elif [ $dir == "all2ost" ]; then
3782 res1=`flvr_cnt_mdt2ost $flavor`
3783 res2=`flvr_cnt_cli2ost $flavor`
3784 res=$((res1 + res2))
3785 elif [ $dir == "all2mdt" ]; then
3786 res1=`flvr_cnt_mdt2mdt $flavor`
3787 res2=`flvr_cnt_cli2mdt $flavor`
3788 res=$((res1 + res2))
3789 elif [ $dir == "all2all" ]; then
3790 res1=`flvr_cnt_mdt2ost $flavor`
3791 res2=`flvr_cnt_cli2ost $flavor`
3792 res3=`flvr_cnt_mdt2mdt $flavor`
3793 res4=`flvr_cnt_cli2mdt $flavor`
3794 res=$((res1 + res2 + res3 + res4))
3802 local dir=$1 # from to
3803 local flavor=$2 # flavor expected
3804 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
3808 for ((i=0;i<20;i++)); do
3809 echo -n "checking..."
3810 res=$(do_check_flavor $dir $flavor)
3811 if [ $res -eq $expect ]; then
3812 echo "found $res $flavor connections of $dir, OK"
3815 echo "found $res $flavor connections of $dir, not ready ($expect)"
3820 echo "Error checking $flavor of $dir: expect $expect, actual $res"
3824 restore_to_default_flavor()
3826 local proc="mgs.MGS.live.$FSNAME"
3828 echo "restoring to default flavor..."
3830 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3832 # remove all existing rules if any
3833 if [ $nrule -ne 0 ]; then
3834 echo "$nrule existing rules"
3835 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
3836 echo "remove rule: $rule"
3837 spec=`echo $rule | awk -F = '{print $1}'`
3838 do_facet mgs "$LCTL conf_param $spec="
3842 # verify no rules left
3843 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3844 [ $nrule -ne 0 ] && error "still $nrule rules left"
3846 # wait for default flavor to be applied
3847 # currently default flavor for all connections are 'null'
3848 wait_flavor all2all null
3849 echo "now at default flavor settings"
3854 local flavor=${1:-null}
3856 echo "setting all flavor to $flavor"
3858 # FIXME need parameter to this fn
3859 # and remove global vars
3860 local cnt_all2all=$(calc_connection_cnt all2all)
3862 local res=$(do_check_flavor all2all $flavor)
3863 if [ $res -eq $cnt_all2all ]; then
3864 echo "already have total $res $flavor connections"
3868 echo "found $res $flavor out of total $cnt_all2all connections"
3869 restore_to_default_flavor
3871 [[ $flavor = null ]] && return 0
3873 set_rule $FSNAME any any $flavor
3874 wait_flavor all2all $flavor
3880 # Checking for shared logdir
3881 if [ ! -d $dir ]; then
3882 # Not found. Create local logdir
3885 touch $dir/node.$(hostname).yml
3890 check_write_access() {
3892 for node in $(nodes_list); do
3893 if [ ! -f "$dir/node.${node}.yml" ]; then
3894 # Logdir not accessible/writable from this node.
3902 if [[ -n $YAML_LOG ]]; then
3905 export YAML_LOG=${LOGDIR}/results.yml
3909 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
3910 if check_write_access $LOGDIR; then
3911 touch $LOGDIR/shared
3912 echo "Logging to shared log directory: $LOGDIR"
3914 echo "Logging to local directory: $LOGDIR"
3917 yml_nodes_file $LOGDIR
3918 yml_results_file >> $YAML_LOG
3922 yml_log_test $1 >> $YAML_LOG
3926 yml_log_sub_test $@ >> $YAML_LOG
3932 local devname=$(basename $1)
3933 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
3934 size=$(($size / 1024 / 1024)) # Gb
3936 local partial_arg=""
3937 # Run in partial (fast) mode if the size
3938 # of a partition > 10 GB
3939 [ $size -gt 10 ] && partial_arg="-p"
3941 llverdev --force $partial_arg $dev