2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
20 #export PDSH="pdsh -S -Rssh -w"
22 # function used by scripts run on remote nodes
23 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
24 . $LUSTRE/tests/functions.sh
28 [[ $DIR/ = $MOUNT/* ]] || \
29 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
30 [[ $DIR1/ = $MOUNT1/* ]] || \
31 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
32 [[ $DIR2/ = $MOUNT2/* ]] || \
33 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
35 [ -n "$failed" ] && exit 99 || true
39 echo "usage: $0 [-r] [-f cfgfile]"
47 [ "$TESTSUITE" == "lfscktest" ] && return 0
48 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
49 local form="%-13s %-17s %s\n"
50 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
51 echo "------------------------------------------------------------------------------------"
52 for O in $TESTSUITE_LIST; do
55 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
58 local log=${TMP}/${o}.log
59 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
60 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
61 [ "${!O}" = "done" ] && \
62 printf "$form" "Done" "$O" "E=$skipped" && \
63 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
67 for O in $TESTSUITE_LIST; do
68 if [ "${!O}" = "no" ]; then
70 # only for those tests suits which are run directly from acc-sm script:
71 # bonnie, iozone, etc.
72 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
73 printf "$form" "UNFINISHED" "$O" ""
75 printf "$form" "Skipped" "$O" ""
80 for O in $TESTSUITE_LIST; do
81 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
82 printf "$form" "UNFINISHED" "$O" ""
87 export LUSTRE=`absolute_path $LUSTRE`
88 export TESTSUITE=`basename $0 .sh`
89 export TEST_FAILED=false
90 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
92 export MKE2FS=${MKE2FS:-mke2fs}
93 export DEBUGFS=${DEBUGFS:-debugfs}
94 export TUNE2FS=${TUNE2FS:-tune2fs}
95 export E2LABEL=${E2LABEL:-e2label}
96 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
97 export E2FSCK=${E2FSCK:-e2fsck}
99 #[ -d /r ] && export ROOT=${ROOT:-/r}
100 export TMP=${TMP:-$ROOT/tmp}
101 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
102 export HOSTNAME=${HOSTNAME:-`hostname`}
103 if ! echo $PATH | grep -q $LUSTRE/utils; then
104 export PATH=$PATH:$LUSTRE/utils
106 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
107 export PATH=$PATH:$LUSTRE/utils/gss
109 if ! echo $PATH | grep -q $LUSTRE/tests; then
110 export PATH=$PATH:$LUSTRE/tests
112 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
113 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
114 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
115 export PATH=$PATH:$LUSTRE/tests/racer
117 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
118 export PATH=$PATH:$LUSTRE/tests/mpi
120 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
121 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
122 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
123 [ ! -f "$LFS" ] && export LFS=$(which lfs)
124 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
125 if [ ! -f "$L_GETIDENTITY" ]; then
126 if `which l_getidentity > /dev/null 2>&1`; then
127 export L_GETIDENTITY=$(which l_getidentity)
129 export L_GETIDENTITY=NONE
132 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
133 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
134 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
135 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
136 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
137 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
138 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
139 export FSTYPE=${FSTYPE:-"ldiskfs"}
140 export NAME=${NAME:-local}
141 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
142 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
143 export LGSSD=$(which lgssd)
144 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
145 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
146 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
148 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
151 if [ "$ACCEPTOR_PORT" ]; then
152 export PORT_OPT="--port $ACCEPTOR_PORT"
157 echo "Using GSS/krb5 ptlrpc security flavor"
158 which lgss_keyring > /dev/null 2>&1 || \
159 error "built with gss disabled! SEC=$SEC"
170 IDENTITY_UPCALL=false
173 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
175 # Paths on remote nodes, if different
176 export RLUSTRE=${RLUSTRE:-$LUSTRE}
177 export RPWD=${RPWD:-$PWD}
178 export I_MOUNTED=${I_MOUNTED:-"no"}
179 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
180 ! -f `dirname $0`/../mds/mds.ko ]; then
181 export CLIENTMODSONLY=yes
186 while getopts "rvwf:" opt $*; do
189 r) REFORMAT=--reformat;;
191 w) WRITECONF=writeconf;;
196 shift $((OPTIND - 1))
199 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
204 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
205 *) EXT=".ko"; USE_QUOTA=yes;;
210 /sbin/lsmod | grep -q $1
217 BASE=`basename $module $EXT`
219 module_loaded ${BASE} && return
221 if [ -f ${LUSTRE}/${module}${EXT} ]; then
222 insmod ${LUSTRE}/${module}${EXT} $@
224 # must be testing a "make install" or "rpm" installation
225 # note failed to load ptlrpc_gss is considered not fatal
226 if [ "$BASE" == "ptlrpc_gss" ]; then
227 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
234 load_modules_local() {
235 if [ -n "$MODPROBE" ]; then
239 if [ "$HAVE_MODULES" = true ]; then
245 echo Loading modules from $LUSTRE
246 load_module ../libcfs/libcfs/libcfs
247 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
248 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
250 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
251 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
252 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
253 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
254 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
255 echo "lnet options: '$LNETOPTS'"
256 # note that insmod will ignore anything in modprobe.conf
257 load_module ../lnet/lnet/lnet $LNETOPTS
258 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
259 load_module ../lnet/klnds/$LNETLND
260 load_module lvfs/lvfs
261 load_module obdclass/obdclass
262 load_module ptlrpc/ptlrpc
263 load_module ptlrpc/gss/ptlrpc_gss
264 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
272 if ! client_only; then
273 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
274 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
275 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
280 load_module lvfs/fsfilt_$FSTYPE
284 load_module obdfilter/obdfilter
287 load_module llite/lustre
288 load_module llite/llite_lloop
289 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
291 rm -f $OGDB/ogdb-$HOSTNAME
292 $LCTL modules > $OGDB/ogdb-$HOSTNAME
294 # 'mount' doesn't look in $PATH, just sbin
295 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
301 # load modules on remote nodes optionally
302 # lustre-tests have to be installed on these nodes
303 if $LOAD_MODULES_REMOTE ; then
304 local list=$(comma_list $(remote_nodes_list))
305 echo loading modules on $list
306 do_rpc_nodes $list load_modules
311 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
312 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
313 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
314 echo "$LEAK_LUSTRE" 1>&2
315 echo "$LEAK_PORTALS" 1>&2
316 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
317 echo "Memory leaks detected"
318 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
324 wait_exit_ST client # bug 12845
326 $LUSTRE_RMMOD $FSTYPE || return 2
328 if $LOAD_MODULES_REMOTE ; then
329 local list=$(comma_list $(remote_nodes_list))
330 echo unloading modules on $list
331 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
332 do_rpc_nodes $list check_mem_leak
337 check_mem_leak || return 254
339 echo "modules unloaded."
343 check_gss_daemon_facet() {
347 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
348 if [ $num -ne 1 ]; then
349 echo "$num instance of $dname on $facet"
358 do_facet $facet "killall -2 $@ 2>/dev/null || true"
361 start_gss_daemons() {
363 for num in `seq $MDSCOUNT`; do
364 do_facet mds$num "$LSVCGSSD -v"
366 do_facet mds$num "$LGSSD -v"
370 for num in `seq $OSTCOUNT`; do
371 do_facet ost$num "$LSVCGSSD -v"
374 # FIXME: is "client" the right facet name?
376 do_facet client "$LGSSD -v"
379 # wait daemons entering "stable" status
383 # check daemons are running
385 for num in `seq $MDSCOUNT`; do
386 check_gss_daemon_facet mds$num lsvcgssd
388 check_gss_daemon_facet mds$num lgssd
391 for num in `seq $OSTCOUNT`; do
392 check_gss_daemon_facet ost$num lsvcgssd
395 check_gss_daemon_facet client lgssd
400 for num in `seq $MDSCOUNT`; do
401 send_sigint mds$num lsvcgssd lgssd
403 for num in `seq $OSTCOUNT`; do
404 send_sigint ost$num lsvcgssd
406 send_sigint client lgssd
413 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
414 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
422 # maybe cleanup credential cache?
428 local device=`mdsdevname $num`
429 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
435 local device=`ostdevname $num`
436 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
444 local dev=$(facet_active $facet)_dev
445 local opt=${facet}_opt
446 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
447 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
449 if [ $RC -ne 0 ]; then
450 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
451 echo "Start of ${!dev} on ${facet} failed ${RC}"
453 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
454 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
455 lctl set_param debug_mb=${DEBUG_SIZE}; \
458 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
459 [ -z "$label" ] && echo no label for ${!dev} && exit 1
460 eval export ${facet}_svc=${label}
461 echo Started ${label}
466 # start facet device options
472 eval export ${facet}_dev=${device}
473 eval export ${facet}_opt=\"$@\"
475 local varname=${facet}failover_dev
476 if [ -n "${!varname}" ] ; then
477 eval export ${facet}failover_dev=${!varname}
479 eval export ${facet}failover_dev=$device
482 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
492 HOST=`facet_active_host $facet`
493 [ -z $HOST ] && echo stop: no host for $facet && return 0
495 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
496 if [ ${running} -ne 0 ]; then
497 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
498 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
501 # umount should block, but we should wait for unrelated obd's
502 # like the MGS or MGC to also stop.
503 wait_exit_ST ${facet}
506 # save quota version (both administrative and operational quotas)
507 # add an additional parameter if mountpoint is ever different from $MOUNT
508 quota_save_version() {
509 local fsname=${2:-$FSNAME}
511 local ver=$(tr -c -d "123" <<< $spec)
512 local type=$(tr -c -d "ug" <<< $spec)
514 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
516 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
518 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
520 local osts=$(get_facets OST)
521 for ost in ${osts//,/ }; do
523 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
527 # client could mount several lustre
529 local fsname=${1:-$FSNAME}
531 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
532 do_nodes $(comma_list $(osts_nodes)) \
533 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
537 restore_quota_type () {
538 local mntpt=${1:-$MOUNT}
539 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
540 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
543 quota_save_version $old_QUOTA_TYPE
549 # We need save the original quota_type params, and restore them after testing
551 # Suppose that quota type the same on mds and ost
552 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
553 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
554 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
555 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
556 export old_QUOTA_TYPE=$quota_type
557 quota_save_version $QUOTA_TYPE
559 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
560 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
563 local quota_usrs=$QUOTA_USERS
565 # get_filesystem_size
566 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
567 local blk_soft=$((disksz + 1024))
568 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
570 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
572 local i_hard=$((i_soft + i_soft / 20))
574 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
575 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
578 for usr in $quota_usrs; do
579 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
581 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
583 eval $cmd || error "$cmd FAILED!"
585 # display the quota status
586 echo "Quota settings for $usr : "
587 $LFS quota -v -u $usr $mntpt || true
595 # Only supply -o to mount if we have options
596 if [ -n "$MOUNTOPT" ]; then
597 OPTIONS="-o $MOUNTOPT"
599 local device=$MGSNID:/$FSNAME
600 if [ -z "$mnt" -o -z "$FSNAME" ]; then
601 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
605 echo "Starting client: $client: $OPTIONS $device $mnt"
606 do_node $client mkdir -p $mnt
607 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
609 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
610 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
611 lctl set_param debug_mb=${DEBUG_SIZE}"
624 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
625 if [ $running -ne 0 ]; then
626 echo "Stopping client $client $mnt (opts:$force)"
627 do_node $client lsof -t $mnt || need_kill=no
628 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
629 pids=$(do_node $client lsof -t $mnt | sort -u);
630 if [ -n $pids ]; then
631 do_node $client kill -9 $pids || true
635 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
636 if [ $busy -ne 0 ] ; then
637 echo "$mnt is still busy, wait one second" && sleep 1
638 do_node $client umount $force $mnt
643 # nodes is comma list
644 sanity_mount_check_nodes () {
650 # FIXME: assume that all cluster nodes run the same os
651 [ "$(uname)" = Linux ] || return 0
654 for mnt in $mnts ; do
655 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
656 mpts=\\\$(mount | grep -w -c $mnt);
657 if [ \\\$running -ne \\\$mpts ]; then
658 echo \\\$(hostname) env are INSANE!;
666 sanity_mount_check_servers () {
668 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
669 echo Checking servers environments
671 # FIXME: modify get_facets to display all facets wo params
672 local facets="$(get_facets OST),$(get_facets MDS),mgs"
676 for facet in ${facets//,/ }; do
677 node=$(facet_host ${facet})
678 mnt=${MOUNT%/*}/${facet}
679 sanity_mount_check_nodes $node $mnt ||
680 { error "server $node environments are insane!"; return 1; }
684 sanity_mount_check_clients () {
685 local clients=${1:-$CLIENTS}
686 local mntpt=${2:-$MOUNT}
687 local mntpt2=${3:-$MOUNT2}
689 [ -z $clients ] && clients=$(hostname)
690 echo Checking clients $clients environments
692 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
693 error "clients environments are insane!"
696 sanity_mount_check () {
697 sanity_mount_check_servers || return 1
698 sanity_mount_check_clients || return 2
701 # mount clients if not mouted
702 zconf_mount_clients() {
708 # Only supply -o to mount if we have options
709 if [ -n "$MOUNTOPT" ]; then
710 OPTIONS="-o $MOUNTOPT"
712 local device=$MGSNID:/$FSNAME
713 if [ -z "$mnt" -o -z "$FSNAME" ]; then
714 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
718 echo "Starting client $clients: $OPTIONS $device $mnt"
721 running=\\\$(mount | grep -c $mnt' ');
723 if [ \\\$running -eq 0 ] ; then
725 mount -t lustre $OPTIONS $device $mnt;
728 exit \\\$rc" || return ${PIPESTATUS[0]}
730 echo "Started clients $clients: "
731 do_nodes $clients "mount | grep -w $mnt"
733 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
734 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
735 lctl set_param debug_mb=${DEBUG_SIZE};"
740 zconf_umount_clients() {
747 echo "Stopping clients: $clients $mnt (opts:$force)"
748 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
749 if [ \\\$running -ne 0 ] ; then
750 echo Stopping client \\\$(hostname) client $mnt opts:$force;
751 lsof -t $mnt || need_kill=no;
752 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
753 pids=\\\$(lsof -t $mnt | sort -u);
754 if [ -n \\\"\\\$pids\\\" ]; then
758 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
759 if [ \\\$busy -ne 0 ] ; then
760 echo "$mnt is still busy, wait one second" && sleep 1;
766 shudown_node_hard () {
770 for i in $(seq $attempts) ; do
773 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
774 echo "waiting for $host to fail attempts=$attempts"
775 [ $i -lt $attempts ] || \
776 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
782 local mnt=${2:-$MOUNT}
785 if [ "$FAILURE_MODE" = HARD ]; then
786 shudown_node_hard $client
788 zconf_umount_clients $client $mnt -f
794 if [ "$FAILURE_MODE" = HARD ]; then
795 shudown_node_hard $(facet_active_host $facet)
796 elif [ "$FAILURE_MODE" = SOFT ]; then
803 if [ "$FAILURE_MODE" = HARD ]; then
804 $POWER_UP `facet_active_host $facet`
812 if [ "$FAILURE_MODE" = HARD ]; then
818 # recovery-scale functions
819 check_progs_installed () {
824 do_nodes $clients "PATH=:$PATH; status=true;
825 for prog in $progs; do
826 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
827 echo \\\$prog missing on \\\$(hostname);
835 echo __$(echo $1 | tr '-' 'X')
838 start_client_load() {
841 local var=$(client_var_name $client)_load
842 eval export ${var}=$load
844 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
845 BREAK_ON_ERROR=$BREAK_ON_ERROR \
846 END_RUN_FILE=$END_RUN_FILE \
847 LOAD_PID_FILE=$LOAD_PID_FILE \
848 TESTSUITELOG=$TESTSUITELOG \
850 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
851 log "Started client load: ${load} on $client"
856 start_client_loads () {
857 local -a clients=(${1//,/ })
858 local numloads=${#CLIENT_LOADS[@]}
861 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
862 testnum=$((nodenum % numloads))
863 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
867 # only for remote client
868 check_client_load () {
870 local var=$(client_var_name $client)_load
871 local TESTLOAD=run_${!var}.sh
873 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
875 # bug 18914: try to connect several times not only when
876 # check ps, but while check_catastrophe also
879 while [ $RC = 254 -a $tries -gt 0 ]; do
883 if ! check_catastrophe $client; then
885 if [ $RC -eq 254 ]; then
886 # FIXME: not sure how long we shuold sleep here
890 echo "check catastrophe failed: RC=$RC "
894 # We can continue try to connect if RC=254
895 # Just print the warning about this
896 if [ $RC = 254 ]; then
897 echo "got a return status of $RC from do_node while checking catastrophe on $client"
900 # see if the load is still on the client
903 while [ $RC = 254 -a $tries -gt 0 ]; do
907 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
912 if [ $RC = 254 ]; then
913 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
914 # see if we can diagnose a bit why this is
919 check_client_loads () {
920 local clients=${1//,/ }
924 for client in $clients; do
925 check_client_load $client
927 if [ "$rc" != 0 ]; then
928 log "Client load failed on node $client, rc=$rc"
934 restart_client_loads () {
935 local clients=${1//,/ }
936 local expectedfail=${2:-""}
940 for client in $clients; do
941 check_client_load $client
943 if [ "$rc" != 0 -a "$expectedfail" ]; then
944 local var=$(client_var_name $client)_load
945 start_client_load $client ${!var}
946 echo "Restarted client load ${!var}: on $client. Checking ..."
947 check_client_load $client
949 if [ "$rc" != 0 ]; then
950 log "Client load failed to restart on node $client, rc=$rc"
951 # failure one client load means test fail
952 # we do not need to check other
960 # End recovery-scale functions
962 # verify that lustre actually cleaned up properly
964 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
965 error "LBUG/LASSERT detected"
966 BUSY=`dmesg | grep -i destruct || true`
969 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
973 check_mem_leak || exit 204
975 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
976 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
978 if module_loaded lnet || module_loaded libcfs; then
979 echo "$0: modules still loaded..." 1>&2
996 RESULT=$(do_node $node "$TEST")
997 if [ "$RESULT" == "$FINAL" ]; then
998 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1001 [ $WAIT -ge $MAX ] && break
1002 echo "Waiting $((MAX - WAIT)) secs for update"
1003 WAIT=$((WAIT + sleep))
1006 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1010 wait_update_facet () {
1012 wait_update $(facet_active_host $facet) "$@"
1015 wait_delete_completed () {
1016 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1017 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1021 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1023 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1024 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1025 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1026 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1030 echo "Delete is not completed in $MAX_WAIT sec"
1036 check_network "$host" 900
1037 while ! do_node $host hostname > /dev/null; do sleep 5; done
1042 local host=`facet_active_host $facet`
1046 wait_recovery_complete () {
1049 # Use default policy if $2 is not passed by caller.
1050 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1051 # as we are in process of changing obd_timeout in different ways
1052 # let's set MAX longer than that
1053 local MAX=${2:-$(( TIMEOUT * 4 ))}
1055 local var_svc=${facet}_svc
1056 local procfile="*.${!var_svc}.recovery_status"
1060 while [ $WAIT -lt $MAX ]; do
1061 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1062 [[ $STATUS = "status: COMPLETE" ]] && return 0
1065 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1067 echo "$facet recovery not done in $MAX sec. $STATUS"
1071 wait_mds_ost_sync () {
1072 # just because recovery is done doesn't mean we've finished
1073 # orphan cleanup. Wait for llogs to get synchronized.
1074 echo "Waiting for orphan cleanup..."
1075 # MAX value includes time needed for MDS-OST reconnection
1076 local MAX=$(( TIMEOUT * 2 ))
1078 while [ $WAIT -lt $MAX ]; do
1079 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1080 "$LCTL get_param -n obdfilter.*.mds_sync"))
1082 for ((i=0; i<${#sync[@]}; i++)); do
1083 [ ${sync[$i]} -eq 0 ] && continue
1084 # there is a not finished MDS-OST synchronization
1088 sleep 2 # increase waiting time and cover statfs cache
1089 [ ${con} -eq 1 ] && return 0
1090 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1093 echo "$facet recovery not done in $MAX sec. $STATUS"
1097 wait_destroy_complete () {
1098 echo "Waiting for destroy to be done..."
1099 # MAX value shouldn't be big as this mean server responsiveness
1100 # never increase this just to make test pass but investigate
1101 # why it takes so long time
1104 while [ $WAIT -lt $MAX ]; do
1105 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1107 for ((i=0; i<${#RPCs[@]}; i++)); do
1108 [ ${RPCs[$i]} -eq 0 ] && continue
1109 # there are still some destroy RPCs in flight
1114 [ ${con} -eq 1 ] && return 0 # done waiting
1115 echo "Waiting $WAIT secs for destroys to be done."
1118 echo "Destroys weren't done in $MAX sec."
1128 # conf-sanity 31 takes a long time cleanup
1129 while [ $WAIT -lt 300 ]; do
1130 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1131 [ -z "${running}" ] && return 0
1132 echo "waited $WAIT for${running}"
1133 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1135 WAIT=$((WAIT + INTERVAL))
1137 echo "service didn't stop after $WAIT seconds. Still running:"
1142 wait_remote_prog () {
1148 [ "$PDSH" = "no_dsh" ] && return 0
1150 while [ $WAIT -lt $2 ]; do
1151 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1152 [ -z "${running}" ] && return 0 || true
1153 echo "waited $WAIT for: "
1155 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1157 WAIT=$((WAIT + INTERVAL))
1159 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1160 [ -z "$pids" ] && return 0
1161 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1162 # FIXME: not portable
1163 for pid in $pids; do
1164 cat /proc/${pid}/status || true
1165 cat /proc/${pid}/wchan || true
1167 kill -9 $pid || true
1176 # not every config has many clients
1177 if [ ! -z "$CLIENTS" ]; then
1178 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1180 df $MOUNT > /dev/null
1184 client_reconnect() {
1185 uname -n >> $MOUNT/recon
1186 if [ -z "$CLIENTS" ]; then
1187 df $MOUNT; uname -n >> $MOUNT/recon
1189 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1191 echo Connected clients:
1193 ls -l $MOUNT/recon > /dev/null
1200 echo "Failing $facet on node `facet_active_host $facet`"
1201 shutdown_facet $facet
1202 [ -n "$sleep_time" ] && sleep $sleep_time
1204 change_active $facet
1205 local TO=`facet_active_host $facet`
1206 echo "Failover $facet to $TO"
1208 mount_facet $facet || error "Restart of $facet failed"
1217 do_facet $facet sync
1219 local svc=${facet}_svc
1220 do_facet $facet $LCTL --device %${!svc} notransno
1221 do_facet $facet $LCTL --device %${!svc} readonly
1222 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1223 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1226 replay_barrier_nodf() {
1227 local facet=$1 echo running=${running}
1228 do_facet $facet sync
1229 local svc=${facet}_svc
1230 echo Replay barrier on ${!svc}
1231 do_facet $facet $LCTL --device %${!svc} notransno
1232 do_facet $facet $LCTL --device %${!svc} readonly
1233 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1234 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1237 replay_barrier_nosync() {
1238 local facet=$1 echo running=${running}
1239 local svc=${facet}_svc
1240 echo Replay barrier on ${!svc}
1241 do_facet $facet $LCTL --device %${!svc} notransno
1242 do_facet $facet $LCTL --device %${!svc} readonly
1243 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1244 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1247 mds_evict_client() {
1248 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1249 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1252 ost_evict_client() {
1253 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1254 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1258 facet_failover $* || error "failover: $?"
1259 client_df || error "post-failover df: $?"
1264 facet_failover $facet
1270 change_active $facet
1271 mount_facet $facet -o abort_recovery
1272 client_df || echo "first df failed: $?"
1274 client_df || error "post-failover df: $?"
1278 echo There is no lmc. This is mountconf, baby.
1283 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1284 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1290 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1296 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1297 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1298 if [ -z "$ID" ]; then
1299 echo "Could not get a ptl id for $1..."
1308 h2name_or_ip "$1" "tcp"
1313 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1314 if type __h2elan >/dev/null 2>&1; then
1317 ID=`echo $1 | sed 's/[^0-9]*//g'`
1325 h2name_or_ip "$1" "openib"
1327 declare -fx h2openib
1330 h2name_or_ip "$1" "o2ib"
1337 [ "$facet" == client ] && echo -n $HOSTNAME && return
1338 varname=${facet}_HOST
1339 if [ -z "${!varname}" ]; then
1340 if [ "${facet:0:3}" == "ost" ]; then
1341 eval ${facet}_HOST=${ost_HOST}
1349 local activevar=${facet}active
1351 if [ -f $TMP/${facet}active ] ; then
1352 source $TMP/${facet}active
1355 active=${!activevar}
1356 if [ -z "$active" ] ; then
1363 facet_active_host() {
1365 local active=`facet_active $facet`
1366 if [ "$facet" == client ]; then
1369 echo `facet_host $active`
1375 local failover=${facet}failover
1376 host=`facet_host $failover`
1377 [ -z "$host" ] && return
1378 local curactive=`facet_active $facet`
1379 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1380 eval export ${facet}active=$facet
1382 eval export ${facet}active=$failover
1384 # save the active host for this facet
1385 local activevar=${facet}active
1386 echo "$activevar=${!activevar}" > $TMP/$activevar
1391 # do not stripe off hostname if verbose, bug 19215
1392 if [ x$1 = x--verbose ]; then
1400 if [ "$HOST" = "$HOSTNAME" ]; then
1402 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1403 echo "cannot run remote command on $HOST with $myPDSH"
1407 echo "CMD: $HOST $@" >&2
1408 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1411 if [ "$myPDSH" = "rsh" ]; then
1412 # we need this because rsh does not return exit code of an executed command
1413 local command_status="$TMP/cs"
1414 rsh $HOST ":> $command_status"
1415 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1416 cd $RPWD; sh -c \"$@\") ||
1417 echo command failed >$command_status"
1418 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1423 # print HOSTNAME for myPDSH="no_dsh"
1424 if [[ $myPDSH = no_dsh ]]; then
1425 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1427 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1430 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1432 return ${PIPESTATUS[0]}
1435 single_local_node () {
1436 [ "$1" = "$HOSTNAME" ]
1441 # do not stripe off hostname if verbose, bug 19215
1442 if [ x$1 = x--verbose ]; then
1450 if $(single_local_node $rnodes); then
1452 do_node --verbose $rnodes $@
1459 # This is part from do_node
1462 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1463 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1466 echo "CMD: $rnodes $@" >&2
1467 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1471 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1473 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1475 return ${PIPESTATUS[0]}
1481 local HOST=`facet_active_host $facet`
1482 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1489 # make sure its not already running
1491 rm -f $TMP/${facet}active
1492 do_facet ${facet} $MKFS $*
1498 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1499 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1506 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1507 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1515 # make sure we are using the primary server, so test-framework will
1516 # be able to clean up properly.
1517 activemds=`facet_active mds1`
1518 if [ $activemds != "mds1" ]; then
1522 local clients=$CLIENTS
1523 [ -z $clients ] && clients=$(hostname)
1525 zconf_umount_clients $clients $MOUNT "$*" || true
1526 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1528 [ "$CLIENTONLY" ] && return
1529 # The add fn does rm ${facet}active file, this would be enough
1530 # if we use do_facet <facet> only after the facet added, but
1531 # currently we use do_facet mds in local.sh
1532 for num in `seq $MDSCOUNT`; do
1534 rm -f ${TMP}/mds${num}active
1537 for num in `seq $OSTCOUNT`; do
1539 rm -f $TMP/ost${num}active
1546 nfs_client_mode && return
1556 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1560 if [ "$IAMDIR" == "yes" ]; then
1561 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1562 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1565 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1567 if [ ! -z $SEC ]; then
1568 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1569 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1570 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1574 # We need ldiskfs here, may as well load them all
1576 [ "$CLIENTONLY" ] && return
1577 echo Formatting mgs, mds, osts
1578 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1579 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1582 for num in `seq $MDSCOUNT`; do
1583 echo "Format mds$num: $(mdsdevname $num)"
1585 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1587 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1591 for num in `seq $OSTCOUNT`; do
1592 echo "Format ost$num: $(ostdevname $num)"
1594 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1596 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1602 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1606 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1610 # 0: success, the old identity set already.
1611 # 1: success, the old identity does not set.
1616 local j=`expr $num - 1`
1617 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1619 if [ -z "$MDT" ]; then
1623 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1626 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1628 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1631 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1633 if [ $old = "NONE" ]; then
1642 zconf_umount `hostname` $1 || error "umount failed"
1643 zconf_mount `hostname` $1 || error "mount failed"
1646 writeconf_facet () {
1650 do_facet $facet "$TUNEFS --writeconf $dev"
1654 for num in `seq $MDSCOUNT`; do
1655 DEVNAME=$(mdsdevname $num)
1656 writeconf_facet mds$num $DEVNAME
1659 for num in `seq $OSTCOUNT`; do
1660 DEVNAME=$(ostdevname $num)
1661 writeconf_facet ost$num $DEVNAME
1666 nfs_client_mode && return
1668 sanity_mount_check ||
1669 error "environments are insane!"
1673 if [ -z "$CLIENTONLY" ]; then
1674 echo Setup mgs, mdt, osts
1675 echo $WRITECONF | grep -q "writeconf" && \
1677 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1678 start mgs $MGSDEV $mgs_MOUNT_OPTS
1681 for num in `seq $MDSCOUNT`; do
1682 DEVNAME=$(mdsdevname $num)
1683 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1685 # We started mds, now we should set failover variables properly.
1686 # Set mds${num}failover_HOST if it is not set (the default failnode).
1687 local varname=mds${num}failover_HOST
1688 if [ -z "${!varname}" ]; then
1689 eval mds${num}failover_HOST=$(facet_host mds$num)
1692 if [ $IDENTITY_UPCALL != "default" ]; then
1693 switch_identity $num $IDENTITY_UPCALL
1696 for num in `seq $OSTCOUNT`; do
1697 DEVNAME=$(ostdevname $num)
1698 start ost$num $DEVNAME $OST_MOUNT_OPTS
1700 # We started ost$num, now we should set ost${num}failover variable properly.
1701 # Set ost${num}failover_HOST if it is not set (the default failnode).
1702 varname=ost${num}failover_HOST
1703 if [ -z "${!varname}" ]; then
1704 eval ost${num}failover_HOST=$(facet_host ost${num})
1709 # wait a while to allow sptlrpc configuration be propogated to targets,
1710 # only needed when mounting new target devices.
1713 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1715 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1717 if [ "$MOUNT_2" ]; then
1718 mount_client $MOUNT2
1719 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1724 # by remounting mdt before ost, initial connect from mdt to ost might
1725 # timeout because ost is not ready yet. wait some time to its fully
1726 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1727 # by a context negotiation rpc with $TIMEOUT.
1728 # FIXME better by monitoring import status.
1730 sleep $((TIMEOUT + 5))
1736 mounted_lustre_filesystems() {
1737 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1740 init_facet_vars () {
1741 [ "$CLIENTONLY" ] && return 0
1748 eval export ${facet}_dev=${device}
1749 eval export ${facet}_opt=\"$@\"
1751 local dev=${facet}_dev
1752 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1753 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1755 eval export ${facet}_svc=${label}
1757 local varname=${facet}failover_HOST
1758 if [ -z "${!varname}" ]; then
1759 eval $varname=$(facet_host $facet)
1762 # ${facet}failover_dev is set in cfg file
1763 varname=${facet}failover_dev
1764 if [ -n "${!varname}" ] ; then
1765 eval export ${facet}failover_dev=${!varname}
1767 eval export ${facet}failover_dev=$device
1771 init_facets_vars () {
1774 if ! remote_mds_nodsh; then
1775 for num in `seq $MDSCOUNT`; do
1776 DEVNAME=`mdsdevname $num`
1777 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1781 remote_ost_nodsh && return
1783 for num in `seq $OSTCOUNT`; do
1784 DEVNAME=`ostdevname $num`
1785 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1789 osc_ensure_active () {
1795 while [ $period -lt $timeout ]; do
1796 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1797 if [ $count -eq 0 ]; then
1801 echo "There are $count OST are inactive, wait $period seconds, and try again"
1803 period=$((period+3))
1806 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1810 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1814 init_param_vars () {
1815 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1816 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1817 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1818 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1822 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1824 log "Using TIMEOUT=$TIMEOUT"
1826 osc_ensure_active $SINGLEMDS M $TIMEOUT
1827 osc_ensure_active client c $TIMEOUT
1829 if [ x"$(som_check)" = x"enabled" ]; then
1831 echo "disable quota temporary when SOM enabled"
1833 if [ $QUOTA_AUTO -ne 0 ]; then
1834 if [ "$ENABLE_QUOTA" ]; then
1835 echo "enable quota as required"
1836 setup_quota $MOUNT || return 2
1838 echo "disable quota as required"
1839 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1844 nfs_client_mode () {
1845 if [ "$NFSCLIENT" ]; then
1846 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1847 local clients=$CLIENTS
1848 [ -z $clients ] && clients=$(hostname)
1850 # FIXME: remove hostname when 19215 fixed
1851 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1852 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1853 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1860 nfs_client_mode && return
1864 local mounted=$(mount | grep " $mntpt ")
1865 if [ "$CLIENTONLY" ]; then
1867 # CLIENTONLY should not depend on *_HOST settings
1868 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1869 # in theory someone could create a new,
1870 # client-only config file that assumed lustre was already
1871 # configured and didn't set the MGSNID. If MGSNID is not set,
1872 # then we should use the mgs nid currently being used
1873 # as the default value. bug 18021
1874 [[ x$MGSNID = x ]] &&
1877 if [[ x$mgc != xMGC$MGSNID ]]; then
1878 if [ "$mgs_HOST" ]; then
1879 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1880 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1881 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1887 local myMGS_host=$mgs_HOST
1888 if [ "$NETTYPE" = "ptl" ]; then
1889 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1892 echo Checking config lustre mounted on $mntpt
1893 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1894 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1896 # if [ "$mgshost" != "$myMGS_host" ]; then
1897 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1898 # Please use correct config or set mds_HOST correctly!"
1901 sanity_mount_check ||
1902 error "environments are insane!"
1906 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1907 local cltimeout=$(lctl get_param -n timeout)
1908 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1909 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1914 check_and_setup_lustre() {
1915 nfs_client_mode && return
1917 local MOUNTED=$(mounted_lustre_filesystems)
1920 # MOUNT is not mounted
1921 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1922 [ "$REFORMAT" ] && formatall
1924 MOUNTED=$(mounted_lustre_filesystems | head -1)
1925 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1926 export I_MOUNTED=yes
1929 # MOUNT and MOUNT2 are mounted
1930 elif $(echo $MOUNTED | grep -w -q $MOUNT2); then
1932 # MOUNT2 is mounted, MOUNT_2 is not set
1933 if ! [ "$MOUNT_2" ]; then
1934 zconf_umount `hostname` $MOUNT2
1935 export I_UMOUNTED2=yes
1937 # MOUNT2 is mounted, MOUNT_2 is set
1939 check_config $MOUNT2
1948 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1949 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1950 lctl set_param debug_mb=${DEBUG_SIZE};
1953 if [ "$ONLY" == "setup" ]; then
1958 cleanup_and_setup_lustre() {
1959 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1960 lctl set_param debug=0 || true
1962 if [ "$ONLY" == "cleanup" ]; then
1966 check_and_setup_lustre
1969 check_and_cleanup_lustre() {
1970 if [ "`mount | grep $MOUNT`" ]; then
1971 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1972 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1974 if [ "$I_UMOUNTED2" = "yes" ]; then
1975 mount_client $MOUNT2 || error "restore $MOUNT2 failed"
1978 if [ "$I_MOUNTED" = "yes" ]; then
1979 cleanupall -f || error "cleanup failed"
1991 while [ $NETWORK -eq 0 ]; do
1992 if ping -c 1 -w 3 $1 > /dev/null; then
1996 echo "waiting for $1, $((MAX - WAIT)) secs left"
1999 if [ $WAIT -gt $MAX ]; then
2000 echo "Network not available"
2006 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2017 # the sed converts spaces to commas, but leaves the last space
2018 # alone, so the line doesn't end with a comma.
2019 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2022 # list, excluded are the comma separated lists
2023 exclude_items_from_list () {
2029 for item in ${excluded//,/ }; do
2030 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2032 echo $(comma_list $list)
2035 # list, expand are the comma separated lists
2037 local list=${1//,/ }
2038 local expand=${2//,/ }
2041 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2042 echo $(comma_list $expanded)
2045 testslist_filter () {
2046 local script=$LUSTRE/tests/${TESTSUITE}.sh
2048 [ -f $script ] || return 0
2050 local start_at=$START_AT
2051 local stop_at=$STOP_AT
2053 local var=${TESTSUITE}_START_AT
2054 [ x"${!var}" != x ] && start_at=${!var}
2055 var=${TESTSUITE}_STOP_AT
2056 [ x"${!var}" != x ] && stop_at=${!var}
2058 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2059 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2060 /^'${start_at}'$/ {flag = 0}
2061 {if (flag == 1) print $0}
2062 /^'${stop_at}'$/ { flag = 1 }'
2066 (cd `dirname $1`; echo $PWD/`basename $1`)
2070 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2071 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2074 local count=${type}COUNT
2075 for ((i=1; i<=${!count}; i++)) do
2076 list="$list ${name}$i"
2078 echo $(comma_list $list)
2081 ##################################
2082 # Adaptive Timeouts funcs
2085 # only check mds, we assume at_max is the same on all nodes
2086 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2087 if [ $at_max -eq 0 ]; then
2097 # suppose that all ost-s has the same at_max set
2098 if [ $facet == "ost" ]; then
2099 do_facet ost1 "lctl get_param -n at_max"
2101 do_facet $facet "lctl get_param -n at_max"
2111 if [ $facet == "ost" ]; then
2112 for i in `seq $OSTCOUNT`; do
2113 do_facet ost$i "lctl set_param at_max=$at_max"
2116 elif [ $facet == "mds" ]; then
2117 for i in `seq $MDSCOUNT`; do
2118 do_facet mds$i "lctl set_param at_max=$at_max"
2121 do_facet $facet "lctl set_param at_max=$at_max"
2126 ##################################
2130 # OBD_FAIL_MDS_ALL_REQUEST_NET
2132 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2133 do_facet client "$1" || RC=$?
2134 do_facet $SINGLEMDS lctl set_param fail_loc=0
2139 # OBD_FAIL_MDS_ALL_REPLY_NET
2141 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2142 do_facet client "$@" || RC=$?
2143 do_facet $SINGLEMDS lctl set_param fail_loc=0
2147 drop_reint_reply() {
2148 # OBD_FAIL_MDS_REINT_NET_REP
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2151 do_facet client "$@" || RC=$?
2152 do_facet $SINGLEMDS lctl set_param fail_loc=0
2157 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2159 do_facet ost1 lctl set_param fail_loc=0x214
2160 do_facet client "$1" || RC=$?
2161 do_facet client "sync"
2162 do_facet ost1 lctl set_param fail_loc=0
2166 drop_ldlm_cancel() {
2167 #define OBD_FAIL_LDLM_CANCEL 0x304
2169 do_facet client lctl set_param fail_loc=0x304
2170 do_facet client "$@" || RC=$?
2171 do_facet client lctl set_param fail_loc=0
2175 drop_bl_callback() {
2176 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2178 do_facet client lctl set_param fail_loc=0x305
2179 do_facet client "$@" || RC=$?
2180 do_facet client lctl set_param fail_loc=0
2185 #define OBD_FAIL_LDLM_REPLY 0x30c
2187 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2188 do_facet client "$@" || RC=$?
2189 do_facet $SINGLEMDS lctl set_param fail_loc=0
2197 echo "clearing fail_loc on $facet"
2198 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2201 set_nodes_failloc () {
2202 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2205 cancel_lru_locks() {
2206 $LCTL mark "cancel_lru_locks $1 start"
2207 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2208 $LCTL set_param -n $d=clear
2210 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2211 $LCTL mark "cancel_lru_locks $1 stop"
2216 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2217 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2218 echo "$DEFAULT_LRU_SIZE"
2223 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2226 lru_resize_disable()
2228 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2233 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2234 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2235 echo there is still data in page cache $FILE ?
2236 lctl get_param -n $FILE
2240 if [[ $MDSDEV1 != $MGSDEV ]]; then
2248 DEBUGSAVE="$(lctl get_param -n debug)"
2252 [ -n "$DEBUGSAVE" ] && \
2253 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2258 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2261 debug_size_restore() {
2262 [ -n "$DEBUG_SIZE_SAVED" ] && \
2263 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2267 start_full_debug_logging() {
2272 local DEBUG_SIZE=150
2274 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2275 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2278 stop_full_debug_logging() {
2283 ##################################
2285 ##################################
2288 local TYPE=${TYPE:-"FAIL"}
2290 lctl set_param fail_loc=0 2>/dev/null || true
2293 # do not dump logs if $1=false
2294 if [ "x$1" = "xfalse" ]; then
2299 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2302 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2303 echo "Dumping lctl log to $ERRLOG"
2304 # We need to dump the logs on all nodes
2305 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2308 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2314 $FAIL_ON_ERROR && exit 1 || true
2322 # use only if we are ignoring failures for this test, bugno required.
2323 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2324 # e.g. error_ignore 5494 "your message"
2326 local TYPE="IGNORE (bz$1)"
2332 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2337 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2338 [ "$TESTSUITELOG" ] && \
2339 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2342 build_test_filter() {
2343 EXCEPT="$EXCEPT $(testslist_filter)"
2345 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2349 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2350 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2351 [ "$EXCEPT_SLOW" ] && \
2352 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2353 for E in $EXCEPT $ALWAYS_EXCEPT; do
2354 eval EXCEPT_${E}=true
2356 for E in $EXCEPT_SLOW; do
2357 eval EXCEPT_SLOW_${E}=true
2359 for G in $GRANT_CHECK_LIST; do
2360 eval GCHECK_ONLY_${G}=true
2365 if [[ $1 = [a-z]* ]]; then
2372 # print a newline if the last test was skipped
2373 export LAST_SKIPPED=
2377 export base=`basetest $1`
2378 if [ ! -z "$ONLY" ]; then
2380 if [ ${!testname}x != x ]; then
2381 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2386 if [ ${!testname}x != x ]; then
2387 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2396 if [ ${!testname}x != x ]; then
2398 TESTNAME=test_$1 skip "skipping excluded test $1"
2401 testname=EXCEPT_$base
2402 if [ ${!testname}x != x ]; then
2404 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2407 testname=EXCEPT_SLOW_$1
2408 if [ ${!testname}x != x ]; then
2410 TESTNAME=test_$1 skip "skipping SLOW test $1"
2413 testname=EXCEPT_SLOW_$base
2414 if [ ${!testname}x != x ]; then
2416 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2426 EQUALS="======================================================================"
2430 local suffixlen=$((${#EQUALS} - ${#msg}))
2431 [ $suffixlen -lt 5 ] && suffixlen=5
2432 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2437 module_loaded lnet || load_modules
2449 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2454 strace -o $TMP/$1.strace -ttt $*
2456 log "FINISHED: $*: rc $RC"
2461 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2466 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2467 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2468 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2472 echo -n "Resetting fail_loc on all nodes..."
2473 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2481 export tdir=d0.${TESTSUITE}/d${base}
2483 local SAVE_UMASK=`umask`
2486 local BEFORE=`date +%s`
2488 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2490 export TESTNAME=test_$testnum
2492 test_${testnum} || error "test_$testnum failed with $?"
2496 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2497 check_catastrophe || error "LBUG/LASSERT detected"
2498 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2499 pass "($((`date +%s` - $BEFORE))s)"
2507 (cd `dirname $1`; echo $PWD/`basename $1`)
2511 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2512 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2517 export base=`basetest $1`
2518 [ "$CHECK_GRANT" == "no" ] && return 0
2520 testname=GCHECK_ONLY_${base}
2521 [ ${!testname}x == x ] && return 0
2523 echo -n "checking grant......"
2525 # write some data to sync client lost_grant
2526 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2527 for i in `seq $OSTCOUNT`; do
2528 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2529 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2530 count=1 > /dev/null 2>&1
2532 # sync all the data and make sure no pending data on server
2535 #get client grant and server grant
2537 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2538 client_grant=$((client_grant + $d))
2541 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2542 server_grant=$((server_grant + $d))
2545 # cleanup the check_grant file
2546 for i in `seq $OSTCOUNT`; do
2547 rm $DIR1/${tfile}_check_grant_$i
2550 #check whether client grant == server grant
2551 if [ $client_grant != $server_grant ]; then
2552 echo "failed: client:${client_grant} server: ${server_grant}"
2559 ########################
2565 ost=`echo $1 | awk -F_ '{print $3}'`
2566 if [ -z $ost ]; then
2567 ost=`echo $1 | sed 's/-osc.*//'`
2574 [ "$node" != "$(hostname)" ]
2580 for node in $(mdts_nodes); do
2581 remote_node $node && return 0
2588 [ "$CLIENTONLY" ] && return 0 || true
2589 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2595 for node in $(osts_nodes) ; do
2596 remote_node $node && return 0
2603 [ "$CLIENTONLY" ] && return 0 || true
2604 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2610 MGS=$(facet_host mgs)
2611 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2617 for num in `seq $MDSCOUNT`; do
2618 MDSNODES="$MDSNODES $(facet_host mds$num)"
2620 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2626 remote_ost && remote_mds
2630 local OSTNODES=$(facet_host ost1)
2633 for num in `seq $OSTCOUNT`; do
2634 local myOST=$(facet_host ost$num)
2635 OSTNODES="$OSTNODES $myOST"
2637 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2643 # FIXME. We need a list of clients
2644 local myNODES=$HOSTNAME
2647 # CLIENTS (if specified) contains the local client
2648 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2650 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2651 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2654 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2659 remote_nodes_list () {
2660 local rnodes=$(nodes_list)
2661 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2665 init_clients_lists () {
2666 # Sanity check: exclude the local client from RCLIENTS
2667 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2669 # Sanity check: exclude the dup entries
2670 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2672 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2674 # Sanity check: exclude the dup entries from CLIENTS
2675 # for those configs which has SINGLCLIENT set to local client
2676 clients=$(for i in $clients; do echo $i; done | sort -u)
2678 CLIENTS=`comma_list $clients`
2679 local -a remoteclients=($rclients)
2680 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2681 varname=CLIENT$((i + 2))
2682 eval $varname=${remoteclients[i]}
2685 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2688 get_random_entry () {
2691 rnodes=${rnodes//,/ }
2693 local -a nodes=($rnodes)
2694 local num=${#nodes[@]}
2695 local i=$((RANDOM * num * 2 / 65536))
2701 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2706 lctl get_param version | grep -q patchless
2710 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2715 echo $nodes | wc -w || true
2719 local nodes=$(osts_nodes)
2720 local osscount=$(get_node_count "$nodes")
2721 [ ! "$OSTCOUNT" = "$osscount" ]
2725 local nodes=$(mdts_nodes)
2726 local mdtcount=$(get_node_count "$nodes")
2727 [ ! "$MDSCOUNT" = "$mdtcount" ]
2730 generate_machine_file() {
2731 local nodes=${1//,/ }
2732 local machinefile=$2
2733 rm -f $machinefile || error "can't rm $machinefile"
2734 for node in $nodes; do
2735 echo $node >>$machinefile
2740 local file=$1/stripe
2742 $LFS getstripe -v $file || error
2746 check_runas_id_ret() {
2748 local myRUNAS_UID=$1
2749 local myRUNAS_GID=$2
2752 if [ -z "$myRUNAS" ]; then
2753 error_exit "myRUNAS command must be specified for check_runas_id"
2756 $myRUNAS krb5_login.sh || \
2757 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2759 mkdir $DIR/d0_runas_test
2761 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2762 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2763 rm -rf $DIR/d0_runas_test
2768 local myRUNAS_UID=$1
2769 local myRUNAS_GID=$2
2772 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2773 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2774 Please set RUNAS_ID to some UID which exists on MDS and client or
2775 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2778 # obtain the UID/GID for MPI_USER
2782 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2783 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2785 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2786 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2789 # obtain and cache Kerberos ticket-granting ticket
2790 refresh_krb5_tgt() {
2791 local myRUNAS_UID=$1
2792 local myRUNAS_GID=$2
2795 if [ -z "$myRUNAS" ]; then
2796 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2799 CLIENTS=${CLIENTS:-$HOSTNAME}
2800 do_nodes $CLIENTS "set -x
2801 if ! $myRUNAS krb5_login.sh; then
2802 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2807 # Run multiop in the background, but wait for it to print
2808 # "PAUSING" to its stdout before returning from this function.
2809 multiop_bg_pause() {
2810 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2814 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2817 echo "$MULTIOP_PROG $FILE v$ARGS"
2818 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2820 echo "TMPPIPE=${TMPPIPE}"
2821 read -t 60 multiop_output < $TMPPIPE
2822 if [ $? -ne 0 ]; then
2827 if [ "$multiop_output" != "PAUSING" ]; then
2828 echo "Incorrect multiop output: $multiop_output"
2843 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2849 inodes_available () {
2850 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2854 # reset llite stat counters
2855 clear_llite_stats(){
2856 lctl set_param -n llite.*.stats 0
2859 # sum llite stat items
2860 calc_llite_stats() {
2861 local res=$(lctl get_param -n llite.*.stats |
2862 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2866 # reset osc stat counters
2868 lctl set_param -n osc.*.osc_stats 0
2871 # sum osc stat items
2873 local res=$(lctl get_param -n osc.*.osc_stats |
2874 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2879 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2882 calc_osc_kbytes () {
2883 df $MOUNT > /dev/null
2884 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2887 # save_lustre_params(node, parameter_mask)
2888 # generate a stream of formatted strings (<node> <param name>=<param value>)
2889 save_lustre_params() {
2891 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2894 # restore lustre parameters from input stream, produces by save_lustre_params
2895 restore_lustre_params() {
2899 while IFS=" =" read node name val; do
2900 do_node ${node//:/} "lctl set_param -n $name $val"
2904 check_catastrophe() {
2905 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2906 local C=$CATASTROPHE
2907 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2909 if [ $rnodes ]; then
2910 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2911 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2927 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2929 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2930 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2931 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2935 # CMD: determine mds index where directory inode presents
2938 local file=$dir/f0.get_mds_dir_tmpfile
2942 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2943 local -a oldused=($iused)
2947 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2948 local -a newused=($iused)
2951 for ((i=0; i<${#newused[@]}; i++)); do
2952 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2958 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2961 mdsrate_cleanup () {
2963 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2968 delayed_recovery_enabled () {
2969 local var=${SINGLEMDS}_svc
2970 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2973 ########################
2975 convert_facet2label() {
2978 if [ x$facet = xost ]; then
2982 local varsvc=${facet}_svc
2984 if [ -n ${!varsvc} ]; then
2987 error "No lablel for $facet!"
2991 get_clientosc_proc_path() {
2997 get_lustre_version () {
2998 local node=${1:-"mds"}
2999 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3002 get_mds_version_major () {
3003 local version=$(get_lustre_version mds)
3004 echo $version | awk -F. '{print $1}'
3007 get_mds_version_minor () {
3008 local version=$(get_lustre_version mds)
3009 echo $version | awk -F. '{print $2}'
3012 get_mdtosc_proc_path() {
3014 local major=$(get_mds_version_major)
3015 local minor=$(get_mds_version_minor)
3016 if [ $major -le 1 -a $minor -le 8 ] ; then
3019 echo "${ost}-osc-MDT0000"
3023 get_osc_import_name() {
3026 local label=$(convert_facet2label $ost)
3028 if [ "$facet" == "mds" ]; then
3029 get_mdtosc_proc_path $label
3033 get_clientosc_proc_path $label
3037 wait_import_state () {
3043 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3044 while [ "${CONN_STATE}" != "${expected}" ]; do
3045 if [ "${expected}" == "DISCONN" ]; then
3046 # for disconn we can check after proc entry is removed
3047 [ "x${CONN_STATE}" == "x" ] && return 0
3048 # with AT we can have connect request timeout ~ reconnect timeout
3049 # and test can't see real disconnect
3050 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3052 # disconnect rpc should be wait not more obd_timeout
3053 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3054 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3056 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3060 log "$CONN_PROC now in ${CONN_STATE} state"
3064 wait_osc_import_state() {
3068 local ost=$(get_osc_import_name $facet $ost_facet)
3073 CONN_PROC="osc.${ost}.ost_server_uuid"
3074 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3075 while [ "${CONN_STATE}" != "${expected}" ]; do
3076 if [ "${expected}" == "DISCONN" ]; then
3077 # for disconn we can check after proc entry is removed
3078 [ "x${CONN_STATE}" == "x" ] && return 0
3079 # with AT we can have connect request timeout ~ reconnect timeout
3080 # and test can't see real disconnect
3081 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3083 # disconnect rpc should be wait not more obd_timeout
3084 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3085 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3087 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3091 log "${ost_facet} now in ${CONN_STATE} state"
3095 get_clientmdc_proc_path() {
3103 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3106 wait_clients_import_state () {
3112 local label=$(convert_facet2label $facet)
3115 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3116 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3117 *) error "unknown facet!" ;;
3121 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3122 error "import is not in ${expected} state"
3131 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3132 $LCTL get_param obdfilter.*.kbytesavail))
3133 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3134 $LCTL get_param -n obdfilter.*.tot_granted))
3135 for ((i=0; i<${#AVAILA[@]}; i++)); do
3136 local -a AVAIL1=(${AVAILA[$i]//=/ })
3137 GRANT=$((${GRANTA[$i]}/1024))
3138 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3139 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3145 destroy_pool_int() {
3147 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3148 awk '$1 !~ /^Pool:/ {print $1}')
3149 for ost in $OSTS; do
3150 do_facet mgs lctl pool_remove $1 $ost
3152 do_facet mgs lctl pool_destroy $1
3158 do_facet $SINGLEMDS lctl pool_list $FSNAME.$1
3160 [[ $RC -ne 0 ]] && return $RC
3162 destroy_pool_int $FSNAME.$1
3164 [[ $RC -ne 0 ]] && return $RC
3166 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
3167 2>/dev/null || echo foo" "foo" && return 0
3173 local ts=$(date +%s)
3175 # bug 20237, comment 11
3176 # It would also be useful to provide the option
3177 # of writing the file to an NFS directory so it doesn't need to be copied.
3180 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3182 # dump lustre logs, dmesg
3183 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3184 lctl dk \\\$log >/dev/null;
3185 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3188 # FIXME: does it make sense to collect the logs for $ts only, but all
3190 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3191 local logs=$TMP/'*'${TESTSUITE}'*'
3193 logs=$logs' '$tmp/'*'$ts'*'
3195 for node in ${list//,/ }; do
3196 rsync -az $node:"$logs" $TMP
3199 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3200 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3206 local list=${1:-$(comma_list $(nodes_list))}
3208 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true