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 MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
114 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
115 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
116 export PATH=$PATH:$LUSTRE/tests/racer
118 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
119 export PATH=$PATH:$LUSTRE/tests/mpi
121 export RSYNC_RSH=${RSYNC_RSH:-rsh}
122 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
123 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
124 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
125 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
126 [ ! -f "$LFS" ] && export LFS=$(which lfs)
127 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
128 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
129 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
130 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
131 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
132 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
133 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
134 export FSTYPE=${FSTYPE:-"ldiskfs"}
135 export NAME=${NAME:-local}
137 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
139 if [ "$ACCEPTOR_PORT" ]; then
140 export PORT_OPT="--port $ACCEPTOR_PORT"
143 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
145 # Paths on remote nodes, if different
146 export RLUSTRE=${RLUSTRE:-$LUSTRE}
147 export RPWD=${RPWD:-$PWD}
148 export I_MOUNTED=${I_MOUNTED:-"no"}
149 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
150 ! -f `dirname $0`/../mds/mds.ko ]; then
151 export CLIENTMODSONLY=yes
156 while getopts "rvwf:" opt $*; do
159 r) REFORMAT=--reformat;;
161 w) WRITECONF=writeconf;;
166 shift $((OPTIND - 1))
169 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
174 *) EXT=".ko"; USE_QUOTA=yes;;
178 do_facet mgs lctl pool_list $1
182 local fsname=${1%%.*}
183 local poolname=${1##$fsname.}
185 do_facet mgs lctl pool_new $1
187 # get param should return err unless pool is created
188 [[ $RC -ne 0 ]] && return $RC
190 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
191 2>/dev/null || echo foo" "" || RC=1
192 if [[ $RC -eq 0 ]]; then
195 error "pool_new failed $1"
200 add_pool_to_list () {
201 local fsname=${1%%.*}
202 local poolname=${1##$fsname.}
204 local listvar=${fsname}_CREATED_POOLS
205 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
208 remove_pool_from_list () {
209 local fsname=${1%%.*}
210 local poolname=${1##$fsname.}
212 local listvar=${fsname}_CREATED_POOLS
213 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
217 /sbin/lsmod | grep -q $1
223 BASE=`basename $module $EXT`
225 module_loaded ${BASE} && return
227 if [ -f ${LUSTRE}/${module}${EXT} ]; then
228 insmod ${LUSTRE}/${module}${EXT} $@
230 # must be testing a "make install" or "rpm" installation
235 load_modules_local() {
236 if [ -n "$MODPROBE" ]; then
240 if [ "$HAVE_MODULES" = true ]; then
246 echo Loading modules from $LUSTRE
247 load_module ../lnet/libcfs/libcfs
248 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
249 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
251 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
252 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
253 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
254 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
255 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
257 # disable it for now since it only hides the stack overflow upon test w/
259 # if [ "$NETTYPE" = "tcp" -o "$NETTYPE" = "o2ib" -o "$NETTYPE" = "ptl" ]; then
260 # echo $LNETOPTS | grep -q "local_nid_dist_zero=0" ||
261 # LNETOPTS="$LNETOPTS local_nid_dist_zero=0"
263 echo "lnet options: '$LNETOPTS'"
264 # note that insmod will ignore anything in modprobe.conf
265 load_module ../lnet/lnet/lnet $LNETOPTS
266 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
267 load_module ../lnet/klnds/$LNETLND
268 load_module lvfs/lvfs
269 load_module obdclass/obdclass
270 load_module ptlrpc/ptlrpc
271 [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota
276 if ! client_only; then
279 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
280 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
281 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
282 load_module lvfs/fsfilt_$FSTYPE
284 load_module obdfilter/obdfilter
287 load_module llite/lustre
288 load_module llite/llite_lloop
289 rm -f $TMP/ogdb-$HOSTNAME
291 [ -d /r ] && OGDB="/r/tmp"
292 $LCTL modules > $OGDB/ogdb-$HOSTNAME
293 # 'mount' doesn't look in $PATH, just sbin
294 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
300 # load modules on remote nodes optionally
301 # lustre-tests have to be installed on these nodes
302 if $LOAD_MODULES_REMOTE ; then
303 local list=$(comma_list $(remote_nodes_list))
304 echo loading modules on $list
305 do_rpc_nodes $list load_modules
310 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
311 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
312 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
313 echo "$LEAK_LUSTRE" 1>&2
314 echo "$LEAK_PORTALS" 1>&2
315 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
316 echo "Memory leaks detected"
317 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
323 wait_exit_ST client # bug 12845
325 if $LOAD_MODULES_REMOTE ; then
326 local list=$(comma_list $(remote_nodes_list))
327 echo unloading modules on $list
328 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
329 do_rpc_nodes $list check_mem_leak
332 $LUSTRE_RMMOD $FSTYPE || return 2
336 check_mem_leak || return 254
338 echo "modules unloaded."
346 local dev=$(facet_active $facet)_dev
347 local opt=${facet}_opt
348 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
349 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
351 if [ $RC -ne 0 ]; then
352 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
353 echo "Start of ${!dev} on ${facet} failed ${RC}"
355 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
356 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
357 lctl set_param debug_mb=${DEBUG_SIZE}; \
360 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
361 [ -z "$label" ] && echo no label for ${!dev} && exit 1
362 eval export ${facet}_svc=${label}
363 echo Started ${label}
368 # start facet device options
374 eval export ${facet}_dev=${device}
375 eval export ${facet}_opt=\"$@\"
377 local varname=${facet}failover_dev
378 if [ -n "${!varname}" ] ; then
379 eval export ${facet}failover_dev=${!varname}
381 eval export ${facet}failover_dev=$device
384 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
394 HOST=`facet_active_host $facet`
395 [ -z $HOST ] && echo stop: no host for $facet && return 0
397 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
398 if [ ${running} -ne 0 ]; then
399 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
400 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
403 # umount should block, but we should wait for unrelated obd's
404 # like the MGS or MGC to also stop.
406 wait_exit_ST ${facet}
409 # set quota version (both administrative and operational quotas)
410 quota_set_version() {
411 do_facet mds "lctl set_param lquota.${FSNAME}-MDT*.quota_type=$1"
413 local osts=$(get_facets OST)
414 for ost in ${osts//,/ }; do
416 do_facet $ost "lctl set_param lquota.${!varsvc}.quota_type=$1"
420 # save quota version (both administrative and operational quotas)
421 # the function will also switch to the new version and the new type
422 quota_save_version() {
424 local ver=$(tr -c -d "123" <<< $spec)
425 local type=$(tr -c -d "ug" <<< $spec)
427 $LFS quotaoff -ug $MOUNT # just in case
428 [ -n "$ver" ] && quota_set_version $ver
429 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
431 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdt.quota_type=$spec"
433 local osts=$(get_facets OST)
434 for ost in ${osts//,/ }; do
436 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
440 # client could mount several lustre
442 local fsname=${1:-$FSNAME}
444 do_facet mgs lctl get_param mds.${fsname}-MDT*.quota_type || rc=$?
445 do_nodes $(comma_list $(osts_nodes)) \
446 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
450 restore_quota_type () {
451 local mntpt=${1:-$MOUNT}
452 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
453 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
456 quota_save_version $old_QUOTA_TYPE
463 # 1. run quotacheck only if quota is off
464 # 2. save the original quota_type params, restore them after testing
466 # Suppose that quota type the same on mds and ost
467 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
468 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
469 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
470 export old_QUOTA_TYPE=$quota_type
471 quota_save_version $QUOTA_TYPE
474 local quota_usrs=$QUOTA_USERS
476 # get_filesystem_size
477 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
478 local blk_soft=$((disksz + 1024))
479 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
481 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
483 local i_hard=$((i_soft + i_soft / 20))
485 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
486 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
489 for usr in $quota_usrs; do
490 echo "Setting up quota on $client:$mntpt for $usr..."
492 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
494 eval $cmd || error "$cmd FAILED!"
496 # display the quota status
497 echo "Quota settings for $usr : "
498 $LFS quota -v -u $usr $mntpt || true
506 # Only supply -o to mount if we have options
507 if [ -n "$MOUNTOPT" ]; then
508 OPTIONS="-o $MOUNTOPT"
510 local device=$MGSNID:/$FSNAME
511 if [ -z "$mnt" -o -z "$FSNAME" ]; then
512 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
516 echo "Starting client: $client: $OPTIONS $device $mnt"
517 do_node $client mkdir -p $mnt
518 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
519 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
520 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
521 lctl set_param debug_mb=${DEBUG_SIZE}"
534 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
535 if [ $running -ne 0 ]; then
536 echo "Stopping client $client $mnt (opts:$force)"
537 do_node $client lsof -t $mnt || need_kill=no
538 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
539 pids=$(do_node $client lsof -t $mnt | sort -u);
540 if [ -n $pids ]; then
541 do_node $client kill -9 $pids || true
545 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
546 if [ $busy -ne 0 ] ; then
547 echo "$mnt is still busy, wait one second" && sleep 1
548 do_node $client umount $force $mnt
553 # nodes is comma list
554 sanity_mount_check_nodes () {
560 # FIXME: assume that all cluster nodes run the same os
561 [ "$(uname)" = Linux ] || return 0
564 for mnt in $mnts ; do
565 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
566 mpts=\\\$(mount | grep -w -c $mnt);
567 if [ \\\$running -ne \\\$mpts ]; then
568 echo \\\$(hostname) env are INSANE!;
576 sanity_mount_check_servers () {
578 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
579 echo Checking servers environments
581 # FIXME: modify get_facets to display all facets wo params
582 local facets="$(get_facets OST),$(get_facets MDS),mgs"
586 for facet in ${facets//,/ }; do
587 node=$(facet_host ${facet})
588 mnt=${MOUNT%/*}/${facet}
589 sanity_mount_check_nodes $node $mnt ||
590 { error "server $node environments are insane!"; return 1; }
594 sanity_mount_check_clients () {
595 local clients=${1:-$CLIENTS}
596 local mntpt=${2:-$MOUNT}
597 local mntpt2=${3:-$MOUNT2}
599 [ -z $clients ] && clients=$(hostname)
600 echo Checking clients $clients environments
602 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
603 error "clients environments are insane!"
606 sanity_mount_check () {
607 sanity_mount_check_servers || return 1
608 sanity_mount_check_clients || return 2
611 # mount clients if not mouted
612 zconf_mount_clients() {
615 local OPTIONS=${3:-$MOUNTOPT}
617 # Only supply -o to mount if we have options
618 if [ "$OPTIONS" ]; then
619 OPTIONS="-o $OPTIONS"
621 local device=$MGSNID:/$FSNAME
622 if [ -z "$mnt" -o -z "$FSNAME" ]; then
623 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
627 echo "Starting client $clients: $OPTIONS $device $mnt"
630 running=\\\$(mount | grep -c $mnt' ');
632 if [ \\\$running -eq 0 ] ; then
634 mount -t lustre $OPTIONS $device $mnt;
639 echo "Started clients $clients: "
640 do_nodes $clients "mount | grep -w $mnt"
642 do_nodes $clients "sysctl -w lnet.debug=\\\"$PTLDEBUG\\\";
643 sysctl -w lnet.subsystem_debug=\\\"${SUBSYSTEM# }\\\";
644 sysctl -w lnet.debug_mb=${DEBUG_SIZE};"
649 zconf_umount_clients() {
656 echo "Stopping clients: $clients $mnt (opts:$force)"
657 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
658 if [ \\\$running -ne 0 ] ; then
659 echo Stopping client \\\$(hostname) $mnt opts:$force;
660 lsof -t $mnt || need_kill=no;
661 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
662 pids=\\\$(lsof -t $mnt | sort -u);
663 if [ -n \\\"\\\$pids\\\" ]; then
667 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
668 if [ \\\$busy -ne 0 ] ; then
669 echo "$mnt is still busy, wait one second" && sleep 1;
675 shudown_node_hard () {
679 for i in $(seq $attempts) ; do
682 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
683 echo "waiting for $host to fail attempts=$attempts"
684 [ $i -lt $attempts ] || \
685 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
691 local mnt=${2:-$MOUNT}
694 if [ "$FAILURE_MODE" = HARD ]; then
695 shudown_node_hard $client
697 zconf_umount_clients $client $mnt -f
703 if [ "$FAILURE_MODE" = HARD ]; then
704 shudown_node_hard $(facet_active_host $facet)
705 elif [ "$FAILURE_MODE" = SOFT ]; then
712 if [ "$FAILURE_MODE" = HARD ]; then
713 $POWER_UP `facet_active_host $facet`
721 if [ "$FAILURE_MODE" = HARD ]; then
727 # recovery-scale functions
728 check_progs_installed () {
733 do_nodes $clients "PATH=:$PATH; status=true;
734 for prog in $progs; do
735 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
736 echo \\\$prog missing on \\\$(hostname);
744 echo __$(echo $1 | tr '-' 'X')
747 start_client_load() {
750 local var=$(client_var_name $client)_load
751 eval export ${var}=$load
753 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
754 BREAK_ON_ERROR=$BREAK_ON_ERROR \
755 END_RUN_FILE=$END_RUN_FILE \
756 LOAD_PID_FILE=$LOAD_PID_FILE \
757 TESTSUITELOG=$TESTSUITELOG \
759 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
760 log "Started client load: ${load} on $client"
765 start_client_loads () {
766 local -a clients=(${1//,/ })
767 local numloads=${#CLIENT_LOADS[@]}
770 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
771 testnum=$((nodenum % numloads))
772 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
776 # only for remote client
777 check_client_load () {
779 local var=$(client_var_name $client)_load
780 local TESTLOAD=run_${!var}.sh
782 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
784 # bug 18914: try to connect several times not only when
785 # check ps, but while check_catastrophe also
788 while [ $RC = 254 -a $tries -gt 0 ]; do
792 if ! check_catastrophe $client; then
794 if [ $RC -eq 254 ]; then
795 # FIXME: not sure how long we shuold sleep here
799 echo "check catastrophe failed: RC=$RC "
804 # We can continue try to connect if RC=254
805 # Just print the warning about this
806 if [ $RC = 254 ]; then
807 echo "got a return status of $RC from do_node while checking catastrophe on $client"
810 # see if the load is still on the client
813 while [ $RC = 254 -a $tries -gt 0 ]; do
817 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
822 if [ $RC = 254 ]; then
823 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
824 # see if we can diagnose a bit why this is
829 check_client_loads () {
830 local clients=${1//,/ }
834 for client in $clients; do
835 check_client_load $client
837 if [ "$rc" != 0 ]; then
838 log "Client load failed on node $client, rc=$rc"
844 restart_client_loads () {
845 local clients=${1//,/ }
846 local expectedfail=${2:-""}
850 for client in $clients; do
851 check_client_load $client
853 if [ "$rc" != 0 -a "$expectedfail" ]; then
854 local var=$(client_var_name $client)_load
855 start_client_load $client ${!var}
856 echo "Restarted client load ${!var}: on $client. Checking ..."
857 check_client_load $client
859 if [ "$rc" != 0 ]; then
860 log "Client load failed to restart on node $client, rc=$rc"
861 # failure one client load means test fail
862 # we do not need to check other
870 # End recovery-scale functions
872 # verify that lustre actually cleaned up properly
874 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
875 error "LBUG/LASSERT detected"
876 BUSY=`dmesg | grep -i destruct || true`
879 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
883 check_mem_leak || exit 204
885 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
886 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
888 if module_loaded lnet || module_loaded libcfs; then
889 echo "$0: modules still loaded..." 1>&2
906 RESULT=$(do_node $node "$TEST")
907 if [ "$RESULT" == "$FINAL" ]; then
908 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
911 [ $WAIT -ge $MAX ] && break
912 echo "Waiting $((MAX - WAIT)) secs for update"
913 WAIT=$((WAIT + sleep))
916 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
920 wait_update_facet () {
923 wait_update $(facet_active_host $facet) "$@"
926 wait_delete_completed () {
927 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
928 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
932 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
934 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
935 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
936 [ "$TOTAL" -eq "$TOTALPREV" ] && break
937 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
941 echo "Delete completed."
946 check_network "$host" 900
947 while ! do_node $host hostname > /dev/null; do sleep 5; done
952 local host=`facet_active_host $facet`
956 wait_recovery_complete () {
959 # Use default policy if $2 is not passed by caller.
960 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
961 # as we are in process of changing obd_timeout in different ways
962 # let's set MAX longer than that
963 local MAX=${2:-$(( TIMEOUT * 4 ))}
965 local var_svc=${facet}_svc
966 local procfile="*.${!var_svc}.recovery_status"
970 while [ $WAIT -lt $MAX ]; do
971 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
972 [[ $STATUS = "status: COMPLETE" ]] && return 0
975 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
977 echo "$facet recovery not done in $MAX sec. $STATUS"
987 # conf-sanity 31 takes a long time cleanup
988 while [ $WAIT -lt 300 ]; do
989 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
990 [ -z "${running}" ] && return 0
991 echo "waited $WAIT for${running}"
992 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
994 WAIT=$((WAIT + INTERVAL))
996 echo "service didn't stop after $WAIT seconds. Still running:"
1001 wait_remote_prog () {
1007 [ "$PDSH" = "no_dsh" ] && return 0
1009 while [ $WAIT -lt $2 ]; do
1010 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1011 [ -z "${running}" ] && return 0 || true
1012 echo "waited $WAIT for: "
1014 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1016 WAIT=$((WAIT + INTERVAL))
1018 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1019 [ -z "$pids" ] && return 0
1020 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1021 # FIXME: not portable
1022 for pid in $pids; do
1023 cat /proc/${pid}/status || true
1024 cat /proc/${pid}/wchan || true
1026 kill -9 $pid || true
1035 # not every config has many clients
1037 if [ -n "$CLIENTS" ]; then
1038 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1040 stat -f $MOUNT > /dev/null
1046 # usually checked on particular client or locally
1048 if [ ! -z "$client" ]; then
1049 $PDSH $client "stat -f $MOUNT" > /dev/null
1051 stat -f $MOUNT > /dev/null
1059 client_reconnect() {
1060 uname -n >> $MOUNT/recon
1061 if [ -z "$CLIENTS" ]; then
1062 df $MOUNT; uname -n >> $MOUNT/recon
1064 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1066 echo Connected clients:
1068 ls -l $MOUNT/recon > /dev/null
1075 echo "Failing $facet on node `facet_active_host $facet`"
1076 shutdown_facet $facet
1077 [ -n "$sleep_time" ] && sleep $sleep_time
1081 RECOVERY_START_TIME=`date +%s`
1082 echo "df pid is $DFPID"
1083 change_active $facet
1084 local TO=`facet_active_host $facet`
1085 echo "Failover $facet to $TO"
1087 mount_facet $facet || error "Restart of $facet failed"
1096 do_facet $facet sync
1098 local svc=${facet}_svc
1099 do_facet $facet $LCTL --device %${!svc} notransno
1100 do_facet $facet $LCTL --device %${!svc} readonly
1101 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1102 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1105 replay_barrier_nodf() {
1106 local facet=$1 echo running=${running}
1107 do_facet $facet sync
1108 local svc=${facet}_svc
1109 echo Replay barrier on ${!svc}
1110 do_facet $facet $LCTL --device %${!svc} notransno
1111 do_facet $facet $LCTL --device %${!svc} readonly
1112 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1113 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1116 mds_evict_client() {
1117 UUID=`lctl get_param -n mdc.${mds_svc}-mdc-*.uuid`
1118 local mdtdevice=$(get_mds_mdt_device_proc_path)
1119 do_facet mds "lctl set_param -n ${mdtdevice}.${mds_svc}.evict_client $UUID"
1122 ost_evict_client() {
1123 UUID=`lctl get_param -n osc.${ost1_svc}-osc-*.uuid`
1124 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1128 facet_failover $* || error "failover: $?"
1129 clients_up || error "post-failover df: $?"
1134 facet_failover $facet
1140 change_active $facet
1141 mount_facet $facet -o abort_recovery
1142 clients_up || echo "first df failed: $?"
1143 clients_up || error "post-failover df: $?"
1147 echo There is no lmc. This is mountconf, baby.
1152 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1153 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1159 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1165 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1166 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1167 if [ -z "$ID" ]; then
1168 echo "Could not get a ptl id for $1..."
1177 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1184 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1185 if type __h2elan >/dev/null 2>&1; then
1188 ID=`echo $1 | sed 's/[^0-9]*//g'`
1196 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1197 ID=`echo $1 | sed 's/[^0-9]*//g'`
1201 declare -fx h2openib
1204 h2name_or_ip "$1" "o2ib"
1211 [ "$facet" == client ] && echo -n $HOSTNAME && return
1212 varname=${facet}_HOST
1213 if [ -z "${!varname}" ]; then
1214 if [ "${facet:0:3}" == "ost" ]; then
1215 eval ${facet}_HOST=${ost_HOST}
1223 local activevar=${facet}active
1225 if [ -f $TMP/${facet}active ] ; then
1226 source $TMP/${facet}active
1229 active=${!activevar}
1230 if [ -z "$active" ] ; then
1237 facet_active_host() {
1239 local active=`facet_active $facet`
1240 if [ "$facet" == client ]; then
1243 echo `facet_host $active`
1249 local failover=${facet}failover
1250 host=`facet_host $failover`
1251 [ -z "$host" ] && return
1252 local curactive=`facet_active $facet`
1253 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1254 eval export ${facet}active=$facet
1256 eval export ${facet}active=$failover
1258 # save the active host for this facet
1259 local activevar=${facet}active
1260 echo "$activevar=${!activevar}" > $TMP/$activevar
1265 # do not stripe off hostname if verbose, bug 19215
1266 if [ x$1 = x--verbose ]; then
1274 if [ "$HOST" = "$HOSTNAME" ]; then
1276 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1277 echo "cannot run remote command on $HOST with $myPDSH"
1281 echo "CMD: $HOST $@" >&2
1282 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1285 if [ "$myPDSH" = "rsh" ]; then
1286 # we need this because rsh does not return exit code of an executed command
1287 local command_status="$TMP/cs"
1288 rsh $HOST ":> $command_status"
1289 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1290 cd $RPWD; sh -c \"$@\") ||
1291 echo command failed >$command_status"
1292 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1297 # print HOSTNAME for myPDSH="no_dsh"
1298 if [[ $myPDSH = no_dsh ]]; then
1299 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1301 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1304 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1306 return ${PIPESTATUS[0]}
1309 single_local_node () {
1310 [ "$1" = "$HOSTNAME" ]
1315 # do not stripe off hostname if verbose, bug 19215
1316 if [ x$1 = x--verbose ]; then
1324 if $(single_local_node $rnodes); then
1326 do_node --verbose $rnodes $@
1333 # This is part from do_node
1336 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1337 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1340 echo "CMD: $rnodes $@" >&2
1341 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1345 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1347 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1349 return ${PIPESTATUS[0]}
1355 local HOST=`facet_active_host $facet`
1356 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1363 # make sure its not already running
1365 rm -f $TMP/${facet}active
1366 do_facet ${facet} $MKFS $*
1372 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1373 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1381 # make sure we are using the primary server, so test-framework will
1382 # be able to clean up properly.
1383 activemds=`facet_active mds`
1384 if [ $activemds != "mds" ]; then
1388 local clients=$CLIENTS
1389 [ -z $clients ] && clients=$(hostname)
1391 zconf_umount_clients $clients $MOUNT "$*" || true
1392 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1394 [ "$CLIENTONLY" ] && return
1395 # The add fn does rm ${facet}active file, this would be enough
1396 # if we use do_facet <facet> only after the facet added, but
1397 # currently we use do_facet mds in local.sh
1399 rm -f ${TMP}/mdsactive
1400 for num in `seq $OSTCOUNT`; do
1402 rm -f $TMP/ost${num}active
1404 if [[ $MDSDEV != $MGSDEV ]]; then
1412 nfs_client_mode && return
1419 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1422 # We need ldiskfs here, may as well load them all
1424 [ "$CLIENTONLY" ] && return
1425 echo Formatting mgs, mds, osts
1426 if [[ $MDSDEV != $MGSDEV ]] || [[ $mds_HOST != $mgs_HOST ]]; then
1427 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1431 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
1433 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1436 for num in `seq $OSTCOUNT`; do
1438 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1440 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1446 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1451 zconf_umount `hostname` $1 || error "umount failed"
1452 zconf_mount `hostname` $1 || error "mount failed"
1455 writeconf_facet () {
1459 do_facet $facet "$TUNEFS --writeconf $dev"
1463 writeconf_facet mds $MDSDEV
1465 for num in `seq $OSTCOUNT`; do
1466 DEVNAME=`ostdevname $num`
1467 writeconf_facet ost$num $DEVNAME
1472 nfs_client_mode && return
1474 sanity_mount_check ||
1475 error "environments are insane!"
1478 if [ -z "$CLIENTONLY" ]; then
1479 echo Setup mgs, mdt, osts
1481 echo $WRITECONF | grep -q "writeconf" && \
1484 if [[ $mds_HOST != $mgs_HOST ]] || [[ $MDSDEV != $MGSDEV ]]; then
1485 start mgs $MGSDEV $mgs_MOUNT_OPTS
1488 start mds $MDSDEV $MDS_MOUNT_OPTS
1489 # We started mds, now we should set failover variable properly.
1490 # Set mdsfailover_HOST if it is not set (the default failnode).
1491 if [ -z "$mdsfailover_HOST" ]; then
1492 mdsfailover_HOST=$(facet_host mds)
1495 for num in `seq $OSTCOUNT`; do
1496 DEVNAME=`ostdevname $num`
1497 start ost$num $DEVNAME $OST_MOUNT_OPTS
1499 # We started ost$num, now we should set ost${num}failover variable properly.
1500 # Set ost${num}failover_HOST if it is not set (the default failnode).
1501 varname=ost${num}failover_HOST
1502 if [ -z "${!varname}" ]; then
1503 eval ost${num}failover_HOST=$(facet_host ost${num})
1508 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1510 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1512 if [ "$MOUNT_2" ]; then
1513 mount_client $MOUNT2
1514 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1520 mounted_lustre_filesystems() {
1521 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1524 init_facet_vars () {
1525 [ "$CLIENTONLY" ] && return 0
1532 eval export ${facet}_dev=${device}
1533 eval export ${facet}_opt=\"$@\"
1535 local dev=${facet}_dev
1536 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1537 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1539 eval export ${facet}_svc=${label}
1541 local varname=${facet}failover_HOST
1542 if [ -z "${!varname}" ]; then
1543 eval $varname=$(facet_host $facet)
1546 # ${facet}failover_dev is set in cfg file
1547 varname=${facet}failover_dev
1548 if [ -n "${!varname}" ] ; then
1549 eval export ${facet}failover_dev=${!varname}
1551 eval export ${facet}failover_dev=$device
1555 init_facets_vars () {
1557 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1559 remote_ost_nodsh && return
1561 for num in `seq $OSTCOUNT`; do
1562 DEVNAME=`ostdevname $num`
1563 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1567 init_param_vars () {
1568 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1569 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1570 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1571 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1575 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1577 log "Using TIMEOUT=$TIMEOUT"
1579 if [ "$ENABLE_QUOTA" ]; then
1580 setup_quota $MOUNT || return 2
1584 nfs_client_mode () {
1585 if [ "$NFSCLIENT" ]; then
1586 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1587 local clients=$CLIENTS
1588 [ -z $clients ] && clients=$(hostname)
1590 # FIXME: remove hostname when 19215 fixed
1591 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1592 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1593 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1599 check_config_client () {
1602 local mounted=$(mount | grep " $mntpt ")
1603 if [ "$CLIENTONLY" ]; then
1605 # CLIENTONLY should not depend on *_HOST settings
1606 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1607 # in theory someone could create a new,
1608 # client-only config file that assumed lustre was already
1609 # configured and didn't set the MGSNID. If MGSNID is not set,
1610 # then we should use the mgs nid currently being used
1611 # as the default value. bug 18021
1612 [[ x$MGSNID = x ]] &&
1615 if [[ x$mgc != xMGC$MGSNID ]]; then
1616 if [ "$mgs_HOST" ]; then
1617 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1618 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1619 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1625 local myMGS_host=$mgs_HOST
1626 if [ "$NETTYPE" = "ptl" ]; then
1627 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1630 echo Checking config lustre mounted on $mntpt
1631 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1632 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1634 # if [ "$mgshost" != "$myMGS_host" ]; then
1635 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1636 # Please use correct config or set mds_HOST correctly!"
1641 check_config_clients () {
1642 local clients=${CLIENTS:-$HOSTNAME}
1645 nfs_client_mode && return
1647 do_rpc_nodes $clients check_config_client $mntpt
1649 sanity_mount_check ||
1650 error "environments are insane!"
1654 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
1655 local cltimeout=$(lctl get_param -n timeout)
1656 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1657 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1664 local mounted=$(mounted_lustre_filesystems)
1666 echo $mounted' ' | grep -w -q $mntpt' '
1669 check_and_setup_lustre() {
1670 nfs_client_mode && return
1672 local MOUNTED=$(mounted_lustre_filesystems)
1676 # both MOUNT and MOUNT2 are not mounted
1677 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
1678 [ "$REFORMAT" ] && formatall
1679 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
1681 is_mounted $MOUNT || error "NAME=$NAME not mounted"
1682 export I_MOUNTED=yes
1686 elif is_mounted $MOUNT2; then
1688 # MOUNT2 is mounted, while MOUNT_2 is not set
1689 if ! [ "$MOUNT_2" ]; then
1690 cleanup_mount $MOUNT2
1691 export I_UMOUNTED2=yes
1694 # MOUNT2 is mounted, MOUNT_2 is set
1696 # FIXME: what to do if check_config failed?
1698 # 1) remote client has mounted other Lustre fs ?
1699 # 2) it has insane env ?
1700 # let's try umount MOUNT2 on all clients and mount it again:
1701 if ! check_config_clients $MOUNT2; then
1702 cleanup_mount $MOUNT2
1703 restore_mount $MOUNT2
1704 export I_MOUNTED2=yes
1709 # MOUNT is mounted MOUNT2 is not mounted
1710 elif [ "$MOUNT_2" ]; then
1711 restore_mount $MOUNT2
1712 export I_MOUNTED2=yes
1716 # FIXME: what to do if check_config failed?
1718 # 1) remote client has mounted other Lustre fs?
1719 # 2) lustre is mounted on remote_clients atall ?
1720 check_config_clients $MOUNT
1724 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1725 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1726 lctl set_param debug_mb=${DEBUG_SIZE};
1729 if [ "$ONLY" == "setup" ]; then
1735 local clients=${CLIENTS:-$HOSTNAME}
1738 zconf_mount_clients $clients $mntpt
1742 local clients=${CLIENTS:-$HOSTNAME}
1745 zconf_umount_clients $clients $mntpt
1748 cleanup_and_setup_lustre() {
1749 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1750 lctl set_param debug=0 || true
1752 if [ "$ONLY" == "cleanup" ]; then
1756 check_and_setup_lustre
1759 check_and_cleanup_lustre() {
1760 if is_mounted $MOUNT; then
1761 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1762 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1765 if [ "$I_UMOUNTED2" = "yes" ]; then
1766 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
1769 if [ "$I_MOUNTED2" = "yes" ]; then
1770 cleanup_mount $MOUNT2
1773 if [ "$I_MOUNTED" = "yes" ]; then
1774 cleanupall -f || error "cleanup failed"
1786 while [ $NETWORK -eq 0 ]; do
1787 if ping -c 1 -w 3 $1 > /dev/null; then
1791 echo "waiting for $1, $((MAX - WAIT)) secs left"
1794 if [ $WAIT -gt $MAX ]; then
1795 echo "Network not available"
1801 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1812 # the sed converts spaces to commas, but leaves the last space
1813 # alone, so the line doesn't end with a comma.
1814 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1817 # list, excluded are the comma separated lists
1818 exclude_items_from_list () {
1824 for item in ${excluded//,/ }; do
1825 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1827 echo $(comma_list $list)
1830 # list, expand are the comma separated lists
1832 local list=${1//,/ }
1833 local expand=${2//,/ }
1836 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1837 echo $(comma_list $expanded)
1840 testslist_filter () {
1841 local script=$LUSTRE/tests/${TESTSUITE}.sh
1843 [ -f $script ] || return 0
1845 local start_at=$START_AT
1846 local stop_at=$STOP_AT
1848 local var=${TESTSUITE//-/_}_START_AT
1849 [ x"${!var}" != x ] && start_at=${!var}
1850 var=${TESTSUITE//-/_}_STOP_AT
1851 [ x"${!var}" != x ] && stop_at=${!var}
1853 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
1854 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
1855 /^'${start_at}'$/ {flag = 0}
1856 {if (flag == 1) print $0}
1857 /^'${stop_at}'$/ { flag = 1 }'
1861 (cd `dirname $1`; echo $PWD/`basename $1`)
1865 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1866 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1872 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
1873 list="$list ${name}$i"
1875 * ) error "Invalid facet type"
1878 echo $(comma_list $list)
1881 ##################################
1882 # Adaptive Timeouts funcs
1885 # only check mds, we assume at_max is the same on all nodes
1886 local at_max=$(do_facet mds "lctl get_param -n at_max")
1887 if [ $at_max -eq 0 ]; then
1897 # suppose that all ost-s has the same at_max set
1898 if [ $facet == "ost" ]; then
1899 do_facet ost1 "lctl get_param -n at_max"
1901 do_facet $facet "lctl get_param -n at_max"
1911 if [ $facet == "ost" ]; then
1912 for i in `seq $OSTCOUNT`; do
1913 do_facet ost$i "lctl set_param at_max=$at_max"
1916 do_facet $facet "lctl set_param at_max=$at_max"
1921 ##################################
1925 # OBD_FAIL_MDS_ALL_REQUEST_NET
1927 do_facet mds lctl set_param fail_loc=0x123
1928 do_facet client "$1" || RC=$?
1929 do_facet mds lctl set_param fail_loc=0
1934 # OBD_FAIL_MDS_ALL_REPLY_NET
1936 do_facet mds lctl set_param fail_loc=0x122
1937 do_facet client "$@" || RC=$?
1938 do_facet mds lctl set_param fail_loc=0
1942 drop_reint_reply() {
1943 # OBD_FAIL_MDS_REINT_NET_REP
1945 do_facet mds lctl set_param fail_loc=0x119
1946 do_facet client "$@" || RC=$?
1947 do_facet mds lctl set_param fail_loc=0
1952 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1954 do_facet ost1 lctl set_param fail_loc=0x214
1955 do_facet client "$1" || RC=$?
1956 do_facet client "sync"
1957 do_facet ost1 lctl set_param fail_loc=0
1961 drop_ldlm_cancel() {
1962 #define OBD_FAIL_LDLM_CANCEL 0x304
1964 do_facet client lctl set_param fail_loc=0x304
1965 do_facet client "$@" || RC=$?
1966 do_facet client lctl set_param fail_loc=0
1970 drop_bl_callback() {
1971 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1973 do_facet client lctl set_param fail_loc=0x305
1974 do_facet client "$@" || RC=$?
1975 do_facet client lctl set_param fail_loc=0
1980 #define OBD_FAIL_LDLM_REPLY 0x30c
1982 do_facet mds lctl set_param fail_loc=0x30c
1983 do_facet client "$@" || RC=$?
1984 do_facet mds lctl set_param fail_loc=0
1992 echo "clearing fail_loc on $facet"
1993 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1996 set_nodes_failloc () {
1997 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2000 cancel_lru_locks() {
2001 $LCTL mark "cancel_lru_locks $1 start"
2002 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2003 $LCTL set_param -n $d=clear
2005 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2006 $LCTL mark "cancel_lru_locks $1 stop"
2011 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2012 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2013 echo "$DEFAULT_LRU_SIZE"
2018 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2021 lru_resize_disable()
2023 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2028 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2029 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2030 echo there is still data in page cache $FILE ?
2031 lctl get_param -n $FILE
2038 create_fake_exports () {
2041 #obd_fail_val = num;
2042 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2043 do_facet $facet "lctl set_param fail_val=$num"
2044 do_facet $facet "lctl set_param fail_loc=0x80000708"
2049 DEBUGSAVE="$(lctl get_param -n debug)"
2053 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2057 ##################################
2059 ##################################
2062 local TYPE=${TYPE:-"FAIL"}
2066 # do not dump logs if $1=false
2067 if [ "x$1" = "xfalse" ]; then
2072 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2075 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2076 echo "Dumping lctl log to $ERRLOG"
2077 # We need to dump the logs on all nodes
2078 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2081 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2087 if $FAIL_ON_ERROR; then
2098 # use only if we are ignoring failures for this test, bugno required.
2099 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2100 # e.g. error_ignore 5494 "your message"
2102 local TYPE="IGNORE (bz$1)"
2108 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2112 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2113 [ "$TESTSUITELOG" ] && \
2114 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2117 build_test_filter() {
2118 EXCEPT="$EXCEPT $(testslist_filter)"
2120 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2124 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2125 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2126 [ "$EXCEPT_SLOW" ] && \
2127 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2128 for E in $EXCEPT $ALWAYS_EXCEPT; do
2129 eval EXCEPT_${E}=true
2131 for E in $EXCEPT_SLOW; do
2132 eval EXCEPT_SLOW_${E}=true
2134 for G in $GRANT_CHECK_LIST; do
2135 eval GCHECK_ONLY_${G}=true
2140 if [[ $1 = [a-z]* ]]; then
2147 # print a newline if the last test was skipped
2148 export LAST_SKIPPED=
2152 export base=`basetest $1`
2153 if [ ! -z "$ONLY" ]; then
2155 if [ ${!testname}x != x ]; then
2156 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2161 if [ ${!testname}x != x ]; then
2162 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2171 if [ ${!testname}x != x ]; then
2173 TESTNAME=test_$1 skip "skipping excluded test $1"
2176 testname=EXCEPT_$base
2177 if [ ${!testname}x != x ]; then
2179 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2182 testname=EXCEPT_SLOW_$1
2183 if [ ${!testname}x != x ]; then
2185 TESTNAME=test_$1 skip "skipping SLOW test $1"
2188 testname=EXCEPT_SLOW_$base
2189 if [ ${!testname}x != x ]; then
2191 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2201 EQUALS="======================================================================"
2205 local suffixlen=$((${#EQUALS} - ${#msg}))
2206 [ $suffixlen -lt 5 ] && suffixlen=5
2207 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2212 module_loaded lnet || load_modules
2224 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2229 strace -o $TMP/$1.strace -ttt $*
2231 log "FINISHED: $*: rc $RC"
2236 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2241 FFREE=`lctl get_param -n mds.*.filesfree`
2242 FTOTAL=`lctl get_param -n mds.*.filestotal`
2243 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2247 echo -n "Resetting fail_loc on all nodes..."
2248 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2256 export tdir=d0.${TESTSUITE}/d${base}
2258 local SAVE_UMASK=`umask`
2261 local BEFORE=`date +%s`
2263 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2265 export TESTNAME=test_$testnum
2267 test_${testnum} || error "test_$testnum failed with $?"
2271 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2272 check_catastrophe || error "LBUG/LASSERT detected"
2273 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2274 pass "($((`date +%s` - $BEFORE))s)"
2282 (cd `dirname $1`; echo $PWD/`basename $1`)
2286 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2287 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2292 export base=`basetest $1`
2293 [ "$CHECK_GRANT" == "no" ] && return 0
2295 testname=GCHECK_ONLY_${base}
2296 [ ${!testname}x == x ] && return 0
2298 echo -n "checking grant......"
2300 # write some data to sync client lost_grant
2301 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2302 for i in `seq $OSTCOUNT`; do
2303 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2304 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2305 count=1 > /dev/null 2>&1
2307 # sync all the data and make sure no pending data on server
2310 #get client grant and server grant
2312 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2313 client_grant=$((client_grant + $d))
2316 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2317 server_grant=$((server_grant + $d))
2320 # cleanup the check_grant file
2321 for i in `seq $OSTCOUNT`; do
2322 rm $DIR1/${tfile}_check_grant_$i
2325 #check whether client grant == server grant
2326 if [ $client_grant != $server_grant ]; then
2327 echo "failed: client:${client_grant} server: ${server_grant}"
2334 ########################
2340 ost=`echo $1 | awk -F_ '{print $3}'`
2341 if [ -z $ost ]; then
2342 ost=`echo $1 | sed 's/-osc.*//'`
2349 [ "$node" != "$(hostname)" ]
2354 remote_node $mds_HOST
2359 [ "$CLIENTONLY" ] && return 0 || true
2360 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2366 for node in $(osts_nodes) ; do
2367 remote_node $node && return 0
2374 [ "$CLIENTONLY" ] && return 0 || true
2375 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2381 MGS=$(facet_host mgs)
2382 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2386 remote_ost && remote_mds
2390 local OSTNODES=$(facet_host ost1)
2393 for num in `seq $OSTCOUNT`; do
2394 local myOST=$(facet_host ost$num)
2395 OSTNODES="$OSTNODES $myOST"
2397 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2403 # FIXME. We need a list of clients
2404 local myNODES=$HOSTNAME
2407 # CLIENTS (if specified) contains the local client
2408 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2410 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2411 myNODES="$myNODES $(osts_nodes) $mds_HOST"
2414 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2419 remote_nodes_list () {
2420 local rnodes=$(nodes_list)
2421 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2425 init_clients_lists () {
2426 # Sanity check: exclude the local client from RCLIENTS
2427 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2429 # Sanity check: exclude the dup entries
2430 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2432 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2434 # Sanity check: exclude the dup entries from CLIENTS
2435 # for those configs which has SINGLCLIENT set to local client
2436 clients=$(for i in $clients; do echo $i; done | sort -u)
2438 CLIENTS=`comma_list $clients`
2439 local -a remoteclients=($rclients)
2440 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2441 varname=CLIENT$((i + 2))
2442 eval $varname=${remoteclients[i]}
2445 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2448 get_random_entry () {
2451 rnodes=${rnodes//,/ }
2453 local -a nodes=($rnodes)
2454 local num=${#nodes[@]}
2455 local i=$((RANDOM * num * 2 / 65536))
2461 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2466 lctl get_param version | grep -q patchless
2470 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2475 echo $nodes | wc -w || true
2479 local nodes=$(osts_nodes)
2480 local osscount=$(get_node_count "$nodes")
2481 [ ! "$OSTCOUNT" = "$osscount" ]
2484 generate_machine_file() {
2485 local nodes=${1//,/ }
2486 local machinefile=$2
2487 rm -f $machinefile || error "can't rm $machinefile"
2488 for node in $nodes; do
2489 echo $node >>$machinefile
2494 local file=$1/stripe
2496 $LFS getstripe -v $file || error
2500 check_runas_id_ret() {
2502 local myRUNAS_UID=$1
2503 local myRUNAS_GID=$2
2506 if [ -z "$myRUNAS" ]; then
2507 error_exit "myRUNAS command must be specified for check_runas_id"
2509 mkdir $DIR/d0_runas_test
2511 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2512 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
2513 rm -rf $DIR/d0_runas_test
2518 local myRUNAS_UID=$1
2519 local myRUNAS_GID=$2
2522 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2523 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2524 Please set RUNAS_ID to some UID which exists on MDS and client or
2525 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2528 # Run multiop in the background, but wait for it to print
2529 # "PAUSING" to its stdout before returning from this function.
2530 multiop_bg_pause() {
2531 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2535 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2538 echo "$MULTIOP_PROG $FILE v$ARGS"
2539 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2541 echo "TMPPIPE=${TMPPIPE}"
2542 local multiop_output
2544 read -t 60 multiop_output < $TMPPIPE
2545 if [ $? -ne 0 ]; then
2550 if [ "$multiop_output" != "PAUSING" ]; then
2551 echo "Incorrect multiop output: $multiop_output"
2566 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2572 inodes_available () {
2573 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2577 # reset llite stat counters
2578 clear_llite_stats(){
2579 lctl set_param -n llite.*.stats 0
2582 # sum llite stat items
2583 calc_llite_stats() {
2584 local res=$(lctl get_param -n llite.*.stats |
2585 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2590 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2593 calc_osc_kbytes () {
2594 df $MOUNT > /dev/null
2595 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
2598 # save_lustre_params(node, parameter_mask)
2599 # generate a stream of formatted strings (<node> <param name>=<param value>)
2600 save_lustre_params() {
2602 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2605 # restore lustre parameters from input stream, produces by save_lustre_params
2606 restore_lustre_params() {
2610 while IFS=" =" read node name val; do
2611 do_node ${node//:/} "lctl set_param -n $name $val"
2615 check_catastrophe() {
2616 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2617 local C=$CATASTROPHE
2618 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2620 if [ $rnodes ]; then
2621 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2622 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2638 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2640 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2641 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2642 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2646 mdsrate_cleanup () {
2647 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2650 delayed_recovery_enabled () {
2651 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
2654 ################################################################################
2655 # The following functions are used to enable interop testing between
2656 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
2658 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
2659 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
2660 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
2661 ################################################################################
2663 get_lustre_version () {
2664 local node=${1:-"mds"}
2665 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2668 get_mds_version_major () {
2669 local version=$(get_lustre_version mds)
2670 echo $version | awk -F. '{print $1}'
2673 get_mds_version_minor () {
2674 local version=$(get_lustre_version mds)
2675 echo $version | awk -F. '{print $2}'
2678 get_mds_version_patch () {
2679 local version=$(get_lustre_version mds)
2680 echo $version | awk -F. '{print $3}'
2683 get_mds_version_fix () {
2684 local version=$(get_lustre_version mds)
2685 echo $version | awk -F. '{print $4}'
2688 get_mds_fsstat_proc_path() {
2689 local major=$(get_mds_version_major)
2690 local minor=$(get_mds_version_minor)
2691 if [ $major -le 1 -a $minor -le 8 ] ; then
2698 get_mds_mntdev_proc_path() {
2699 local fsstat_dev=$(get_mds_fsstat_proc_path)
2700 echo "$fsstat_dev.*.mntdev"
2703 get_mdtlov_proc_path() {
2705 local major=$(get_mds_version_major)
2706 local minor=$(get_mds_version_minor)
2707 if [ $major -le 1 -a $minor -le 8 ] ; then
2708 echo "${fsname}-mdtlov"
2710 echo "${fsname}-MDT0000-mdtlov"
2714 get_mdtosc_proc_path() {
2716 local major=$(get_mds_version_major)
2717 local minor=$(get_mds_version_minor)
2718 if [ $major -le 1 -a $minor -le 8 ] ; then
2721 echo "${ost}-osc-MDT0000"
2725 get_mds_mdt_device_proc_path() {
2726 local major=$(get_mds_version_major)
2727 local minor=$(get_mds_version_minor)
2728 if [ $major -le 1 -a $minor -le 8 ] ; then
2735 ########################
2737 convert_facet2label() {
2740 if [ x$facet = xost ]; then
2744 local varsvc=${facet}_svc
2746 if [ -n ${!varsvc} ]; then
2749 error "No lablel for $facet!"
2753 get_clientosc_proc_path() {
2759 get_osc_import_name() {
2762 local label=$(convert_facet2label $ost)
2764 if [ "$facet" == "mds" ]; then
2765 get_mdtosc_proc_path $label
2769 get_clientosc_proc_path $label
2773 wait_import_state () {
2779 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2780 while [ "${CONN_STATE}" != "${expected}" ]; do
2781 if [ "${expected}" == "DISCONN" ]; then
2782 # for disconn we can check after proc entry is removed
2783 [ "x${CONN_STATE}" == "x" ] && return 0
2784 # with AT we can have connect request timeout ~ reconnect timeout
2785 # and test can't see real disconnect
2786 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2788 # disconnect rpc should be wait not more obd_timeout
2789 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2790 error "can't put import for $CONN_PROC into ${expected} state" && return 1
2792 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2796 log "$CONN_PROC now in ${CONN_STATE} state"
2800 wait_osc_import_state() {
2804 local ost=$(get_osc_import_name $facet $ost_facet)
2809 CONN_PROC="osc.${ost}.ost_server_uuid"
2810 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2811 while [ "${CONN_STATE}" != "${expected}" ]; do
2812 if [ "${expected}" == "DISCONN" ]; then
2813 # for disconn we can check after proc entry is removed
2814 [ "x${CONN_STATE}" == "x" ] && return 0
2815 # with AT enabled, we can have connect request timeout near of
2816 # reconnect timeout and test can't see real disconnect
2817 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2819 # disconnect rpc should be wait not more obd_timeout
2820 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2821 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2823 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC | cut -f2)
2827 log "${ost_facet} now in ${CONN_STATE} state"
2831 get_clientmdc_proc_path() {
2839 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
2842 wait_clients_import_state () {
2848 local label=$(convert_facet2label $facet)
2851 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
2852 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
2853 *) error "unknown facet!" ;;
2856 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
2857 error "import is not in ${expected} state"
2862 destroy_pool_int() {
2864 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
2865 for ost in $OSTS; do
2866 do_facet mgs lctl pool_remove $1 $ost
2868 do_facet mgs lctl pool_destroy $1
2871 # <fsname>.<poolname> or <poolname>
2873 local fsname=${1%%.*}
2874 local poolname=${1##$fsname.}
2876 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
2880 pool_list $fsname.$poolname || return $?
2882 destroy_pool_int $fsname.$poolname
2884 [[ $RC -ne 0 ]] && return $RC
2886 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
2887 2>/dev/null || echo foo" "foo" || RC=1
2889 if [[ $RC -eq 0 ]]; then
2890 remove_pool_from_list $fsname.$poolname
2892 error "destroy pool failed $1"
2898 local fsname=${1:-$FSNAME}
2900 local listvar=${fsname}_CREATED_POOLS
2904 [ x${!listvar} = x ] && return 0
2906 echo destroy the created pools: ${!listvar}
2907 for poolname in ${!listvar//,/ }; do
2908 destroy_pool $fsname.$poolname
2913 local fsname=${1:-$FSNAME}
2915 destroy_pools $fsname
2921 local ts=$(date +%s)
2923 # bug 20237, comment 11
2924 # It would also be useful to provide the option
2925 # of writing the file to an NFS directory so it doesn't need to be copied.
2928 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
2930 # dump lustre logs, dmesg
2931 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
2932 lctl dk \\\$log >/dev/null;
2933 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
2936 # FIXME: does it make sense to collect the logs for $ts only, but all
2938 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
2939 local logs=$TMP/'*'${TESTSUITE}'*'
2941 logs=$logs' '$tmp/'*'$ts'*'
2943 for node in ${list//,/ }; do
2944 rsync -az $node:"$logs" $TMP
2947 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
2948 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
2954 local list=${1:-$(comma_list $(nodes_list))}
2956 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
2968 for i in $(seq 0 $num_mntpts); do
2969 cmd="ls -laf ${mntpt_root}$i/$dir"
2975 for pid in $pids; do