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 df $MOUNT || error "post-failover df: $?"
1134 facet_failover $facet
1140 change_active $facet
1141 mount_facet $facet -o abort_recovery
1142 df $MOUNT || echo "first df failed: $?"
1144 df $MOUNT || error "post-failover df: $?"
1148 echo There is no lmc. This is mountconf, baby.
1153 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1154 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1160 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1166 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1167 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1168 if [ -z "$ID" ]; then
1169 echo "Could not get a ptl id for $1..."
1178 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1185 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1186 if type __h2elan >/dev/null 2>&1; then
1189 ID=`echo $1 | sed 's/[^0-9]*//g'`
1197 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1198 ID=`echo $1 | sed 's/[^0-9]*//g'`
1202 declare -fx h2openib
1205 h2name_or_ip "$1" "o2ib"
1212 [ "$facet" == client ] && echo -n $HOSTNAME && return
1213 varname=${facet}_HOST
1214 if [ -z "${!varname}" ]; then
1215 if [ "${facet:0:3}" == "ost" ]; then
1216 eval ${facet}_HOST=${ost_HOST}
1224 local activevar=${facet}active
1226 if [ -f $TMP/${facet}active ] ; then
1227 source $TMP/${facet}active
1230 active=${!activevar}
1231 if [ -z "$active" ] ; then
1238 facet_active_host() {
1240 local active=`facet_active $facet`
1241 if [ "$facet" == client ]; then
1244 echo `facet_host $active`
1250 local failover=${facet}failover
1251 host=`facet_host $failover`
1252 [ -z "$host" ] && return
1253 local curactive=`facet_active $facet`
1254 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1255 eval export ${facet}active=$facet
1257 eval export ${facet}active=$failover
1259 # save the active host for this facet
1260 local activevar=${facet}active
1261 echo "$activevar=${!activevar}" > $TMP/$activevar
1266 # do not stripe off hostname if verbose, bug 19215
1267 if [ x$1 = x--verbose ]; then
1275 if [ "$HOST" = "$HOSTNAME" ]; then
1277 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1278 echo "cannot run remote command on $HOST with $myPDSH"
1282 echo "CMD: $HOST $@" >&2
1283 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1286 if [ "$myPDSH" = "rsh" ]; then
1287 # we need this because rsh does not return exit code of an executed command
1288 local command_status="$TMP/cs"
1289 rsh $HOST ":> $command_status"
1290 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1291 cd $RPWD; sh -c \"$@\") ||
1292 echo command failed >$command_status"
1293 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1298 # print HOSTNAME for myPDSH="no_dsh"
1299 if [[ $myPDSH = no_dsh ]]; then
1300 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1302 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1305 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1307 return ${PIPESTATUS[0]}
1310 single_local_node () {
1311 [ "$1" = "$HOSTNAME" ]
1316 # do not stripe off hostname if verbose, bug 19215
1317 if [ x$1 = x--verbose ]; then
1325 if $(single_local_node $rnodes); then
1327 do_node --verbose $rnodes $@
1334 # This is part from do_node
1337 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1338 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1341 echo "CMD: $rnodes $@" >&2
1342 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1346 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1348 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1350 return ${PIPESTATUS[0]}
1356 local HOST=`facet_active_host $facet`
1357 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1364 # make sure its not already running
1366 rm -f $TMP/${facet}active
1367 do_facet ${facet} $MKFS $*
1373 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1374 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1382 # make sure we are using the primary server, so test-framework will
1383 # be able to clean up properly.
1384 activemds=`facet_active mds`
1385 if [ $activemds != "mds" ]; then
1389 local clients=$CLIENTS
1390 [ -z $clients ] && clients=$(hostname)
1392 zconf_umount_clients $clients $MOUNT "$*" || true
1393 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1395 [ "$CLIENTONLY" ] && return
1396 # The add fn does rm ${facet}active file, this would be enough
1397 # if we use do_facet <facet> only after the facet added, but
1398 # currently we use do_facet mds in local.sh
1400 rm -f ${TMP}/mdsactive
1401 for num in `seq $OSTCOUNT`; do
1403 rm -f $TMP/ost${num}active
1405 if [[ $MDSDEV != $MGSDEV ]]; then
1413 nfs_client_mode && return
1420 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1423 # We need ldiskfs here, may as well load them all
1425 [ "$CLIENTONLY" ] && return
1426 echo Formatting mgs, mds, osts
1427 if [[ $MDSDEV != $MGSDEV ]] || [[ $mds_HOST != $mgs_HOST ]]; then
1428 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1432 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV || exit 10
1434 add mds $MDS_MKFS_OPTS $FSTYPE_OPT --reformat $MDSDEV > /dev/null || exit 10
1437 for num in `seq $OSTCOUNT`; do
1439 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` || exit 10
1441 add ost$num $OST_MKFS_OPTS $FSTYPE_OPT --reformat `ostdevname $num` > /dev/null || exit 10
1447 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1452 zconf_umount `hostname` $1 || error "umount failed"
1453 zconf_mount `hostname` $1 || error "mount failed"
1456 writeconf_facet () {
1460 do_facet $facet "$TUNEFS --writeconf $dev"
1464 writeconf_facet mds $MDSDEV
1466 for num in `seq $OSTCOUNT`; do
1467 DEVNAME=`ostdevname $num`
1468 writeconf_facet ost$num $DEVNAME
1473 nfs_client_mode && return
1475 sanity_mount_check ||
1476 error "environments are insane!"
1479 if [ -z "$CLIENTONLY" ]; then
1480 echo Setup mgs, mdt, osts
1482 echo $WRITECONF | grep -q "writeconf" && \
1485 if [[ $mds_HOST != $mgs_HOST ]] || [[ $MDSDEV != $MGSDEV ]]; then
1486 start mgs $MGSDEV $mgs_MOUNT_OPTS
1489 start mds $MDSDEV $MDS_MOUNT_OPTS
1490 # We started mds, now we should set failover variable properly.
1491 # Set mdsfailover_HOST if it is not set (the default failnode).
1492 if [ -z "$mdsfailover_HOST" ]; then
1493 mdsfailover_HOST=$(facet_host mds)
1496 for num in `seq $OSTCOUNT`; do
1497 DEVNAME=`ostdevname $num`
1498 start ost$num $DEVNAME $OST_MOUNT_OPTS
1500 # We started ost$num, now we should set ost${num}failover variable properly.
1501 # Set ost${num}failover_HOST if it is not set (the default failnode).
1502 varname=ost${num}failover_HOST
1503 if [ -z "${!varname}" ]; then
1504 eval ost${num}failover_HOST=$(facet_host ost${num})
1509 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1511 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1513 if [ "$MOUNT_2" ]; then
1514 mount_client $MOUNT2
1515 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1521 mounted_lustre_filesystems() {
1522 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1525 init_facet_vars () {
1526 [ "$CLIENTONLY" ] && return 0
1533 eval export ${facet}_dev=${device}
1534 eval export ${facet}_opt=\"$@\"
1536 local dev=${facet}_dev
1537 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1538 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1540 eval export ${facet}_svc=${label}
1542 local varname=${facet}failover_HOST
1543 if [ -z "${!varname}" ]; then
1544 eval $varname=$(facet_host $facet)
1547 # ${facet}failover_dev is set in cfg file
1548 varname=${facet}failover_dev
1549 if [ -n "${!varname}" ] ; then
1550 eval export ${facet}failover_dev=${!varname}
1552 eval export ${facet}failover_dev=$device
1556 init_facets_vars () {
1558 init_facet_vars mds $MDSDEV $MDS_MOUNT_OPTS
1560 remote_ost_nodsh && return
1562 for num in `seq $OSTCOUNT`; do
1563 DEVNAME=`ostdevname $num`
1564 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1568 init_param_vars () {
1569 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1570 export MDSVER=$(do_facet mds "lctl get_param version" | cut -d. -f1,2)
1571 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1572 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1576 TIMEOUT=$(do_facet mds "lctl get_param -n timeout")
1578 log "Using TIMEOUT=$TIMEOUT"
1580 if [ "$ENABLE_QUOTA" ]; then
1581 setup_quota $MOUNT || return 2
1585 nfs_client_mode () {
1586 if [ "$NFSCLIENT" ]; then
1587 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1588 local clients=$CLIENTS
1589 [ -z $clients ] && clients=$(hostname)
1591 # FIXME: remove hostname when 19215 fixed
1592 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1593 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1594 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1600 check_config_client () {
1603 local mounted=$(mount | grep " $mntpt ")
1604 if [ "$CLIENTONLY" ]; then
1606 # CLIENTONLY should not depend on *_HOST settings
1607 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1608 # in theory someone could create a new,
1609 # client-only config file that assumed lustre was already
1610 # configured and didn't set the MGSNID. If MGSNID is not set,
1611 # then we should use the mgs nid currently being used
1612 # as the default value. bug 18021
1613 [[ x$MGSNID = x ]] &&
1616 if [[ x$mgc != xMGC$MGSNID ]]; then
1617 if [ "$mgs_HOST" ]; then
1618 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1619 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1620 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1626 local myMGS_host=$mgs_HOST
1627 if [ "$NETTYPE" = "ptl" ]; then
1628 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1631 echo Checking config lustre mounted on $mntpt
1632 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1633 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1635 # if [ "$mgshost" != "$myMGS_host" ]; then
1636 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1637 # Please use correct config or set mds_HOST correctly!"
1642 check_config_clients () {
1643 local clients=${CLIENTS:-$HOSTNAME}
1646 nfs_client_mode && return
1648 do_rpc_nodes $clients check_config_client $mntpt
1650 sanity_mount_check ||
1651 error "environments are insane!"
1655 local mdstimeout=$(do_facet mds "lctl get_param -n timeout")
1656 local cltimeout=$(lctl get_param -n timeout)
1657 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1658 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1665 local mounted=$(mounted_lustre_filesystems)
1667 echo $mounted' ' | grep -w -q $mntpt' '
1670 check_and_setup_lustre() {
1671 nfs_client_mode && return
1673 local MOUNTED=$(mounted_lustre_filesystems)
1677 # both MOUNT and MOUNT2 are not mounted
1678 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
1679 [ "$REFORMAT" ] && formatall
1680 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
1682 is_mounted $MOUNT || error "NAME=$NAME not mounted"
1683 export I_MOUNTED=yes
1687 elif is_mounted $MOUNT2; then
1689 # MOUNT2 is mounted, while MOUNT_2 is not set
1690 if ! [ "$MOUNT_2" ]; then
1691 cleanup_mount $MOUNT2
1692 export I_UMOUNTED2=yes
1695 # MOUNT2 is mounted, MOUNT_2 is set
1697 # FIXME: what to do if check_config failed?
1699 # 1) remote client has mounted other Lustre fs ?
1700 # 2) it has insane env ?
1701 # let's try umount MOUNT2 on all clients and mount it again:
1702 if ! check_config_clients $MOUNT2; then
1703 cleanup_mount $MOUNT2
1704 restore_mount $MOUNT2
1705 export I_MOUNTED2=yes
1710 # MOUNT is mounted MOUNT2 is not mounted
1711 elif [ "$MOUNT_2" ]; then
1712 restore_mount $MOUNT2
1713 export I_MOUNTED2=yes
1717 # FIXME: what to do if check_config failed?
1719 # 1) remote client has mounted other Lustre fs?
1720 # 2) lustre is mounted on remote_clients atall ?
1721 check_config_clients $MOUNT
1725 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1726 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1727 lctl set_param debug_mb=${DEBUG_SIZE};
1730 if [ "$ONLY" == "setup" ]; then
1736 local clients=${CLIENTS:-$HOSTNAME}
1739 zconf_mount_clients $clients $mntpt
1743 local clients=${CLIENTS:-$HOSTNAME}
1746 zconf_umount_clients $clients $mntpt
1749 cleanup_and_setup_lustre() {
1750 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1751 lctl set_param debug=0 || true
1753 if [ "$ONLY" == "cleanup" ]; then
1757 check_and_setup_lustre
1760 check_and_cleanup_lustre() {
1761 if is_mounted $MOUNT; then
1762 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1763 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1766 if [ "$I_UMOUNTED2" = "yes" ]; then
1767 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
1770 if [ "$I_MOUNTED2" = "yes" ]; then
1771 cleanup_mount $MOUNT2
1774 if [ "$I_MOUNTED" = "yes" ]; then
1775 cleanupall -f || error "cleanup failed"
1787 while [ $NETWORK -eq 0 ]; do
1788 if ping -c 1 -w 3 $1 > /dev/null; then
1792 echo "waiting for $1, $((MAX - WAIT)) secs left"
1795 if [ $WAIT -gt $MAX ]; then
1796 echo "Network not available"
1802 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1813 # the sed converts spaces to commas, but leaves the last space
1814 # alone, so the line doesn't end with a comma.
1815 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1818 # list, excluded are the comma separated lists
1819 exclude_items_from_list () {
1825 for item in ${excluded//,/ }; do
1826 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1828 echo $(comma_list $list)
1831 # list, expand are the comma separated lists
1833 local list=${1//,/ }
1834 local expand=${2//,/ }
1837 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1838 echo $(comma_list $expanded)
1841 testslist_filter () {
1842 local script=$LUSTRE/tests/${TESTSUITE}.sh
1844 [ -f $script ] || return 0
1846 local start_at=$START_AT
1847 local stop_at=$STOP_AT
1849 local var=${TESTSUITE//-/_}_START_AT
1850 [ x"${!var}" != x ] && start_at=${!var}
1851 var=${TESTSUITE//-/_}_STOP_AT
1852 [ x"${!var}" != x ] && stop_at=${!var}
1854 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
1855 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
1856 /^'${start_at}'$/ {flag = 0}
1857 {if (flag == 1) print $0}
1858 /^'${stop_at}'$/ { flag = 1 }'
1862 (cd `dirname $1`; echo $PWD/`basename $1`)
1866 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1867 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1873 OST ) for ((i=1; i<=$OSTCOUNT; i++)) do
1874 list="$list ${name}$i"
1876 * ) error "Invalid facet type"
1879 echo $(comma_list $list)
1882 ##################################
1883 # Adaptive Timeouts funcs
1886 # only check mds, we assume at_max is the same on all nodes
1887 local at_max=$(do_facet mds "lctl get_param -n at_max")
1888 if [ $at_max -eq 0 ]; then
1898 # suppose that all ost-s has the same at_max set
1899 if [ $facet == "ost" ]; then
1900 do_facet ost1 "lctl get_param -n at_max"
1902 do_facet $facet "lctl get_param -n at_max"
1912 if [ $facet == "ost" ]; then
1913 for i in `seq $OSTCOUNT`; do
1914 do_facet ost$i "lctl set_param at_max=$at_max"
1917 do_facet $facet "lctl set_param at_max=$at_max"
1922 ##################################
1926 # OBD_FAIL_MDS_ALL_REQUEST_NET
1928 do_facet mds lctl set_param fail_loc=0x123
1929 do_facet client "$1" || RC=$?
1930 do_facet mds lctl set_param fail_loc=0
1935 # OBD_FAIL_MDS_ALL_REPLY_NET
1937 do_facet mds lctl set_param fail_loc=0x122
1938 do_facet client "$@" || RC=$?
1939 do_facet mds lctl set_param fail_loc=0
1943 drop_reint_reply() {
1944 # OBD_FAIL_MDS_REINT_NET_REP
1946 do_facet mds lctl set_param fail_loc=0x119
1947 do_facet client "$@" || RC=$?
1948 do_facet mds lctl set_param fail_loc=0
1953 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1955 do_facet ost1 lctl set_param fail_loc=0x214
1956 do_facet client "$1" || RC=$?
1957 do_facet client "sync"
1958 do_facet ost1 lctl set_param fail_loc=0
1962 drop_ldlm_cancel() {
1963 #define OBD_FAIL_LDLM_CANCEL 0x304
1965 do_facet client lctl set_param fail_loc=0x304
1966 do_facet client "$@" || RC=$?
1967 do_facet client lctl set_param fail_loc=0
1971 drop_bl_callback() {
1972 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1974 do_facet client lctl set_param fail_loc=0x305
1975 do_facet client "$@" || RC=$?
1976 do_facet client lctl set_param fail_loc=0
1981 #define OBD_FAIL_LDLM_REPLY 0x30c
1983 do_facet mds lctl set_param fail_loc=0x30c
1984 do_facet client "$@" || RC=$?
1985 do_facet mds lctl set_param fail_loc=0
1993 echo "clearing fail_loc on $facet"
1994 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1997 set_nodes_failloc () {
1998 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2001 cancel_lru_locks() {
2002 $LCTL mark "cancel_lru_locks $1 start"
2003 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2004 $LCTL set_param -n $d=clear
2006 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2007 $LCTL mark "cancel_lru_locks $1 stop"
2012 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2013 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2014 echo "$DEFAULT_LRU_SIZE"
2019 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2022 lru_resize_disable()
2024 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2029 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2030 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2031 echo there is still data in page cache $FILE ?
2032 lctl get_param -n $FILE
2039 create_fake_exports () {
2042 #obd_fail_val = num;
2043 #define OBD_FAIL_TGT_FAKE_EXP 0x708
2044 do_facet $facet "lctl set_param fail_val=$num"
2045 do_facet $facet "lctl set_param fail_loc=0x80000708"
2050 DEBUGSAVE="$(lctl get_param -n debug)"
2054 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2058 ##################################
2060 ##################################
2063 local TYPE=${TYPE:-"FAIL"}
2067 # do not dump logs if $1=false
2068 if [ "x$1" = "xfalse" ]; then
2073 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2076 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2077 echo "Dumping lctl log to $ERRLOG"
2078 # We need to dump the logs on all nodes
2079 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2082 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2089 $FAIL_ON_ERROR && exit 1 || true
2097 # use only if we are ignoring failures for this test, bugno required.
2098 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2099 # e.g. error_ignore 5494 "your message"
2101 local TYPE="IGNORE (bz$1)"
2107 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2111 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2112 [ "$TESTSUITELOG" ] && \
2113 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2116 build_test_filter() {
2117 EXCEPT="$EXCEPT $(testslist_filter)"
2119 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2123 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2124 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2125 [ "$EXCEPT_SLOW" ] && \
2126 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2127 for E in $EXCEPT $ALWAYS_EXCEPT; do
2128 eval EXCEPT_${E}=true
2130 for E in $EXCEPT_SLOW; do
2131 eval EXCEPT_SLOW_${E}=true
2133 for G in $GRANT_CHECK_LIST; do
2134 eval GCHECK_ONLY_${G}=true
2139 if [[ $1 = [a-z]* ]]; then
2146 # print a newline if the last test was skipped
2147 export LAST_SKIPPED=
2151 export base=`basetest $1`
2152 if [ ! -z "$ONLY" ]; then
2154 if [ ${!testname}x != x ]; then
2155 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2160 if [ ${!testname}x != x ]; then
2161 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2170 if [ ${!testname}x != x ]; then
2172 TESTNAME=test_$1 skip "skipping excluded test $1"
2175 testname=EXCEPT_$base
2176 if [ ${!testname}x != x ]; then
2178 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2181 testname=EXCEPT_SLOW_$1
2182 if [ ${!testname}x != x ]; then
2184 TESTNAME=test_$1 skip "skipping SLOW test $1"
2187 testname=EXCEPT_SLOW_$base
2188 if [ ${!testname}x != x ]; then
2190 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2200 EQUALS="======================================================================"
2204 local suffixlen=$((${#EQUALS} - ${#msg}))
2205 [ $suffixlen -lt 5 ] && suffixlen=5
2206 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2211 module_loaded lnet || load_modules
2223 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2228 strace -o $TMP/$1.strace -ttt $*
2230 log "FINISHED: $*: rc $RC"
2235 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2240 FFREE=`lctl get_param -n mds.*.filesfree`
2241 FTOTAL=`lctl get_param -n mds.*.filestotal`
2242 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2246 echo -n "Resetting fail_loc on all nodes..."
2247 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2255 export tdir=d0.${TESTSUITE}/d${base}
2257 local SAVE_UMASK=`umask`
2260 local BEFORE=`date +%s`
2262 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2264 export TESTNAME=test_$testnum
2266 test_${testnum} || error "test_$testnum failed with $?"
2270 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2271 check_catastrophe || error "LBUG/LASSERT detected"
2272 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2273 pass "($((`date +%s` - $BEFORE))s)"
2281 (cd `dirname $1`; echo $PWD/`basename $1`)
2285 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2286 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2291 export base=`basetest $1`
2292 [ "$CHECK_GRANT" == "no" ] && return 0
2294 testname=GCHECK_ONLY_${base}
2295 [ ${!testname}x == x ] && return 0
2297 echo -n "checking grant......"
2299 # write some data to sync client lost_grant
2300 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2301 for i in `seq $OSTCOUNT`; do
2302 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2303 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2304 count=1 > /dev/null 2>&1
2306 # sync all the data and make sure no pending data on server
2309 #get client grant and server grant
2311 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2312 client_grant=$((client_grant + $d))
2315 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2316 server_grant=$((server_grant + $d))
2319 # cleanup the check_grant file
2320 for i in `seq $OSTCOUNT`; do
2321 rm $DIR1/${tfile}_check_grant_$i
2324 #check whether client grant == server grant
2325 if [ $client_grant != $server_grant ]; then
2326 echo "failed: client:${client_grant} server: ${server_grant}"
2333 ########################
2339 ost=`echo $1 | awk -F_ '{print $3}'`
2340 if [ -z $ost ]; then
2341 ost=`echo $1 | sed 's/-osc.*//'`
2348 [ "$node" != "$(hostname)" ]
2353 remote_node $mds_HOST
2358 [ "$CLIENTONLY" ] && return 0 || true
2359 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2365 for node in $(osts_nodes) ; do
2366 remote_node $node && return 0
2373 [ "$CLIENTONLY" ] && return 0 || true
2374 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2380 MGS=$(facet_host mgs)
2381 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2385 remote_ost && remote_mds
2389 local OSTNODES=$(facet_host ost1)
2392 for num in `seq $OSTCOUNT`; do
2393 local myOST=$(facet_host ost$num)
2394 OSTNODES="$OSTNODES $myOST"
2396 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2402 # FIXME. We need a list of clients
2403 local myNODES=$HOSTNAME
2406 # CLIENTS (if specified) contains the local client
2407 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2409 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2410 myNODES="$myNODES $(osts_nodes) $mds_HOST"
2413 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2418 remote_nodes_list () {
2419 local rnodes=$(nodes_list)
2420 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2424 init_clients_lists () {
2425 # Sanity check: exclude the local client from RCLIENTS
2426 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2428 # Sanity check: exclude the dup entries
2429 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2431 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2433 # Sanity check: exclude the dup entries from CLIENTS
2434 # for those configs which has SINGLCLIENT set to local client
2435 clients=$(for i in $clients; do echo $i; done | sort -u)
2437 CLIENTS=`comma_list $clients`
2438 local -a remoteclients=($rclients)
2439 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2440 varname=CLIENT$((i + 2))
2441 eval $varname=${remoteclients[i]}
2444 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2447 get_random_entry () {
2450 rnodes=${rnodes//,/ }
2452 local -a nodes=($rnodes)
2453 local num=${#nodes[@]}
2454 local i=$((RANDOM * num * 2 / 65536))
2460 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2465 lctl get_param version | grep -q patchless
2469 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2474 echo $nodes | wc -w || true
2478 local nodes=$(osts_nodes)
2479 local osscount=$(get_node_count "$nodes")
2480 [ ! "$OSTCOUNT" = "$osscount" ]
2483 generate_machine_file() {
2484 local nodes=${1//,/ }
2485 local machinefile=$2
2486 rm -f $machinefile || error "can't rm $machinefile"
2487 for node in $nodes; do
2488 echo $node >>$machinefile
2493 local file=$1/stripe
2495 $LFS getstripe -v $file || error
2499 check_runas_id_ret() {
2501 local myRUNAS_UID=$1
2502 local myRUNAS_GID=$2
2505 if [ -z "$myRUNAS" ]; then
2506 error_exit "myRUNAS command must be specified for check_runas_id"
2508 mkdir $DIR/d0_runas_test
2510 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2511 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=1
2512 rm -rf $DIR/d0_runas_test
2517 local myRUNAS_UID=$1
2518 local myRUNAS_GID=$2
2521 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2522 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2523 Please set RUNAS_ID to some UID which exists on MDS and client or
2524 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2527 # Run multiop in the background, but wait for it to print
2528 # "PAUSING" to its stdout before returning from this function.
2529 multiop_bg_pause() {
2530 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2534 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2537 echo "$MULTIOP_PROG $FILE v$ARGS"
2538 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2540 echo "TMPPIPE=${TMPPIPE}"
2541 local multiop_output
2543 read -t 60 multiop_output < $TMPPIPE
2544 if [ $? -ne 0 ]; then
2549 if [ "$multiop_output" != "PAUSING" ]; then
2550 echo "Incorrect multiop output: $multiop_output"
2565 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2571 inodes_available () {
2572 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2576 # reset llite stat counters
2577 clear_llite_stats(){
2578 lctl set_param -n llite.*.stats 0
2581 # sum llite stat items
2582 calc_llite_stats() {
2583 local res=$(lctl get_param -n llite.*.stats |
2584 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2589 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2592 calc_osc_kbytes () {
2593 df $MOUNT > /dev/null
2594 $LCTL get_param -n osc.*[oO][sS][cC][-_]*.$1 | calc_sum
2597 # save_lustre_params(node, parameter_mask)
2598 # generate a stream of formatted strings (<node> <param name>=<param value>)
2599 save_lustre_params() {
2601 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2604 # restore lustre parameters from input stream, produces by save_lustre_params
2605 restore_lustre_params() {
2609 while IFS=" =" read node name val; do
2610 do_node ${node//:/} "lctl set_param -n $name $val"
2614 check_catastrophe() {
2615 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2616 local C=$CATASTROPHE
2617 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2619 if [ $rnodes ]; then
2620 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2621 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2637 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2639 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2640 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2641 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2645 mdsrate_cleanup () {
2646 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2649 delayed_recovery_enabled () {
2650 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age" > /dev/null 2>&1
2653 ################################################################################
2654 # The following functions are used to enable interop testing between
2655 # 1.8 and 2.0. The lprocfs layout changed from 1.8 to 2.0 as the followings:
2657 # {blocksize filesfree filestotal fstype kbytesavail kbytesfree kbytestotal mntdev} moved from mds to osd
2658 # mdt lov: fsname-mdtlov -> fsname-MDTXXXX-mdtlov
2659 # mdt osc: fsname-OSTXXXX-osc -> fsname-OSTXXXX-osc-MDTXXXX
2660 ################################################################################
2662 get_lustre_version () {
2663 local node=${1:-"mds"}
2664 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2667 get_mds_version_major () {
2668 local version=$(get_lustre_version mds)
2669 echo $version | awk -F. '{print $1}'
2672 get_mds_version_minor () {
2673 local version=$(get_lustre_version mds)
2674 echo $version | awk -F. '{print $2}'
2677 get_mds_version_patch () {
2678 local version=$(get_lustre_version mds)
2679 echo $version | awk -F. '{print $3}'
2682 get_mds_version_fix () {
2683 local version=$(get_lustre_version mds)
2684 echo $version | awk -F. '{print $4}'
2687 get_mds_fsstat_proc_path() {
2688 local major=$(get_mds_version_major)
2689 local minor=$(get_mds_version_minor)
2690 if [ $major -le 1 -a $minor -le 8 ] ; then
2697 get_mds_mntdev_proc_path() {
2698 local fsstat_dev=$(get_mds_fsstat_proc_path)
2699 echo "$fsstat_dev.*.mntdev"
2702 get_mdtlov_proc_path() {
2704 local major=$(get_mds_version_major)
2705 local minor=$(get_mds_version_minor)
2706 if [ $major -le 1 -a $minor -le 8 ] ; then
2707 echo "${fsname}-mdtlov"
2709 echo "${fsname}-MDT0000-mdtlov"
2713 get_mdtosc_proc_path() {
2715 local major=$(get_mds_version_major)
2716 local minor=$(get_mds_version_minor)
2717 if [ $major -le 1 -a $minor -le 8 ] ; then
2720 echo "${ost}-osc-MDT0000"
2724 get_mds_mdt_device_proc_path() {
2725 local major=$(get_mds_version_major)
2726 local minor=$(get_mds_version_minor)
2727 if [ $major -le 1 -a $minor -le 8 ] ; then
2734 ########################
2736 convert_facet2label() {
2739 if [ x$facet = xost ]; then
2743 local varsvc=${facet}_svc
2745 if [ -n ${!varsvc} ]; then
2748 error "No lablel for $facet!"
2752 get_clientosc_proc_path() {
2758 get_osc_import_name() {
2761 local label=$(convert_facet2label $ost)
2763 if [ "$facet" == "mds" ]; then
2764 get_mdtosc_proc_path $label
2768 get_clientosc_proc_path $label
2772 wait_import_state () {
2778 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2779 while [ "${CONN_STATE}" != "${expected}" ]; do
2780 if [ "${expected}" == "DISCONN" ]; then
2781 # for disconn we can check after proc entry is removed
2782 [ "x${CONN_STATE}" == "x" ] && return 0
2783 # with AT we can have connect request timeout ~ reconnect timeout
2784 # and test can't see real disconnect
2785 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2787 # disconnect rpc should be wait not more obd_timeout
2788 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2789 error "can't put import for $CONN_PROC into ${expected} state" && return 1
2791 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2795 log "$CONN_PROC now in ${CONN_STATE} state"
2799 wait_osc_import_state() {
2803 local ost=$(get_osc_import_name $facet $ost_facet)
2808 CONN_PROC="osc.${ost}.ost_server_uuid"
2809 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2810 while [ "${CONN_STATE}" != "${expected}" ]; do
2811 if [ "${expected}" == "DISCONN" ]; then
2812 # for disconn we can check after proc entry is removed
2813 [ "x${CONN_STATE}" == "x" ] && return 0
2814 # with AT enabled, we can have connect request timeout near of
2815 # reconnect timeout and test can't see real disconnect
2816 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2818 # disconnect rpc should be wait not more obd_timeout
2819 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2820 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2822 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC | cut -f2)
2826 log "${ost_facet} now in ${CONN_STATE} state"
2830 get_clientmdc_proc_path() {
2838 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
2841 wait_clients_import_state () {
2847 local label=$(convert_facet2label $facet)
2850 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
2851 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
2852 *) error "unknown facet!" ;;
2855 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
2856 error "import is not in ${expected} state"
2861 destroy_pool_int() {
2863 local OSTS=$(do_facet mds lctl pool_list $1 | awk '$1 !~ /^Pool:/ {print $1}')
2864 for ost in $OSTS; do
2865 do_facet mgs lctl pool_remove $1 $ost
2867 do_facet mgs lctl pool_destroy $1
2870 # <fsname>.<poolname> or <poolname>
2872 local fsname=${1%%.*}
2873 local poolname=${1##$fsname.}
2875 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
2879 pool_list $fsname.$poolname || return $?
2881 destroy_pool_int $fsname.$poolname
2883 [[ $RC -ne 0 ]] && return $RC
2885 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
2886 2>/dev/null || echo foo" "foo" || RC=1
2888 if [[ $RC -eq 0 ]]; then
2889 remove_pool_from_list $fsname.$poolname
2891 error "destroy pool failed $1"
2897 local fsname=${1:-$FSNAME}
2899 local listvar=${fsname}_CREATED_POOLS
2903 [ x${!listvar} = x ] && return 0
2905 echo destroy the created pools: ${!listvar}
2906 for poolname in ${!listvar//,/ }; do
2907 destroy_pool $fsname.$poolname
2912 local fsname=${1:-$FSNAME}
2914 destroy_pools $fsname
2920 local ts=$(date +%s)
2922 # bug 20237, comment 11
2923 # It would also be useful to provide the option
2924 # of writing the file to an NFS directory so it doesn't need to be copied.
2927 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
2929 # dump lustre logs, dmesg
2930 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
2931 lctl dk \\\$log >/dev/null;
2932 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
2935 # FIXME: does it make sense to collect the logs for $ts only, but all
2937 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
2938 local logs=$TMP/'*'${TESTSUITE}'*'
2940 logs=$logs' '$tmp/'*'$ts'*'
2942 for node in ${list//,/ }; do
2943 rsync -az $node:"$logs" $TMP
2946 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
2947 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
2953 local list=${1:-$(comma_list $(nodes_list))}
2955 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
2967 for i in $(seq 0 $num_mntpts); do
2968 cmd="ls -laf ${mntpt_root}$i/$dir"
2974 for pid in $pids; do