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}
14 #export PDSH="pdsh -S -Rssh -w"
16 # function used by scripts run on remote nodes
17 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
18 . $LUSTRE/tests/functions.sh
20 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
22 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
24 if [ -f "$EXCEPT_LIST_FILE" ]; then
25 echo "Reading test skip list from $EXCEPT_LIST_FILE"
32 [[ $DIR/ = $MOUNT/* ]] || \
33 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
34 [[ $DIR1/ = $MOUNT1/* ]] || \
35 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
36 [[ $DIR2/ = $MOUNT2/* ]] || \
37 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
39 [ -n "$failed" ] && exit 99 || true
43 echo "usage: $0 [-r] [-f cfgfile]"
51 [ "$TESTSUITE" == "lfscktest" ] && return 0
52 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
53 local form="%-13s %-17s %s\n"
54 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
55 echo "------------------------------------------------------------------------------------"
56 for O in $TESTSUITE_LIST; do
59 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
62 local log=${TMP}/${o}.log
63 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
64 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
65 [ "${!O}" = "done" ] && \
66 printf "$form" "Done" "$O" "E=$skipped" && \
67 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
71 for O in $TESTSUITE_LIST; do
72 if [ "${!O}" = "no" ]; then
74 # only for those tests suits which are run directly from acc-sm script:
75 # bonnie, iozone, etc.
76 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
77 printf "$form" "UNFINISHED" "$O" ""
79 printf "$form" "Skipped" "$O" ""
84 for O in $TESTSUITE_LIST; do
85 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
86 printf "$form" "UNFINISHED" "$O" ""
91 export LUSTRE=`absolute_path $LUSTRE`
92 export TESTSUITE=`basename $0 .sh`
93 export TEST_FAILED=false
94 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
96 export MKE2FS=${MKE2FS:-mke2fs}
97 export DEBUGFS=${DEBUGFS:-debugfs}
98 export TUNE2FS=${TUNE2FS:-tune2fs}
99 export E2LABEL=${E2LABEL:-e2label}
100 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
101 export E2FSCK=${E2FSCK:-e2fsck}
103 #[ -d /r ] && export ROOT=${ROOT:-/r}
104 export TMP=${TMP:-$ROOT/tmp}
105 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
106 export HOSTNAME=${HOSTNAME:-`hostname`}
107 if ! echo $PATH | grep -q $LUSTRE/utils; then
108 export PATH=$PATH:$LUSTRE/utils
110 if ! echo $PATH | grep -q $LUSTRE/test; then
111 export PATH=$PATH:$LUSTRE/tests
113 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
114 [ ! -f "$LST" ] && export LST=$(which lst)
115 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
116 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
117 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
118 export PATH=$PATH:$LUSTRE/tests/racer
120 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
121 export PATH=$PATH:$LUSTRE/tests/mpi
123 export RSYNC_RSH=${RSYNC_RSH:-rsh}
124 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
125 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
126 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
127 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
128 [ ! -f "$LFS" ] && export LFS=$(which lfs)
129 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
130 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
131 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
132 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
133 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
134 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
135 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
136 export FSTYPE=${FSTYPE:-"ldiskfs"}
137 export NAME=${NAME:-local}
139 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
141 if [ "$ACCEPTOR_PORT" ]; then
142 export PORT_OPT="--port $ACCEPTOR_PORT"
145 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
147 # Paths on remote nodes, if different
148 export RLUSTRE=${RLUSTRE:-$LUSTRE}
149 export RPWD=${RPWD:-$PWD}
150 export I_MOUNTED=${I_MOUNTED:-"no"}
151 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
152 ! -f `dirname $0`/../mds/mds.ko ]; then
153 export CLIENTMODSONLY=yes
158 while getopts "rvwf:" opt $*; do
161 r) REFORMAT=--reformat;;
163 w) WRITECONF=writeconf;;
168 shift $((OPTIND - 1))
171 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
176 *) EXT=".ko"; USE_QUOTA=yes;;
180 do_facet mgs lctl pool_list $1
184 local fsname=${1%%.*}
185 local poolname=${1##$fsname.}
187 do_facet mgs lctl pool_new $1
189 # get param should return err unless pool is created
190 [[ $RC -ne 0 ]] && return $RC
192 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
193 2>/dev/null || echo foo" "" || RC=1
194 if [[ $RC -eq 0 ]]; then
197 error "pool_new failed $1"
202 add_pool_to_list () {
203 local fsname=${1%%.*}
204 local poolname=${1##$fsname.}
206 local listvar=${fsname}_CREATED_POOLS
207 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
210 remove_pool_from_list () {
211 local fsname=${1%%.*}
212 local poolname=${1##$fsname.}
214 local listvar=${fsname}_CREATED_POOLS
215 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
219 /sbin/lsmod | grep -q $1
225 BASE=`basename $module $EXT`
227 module_loaded ${BASE} && return
229 if [ "$BASE" == "lnet_selftest" ] && \
230 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
231 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
233 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
234 insmod ${LUSTRE}/${module}${EXT} $@
236 # must be testing a "make install" or "rpm" installation
241 load_modules_local() {
242 if [ -n "$MODPROBE" ]; then
246 if [ "$HAVE_MODULES" = true ]; then
252 echo Loading modules from $LUSTRE
253 load_module ../lnet/libcfs/libcfs
254 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
255 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
257 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
258 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
259 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
260 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
261 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
263 # disable it for now since it only hides the stack overflow upon test w/
265 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
266 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
267 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
269 echo "lnet options: '$LNETOPTS'"
270 # note that insmod will ignore anything in modprobe.conf
271 load_module ../lnet/lnet/lnet $LNETOPTS
272 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
273 load_module ../lnet/klnds/$LNETLND
274 load_module lvfs/lvfs
275 load_module obdclass/obdclass
276 load_module ptlrpc/ptlrpc
277 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
282 if ! client_only; then
285 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
286 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
287 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
288 load_module lvfs/fsfilt_$FSTYPE
290 load_module obdfilter/obdfilter
293 load_module llite/lustre
294 load_module llite/llite_lloop
295 rm -f $TMP/ogdb-$HOSTNAME
297 [ -d /r ] && OGDB="/r/tmp"
298 $LCTL modules > $OGDB/ogdb-$HOSTNAME
299 # 'mount' doesn't look in $PATH, just sbin
300 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
306 # load modules on remote nodes optionally
307 # lustre-tests have to be installed on these nodes
308 if $LOAD_MODULES_REMOTE ; then
309 local list=$(comma_list $(remote_nodes_list))
310 echo loading modules on $list
311 do_rpc_nodes $list load_modules
316 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
317 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
318 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
319 echo "$LEAK_LUSTRE" 1>&2
320 echo "$LEAK_PORTALS" 1>&2
321 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
322 echo "Memory leaks detected"
323 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
329 wait_exit_ST client # bug 12845
331 if $LOAD_MODULES_REMOTE ; then
332 local list=$(comma_list $(remote_nodes_list))
333 if [ ! -z $list ]; then
334 echo unloading modules on $list
335 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
336 do_rpc_nodes $list check_mem_leak
340 $LUSTRE_RMMOD $FSTYPE || return 2
344 check_mem_leak || return 254
346 echo "modules unloaded."
354 local dev=$(facet_active $facet)_dev
355 local opt=${facet}_opt
356 local mntpt=$(facet_mntpt $facet)
358 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
359 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} $mntpt
361 if [ $RC -ne 0 ]; then
362 echo "mount -t lustre $@ ${!dev} $mntpt"
363 echo "Start of ${!dev} on ${facet} failed ${RC}"
365 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
366 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
367 lctl set_param debug_mb=${DEBUG_SIZE}; \
370 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
371 [ -z "$label" ] && echo no label for ${!dev} && exit 1
372 eval export ${facet}_svc=${label}
373 echo Started ${label}
378 # start facet device options
384 eval export ${facet}_dev=${device}
385 eval export ${facet}_opt=\"$@\"
387 local varname=${facet}failover_dev
388 if [ -n "${!varname}" ] ; then
389 eval export ${facet}failover_dev=${!varname}
391 eval export ${facet}failover_dev=$device
394 local mntpt=$(facet_mntpt $facet)
395 do_facet ${facet} mkdir -p $mntpt
396 eval export ${facet}_MOUNT=$mntpt
406 local HOST=`facet_active_host $facet`
407 [ -z $HOST ] && echo stop: no host for $facet && return 0
409 local mntpt=$(facet_mntpt $facet)
410 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
411 if [ ${running} -ne 0 ]; then
412 echo "Stopping $mntpt (opts:$@)"
413 do_facet ${facet} umount -d $@ $mntpt
416 # umount should block, but we should wait for unrelated obd's
417 # like the MGS or MGC to also stop.
419 wait_exit_ST ${facet}
422 # set quota version (both administrative and operational quotas)
423 quota_set_version() {
424 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
426 local osts=$(get_facets OST)
427 for ost in ${osts//,/ }; do
429 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
433 # save quota version (both administrative and operational quotas)
434 # the function will also switch to the new version and the new type
435 quota_save_version() {
437 local ver=$(tr -c -d "123" <<< $spec)
438 local type=$(tr -c -d "ug" <<< $spec)
440 local lustre_version=$(get_lustre_version mds)
441 if [[ $lustre_version = 1.8* ]] ; then
442 $LFS quotaoff -ug $MOUNT # just in case
443 [ -n "$ver" ] && quota_set_version $ver
445 echo mds running $lustre_version
446 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
449 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
451 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.$(get_md_name).quota_type=$spec"
453 local osts=$(get_facets OST)
454 for ost in ${osts//,/ }; do
456 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
460 # client could mount several lustre
462 local fsname=${1:-$FSNAME}
464 do_facet mgs lctl get_param md*.${fsname}-MDT*.quota_type || rc=$?
465 do_nodes $(comma_list $(osts_nodes)) \
466 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
470 restore_quota_type () {
471 local mntpt=${1:-$MOUNT}
472 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
473 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
476 quota_save_version $old_QUOTA_TYPE
483 # 1. run quotacheck only if quota is off
484 # 2. save the original quota_type params, restore them after testing
486 # Suppose that quota type the same on mds and ost
487 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
488 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
489 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
490 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
491 export old_QUOTA_TYPE=$quota_type
492 quota_save_version $QUOTA_TYPE
495 local quota_usrs=$QUOTA_USERS
497 # get_filesystem_size
498 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
499 local blk_soft=$((disksz + 1024))
500 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
502 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
504 local i_hard=$((i_soft + i_soft / 20))
506 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
507 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
510 for usr in $quota_usrs; do
511 echo "Setting up quota on $client:$mntpt for $usr..."
513 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
515 eval $cmd || error "$cmd FAILED!"
517 # display the quota status
518 echo "Quota settings for $usr : "
519 $LFS quota -v -u $usr $mntpt || true
527 # Only supply -o to mount if we have options
528 if [ -n "$MOUNTOPT" ]; then
529 OPTIONS="-o $MOUNTOPT"
531 local device=$MGSNID:/$FSNAME
532 if [ -z "$mnt" -o -z "$FSNAME" ]; then
533 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
537 echo "Starting client: $client: $OPTIONS $device $mnt"
538 do_node $client mkdir -p $mnt
539 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
540 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
541 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
542 lctl set_param debug_mb=${DEBUG_SIZE}"
555 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
556 if [ $running -ne 0 ]; then
557 echo "Stopping client $client $mnt (opts:$force)"
558 do_node $client lsof -t $mnt || need_kill=no
559 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
560 pids=$(do_node $client lsof -t $mnt | sort -u);
561 if [ -n $pids ]; then
562 do_node $client kill -9 $pids || true
566 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
567 if [ $busy -ne 0 ] ; then
568 echo "$mnt is still busy, wait one second" && sleep 1
569 do_node $client umount $force $mnt
574 # nodes is comma list
575 sanity_mount_check_nodes () {
581 # FIXME: assume that all cluster nodes run the same os
582 [ "$(uname)" = Linux ] || return 0
585 for mnt in $mnts ; do
586 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
587 mpts=\\\$(mount | grep -w -c $mnt);
588 if [ \\\$running -ne \\\$mpts ]; then
589 echo \\\$(hostname) env are INSANE!;
597 sanity_mount_check_servers () {
599 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
600 echo Checking servers environments
602 # FIXME: modify get_facets to display all facets wo params
603 local facets="$(get_facets OST),$(get_facets MDS),mgs"
607 for facet in ${facets//,/ }; do
608 node=$(facet_host ${facet})
609 mntpt=$(facet_mntpt $facet)
610 sanity_mount_check_nodes $node $mntpt ||
611 { error "server $node environments are insane!"; return 1; }
615 sanity_mount_check_clients () {
616 local clients=${1:-$CLIENTS}
617 local mntpt=${2:-$MOUNT}
618 local mntpt2=${3:-$MOUNT2}
620 [ -z $clients ] && clients=$(hostname)
621 echo Checking clients $clients environments
623 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
624 error "clients environments are insane!"
627 sanity_mount_check () {
628 sanity_mount_check_servers || return 1
629 sanity_mount_check_clients || return 2
632 # mount clients if not mouted
633 zconf_mount_clients() {
636 local OPTIONS=${3:-$MOUNTOPT}
638 # Only supply -o to mount if we have options
639 if [ "$OPTIONS" ]; then
640 OPTIONS="-o $OPTIONS"
642 local device=$MGSNID:/$FSNAME
643 if [ -z "$mnt" -o -z "$FSNAME" ]; then
644 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
648 echo "Starting client $clients: $OPTIONS $device $mnt"
651 running=\\\$(mount | grep -c $mnt' ');
653 if [ \\\$running -eq 0 ] ; then
655 mount -t lustre $OPTIONS $device $mnt;
660 echo "Started clients $clients: "
661 do_nodes $clients "mount | grep -w $mnt"
663 do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
664 sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
665 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
670 zconf_umount_clients() {
677 echo "Stopping clients: $clients $mnt (opts:$force)"
678 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
679 if [ \\\$running -ne 0 ] ; then
680 echo Stopping client \\\$(hostname) $mnt opts:$force;
681 lsof -t $mnt || need_kill=no;
682 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
683 pids=\\\$(lsof -t $mnt | sort -u);
684 if [ -n \\\"\\\$pids\\\" ]; then
688 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
689 if [ \\\$busy -ne 0 ] ; then
690 echo "$mnt is still busy, wait one second" && sleep 1;
696 shudown_node_hard () {
700 for i in $(seq $attempts) ; do
703 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
704 echo "waiting for $host to fail attempts=$attempts"
705 [ $i -lt $attempts ] || \
706 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
712 local mnt=${2:-$MOUNT}
715 if [ "$FAILURE_MODE" = HARD ]; then
716 shudown_node_hard $client
718 zconf_umount_clients $client $mnt -f
724 if [ "$FAILURE_MODE" = HARD ]; then
725 shudown_node_hard $(facet_active_host $facet)
726 elif [ "$FAILURE_MODE" = SOFT ]; then
733 if [ "$FAILURE_MODE" = HARD ]; then
734 $POWER_UP `facet_active_host $facet`
742 if [ "$FAILURE_MODE" = HARD ]; then
748 # recovery-scale functions
749 check_progs_installed () {
754 do_nodes $clients "PATH=:$PATH; status=true;
755 for prog in $progs; do
756 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
757 echo \\\$prog missing on \\\$(hostname);
765 echo __$(echo $1 | tr '-' 'X')
768 start_client_load() {
771 local var=$(client_var_name $client)_load
772 eval export ${var}=$load
774 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
775 BREAK_ON_ERROR=$BREAK_ON_ERROR \
776 END_RUN_FILE=$END_RUN_FILE \
777 LOAD_PID_FILE=$LOAD_PID_FILE \
778 TESTSUITELOG=$TESTSUITELOG \
780 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
781 log "Started client load: ${load} on $client"
786 start_client_loads () {
787 local -a clients=(${1//,/ })
788 local numloads=${#CLIENT_LOADS[@]}
791 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
792 testnum=$((nodenum % numloads))
793 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
795 # bug 22169: wait the background threads to start
799 # only for remote client
800 check_client_load () {
802 local var=$(client_var_name $client)_load
803 local TESTLOAD=run_${!var}.sh
805 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
807 # bug 18914: try to connect several times not only when
808 # check ps, but while check_catastrophe also
811 while [ $RC = 254 -a $tries -gt 0 ]; do
815 if ! check_catastrophe $client; then
817 if [ $RC -eq 254 ]; then
818 # FIXME: not sure how long we shuold sleep here
822 echo "check catastrophe failed: RC=$RC "
827 # We can continue try to connect if RC=254
828 # Just print the warning about this
829 if [ $RC = 254 ]; then
830 echo "got a return status of $RC from do_node while checking catastrophe on $client"
833 # see if the load is still on the client
836 while [ $RC = 254 -a $tries -gt 0 ]; do
840 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
845 if [ $RC = 254 ]; then
846 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
847 # see if we can diagnose a bit why this is
852 check_client_loads () {
853 local clients=${1//,/ }
857 for client in $clients; do
858 check_client_load $client
860 if [ "$rc" != 0 ]; then
861 log "Client load failed on node $client, rc=$rc"
867 restart_client_loads () {
868 local clients=${1//,/ }
869 local expectedfail=${2:-""}
873 for client in $clients; do
874 check_client_load $client
876 if [ "$rc" != 0 -a "$expectedfail" ]; then
877 local var=$(client_var_name $client)_load
878 start_client_load $client ${!var}
879 echo "Restarted client load ${!var}: on $client. Checking ..."
880 check_client_load $client
882 if [ "$rc" != 0 ]; then
883 log "Client load failed to restart on node $client, rc=$rc"
884 # failure one client load means test fail
885 # we do not need to check other
893 # End recovery-scale functions
895 # verify that lustre actually cleaned up properly
897 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
898 error "LBUG/LASSERT detected"
899 BUSY=`dmesg | grep -i destruct || true`
902 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
906 check_mem_leak || exit 204
908 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
909 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
911 if module_loaded lnet || module_loaded libcfs; then
912 echo "$0: modules still loaded..." 1>&2
929 RESULT=$(do_node $node "$TEST")
930 if [ "$RESULT" == "$FINAL" ]; then
931 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
934 [ $WAIT -ge $MAX ] && break
935 echo "Waiting $((MAX - WAIT)) secs for update"
936 WAIT=$((WAIT + sleep))
939 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
943 wait_update_facet () {
946 wait_update $(facet_active_host $facet) "$@"
949 wait_delete_completed () {
950 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
951 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
955 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
957 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
958 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
959 [ "$TOTAL" -eq "$TOTALPREV" ] && break
960 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
964 echo "Delete completed."
969 check_network "$host" 900
970 while ! do_node $host hostname > /dev/null; do sleep 5; done
975 local host=`facet_active_host $facet`
979 wait_recovery_complete () {
982 # Use default policy if $2 is not passed by caller.
983 local MAX=${2:-$(max_recovery_time)}
985 local var_svc=${facet}_svc
986 local procfile="*.${!var_svc}.recovery_status"
990 while [ $WAIT -lt $MAX ]; do
991 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
992 [[ $STATUS = "status: COMPLETE" ]] && return 0
995 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
997 echo "$facet recovery not done in $MAX sec. $STATUS"
1007 # conf-sanity 31 takes a long time cleanup
1008 while [ $WAIT -lt 300 ]; do
1009 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1010 [ -z "${running}" ] && return 0
1011 echo "waited $WAIT for${running}"
1012 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1014 WAIT=$((WAIT + INTERVAL))
1016 echo "service didn't stop after $WAIT seconds. Still running:"
1021 wait_remote_prog () {
1027 [ "$PDSH" = "no_dsh" ] && return 0
1029 while [ $WAIT -lt $2 ]; do
1030 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1031 [ -z "${running}" ] && return 0 || true
1032 echo "waited $WAIT for: "
1034 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1036 WAIT=$((WAIT + INTERVAL))
1038 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1039 [ -z "$pids" ] && return 0
1040 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1041 # FIXME: not portable
1042 for pid in $pids; do
1043 cat /proc/${pid}/status || true
1044 cat /proc/${pid}/wchan || true
1046 kill -9 $pid || true
1055 # not every config has many clients
1057 if [ -n "$CLIENTS" ]; then
1058 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1060 stat -f $MOUNT > /dev/null
1066 # usually checked on particular client or locally
1068 if [ ! -z "$client" ]; then
1069 $PDSH $client "stat -f $MOUNT" > /dev/null
1071 stat -f $MOUNT > /dev/null
1079 client_reconnect() {
1080 uname -n >> $MOUNT/recon
1081 if [ -z "$CLIENTS" ]; then
1082 df $MOUNT; uname -n >> $MOUNT/recon
1084 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1086 echo Connected clients:
1088 ls -l $MOUNT/recon > /dev/null
1095 echo "Failing $facet on node `facet_active_host $facet`"
1096 shutdown_facet $facet
1097 [ -n "$sleep_time" ] && sleep $sleep_time
1101 RECOVERY_START_TIME=`date +%s`
1102 echo "df pid is $DFPID"
1103 change_active $facet
1104 local TO=`facet_active_host $facet`
1105 echo "Failover $facet to $TO"
1107 mount_facet $facet || error "Restart of $facet failed"
1116 do_facet $facet sync
1118 local svc=${facet}_svc
1119 do_facet $facet $LCTL --device %${!svc} notransno
1120 do_facet $facet $LCTL --device %${!svc} readonly
1121 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1122 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1125 replay_barrier_nodf() {
1126 local facet=$1 echo running=${running}
1127 do_facet $facet sync
1128 local svc=${facet}_svc
1129 echo Replay barrier on ${!svc}
1130 do_facet $facet $LCTL --device %${!svc} notransno
1131 do_facet $facet $LCTL --device %${!svc} readonly
1132 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1133 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1136 mds_evict_client() {
1137 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1138 local mdtdevice=$(get_mds_mdt_device_proc_path)
1139 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1142 ost_evict_client() {
1143 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1144 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1148 facet_failover $* || error "failover: $?"
1149 clients_up || error "post-failover df: $?"
1154 facet_failover $facet
1160 change_active $facet
1161 mount_facet $facet -o abort_recovery
1162 clients_up || echo "first df failed: $?"
1163 clients_up || error "post-failover df: $?"
1167 echo There is no lmc. This is mountconf, baby.
1172 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1173 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1179 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1185 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1186 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1187 if [ -z "$ID" ]; then
1188 echo "Could not get a ptl id for $1..."
1197 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1204 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1205 if type __h2elan >/dev/null 2>&1; then
1208 ID=`echo $1 | sed 's/[^0-9]*//g'`
1216 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1217 ID=`echo $1 | sed 's/[^0-9]*//g'`
1221 declare -fx h2openib
1224 h2name_or_ip "$1" "o2ib"
1231 [ "$facet" == client ] && echo -n $HOSTNAME && return
1232 varname=${facet}_HOST
1233 if [ -z "${!varname}" ]; then
1234 if [ "${facet:0:3}" == "ost" ]; then
1235 eval ${facet}_HOST=${ost_HOST}
1243 local activevar=${facet}active
1245 if [ -f $TMP/${facet}active ] ; then
1246 source $TMP/${facet}active
1249 active=${!activevar}
1250 if [ -z "$active" ] ; then
1257 facet_active_host() {
1259 local active=`facet_active $facet`
1260 if [ "$facet" == client ]; then
1263 echo `facet_host $active`
1269 local failover=${facet}failover
1270 host=`facet_host $failover`
1271 [ -z "$host" ] && return
1272 local curactive=`facet_active $facet`
1273 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1274 eval export ${facet}active=$facet
1276 eval export ${facet}active=$failover
1278 # save the active host for this facet
1279 local activevar=${facet}active
1280 echo "$activevar=${!activevar}" > $TMP/$activevar
1285 # do not stripe off hostname if verbose, bug 19215
1286 if [ x$1 = x--verbose ]; then
1294 if [ "$HOST" = "$HOSTNAME" ]; then
1296 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1297 echo "cannot run remote command on $HOST with $myPDSH"
1301 echo "CMD: $HOST $@" >&2
1302 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1305 if [ "$myPDSH" = "rsh" ]; then
1306 # we need this because rsh does not return exit code of an executed command
1307 local command_status="$TMP/cs"
1308 rsh $HOST ":> $command_status"
1309 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1310 cd $RPWD; sh -c \"$@\") ||
1311 echo command failed >$command_status"
1312 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1317 # print HOSTNAME for myPDSH="no_dsh"
1318 if [[ $myPDSH = no_dsh ]]; then
1319 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1321 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1324 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1326 return ${PIPESTATUS[0]}
1330 do_node --verbose "$@"
1333 single_local_node () {
1334 [ "$1" = "$HOSTNAME" ]
1339 # do not stripe off hostname if verbose, bug 19215
1340 if [ x$1 = x--verbose ]; then
1348 if $(single_local_node $rnodes); then
1350 do_nodev $rnodes "$@"
1352 do_node $rnodes "$@"
1357 # This is part from do_node
1360 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1361 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1364 echo "CMD: $rnodes $@" >&2
1365 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1369 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1371 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1373 return ${PIPESTATUS[0]}
1379 local HOST=`facet_active_host $facet`
1380 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1385 do_nodes --verbose "$@"
1391 # make sure its not already running
1393 rm -f $TMP/${facet}active
1394 do_facet ${facet} $MKFS $*
1400 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1401 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1407 if combined_mgs_mds && [[ $facet = "mgs" ]] ; then
1410 local var=${facet}_MOUNT
1411 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1420 # make sure we are using the primary server, so test-framework will
1421 # be able to clean up properly.
1422 activemds=`facet_active mds`
1423 if [ $activemds != "mds" ]; then
1427 local clients=$CLIENTS
1428 [ -z $clients ] && clients=$(hostname)
1430 zconf_umount_clients $clients $MOUNT "$*" || true
1431 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1433 [ "$CLIENTONLY" ] && return
1434 # The add fn does rm ${facet}active file, this would be enough
1435 # if we use do_facet <facet> only after the facet added, but
1436 # currently we use do_facet mds in local.sh
1438 rm -f ${TMP}/mdsactive
1439 for num in `seq $OSTCOUNT`; do
1441 rm -f $TMP/ost${num}active
1443 if ! combined_mgs_mds ; then
1451 nfs_client_mode && return
1457 combined_mgs_mds () {
1458 [[ $MDSDEV = $MGSDEV ]] && [[ $mds_HOST = $mgs_HOST ]]
1462 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1465 # We need ldiskfs here, may as well load them all
1467 [ "$CLIENTONLY" ] && return
1468 echo Formatting mgs, mds, osts
1469 if ! combined_mgs_mds ; then
1470 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1474 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
1476 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1479 for num in `seq $OSTCOUNT`; do
1481 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1483 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1489 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1494 zconf_umount `hostname` $1 || error "umount failed"
1495 zconf_mount `hostname` $1 || error "mount failed"
1498 writeconf_facet () {
1502 do_facet $facet "$TUNEFS --writeconf $dev"
1506 writeconf_facet mds $MDSDEV
1508 for num in `seq $OSTCOUNT`; do
1509 DEVNAME=`ostdevname $num`
1510 writeconf_facet ost$num $DEVNAME
1515 nfs_client_mode && return
1517 sanity_mount_check ||
1518 error "environments are insane!"
1521 if [ -z "$CLIENTONLY" ]; then
1522 echo Setup mgs, mdt, osts
1524 echo $WRITECONF | grep -q "writeconf" && \
1527 if ! combined_mgs_mds ; then
1528 start mgs $MGSDEV $mgs_MOUNT_OPTS
1531 start mds $MDSDEV $MDS_MOUNT_OPTS
1532 # We started mds, now we should set failover variable properly.
1533 # Set mdsfailover_HOST if it is not set (the default failnode).
1534 if [ -z "$mdsfailover_HOST" ]; then
1535 mdsfailover_HOST=$(facet_host mds)
1538 for num in `seq $OSTCOUNT`; do
1539 DEVNAME=`ostdevname $num`
1540 start ost$num $DEVNAME $OST_MOUNT_OPTS
1542 # We started ost$num, now we should set ost${num}failover variable properly.
1543 # Set ost${num}failover_HOST if it is not set (the default failnode).
1544 varname=ost${num}failover_HOST
1545 if [ -z "${!varname}" ]; then
1546 eval ost${num}failover_HOST=$(facet_host ost${num})
1551 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1553 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1555 if [ "$MOUNT_2" ]; then
1556 mount_client $MOUNT2
1557 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1563 mounted_lustre_filesystems() {
1564 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1567 init_facet_vars () {
1568 [ "$CLIENTONLY" ] && return 0
1575 eval export ${facet}_dev=${device}
1576 eval export ${facet}_opt=\"$@\"
1578 local dev=${facet}_dev
1579 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1580 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1582 eval export ${facet}_svc=${label}
1584 local varname=${facet}failover_HOST
1585 if [ -z "${!varname}" ]; then
1586 eval $varname=$(facet_host $facet)
1589 # ${facet}failover_dev is set in cfg file
1590 varname=${facet}failover_dev
1591 if [ -n "${!varname}" ] ; then
1592 eval export ${facet}failover_dev=${!varname}
1594 eval export ${facet}failover_dev=$device
1597 # get mount point of already mounted device
1598 # is facet_dev is already mounted then use the real
1599 # mount point of this facet; otherwise use $(facet_mntpt $facet)
1600 # i.e. ${facet}_MOUNT if specified by user or default
1601 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
1602 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
1603 if [ -z $mntpt ]; then
1604 mntpt=$(facet_mntpt $facet)
1606 eval export ${facet}_MOUNT=$mntpt
1609 init_facets_vars () {
1611 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1613 remote_ost_nodsh && return
1615 for num in `seq $OSTCOUNT`; do
1616 DEVNAME=`ostdevname $num`
1617 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1621 init_param_vars () {
1622 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1623 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1624 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1625 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1629 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1631 log "Using TIMEOUT=$TIMEOUT"
1633 if [ "$ENABLE_QUOTA" ]; then
1634 setup_quota $MOUNT || return 2
1638 nfs_client_mode () {
1639 if [ "$NFSCLIENT" ]; then
1640 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1641 local clients=$CLIENTS
1642 [ -z $clients ] && clients=$(hostname)
1644 # FIXME: remove hostname when 19215 fixed
1645 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1646 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1647 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1653 check_config_client () {
1656 local mounted=$(mount | grep " $mntpt ")
1657 if [ "$CLIENTONLY" ]; then
1659 # CLIENTONLY should not depend on *_HOST settings
1660 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1661 # in theory someone could create a new,
1662 # client-only config file that assumed lustre was already
1663 # configured and didn't set the MGSNID. If MGSNID is not set,
1664 # then we should use the mgs nid currently being used
1665 # as the default value. bug 18021
1666 [[ x$MGSNID = x ]] &&
1669 if [[ x$mgc != xMGC$MGSNID ]]; then
1670 if [ "$mgs_HOST" ]; then
1671 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1672 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1673 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1679 local myMGS_host=$mgs_HOST
1680 if [ "$NETTYPE" = "ptl" ]; then
1681 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1684 echo Checking config lustre mounted on $mntpt
1685 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1686 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1688 # if [ "$mgshost" != "$myMGS_host" ]; then
1689 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1690 # Please use correct config or set mds_HOST correctly!"
1695 check_config_clients () {
1696 local clients=${CLIENTS:-$HOSTNAME}
1699 nfs_client_mode && return
1701 do_rpc_nodes $clients check_config_client $mntpt
1703 sanity_mount_check ||
1704 error "environments are insane!"
1708 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
1709 local cltimeout=$(lctl get_param -n timeout)
1710 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1711 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1718 local mounted=$(mounted_lustre_filesystems)
1720 echo $mounted' ' | grep -w -q $mntpt' '
1723 check_and_setup_lustre() {
1724 nfs_client_mode && return
1726 local MOUNTED=$(mounted_lustre_filesystems)
1730 # both MOUNT and MOUNT2 are not mounted
1731 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
1732 [ "$REFORMAT" ] && formatall
1733 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
1735 is_mounted $MOUNT || error "NAME=$NAME not mounted"
1736 export I_MOUNTED=yes
1740 elif is_mounted $MOUNT2; then
1742 # MOUNT2 is mounted, while MOUNT_2 is not set
1743 if ! [ "$MOUNT_2" ]; then
1744 cleanup_mount $MOUNT2
1745 export I_UMOUNTED2=yes
1748 # MOUNT2 is mounted, MOUNT_2 is set
1750 # FIXME: what to do if check_config failed?
1752 # 1) remote client has mounted other Lustre fs ?
1753 # 2) it has insane env ?
1754 # let's try umount MOUNT2 on all clients and mount it again:
1755 if ! check_config_clients $MOUNT2; then
1756 cleanup_mount $MOUNT2
1757 restore_mount $MOUNT2
1758 export I_MOUNTED2=yes
1763 # MOUNT is mounted MOUNT2 is not mounted
1764 elif [ "$MOUNT_2" ]; then
1765 restore_mount $MOUNT2
1766 export I_MOUNTED2=yes
1770 # FIXME: what to do if check_config failed?
1772 # 1) remote client has mounted other Lustre fs?
1773 # 2) lustre is mounted on remote_clients atall ?
1774 check_config_clients $MOUNT
1778 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1779 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1780 lctl set_param debug_mb=${DEBUG_SIZE};
1783 if [ "$ONLY" == "setup" ]; then
1789 local clients=${CLIENTS:-$HOSTNAME}
1792 zconf_mount_clients $clients $mntpt
1796 local clients=${CLIENTS:-$HOSTNAME}
1799 zconf_umount_clients $clients $mntpt
1802 cleanup_and_setup_lustre() {
1803 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1804 lctl set_param debug=0 || true
1806 if [ "$ONLY" == "cleanup" ]; then
1810 check_and_setup_lustre
1813 check_and_cleanup_lustre() {
1814 if is_mounted $MOUNT; then
1815 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1816 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1819 if [ "$I_UMOUNTED2" = "yes" ]; then
1820 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
1823 if [ "$I_MOUNTED2" = "yes" ]; then
1824 cleanup_mount $MOUNT2
1827 if [ "$I_MOUNTED" = "yes" ]; then
1828 cleanupall -f || error "cleanup failed"
1840 while [ $NETWORK -eq 0 ]; do
1841 if ping -c 1 -w 3 $1 > /dev/null; then
1845 echo "waiting for $1, $((MAX - WAIT)) secs left"
1848 if [ $WAIT -gt $MAX ]; then
1849 echo "Network not available"
1855 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1866 # the sed converts spaces to commas, but leaves the last space
1867 # alone, so the line doesn't end with a comma.
1868 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1871 # list, excluded are the comma separated lists
1872 exclude_items_from_list () {
1878 for item in ${excluded//,/ }; do
1879 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1881 echo $(comma_list $list)
1884 # list, expand are the comma separated lists
1886 local list=${1//,/ }
1887 local expand=${2//,/ }
1890 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1891 echo $(comma_list $expanded)
1894 testslist_filter () {
1895 local script=$LUSTRE/tests/${TESTSUITE}.sh
1897 [ -f $script ] || return 0
1899 local start_at=$START_AT
1900 local stop_at=$STOP_AT
1902 local var=${TESTSUITE//-/_}_START_AT
1903 [ x"${!var}" != x ] && start_at=${!var}
1904 var=${TESTSUITE//-/_}_STOP_AT
1905 [ x"${!var}" != x ] && stop_at=${!var}
1907 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
1908 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
1909 /^'${start_at}'$/ {flag = 0}
1910 {if (flag == 1) print $0}
1911 /^'${stop_at}'$/ { flag = 1 }'
1915 (cd `dirname $1`; echo $PWD/`basename $1`)
1919 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1920 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1926 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
1927 list="$list ${name}$i"
1929 * ) error "Invalid facet type"
1932 echo $(comma_list $list)
1935 ##################################
1936 # Adaptive Timeouts funcs
1939 # only check mds, we assume at_max is the same on all nodes
1940 local at_max=$(do_facet mds "lctl get_param -n at_max")
1941 if [ $at_max -eq 0 ]; then
1951 # suppose that all ost-s has the same at_max set
1952 if [ $facet == "ost" ]; then
1953 do_facet ost1 "lctl get_param -n at_max"
1955 do_facet $facet "lctl get_param -n at_max"
1965 if [ $facet == "ost" ]; then
1966 for i in `seq $OSTCOUNT`; do
1967 do_facet ost$i "lctl set_param at_max=$at_max"
1970 do_facet $facet "lctl set_param at_max=$at_max"
1975 ##################################
1979 # OBD_FAIL_MDS_ALL_REQUEST_NET
1981 do_facet mds lctl set_param fail_loc=0x123
1982 do_facet client "$1" || RC=$?
1983 do_facet mds lctl set_param fail_loc=0
1988 # OBD_FAIL_MDS_ALL_REPLY_NET
1990 do_facet mds lctl set_param fail_loc=0x122
1991 do_facet client "$@" || RC=$?
1992 do_facet mds lctl set_param fail_loc=0
1996 drop_reint_reply() {
1997 # OBD_FAIL_MDS_REINT_NET_REP
1999 do_facet mds lctl set_param fail_loc=0x119
2000 do_facet client "$@" || RC=$?
2001 do_facet mds lctl set_param fail_loc=0
2006 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2008 do_facet ost1 lctl set_param fail_loc=0x214
2009 do_facet client "$1" || RC=$?
2010 do_facet client "sync"
2011 do_facet ost1 lctl set_param fail_loc=0
2015 drop_ldlm_cancel() {
2016 #define OBD_FAIL_LDLM_CANCEL 0x304
2018 do_facet client lctl set_param fail_loc=0x304
2019 do_facet client "$@" || RC=$?
2020 do_facet client lctl set_param fail_loc=0
2024 drop_bl_callback() {
2025 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2027 do_facet client lctl set_param fail_loc=0x305
2028 do_facet client "$@" || RC=$?
2029 do_facet client lctl set_param fail_loc=0
2034 #define OBD_FAIL_LDLM_REPLY 0x30c
2036 do_facet mds lctl set_param fail_loc=0x30c
2037 do_facet client "$@" || RC=$?
2038 do_facet mds lctl set_param fail_loc=0
2046 echo "clearing fail_loc on $facet"
2047 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2050 set_nodes_failloc () {
2051 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2054 cancel_lru_locks() {
2055 $LCTL mark "cancel_lru_locks $1 start"
2056 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2057 $LCTL set_param -n $d=clear
2059 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2060 $LCTL mark "cancel_lru_locks $1 stop"
2065 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2066 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2067 echo "$DEFAULT_LRU_SIZE"
2072 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2075 lru_resize_disable()
2077 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2082 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2083 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2084 echo there is still data in page cache $FILE ?
2085 lctl get_param -n $FILE
2092 create_fake_exports () {
2095 #obd_fail_val = num;
2096 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2097 do_facet $facet "lctl set_param fail_val=$num"
2098 do_facet $facet "lctl set_param fail_loc=0x80000708"
2103 DEBUGSAVE="$(lctl get_param -n debug)"
2107 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2111 ##################################
2113 ##################################
2116 local TYPE=${TYPE:-"FAIL"}
2120 # do not dump logs if $1=false
2121 if [ "x$1" = "xfalse" ]; then
2126 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2129 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2130 echo "Dumping lctl log to $ERRLOG"
2131 # We need to dump the logs on all nodes
2132 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2135 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2141 if $FAIL_ON_ERROR; then
2152 # use only if we are ignoring failures for this test, bugno required.
2153 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2154 # e.g. error_ignore 5494 "your message"
2156 local TYPE="IGNORE (bz$1)"
2162 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2166 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2167 [ "$TESTSUITELOG" ] && \
2168 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2171 build_test_filter() {
2172 EXCEPT="$EXCEPT $(testslist_filter)"
2174 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2178 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2179 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2180 [ "$EXCEPT_SLOW" ] && \
2181 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2182 for E in $EXCEPT $ALWAYS_EXCEPT; do
2183 eval EXCEPT_${E}=true
2185 for E in $EXCEPT_SLOW; do
2186 eval EXCEPT_SLOW_${E}=true
2188 for G in $GRANT_CHECK_LIST; do
2189 eval GCHECK_ONLY_${G}=true
2194 if [[ $1 = [a-z]* ]]; then
2201 # print a newline if the last test was skipped
2202 export LAST_SKIPPED=
2206 export base=`basetest $1`
2207 if [ ! -z "$ONLY" ]; then
2209 if [ ${!testname}x != x ]; then
2210 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2215 if [ ${!testname}x != x ]; then
2216 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2225 if [ ${!testname}x != x ]; then
2227 TESTNAME=test_$1 skip "skipping excluded test $1"
2230 testname=EXCEPT_$base
2231 if [ ${!testname}x != x ]; then
2233 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2236 testname=EXCEPT_SLOW_$1
2237 if [ ${!testname}x != x ]; then
2239 TESTNAME=test_$1 skip "skipping SLOW test $1"
2242 testname=EXCEPT_SLOW_$base
2243 if [ ${!testname}x != x ]; then
2245 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2255 EQUALS="======================================================================"
2259 local suffixlen=$((${#EQUALS} - ${#msg}))
2260 [ $suffixlen -lt 5 ] && suffixlen=5
2261 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2266 module_loaded lnet || load_modules
2278 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2283 strace -o $TMP/$1.strace -ttt $*
2285 log "FINISHED: $*: rc $RC"
2290 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2295 FFREE=`lctl get_param -n mds.*.filesfree`
2296 FTOTAL=`lctl get_param -n mds.*.filestotal`
2297 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2301 echo -n "Resetting fail_loc on all nodes..."
2302 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2310 export tdir=d0.${TESTSUITE}/d${base}
2312 local SAVE_UMASK=`umask`
2315 local BEFORE=`date +%s`
2317 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2319 export TESTNAME=test_$testnum
2321 test_${testnum} || error "test_$testnum failed with $?"
2325 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2326 check_catastrophe || error "LBUG/LASSERT detected"
2327 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2328 pass "($((`date +%s` - $BEFORE))s)"
2336 (cd `dirname $1`; echo $PWD/`basename $1`)
2340 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2341 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2346 export base=`basetest $1`
2347 [ "$CHECK_GRANT" == "no" ] && return 0
2349 testname=GCHECK_ONLY_${base}
2350 [ ${!testname}x == x ] && return 0
2352 echo -n "checking grant......"
2354 # write some data to sync client lost_grant
2355 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2356 for i in `seq $OSTCOUNT`; do
2357 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2358 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2359 count=1 > /dev/null 2>&1
2361 # sync all the data and make sure no pending data on server
2364 #get client grant and server grant
2366 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2367 client_grant=$((client_grant + $d))
2370 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2371 server_grant=$((server_grant + $d))
2374 # cleanup the check_grant file
2375 for i in `seq $OSTCOUNT`; do
2376 rm $DIR1/${tfile}_check_grant_$i
2379 #check whether client grant == server grant
2380 if [ $client_grant != $server_grant ]; then
2381 echo "failed: client:${client_grant} server: ${server_grant}"
2388 ########################
2394 ost=`echo $1 | awk -F_ '{print $3}'`
2395 if [ -z $ost ]; then
2396 ost=`echo $1 | sed 's/-osc.*//'`
2403 [ "$node" != "$(hostname)" ]
2408 remote_node $mds_HOST
2413 [ "$CLIENTONLY" ] && return 0 || true
2414 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2420 for node in $(osts_nodes) ; do
2421 remote_node $node && return 0
2428 [ "$CLIENTONLY" ] && return 0 || true
2429 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2435 MGS=$(facet_host mgs)
2436 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2440 remote_ost && remote_mds
2445 remote_mds_nodsh || remote_ost_nodsh || \
2446 $(single_local_node $(comma_list $(nodes_list)))
2450 local OSTNODES=$(facet_host ost1)
2453 for num in `seq $OSTCOUNT`; do
2454 local myOST=$(facet_host ost$num)
2455 OSTNODES="$OSTNODES $myOST"
2457 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2463 # FIXME. We need a list of clients
2464 local myNODES=$HOSTNAME
2467 # CLIENTS (if specified) contains the local client
2468 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2470 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2471 myNODES="$myNODES $(osts_nodes) $mds_HOST"
2474 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2479 remote_nodes_list () {
2480 local rnodes=$(nodes_list)
2481 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2485 init_clients_lists () {
2486 # Sanity check: exclude the local client from RCLIENTS
2487 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2489 # Sanity check: exclude the dup entries
2490 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2492 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2494 # Sanity check: exclude the dup entries from CLIENTS
2495 # for those configs which has SINGLCLIENT set to local client
2496 clients=$(for i in $clients; do echo $i; done | sort -u)
2498 CLIENTS=`comma_list $clients`
2499 local -a remoteclients=($rclients)
2500 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2501 varname=CLIENT$((i + 2))
2502 eval $varname=${remoteclients[i]}
2505 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2508 get_random_entry () {
2511 rnodes=${rnodes//,/ }
2513 local -a nodes=($rnodes)
2514 local num=${#nodes[@]}
2515 local i=$((RANDOM * num * 2 / 65536))
2521 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2526 lctl get_param version | grep -q patchless
2530 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2535 echo $nodes | wc -w || true
2539 local nodes=$(osts_nodes)
2540 local osscount=$(get_node_count "$nodes")
2541 [ ! "$OSTCOUNT" = "$osscount" ]
2544 generate_machine_file() {
2545 local nodes=${1//,/ }
2546 local machinefile=$2
2548 for node in $nodes; do
2549 echo $node >>$machinefile || \
2550 { echo "can not generate machinefile $machinefile" && return 1; }
2555 local file=$1/stripe
2557 $LFS getstripe -v $file || error
2561 setstripe_nfsserver () {
2564 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
2565 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
2567 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
2569 do_nodev $nfsserver lfs setstripe "$@"
2572 check_runas_id_ret() {
2574 local myRUNAS_UID=$1
2575 local myRUNAS_GID=$2
2578 if [ -z "$myRUNAS" ]; then
2579 error_exit "myRUNAS command must be specified for check_runas_id"
2581 mkdir $DIR/d0_runas_test
2583 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2584 if ! $myRUNAS touch $DIR/d0_runas_test/f$$ ; then
2585 do_nodesv $(comma_list $(nodes_list)) grep -w $myRUNAS_UID /etc/passwd
2588 rm -rf $DIR/d0_runas_test
2593 local myRUNAS_UID=$1
2594 local myRUNAS_GID=$2
2597 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2598 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2599 Please set RUNAS_ID to some UID which exists on MDS and client or
2600 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2603 # Run multiop in the background, but wait for it to print
2604 # "PAUSING" to its stdout before returning from this function.
2605 multiop_bg_pause() {
2606 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2610 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2613 echo "$MULTIOP_PROG $FILE v$ARGS"
2614 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2616 echo "TMPPIPE=${TMPPIPE}"
2617 local multiop_output
2619 read -t 60 multiop_output < $TMPPIPE
2620 if [ $? -ne 0 ]; then
2625 if [ "$multiop_output" != "PAUSING" ]; then
2626 echo "Incorrect multiop output: $multiop_output"
2641 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2647 inodes_available () {
2648 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2652 # reset llite stat counters
2653 clear_llite_stats(){
2654 lctl set_param -n llite.*.stats 0
2657 # sum llite stat items
2658 calc_llite_stats() {
2659 local res=$(lctl get_param -n llite.*.stats |
2660 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2665 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2668 calc_osc_kbytes () {
2669 df $MOUNT > /dev/null
2670 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
2673 # save_lustre_params(node, parameter_mask)
2674 # generate a stream of formatted strings (<node> <param name>=<param value>)
2675 save_lustre_params() {
2677 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2680 # restore lustre parameters from input stream, produces by save_lustre_params
2681 restore_lustre_params() {
2685 while IFS=" =" read node name val; do
2686 do_node ${node//:/} "lctl set_param -n $name $val"
2690 check_catastrophe() {
2691 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2692 local C=$CATASTROPHE
2693 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2695 if [ $rnodes ]; then
2696 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2697 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2713 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2715 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2716 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2717 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2721 mdsrate_cleanup () {
2722 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2725 delayed_recovery_enabled () {
2726 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
2729 ################################################################################
2730 # The following functions are used to enable interop testing between
2731 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
2733 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
2734 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
2735 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
2736 ################################################################################
2738 get_lustre_version () {
2739 local node=${1:-"mds"}
2740 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2743 get_mds_version_major () {
2744 local version=$(get_lustre_version mds)
2745 echo $version | awk -F. '{print $1}'
2748 get_mds_version_minor () {
2749 local version=$(get_lustre_version mds)
2750 echo $version | awk -F. '{print $2}'
2753 get_mds_version_patch () {
2754 local version=$(get_lustre_version mds)
2755 echo $version | awk -F. '{print $3}'
2758 get_mds_version_fix () {
2759 local version=$(get_lustre_version mds)
2760 echo $version | awk -F. '{print $4}'
2763 get_mds_fsstat_proc_path() {
2764 local major=$(get_mds_version_major)
2765 local minor=$(get_mds_version_minor)
2766 if [ $major -le 1 -a $minor -le 8 ] ; then
2773 get_mds_mntdev_proc_path() {
2774 local fsstat_dev=$(get_mds_fsstat_proc_path)
2775 echo "$fsstat_dev.*.mntdev"
2778 get_mdtlov_proc_path() {
2780 local major=$(get_mds_version_major)
2781 local minor=$(get_mds_version_minor)
2782 if [ $major -le 1 -a $minor -le 8 ] ; then
2783 echo "${fsname}-mdtlov"
2785 echo "${fsname}-MDT0000-mdtlov"
2789 get_mdtosc_proc_path() {
2791 local major=$(get_mds_version_major)
2792 local minor=$(get_mds_version_minor)
2793 if [ $major -le 1 -a $minor -le 8 ] ; then
2796 echo "${ost}-osc-MDT0000"
2800 get_mds_mdt_device_proc_path() {
2801 local major=$(get_mds_version_major)
2802 local minor=$(get_mds_version_minor)
2803 if [ $major -le 1 -a $minor -le 8 ] ; then
2811 local major=$(get_mds_version_major)
2812 local minor=$(get_mds_version_minor)
2813 if [ $major -le 1 -a $minor -le 8 ] ; then
2820 ########################
2822 convert_facet2label() {
2825 if [ x$facet = xost ]; then
2829 local varsvc=${facet}_svc
2831 if [ -n ${!varsvc} ]; then
2834 error "No lablel for $facet!"
2838 get_clientosc_proc_path() {
2844 get_osc_import_name() {
2847 local label=$(convert_facet2label $ost)
2849 if [ "$facet" == "mds" ]; then
2850 get_mdtosc_proc_path $label
2854 get_clientosc_proc_path $label
2858 wait_import_state () {
2864 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2865 while [ "${CONN_STATE}" != "${expected}" ]; do
2866 if [ "${expected}" == "DISCONN" ]; then
2867 # for disconn we can check after proc entry is removed
2868 [ "x${CONN_STATE}" == "x" ] && return 0
2869 # with AT we can have connect request timeout ~ reconnect timeout
2870 # and test can't see real disconnect
2871 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2873 # disconnect rpc should be wait not more obd_timeout
2874 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2875 error "can't put import for $CONN_PROC into ${expected} state" && return 1
2877 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2881 log "$CONN_PROC now in ${CONN_STATE} state"
2885 wait_osc_import_state() {
2889 local ost=$(get_osc_import_name $facet $ost_facet)
2894 CONN_PROC="osc.${ost}.ost_server_uuid"
2895 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2896 while [ "${CONN_STATE}" != "${expected}" ]; do
2897 if [ "${expected}" == "DISCONN" ]; then
2898 # for disconn we can check after proc entry is removed
2899 [ "x${CONN_STATE}" == "x" ] && return 0
2900 # with AT enabled, we can have connect request timeout near of
2901 # reconnect timeout and test can't see real disconnect
2902 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2904 # disconnect rpc should be wait not more obd_timeout
2905 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2906 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2908 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC | cut -f2)
2912 log "${ost_facet} now in ${CONN_STATE} state"
2916 get_clientmdc_proc_path() {
2924 do_nodesv $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
2927 wait_clients_import_state () {
2933 local label=$(convert_facet2label $facet)
2936 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
2937 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
2938 *) error "unknown facet!" ;;
2941 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
2942 error "import is not in ${expected} state"
2947 destroy_pool_int() {
2949 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
2950 for ost in $OSTS; do
2951 do_facet mgs lctl pool_remove $1 $ost
2953 do_facet mgs lctl pool_destroy $1
2956 # <fsname>.<poolname> or <poolname>
2958 local fsname=${1%%.*}
2959 local poolname=${1##$fsname.}
2961 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
2965 pool_list $fsname.$poolname || return $?
2967 destroy_pool_int $fsname.$poolname
2969 [[ $RC -ne 0 ]] && return $RC
2971 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
2972 2>/dev/null || echo foo" "foo" || RC=1
2974 if [[ $RC -eq 0 ]]; then
2975 remove_pool_from_list $fsname.$poolname
2977 error "destroy pool failed $1"
2983 local fsname=${1:-$FSNAME}
2985 local listvar=${fsname}_CREATED_POOLS
2989 [ x${!listvar} = x ] && return 0
2991 echo destroy the created pools: ${!listvar}
2992 for poolname in ${!listvar//,/ }; do
2993 destroy_pool $fsname.$poolname
2998 local fsname=${1:-$FSNAME}
3000 destroy_pools $fsname
3006 local ts=$(date +%s)
3008 # bug 20237, comment 11
3009 # It would also be useful to provide the option
3010 # of writing the file to an NFS directory so it doesn't need to be copied.
3013 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3015 # dump lustre logs, dmesg
3016 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3017 lctl dk \\\$log >/dev/null;
3018 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3021 # FIXME: does it make sense to collect the logs for $ts only, but all
3023 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3024 local logs=$TMP/'*'${TESTSUITE}'*'
3026 logs=$logs' '$tmp/'*'$ts'*'
3028 for node in ${list//,/ }; do
3029 rsync -az $node:"$logs" $TMP
3032 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3033 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3039 local list=${1:-$(comma_list $(nodes_list))}
3041 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3053 for i in $(seq 0 $num_mntpts); do
3054 cmd="ls -laf ${mntpt_root}$i/$dir"
3060 for pid in $pids; do
3067 # target_start_and_reset_recovery_timer()
3068 # service_time = at_est2timeout(service_time);
3069 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3070 # INITIAL_CONNECT_TIMEOUT);
3071 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3072 #define CONNECTION_SWITCH_INC 1
3073 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3074 #define CONNECTION_SWITCH_MIN 5U
3076 max_recovery_time () {
3077 local init_connect_timeout=$(( TIMEOUT / 20 ))
3078 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
3080 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))