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
19 #export PDSH="pdsh -S -Rssh -w"
21 # function used by scripts run on remote nodes
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/functions.sh
27 [[ $DIR/ = $MOUNT/* ]] || \
28 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
29 [[ $DIR1/ = $MOUNT1/* ]] || \
30 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
31 [[ $DIR2/ = $MOUNT2/* ]] || \
32 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
34 [ -n "$failed" ] && exit 99 || true
38 echo "usage: $0 [-r] [-f cfgfile]"
45 [ "$TESTSUITE" == "lfscktest" ] && return 0
46 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
47 local form="%-13s %-17s %s\n"
48 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
49 echo "------------------------------------------------------------------------------------"
50 for O in $TESTSUITE_LIST; do
53 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
56 local log=${TMP}/${o}.log
57 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
58 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
59 [ "${!O}" = "done" ] && \
60 printf "$form" "Done" "$O" "E=$skipped" && \
61 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
65 for O in $TESTSUITE_LIST; do
66 [ "${!O}" = "no" ] && \
67 printf "$form" "Skipped" "$O" ""
70 for O in $TESTSUITE_LIST; do
71 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
72 printf "$form" "UNFINISHED" "$O" ""
77 export LUSTRE=`absolute_path $LUSTRE`
78 export TESTSUITE=`basename $0 .sh`
79 export TEST_FAILED=false
81 export MKE2FS=${MKE2FS:-mke2fs}
82 export DEBUGFS=${DEBUGFS:-debugfs}
83 export TUNE2FS=${TUNE2FS:-tune2fs}
84 export E2LABEL=${E2LABEL:-e2label}
85 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
86 export E2FSCK=${E2FSCK:-e2fsck}
88 #[ -d /r ] && export ROOT=${ROOT:-/r}
89 export TMP=${TMP:-$ROOT/tmp}
90 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
91 export HOSTNAME=${HOSTNAME:-`hostname`}
92 if ! echo $PATH | grep -q $LUSTRE/utils; then
93 export PATH=$PATH:$LUSTRE/utils
95 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
96 export PATH=$PATH:$LUSTRE/utils/gss
98 if ! echo $PATH | grep -q $LUSTRE/tests; then
99 export PATH=$PATH:$LUSTRE/tests
101 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
102 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
103 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
104 export PATH=$PATH:$LUSTRE/tests/racer
106 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
107 export PATH=$PATH:$LUSTRE/tests/mpi
109 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
110 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
111 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
112 [ ! -f "$LFS" ] && export LFS=$(which lfs)
113 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
114 if [ ! -f "$L_GETIDENTITY" ]; then
115 if `which l_getidentity > /dev/null 2>&1`; then
116 export L_GETIDENTITY=$(which l_getidentity)
118 export L_GETIDENTITY=NONE
121 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
122 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
123 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
124 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
125 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
126 export FSTYPE=${FSTYPE:-"ldiskfs"}
127 export NAME=${NAME:-local}
128 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
129 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
130 export LGSSD=$(which lgssd)
131 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
132 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
133 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
135 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
138 if [ "$ACCEPTOR_PORT" ]; then
139 export PORT_OPT="--port $ACCEPTOR_PORT"
144 echo "Using GSS/krb5 ptlrpc security flavor"
145 which lgss_keyring > /dev/null 2>&1 || \
146 error "built with gss disabled! SEC=$SEC"
157 IDENTITY_UPCALL=false
161 # Paths on remote nodes, if different
162 export RLUSTRE=${RLUSTRE:-$LUSTRE}
163 export RPWD=${RPWD:-$PWD}
164 export I_MOUNTED=${I_MOUNTED:-"no"}
168 while getopts "rvwf:" opt $*; do
171 r) REFORMAT=--reformat;;
173 w) WRITECONF=writeconf;;
178 shift $((OPTIND - 1))
181 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
187 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
188 *) EXT=".ko"; USE_QUOTA=yes;;
195 BASE=`basename $module $EXT`
196 lsmod | grep -q ${BASE} || \
197 if [ -f ${LUSTRE}/${module}${EXT} ]; then
198 insmod ${LUSTRE}/${module}${EXT} $@
200 # must be testing a "make install" or "rpm" installation
201 # note failed to load ptlrpc_gss is considered not fatal
202 if [ "$BASE" == "ptlrpc_gss" ]; then
203 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
211 if [ -n "$MODPROBE" ]; then
215 if [ "$HAVE_MODULES" = true ]; then
221 echo Loading modules from $LUSTRE
222 load_module ../libcfs/libcfs/libcfs
223 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
224 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
226 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
227 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
228 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
229 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
230 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
231 echo "lnet options: '$LNETOPTS'"
232 # note that insmod will ignore anything in modprobe.conf
233 load_module ../lnet/lnet/lnet $LNETOPTS
234 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
235 load_module ../lnet/klnds/$LNETLND
236 load_module lvfs/lvfs
237 load_module obdclass/obdclass
238 load_module ptlrpc/ptlrpc
239 load_module ptlrpc/gss/ptlrpc_gss
240 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
248 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
249 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
250 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
251 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
256 load_module lvfs/fsfilt_$FSTYPE
260 load_module obdfilter/obdfilter
263 load_module llite/lustre
264 load_module llite/llite_lloop
265 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
267 rm -f $OGDB/ogdb-$HOSTNAME
268 $LCTL modules > $OGDB/ogdb-$HOSTNAME
270 # 'mount' doesn't look in $PATH, just sbin
271 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
275 if [ `uname -r | cut -c 3` -eq 4 ]; then
283 MODULES=$($LCTL modules | awk '{ print $2 }')
284 while [ -n "$MODULES" ]; do
286 $RMMOD $MODULES > /dev/null 2>&1 || true
287 MODULES=$($LCTL modules | awk '{ print $2 }')
288 if [ -z "$MODULES" ]; then
292 echo "waiting, $((MAX - WAIT)) secs left"
294 if [ $WAIT -eq $MAX ]; then
295 echo "LNET modules $MODULES will not unload"
302 unload_dep_module() {
304 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
306 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
307 for SUBMOD in $DEPS; do
308 unload_dep_module $SUBMOD
310 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
311 $RMMOD $MODULE || true
315 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
316 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
317 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
318 echo "$LEAK_LUSTRE" 1>&2
319 echo "$LEAK_PORTALS" 1>&2
320 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
321 echo "Memory leaks detected"
322 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
328 wait_exit_ST client # bug 12845
330 lsmod | grep libcfs > /dev/null && $LCTL dl
331 unload_dep_module $FSTYPE
332 unload_dep_module libcfs
334 local MODULES=$($LCTL modules | awk '{ print $2 }')
335 if [ -n "$MODULES" ]; then
336 echo "Modules still loaded: "
338 if [ "$(lctl dl)" ]; then
339 echo "Lustre still loaded"
344 echo "Lustre stopped but LNET is still loaded, waiting..."
345 wait_for_lnet || return 3
351 check_mem_leak || return 254
353 echo "modules unloaded."
357 check_gss_daemon_facet() {
361 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
362 if [ $num -ne 1 ]; then
363 echo "$num instance of $dname on $facet"
372 do_facet $facet "killall -2 $@ 2>/dev/null || true"
375 start_gss_daemons() {
377 for num in `seq $MDSCOUNT`; do
378 do_facet mds$num "$LSVCGSSD -v"
380 do_facet mds$num "$LGSSD -v"
384 for num in `seq $OSTCOUNT`; do
385 do_facet ost$num "$LSVCGSSD -v"
388 # FIXME: is "client" the right facet name?
390 do_facet client "$LGSSD -v"
393 # wait daemons entering "stable" status
397 # check daemons are running
399 for num in `seq $MDSCOUNT`; do
400 check_gss_daemon_facet mds$num lsvcgssd
402 check_gss_daemon_facet mds$num lgssd
405 for num in `seq $OSTCOUNT`; do
406 check_gss_daemon_facet ost$num lsvcgssd
409 check_gss_daemon_facet client lgssd
414 for num in `seq $MDSCOUNT`; do
415 send_sigint mds$num lsvcgssd lgssd
417 for num in `seq $OSTCOUNT`; do
418 send_sigint ost$num lsvcgssd
420 send_sigint client lgssd
427 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
428 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
436 # maybe cleanup credential cache?
442 local device=`mdsdevname $num`
443 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
449 local device=`ostdevname $num`
450 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
458 local dev=$(facet_active $facet)_dev
459 local opt=${facet}_opt
460 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
461 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
463 if [ $RC -ne 0 ]; then
464 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
465 echo "Start of ${!dev} on ${facet} failed ${RC}"
467 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
468 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
469 lctl set_param debug_mb=${DEBUG_SIZE}; \
472 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
473 [ -z "$label" ] && echo no label for ${!dev} && exit 1
474 eval export ${facet}_svc=${label}
475 echo Started ${label}
480 # start facet device options
486 eval export ${facet}_dev=${device}
487 eval export ${facet}_opt=\"$@\"
489 local varname=${facet}failover_dev
490 if [ -n "${!varname}" ] ; then
491 eval export ${facet}failover_dev=${!varname}
493 eval export ${facet}failover_dev=$device
496 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
506 HOST=`facet_active_host $facet`
507 [ -z $HOST ] && echo stop: no host for $facet && return 0
509 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
510 if [ ${running} -ne 0 ]; then
511 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
512 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
515 # umount should block, but we should wait for unrelated obd's
516 # like the MGS or MGC to also stop.
517 wait_exit_ST ${facet}
520 # save quota version (both administrative and operational quotas)
521 # add an additional parameter if mountpoint is ever different from $MOUNT
522 quota_save_version() {
523 local fsname=${2:-$FSNAME}
525 local ver=$(tr -c -d "123" <<< $spec)
526 local type=$(tr -c -d "ug" <<< $spec)
528 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
530 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
532 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
534 local osts=$(get_facets OST)
535 for ost in ${osts//,/ }; do
537 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
541 # client could mount several lustre
543 local fsname=${1:-$FSNAME}
545 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
546 do_nodes $(comma_list $(osts_nodes)) \
547 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
551 restore_quota_type () {
552 local mntpt=${1:-$MOUNT}
553 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
554 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
557 quota_save_version $old_QUOTA_TYPE
564 # 1. run quotacheck only if quota is off
565 # 2. save the original quota_type params, restore them after testing
567 # Suppose that quota type the same on mds and ost
568 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
569 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
570 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
571 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
572 export old_QUOTA_TYPE=$quota_type
573 quota_save_version $QUOTA_TYPE
576 local quota_usrs=$QUOTA_USERS
578 # get_filesystem_size
579 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
580 local blk_soft=$((disksz + 1024))
581 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
583 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
585 local i_hard=$((i_soft + i_soft / 20))
587 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
588 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
591 for usr in $quota_usrs; do
592 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
594 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
596 eval $cmd || error "$cmd FAILED!"
598 # display the quota status
599 echo "Quota settings for $usr : "
600 $LFS quota -v -u $usr $mntpt || true
608 # Only supply -o to mount if we have options
609 if [ -n "$MOUNTOPT" ]; then
610 OPTIONS="-o $MOUNTOPT"
612 local device=$MGSNID:/$FSNAME
613 if [ -z "$mnt" -o -z "$FSNAME" ]; then
614 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
618 echo "Starting client: $client: $OPTIONS $device $mnt"
619 do_node $client mkdir -p $mnt
620 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
622 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
623 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
624 lctl set_param debug_mb=${DEBUG_SIZE}"
637 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
638 if [ $running -ne 0 ]; then
639 echo "Stopping client $client $mnt (opts:$force)"
640 do_node $client lsof -t $mnt || need_kill=no
641 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
642 pids=$(do_node $client lsof -t $mnt | sort -u);
643 if [ -n $pids ]; then
644 do_node $client kill -9 $pids || true
648 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
649 if [ $busy -ne 0 ] ; then
650 echo "$mnt is still busy, wait one second" && sleep 1
651 do_node $client umount $force $mnt
656 # nodes is comma list
657 sanity_mount_check_nodes () {
663 # FIXME: assume that all cluster nodes run the same os
664 [ "$(uname)" = Linux ] || return 0
667 for mnt in $mnts ; do
668 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
669 mpts=\\\$(mount | grep -w -c $mnt);
670 if [ \\\$running -ne \\\$mpts ]; then
671 echo \\\$(hostname) env are INSANE!;
679 sanity_mount_check_servers () {
681 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
682 echo Checking servers environments
684 # FIXME: modify get_facets to display all facets wo params
685 local facets="$(get_facets OST),$(get_facets MDS)"
689 for facet in ${facets//,/ }; do
690 node=$(facet_host ${facet})
691 mnt=${MOUNT%/*}/${facet}
692 sanity_mount_check_nodes $node $mnt ||
693 { error "server $node environments are insane!"; return 1; }
697 sanity_mount_check_clients () {
698 local clients=${1:-$CLIENTS}
699 local mntpt=${2:-$MOUNT}
700 local mntpt2=${3:-$MOUNT2}
702 [ -z $clients ] && clients=$(hostname)
703 echo Checking clients $clients environments
705 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
706 error "clients environments are insane!"
709 sanity_mount_check () {
710 sanity_mount_check_servers || return 1
711 sanity_mount_check_clients || return 2
714 # mount clients if not mouted
715 zconf_mount_clients() {
721 # Only supply -o to mount if we have options
722 if [ -n "$MOUNTOPT" ]; then
723 OPTIONS="-o $MOUNTOPT"
725 local device=$MGSNID:/$FSNAME
726 if [ -z "$mnt" -o -z "$FSNAME" ]; then
727 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
731 echo "Starting client $clients: $OPTIONS $device $mnt"
734 running=\\\$(mount | grep -c $mnt' ');
736 if [ \\\$running -eq 0 ] ; then
738 mount -t lustre $OPTIONS $device $mnt;
743 echo "Started clients $clients: "
744 do_nodes $clients "mount | grep -w $mnt"
746 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
747 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
748 lctl set_param debug_mb=${DEBUG_SIZE};"
753 zconf_umount_clients() {
760 echo "Stopping clients: $clients $mnt (opts:$force)"
761 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
762 if [ \\\$running -ne 0 ] ; then
763 echo Stopping client \\\$(hostname) client $mnt opts:$force;
764 lsof -t $mnt || need_kill=no;
765 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
766 pids=\\\$(lsof -t $mnt | sort -u);
767 if [ -n \\\"\\\$pids\\\" ]; then
771 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
772 if [ \\\$busy -ne 0 ] ; then
773 echo "$mnt is still busy, wait one second" && sleep 1;
779 shudown_node_hard () {
783 for i in $(seq $attempts) ; do
786 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
787 echo "waiting for $host to fail attempts=$attempts"
788 [ $i -lt $attempts ] || \
789 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
795 local mnt=${2:-$MOUNT}
798 if [ "$FAILURE_MODE" = HARD ]; then
799 shudown_node_hard $client
801 zconf_umount_clients $client $mnt -f
807 if [ "$FAILURE_MODE" = HARD ]; then
808 shudown_node_hard $(facet_active_host $facet)
809 elif [ "$FAILURE_MODE" = SOFT ]; then
816 if [ "$FAILURE_MODE" = HARD ]; then
817 $POWER_UP `facet_active_host $facet`
825 if [ "$FAILURE_MODE" = HARD ]; then
830 # recovery-scale functions
831 check_progs_installed () {
836 do_nodes $clients "PATH=:$PATH; status=true;
837 for prog in $progs; do
838 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
839 echo \\\$prog missing on \\\$(hostname);
847 echo __$(echo $1 | tr '-' 'X')
850 start_client_load() {
853 local var=$(client_var_name $client)_load
854 eval export ${var}=$load
856 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
857 BREAK_ON_ERROR=$BREAK_ON_ERROR \
858 END_RUN_FILE=$END_RUN_FILE \
859 LOAD_PID_FILE=$LOAD_PID_FILE \
860 TESTSUITELOG=$TESTSUITELOG \
862 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
863 log "Started client load: ${load} on $client"
868 start_client_loads () {
869 local -a clients=(${1//,/ })
870 local numloads=${#CLIENT_LOADS[@]}
873 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
874 testnum=$((nodenum % numloads))
875 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
879 # only for remote client
880 check_client_load () {
882 local var=$(client_var_name $client)_load
883 local TESTLOAD=run_${!var}.sh
885 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
887 # bug 18914: try to connect several times not only when
888 # check ps, but while check_catastrophe also
891 while [ $RC = 254 -a $tries -gt 0 ]; do
895 if ! check_catastrophe $client; then
897 if [ $RC -eq 254 ]; then
898 # FIXME: not sure how long we shuold sleep here
902 echo "check catastrophe failed: RC=$RC "
906 # We can continue try to connect if RC=254
907 # Just print the warning about this
908 if [ $RC = 254 ]; then
909 echo "got a return status of $RC from do_node while checking catastrophe on $client"
912 # see if the load is still on the client
915 while [ $RC = 254 -a $tries -gt 0 ]; do
919 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
924 if [ $RC = 254 ]; then
925 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
926 # see if we can diagnose a bit why this is
931 check_client_loads () {
932 local clients=${1//,/ }
936 for client in $clients; do
937 check_client_load $client
939 if [ "$rc" != 0 ]; then
940 log "Client load failed on node $client, rc=$rc"
946 restart_client_loads () {
947 local clients=${1//,/ }
948 local expectedfail=${2:-""}
952 for client in $clients; do
953 check_client_load $client
955 if [ "$rc" != 0 -a "$expectedfail" ]; then
956 start_client_load $client
957 echo "Restarted client load: on $client. Checking ..."
958 check_client_load $client
960 if [ "$rc" != 0 ]; then
961 log "Client load failed to restart on node $client, rc=$rc"
962 # failure one client load means test fail
963 # we do not need to check other
971 # End recovery-scale functions
973 # verify that lustre actually cleaned up properly
975 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
976 error "LBUG/LASSERT detected"
977 BUSY=`dmesg | grep -i destruct || true`
980 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
984 check_mem_leak || exit 204
986 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
987 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
989 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
990 echo "$0: modules still loaded..." 1>&2
1007 RESULT=$(do_node $node "$TEST")
1008 if [ "$RESULT" == "$FINAL" ]; then
1009 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1012 [ $WAIT -ge $MAX ] && break
1013 echo "Waiting $((MAX - WAIT)) secs for update"
1014 WAIT=$((WAIT + sleep))
1017 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1021 wait_update_facet () {
1023 wait_update $(facet_active_host $facet) "$@"
1026 wait_delete_completed () {
1027 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1028 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1032 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1034 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1035 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1036 [ "$TOTAL" -eq "$TOTALPREV" ] && break
1037 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1041 echo "Delete completed."
1046 check_network "$host" 900
1047 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
1052 local host=`facet_active_host $facet`
1056 wait_recovery_complete () {
1059 # Use default policy if $2 is not passed by caller.
1060 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1061 # as we are in process of changing obd_timeout in different ways
1062 # let's set MAX longer than that
1063 local MAX=${2:-$(( TIMEOUT * 4 ))}
1065 local var_svc=${facet}_svc
1066 local procfile="*.${!var_svc}.recovery_status"
1070 while [ $WAIT -lt $MAX ]; do
1071 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1072 [[ $STATUS = "status: COMPLETE" ]] && return 0
1075 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1077 echo "$facet recovery not done in $MAX sec. $STATUS"
1087 # conf-sanity 31 takes a long time cleanup
1088 while [ $WAIT -lt 300 ]; do
1089 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1090 [ -z "${running}" ] && return 0
1091 echo "waited $WAIT for${running}"
1092 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1094 WAIT=$((WAIT + INTERVAL))
1096 echo "service didn't stop after $WAIT seconds. Still running:"
1101 wait_remote_prog () {
1107 [ "$PDSH" = "no_dsh" ] && return 0
1109 while [ $WAIT -lt $2 ]; do
1110 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1111 [ -z "${running}" ] && return 0 || true
1112 echo "waited $WAIT for: "
1114 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1116 WAIT=$((WAIT + INTERVAL))
1118 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1119 [ -z "$pids" ] && return 0
1120 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1121 # FIXME: not portable
1122 for pid in $pids; do
1123 cat /proc/${pid}/status || true
1124 cat /proc/${pid}/wchan || true
1126 kill -9 $pid || true
1135 # not every config has many clients
1136 if [ ! -z "$CLIENTS" ]; then
1137 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1139 df $MOUNT > /dev/null
1143 client_reconnect() {
1144 uname -n >> $MOUNT/recon
1145 if [ -z "$CLIENTS" ]; then
1146 df $MOUNT; uname -n >> $MOUNT/recon
1148 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1150 echo Connected clients:
1152 ls -l $MOUNT/recon > /dev/null
1159 echo "Failing $facet on node `facet_active_host $facet`"
1160 shutdown_facet $facet
1161 [ -n "$sleep_time" ] && sleep $sleep_time
1163 change_active $facet
1164 local TO=`facet_active_host $facet`
1165 echo "Failover $facet to $TO"
1167 mount_facet $facet || error "Restart of $facet failed"
1176 do_facet $facet sync
1178 local svc=${facet}_svc
1179 do_facet $facet $LCTL --device %${!svc} notransno
1180 do_facet $facet $LCTL --device %${!svc} readonly
1181 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1182 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1185 replay_barrier_nodf() {
1186 local facet=$1 echo running=${running}
1187 do_facet $facet sync
1188 local svc=${facet}_svc
1189 echo Replay barrier on ${!svc}
1190 do_facet $facet $LCTL --device %${!svc} notransno
1191 do_facet $facet $LCTL --device %${!svc} readonly
1192 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1193 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1196 replay_barrier_nosync() {
1197 local facet=$1 echo running=${running}
1198 local svc=${facet}_svc
1199 echo Replay barrier on ${!svc}
1200 do_facet $facet $LCTL --device %${!svc} notransno
1201 do_facet $facet $LCTL --device %${!svc} readonly
1202 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1203 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1206 mds_evict_client() {
1207 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1208 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1211 ost_evict_client() {
1212 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1213 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1217 facet_failover $* || error "failover: $?"
1218 client_df || error "post-failover df: $?"
1223 facet_failover $facet
1229 change_active $facet
1230 mount_facet $facet -o abort_recovery
1231 client_df || echo "first df failed: $?"
1233 client_df || error "post-failover df: $?"
1237 echo There is no lmc. This is mountconf, baby.
1242 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1243 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1249 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1255 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1256 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1257 if [ -z "$ID" ]; then
1258 echo "Could not get a ptl id for $1..."
1267 h2name_or_ip "$1" "tcp"
1272 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1273 if type __h2elan >/dev/null 2>&1; then
1276 ID=`echo $1 | sed 's/[^0-9]*//g'`
1284 h2name_or_ip "$1" "openib"
1286 declare -fx h2openib
1289 h2name_or_ip "$1" "o2ib"
1296 [ "$facet" == client ] && echo -n $HOSTNAME && return
1297 varname=${facet}_HOST
1298 if [ -z "${!varname}" ]; then
1299 if [ "${facet:0:3}" == "ost" ]; then
1300 eval ${facet}_HOST=${ost_HOST}
1308 local activevar=${facet}active
1310 if [ -f $TMP/${facet}active ] ; then
1311 source $TMP/${facet}active
1314 active=${!activevar}
1315 if [ -z "$active" ] ; then
1322 facet_active_host() {
1324 local active=`facet_active $facet`
1325 if [ "$facet" == client ]; then
1328 echo `facet_host $active`
1334 local failover=${facet}failover
1335 host=`facet_host $failover`
1336 [ -z "$host" ] && return
1337 local curactive=`facet_active $facet`
1338 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1339 eval export ${facet}active=$facet
1341 eval export ${facet}active=$failover
1343 # save the active host for this facet
1344 local activevar=${facet}active
1345 echo "$activevar=${!activevar}" > $TMP/$activevar
1350 # do not stripe off hostname if verbose, bug 19215
1351 if [ x$1 = x--verbose ]; then
1359 if [ "$HOST" = "$HOSTNAME" ]; then
1361 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1362 echo "cannot run remote command on $HOST with $myPDSH"
1366 echo "CMD: $HOST $@" >&2
1367 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1370 if [ "$myPDSH" = "rsh" ]; then
1371 # we need this because rsh does not return exit code of an executed command
1372 local command_status="$TMP/cs"
1373 rsh $HOST ":> $command_status"
1374 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1375 cd $RPWD; sh -c \"$@\") ||
1376 echo command failed >$command_status"
1377 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1382 # print HOSTNAME for myPDSH="no_dsh"
1383 if [[ $myPDSH = no_dsh ]]; then
1384 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1386 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1389 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1391 return ${PIPESTATUS[0]}
1394 single_local_node () {
1395 [ "$1" = "$HOSTNAME" ]
1400 # do not stripe off hostname if verbose, bug 19215
1401 if [ x$1 = x--verbose ]; then
1409 if $(single_local_node $rnodes); then
1410 do_node --verbose $rnodes $@
1414 # This is part from do_node
1417 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1418 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1421 echo "CMD: $rnodes $@" >&2
1422 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1426 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1428 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1430 return ${PIPESTATUS[0]}
1436 local HOST=`facet_active_host $facet`
1437 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1444 # make sure its not already running
1446 rm -f $TMP/${facet}active
1447 do_facet ${facet} $MKFS $*
1453 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1454 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1461 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1462 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1470 # make sure we are using the primary server, so test-framework will
1471 # be able to clean up properly.
1472 activemds=`facet_active mds1`
1473 if [ $activemds != "mds1" ]; then
1477 local clients=$CLIENTS
1478 [ -z $clients ] && clients=$(hostname)
1480 zconf_umount_clients $clients $MOUNT "$*" || true
1481 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1483 [ "$CLIENTONLY" ] && return
1484 # The add fn does rm ${facet}active file, this would be enough
1485 # if we use do_facet <facet> only after the facet added, but
1486 # currently we use do_facet mds in local.sh
1487 for num in `seq $MDSCOUNT`; do
1489 rm -f ${TMP}/mds${num}active
1492 for num in `seq $OSTCOUNT`; do
1494 rm -f $TMP/ost${num}active
1501 nfs_client_mode && return
1511 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1515 if [ "$IAMDIR" == "yes" ]; then
1516 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1517 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1520 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1522 if [ ! -z $SEC ]; then
1523 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1524 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1525 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1529 # We need ldiskfs here, may as well load them all
1531 [ "$CLIENTONLY" ] && return
1532 echo "Formatting mdts, osts"
1533 for num in `seq $MDSCOUNT`; do
1534 echo "Format mds$num: $(mdsdevname $num)"
1536 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1538 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1542 for num in `seq $OSTCOUNT`; do
1543 echo "Format ost$num: $(ostdevname $num)"
1545 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1547 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1553 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1557 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1561 # 0: success, the old identity set already.
1562 # 1: success, the old identity does not set.
1567 local j=`expr $num - 1`
1568 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1570 if [ -z "$MDT" ]; then
1574 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1577 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1579 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1582 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1584 if [ $old = "NONE" ]; then
1593 zconf_umount `hostname` $1 || error "umount failed"
1594 zconf_mount `hostname` $1 || error "mount failed"
1597 writeconf_facet () {
1601 do_facet $facet "$TUNEFS --writeconf $dev"
1605 for num in `seq $MDSCOUNT`; do
1606 DEVNAME=$(mdsdevname $num)
1607 writeconf_facet mds$num $DEVNAME
1610 for num in `seq $OSTCOUNT`; do
1611 DEVNAME=$(ostdevname $num)
1612 writeconf_facet ost$num $DEVNAME
1617 nfs_client_mode && return
1619 sanity_mount_check ||
1620 error "environments are insane!"
1624 if [ -z "$CLIENTONLY" ]; then
1625 echo "Setup mdts, osts"
1626 echo $WRITECONF | grep -q "writeconf" && \
1628 for num in `seq $MDSCOUNT`; do
1629 DEVNAME=$(mdsdevname $num)
1630 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1632 # We started mds, now we should set failover variables properly.
1633 # Set mds${num}failover_HOST if it is not set (the default failnode).
1634 local varname=mds${num}failover_HOST
1635 if [ -z "${!varname}" ]; then
1636 eval mds${num}failover_HOST=$(facet_host mds$num)
1639 if [ $IDENTITY_UPCALL != "default" ]; then
1640 switch_identity $num $IDENTITY_UPCALL
1643 for num in `seq $OSTCOUNT`; do
1644 DEVNAME=$(ostdevname $num)
1645 start ost$num $DEVNAME $OST_MOUNT_OPTS
1647 # We started ost$num, now we should set ost${num}failover variable properly.
1648 # Set ost${num}failover_HOST if it is not set (the default failnode).
1649 varname=ost${num}failover_HOST
1650 if [ -z "${!varname}" ]; then
1651 eval ost${num}failover_HOST=$(facet_host ost${num})
1656 # wait a while to allow sptlrpc configuration be propogated to targets,
1657 # only needed when mounting new target devices.
1660 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1662 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1664 if [ "$MOUNT_2" ]; then
1665 mount_client $MOUNT2
1666 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1671 # by remounting mdt before ost, initial connect from mdt to ost might
1672 # timeout because ost is not ready yet. wait some time to its fully
1673 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1674 # by a context negotiation rpc with $TIMEOUT.
1675 # FIXME better by monitoring import status.
1677 sleep $((TIMEOUT + 5))
1683 mounted_lustre_filesystems() {
1684 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1687 init_facet_vars () {
1688 [ "$CLIENTONLY" ] && return 0
1695 eval export ${facet}_dev=${device}
1696 eval export ${facet}_opt=\"$@\"
1698 local dev=${facet}_dev
1699 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1700 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1702 eval export ${facet}_svc=${label}
1704 local varname=${facet}failover_HOST
1705 if [ -z "${!varname}" ]; then
1706 eval $varname=$(facet_host $facet)
1709 # ${facet}failover_dev is set in cfg file
1710 varname=${facet}failover_dev
1711 if [ -n "${!varname}" ] ; then
1712 eval export ${facet}failover_dev=${!varname}
1714 eval export ${facet}failover_dev=$device
1718 init_facets_vars () {
1721 if ! remote_mds_nodsh; then
1722 for num in `seq $MDSCOUNT`; do
1723 DEVNAME=`mdsdevname $num`
1724 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1728 remote_ost_nodsh && return
1730 for num in `seq $OSTCOUNT`; do
1731 DEVNAME=`ostdevname $num`
1732 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1736 osc_ensure_active () {
1742 while [ $period -lt $timeout ]; do
1743 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1744 if [ $count -eq 0 ]; then
1748 echo "There are $count OST are inactive, wait $period seconds, and try again"
1750 period=$((period+3))
1753 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1757 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1761 init_param_vars () {
1762 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1763 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1764 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1765 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1769 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1771 log "Using TIMEOUT=$TIMEOUT"
1773 osc_ensure_active $SINGLEMDS M $TIMEOUT
1774 osc_ensure_active client c $TIMEOUT
1776 if [ x"$(som_check)" = x"enabled" ]; then
1779 if [ "$ENABLE_QUOTA" ]; then
1780 setup_quota $MOUNT || return 2
1784 nfs_client_mode () {
1785 if [ "$NFSCLIENT" ]; then
1786 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1787 local clients=$CLIENTS
1788 [ -z $clients ] && clients=$(hostname)
1790 # FIXME: remove hostname when 19215 fixed
1791 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1792 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1793 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1800 nfs_client_mode && return
1804 local mounted=$(mount | grep " $mntpt ")
1805 if [ "$CLIENTONLY" ]; then
1807 # CLIENTONLY should not depend on *_HOST settings
1808 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1809 # in theory someone could create a new,
1810 # client-only config file that assumed lustre was already
1811 # configured and didn't set the MGSNID. If MGSNID is not set,
1812 # then we should use the mgs nid currently being used
1813 # as the default value. bug 18021
1814 [[ x$MGSNID = x ]] &&
1817 if [[ x$mgc != xMGC$MGSNID ]]; then
1818 if [ "$mgs_HOST" ]; then
1819 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1820 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1821 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1827 local myMGS_host=$mgs_HOST
1828 if [ "$NETTYPE" = "ptl" ]; then
1829 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1832 echo Checking config lustre mounted on $mntpt
1833 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1834 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1836 if [ "$mgshost" != "$myMGS_host" ]; then
1837 error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1838 Please use correct config or set mds_HOST correctly!"
1841 sanity_mount_check ||
1842 error "environments are insane!"
1846 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1847 local cltimeout=$(lctl get_param -n timeout)
1848 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1849 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1854 check_and_setup_lustre() {
1855 nfs_client_mode && return
1857 local MOUNTED=$(mounted_lustre_filesystems)
1858 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1859 [ "$REFORMAT" ] && formatall
1861 MOUNTED=$(mounted_lustre_filesystems | head -1)
1862 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1863 export I_MOUNTED=yes
1869 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1870 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1871 lctl set_param debug_mb=${DEBUG_SIZE};
1874 if [ "$ONLY" == "setup" ]; then
1879 cleanup_and_setup_lustre() {
1880 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1881 lctl set_param debug=0 || true
1883 if [ "$ONLY" == "cleanup" ]; then
1887 check_and_setup_lustre
1890 check_and_cleanup_lustre() {
1891 if [ "`mount | grep $MOUNT`" ]; then
1892 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1893 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1895 if [ "$I_MOUNTED" = "yes" ]; then
1896 cleanupall -f || error "cleanup failed"
1908 while [ $NETWORK -eq 0 ]; do
1909 ping -c 1 -w 3 $1 > /dev/null
1910 if [ $? -eq 0 ]; then
1914 echo "waiting for $1, $((MAX - WAIT)) secs left"
1917 if [ $WAIT -gt $MAX ]; then
1918 echo "Network not available"
1924 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1935 # the sed converts spaces to commas, but leaves the last space
1936 # alone, so the line doesn't end with a comma.
1937 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1940 # list, excluded are the comma separated lists
1941 exclude_items_from_list () {
1947 for item in ${excluded//,/ }; do
1948 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1950 echo $(comma_list $list)
1953 # list, expand are the comma separated lists
1955 local list=${1//,/ }
1956 local expand=${2//,/ }
1959 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1960 echo $(comma_list $expanded)
1964 (cd `dirname $1`; echo $PWD/`basename $1`)
1968 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1969 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1972 local count=${type}COUNT
1973 for ((i=1; i<=${!count}; i++)) do
1974 list="$list ${name}$i"
1976 echo $(comma_list $list)
1979 ##################################
1980 # Adaptive Timeouts funcs
1983 # only check mds, we assume at_max is the same on all nodes
1984 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
1985 if [ $at_max -eq 0 ]; then
1995 # suppose that all ost-s has the same at_max set
1996 if [ $facet == "ost" ]; then
1997 do_facet ost1 "lctl get_param -n at_max"
1999 do_facet $facet "lctl get_param -n at_max"
2009 if [ $facet == "ost" ]; then
2010 for i in `seq $OSTCOUNT`; do
2011 do_facet ost$i "lctl set_param at_max=$at_max"
2014 elif [ $facet == "mds" ]; then
2015 for i in `seq $MDSCOUNT`; do
2016 do_facet mds$i "lctl set_param at_max=$at_max"
2019 do_facet $facet "lctl set_param at_max=$at_max"
2024 ##################################
2028 # OBD_FAIL_MDS_ALL_REQUEST_NET
2030 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2031 do_facet client "$1" || RC=$?
2032 do_facet $SINGLEMDS lctl set_param fail_loc=0
2037 # OBD_FAIL_MDS_ALL_REPLY_NET
2039 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2040 do_facet client "$@" || RC=$?
2041 do_facet $SINGLEMDS lctl set_param fail_loc=0
2045 drop_reint_reply() {
2046 # OBD_FAIL_MDS_REINT_NET_REP
2048 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2049 do_facet client "$@" || RC=$?
2050 do_facet $SINGLEMDS lctl set_param fail_loc=0
2055 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2057 do_facet ost1 lctl set_param fail_loc=0x214
2058 do_facet client "$1" || RC=$?
2059 do_facet client "sync"
2060 do_facet ost1 lctl set_param fail_loc=0
2064 drop_ldlm_cancel() {
2065 #define OBD_FAIL_LDLM_CANCEL 0x304
2067 do_facet client lctl set_param fail_loc=0x304
2068 do_facet client "$@" || RC=$?
2069 do_facet client lctl set_param fail_loc=0
2073 drop_bl_callback() {
2074 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2076 do_facet client lctl set_param fail_loc=0x305
2077 do_facet client "$@" || RC=$?
2078 do_facet client lctl set_param fail_loc=0
2083 #define OBD_FAIL_LDLM_REPLY 0x30c
2085 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2086 do_facet client "$@" || RC=$?
2087 do_facet $SINGLEMDS lctl set_param fail_loc=0
2095 echo "clearing fail_loc on $facet"
2096 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2099 set_nodes_failloc () {
2100 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2103 cancel_lru_locks() {
2104 $LCTL mark "cancel_lru_locks $1 start"
2105 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2106 $LCTL set_param -n $d=clear
2108 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2109 $LCTL mark "cancel_lru_locks $1 stop"
2114 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2115 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2116 echo "$DEFAULT_LRU_SIZE"
2121 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2124 lru_resize_disable()
2126 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2131 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2132 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2133 echo there is still data in page cache $FILE ?
2134 lctl get_param -n $FILE
2142 DEBUGSAVE="$(lctl get_param -n debug)"
2146 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2150 ##################################
2152 ##################################
2155 local TYPE=${TYPE:-"FAIL"}
2157 lctl set_param fail_loc=0 2>/dev/null || true
2158 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2159 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2160 echo "Dumping lctl log to $ERRLOG"
2161 # We need to dump the logs on all nodes
2162 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2164 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2170 $FAIL_ON_ERROR && exit 1 || true
2178 # use only if we are ignoring failures for this test, bugno required.
2179 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2180 # e.g. error_ignore 5494 "your message"
2182 local TYPE="IGNORE (bz$1)"
2189 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2190 [ "$TESTSUITELOG" ] && \
2191 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2194 build_test_filter() {
2195 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2199 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2200 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2201 [ "$EXCEPT_SLOW" ] && \
2202 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2203 for E in $EXCEPT $ALWAYS_EXCEPT; do
2204 eval EXCEPT_${E}=true
2206 for E in $EXCEPT_SLOW; do
2207 eval EXCEPT_SLOW_${E}=true
2209 for G in $GRANT_CHECK_LIST; do
2210 eval GCHECK_ONLY_${G}=true
2219 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
2222 # print a newline if the last test was skipped
2223 export LAST_SKIPPED=
2227 export base=`basetest $1`
2228 if [ ! -z "$ONLY" ]; then
2230 if [ ${!testname}x != x ]; then
2231 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2236 if [ ${!testname}x != x ]; then
2237 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2246 if [ ${!testname}x != x ]; then
2248 TESTNAME=test_$1 skip "skipping excluded test $1"
2251 testname=EXCEPT_$base
2252 if [ ${!testname}x != x ]; then
2254 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2257 testname=EXCEPT_SLOW_$1
2258 if [ ${!testname}x != x ]; then
2260 TESTNAME=test_$1 skip "skipping SLOW test $1"
2263 testname=EXCEPT_SLOW_$base
2264 if [ ${!testname}x != x ]; then
2266 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2276 EQUALS="======================================================================"
2280 local suffixlen=$((${#EQUALS} - ${#msg}))
2281 [ $suffixlen -lt 5 ] && suffixlen=5
2282 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2287 lsmod | grep lnet > /dev/null || load_modules
2299 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2304 strace -o $TMP/$1.strace -ttt $*
2306 log "FINISHED: $*: rc $RC"
2311 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2316 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2317 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2318 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2322 echo -n "Resetting fail_loc on all nodes..."
2323 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2331 export tdir=d0.${TESTSUITE}/d${base}
2333 local SAVE_UMASK=`umask`
2336 local BEFORE=`date +%s`
2338 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2340 export TESTNAME=test_$testnum
2342 test_${testnum} || error "test_$testnum failed with $?"
2346 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2347 check_catastrophe || error "LBUG/LASSERT detected"
2348 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2349 pass "($((`date +%s` - $BEFORE))s)"
2357 (cd `dirname $1`; echo $PWD/`basename $1`)
2361 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2362 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2367 export base=`basetest $1`
2368 [ "$CHECK_GRANT" == "no" ] && return 0
2370 testname=GCHECK_ONLY_${base}
2371 [ ${!testname}x == x ] && return 0
2373 echo -n "checking grant......"
2375 # write some data to sync client lost_grant
2376 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2377 for i in `seq $OSTCOUNT`; do
2378 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2379 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2380 count=1 > /dev/null 2>&1
2382 # sync all the data and make sure no pending data on server
2385 #get client grant and server grant
2387 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2388 client_grant=$((client_grant + $d))
2391 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2392 server_grant=$((server_grant + $d))
2395 # cleanup the check_grant file
2396 for i in `seq $OSTCOUNT`; do
2397 rm $DIR1/${tfile}_check_grant_$i
2400 #check whether client grant == server grant
2401 if [ $client_grant != $server_grant ]; then
2402 echo "failed: client:${client_grant} server: ${server_grant}"
2409 ########################
2415 ost=`echo $1 | awk -F_ '{print $3}'`
2416 if [ -z $ost ]; then
2417 ost=`echo $1 | sed 's/-osc.*//'`
2424 [ "$node" != "$(hostname)" ]
2430 for node in $(mdts_nodes); do
2431 remote_node $node && return 0
2438 [ "$CLIENTONLY" ] && return 0 || true
2439 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2445 for node in $(osts_nodes) ; do
2446 remote_node $node && return 0
2453 [ "$CLIENTONLY" ] && return 0 || true
2454 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2460 MGS=$(facet_host mgs)
2461 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2467 for num in `seq $MDSCOUNT`; do
2468 MDSNODES="$MDSNODES $(facet_host mds$num)"
2470 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2476 remote_ost && remote_mds
2480 local OSTNODES=$(facet_host ost1)
2483 for num in `seq $OSTCOUNT`; do
2484 local myOST=$(facet_host ost$num)
2485 OSTNODES="$OSTNODES $myOST"
2487 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2493 # FIXME. We need a list of clients
2494 local myNODES=$HOSTNAME
2497 # CLIENTS (if specified) contains the local client
2498 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2500 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2501 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2504 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2509 remote_nodes_list () {
2510 local rnodes=$(nodes_list)
2511 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2515 init_clients_lists () {
2516 # Sanity check: exclude the local client from RCLIENTS
2517 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2519 # Sanity check: exclude the dup entries
2520 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2522 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2524 # Sanity check: exclude the dup entries from CLIENTS
2525 # for those configs which has SINGLCLIENT set to local client
2526 clients=$(for i in $clients; do echo $i; done | sort -u)
2528 CLIENTS=`comma_list $clients`
2529 local -a remoteclients=($rclients)
2530 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2531 varname=CLIENT$((i + 2))
2532 eval $varname=${remoteclients[i]}
2535 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2538 get_random_entry () {
2541 rnodes=${rnodes//,/ }
2543 local -a nodes=($rnodes)
2544 local num=${#nodes[@]}
2545 local i=$((RANDOM * num * 2 / 65536))
2552 lctl get_param version | grep -q patchless
2556 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2561 echo $nodes | wc -w || true
2565 local nodes=$(osts_nodes)
2566 local osscount=$(get_node_count "$nodes")
2567 [ ! "$OSTCOUNT" = "$osscount" ]
2571 local nodes=$(mdts_nodes)
2572 local mdtcount=$(get_node_count "$nodes")
2573 [ ! "$MDSCOUNT" = "$mdtcount" ]
2576 generate_machine_file() {
2577 local nodes=${1//,/ }
2578 local machinefile=$2
2579 rm -f $machinefile || error "can't rm $machinefile"
2580 for node in $nodes; do
2581 echo $node >>$machinefile
2586 local file=$1/stripe
2588 $LFS getstripe -v $file || error
2592 check_runas_id_ret() {
2594 local myRUNAS_UID=$1
2595 local myRUNAS_GID=$2
2598 if [ -z "$myRUNAS" ]; then
2599 error_exit "myRUNAS command must be specified for check_runas_id"
2602 $myRUNAS krb5_login.sh || \
2603 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2605 mkdir $DIR/d0_runas_test
2607 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2608 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2609 rm -rf $DIR/d0_runas_test
2614 local myRUNAS_UID=$1
2615 local myRUNAS_GID=$2
2618 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2619 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2620 Please set RUNAS_ID to some UID which exists on MDS and client or
2621 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2624 # obtain the UID/GID for MPI_USER
2628 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2629 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2631 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2632 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2635 # obtain and cache Kerberos ticket-granting ticket
2636 refresh_krb5_tgt() {
2637 local myRUNAS_UID=$1
2638 local myRUNAS_GID=$2
2641 if [ -z "$myRUNAS" ]; then
2642 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2645 CLIENTS=${CLIENTS:-$HOSTNAME}
2646 do_nodes $CLIENTS "set -x
2647 if ! $myRUNAS krb5_login.sh; then
2648 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2653 # Run multiop in the background, but wait for it to print
2654 # "PAUSING" to its stdout before returning from this function.
2655 multiop_bg_pause() {
2656 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2660 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2663 echo "$MULTIOP_PROG $FILE v$ARGS"
2664 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2666 echo "TMPPIPE=${TMPPIPE}"
2667 read -t 60 multiop_output < $TMPPIPE
2668 if [ $? -ne 0 ]; then
2673 if [ "$multiop_output" != "PAUSING" ]; then
2674 echo "Incorrect multiop output: $multiop_output"
2689 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2695 inodes_available () {
2696 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2700 # reset llite stat counters
2701 clear_llite_stats(){
2702 lctl set_param -n llite.*.stats 0
2705 # sum llite stat items
2706 calc_llite_stats() {
2707 local res=$(lctl get_param -n llite.*.stats |
2708 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2712 # reset osc stat counters
2714 lctl set_param -n osc.*.osc_stats 0
2717 # sum osc stat items
2719 local res=$(lctl get_param -n osc.*.osc_stats |
2720 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2725 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2728 calc_osc_kbytes () {
2729 df $MOUNT > /dev/null
2730 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2733 # save_lustre_params(node, parameter_mask)
2734 # generate a stream of formatted strings (<node> <param name>=<param value>)
2735 save_lustre_params() {
2737 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2740 # restore lustre parameters from input stream, produces by save_lustre_params
2741 restore_lustre_params() {
2745 while IFS=" =" read node name val; do
2746 do_node ${node//:/} "lctl set_param -n $name $val"
2750 check_catastrophe() {
2751 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2752 local C=$CATASTROPHE
2753 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2755 if [ $rnodes ]; then
2756 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2757 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2773 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2775 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2776 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2777 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2781 # CMD: determine mds index where directory inode presents
2784 local file=$dir/f0.get_mds_dir_tmpfile
2788 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2789 local -a oldused=($iused)
2793 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2794 local -a newused=($iused)
2797 for ((i=0; i<${#newused[@]}; i++)); do
2798 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2804 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2807 mdsrate_cleanup () {
2808 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2811 delayed_recovery_enabled () {
2812 local var=${SINGLEMDS}_svc
2813 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2816 ########################
2817 convert_facet2name() {
2819 "ost" ) echo "OST0000" ;;
2820 "ost1") echo "OST0000" ;;
2821 "ost2") echo "OST0001" ;;
2822 "ost3") echo "OST0002" ;;
2823 "ost4") echo "OST0003" ;;
2824 "ost5") echo "OST0004" ;;
2825 *) error "unknown facet!" ;;
2829 get_clientosc_proc_path() {
2835 get_lustre_version () {
2836 local node=${1:-"mds"}
2837 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2840 get_mds_version_major () {
2841 local version=$(get_lustre_version mds)
2842 echo $version | awk -F. '{print $1}'
2845 get_mds_version_minor () {
2846 local version=$(get_lustre_version mds)
2847 echo $version | awk -F. '{print $2}'
2850 get_mdtosc_proc_path() {
2852 local major=$(get_mds_version_major)
2853 local minor=$(get_mds_version_minor)
2854 if [ $major -le 1 -a $minor -le 8 ] ; then
2857 echo "${ost}-osc-MDT0000"
2861 get_osc_import_name() {
2864 local name=$(convert_facet2name $ost)
2866 if [ "$node" == "mds" ]; then
2867 get_mdtosc_proc_path $name
2871 get_clientosc_proc_path $name
2875 wait_osc_import_state() {
2879 local ost=$(get_osc_import_name $node $ost_facet)
2884 CONN_PROC="osc.${FSNAME}-${ost}.ost_server_uuid"
2885 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2886 while [ "${CONN_STATE}" != "${expected}" ]; do
2887 if [ "${expected}" == "DISCONN" ]; then
2888 # for disconn we can check after proc entry is removed
2889 [ "x${CONN_STATE}" == "x" ] && return 0
2890 # with AT we can have connect request timeout ~ reconnect timeout
2891 # and test can't see real disconnect
2892 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2894 # disconnect rpc should be wait not more obd_timeout
2895 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2896 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2898 CONN_STATE=$(do_facet $node lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2902 log "${ost_facet} now in ${CONN_STATE} state"