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() {
705 local OPTIONS=${3:-$MOUNTOPT}
707 # Only supply -o to mount if we have options
708 if [ "$OPTIONS" ]; then
709 OPTIONS="-o $OPTIONS"
711 local device=$MGSNID:/$FSNAME
712 if [ -z "$mnt" -o -z "$FSNAME" ]; then
713 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
717 echo "Starting client $clients: $OPTIONS $device $mnt"
720 running=\\\$(mount | grep -c $mnt' ');
722 if [ \\\$running -eq 0 ] ; then
724 mount -t lustre $OPTIONS $device $mnt;
727 exit \\\$rc" || return ${PIPESTATUS[0]}
729 echo "Started clients $clients: "
730 do_nodes $clients "mount | grep -w $mnt"
732 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
733 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
734 lctl set_param debug_mb=${DEBUG_SIZE};"
739 zconf_umount_clients() {
746 echo "Stopping clients: $clients $mnt (opts:$force)"
747 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
748 if [ \\\$running -ne 0 ] ; then
749 echo Stopping client \\\$(hostname) $mnt opts:$force;
750 lsof -t $mnt || need_kill=no;
751 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
752 pids=\\\$(lsof -t $mnt | sort -u);
753 if [ -n \\\"\\\$pids\\\" ]; then
757 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
758 if [ \\\$busy -ne 0 ] ; then
759 echo "$mnt is still busy, wait one second" && sleep 1;
765 shudown_node_hard () {
769 for i in $(seq $attempts) ; do
772 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
773 echo "waiting for $host to fail attempts=$attempts"
774 [ $i -lt $attempts ] || \
775 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
781 local mnt=${2:-$MOUNT}
784 if [ "$FAILURE_MODE" = HARD ]; then
785 shudown_node_hard $client
787 zconf_umount_clients $client $mnt -f
793 if [ "$FAILURE_MODE" = HARD ]; then
794 shudown_node_hard $(facet_active_host $facet)
795 elif [ "$FAILURE_MODE" = SOFT ]; then
802 if [ "$FAILURE_MODE" = HARD ]; then
803 $POWER_UP `facet_active_host $facet`
811 if [ "$FAILURE_MODE" = HARD ]; then
817 # recovery-scale functions
818 check_progs_installed () {
823 do_nodes $clients "PATH=:$PATH; status=true;
824 for prog in $progs; do
825 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
826 echo \\\$prog missing on \\\$(hostname);
834 echo __$(echo $1 | tr '-' 'X')
837 start_client_load() {
840 local var=$(client_var_name $client)_load
841 eval export ${var}=$load
843 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
844 BREAK_ON_ERROR=$BREAK_ON_ERROR \
845 END_RUN_FILE=$END_RUN_FILE \
846 LOAD_PID_FILE=$LOAD_PID_FILE \
847 TESTSUITELOG=$TESTSUITELOG \
849 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
850 log "Started client load: ${load} on $client"
855 start_client_loads () {
856 local -a clients=(${1//,/ })
857 local numloads=${#CLIENT_LOADS[@]}
860 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
861 testnum=$((nodenum % numloads))
862 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
866 # only for remote client
867 check_client_load () {
869 local var=$(client_var_name $client)_load
870 local TESTLOAD=run_${!var}.sh
872 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
874 # bug 18914: try to connect several times not only when
875 # check ps, but while check_catastrophe also
878 while [ $RC = 254 -a $tries -gt 0 ]; do
882 if ! check_catastrophe $client; then
884 if [ $RC -eq 254 ]; then
885 # FIXME: not sure how long we shuold sleep here
889 echo "check catastrophe failed: RC=$RC "
893 # We can continue try to connect if RC=254
894 # Just print the warning about this
895 if [ $RC = 254 ]; then
896 echo "got a return status of $RC from do_node while checking catastrophe on $client"
899 # see if the load is still on the client
902 while [ $RC = 254 -a $tries -gt 0 ]; do
906 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
911 if [ $RC = 254 ]; then
912 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
913 # see if we can diagnose a bit why this is
918 check_client_loads () {
919 local clients=${1//,/ }
923 for client in $clients; do
924 check_client_load $client
926 if [ "$rc" != 0 ]; then
927 log "Client load failed on node $client, rc=$rc"
933 restart_client_loads () {
934 local clients=${1//,/ }
935 local expectedfail=${2:-""}
939 for client in $clients; do
940 check_client_load $client
942 if [ "$rc" != 0 -a "$expectedfail" ]; then
943 local var=$(client_var_name $client)_load
944 start_client_load $client ${!var}
945 echo "Restarted client load ${!var}: on $client. Checking ..."
946 check_client_load $client
948 if [ "$rc" != 0 ]; then
949 log "Client load failed to restart on node $client, rc=$rc"
950 # failure one client load means test fail
951 # we do not need to check other
959 # End recovery-scale functions
961 # verify that lustre actually cleaned up properly
963 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
964 error "LBUG/LASSERT detected"
965 BUSY=`dmesg | grep -i destruct || true`
968 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
972 check_mem_leak || exit 204
974 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
975 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
977 if module_loaded lnet || module_loaded libcfs; then
978 echo "$0: modules still loaded..." 1>&2
995 RESULT=$(do_node $node "$TEST")
996 if [ "$RESULT" == "$FINAL" ]; then
997 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1000 [ $WAIT -ge $MAX ] && break
1001 echo "Waiting $((MAX - WAIT)) secs for update"
1002 WAIT=$((WAIT + sleep))
1005 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1009 wait_update_facet () {
1011 wait_update $(facet_active_host $facet) "$@"
1014 wait_delete_completed () {
1015 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1016 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1020 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1022 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1023 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1024 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1025 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1029 echo "Delete is not completed in $MAX_WAIT sec"
1035 check_network "$host" 900
1036 while ! do_node $host hostname > /dev/null; do sleep 5; done
1041 local host=`facet_active_host $facet`
1045 wait_recovery_complete () {
1048 # Use default policy if $2 is not passed by caller.
1049 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1050 # as we are in process of changing obd_timeout in different ways
1051 # let's set MAX longer than that
1052 local MAX=${2:-$(( TIMEOUT * 4 ))}
1054 local var_svc=${facet}_svc
1055 local procfile="*.${!var_svc}.recovery_status"
1059 while [ $WAIT -lt $MAX ]; do
1060 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1061 [[ $STATUS = "status: COMPLETE" ]] && return 0
1064 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1066 echo "$facet recovery not done in $MAX sec. $STATUS"
1070 wait_mds_ost_sync () {
1071 # just because recovery is done doesn't mean we've finished
1072 # orphan cleanup. Wait for llogs to get synchronized.
1073 echo "Waiting for orphan cleanup..."
1074 # MAX value includes time needed for MDS-OST reconnection
1075 local MAX=$(( TIMEOUT * 2 ))
1077 while [ $WAIT -lt $MAX ]; do
1078 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1079 "$LCTL get_param -n obdfilter.*.mds_sync"))
1081 for ((i=0; i<${#sync[@]}; i++)); do
1082 [ ${sync[$i]} -eq 0 ] && continue
1083 # there is a not finished MDS-OST synchronization
1087 sleep 2 # increase waiting time and cover statfs cache
1088 [ ${con} -eq 1 ] && return 0
1089 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1092 echo "$facet recovery not done in $MAX sec. $STATUS"
1096 wait_destroy_complete () {
1097 echo "Waiting for destroy to be done..."
1098 # MAX value shouldn't be big as this mean server responsiveness
1099 # never increase this just to make test pass but investigate
1100 # why it takes so long time
1103 while [ $WAIT -lt $MAX ]; do
1104 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1106 for ((i=0; i<${#RPCs[@]}; i++)); do
1107 [ ${RPCs[$i]} -eq 0 ] && continue
1108 # there are still some destroy RPCs in flight
1113 [ ${con} -eq 1 ] && return 0 # done waiting
1114 echo "Waiting $WAIT secs for destroys to be done."
1117 echo "Destroys weren't done in $MAX sec."
1127 # conf-sanity 31 takes a long time cleanup
1128 while [ $WAIT -lt 300 ]; do
1129 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1130 [ -z "${running}" ] && return 0
1131 echo "waited $WAIT for${running}"
1132 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1134 WAIT=$((WAIT + INTERVAL))
1136 echo "service didn't stop after $WAIT seconds. Still running:"
1141 wait_remote_prog () {
1147 [ "$PDSH" = "no_dsh" ] && return 0
1149 while [ $WAIT -lt $2 ]; do
1150 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1151 [ -z "${running}" ] && return 0 || true
1152 echo "waited $WAIT for: "
1154 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1156 WAIT=$((WAIT + INTERVAL))
1158 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1159 [ -z "$pids" ] && return 0
1160 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1161 # FIXME: not portable
1162 for pid in $pids; do
1163 cat /proc/${pid}/status || true
1164 cat /proc/${pid}/wchan || true
1166 kill -9 $pid || true
1175 # not every config has many clients
1177 if [ ! -z "$CLIENTS" ]; then
1178 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1180 stat -f $MOUNT > /dev/null
1186 # usually checked on particular client or locally
1188 if [ ! -z "$client" ]; then
1189 $PDSH $client "stat -f $MOUNT" > /dev/null
1191 stat -f $MOUNT > /dev/null
1199 client_reconnect() {
1200 uname -n >> $MOUNT/recon
1201 if [ -z "$CLIENTS" ]; then
1202 df $MOUNT; uname -n >> $MOUNT/recon
1204 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1206 echo Connected clients:
1208 ls -l $MOUNT/recon > /dev/null
1215 echo "Failing $facet on node `facet_active_host $facet`"
1216 shutdown_facet $facet
1217 [ -n "$sleep_time" ] && sleep $sleep_time
1219 change_active $facet
1220 local TO=`facet_active_host $facet`
1221 echo "Failover $facet to $TO"
1223 mount_facet $facet || error "Restart of $facet failed"
1232 do_facet $facet sync
1234 local svc=${facet}_svc
1235 do_facet $facet $LCTL --device %${!svc} notransno
1236 do_facet $facet $LCTL --device %${!svc} readonly
1237 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1238 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1241 replay_barrier_nodf() {
1242 local facet=$1 echo running=${running}
1243 do_facet $facet sync
1244 local svc=${facet}_svc
1245 echo Replay barrier on ${!svc}
1246 do_facet $facet $LCTL --device %${!svc} notransno
1247 do_facet $facet $LCTL --device %${!svc} readonly
1248 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1249 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1252 replay_barrier_nosync() {
1253 local facet=$1 echo running=${running}
1254 local svc=${facet}_svc
1255 echo Replay barrier on ${!svc}
1256 do_facet $facet $LCTL --device %${!svc} notransno
1257 do_facet $facet $LCTL --device %${!svc} readonly
1258 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1259 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1262 mds_evict_client() {
1263 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1264 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1267 ost_evict_client() {
1268 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1269 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1273 facet_failover $* || error "failover: $?"
1274 clients_up || error "post-failover df: $?"
1279 facet_failover $facet
1285 change_active $facet
1286 mount_facet $facet -o abort_recovery
1287 clients_up || echo "first df failed: $?"
1288 clients_up || error "post-failover df: $?"
1292 echo There is no lmc. This is mountconf, baby.
1297 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1298 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1304 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1310 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1311 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1312 if [ -z "$ID" ]; then
1313 echo "Could not get a ptl id for $1..."
1322 h2name_or_ip "$1" "tcp"
1327 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1328 if type __h2elan >/dev/null 2>&1; then
1331 ID=`echo $1 | sed 's/[^0-9]*//g'`
1339 h2name_or_ip "$1" "openib"
1341 declare -fx h2openib
1344 h2name_or_ip "$1" "o2ib"
1351 [ "$facet" == client ] && echo -n $HOSTNAME && return
1352 varname=${facet}_HOST
1353 if [ -z "${!varname}" ]; then
1354 if [ "${facet:0:3}" == "ost" ]; then
1355 eval ${facet}_HOST=${ost_HOST}
1363 local activevar=${facet}active
1365 if [ -f $TMP/${facet}active ] ; then
1366 source $TMP/${facet}active
1369 active=${!activevar}
1370 if [ -z "$active" ] ; then
1377 facet_active_host() {
1379 local active=`facet_active $facet`
1380 if [ "$facet" == client ]; then
1383 echo `facet_host $active`
1389 local failover=${facet}failover
1390 host=`facet_host $failover`
1391 [ -z "$host" ] && return
1392 local curactive=`facet_active $facet`
1393 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1394 eval export ${facet}active=$facet
1396 eval export ${facet}active=$failover
1398 # save the active host for this facet
1399 local activevar=${facet}active
1400 echo "$activevar=${!activevar}" > $TMP/$activevar
1405 # do not stripe off hostname if verbose, bug 19215
1406 if [ x$1 = x--verbose ]; then
1414 if [ "$HOST" = "$HOSTNAME" ]; then
1416 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1417 echo "cannot run remote command on $HOST with $myPDSH"
1421 echo "CMD: $HOST $@" >&2
1422 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1425 if [ "$myPDSH" = "rsh" ]; then
1426 # we need this because rsh does not return exit code of an executed command
1427 local command_status="$TMP/cs"
1428 rsh $HOST ":> $command_status"
1429 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1430 cd $RPWD; sh -c \"$@\") ||
1431 echo command failed >$command_status"
1432 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1437 # print HOSTNAME for myPDSH="no_dsh"
1438 if [[ $myPDSH = no_dsh ]]; then
1439 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1441 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1444 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1446 return ${PIPESTATUS[0]}
1449 single_local_node () {
1450 [ "$1" = "$HOSTNAME" ]
1455 # do not stripe off hostname if verbose, bug 19215
1456 if [ x$1 = x--verbose ]; then
1464 if $(single_local_node $rnodes); then
1466 do_node --verbose $rnodes $@
1473 # This is part from do_node
1476 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1477 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1480 echo "CMD: $rnodes $@" >&2
1481 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1485 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1487 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1489 return ${PIPESTATUS[0]}
1495 local HOST=`facet_active_host $facet`
1496 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1503 # make sure its not already running
1505 rm -f $TMP/${facet}active
1506 do_facet ${facet} $MKFS $*
1512 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1513 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1520 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1521 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1529 # make sure we are using the primary server, so test-framework will
1530 # be able to clean up properly.
1531 activemds=`facet_active mds1`
1532 if [ $activemds != "mds1" ]; then
1536 local clients=$CLIENTS
1537 [ -z $clients ] && clients=$(hostname)
1539 zconf_umount_clients $clients $MOUNT "$*" || true
1540 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1542 [ "$CLIENTONLY" ] && return
1543 # The add fn does rm ${facet}active file, this would be enough
1544 # if we use do_facet <facet> only after the facet added, but
1545 # currently we use do_facet mds in local.sh
1546 for num in `seq $MDSCOUNT`; do
1548 rm -f ${TMP}/mds${num}active
1551 for num in `seq $OSTCOUNT`; do
1553 rm -f $TMP/ost${num}active
1560 nfs_client_mode && return
1570 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1574 if [ "$IAMDIR" == "yes" ]; then
1575 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1576 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1579 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1581 if [ ! -z $SEC ]; then
1582 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1583 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1584 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1588 # We need ldiskfs here, may as well load them all
1590 [ "$CLIENTONLY" ] && return
1591 echo Formatting mgs, mds, osts
1592 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1593 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1596 for num in `seq $MDSCOUNT`; do
1597 echo "Format mds$num: $(mdsdevname $num)"
1599 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1601 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1605 for num in `seq $OSTCOUNT`; do
1606 echo "Format ost$num: $(ostdevname $num)"
1608 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1610 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1616 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1620 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1624 # 0: success, the old identity set already.
1625 # 1: success, the old identity does not set.
1630 local j=`expr $num - 1`
1631 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1633 if [ -z "$MDT" ]; then
1637 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1640 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1642 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1645 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1647 if [ $old = "NONE" ]; then
1656 zconf_umount `hostname` $1 || error "umount failed"
1657 zconf_mount `hostname` $1 || error "mount failed"
1660 writeconf_facet () {
1664 do_facet $facet "$TUNEFS --writeconf $dev"
1668 for num in `seq $MDSCOUNT`; do
1669 DEVNAME=$(mdsdevname $num)
1670 writeconf_facet mds$num $DEVNAME
1673 for num in `seq $OSTCOUNT`; do
1674 DEVNAME=$(ostdevname $num)
1675 writeconf_facet ost$num $DEVNAME
1680 nfs_client_mode && return
1682 sanity_mount_check ||
1683 error "environments are insane!"
1687 if [ -z "$CLIENTONLY" ]; then
1688 echo Setup mgs, mdt, osts
1689 echo $WRITECONF | grep -q "writeconf" && \
1691 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1692 start mgs $MGSDEV $mgs_MOUNT_OPTS
1695 for num in `seq $MDSCOUNT`; do
1696 DEVNAME=$(mdsdevname $num)
1697 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1699 # We started mds, now we should set failover variables properly.
1700 # Set mds${num}failover_HOST if it is not set (the default failnode).
1701 local varname=mds${num}failover_HOST
1702 if [ -z "${!varname}" ]; then
1703 eval mds${num}failover_HOST=$(facet_host mds$num)
1706 if [ $IDENTITY_UPCALL != "default" ]; then
1707 switch_identity $num $IDENTITY_UPCALL
1710 for num in `seq $OSTCOUNT`; do
1711 DEVNAME=$(ostdevname $num)
1712 start ost$num $DEVNAME $OST_MOUNT_OPTS
1714 # We started ost$num, now we should set ost${num}failover variable properly.
1715 # Set ost${num}failover_HOST if it is not set (the default failnode).
1716 varname=ost${num}failover_HOST
1717 if [ -z "${!varname}" ]; then
1718 eval ost${num}failover_HOST=$(facet_host ost${num})
1723 # wait a while to allow sptlrpc configuration be propogated to targets,
1724 # only needed when mounting new target devices.
1727 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1729 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1731 if [ "$MOUNT_2" ]; then
1732 mount_client $MOUNT2
1733 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1738 # by remounting mdt before ost, initial connect from mdt to ost might
1739 # timeout because ost is not ready yet. wait some time to its fully
1740 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1741 # by a context negotiation rpc with $TIMEOUT.
1742 # FIXME better by monitoring import status.
1744 sleep $((TIMEOUT + 5))
1750 mounted_lustre_filesystems() {
1751 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1754 init_facet_vars () {
1755 [ "$CLIENTONLY" ] && return 0
1762 eval export ${facet}_dev=${device}
1763 eval export ${facet}_opt=\"$@\"
1765 local dev=${facet}_dev
1766 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1767 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1769 eval export ${facet}_svc=${label}
1771 local varname=${facet}failover_HOST
1772 if [ -z "${!varname}" ]; then
1773 eval $varname=$(facet_host $facet)
1776 # ${facet}failover_dev is set in cfg file
1777 varname=${facet}failover_dev
1778 if [ -n "${!varname}" ] ; then
1779 eval export ${facet}failover_dev=${!varname}
1781 eval export ${facet}failover_dev=$device
1785 init_facets_vars () {
1788 if ! remote_mds_nodsh; then
1789 for num in `seq $MDSCOUNT`; do
1790 DEVNAME=`mdsdevname $num`
1791 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1795 remote_ost_nodsh && return
1797 for num in `seq $OSTCOUNT`; do
1798 DEVNAME=`ostdevname $num`
1799 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1803 osc_ensure_active () {
1809 while [ $period -lt $timeout ]; do
1810 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1811 if [ $count -eq 0 ]; then
1815 echo "There are $count OST are inactive, wait $period seconds, and try again"
1817 period=$((period+3))
1820 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1824 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1828 init_param_vars () {
1829 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1830 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1831 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1832 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1836 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1838 log "Using TIMEOUT=$TIMEOUT"
1840 osc_ensure_active $SINGLEMDS M $TIMEOUT
1841 osc_ensure_active client c $TIMEOUT
1843 if [ x"$(som_check)" = x"enabled" ]; then
1845 echo "disable quota temporary when SOM enabled"
1847 if [ $QUOTA_AUTO -ne 0 ]; then
1848 if [ "$ENABLE_QUOTA" ]; then
1849 echo "enable quota as required"
1850 setup_quota $MOUNT || return 2
1852 echo "disable quota as required"
1853 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1860 nfs_client_mode () {
1861 if [ "$NFSCLIENT" ]; then
1862 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1863 local clients=$CLIENTS
1864 [ -z $clients ] && clients=$(hostname)
1866 # FIXME: remove hostname when 19215 fixed
1867 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1868 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1869 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1876 nfs_client_mode && return
1880 local mounted=$(mount | grep " $mntpt ")
1881 if [ "$CLIENTONLY" ]; then
1883 # CLIENTONLY should not depend on *_HOST settings
1884 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1885 # in theory someone could create a new,
1886 # client-only config file that assumed lustre was already
1887 # configured and didn't set the MGSNID. If MGSNID is not set,
1888 # then we should use the mgs nid currently being used
1889 # as the default value. bug 18021
1890 [[ x$MGSNID = x ]] &&
1893 if [[ x$mgc != xMGC$MGSNID ]]; then
1894 if [ "$mgs_HOST" ]; then
1895 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1896 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1897 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1903 local myMGS_host=$mgs_HOST
1904 if [ "$NETTYPE" = "ptl" ]; then
1905 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1908 echo Checking config lustre mounted on $mntpt
1909 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1910 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1912 if [ "$mgshost" != "$myMGS_host" ]; then
1913 log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1914 Please use correct config or set mds_HOST correctly!"
1917 sanity_mount_check ||
1918 error "environments are insane!"
1922 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1923 local cltimeout=$(lctl get_param -n timeout)
1924 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1925 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1930 check_and_setup_lustre() {
1931 nfs_client_mode && return
1933 local MOUNTED=$(mounted_lustre_filesystems)
1936 # MOUNT is not mounted
1937 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1938 [ "$REFORMAT" ] && formatall
1940 MOUNTED=$(mounted_lustre_filesystems | head -1)
1941 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1942 export I_MOUNTED=yes
1945 # MOUNT and MOUNT2 are mounted
1946 elif $(echo $MOUNTED | grep -w -q $MOUNT2); then
1948 # MOUNT2 is mounted, MOUNT_2 is not set
1949 if ! [ "$MOUNT_2" ]; then
1950 zconf_umount `hostname` $MOUNT2
1951 export I_UMOUNTED2=yes
1953 # MOUNT2 is mounted, MOUNT_2 is set
1955 check_config $MOUNT2
1964 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1965 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1966 lctl set_param debug_mb=${DEBUG_SIZE};
1969 if [ "$ONLY" == "setup" ]; then
1974 cleanup_and_setup_lustre() {
1975 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1976 lctl set_param debug=0 || true
1978 if [ "$ONLY" == "cleanup" ]; then
1982 check_and_setup_lustre
1985 check_and_cleanup_lustre() {
1986 if [ "`mount | grep $MOUNT`" ]; then
1987 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1988 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1990 if [ "$I_UMOUNTED2" = "yes" ]; then
1991 mount_client $MOUNT2 || error "restore $MOUNT2 failed"
1994 if [ "$I_MOUNTED" = "yes" ]; then
1995 cleanupall -f || error "cleanup failed"
2007 while [ $NETWORK -eq 0 ]; do
2008 if ping -c 1 -w 3 $1 > /dev/null; then
2012 echo "waiting for $1, $((MAX - WAIT)) secs left"
2015 if [ $WAIT -gt $MAX ]; then
2016 echo "Network not available"
2022 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2033 # the sed converts spaces to commas, but leaves the last space
2034 # alone, so the line doesn't end with a comma.
2035 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2038 # list, excluded are the comma separated lists
2039 exclude_items_from_list () {
2045 for item in ${excluded//,/ }; do
2046 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2048 echo $(comma_list $list)
2051 # list, expand are the comma separated lists
2053 local list=${1//,/ }
2054 local expand=${2//,/ }
2057 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2058 echo $(comma_list $expanded)
2061 testslist_filter () {
2062 local script=$LUSTRE/tests/${TESTSUITE}.sh
2064 [ -f $script ] || return 0
2066 local start_at=$START_AT
2067 local stop_at=$STOP_AT
2069 local var=${TESTSUITE//-/_}_START_AT
2070 [ x"${!var}" != x ] && start_at=${!var}
2071 var=${TESTSUITE//-/_}_STOP_AT
2072 [ x"${!var}" != x ] && stop_at=${!var}
2074 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2075 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2076 /^'${start_at}'$/ {flag = 0}
2077 {if (flag == 1) print $0}
2078 /^'${stop_at}'$/ { flag = 1 }'
2082 (cd `dirname $1`; echo $PWD/`basename $1`)
2086 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2087 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2090 local count=${type}COUNT
2091 for ((i=1; i<=${!count}; i++)) do
2092 list="$list ${name}$i"
2094 echo $(comma_list $list)
2097 ##################################
2098 # Adaptive Timeouts funcs
2101 # only check mds, we assume at_max is the same on all nodes
2102 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2103 if [ $at_max -eq 0 ]; then
2113 # suppose that all ost-s has the same at_max set
2114 if [ $facet == "ost" ]; then
2115 do_facet ost1 "lctl get_param -n at_max"
2117 do_facet $facet "lctl get_param -n at_max"
2127 if [ $facet == "ost" ]; then
2128 for i in `seq $OSTCOUNT`; do
2129 do_facet ost$i "lctl set_param at_max=$at_max"
2132 elif [ $facet == "mds" ]; then
2133 for i in `seq $MDSCOUNT`; do
2134 do_facet mds$i "lctl set_param at_max=$at_max"
2137 do_facet $facet "lctl set_param at_max=$at_max"
2142 ##################################
2146 # OBD_FAIL_MDS_ALL_REQUEST_NET
2148 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2149 do_facet client "$1" || RC=$?
2150 do_facet $SINGLEMDS lctl set_param fail_loc=0
2155 # OBD_FAIL_MDS_ALL_REPLY_NET
2157 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2158 do_facet client "$@" || RC=$?
2159 do_facet $SINGLEMDS lctl set_param fail_loc=0
2163 drop_reint_reply() {
2164 # OBD_FAIL_MDS_REINT_NET_REP
2166 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2167 do_facet client "$@" || RC=$?
2168 do_facet $SINGLEMDS lctl set_param fail_loc=0
2173 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2175 do_facet ost1 lctl set_param fail_loc=0x214
2176 do_facet client "$1" || RC=$?
2177 do_facet client "sync"
2178 do_facet ost1 lctl set_param fail_loc=0
2182 drop_ldlm_cancel() {
2183 #define OBD_FAIL_LDLM_CANCEL 0x304
2185 do_facet client lctl set_param fail_loc=0x304
2186 do_facet client "$@" || RC=$?
2187 do_facet client lctl set_param fail_loc=0
2191 drop_bl_callback() {
2192 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2194 do_facet client lctl set_param fail_loc=0x305
2195 do_facet client "$@" || RC=$?
2196 do_facet client lctl set_param fail_loc=0
2201 #define OBD_FAIL_LDLM_REPLY 0x30c
2203 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2204 do_facet client "$@" || RC=$?
2205 do_facet $SINGLEMDS lctl set_param fail_loc=0
2213 echo "clearing fail_loc on $facet"
2214 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2217 set_nodes_failloc () {
2218 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2221 cancel_lru_locks() {
2222 $LCTL mark "cancel_lru_locks $1 start"
2223 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2224 $LCTL set_param -n $d=clear
2226 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2227 $LCTL mark "cancel_lru_locks $1 stop"
2232 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2233 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2234 echo "$DEFAULT_LRU_SIZE"
2239 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2242 lru_resize_disable()
2244 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2249 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2250 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2251 echo there is still data in page cache $FILE ?
2252 lctl get_param -n $FILE
2256 if [[ $MDSDEV1 != $MGSDEV ]]; then
2264 DEBUGSAVE="$(lctl get_param -n debug)"
2268 [ -n "$DEBUGSAVE" ] && \
2269 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2274 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2277 debug_size_restore() {
2278 [ -n "$DEBUG_SIZE_SAVED" ] && \
2279 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2283 start_full_debug_logging() {
2288 local DEBUG_SIZE=150
2290 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2291 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2294 stop_full_debug_logging() {
2299 ##################################
2301 ##################################
2304 local TYPE=${TYPE:-"FAIL"}
2308 # do not dump logs if $1=false
2309 if [ "x$1" = "xfalse" ]; then
2314 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2317 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2318 echo "Dumping lctl log to $ERRLOG"
2319 # We need to dump the logs on all nodes
2320 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2323 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2329 if $FAIL_ON_ERROR; then
2340 # use only if we are ignoring failures for this test, bugno required.
2341 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2342 # e.g. error_ignore 5494 "your message"
2344 local TYPE="IGNORE (bz$1)"
2350 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2355 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2356 [ "$TESTSUITELOG" ] && \
2357 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2360 build_test_filter() {
2361 EXCEPT="$EXCEPT $(testslist_filter)"
2363 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2367 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2368 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2369 [ "$EXCEPT_SLOW" ] && \
2370 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2371 for E in $EXCEPT $ALWAYS_EXCEPT; do
2372 eval EXCEPT_${E}=true
2374 for E in $EXCEPT_SLOW; do
2375 eval EXCEPT_SLOW_${E}=true
2377 for G in $GRANT_CHECK_LIST; do
2378 eval GCHECK_ONLY_${G}=true
2383 if [[ $1 = [a-z]* ]]; then
2390 # print a newline if the last test was skipped
2391 export LAST_SKIPPED=
2395 export base=`basetest $1`
2396 if [ ! -z "$ONLY" ]; then
2398 if [ ${!testname}x != x ]; then
2399 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2404 if [ ${!testname}x != x ]; then
2405 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2414 if [ ${!testname}x != x ]; then
2416 TESTNAME=test_$1 skip "skipping excluded test $1"
2419 testname=EXCEPT_$base
2420 if [ ${!testname}x != x ]; then
2422 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2425 testname=EXCEPT_SLOW_$1
2426 if [ ${!testname}x != x ]; then
2428 TESTNAME=test_$1 skip "skipping SLOW test $1"
2431 testname=EXCEPT_SLOW_$base
2432 if [ ${!testname}x != x ]; then
2434 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2444 EQUALS="======================================================================"
2448 local suffixlen=$((${#EQUALS} - ${#msg}))
2449 [ $suffixlen -lt 5 ] && suffixlen=5
2450 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2455 module_loaded lnet || load_modules
2467 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2472 strace -o $TMP/$1.strace -ttt $*
2474 log "FINISHED: $*: rc $RC"
2479 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2484 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2485 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2486 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2490 echo -n "Resetting fail_loc on all nodes..."
2491 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2499 export tdir=d0.${TESTSUITE}/d${base}
2501 local SAVE_UMASK=`umask`
2504 local BEFORE=`date +%s`
2506 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2508 export TESTNAME=test_$testnum
2510 test_${testnum} || error "test_$testnum failed with $?"
2514 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2515 check_catastrophe || error "LBUG/LASSERT detected"
2516 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2517 pass "($((`date +%s` - $BEFORE))s)"
2525 (cd `dirname $1`; echo $PWD/`basename $1`)
2529 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2530 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2535 export base=`basetest $1`
2536 [ "$CHECK_GRANT" == "no" ] && return 0
2538 testname=GCHECK_ONLY_${base}
2539 [ ${!testname}x == x ] && return 0
2541 echo -n "checking grant......"
2543 # write some data to sync client lost_grant
2544 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2545 for i in `seq $OSTCOUNT`; do
2546 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2547 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2548 count=1 > /dev/null 2>&1
2550 # sync all the data and make sure no pending data on server
2553 #get client grant and server grant
2555 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2556 client_grant=$((client_grant + $d))
2559 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2560 server_grant=$((server_grant + $d))
2563 # cleanup the check_grant file
2564 for i in `seq $OSTCOUNT`; do
2565 rm $DIR1/${tfile}_check_grant_$i
2568 #check whether client grant == server grant
2569 if [ $client_grant != $server_grant ]; then
2570 echo "failed: client:${client_grant} server: ${server_grant}"
2577 ########################
2583 ost=`echo $1 | awk -F_ '{print $3}'`
2584 if [ -z $ost ]; then
2585 ost=`echo $1 | sed 's/-osc.*//'`
2592 [ "$node" != "$(hostname)" ]
2598 for node in $(mdts_nodes); do
2599 remote_node $node && return 0
2606 [ "$CLIENTONLY" ] && return 0 || true
2607 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2613 for node in $(osts_nodes) ; do
2614 remote_node $node && return 0
2621 [ "$CLIENTONLY" ] && return 0 || true
2622 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2628 MGS=$(facet_host mgs)
2629 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2635 for num in `seq $MDSCOUNT`; do
2636 MDSNODES="$MDSNODES $(facet_host mds$num)"
2638 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2644 remote_ost && remote_mds
2648 local OSTNODES=$(facet_host ost1)
2651 for num in `seq $OSTCOUNT`; do
2652 local myOST=$(facet_host ost$num)
2653 OSTNODES="$OSTNODES $myOST"
2655 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2661 # FIXME. We need a list of clients
2662 local myNODES=$HOSTNAME
2665 # CLIENTS (if specified) contains the local client
2666 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2668 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2669 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2672 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2677 remote_nodes_list () {
2678 local rnodes=$(nodes_list)
2679 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2683 init_clients_lists () {
2684 # Sanity check: exclude the local client from RCLIENTS
2685 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2687 # Sanity check: exclude the dup entries
2688 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2690 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2692 # Sanity check: exclude the dup entries from CLIENTS
2693 # for those configs which has SINGLCLIENT set to local client
2694 clients=$(for i in $clients; do echo $i; done | sort -u)
2696 CLIENTS=`comma_list $clients`
2697 local -a remoteclients=($rclients)
2698 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2699 varname=CLIENT$((i + 2))
2700 eval $varname=${remoteclients[i]}
2703 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2706 get_random_entry () {
2709 rnodes=${rnodes//,/ }
2711 local -a nodes=($rnodes)
2712 local num=${#nodes[@]}
2713 local i=$((RANDOM * num * 2 / 65536))
2719 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2724 lctl get_param version | grep -q patchless
2728 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2733 echo $nodes | wc -w || true
2737 local nodes=$(osts_nodes)
2738 local osscount=$(get_node_count "$nodes")
2739 [ ! "$OSTCOUNT" = "$osscount" ]
2743 local nodes=$(mdts_nodes)
2744 local mdtcount=$(get_node_count "$nodes")
2745 [ ! "$MDSCOUNT" = "$mdtcount" ]
2748 generate_machine_file() {
2749 local nodes=${1//,/ }
2750 local machinefile=$2
2751 rm -f $machinefile || error "can't rm $machinefile"
2752 for node in $nodes; do
2753 echo $node >>$machinefile
2758 local file=$1/stripe
2760 $LFS getstripe -v $file || error
2764 check_runas_id_ret() {
2766 local myRUNAS_UID=$1
2767 local myRUNAS_GID=$2
2770 if [ -z "$myRUNAS" ]; then
2771 error_exit "myRUNAS command must be specified for check_runas_id"
2774 $myRUNAS krb5_login.sh || \
2775 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2777 mkdir $DIR/d0_runas_test
2779 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2780 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2781 rm -rf $DIR/d0_runas_test
2786 local myRUNAS_UID=$1
2787 local myRUNAS_GID=$2
2790 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2791 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2792 Please set RUNAS_ID to some UID which exists on MDS and client or
2793 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2796 # obtain the UID/GID for MPI_USER
2800 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2801 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2803 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2804 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2807 # obtain and cache Kerberos ticket-granting ticket
2808 refresh_krb5_tgt() {
2809 local myRUNAS_UID=$1
2810 local myRUNAS_GID=$2
2813 if [ -z "$myRUNAS" ]; then
2814 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2817 CLIENTS=${CLIENTS:-$HOSTNAME}
2818 do_nodes $CLIENTS "set -x
2819 if ! $myRUNAS krb5_login.sh; then
2820 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2825 # Run multiop in the background, but wait for it to print
2826 # "PAUSING" to its stdout before returning from this function.
2827 multiop_bg_pause() {
2828 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2832 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2835 echo "$MULTIOP_PROG $FILE v$ARGS"
2836 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2838 echo "TMPPIPE=${TMPPIPE}"
2839 read -t 60 multiop_output < $TMPPIPE
2840 if [ $? -ne 0 ]; then
2845 if [ "$multiop_output" != "PAUSING" ]; then
2846 echo "Incorrect multiop output: $multiop_output"
2861 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2867 inodes_available () {
2868 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2872 # reset llite stat counters
2873 clear_llite_stats(){
2874 lctl set_param -n llite.*.stats 0
2877 # sum llite stat items
2878 calc_llite_stats() {
2879 local res=$(lctl get_param -n llite.*.stats |
2880 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2884 # reset osc stat counters
2886 lctl set_param -n osc.*.osc_stats 0
2889 # sum osc stat items
2891 local res=$(lctl get_param -n osc.*.osc_stats |
2892 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2897 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2900 calc_osc_kbytes () {
2901 df $MOUNT > /dev/null
2902 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2905 # save_lustre_params(node, parameter_mask)
2906 # generate a stream of formatted strings (<node> <param name>=<param value>)
2907 save_lustre_params() {
2909 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2912 # restore lustre parameters from input stream, produces by save_lustre_params
2913 restore_lustre_params() {
2917 while IFS=" =" read node name val; do
2918 do_node ${node//:/} "lctl set_param -n $name $val"
2922 check_catastrophe() {
2923 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2924 local C=$CATASTROPHE
2925 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2927 if [ $rnodes ]; then
2928 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2929 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2945 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2947 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2948 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2949 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2953 # CMD: determine mds index where directory inode presents
2956 local file=$dir/f0.get_mds_dir_tmpfile
2961 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2962 local -a oldused=($iused)
2964 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
2966 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2967 local -a newused=($iused)
2970 for ((i=0; i<${#newused[@]}; i++)); do
2971 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2977 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2980 mdsrate_cleanup () {
2982 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2987 delayed_recovery_enabled () {
2988 local var=${SINGLEMDS}_svc
2989 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2992 ########################
2994 convert_facet2label() {
2997 if [ x$facet = xost ]; then
3001 local varsvc=${facet}_svc
3003 if [ -n ${!varsvc} ]; then
3006 error "No lablel for $facet!"
3010 get_clientosc_proc_path() {
3016 get_lustre_version () {
3017 local node=${1:-"mds"}
3018 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3021 get_mds_version_major () {
3022 local version=$(get_lustre_version mds)
3023 echo $version | awk -F. '{print $1}'
3026 get_mds_version_minor () {
3027 local version=$(get_lustre_version mds)
3028 echo $version | awk -F. '{print $2}'
3031 get_mdtosc_proc_path() {
3033 local major=$(get_mds_version_major)
3034 local minor=$(get_mds_version_minor)
3035 if [ $major -le 1 -a $minor -le 8 ] ; then
3038 echo "${ost}-osc-MDT0000"
3042 get_osc_import_name() {
3045 local label=$(convert_facet2label $ost)
3047 if [ "$facet" == "mds" ]; then
3048 get_mdtosc_proc_path $label
3052 get_clientosc_proc_path $label
3056 wait_import_state () {
3062 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3063 while [ "${CONN_STATE}" != "${expected}" ]; do
3064 if [ "${expected}" == "DISCONN" ]; then
3065 # for disconn we can check after proc entry is removed
3066 [ "x${CONN_STATE}" == "x" ] && return 0
3067 # with AT we can have connect request timeout ~ reconnect timeout
3068 # and test can't see real disconnect
3069 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3071 # disconnect rpc should be wait not more obd_timeout
3072 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3073 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3075 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3079 log "$CONN_PROC now in ${CONN_STATE} state"
3083 wait_osc_import_state() {
3087 local ost=$(get_osc_import_name $facet $ost_facet)
3092 CONN_PROC="osc.${ost}.ost_server_uuid"
3093 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3094 while [ "${CONN_STATE}" != "${expected}" ]; do
3095 if [ "${expected}" == "DISCONN" ]; then
3096 # for disconn we can check after proc entry is removed
3097 [ "x${CONN_STATE}" == "x" ] && return 0
3098 # with AT we can have connect request timeout ~ reconnect timeout
3099 # and test can't see real disconnect
3100 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3102 # disconnect rpc should be wait not more obd_timeout
3103 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3104 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3106 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3110 log "${ost_facet} now in ${CONN_STATE} state"
3114 get_clientmdc_proc_path() {
3122 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3125 wait_clients_import_state () {
3131 local label=$(convert_facet2label $facet)
3134 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3135 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3136 *) error "unknown facet!" ;;
3140 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3141 error "import is not in ${expected} state"
3150 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3151 $LCTL get_param obdfilter.*.kbytesavail))
3152 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3153 $LCTL get_param -n obdfilter.*.tot_granted))
3154 for ((i=0; i<${#AVAILA[@]}; i++)); do
3155 local -a AVAIL1=(${AVAILA[$i]//=/ })
3156 GRANT=$((${GRANTA[$i]}/1024))
3157 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3158 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3163 destroy_pool_int() {
3165 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3166 awk '$1 !~ /^Pool:/ {print $1}')
3167 for ost in $OSTS; do
3168 do_facet mgs lctl pool_remove $1 $ost
3170 do_facet mgs lctl pool_destroy $1
3176 do_facet $SINGLEMDS lctl pool_list $FSNAME.$1
3178 [[ $RC -ne 0 ]] && return $RC
3180 destroy_pool_int $FSNAME.$1
3182 [[ $RC -ne 0 ]] && return $RC
3184 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$1 \
3185 2>/dev/null || echo foo" "foo" && return 0
3191 local ts=$(date +%s)
3193 # bug 20237, comment 11
3194 # It would also be useful to provide the option
3195 # of writing the file to an NFS directory so it doesn't need to be copied.
3198 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3200 # dump lustre logs, dmesg
3201 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3202 lctl dk \\\$log >/dev/null;
3203 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3206 # FIXME: does it make sense to collect the logs for $ts only, but all
3208 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3209 local logs=$TMP/'*'${TESTSUITE}'*'
3211 logs=$logs' '$tmp/'*'$ts'*'
3213 for node in ${list//,/ }; do
3214 rsync -az $node:"$logs" $TMP
3217 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3218 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3224 local list=${1:-$(comma_list $(nodes_list))}
3226 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3238 for i in $(seq 0 $num_mntpts); do
3239 cmd="ls -laf ${mntpt_root}$i/$dir"
3245 for pid in $pids; do