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}
102 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
103 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check filesystem after each test suit
104 export SKIP_LFSCK=${SKIP_LFSCK:-"yes"} # bug 13698, change to "no" when fixed
105 export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
106 export FSCK_MAX_ERR=4 # File system errors left uncorrected
107 if [ "$SKIP_LFSCK" == "no" ]; then
108 if [ ! -x `which $LFSCK_BIN` ]; then
110 error_exit "$E2FSCK does not support lfsck"
113 export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
114 export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
115 export MDSDB_OPT="--mdsdb $MDSDB"
116 export OSTDB_OPT="--ostdb $OSTDB-\$ostidx"
120 #[ -d /r ] && export ROOT=${ROOT:-/r}
121 export TMP=${TMP:-$ROOT/tmp}
122 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
123 export HOSTNAME=${HOSTNAME:-`hostname`}
124 if ! echo $PATH | grep -q $LUSTRE/utils; then
125 export PATH=$PATH:$LUSTRE/utils
127 if ! echo $PATH | grep -q $LUSTRE/test; then
128 export PATH=$PATH:$LUSTRE/tests
130 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
131 [ ! -f "$LST" ] && export LST=$(which lst)
132 export SGPDDSURVEY=${SGPDDSURVEY:-$(which sgpdd-survey)}
133 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
134 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
135 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
136 export PATH=$PATH:$LUSTRE/tests/racer
138 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
139 export PATH=$PATH:$LUSTRE/tests/mpi
141 export RSYNC_RSH=${RSYNC_RSH:-rsh}
142 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
143 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
144 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
145 [ ! -f "$LFS" ] && export LFS=$(which lfs)
146 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
147 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
148 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
149 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
150 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
151 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
152 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
153 export FSTYPE=${FSTYPE:-"ldiskfs"}
154 export NAME=${NAME:-local}
156 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
158 if [ "$ACCEPTOR_PORT" ]; then
159 export PORT_OPT="--port $ACCEPTOR_PORT"
162 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
164 # Paths on remote nodes, if different
165 export RLUSTRE=${RLUSTRE:-$LUSTRE}
166 export RPWD=${RPWD:-$PWD}
167 export I_MOUNTED=${I_MOUNTED:-"no"}
168 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
169 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mds.ko -a \
170 ! -f `dirname $0`/../mds/mds.ko ]; then
171 export CLIENTMODSONLY=yes
176 while getopts "rvwf:" opt $*; do
179 r) REFORMAT=--reformat;;
181 w) WRITECONF=writeconf;;
186 shift $((OPTIND - 1))
189 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
194 *) EXT=".ko"; USE_QUOTA=yes;;
198 do_facet mgs lctl pool_list $1
202 local fsname=${1%%.*}
203 local poolname=${1##$fsname.}
205 do_facet mgs lctl pool_new $1
207 # get param should return err unless pool is created
208 [[ $RC -ne 0 ]] && return $RC
210 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
211 2>/dev/null || echo foo" "" || RC=1
212 if [[ $RC -eq 0 ]]; then
215 error "pool_new failed $1"
220 add_pool_to_list () {
221 local fsname=${1%%.*}
222 local poolname=${1##$fsname.}
224 local listvar=${fsname}_CREATED_POOLS
225 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
228 remove_pool_from_list () {
229 local fsname=${1%%.*}
230 local poolname=${1##$fsname.}
232 local listvar=${fsname}_CREATED_POOLS
233 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
237 /sbin/lsmod | grep -q $1
243 BASE=`basename $module $EXT`
245 module_loaded ${BASE} && return
247 if [ "$BASE" == "lnet_selftest" ] && \
248 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
249 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
251 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
252 insmod ${LUSTRE}/${module}${EXT} $@
254 # must be testing a "make install" or "rpm" installation
259 load_modules_local() {
260 if [ -n "$MODPROBE" ]; then
264 if [ "$HAVE_MODULES" = true ]; then
270 echo Loading modules from $LUSTRE
271 load_module ../lnet/libcfs/libcfs
272 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
273 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
275 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
276 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
277 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
278 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
279 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
281 # disable it for now since it only hides the stack overflow upon test w/
283 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
284 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
285 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
287 echo "lnet options: '$LNETOPTS'"
288 # note that insmod will ignore anything in modprobe.conf
289 load_module ../lnet/lnet/lnet $LNETOPTS
290 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
291 load_module ../lnet/klnds/$LNETLND
292 load_module lvfs/lvfs
293 load_module obdclass/obdclass
294 load_module ptlrpc/ptlrpc
295 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota $LQUOTAOPTS
300 if ! client_only; then
303 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
304 grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
305 grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
306 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
307 load_module lvfs/fsfilt_$FSTYPE
309 load_module obdfilter/obdfilter
312 load_module llite/lustre
313 load_module llite/llite_lloop
314 rm -f $TMP/ogdb-$HOSTNAME
316 [ -d /r ] && OGDB="/r/tmp"
317 $LCTL modules > $OGDB/ogdb-$HOSTNAME
318 # 'mount' doesn't look in $PATH, just sbin
319 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
325 # load modules on remote nodes optionally
326 # lustre-tests have to be installed on these nodes
327 if $LOAD_MODULES_REMOTE ; then
328 local list=$(comma_list $(remote_nodes_list))
329 echo loading modules on $list
330 do_rpc_nodes $list load_modules
335 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
336 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
337 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
338 echo "$LEAK_LUSTRE" 1>&2
339 echo "$LEAK_PORTALS" 1>&2
340 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
341 echo "Memory leaks detected"
342 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
348 wait_exit_ST client # bug 12845
350 if $LOAD_MODULES_REMOTE ; then
351 local list=$(comma_list $(remote_nodes_list))
352 if [ ! -z $list ]; then
353 echo unloading modules on $list
354 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
355 do_rpc_nodes $list check_mem_leak
359 $LUSTRE_RMMOD $FSTYPE || return 2
363 check_mem_leak || return 254
365 echo "modules unloaded."
373 local dev=$(facet_active $facet)_dev
374 local opt=${facet}_opt
375 local mntpt=$(facet_mntpt $facet)
377 echo "Starting ${facet}: ${!opt} $@ ${!dev} $mntpt"
378 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} $mntpt
380 if [ $RC -ne 0 ]; then
381 echo "mount -t lustre $@ ${!dev} $mntpt"
382 echo "Start of ${!dev} on ${facet} failed ${RC}"
384 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
385 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
386 lctl set_param debug_mb=${DEBUG_SIZE}; \
389 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
390 [ -z "$label" ] && echo no label for ${!dev} && exit 1
391 eval export ${facet}_svc=${label}
392 echo Started ${label}
397 # start facet device options
403 eval export ${facet}_dev=${device}
404 eval export ${facet}_opt=\"$@\"
406 local varname=${facet}failover_dev
407 if [ -n "${!varname}" ] ; then
408 eval export ${facet}failover_dev=${!varname}
410 eval export ${facet}failover_dev=$device
413 local mntpt=$(facet_mntpt $facet)
414 do_facet ${facet} mkdir -p $mntpt
415 eval export ${facet}_MOUNT=$mntpt
425 local HOST=`facet_active_host $facet`
426 [ -z $HOST ] && echo stop: no host for $facet && return 0
428 local mntpt=$(facet_mntpt $facet)
429 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
430 if [ ${running} -ne 0 ]; then
431 echo "Stopping $mntpt (opts:$@)"
432 do_facet ${facet} umount -d $@ $mntpt
435 # umount should block, but we should wait for unrelated obd's
436 # like the MGS or MGC to also stop.
438 wait_exit_ST ${facet}
441 # set quota version (both administrative and operational quotas)
442 quota_set_version() {
443 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
445 local osts=$(get_facets OST)
446 for ost in ${osts//,/ }; do
448 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
452 # save quota version (both administrative and operational quotas)
453 # the function will also switch to the new version and the new type
454 quota_save_version() {
456 local ver=$(tr -c -d "123" <<< $spec)
457 local type=$(tr -c -d "ug" <<< $spec)
459 local lustre_version=$(get_lustre_version mds)
460 if [[ $lustre_version = 1.8* ]] ; then
461 $LFS quotaoff -ug $MOUNT # just in case
462 [ -n "$ver" ] && quota_set_version $ver
464 echo mds running $lustre_version
465 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
468 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
470 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.$(get_md_name).quota_type=$spec"
472 local osts=$(get_facets OST)
473 for ost in ${osts//,/ }; do
475 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
479 # client could mount several lustre
481 local fsname=${1:-$FSNAME}
483 do_facet mgs lctl get_param md*.${fsname}-MDT*.quota_type || rc=$?
484 do_nodes $(comma_list $(osts_nodes)) \
485 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
489 restore_quota_type () {
490 local mntpt=${1:-$MOUNT}
491 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
492 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
495 quota_save_version $old_QUOTA_TYPE
502 # 1. run quotacheck only if quota is off
503 # 2. save the original quota_type params, restore them after testing
505 # Suppose that quota type the same on mds and ost
506 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
507 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
508 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
509 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
510 export old_QUOTA_TYPE=$quota_type
511 quota_save_version $QUOTA_TYPE
514 local quota_usrs=$QUOTA_USERS
516 # get_filesystem_size
517 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
518 local blk_soft=$((disksz + 1024))
519 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
521 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
523 local i_hard=$((i_soft + i_soft / 20))
525 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
526 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
529 for usr in $quota_usrs; do
530 echo "Setting up quota on $client:$mntpt for $usr..."
532 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
534 eval $cmd || error "$cmd FAILED!"
536 # display the quota status
537 echo "Quota settings for $usr : "
538 $LFS quota -v -u $usr $mntpt || true
546 # Only supply -o to mount if we have options
547 if [ -n "$MOUNTOPT" ]; then
548 OPTIONS="-o $MOUNTOPT"
550 local device=$MGSNID:/$FSNAME
551 if [ -z "$mnt" -o -z "$FSNAME" ]; then
552 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
556 echo "Starting client: $client: $OPTIONS $device $mnt"
557 do_node $client mkdir -p $mnt
558 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
559 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
560 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
561 lctl set_param debug_mb=${DEBUG_SIZE}"
574 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
575 if [ $running -ne 0 ]; then
576 echo "Stopping client $client $mnt (opts:$force)"
577 do_node $client lsof -t $mnt || need_kill=no
578 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
579 pids=$(do_node $client lsof -t $mnt | sort -u);
580 if [ -n $pids ]; then
581 do_node $client kill -9 $pids || true
585 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
586 if [ $busy -ne 0 ] ; then
587 echo "$mnt is still busy, wait one second" && sleep 1
588 do_node $client umount $force $mnt
593 # nodes is comma list
594 sanity_mount_check_nodes () {
600 # FIXME: assume that all cluster nodes run the same os
601 [ "$(uname)" = Linux ] || return 0
604 for mnt in $mnts ; do
605 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
606 mpts=\\\$(mount | grep -w -c $mnt);
607 if [ \\\$running -ne \\\$mpts ]; then
608 echo \\\$(hostname) env are INSANE!;
616 sanity_mount_check_servers () {
618 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
619 echo Checking servers environments
621 # FIXME: modify get_facets to display all facets wo params
622 local facets="$(get_facets OST),$(get_facets MDS),mgs"
626 for facet in ${facets//,/ }; do
627 node=$(facet_host ${facet})
628 mntpt=$(facet_mntpt $facet)
629 sanity_mount_check_nodes $node $mntpt ||
630 { error "server $node environments are insane!"; return 1; }
634 sanity_mount_check_clients () {
635 local clients=${1:-$CLIENTS}
636 local mntpt=${2:-$MOUNT}
637 local mntpt2=${3:-$MOUNT2}
639 [ -z $clients ] && clients=$(hostname)
640 echo Checking clients $clients environments
642 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
643 error "clients environments are insane!"
646 sanity_mount_check () {
647 sanity_mount_check_servers || return 1
648 sanity_mount_check_clients || return 2
651 # mount clients if not mouted
652 zconf_mount_clients() {
655 local OPTIONS=${3:-$MOUNTOPT}
657 # Only supply -o to mount if we have options
658 if [ "$OPTIONS" ]; then
659 OPTIONS="-o $OPTIONS"
661 local device=$MGSNID:/$FSNAME
662 if [ -z "$mnt" -o -z "$FSNAME" ]; then
663 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
667 echo "Starting client $clients: $OPTIONS $device $mnt"
670 running=\\\$(mount | grep -c $mnt' ');
672 if [ \\\$running -eq 0 ] ; then
674 mount -t lustre $OPTIONS $device $mnt;
679 echo "Started clients $clients: "
680 do_nodes $clients "mount | grep -w $mnt"
682 do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
683 sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
684 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
689 zconf_umount_clients() {
696 echo "Stopping clients: $clients $mnt (opts:$force)"
697 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
698 if [ \\\$running -ne 0 ] ; then
699 echo Stopping client \\\$(hostname) $mnt opts:$force;
700 lsof -t $mnt || need_kill=no;
701 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
702 pids=\\\$(lsof -t $mnt | sort -u);
703 if [ -n \\\"\\\$pids\\\" ]; then
707 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
708 if [ \\\$busy -ne 0 ] ; then
709 echo "$mnt is still busy, wait one second" && sleep 1;
717 echo + $POWER_DOWN $node
721 shutdown_node_hard () {
725 for i in $(seq $attempts) ; do
728 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
729 echo "waiting for $host to fail attempts=$attempts"
730 [ $i -lt $attempts ] || \
731 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
737 local mnt=${2:-$MOUNT}
740 if [ "$FAILURE_MODE" = HARD ]; then
741 shutdown_node_hard $client
743 zconf_umount_clients $client $mnt -f
749 local facets="$(get_facets OST),$(get_facets MDS)"
752 combined_mgs_mds || facets="$facets,mgs"
754 for facet in ${facets//,/ }; do
755 if [ $(facet_active_host $facet) == $host ]; then
756 affected="$affected $facet"
760 echo $(comma_list $affected)
766 if [ "$FAILURE_MODE" = HARD ]; then
767 shutdown_node_hard $(facet_active_host $facet)
775 echo + $POWER_UP $node
788 if [ "$FAILURE_MODE" = HARD ]; then
789 reboot_node $(facet_active_host $facet)
797 if [ "$FAILURE_MODE" = HARD ]; then
803 # recovery-scale functions
804 check_progs_installed () {
809 do_nodes $clients "PATH=:$PATH; status=true;
810 for prog in $progs; do
811 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
812 echo \\\$prog missing on \\\$(hostname);
820 echo __$(echo $1 | tr '-' 'X')
823 start_client_load() {
826 local var=$(client_var_name $client)_load
827 eval export ${var}=$load
829 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
830 BREAK_ON_ERROR=$BREAK_ON_ERROR \
831 END_RUN_FILE=$END_RUN_FILE \
832 LOAD_PID_FILE=$LOAD_PID_FILE \
833 TESTSUITELOG=$TESTSUITELOG \
835 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
836 log "Started client load: ${load} on $client"
841 start_client_loads () {
842 local -a clients=(${1//,/ })
843 local numloads=${#CLIENT_LOADS[@]}
846 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
847 testnum=$((nodenum % numloads))
848 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
850 # bug 22169: wait the background threads to start
854 # only for remote client
855 check_client_load () {
857 local var=$(client_var_name $client)_load
858 local TESTLOAD=run_${!var}.sh
860 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
862 # bug 18914: try to connect several times not only when
863 # check ps, but while check_catastrophe also
866 while [ $RC = 254 -a $tries -gt 0 ]; do
870 if ! check_catastrophe $client; then
872 if [ $RC -eq 254 ]; then
873 # FIXME: not sure how long we shuold sleep here
877 echo "check catastrophe failed: RC=$RC "
882 # We can continue try to connect if RC=254
883 # Just print the warning about this
884 if [ $RC = 254 ]; then
885 echo "got a return status of $RC from do_node while checking catastrophe on $client"
888 # see if the load is still on the client
891 while [ $RC = 254 -a $tries -gt 0 ]; do
895 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
900 if [ $RC = 254 ]; then
901 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
902 # see if we can diagnose a bit why this is
907 check_client_loads () {
908 local clients=${1//,/ }
912 for client in $clients; do
913 check_client_load $client
915 if [ "$rc" != 0 ]; then
916 log "Client load failed on node $client, rc=$rc"
922 restart_client_loads () {
923 local clients=${1//,/ }
924 local expectedfail=${2:-""}
928 for client in $clients; do
929 check_client_load $client
931 if [ "$rc" != 0 -a "$expectedfail" ]; then
932 local var=$(client_var_name $client)_load
933 start_client_load $client ${!var}
934 echo "Restarted client load ${!var}: on $client. Checking ..."
935 check_client_load $client
937 if [ "$rc" != 0 ]; then
938 log "Client load failed to restart on node $client, rc=$rc"
939 # failure one client load means test fail
940 # we do not need to check other
948 # End recovery-scale functions
950 # verify that lustre actually cleaned up properly
952 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
953 error "LBUG/LASSERT detected"
954 BUSY=`dmesg | grep -i destruct || true`
957 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
961 check_mem_leak || exit 204
963 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
964 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
966 if module_loaded lnet || module_loaded libcfs; then
967 echo "$0: modules still loaded..." 1>&2
984 RESULT=$(do_node $node "$TEST")
985 if [ "$RESULT" == "$FINAL" ]; then
986 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
989 [ $WAIT -ge $MAX ] && break
990 echo "Waiting $((MAX - WAIT)) secs for update"
991 WAIT=$((WAIT + sleep))
994 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
998 wait_update_facet () {
1001 wait_update $(facet_active_host $facet) "$@"
1004 wait_delete_completed () {
1005 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1006 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1010 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1012 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1013 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1014 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1015 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1019 echo "Delete is not completed in $MAX_WAIT sec"
1026 # we can use "for" here because we are waiting the slowest
1027 for host in ${hostlist//,/ }; do
1028 check_network "$host" 900
1030 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
1037 for facet in ${facetlist//,/ }; do
1038 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
1040 wait_for_host $hostlist
1043 _wait_recovery_complete () {
1046 # Use default policy if $2 is not passed by caller.
1047 local MAX=${2:-$(max_recovery_time)}
1052 while [ $WAIT -lt $MAX ]; do
1053 STATUS=$(lctl get_param -n $param | grep status)
1055 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
1058 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
1060 echo "$param recovery not done in $MAX sec. $STATUS"
1064 wait_recovery_complete () {
1067 # with an assumption that at_max is the same on all nodes
1068 local MAX=${2:-$(max_recovery_time)}
1071 if [ "$FAILURE_MODE" = HARD ]; then
1072 facets=$(facets_on_host $(facet_active_host $facet))
1074 echo affected facets: $facets
1076 # we can use "for" here because we are waiting the slowest
1077 for facet in ${facets//,/ }; do
1078 local var_svc=${facet}_svc
1079 local param="*.${!var_svc}.recovery_status"
1081 local host=$(facet_active_host $facet)
1082 do_rpc_nodes $host _wait_recovery_complete $param $MAX
1086 wait_mds_ost_sync () {
1087 # just because recovery is done doesn't mean we've finished
1088 # orphan cleanup. Wait for llogs to get synchronized.
1089 echo "Waiting for orphan cleanup..."
1090 # MAX value includes time needed for MDS-OST reconnection
1091 local MAX=$(( TIMEOUT * 2 ))
1093 while [ $WAIT -lt $MAX ]; do
1094 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1095 "$LCTL get_param -n obdfilter.*.mds_sync"))
1097 for ((i=0; i<${#sync[@]}; i++)); do
1098 [ ${sync[$i]} -eq 0 ] && continue
1099 # there is a not finished MDS-OST synchronization
1103 sleep 2 # increase waiting time and cover statfs cache
1104 [ ${con} -eq 1 ] && return 0
1105 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1108 echo "$facet recovery not done in $MAX sec. $STATUS"
1112 wait_destroy_complete () {
1113 echo "Waiting for destroy to be done..."
1114 # MAX value shouldn't be big as this mean server responsiveness
1115 # never increase this just to make test pass but investigate
1116 # why it takes so long time
1119 while [ $WAIT -lt $MAX ]; do
1120 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1122 for ((i=0; i<${#RPCs[@]}; i++)); do
1123 [ ${RPCs[$i]} -eq 0 ] && continue
1124 # there are still some destroy RPCs in flight
1129 [ ${con} -eq 1 ] && return 0 # done waiting
1130 echo "Waiting $WAIT secs for destroys to be done."
1133 echo "Destroys weren't done in $MAX sec."
1143 # conf-sanity 31 takes a long time cleanup
1144 while [ $WAIT -lt 300 ]; do
1145 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1146 [ -z "${running}" ] && return 0
1147 echo "waited $WAIT for${running}"
1148 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1150 WAIT=$((WAIT + INTERVAL))
1152 echo "service didn't stop after $WAIT seconds. Still running:"
1157 wait_remote_prog () {
1163 [ "$PDSH" = "no_dsh" ] && return 0
1165 while [ $WAIT -lt $2 ]; do
1166 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1167 [ -z "${running}" ] && return 0 || true
1168 echo "waited $WAIT for: "
1170 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1172 WAIT=$((WAIT + INTERVAL))
1174 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1175 [ -z "$pids" ] && return 0
1176 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1177 # FIXME: not portable
1178 for pid in $pids; do
1179 cat /proc/${pid}/status || true
1180 cat /proc/${pid}/wchan || true
1182 kill -9 $pid || true
1191 # not every config has many clients
1193 if [ -n "$CLIENTS" ]; then
1194 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1196 stat -f $MOUNT > /dev/null
1202 # usually checked on particular client or locally
1204 if [ ! -z "$client" ]; then
1205 $PDSH $client "stat -f $MOUNT" > /dev/null
1207 stat -f $MOUNT > /dev/null
1215 client_reconnect() {
1216 uname -n >> $MOUNT/recon
1217 if [ -z "$CLIENTS" ]; then
1218 df $MOUNT; uname -n >> $MOUNT/recon
1220 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1222 echo Connected clients:
1224 ls -l $MOUNT/recon > /dev/null
1231 local host=$(facet_active_host $facet)
1233 echo "Failing $facet on node $host"
1235 local affected=$facet
1237 if [ "$FAILURE_MODE" = HARD ]; then
1238 affected=$(facets_on_host $host)
1241 shutdown_facet $facet
1243 echo affected facets: $affected
1245 [ -n "$sleep_time" ] && sleep $sleep_time
1250 RECOVERY_START_TIME=`date +%s`
1251 echo "df pid is $dfpid"
1253 change_active $affected
1255 wait_for_facet $affected
1256 # start mgs first if it is affected
1257 if ! combined_mgs_mds && list_member $affected mgs; then
1258 mount_facet mgs || error "Restart of mgs failed"
1260 # FIXME; has to be changed to mount all facets concurrently
1261 affected=$(exclude_items_from_list $affected mgs)
1262 for facet in ${affected//,/ }; do
1263 mount_facet $facet || error "Restart of $facet on node $host failed!"
1273 do_facet $facet sync
1275 local svc=${facet}_svc
1276 do_facet $facet $LCTL --device %${!svc} notransno
1277 do_facet $facet $LCTL --device %${!svc} readonly
1278 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1279 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1282 replay_barrier_nodf() {
1283 local facet=$1 echo running=${running}
1284 do_facet $facet sync
1285 local svc=${facet}_svc
1286 echo Replay barrier on ${!svc}
1287 do_facet $facet $LCTL --device %${!svc} notransno
1288 do_facet $facet $LCTL --device %${!svc} readonly
1289 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1290 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1293 mds_evict_client() {
1294 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1295 local mdtdevice=$(get_mds_mdt_device_proc_path)
1296 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1299 ost_evict_client() {
1300 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1301 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1305 facet_failover $* || error "failover: $?"
1306 clients_up || error "post-failover df: $?"
1311 facet_failover $facet
1317 change_active $facet
1318 mount_facet $facet -o abort_recovery
1319 clients_up || echo "first df failed: $?"
1320 clients_up || error "post-failover df: $?"
1324 echo There is no lmc. This is mountconf, baby.
1329 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1330 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1336 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1342 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1343 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1344 if [ -z "$ID" ]; then
1345 echo "Could not get a ptl id for $1..."
1354 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1361 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1362 if type __h2elan >/dev/null 2>&1; then
1365 ID=`echo $1 | sed 's/[^0-9]*//g'`
1373 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1374 ID=`echo $1 | sed 's/[^0-9]*//g'`
1378 declare -fx h2openib
1381 h2name_or_ip "$1" "o2ib"
1388 [ "$facet" == client ] && echo -n $HOSTNAME && return
1389 varname=${facet}_HOST
1390 if [ -z "${!varname}" ]; then
1391 if [ "${facet:0:3}" == "ost" ]; then
1392 eval ${facet}_HOST=${ost_HOST}
1400 local activevar=${facet}active
1402 if [ -f $TMP/${facet}active ] ; then
1403 source $TMP/${facet}active
1406 active=${!activevar}
1407 if [ -z "$active" ] ; then
1414 facet_active_host() {
1416 local active=`facet_active $facet`
1417 if [ "$facet" == client ]; then
1420 echo `facet_host $active`
1428 facetlist=$(exclude_items_from_list $facetlist mgs)
1430 for facet in ${facetlist//,/ }; do
1431 local failover=${facet}failover
1432 local host=`facet_host $failover`
1433 [ -z "$host" ] && return
1435 local curactive=`facet_active $facet`
1436 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1437 eval export ${facet}active=$facet
1439 eval export ${facet}active=$failover
1441 # save the active host for this facet
1442 local activevar=${facet}active
1443 echo "$activevar=${!activevar}" > $TMP/$activevar
1444 local TO=`facet_active_host $facet`
1445 echo "Failover $facet to $TO"
1451 # do not stripe off hostname if verbose, bug 19215
1452 if [ x$1 = x--verbose ]; then
1460 if [ "$HOST" = "$HOSTNAME" ]; then
1462 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1463 echo "cannot run remote command on $HOST with $myPDSH"
1467 echo "CMD: $HOST $@" >&2
1468 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1471 if [ "$myPDSH" = "rsh" ]; then
1472 # we need this because rsh does not return exit code of an executed command
1473 local command_status="$TMP/cs"
1474 rsh $HOST ":> $command_status"
1475 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1476 cd $RPWD; sh -c \"$@\") ||
1477 echo command failed >$command_status"
1478 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1483 # print HOSTNAME for myPDSH="no_dsh"
1484 if [[ $myPDSH = no_dsh ]]; then
1485 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1487 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1490 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1492 return ${PIPESTATUS[0]}
1496 do_node --verbose "$@"
1499 single_local_node () {
1500 [ "$1" = "$HOSTNAME" ]
1505 # do not stripe off hostname if verbose, bug 19215
1506 if [ x$1 = x--verbose ]; then
1514 if $(single_local_node $rnodes); then
1516 do_nodev $rnodes "$@"
1518 do_node $rnodes "$@"
1523 # This is part from do_node
1526 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1527 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1530 echo "CMD: $rnodes $@" >&2
1531 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1534 # do not replace anything from pdsh output if -N is used
1535 # -N Disable hostname: prefix on lines of output.
1536 if $verbose || [[ $myPDSH = *-N* ]]; then
1537 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1539 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
1541 return ${PIPESTATUS[0]}
1547 local HOST=`facet_active_host $facet`
1548 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1553 do_nodes --verbose "$@"
1559 # make sure its not already running
1561 rm -f $TMP/${facet}active
1562 do_facet ${facet} $MKFS $*
1568 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1569 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1575 if combined_mgs_mds && [[ $facet = "mgs" ]] ; then
1578 local var=${facet}_MOUNT
1579 eval mntpt=${!var:-${MOUNT%/*}/$facet}
1588 # make sure we are using the primary server, so test-framework will
1589 # be able to clean up properly.
1590 activemds=`facet_active mds`
1591 if [ $activemds != "mds" ]; then
1595 local clients=$CLIENTS
1596 [ -z $clients ] && clients=$(hostname)
1598 zconf_umount_clients $clients $MOUNT "$*" || true
1599 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1601 [ "$CLIENTONLY" ] && return
1602 # The add fn does rm ${facet}active file, this would be enough
1603 # if we use do_facet <facet> only after the facet added, but
1604 # currently we use do_facet mds in local.sh
1606 rm -f ${TMP}/mdsactive
1607 for num in `seq $OSTCOUNT`; do
1609 rm -f $TMP/ost${num}active
1611 if ! combined_mgs_mds ; then
1618 cleanup_echo_devs () {
1619 local devs=$($LCTL dl | grep echo | awk '{print $4}')
1621 for dev in $devs; do
1622 $LCTL --device $dev cleanup
1623 $LCTL --device $dev detach
1628 nfs_client_mode && return
1636 combined_mgs_mds () {
1637 [[ $MDSDEV = $MGSDEV ]] && [[ $mds_HOST = $mgs_HOST ]]
1643 local tgt=$(echo $facet | tr -d [:digit:] | tr "[:lower:]" "[:upper:]")
1644 local optvar=${tgt}_MKFS_OPTS
1645 local opt=${!optvar}
1647 # FIXME: ! combo mgs/mds + mgsfailover is not supported yet
1648 [[ $facet = mgs ]] && echo $opt && return
1651 # --failnode options
1652 local var=${facet}failover_HOST
1653 if [ x"${!var}" != x ] && [ x"${!var}" != x$(facet_host $facet) ] ; then
1654 local failnode=$(h2$NETTYPE ${!var})
1655 failnode="--failnode=$failnode"
1656 # options does not contain
1657 # or contains wrong --failnode=
1658 if [[ $opt != *${failnode}* ]]; then
1659 opt=$(echo $opt | sed 's/--failnode=.* / /')
1660 opt="$opt $failnode"
1666 # no additional mkfs mds "--mgsnode" option for this configuration
1667 if [[ $facet = mds ]] && combined_mgs_mds; then
1672 # additional mkfs "--mgsnode"
1673 local mgsnode="--mgsnode=$MGSNID"
1674 opt=${opt//$mgsnode }
1675 for nid in ${MGSNID//:/ }; do
1676 local mgsnode="--mgsnode=$nid"
1677 # options does not contain
1679 if [[ $opt != *${mgsnode}" "* ]]; then
1680 opt="$opt --mgsnode=$nid"
1688 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1691 # We need ldiskfs here, may as well load them all
1693 [ "$CLIENTONLY" ] && return
1694 echo Formatting mgs, mds, osts
1695 if ! combined_mgs_mds ; then
1696 add mgs $(mkfs_opts mgs) $FSTYPE_OPT --reformat $MGSDEV || exit 10
1700 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV || exit 10
1702 add mds $(mkfs_opts mds) $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1705 # the ost-s could have different OST_MKFS_OPTS
1706 # because of different failnode-s
1707 for num in `seq $OSTCOUNT`; do
1709 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1711 add ost$num $(mkfs_opts ost${num}) $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1717 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1722 zconf_umount `hostname` $1 || error "umount failed"
1723 zconf_mount `hostname` $1 || error "mount failed"
1726 writeconf_facet () {
1730 do_facet $facet "$TUNEFS --writeconf $dev"
1734 writeconf_facet mds $MDSDEV
1736 for num in `seq $OSTCOUNT`; do
1737 DEVNAME=`ostdevname $num`
1738 writeconf_facet ost$num $DEVNAME
1743 nfs_client_mode && return
1745 sanity_mount_check ||
1746 error "environments are insane!"
1749 if [ -z "$CLIENTONLY" ]; then
1750 echo Setup mgs, mdt, osts
1752 echo $WRITECONF | grep -q "writeconf" && \
1755 if ! combined_mgs_mds ; then
1756 start mgs $MGSDEV $MGS_MOUNT_OPTS
1759 start mds $MDSDEV $MDS_MOUNT_OPTS
1760 # We started mds, now we should set failover variable properly.
1761 # Set mdsfailover_HOST if it is not set (the default failnode).
1762 if [ -z "$mdsfailover_HOST" ]; then
1763 mdsfailover_HOST=$(facet_host mds)
1766 for num in `seq $OSTCOUNT`; do
1767 DEVNAME=`ostdevname $num`
1768 start ost$num $DEVNAME $OST_MOUNT_OPTS
1770 # We started ost$num, now we should set ost${num}failover variable properly.
1771 # Set ost${num}failover_HOST if it is not set (the default failnode).
1772 varname=ost${num}failover_HOST
1773 if [ -z "${!varname}" ]; then
1774 eval ost${num}failover_HOST=$(facet_host ost${num})
1779 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1781 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1783 if [ "$MOUNT_2" ]; then
1784 mount_client $MOUNT2
1785 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1791 mounted_lustre_filesystems() {
1792 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1795 init_facet_vars () {
1796 [ "$CLIENTONLY" ] && return 0
1803 eval export ${facet}_dev=${device}
1804 eval export ${facet}_opt=\"$@\"
1806 local dev=${facet}_dev
1807 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1808 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1810 eval export ${facet}_svc=${label}
1812 local varname=${facet}failover_HOST
1813 if [ -z "${!varname}" ]; then
1814 eval $varname=$(facet_host $facet)
1817 # ${facet}failover_dev is set in cfg file
1818 varname=${facet}failover_dev
1819 if [ -n "${!varname}" ] ; then
1820 eval export ${facet}failover_dev=${!varname}
1822 eval export ${facet}failover_dev=$device
1825 # get mount point of already mounted device
1826 # is facet_dev is already mounted then use the real
1827 # mount point of this facet; otherwise use $(facet_mntpt $facet)
1828 # i.e. ${facet}_MOUNT if specified by user or default
1829 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
1830 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
1831 if [ -z $mntpt ]; then
1832 mntpt=$(facet_mntpt $facet)
1834 eval export ${facet}_MOUNT=$mntpt
1837 init_facets_vars () {
1839 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1841 combined_mgs_mds || init_facet_vars mgs $MGSDEV $MGS_MOUNT_OPTS
1843 remote_ost_nodsh && return
1845 for num in `seq $OSTCOUNT`; do
1846 DEVNAME=`ostdevname $num`
1847 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1851 init_param_vars () {
1852 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1853 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1854 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1855 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1859 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1861 log "Using TIMEOUT=$TIMEOUT"
1863 if [ "$ENABLE_QUOTA" ]; then
1864 setup_quota $MOUNT || return 2
1868 nfs_client_mode () {
1869 if [ "$NFSCLIENT" ]; then
1870 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1871 local clients=$CLIENTS
1872 [ -z $clients ] && clients=$(hostname)
1874 # FIXME: remove hostname when 19215 fixed
1875 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1876 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1877 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1883 check_config_client () {
1886 local mounted=$(mount | grep " $mntpt ")
1887 if [ "$CLIENTONLY" ]; then
1889 # CLIENTONLY should not depend on *_HOST settings
1890 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1891 # in theory someone could create a new,
1892 # client-only config file that assumed lustre was already
1893 # configured and didn't set the MGSNID. If MGSNID is not set,
1894 # then we should use the mgs nid currently being used
1895 # as the default value. bug 18021
1896 [[ x$MGSNID = x ]] &&
1899 if [[ x$mgc != xMGC$MGSNID ]]; then
1900 if [ "$mgs_HOST" ]; then
1901 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1902 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1903 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1909 local myMGS_host=$mgs_HOST
1910 if [ "$NETTYPE" = "ptl" ]; then
1911 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1914 echo Checking config lustre mounted on $mntpt
1915 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1916 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1918 # if [ "$mgshost" != "$myMGS_host" ]; then
1919 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1920 # Please use correct config or set mds_HOST correctly!"
1925 check_config_clients () {
1926 local clients=${CLIENTS:-$HOSTNAME}
1929 nfs_client_mode && return
1931 do_rpc_nodes $clients check_config_client $mntpt
1933 sanity_mount_check ||
1934 error "environments are insane!"
1938 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
1939 local cltimeout=$(lctl get_param -n timeout)
1940 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1941 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1948 local mounted=$(mounted_lustre_filesystems)
1950 echo $mounted' ' | grep -w -q $mntpt' '
1954 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
1958 # empty lustre filesystem may have empty directories lost+found and .lustre
1960 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
1961 -print | wc -l) = 1 ] || return 1
1962 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found && return 0
1963 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre && return 0
1967 check_and_setup_lustre() {
1968 nfs_client_mode && return
1970 local MOUNTED=$(mounted_lustre_filesystems)
1974 # both MOUNT and MOUNT2 are not mounted
1975 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
1976 [ "$REFORMAT" ] && formatall
1977 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
1979 is_mounted $MOUNT || error "NAME=$NAME not mounted"
1980 export I_MOUNTED=yes
1984 elif is_mounted $MOUNT2; then
1986 # MOUNT2 is mounted, while MOUNT_2 is not set
1987 if ! [ "$MOUNT_2" ]; then
1988 cleanup_mount $MOUNT2
1989 export I_UMOUNTED2=yes
1992 # MOUNT2 is mounted, MOUNT_2 is set
1994 # FIXME: what to do if check_config failed?
1996 # 1) remote client has mounted other Lustre fs ?
1997 # 2) it has insane env ?
1998 # let's try umount MOUNT2 on all clients and mount it again:
1999 if ! check_config_clients $MOUNT2; then
2000 cleanup_mount $MOUNT2
2001 restore_mount $MOUNT2
2002 export I_MOUNTED2=yes
2007 # MOUNT is mounted MOUNT2 is not mounted
2008 elif [ "$MOUNT_2" ]; then
2009 restore_mount $MOUNT2
2010 export I_MOUNTED2=yes
2014 # FIXME: what to do if check_config failed?
2016 # 1) remote client has mounted other Lustre fs?
2017 # 2) lustre is mounted on remote_clients atall ?
2018 check_config_clients $MOUNT
2022 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2023 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2024 lctl set_param debug_mb=${DEBUG_SIZE};
2027 if [ "$ONLY" == "setup" ]; then
2033 local clients=${CLIENTS:-$HOSTNAME}
2036 zconf_mount_clients $clients $mntpt
2040 local clients=${CLIENTS:-$HOSTNAME}
2043 zconf_umount_clients $clients $mntpt
2046 cleanup_and_setup_lustre() {
2047 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2048 lctl set_param debug=0 || true
2050 if [ "$ONLY" == "cleanup" ]; then
2054 check_and_setup_lustre
2057 # Get all of the server target devices from a given server node and type.
2066 mdt) obd_type="osd" ;;
2067 ost) obd_type="obdfilter" ;; # needs to be fixed when OST also uses an OSD
2068 *) echo "invalid server type" && return 1 ;;
2071 devs=$(do_node $node "lctl get_param -n $obd_type.*.mntdev")
2072 for dev in $devs; do
2074 *loop*) do_node $node "losetup $dev" | \
2075 sed -e "s/.*(//" -e "s/).*//" ;;
2081 # Get all of the server target devices.
2087 for node in $(osts_nodes); do
2088 OSTDEVS[i]=$(get_mnt_devs $node ost)
2093 # Run e2fsck on MDT or OST device.
2100 df > /dev/null # update statfs data on disk
2101 local cmd="$E2FSCK -d -v -f -n $MDSDB_OPT $ostdb_opt $target_dev"
2104 do_node $node $cmd || rc=$?
2105 [ $rc -le $FSCK_MAX_ERR ] || \
2106 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2110 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
2117 tmp_file=$(mktemp -p $SHARED_DIRECTORY ||
2118 error_exit "fail to create file in $SHARED_DIRECTORY")
2120 # make sure everything gets to the backing store
2121 local list=$(comma_list $CLIENTS $(facet_host mds) $(osts_nodes))
2122 do_nodes $list "sync; sleep 2; sync"
2124 do_nodes $list ls $tmp_file || \
2125 error_exit "$SHARED_DIRECTORY is not a shared directory"
2128 run_e2fsck $(facet_host mds) $MDSDEV
2133 for node in $(osts_nodes); do
2134 for dev in ${OSTDEVS[i]}; do
2135 local ostdb_opt=`eval echo $OSTDB_OPT`
2136 run_e2fsck $node $dev $ostidx "$ostdb_opt"
2137 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
2138 ostidx=$((ostidx + 1))
2145 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
2149 [ $rc -le $FSCK_MAX_ERR ] || \
2150 error_exit "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
2151 echo "lfsck finished with rc=$rc"
2153 rm -rvf $MDSDB* $OSTDB* || true
2157 check_and_cleanup_lustre() {
2158 if [ "$LFSCK_ALWAYS" = "yes" ]; then
2161 if [ "$SKIP_LFSCK" == "no" ]; then
2168 if is_mounted $MOUNT; then
2169 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2170 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2173 if [ "$I_UMOUNTED2" = "yes" ]; then
2174 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2177 if [ "$I_MOUNTED2" = "yes" ]; then
2178 cleanup_mount $MOUNT2
2181 if [ "$I_MOUNTED" = "yes" ]; then
2182 cleanupall -f || error "cleanup failed"
2194 while [ $NETWORK -eq 0 ]; do
2195 if ping -c 1 -w 3 $1 > /dev/null; then
2199 echo "waiting for $1, $((MAX - WAIT)) secs left"
2202 if [ $WAIT -gt $MAX ]; then
2203 echo "Network not available"
2209 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2220 # the sed converts spaces to commas, but leaves the last space
2221 # alone, so the line doesn't end with a comma.
2222 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2228 echo $list | grep -qw $item
2231 # list, excluded are the comma separated lists
2232 exclude_items_from_list () {
2238 for item in ${excluded//,/ }; do
2239 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2241 echo $(comma_list $list)
2244 # list, expand are the comma separated lists
2246 local list=${1//,/ }
2247 local expand=${2//,/ }
2250 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2251 echo $(comma_list $expanded)
2254 testslist_filter () {
2255 local script=$LUSTRE/tests/${TESTSUITE}.sh
2257 [ -f $script ] || return 0
2259 local start_at=$START_AT
2260 local stop_at=$STOP_AT
2262 local var=${TESTSUITE//-/_}_START_AT
2263 [ x"${!var}" != x ] && start_at=${!var}
2264 var=${TESTSUITE//-/_}_STOP_AT
2265 [ x"${!var}" != x ] && stop_at=${!var}
2267 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2268 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2269 /^'${start_at}'$/ {flag = 0}
2270 {if (flag == 1) print $0}
2271 /^'${stop_at}'$/ { flag = 1 }'
2275 (cd `dirname $1`; echo $PWD/`basename $1`)
2279 local types=${1:-"OST MDS MGS"}
2282 for entry in $types; do
2283 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
2284 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
2287 MDS|MGS ) list="$list $name";;
2288 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
2289 list="$list ${name}$i"
2291 * ) error "Invalid facet type"
2295 echo $(comma_list $list)
2298 ##################################
2299 # Adaptive Timeouts funcs
2302 # only check mds, we assume at_max is the same on all nodes
2303 local at_max=$(do_facet mds "lctl get_param -n at_max")
2304 if [ $at_max -eq 0 ]; then
2314 # suppose that all ost-s has the same at_max set
2315 if [ $facet == "ost" ]; then
2316 do_facet ost1 "lctl get_param -n at_max"
2318 do_facet $facet "lctl get_param -n at_max"
2328 if [ $facet == "ost" ]; then
2329 for i in `seq $OSTCOUNT`; do
2330 do_facet ost$i "lctl set_param at_max=$at_max"
2333 do_facet $facet "lctl set_param at_max=$at_max"
2338 ##################################
2342 # OBD_FAIL_MDS_ALL_REQUEST_NET
2344 do_facet mds lctl set_param fail_loc=0x123
2345 do_facet client "$1" || RC=$?
2346 do_facet mds lctl set_param fail_loc=0
2351 # OBD_FAIL_MDS_ALL_REPLY_NET
2353 do_facet mds lctl set_param fail_loc=0x122
2354 do_facet client "$@" || RC=$?
2355 do_facet mds lctl set_param fail_loc=0
2359 drop_reint_reply() {
2360 # OBD_FAIL_MDS_REINT_NET_REP
2362 do_facet mds lctl set_param fail_loc=0x119
2363 do_facet client "$@" || RC=$?
2364 do_facet mds lctl set_param fail_loc=0
2369 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2371 do_facet ost1 lctl set_param fail_loc=0x214
2372 do_facet client "$1" || RC=$?
2373 do_facet client "sync"
2374 do_facet ost1 lctl set_param fail_loc=0
2378 drop_ldlm_cancel() {
2379 #define OBD_FAIL_LDLM_CANCEL 0x304
2381 do_facet client lctl set_param fail_loc=0x304
2382 do_facet client "$@" || RC=$?
2383 do_facet client lctl set_param fail_loc=0
2387 drop_bl_callback() {
2388 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2390 do_facet client lctl set_param fail_loc=0x305
2391 do_facet client "$@" || RC=$?
2392 do_facet client lctl set_param fail_loc=0
2397 #define OBD_FAIL_LDLM_REPLY 0x30c
2399 do_facet mds lctl set_param fail_loc=0x30c
2400 do_facet client "$@" || RC=$?
2401 do_facet mds lctl set_param fail_loc=0
2409 echo "clearing fail_loc on $facet"
2410 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2413 set_nodes_failloc () {
2414 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2417 cancel_lru_locks() {
2418 $LCTL mark "cancel_lru_locks $1 start"
2419 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2420 $LCTL set_param -n $d=clear
2422 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2423 $LCTL mark "cancel_lru_locks $1 stop"
2428 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2429 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2430 echo "$DEFAULT_LRU_SIZE"
2435 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2438 lru_resize_disable()
2440 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2445 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2446 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2447 echo there is still data in page cache $FILE ?
2448 lctl get_param -n $FILE
2455 create_fake_exports () {
2458 #obd_fail_val = num;
2459 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2460 do_facet $facet "lctl set_param fail_val=$num"
2461 do_facet $facet "lctl set_param fail_loc=0x80000708"
2466 DEBUGSAVE="$(lctl get_param -n debug)"
2470 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2474 ##################################
2476 ##################################
2479 local TYPE=${TYPE:-"FAIL"}
2482 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS
2485 # do not dump logs if $1=false
2486 if [ "x$1" = "xfalse" ]; then
2491 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2494 ERRLOG=$tmp/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2495 echo "Dumping lctl log to $ERRLOG"
2496 # We need to dump the logs on all nodes
2497 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2500 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2506 if $FAIL_ON_ERROR; then
2517 # use only if we are ignoring failures for this test, bugno required.
2518 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2519 # e.g. error_ignore 5494 "your message"
2521 local TYPE="IGNORE (bz$1)"
2527 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2531 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2532 [ "$TESTSUITELOG" ] && \
2533 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2536 build_test_filter() {
2537 EXCEPT="$EXCEPT $(testslist_filter)"
2539 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2543 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2544 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2545 [ "$EXCEPT_SLOW" ] && \
2546 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2547 for E in $EXCEPT $ALWAYS_EXCEPT; do
2548 eval EXCEPT_${E}=true
2550 for E in $EXCEPT_SLOW; do
2551 eval EXCEPT_SLOW_${E}=true
2553 for G in $GRANT_CHECK_LIST; do
2554 eval GCHECK_ONLY_${G}=true
2559 if [[ $1 = [a-z]* ]]; then
2566 # print a newline if the last test was skipped
2567 export LAST_SKIPPED=
2571 export base=`basetest $1`
2572 if [ ! -z "$ONLY" ]; then
2574 if [ ${!testname}x != x ]; then
2575 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2580 if [ ${!testname}x != x ]; then
2581 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2590 if [ ${!testname}x != x ]; then
2592 TESTNAME=test_$1 skip "skipping excluded test $1"
2595 testname=EXCEPT_$base
2596 if [ ${!testname}x != x ]; then
2598 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2601 testname=EXCEPT_SLOW_$1
2602 if [ ${!testname}x != x ]; then
2604 TESTNAME=test_$1 skip "skipping SLOW test $1"
2607 testname=EXCEPT_SLOW_$base
2608 if [ ${!testname}x != x ]; then
2610 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2620 EQUALS="======================================================================"
2624 local suffixlen=$((${#EQUALS} - ${#msg}))
2625 [ $suffixlen -lt 5 ] && suffixlen=5
2626 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2631 module_loaded lnet || load_modules
2643 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2648 strace -o $TMP/$1.strace -ttt $*
2650 log "FINISHED: $*: rc $RC"
2655 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2660 FFREE=`lctl get_param -n mds.*.filesfree`
2661 FTOTAL=`lctl get_param -n mds.*.filestotal`
2662 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2666 echo -n "Resetting fail_loc on all nodes..."
2667 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2675 export tdir=d0.${TESTSUITE}/d${base}
2677 local SAVE_UMASK=`umask`
2680 local BEFORE=`date +%s`
2682 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2684 export TESTNAME=test_$testnum
2686 test_${testnum} || error "test_$testnum failed with $?"
2690 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2691 check_catastrophe || error "LBUG/LASSERT detected"
2692 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2693 pass "($((`date +%s` - $BEFORE))s)"
2701 (cd `dirname $1`; echo $PWD/`basename $1`)
2705 export base=`basetest $1`
2706 [ "$CHECK_GRANT" == "no" ] && return 0
2708 testname=GCHECK_ONLY_${base}
2709 [ ${!testname}x == x ] && return 0
2711 echo -n "checking grant......"
2713 local clients=$CLIENTS
2714 [ -z $clients ] && clients=$(hostname)
2716 # sync all the data and make sure no pending data on server
2717 do_nodes $clients sync
2720 client_grant=`do_nodes $clients \
2721 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" | \
2722 awk '{total += $1} END{print total}'`
2725 server_grant=`do_nodes $(comma_list $(osts_nodes)) \
2726 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" | \
2727 awk '{total += $1} END{print total}'`
2729 # check whether client grant == server grant
2730 if [ $client_grant -ne $server_grant ]; then
2731 echo "failed: client:${client_grant} server: ${server_grant}."
2732 do_nodes $(comma_list $(osts_nodes)) \
2733 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
2734 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
2737 echo "pass: client:${client_grant} server: ${server_grant}"
2741 ########################
2747 ost=`echo $1 | awk -F_ '{print $3}'`
2748 if [ -z $ost ]; then
2749 ost=`echo $1 | sed 's/-osc.*//'`
2754 ostuuid_from_index()
2756 $LFS osts $2 | awk '/^'$1'/ { print $2 }'
2761 [ "$node" != "$(hostname)" ]
2766 remote_node $mds_HOST
2771 [ "$CLIENTONLY" ] && return 0 || true
2772 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2778 for node in $(osts_nodes) ; do
2779 remote_node $node && return 0
2786 [ "$CLIENTONLY" ] && return 0 || true
2787 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2793 MGS=$(facet_host mgs)
2794 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2798 remote_ost && remote_mds
2803 remote_mds_nodsh || remote_ost_nodsh || \
2804 $(single_local_node $(comma_list $(nodes_list)))
2812 for facet in ${facets//,/ }; do
2813 if [ "$FAILURE_MODE" = HARD ]; then
2814 nodes="$nodes $(facet_active_host $facet)"
2816 nodes="$nodes $(facet_host $facet)"
2819 NODES_sort=$(for i in $nodes; do echo $i; done | sort -u)
2825 local facets=$(get_facets OST)
2826 local nodes=$(facets_nodes $facets)
2832 # FIXME. We need a list of clients
2833 local myNODES=$HOSTNAME
2836 # CLIENTS (if specified) contains the local client
2837 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2839 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2840 myNODES="$myNODES $(facets_nodes $(get_facets))"
2843 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2848 remote_nodes_list () {
2849 local rnodes=$(nodes_list)
2850 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2854 init_clients_lists () {
2855 # Sanity check: exclude the local client from RCLIENTS
2856 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2858 # Sanity check: exclude the dup entries
2859 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2861 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2863 # Sanity check: exclude the dup entries from CLIENTS
2864 # for those configs which has SINGLCLIENT set to local client
2865 clients=$(for i in $clients; do echo $i; done | sort -u)
2867 CLIENTS=`comma_list $clients`
2868 local -a remoteclients=($rclients)
2869 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2870 varname=CLIENT$((i + 2))
2871 eval $varname=${remoteclients[i]}
2874 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2877 get_random_entry () {
2880 rnodes=${rnodes//,/ }
2882 local -a nodes=($rnodes)
2883 local num=${#nodes[@]}
2884 local i=$((RANDOM * num * 2 / 65536))
2890 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2895 lctl get_param version | grep -q patchless
2899 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2904 echo $nodes | wc -w || true
2908 local nodes=$(osts_nodes)
2909 local osscount=$(get_node_count "$nodes")
2910 [ ! "$OSTCOUNT" = "$osscount" ]
2913 generate_machine_file() {
2914 local nodes=${1//,/ }
2915 local machinefile=$2
2917 for node in $nodes; do
2918 echo $node >>$machinefile || \
2919 { echo "can not generate machinefile $machinefile" && return 1; }
2924 local file=$1/stripe
2926 $LFS getstripe -v $file || error
2930 setstripe_nfsserver () {
2933 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
2934 { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
2936 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
2938 do_nodev $nfsserver lfs setstripe "$@"
2941 check_runas_id_ret() {
2943 local myRUNAS_UID=$1
2944 local myRUNAS_GID=$2
2947 if [ -z "$myRUNAS" ]; then
2948 error_exit "myRUNAS command must be specified for check_runas_id"
2950 mkdir $DIR/d0_runas_test
2952 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2953 if ! $myRUNAS touch $DIR/d0_runas_test/f$$ ; then
2954 do_nodesv $(comma_list $(nodes_list)) grep -w $myRUNAS_UID /etc/passwd
2957 rm -rf $DIR/d0_runas_test
2962 local myRUNAS_UID=$1
2963 local myRUNAS_GID=$2
2966 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2967 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2968 Please set RUNAS_ID to some UID which exists on MDS and client or
2969 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2972 # Run multiop in the background, but wait for it to print
2973 # "PAUSING" to its stdout before returning from this function.
2974 multiop_bg_pause() {
2975 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2979 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2982 echo "$MULTIOP_PROG $FILE v$ARGS"
2983 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2985 echo "TMPPIPE=${TMPPIPE}"
2986 local multiop_output
2988 read -t 60 multiop_output < $TMPPIPE
2989 if [ $? -ne 0 ]; then
2994 if [ "$multiop_output" != "PAUSING" ]; then
2995 echo "Incorrect multiop output: $multiop_output"
3010 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3016 inodes_available () {
3017 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3021 mdsrate_inodes_available () {
3022 echo $(($(inodes_available) - 1))
3025 # reset llite stat counters
3026 clear_llite_stats(){
3027 lctl set_param -n llite.*.stats 0
3030 # sum llite stat items
3031 calc_llite_stats() {
3032 local res=$(lctl get_param -n llite.*.stats |
3033 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3038 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3041 calc_osc_kbytes () {
3042 df $MOUNT > /dev/null
3043 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
3046 # save_lustre_params(node, parameter_mask)
3047 # generate a stream of formatted strings (<node> <param name>=<param value>)
3048 save_lustre_params() {
3050 do_nodesv $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3053 # restore lustre parameters from input stream, produces by save_lustre_params
3054 restore_lustre_params() {
3058 while IFS=" =" read node name val; do
3059 do_node ${node//:/} "lctl set_param -n $name $val"
3063 check_catastrophe() {
3064 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3065 local C=$CATASTROPHE
3066 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3068 if [ $rnodes ]; then
3069 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3070 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3086 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3088 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3089 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3090 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3094 mdsrate_cleanup () {
3095 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3098 delayed_recovery_enabled () {
3099 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
3102 ################################################################################
3103 # The following functions are used to enable interop testing between
3104 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
3106 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
3107 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
3108 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
3109 ################################################################################
3111 get_lustre_version () {
3112 local node=${1:-"mds"}
3113 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3116 get_mds_version_major () {
3117 local version=$(get_lustre_version mds)
3118 echo $version | awk -F. '{print $1}'
3121 get_mds_version_minor () {
3122 local version=$(get_lustre_version mds)
3123 echo $version | awk -F. '{print $2}'
3126 get_mds_version_patch () {
3127 local version=$(get_lustre_version mds)
3128 echo $version | awk -F. '{print $3}'
3131 get_mds_version_fix () {
3132 local version=$(get_lustre_version mds)
3133 echo $version | awk -F. '{print $4}'
3136 get_kernel_version () {
3137 local facet=${1:-"mds"}
3138 do_facet $facet uname -r | awk -F "-" '{print $1}'
3141 get_mds_kernel_major () {
3142 local version=$(get_kernel_version mds)
3143 echo $version | awk -F. '{print $1"."$2}'
3146 get_mds_kernel_minor () {
3147 local version=$(get_kernel_version mds)
3148 echo $version | awk -F. '{print $3}'
3151 get_mds_fsstat_proc_path() {
3152 local major=$(get_mds_version_major)
3153 local minor=$(get_mds_version_minor)
3154 if [ $major -le 1 -a $minor -le 8 ] ; then
3161 get_mds_mntdev_proc_path() {
3162 local fsstat_dev=$(get_mds_fsstat_proc_path)
3163 echo "$fsstat_dev.*.mntdev"
3166 get_mdtlov_proc_path() {
3168 local major=$(get_mds_version_major)
3169 local minor=$(get_mds_version_minor)
3170 if [ $major -le 1 -a $minor -le 8 ] ; then
3171 echo "${fsname}-mdtlov"
3173 echo "${fsname}-MDT0000-mdtlov"
3177 get_mdtosc_proc_path() {
3179 local major=$(get_mds_version_major)
3180 local minor=$(get_mds_version_minor)
3181 if [ $major -le 1 -a $minor -le 8 ] ; then
3184 echo "${ost}-osc-MDT0000"
3188 get_mds_mdt_device_proc_path() {
3189 local major=$(get_mds_version_major)
3190 local minor=$(get_mds_version_minor)
3191 if [ $major -le 1 -a $minor -le 8 ] ; then
3199 local major=$(get_mds_version_major)
3200 local minor=$(get_mds_version_minor)
3201 if [ $major -le 1 -a $minor -le 8 ] ; then
3208 ########################
3210 convert_facet2label() {
3213 if [ x$facet = xost ]; then
3217 local varsvc=${facet}_svc
3219 if [ -n ${!varsvc} ]; then
3222 error "No lablel for $facet!"
3226 get_clientosc_proc_path() {
3232 get_osc_import_name() {
3235 local label=$(convert_facet2label $ost)
3237 if [ "$facet" == "mds" ]; then
3238 get_mdtosc_proc_path $label
3242 get_clientosc_proc_path $label
3246 _wait_import_state () {
3249 local maxtime=${3:-max_recovery_time}
3253 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3254 while [ "${CONN_STATE}" != "${expected}" ]; do
3255 [ $i -ge $maxtime ] && \
3256 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
3259 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3263 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
3267 wait_import_state() {
3270 local maxtime=${3:-max_recovery_time}
3273 for param in ${params//,/ }; do
3274 _wait_import_state $state $param $maxtime || return
3277 wait_osc_import_state() {
3281 local ost=$(get_osc_import_name $facet $ost_facet)
3286 CONN_PROC="osc.${ost}.ost_server_uuid"
3287 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3288 while [ "${CONN_STATE}" != "${expected}" ]; do
3289 if [ "${expected}" == "DISCONN" ]; then
3290 # for disconn we can check after proc entry is removed
3291 [ "x${CONN_STATE}" == "x" ] && return 0
3292 # with AT enabled, we can have connect request timeout near of
3293 # reconnect timeout and test can't see real disconnect
3294 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3296 # disconnect rpc should be wait not more obd_timeout
3297 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3298 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3300 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3304 log "${ost_facet} now in ${CONN_STATE} state"
3308 get_clientmdc_proc_path() {
3316 local RPATH="PATH=$LUSTRE/tests/:$PATH"
3317 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
3320 wait_clients_import_state () {
3327 if [ "$FAILURE_MODE" = HARD ]; then
3328 facets=$(facets_on_host $(facet_active_host $facet))
3331 for facet in ${facets//,/ }; do
3332 local label=$(convert_facet2label $facet)
3335 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3336 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3337 *) error "unknown facet!" ;;
3339 local params=$(expand_list $params $proc_path)
3342 if ! do_rpc_nodes $list wait_import_state $expected $params; then
3343 error "import is not in ${expected} state"
3348 destroy_pool_int() {
3350 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
3351 for ost in $OSTS; do
3352 do_facet mgs lctl pool_remove $1 $ost
3354 do_facet mgs lctl pool_destroy $1
3357 # <fsname>.<poolname> or <poolname>
3359 local fsname=${1%%.*}
3360 local poolname=${1##$fsname.}
3362 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3366 pool_list $fsname.$poolname || return $?
3368 destroy_pool_int $fsname.$poolname
3370 [[ $RC -ne 0 ]] && return $RC
3372 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3373 2>/dev/null || echo foo" "foo" || RC=1
3375 if [[ $RC -eq 0 ]]; then
3376 remove_pool_from_list $fsname.$poolname
3378 error "destroy pool failed $1"
3384 local fsname=${1:-$FSNAME}
3386 local listvar=${fsname}_CREATED_POOLS
3390 [ x${!listvar} = x ] && return 0
3392 echo destroy the created pools: ${!listvar}
3393 for poolname in ${!listvar//,/ }; do
3394 destroy_pool $fsname.$poolname
3399 local fsname=${1:-$FSNAME}
3401 destroy_pools $fsname
3407 local ts=$(date +%s)
3409 # bug 20237, comment 11
3410 # It would also be useful to provide the option
3411 # of writing the file to an NFS directory so it doesn't need to be copied.
3414 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3416 # dump lustre logs, dmesg
3417 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3418 lctl dk \\\$log >/dev/null;
3419 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3422 # FIXME: does it make sense to collect the logs for $ts only, but all
3424 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3425 local logs=$TMP/'*'${TESTSUITE}'*'
3427 logs=$logs' '$tmp/'*'$ts'*'
3429 for node in ${list//,/ }; do
3430 rsync -az $node:"$logs" $TMP
3433 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3434 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3440 local list=${1:-$(comma_list $(nodes_list))}
3442 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3454 for i in $(seq 0 $num_mntpts); do
3455 cmd="ls -laf ${mntpt_root}$i/$dir"
3461 for pid in $pids; do
3468 # target_start_and_reset_recovery_timer()
3469 # service_time = at_est2timeout(service_time);
3470 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC +
3471 # INITIAL_CONNECT_TIMEOUT);
3472 # CONNECTION_SWITCH_MAX : min(25U, max(CONNECTION_SWITCH_MIN,obd_timeout))
3473 #define CONNECTION_SWITCH_INC 1
3474 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
3475 #define CONNECTION_SWITCH_MIN 5U
3477 max_recovery_time () {
3478 local init_connect_timeout=$(( TIMEOUT / 20 ))
3479 [[ $init_connect_timeout > 5 ]] || init_connect_timeout=5
3481 local service_time=$(( $(at_max_get client) + $(( 2 * $(( 25 + 1 + init_connect_timeout)) )) ))
3486 remove_mdt_files() {
3491 local mntpt=${MOUNT%/*}/$facet
3493 echo "removing files from $mdtdev on $facet: $files"
3494 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3497 rm $mntpt/ROOT/$f || { rc=$?; break; }
3499 umount -f $mntpt || return $?
3503 duplicate_mdt_files() {
3508 local mntpt=${MOUNT%/*}/$facet
3510 echo "duplicating files on $mdtdev on $facet: $files"
3511 mkdir -p $mntpt || return $?
3512 mount -t $FSTYPE $MDS_MOUNT_OPTS $mdtdev $mntpt || return $?
3522 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
3523 pushd $mntpt/ROOT > /dev/null || return $?
3526 touch $f.bad || return $?
3527 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
3529 [ $rc -eq 0 ] || return $rc
3530 setfattr --restore $tmp || return $?
3536 local devs=${1//,/ }
3539 local rslt=$TMP/sgpdd_survey
3541 # sgpdd-survey cleanups ${rslt}.* files
3543 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"