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/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 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
107 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
108 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
109 [ ! -f "$LFS" ] && export LFS=$(which lfs)
110 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
111 if [ ! -f "$L_GETIDENTITY" ]; then
112 if `which l_getidentity > /dev/null 2>&1`; then
113 export L_GETIDENTITY=$(which l_getidentity)
115 export L_GETIDENTITY=NONE
118 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
119 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
120 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
121 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
122 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
123 export FSTYPE=${FSTYPE:-"ldiskfs"}
124 export NAME=${NAME:-local}
125 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
126 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
127 export LGSSD=$(which lgssd)
128 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
129 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
130 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
132 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
135 if [ "$ACCEPTOR_PORT" ]; then
136 export PORT_OPT="--port $ACCEPTOR_PORT"
141 echo "Using GSS/krb5 ptlrpc security flavor"
142 which lgss_keyring > /dev/null 2>&1 || \
143 error "built with gss disabled! SEC=$SEC"
154 IDENTITY_UPCALL=false
158 # Paths on remote nodes, if different
159 export RLUSTRE=${RLUSTRE:-$LUSTRE}
160 export RPWD=${RPWD:-$PWD}
161 export I_MOUNTED=${I_MOUNTED:-"no"}
165 while getopts "rvwf:" opt $*; do
168 r) REFORMAT=--reformat;;
170 w) WRITECONF=writeconf;;
175 shift $((OPTIND - 1))
178 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
184 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
185 *) EXT=".ko"; USE_QUOTA=yes;;
192 BASE=`basename $module $EXT`
193 lsmod | grep -q ${BASE} || \
194 if [ -f ${LUSTRE}/${module}${EXT} ]; then
195 insmod ${LUSTRE}/${module}${EXT} $@
197 # must be testing a "make install" or "rpm" installation
198 # note failed to load ptlrpc_gss is considered not fatal
199 if [ "$BASE" == "ptlrpc_gss" ]; then
200 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
208 if [ -n "$MODPROBE" ]; then
212 if [ "$HAVE_MODULES" = true ]; then
218 echo Loading modules from $LUSTRE
219 load_module ../libcfs/libcfs/libcfs
220 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
221 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
223 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
224 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
225 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
226 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
227 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
228 echo "lnet options: '$LNETOPTS'"
229 # note that insmod will ignore anything in modprobe.conf
230 load_module ../lnet/lnet/lnet $LNETOPTS
231 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
232 load_module ../lnet/klnds/$LNETLND
233 load_module lvfs/lvfs
234 load_module obdclass/obdclass
235 load_module ptlrpc/ptlrpc
236 load_module ptlrpc/gss/ptlrpc_gss
237 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
245 if [ -z "$CLIENTONLY" ] && [ -z "$CLIENTMODSONLY" ]; then
246 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
247 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
248 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
253 load_module lvfs/fsfilt_$FSTYPE
257 load_module obdfilter/obdfilter
260 load_module llite/lustre
261 load_module llite/llite_lloop
262 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
264 rm -f $OGDB/ogdb-$HOSTNAME
265 $LCTL modules > $OGDB/ogdb-$HOSTNAME
267 # 'mount' doesn't look in $PATH, just sbin
268 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
272 if [ `uname -r | cut -c 3` -eq 4 ]; then
280 MODULES=$($LCTL modules | awk '{ print $2 }')
281 while [ -n "$MODULES" ]; do
283 $RMMOD $MODULES > /dev/null 2>&1 || true
284 MODULES=$($LCTL modules | awk '{ print $2 }')
285 if [ -z "$MODULES" ]; then
289 echo "waiting, $((MAX - WAIT)) secs left"
291 if [ $WAIT -eq $MAX ]; then
292 echo "LNET modules $MODULES will not unload"
299 unload_dep_module() {
301 #libcfs 107852 17 llite_lloop,lustre,obdfilter,ost,...
303 local DEPS=$(lsmod | awk '($1 == "'$MODULE'") { print $4 }' | tr ',' ' ')
304 for SUBMOD in $DEPS; do
305 unload_dep_module $SUBMOD
307 [ "$MODULE" = "libcfs" ] && $LCTL dk $TMP/debug || true
308 $RMMOD $MODULE || true
312 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
313 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
314 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
315 echo "$LEAK_LUSTRE" 1>&2
316 echo "$LEAK_PORTALS" 1>&2
317 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
318 echo "Memory leaks detected"
319 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
325 wait_exit_ST client # bug 12845
327 lsmod | grep libcfs > /dev/null && $LCTL dl
328 unload_dep_module $FSTYPE
329 unload_dep_module libcfs
331 local MODULES=$($LCTL modules | awk '{ print $2 }')
332 if [ -n "$MODULES" ]; then
333 echo "Modules still loaded: "
335 if [ "$(lctl dl)" ]; then
336 echo "Lustre still loaded"
341 echo "Lustre stopped but LNET is still loaded, waiting..."
342 wait_for_lnet || return 3
348 check_mem_leak || return 254
350 echo "modules unloaded."
354 check_gss_daemon_facet() {
358 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
359 if [ $num -ne 1 ]; then
360 echo "$num instance of $dname on $facet"
369 do_facet $facet "killall -2 $@ 2>/dev/null || true"
372 start_gss_daemons() {
374 for num in `seq $MDSCOUNT`; do
375 do_facet mds$num "$LSVCGSSD -v"
377 do_facet mds$num "$LGSSD -v"
381 for num in `seq $OSTCOUNT`; do
382 do_facet ost$num "$LSVCGSSD -v"
385 # FIXME: is "client" the right facet name?
387 do_facet client "$LGSSD -v"
390 # wait daemons entering "stable" status
394 # check daemons are running
396 for num in `seq $MDSCOUNT`; do
397 check_gss_daemon_facet mds$num lsvcgssd
399 check_gss_daemon_facet mds$num lgssd
402 for num in `seq $OSTCOUNT`; do
403 check_gss_daemon_facet ost$num lsvcgssd
406 check_gss_daemon_facet client lgssd
411 for num in `seq $MDSCOUNT`; do
412 send_sigint mds$num lsvcgssd lgssd
414 for num in `seq $OSTCOUNT`; do
415 send_sigint ost$num lsvcgssd
417 send_sigint client lgssd
424 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
425 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
433 # maybe cleanup credential cache?
439 local device=`mdsdevname $num`
440 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
446 local device=`ostdevname $num`
447 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
455 local dev=$(facet_active $facet)_dev
456 local opt=${facet}_opt
457 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
458 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
460 if [ $RC -ne 0 ]; then
461 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
462 echo "Start of ${!dev} on ${facet} failed ${RC}"
464 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
465 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
466 lctl set_param debug_mb=${DEBUG_SIZE}; \
469 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
470 [ -z "$label" ] && echo no label for ${!dev} && exit 1
471 eval export ${facet}_svc=${label}
472 echo Started ${label}
477 # start facet device options
483 eval export ${facet}_dev=${device}
484 eval export ${facet}_opt=\"$@\"
486 local varname=${facet}failover_dev
487 if [ -n "${!varname}" ] ; then
488 eval export ${facet}failover_dev=${!varname}
490 eval export ${facet}failover_dev=$device
493 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
503 HOST=`facet_active_host $facet`
504 [ -z $HOST ] && echo stop: no host for $facet && return 0
506 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
507 if [ ${running} -ne 0 ]; then
508 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
509 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
512 # umount should block, but we should wait for unrelated obd's
513 # like the MGS or MGC to also stop.
514 wait_exit_ST ${facet}
517 # save quota version (both administrative and operational quotas)
518 quota_save_version() {
519 local fsname=${2:-$FSNAME}
520 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$1"
522 local osts=$(get_facets OST)
523 for ost in ${osts//,/ }; do
525 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1"
529 # client could mount several lustre
531 local fsname=${1:-$FSNAME}
533 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
534 do_nodes $(comma_list $(osts_nodes)) \
535 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
539 restore_quota_type () {
540 local mntpt=${1:-$MOUNT}
541 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
542 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
546 quota_save_version $old_QUOTA_TYPE
547 $LFS quotacheck -ug $mntpt
554 # 1. run quotacheck only if quota is off
555 # 2. save the original quota_type params, restore them after testing
557 # Suppose that quota type the same on mds and ost
558 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
559 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
560 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
561 export old_QUOTA_TYPE=$quota_type
562 quota_save_version $QUOTA_TYPE
563 $LFS quotacheck -ug $mntpt
566 local quota_usrs=$QUOTA_USERS
568 # get_filesystem_size
569 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
570 local blk_soft=$((disksz + 1024))
571 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
573 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
575 local i_hard=$((i_soft + i_soft / 20))
577 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
578 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
581 for usr in $quota_usrs; do
582 echo "Setting up quota on $client:$mntpt for $usr..."
584 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
586 eval $cmd || error "$cmd FAILED!"
588 # display the quota status
589 echo "Quota settings for $usr : "
590 $LFS quota -v -u $usr $mntpt || true
598 # Only supply -o to mount if we have options
599 if [ -n "$MOUNTOPT" ]; then
600 OPTIONS="-o $MOUNTOPT"
602 local device=$MGSNID:/$FSNAME
603 if [ -z "$mnt" -o -z "$FSNAME" ]; then
604 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
608 echo "Starting client: $client: $OPTIONS $device $mnt"
609 do_node $client mkdir -p $mnt
610 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
612 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
613 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
614 lctl set_param debug_mb=${DEBUG_SIZE}"
627 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
628 if [ $running -ne 0 ]; then
629 echo "Stopping client $client $mnt (opts:$force)"
630 do_node $client lsof -t $mnt || need_kill=no
631 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
632 pids=$(do_node $client lsof -t $mnt | sort -u);
633 if [ -n $pids ]; then
634 do_node $client kill -9 $pids || true
638 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
639 if [ $busy -ne 0 ] ; then
640 echo "$mnt is still busy, wait one second" && sleep 1
641 do_node $client umount $force $mnt
646 # nodes is comma list
647 sanity_mount_check_nodes () {
653 # FIXME: assume that all cluster nodes run the same os
654 [ "$(uname)" = Linux ] || return 0
657 for mnt in $mnts ; do
658 do_nodes $nodes "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
659 mpts=\\\$(mount | grep -w -c $mnt);
660 if [ \\\$running -ne \\\$mpts ]; then
661 echo \\\$(hostname) env are INSANE!;
669 sanity_mount_check_servers () {
670 echo Checking servers environments
672 # FIXME: modify get_facets to display all facets wo params
673 local facets="$(get_facets OST),$(get_facets MDS)"
677 for facet in ${facets//,/ }; do
678 node=$(facet_host ${facet})
679 mnt=${MOUNT%/*}/${facet}
680 sanity_mount_check_nodes $node $mnt ||
681 { error "server $node environments are insane!"; return 1; }
685 sanity_mount_check_clients () {
686 local clients=${1:-$CLIENTS}
687 local mntpt=${2:-$MOUNT}
688 local mntpt2=${3:-$MOUNT2}
690 [ -z $clients ] && clients=$(hostname)
691 echo Checking clients $clients environments
693 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
694 error "clients environments are insane!"
697 sanity_mount_check () {
698 sanity_mount_check_servers || return 1
699 sanity_mount_check_clients || return 2
702 # mount clients if not mouted
703 zconf_mount_clients() {
709 # Only supply -o to mount if we have options
710 if [ -n "$MOUNTOPT" ]; then
711 OPTIONS="-o $MOUNTOPT"
713 local device=$MGSNID:/$FSNAME
714 if [ -z "$mnt" -o -z "$FSNAME" ]; then
715 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
719 echo "Starting client $clients: $OPTIONS $device $mnt"
721 do_nodes $clients "set -x;
722 running=\\\$(mount | grep -c $mnt' ');
724 if [ \\\$running -eq 0 ] ; then
726 mount -t lustre $OPTIONS $device $mnt;
731 echo "Started clients $clients: "
732 do_nodes $clients "mount | grep -w $mnt"
734 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
735 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
736 lctl set_param debug_mb=${DEBUG_SIZE};"
741 zconf_umount_clients() {
748 echo "Stopping clients: $clients $mnt (opts:$force)"
749 do_nodes $clients "set -x; running=\\\$(grep -c $mnt' ' /proc/mounts);
750 if [ \\\$running -ne 0 ] ; then
751 echo Stopping client \\\$(hostname) client $mnt opts:$force;
752 lsof -t $mnt || need_kill=no;
753 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
754 pids=\\\$(lsof -t $mnt | sort -u);
755 if [ -n \\\"\\\$pids\\\" ]; then
759 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
760 if [ \\\$busy -ne 0 ] ; then
761 echo "$mnt is still busy, wait one second" && sleep 1;
767 shudown_node_hard () {
771 for i in $(seq $attempts) ; do
774 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
775 echo "waiting for $host to fail attempts=$attempts"
776 [ $i -lt $attempts ] || \
777 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
783 local mnt=${2:-$MOUNT}
786 if [ "$FAILURE_MODE" = HARD ]; then
787 shudown_node_hard $client
789 zconf_umount_clients $client $mnt -f
795 if [ "$FAILURE_MODE" = HARD ]; then
796 shudown_node_hard $(facet_active_host $facet)
797 elif [ "$FAILURE_MODE" = SOFT ]; then
804 if [ "$FAILURE_MODE" = HARD ]; then
805 $POWER_UP `facet_active_host $facet`
813 if [ "$FAILURE_MODE" = HARD ]; then
818 # recovery-scale functions
819 check_progs_installed () {
824 do_nodes $clients "set -x ; PATH=:$PATH status=true; for prog in $progs; do
825 which \\\$prog || { echo \\\$prog missing on \\\$(hostname) && status=false; }
831 echo __$(echo $1 | tr '-' 'X')
834 start_client_load() {
837 local var=$(client_var_name $client)_load
838 eval export ${var}=$load
840 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
841 BREAK_ON_ERROR=$BREAK_ON_ERROR \
842 END_RUN_FILE=$END_RUN_FILE \
843 LOAD_PID_FILE=$LOAD_PID_FILE \
844 TESTSUITELOG=$TESTSUITELOG \
846 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
847 log "Started client load: ${load} on $client"
852 start_client_loads () {
853 local -a clients=(${1//,/ })
854 local numloads=${#CLIENT_LOADS[@]}
857 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
858 testnum=$((nodenum % numloads))
859 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
863 # only for remote client
864 check_client_load () {
866 local var=$(client_var_name $client)_load
867 local TESTLOAD=run_${!var}.sh
869 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
871 check_catastrophe $client || return 2
873 # see if the load is still on the client
876 while [ $RC = 254 -a $tries -gt 0 ]; do
880 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
885 if [ $RC = 254 ]; then
886 echo "got a return status of $RC from do_node while checking (i.e. with 'ps') the client load on the remote system"
887 # see if we can diagnose a bit why this is
892 check_client_loads () {
893 local clients=${1//,/ }
897 for client in $clients; do
898 check_client_load $client
900 if [ "$rc" != 0 ]; then
901 log "Client load failed on node $client, rc=$rc"
907 restart_client_loads () {
908 local clients=${1//,/ }
909 local expectedfail=${2:-""}
913 for client in $clients; do
914 check_client_load $client
916 if [ "$rc" != 0 -a "$expectedfail" ]; then
917 start_client_load $client
918 echo "Restarted client load: on $client. Checking ..."
919 check_client_load $client
921 if [ "$rc" != 0 ]; then
922 log "Client load failed to restart on node $client, rc=$rc"
923 # failure one client load means test fail
924 # we do not need to check other
932 # End recovery-scale functions
934 # verify that lustre actually cleaned up properly
936 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
937 error "LBUG/LASSERT detected"
938 BUSY=`dmesg | grep -i destruct || true`
941 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
945 check_mem_leak || exit 204
947 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
948 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
950 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
951 echo "$0: modules still loaded..." 1>&2
967 while [ $WAIT -lt $MAX ]; do
968 RESULT=$(do_node $node "$TEST")
969 if [ "$RESULT" == "$FINAL" ]; then
970 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
973 echo "Waiting $((MAX - WAIT)) secs for update"
974 WAIT=$((WAIT + sleep))
977 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
981 wait_update_facet () {
983 wait_update $(facet_active_host $facet) "$@"
986 wait_delete_completed () {
987 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
988 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
992 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
994 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
995 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
996 [ "$TOTAL" -eq "$TOTALPREV" ] && break
997 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1001 echo "Delete completed."
1006 check_network "$host" 900
1007 while ! do_node $host "ls -d $LUSTRE " > /dev/null; do sleep 5; done
1012 local host=`facet_active_host $facet`
1016 wait_recovery_complete () {
1019 # Use default policy if $2 is not passed by caller.
1020 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1021 # as we are in process of changing obd_timeout in different ways
1022 # let's set MAX longer than that
1023 local MAX=${2:-$(( TIMEOUT * 4 ))}
1025 local var_svc=${facet}_svc
1026 local procfile="*.${!var_svc}.recovery_status"
1030 while [ $WAIT -lt $MAX ]; do
1031 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1032 [[ $STATUS = "status: COMPLETE" ]] && return 0
1035 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1037 echo "$facet recovery not done in $MAX sec. $STATUS"
1047 # conf-sanity 31 takes a long time cleanup
1048 while [ $WAIT -lt 300 ]; do
1049 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1050 [ -z "${running}" ] && return 0
1051 echo "waited $WAIT for${running}"
1052 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1054 WAIT=$((WAIT + INTERVAL))
1056 echo "service didn't stop after $WAIT seconds. Still running:"
1061 wait_remote_prog () {
1067 [ "$PDSH" = "no_dsh" ] && return 0
1069 while [ $WAIT -lt $2 ]; do
1070 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1071 [ -z "${running}" ] && return 0 || true
1072 echo "waited $WAIT for: "
1074 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1076 WAIT=$((WAIT + INTERVAL))
1078 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1079 [ -z "$pids" ] && return 0
1080 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1081 # FIXME: not portable
1082 for pid in $pids; do
1083 cat /proc/${pid}/status || true
1084 cat /proc/${pid}/wchan || true
1086 kill -9 $pid || true
1095 # not every config has many clients
1096 if [ ! -z "$CLIENTS" ]; then
1097 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1099 df $MOUNT > /dev/null
1103 client_reconnect() {
1104 uname -n >> $MOUNT/recon
1105 if [ -z "$CLIENTS" ]; then
1106 df $MOUNT; uname -n >> $MOUNT/recon
1108 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1110 echo Connected clients:
1112 ls -l $MOUNT/recon > /dev/null
1119 echo "Failing $facet on node `facet_active_host $facet`"
1120 shutdown_facet $facet
1121 [ -n "$sleep_time" ] && sleep $sleep_time
1125 echo "df pid is $DFPID"
1126 change_active $facet
1127 local TO=`facet_active_host $facet`
1128 echo "Failover $facet to $TO"
1130 mount_facet $facet || error "Restart of $facet failed"
1139 do_facet $facet sync
1141 local svc=${facet}_svc
1142 do_facet $facet $LCTL --device %${!svc} notransno
1143 do_facet $facet $LCTL --device %${!svc} readonly
1144 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1145 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1148 replay_barrier_nodf() {
1149 local facet=$1 echo running=${running}
1150 do_facet $facet sync
1151 local svc=${facet}_svc
1152 echo Replay barrier on ${!svc}
1153 do_facet $facet $LCTL --device %${!svc} notransno
1154 do_facet $facet $LCTL --device %${!svc} readonly
1155 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1156 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1159 replay_barrier_nosync() {
1160 local facet=$1 echo running=${running}
1161 local svc=${facet}_svc
1162 echo Replay barrier on ${!svc}
1163 do_facet $facet $LCTL --device %${!svc} notransno
1164 do_facet $facet $LCTL --device %${!svc} readonly
1165 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1166 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1169 mds_evict_client() {
1170 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1171 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1174 ost_evict_client() {
1175 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1176 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1180 facet_failover $* || error "failover: $?"
1181 df $MOUNT || error "post-failover df: $?"
1186 facet_failover $facet
1192 change_active $facet
1193 mount_facet $facet -o abort_recovery
1194 df $MOUNT || echo "first df failed: $?"
1196 df $MOUNT || error "post-failover df: $?"
1200 echo There is no lmc. This is mountconf, baby.
1205 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1206 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1212 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1218 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1219 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1220 if [ -z "$ID" ]; then
1221 echo "Could not get a ptl id for $1..."
1230 h2name_or_ip "$1" "tcp"
1235 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1236 if type __h2elan >/dev/null 2>&1; then
1239 ID=`echo $1 | sed 's/[^0-9]*//g'`
1247 h2name_or_ip "$1" "openib"
1249 declare -fx h2openib
1252 h2name_or_ip "$1" "o2ib"
1259 [ "$facet" == client ] && echo -n $HOSTNAME && return
1260 varname=${facet}_HOST
1261 if [ -z "${!varname}" ]; then
1262 if [ "${facet:0:3}" == "ost" ]; then
1263 eval ${facet}_HOST=${ost_HOST}
1271 local activevar=${facet}active
1273 if [ -f $TMP/${facet}active ] ; then
1274 source $TMP/${facet}active
1277 active=${!activevar}
1278 if [ -z "$active" ] ; then
1285 facet_active_host() {
1287 local active=`facet_active $facet`
1288 if [ "$facet" == client ]; then
1291 echo `facet_host $active`
1297 local failover=${facet}failover
1298 host=`facet_host $failover`
1299 [ -z "$host" ] && return
1300 local curactive=`facet_active $facet`
1301 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1302 eval export ${facet}active=$facet
1304 eval export ${facet}active=$failover
1306 # save the active host for this facet
1307 local activevar=${facet}active
1308 echo "$activevar=${!activevar}" > $TMP/$activevar
1315 if [ "$HOST" = "$HOSTNAME" ]; then
1317 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1318 echo "cannot run remote command on $HOST with $myPDSH"
1322 echo "CMD: $HOST $@" >&2
1323 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1326 if [ "$myPDSH" = "rsh" ]; then
1327 # we need this because rsh does not return exit code of an executed command
1328 local command_status="$TMP/cs"
1329 rsh $HOST ":> $command_status"
1330 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1331 cd $RPWD; sh -c \"$@\") ||
1332 echo command failed >$command_status"
1333 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1336 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1337 return ${PIPESTATUS[0]}
1340 single_local_node () {
1341 [ "$1" = "$HOSTNAME" ]
1348 if $(single_local_node $rnodes); then
1353 # This is part from do_node
1356 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1357 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1360 echo "CMD: $rnodes $@" >&2
1361 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1364 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1365 return ${PIPESTATUS[0]}
1371 local HOST=`facet_active_host $facet`
1372 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1379 # make sure its not already running
1381 rm -f $TMP/${facet}active
1382 do_facet ${facet} $MKFS $*
1388 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1389 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1396 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1397 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1405 # make sure we are using the primary server, so test-framework will
1406 # be able to clean up properly.
1407 activemds=`facet_active mds1`
1408 if [ $activemds != "mds1" ]; then
1412 local clients=$CLIENTS
1413 [ -z $clients ] && clients=$(hostname)
1415 zconf_umount_clients $clients $MOUNT "$*" || true
1416 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1418 [ "$CLIENTONLY" ] && return
1419 # The add fn does rm ${facet}active file, this would be enough
1420 # if we use do_facet <facet> only after the facet added, but
1421 # currently we use do_facet mds in local.sh
1422 for num in `seq $MDSCOUNT`; do
1424 rm -f ${TMP}/mds${num}active
1427 for num in `seq $OSTCOUNT`; do
1429 rm -f $TMP/ost${num}active
1444 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1448 if [ "$IAMDIR" == "yes" ]; then
1449 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1450 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1453 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1455 if [ ! -z $SEC ]; then
1456 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1457 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1458 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1462 # We need ldiskfs here, may as well load them all
1464 [ "$CLIENTONLY" ] && return
1465 echo "Formatting mdts, osts"
1466 for num in `seq $MDSCOUNT`; do
1467 echo "Format mds$num: $(mdsdevname $num)"
1469 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1471 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1475 for num in `seq $OSTCOUNT`; do
1476 echo "Format ost$num: $(ostdevname $num)"
1478 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1480 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1486 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1490 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1494 # 0: success, the old identity set already.
1495 # 1: success, the old identity does not set.
1500 local j=`expr $num - 1`
1501 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1503 if [ -z "$MDT" ]; then
1507 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1510 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1512 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1515 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1517 if [ $old = "NONE" ]; then
1526 zconf_umount `hostname` $1 || error "umount failed"
1527 zconf_mount `hostname` $1 || error "mount failed"
1530 writeconf_facet () {
1534 do_facet $facet "$TUNEFS --writeconf $dev"
1538 for num in `seq $MDSCOUNT`; do
1539 DEVNAME=$(mdsdevname $num)
1540 writeconf_facet mds$num $DEVNAME
1543 for num in `seq $OSTCOUNT`; do
1544 DEVNAME=$(ostdevname $num)
1545 writeconf_facet ost$num $DEVNAME
1550 sanity_mount_check ||
1551 error "environments are insane!"
1555 if [ -z "$CLIENTONLY" ]; then
1556 echo "Setup mdts, osts"
1557 echo $WRITECONF | grep -q "writeconf" && \
1559 for num in `seq $MDSCOUNT`; do
1560 DEVNAME=$(mdsdevname $num)
1561 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1563 # We started mds, now we should set failover variables properly.
1564 # Set mds${num}failover_HOST if it is not set (the default failnode).
1565 local varname=mds${num}failover_HOST
1566 if [ -z "${!varname}" ]; then
1567 eval mds${num}failover_HOST=$(facet_host mds$num)
1570 if [ $IDENTITY_UPCALL != "default" ]; then
1571 switch_identity $num $IDENTITY_UPCALL
1574 for num in `seq $OSTCOUNT`; do
1575 DEVNAME=$(ostdevname $num)
1576 start ost$num $DEVNAME $OST_MOUNT_OPTS
1578 # We started ost$num, now we should set ost${num}failover variable properly.
1579 # Set ost${num}failover_HOST if it is not set (the default failnode).
1580 varname=ost${num}failover_HOST
1581 if [ -z "${!varname}" ]; then
1582 eval ost${num}failover_HOST=$(facet_host ost${num})
1587 # wait a while to allow sptlrpc configuration be propogated to targets,
1588 # only needed when mounting new target devices.
1591 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1593 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1595 if [ "$MOUNT_2" ]; then
1596 mount_client $MOUNT2
1597 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1602 # by remounting mdt before ost, initial connect from mdt to ost might
1603 # timeout because ost is not ready yet. wait some time to its fully
1604 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1605 # by a context negotiation rpc with $TIMEOUT.
1606 # FIXME better by monitoring import status.
1608 sleep $((TIMEOUT + 5))
1614 mounted_lustre_filesystems() {
1615 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1618 init_facet_vars () {
1625 eval export ${facet}_dev=${device}
1626 eval export ${facet}_opt=\"$@\"
1628 local dev=${facet}_dev
1629 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1630 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1632 eval export ${facet}_svc=${label}
1634 local varname=${facet}failover_HOST
1635 if [ -z "${!varname}" ]; then
1636 eval $varname=$(facet_host $facet)
1639 # ${facet}failover_dev is set in cfg file
1640 varname=${facet}failover_dev
1641 if [ -n "${!varname}" ] ; then
1642 eval export ${facet}failover_dev=${!varname}
1644 eval export ${facet}failover_dev=$device
1648 init_facets_vars () {
1651 if ! remote_mds_nodsh; then
1652 for num in `seq $MDSCOUNT`; do
1653 DEVNAME=`mdsdevname $num`
1654 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1658 remote_ost_nodsh && return
1660 for num in `seq $OSTCOUNT`; do
1661 DEVNAME=`ostdevname $num`
1662 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1666 init_param_vars () {
1667 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1668 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1669 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1670 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1674 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1676 log "Using TIMEOUT=$TIMEOUT"
1678 if [ "$ENABLE_QUOTA" ]; then
1679 setup_quota $MOUNT || return 2
1685 local myMGS_host=$mgs_HOST
1686 if [ "$NETTYPE" = "ptl" ]; then
1687 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1690 echo Checking config lustre mounted on $mntpt
1691 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1692 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1694 if [ "$mgshost" != "$myMGS_host" ]; then
1695 FAIL_ON_ERROR=true \
1696 error "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1697 Please use correct config or set mds_HOST correctly!"
1700 sanity_mount_check ||
1701 error "environments are insane!"
1705 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1706 local cltimeout=$(lctl get_param -n timeout)
1707 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1708 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1713 check_and_setup_lustre() {
1714 local MOUNTED=$(mounted_lustre_filesystems)
1715 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1716 [ "$REFORMAT" ] && formatall
1718 MOUNTED=$(mounted_lustre_filesystems | head -1)
1719 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1720 export I_MOUNTED=yes
1726 if [ "$ONLY" == "setup" ]; then
1731 cleanup_and_setup_lustre() {
1732 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1733 lctl set_param debug=0 || true
1735 if [ "$ONLY" == "cleanup" ]; then
1739 check_and_setup_lustre
1742 check_and_cleanup_lustre() {
1743 if [ "`mount | grep $MOUNT`" ]; then
1744 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1745 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1747 if [ "$I_MOUNTED" = "yes" ]; then
1748 cleanupall -f || error "cleanup failed"
1760 while [ $NETWORK -eq 0 ]; do
1761 ping -c 1 -w 3 $1 > /dev/null
1762 if [ $? -eq 0 ]; then
1766 echo "waiting for $1, $((MAX - WAIT)) secs left"
1769 if [ $WAIT -gt $MAX ]; then
1770 echo "Network not available"
1776 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1787 # the sed converts spaces to commas, but leaves the last space
1788 # alone, so the line doesn't end with a comma.
1789 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1792 # list, excluded are the comma separated lists
1793 exclude_items_from_list () {
1799 for item in ${excluded//,/ }; do
1800 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1802 echo $(comma_list $list)
1805 # list, expand are the comma separated lists
1807 local list=${1//,/ }
1808 local expand=${2//,/ }
1811 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1812 echo $(comma_list $expanded)
1816 (cd `dirname $1`; echo $PWD/`basename $1`)
1820 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1821 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1824 local count=${type}COUNT
1825 for ((i=1; i<=${!count}; i++)) do
1826 list="$list ${name}$i"
1828 echo $(comma_list $list)
1831 ##################################
1832 # Adaptive Timeouts funcs
1835 if [ -z "$AT_MAX_PATH" ]; then
1836 AT_MAX_PATH=$(do_facet $SINGLEMDS "find /sys/ -name at_max")
1837 [ -z "$AT_MAX_PATH" ] && echo "missing /sys/.../at_max " && return 1
1843 at_is_valid || error "invalid call"
1845 # only check mds, we assume at_max is the same on all nodes
1846 local at_max=$(do_facet $SINGLEMDS "cat $AT_MAX_PATH")
1847 if [ $at_max -eq 0 ]; then
1857 at_is_valid || error "invalid call"
1859 # suppose that all ost-s has the same at_max set
1860 if [ $facet == "ost" ]; then
1861 do_facet ost1 "cat $AT_MAX_PATH"
1863 do_facet $facet "cat $AT_MAX_PATH"
1871 at_is_valid || error "invalid call"
1875 if [ $facet == "ost" ]; then
1876 for i in `seq $OSTCOUNT`; do
1877 do_facet ost$i "echo $at_max > $AT_MAX_PATH"
1879 elif [ $facet == "mds" ]; then
1880 for i in `seq $MDSCOUNT`; do
1881 do_facet mds$i "echo $at_max > $AT_MAX_PATH"
1884 do_facet $facet "echo $at_max > $AT_MAX_PATH"
1889 ##################################
1893 # OBD_FAIL_MDS_ALL_REQUEST_NET
1895 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
1896 do_facet client "$1" || RC=$?
1897 do_facet $SINGLEMDS lctl set_param fail_loc=0
1902 # OBD_FAIL_MDS_ALL_REPLY_NET
1904 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
1905 do_facet client "$@" || RC=$?
1906 do_facet $SINGLEMDS lctl set_param fail_loc=0
1910 drop_reint_reply() {
1911 # OBD_FAIL_MDS_REINT_NET_REP
1913 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
1914 do_facet client "$@" || RC=$?
1915 do_facet $SINGLEMDS lctl set_param fail_loc=0
1920 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
1922 do_facet ost1 lctl set_param fail_loc=0x214
1923 do_facet client "$1" || RC=$?
1924 do_facet client "sync"
1925 do_facet ost1 lctl set_param fail_loc=0
1929 drop_ldlm_cancel() {
1930 #define OBD_FAIL_LDLM_CANCEL 0x304
1932 do_facet client lctl set_param fail_loc=0x304
1933 do_facet client "$@" || RC=$?
1934 do_facet client lctl set_param fail_loc=0
1938 drop_bl_callback() {
1939 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
1941 do_facet client lctl set_param fail_loc=0x305
1942 do_facet client "$@" || RC=$?
1943 do_facet client lctl set_param fail_loc=0
1948 #define OBD_FAIL_LDLM_REPLY 0x30c
1950 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
1951 do_facet client "$@" || RC=$?
1952 do_facet $SINGLEMDS lctl set_param fail_loc=0
1960 echo "clearing fail_loc on $facet"
1961 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
1964 set_nodes_failloc () {
1968 for node in $nodes ; do
1969 do_node $node lctl set_param fail_loc=$2
1973 cancel_lru_locks() {
1974 $LCTL mark "cancel_lru_locks $1 start"
1975 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
1976 $LCTL set_param -n $d=clear
1978 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
1979 $LCTL mark "cancel_lru_locks $1 stop"
1984 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
1985 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
1986 echo "$DEFAULT_LRU_SIZE"
1991 lctl set_param ldlm.namespaces.*$1*.lru_size=0
1994 lru_resize_disable()
1996 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2001 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2002 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2003 echo there is still data in page cache $FILE ?
2004 lctl get_param -n $FILE
2012 DEBUGSAVE="$(lctl get_param -n debug)"
2016 [ -n "$DEBUGSAVE" ] && lctl set_param debug="${DEBUGSAVE}"
2020 ##################################
2022 ##################################
2025 local TYPE=${TYPE:-"FAIL"}
2027 lctl set_param fail_loc=0 2>/dev/null || true
2028 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2029 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2030 echo "Dumping lctl log to $ERRLOG"
2031 # We need to dump the logs on all nodes
2032 local NODES=$(nodes_list)
2033 for NODE in $NODES; do
2034 do_node $NODE $LCTL dk $ERRLOG
2037 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2043 $FAIL_ON_ERROR && exit 1 || true
2051 # use only if we are ignoring failures for this test, bugno required.
2052 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2053 # e.g. error_ignore 5494 "your message"
2055 local TYPE="IGNORE (bz$1)"
2062 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2063 [ "$TESTSUITELOG" ] && \
2064 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2067 build_test_filter() {
2068 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2072 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2073 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2074 [ "$EXCEPT_SLOW" ] && \
2075 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2076 for E in $EXCEPT $ALWAYS_EXCEPT; do
2077 eval EXCEPT_${E}=true
2079 for E in $EXCEPT_SLOW; do
2080 eval EXCEPT_SLOW_${E}=true
2082 for G in $GRANT_CHECK_LIST; do
2083 eval GCHECK_ONLY_${G}=true
2092 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
2095 # print a newline if the last test was skipped
2096 export LAST_SKIPPED=
2100 export base=`basetest $1`
2101 if [ ! -z "$ONLY" ]; then
2103 if [ ${!testname}x != x ]; then
2104 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2109 if [ ${!testname}x != x ]; then
2110 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2119 if [ ${!testname}x != x ]; then
2121 TESTNAME=test_$1 skip "skipping excluded test $1"
2124 testname=EXCEPT_$base
2125 if [ ${!testname}x != x ]; then
2127 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2130 testname=EXCEPT_SLOW_$1
2131 if [ ${!testname}x != x ]; then
2133 TESTNAME=test_$1 skip "skipping SLOW test $1"
2136 testname=EXCEPT_SLOW_$base
2137 if [ ${!testname}x != x ]; then
2139 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2149 EQUALS="======================================================================"
2153 local suffixlen=$((${#EQUALS} - ${#msg}))
2154 [ $suffixlen -lt 5 ] && suffixlen=5
2155 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2160 lsmod | grep lnet > /dev/null || load_modules
2172 local NODES=$(nodes_list)
2173 for NODE in $NODES; do
2174 do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
2180 strace -o $TMP/$1.strace -ttt $*
2182 log "FINISHED: $*: rc $RC"
2187 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2192 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2193 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2194 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2198 local myNODES=$(nodes_list)
2201 echo -n "Resetting fail_loc on all nodes..."
2202 for NODE in $myNODES; do
2203 do_node $NODE "lctl set_param -n fail_loc=0 2>/dev/null || true"
2212 export tdir=d0.${TESTSUITE}/d${base}
2214 local SAVE_UMASK=`umask`
2217 local BEFORE=`date +%s`
2219 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2221 export TESTNAME=test_$testnum
2223 test_${testnum} || error "test_$testnum failed with $?"
2227 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2228 check_catastrophe || error "LBUG/LASSERT detected"
2229 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2230 pass "($((`date +%s` - $BEFORE))s)"
2238 (cd `dirname $1`; echo $PWD/`basename $1`)
2242 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2243 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2248 export base=`basetest $1`
2249 [ "$CHECK_GRANT" == "no" ] && return 0
2251 testname=GCHECK_ONLY_${base}
2252 [ ${!testname}x == x ] && return 0
2254 echo -n "checking grant......"
2256 # write some data to sync client lost_grant
2257 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2258 for i in `seq $OSTCOUNT`; do
2259 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2260 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2261 count=1 > /dev/null 2>&1
2263 # sync all the data and make sure no pending data on server
2266 #get client grant and server grant
2268 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2269 client_grant=$((client_grant + $d))
2272 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2273 server_grant=$((server_grant + $d))
2276 # cleanup the check_grant file
2277 for i in `seq $OSTCOUNT`; do
2278 rm $DIR1/${tfile}_check_grant_$i
2281 #check whether client grant == server grant
2282 if [ $client_grant != $server_grant ]; then
2283 echo "failed: client:${client_grant} server: ${server_grant}"
2290 ########################
2296 ost=`echo $1 | awk -F_ '{print $3}'`
2297 if [ -z $ost ]; then
2298 ost=`echo $1 | sed 's/-osc.*//'`
2305 [ "$node" != "$(hostname)" ]
2311 for node in $(mdts_nodes); do
2312 remote_node $node && return 0
2319 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2325 for node in $(osts_nodes) ; do
2326 remote_node $node && return 0
2333 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2339 MGS=$(facet_host mgs)
2340 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2346 for num in `seq $MDSCOUNT`; do
2347 MDSNODES="$MDSNODES $(facet_host mds$num)"
2349 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2355 remote_ost && remote_mds
2359 local OSTNODES=$(facet_host ost1)
2362 for num in `seq $OSTCOUNT`; do
2363 local myOST=$(facet_host ost$num)
2364 OSTNODES="$OSTNODES $myOST"
2366 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2372 # FIXME. We need a list of clients
2373 local myNODES=$HOSTNAME
2376 # CLIENTS (if specified) contains the local client
2377 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2379 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2380 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2383 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2388 remote_nodes_list () {
2389 local rnodes=$(nodes_list)
2390 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2394 init_clients_lists () {
2395 # Sanity check: exclude the local client from RCLIENTS
2396 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2398 # Sanity check: exclude the dup entries
2399 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2401 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2403 # Sanity check: exclude the dup entries from CLIENTS
2404 # for those configs which has SINGLCLIENT set to local client
2405 clients=$(for i in $clients; do echo $i; done | sort -u)
2407 CLIENTS=`comma_list $clients`
2408 local -a remoteclients=($rclients)
2409 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2410 varname=CLIENT$((i + 2))
2411 eval $varname=${remoteclients[i]}
2414 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2417 get_random_entry () {
2420 rnodes=${rnodes//,/ }
2422 local -a nodes=($rnodes)
2423 local num=${#nodes[@]}
2424 local i=$((RANDOM * num * 2 / 65536))
2431 lctl get_param version | grep -q patchless
2435 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2440 echo $nodes | wc -w || true
2444 local nodes=$(osts_nodes)
2445 local osscount=$(get_node_count "$nodes")
2446 [ ! "$OSTCOUNT" = "$osscount" ]
2450 local nodes=$(mdts_nodes)
2451 local mdtcount=$(get_node_count "$nodes")
2452 [ ! "$MDSCOUNT" = "$mdtcount" ]
2455 generate_machine_file() {
2456 local nodes=${1//,/ }
2457 local machinefile=$2
2458 rm -f $machinefile || error "can't rm $machinefile"
2459 for node in $nodes; do
2460 echo $node >>$machinefile
2465 local file=$1/stripe
2467 $LFS getstripe -v $file || error
2471 check_runas_id_ret() {
2473 local myRUNAS_UID=$1
2474 local myRUNAS_GID=$2
2477 if [ -z "$myRUNAS" ]; then
2478 error_exit "myRUNAS command must be specified for check_runas_id"
2481 $myRUNAS krb5_login.sh || \
2482 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2484 mkdir $DIR/d0_runas_test
2486 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2487 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2488 rm -rf $DIR/d0_runas_test
2493 local myRUNAS_UID=$1
2494 local myRUNAS_GID=$2
2497 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2498 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2499 Please set RUNAS_ID to some UID which exists on MDS and client or
2500 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2503 # Run multiop in the background, but wait for it to print
2504 # "PAUSING" to its stdout before returning from this function.
2505 multiop_bg_pause() {
2506 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2510 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2513 echo "$MULTIOP_PROG $FILE v$ARGS"
2514 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2516 echo "TMPPIPE=${TMPPIPE}"
2517 read -t 60 multiop_output < $TMPPIPE
2518 if [ $? -ne 0 ]; then
2523 if [ "$multiop_output" != "PAUSING" ]; then
2524 echo "Incorrect multiop output: $multiop_output"
2532 inodes_available () {
2533 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2537 # reset llite stat counters
2538 clear_llite_stats(){
2539 lctl set_param -n llite.*.stats 0
2542 # sum llite stat items
2543 calc_llite_stats() {
2544 local res=$(lctl get_param -n llite.*.stats |
2545 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2549 # reset osc stat counters
2551 lctl set_param -n osc.*.osc_stats 0
2554 # sum osc stat items
2556 local res=$(lctl get_param -n osc.*.osc_stats |
2557 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2562 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2565 calc_osc_kbytes () {
2566 df $MOUNT > /dev/null
2567 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2570 # save_lustre_params(node, parameter_mask)
2571 # generate a stream of formatted strings (<node> <param name>=<param value>)
2572 save_lustre_params() {
2574 do_node $1 "lctl get_param $2" | while read s; do echo "$1 $s"; done
2577 # restore lustre parameters from input stream, produces by save_lustre_params
2578 restore_lustre_params() {
2582 while IFS=" =" read node name val; do
2583 do_node $node "lctl set_param -n $name $val"
2587 check_catastrophe() {
2588 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2589 local C=$CATASTROPHE
2590 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2592 if [ $rnodes ]; then
2593 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2594 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2610 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2612 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2613 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2614 stripe_index=`awk '/obdidx/ {start = 1; getline; print $1; exit}' $tmp_file`
2618 # CMD: determine mds index where directory inode presents
2621 local file=$dir/f0.get_mds_dir_tmpfile
2625 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2626 local oldused=($iused)
2630 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2631 local newused=($iused)
2634 for ((i=0; i<${#newused[@]}; i++)); do
2635 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2641 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2645 local mpirun="$MPIRUN $MPIRUN_OPTIONS"
2646 local command="$mpirun $@"
2647 local mpilog=$TMP/mpi.log
2650 if [ "$MPI_USER" != root -a $mpirun ]; then
2651 echo "+ chmod 0777 $MOUNT"
2653 command="su $MPI_USER sh -c \"$command \""
2658 eval $command 2>&1 > $mpilog || true
2661 if [ $rc -eq 0 ] && grep -q "p4_error: : [^0]" $mpilog ; then
2668 mdsrate_cleanup () {
2669 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2672 delayed_recovery_enabled () {
2673 local var=${SINGLEMDS}_svc
2674 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1