2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
20 #export PDSH="pdsh -S -Rssh -w"
22 # function used by scripts run on remote nodes
23 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
24 . $LUSTRE/tests/functions.sh
26 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
28 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
30 if [ -f "$EXCEPT_LIST_FILE" ]; then
31 echo "Reading test skip list from $EXCEPT_LIST_FILE"
38 [[ $DIR/ = $MOUNT/* ]] || \
39 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
40 [[ $DIR1/ = $MOUNT1/* ]] || \
41 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
42 [[ $DIR2/ = $MOUNT2/* ]] || \
43 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
45 [ -n "$failed" ] && exit 99 || true
49 echo "usage: $0 [-r] [-f cfgfile]"
57 [ "$TESTSUITE" == "lfscktest" ] && return 0
58 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
59 local form="%-13s %-17s %s\n"
60 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
61 echo "------------------------------------------------------------------------------------"
62 for O in $TESTSUITE_LIST; do
65 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
68 local log=${TMP}/${o}.log
69 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
70 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
71 [ "${!O}" = "done" ] && \
72 printf "$form" "Done" "$O" "E=$skipped" && \
73 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
77 for O in $TESTSUITE_LIST; do
78 if [ "${!O}" = "no" ]; then
80 # only for those tests suits which are run directly from acc-sm script:
81 # bonnie, iozone, etc.
82 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
83 printf "$form" "UNFINISHED" "$O" ""
85 printf "$form" "Skipped" "$O" ""
90 for O in $TESTSUITE_LIST; do
91 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
92 printf "$form" "UNFINISHED" "$O" ""
97 export LUSTRE=`absolute_path $LUSTRE`
98 export TESTSUITE=`basename $0 .sh`
99 export TEST_FAILED=false
100 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
102 export MKE2FS=${MKE2FS:-mke2fs}
103 export DEBUGFS=${DEBUGFS:-debugfs}
104 export TUNE2FS=${TUNE2FS:-tune2fs}
105 export E2LABEL=${E2LABEL:-e2label}
106 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
107 export E2FSCK=${E2FSCK:-e2fsck}
109 #[ -d /r ] && export ROOT=${ROOT:-/r}
110 export TMP=${TMP:-$ROOT/tmp}
111 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
112 export HOSTNAME=${HOSTNAME:-`hostname`}
113 if ! echo $PATH | grep -q $LUSTRE/utils; then
114 export PATH=$PATH:$LUSTRE/utils
116 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
117 export PATH=$PATH:$LUSTRE/utils/gss
119 if ! echo $PATH | grep -q $LUSTRE/tests; then
120 export PATH=$PATH:$LUSTRE/tests
122 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
123 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
124 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
125 export PATH=$PATH:$LUSTRE/tests/racer
127 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
128 export PATH=$PATH:$LUSTRE/tests/mpi
130 export RSYNC_RSH=${RSYNC_RSH:-rsh}
131 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
132 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
133 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
134 [ ! -f "$LFS" ] && export LFS=$(which lfs)
135 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
136 if [ ! -f "$L_GETIDENTITY" ]; then
137 if `which l_getidentity > /dev/null 2>&1`; then
138 export L_GETIDENTITY=$(which l_getidentity)
140 export L_GETIDENTITY=NONE
143 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
144 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
145 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
146 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
147 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
148 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
149 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
150 export FSTYPE=${FSTYPE:-"ldiskfs"}
151 export NAME=${NAME:-local}
152 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
153 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
154 export LGSSD=$(which lgssd)
155 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
156 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
157 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
159 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
162 if [ "$ACCEPTOR_PORT" ]; then
163 export PORT_OPT="--port $ACCEPTOR_PORT"
168 echo "Using GSS/krb5 ptlrpc security flavor"
169 which lgss_keyring > /dev/null 2>&1 || \
170 error "built with gss disabled! SEC=$SEC"
181 IDENTITY_UPCALL=false
184 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
186 # Paths on remote nodes, if different
187 export RLUSTRE=${RLUSTRE:-$LUSTRE}
188 export RPWD=${RPWD:-$PWD}
189 export I_MOUNTED=${I_MOUNTED:-"no"}
190 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
191 ! -f `dirname $0`/../mds/mds.ko ]; then
192 export CLIENTMODSONLY=yes
197 while getopts "rvwf:" opt $*; do
200 r) REFORMAT=--reformat;;
202 w) WRITECONF=writeconf;;
207 shift $((OPTIND - 1))
210 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
215 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
216 *) EXT=".ko"; USE_QUOTA=yes;;
221 /sbin/lsmod | grep -q $1
228 BASE=`basename $module $EXT`
230 module_loaded ${BASE} && return
232 if [ -f ${LUSTRE}/${module}${EXT} ]; then
233 insmod ${LUSTRE}/${module}${EXT} $@
235 # must be testing a "make install" or "rpm" installation
236 # note failed to load ptlrpc_gss is considered not fatal
237 if [ "$BASE" == "ptlrpc_gss" ]; then
238 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
245 load_modules_local() {
246 if [ -n "$MODPROBE" ]; then
250 if [ "$HAVE_MODULES" = true ]; then
256 echo Loading modules from $LUSTRE
257 load_module ../libcfs/libcfs/libcfs
258 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
259 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
261 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
262 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
263 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
264 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
265 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
266 echo "lnet options: '$LNETOPTS'"
267 # note that insmod will ignore anything in modprobe.conf
268 load_module ../lnet/lnet/lnet $LNETOPTS
269 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
270 load_module ../lnet/klnds/$LNETLND
271 load_module lvfs/lvfs
272 load_module obdclass/obdclass
273 load_module ptlrpc/ptlrpc
274 load_module ptlrpc/gss/ptlrpc_gss
275 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
283 if ! client_only; then
284 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
285 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
286 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
291 load_module lvfs/fsfilt_$FSTYPE
295 load_module obdfilter/obdfilter
298 load_module llite/lustre
299 load_module llite/llite_lloop
300 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
302 rm -f $OGDB/ogdb-$HOSTNAME
303 $LCTL modules > $OGDB/ogdb-$HOSTNAME
305 # 'mount' doesn't look in $PATH, just sbin
306 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
312 # load modules on remote nodes optionally
313 # lustre-tests have to be installed on these nodes
314 if $LOAD_MODULES_REMOTE ; then
315 local list=$(comma_list $(remote_nodes_list))
316 echo loading modules on $list
317 do_rpc_nodes $list load_modules
322 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
323 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
324 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
325 echo "$LEAK_LUSTRE" 1>&2
326 echo "$LEAK_PORTALS" 1>&2
327 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
328 echo "Memory leaks detected"
329 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
335 wait_exit_ST client # bug 12845
337 $LUSTRE_RMMOD $FSTYPE || return 2
339 if $LOAD_MODULES_REMOTE ; then
340 local list=$(comma_list $(remote_nodes_list))
341 echo unloading modules on $list
342 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
343 do_rpc_nodes $list check_mem_leak
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 # add an additional parameter if mountpoint is ever different from $MOUNT
519 quota_save_version() {
520 local fsname=${2:-$FSNAME}
522 local ver=$(tr -c -d "123" <<< $spec)
523 local type=$(tr -c -d "ug" <<< $spec)
525 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
527 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
529 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
531 local osts=$(get_facets OST)
532 for ost in ${osts//,/ }; do
534 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
538 # client could mount several lustre
540 local fsname=${1:-$FSNAME}
542 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
543 do_nodes $(comma_list $(osts_nodes)) \
544 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
548 restore_quota_type () {
549 local mntpt=${1:-$MOUNT}
550 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
551 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
554 quota_save_version $old_QUOTA_TYPE
560 # We need save the original quota_type params, and restore them after testing
562 # Suppose that quota type the same on mds and ost
563 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
564 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
565 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
566 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
567 export old_QUOTA_TYPE=$quota_type
568 quota_save_version $QUOTA_TYPE
570 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
571 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
574 local quota_usrs=$QUOTA_USERS
576 # get_filesystem_size
577 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
578 local blk_soft=$((disksz + 1024))
579 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
581 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
583 local i_hard=$((i_soft + i_soft / 20))
585 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
586 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
589 for usr in $quota_usrs; do
590 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
592 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
594 eval $cmd || error "$cmd FAILED!"
596 # display the quota status
597 echo "Quota settings for $usr : "
598 $LFS quota -v -u $usr $mntpt || true
606 # Only supply -o to mount if we have options
607 if [ -n "$MOUNTOPT" ]; then
608 OPTIONS="-o $MOUNTOPT"
610 local device=$MGSNID:/$FSNAME
611 if [ -z "$mnt" -o -z "$FSNAME" ]; then
612 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
616 echo "Starting client: $client: $OPTIONS $device $mnt"
617 do_node $client mkdir -p $mnt
618 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
620 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
621 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
622 lctl set_param debug_mb=${DEBUG_SIZE}"
635 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
636 if [ $running -ne 0 ]; then
637 echo "Stopping client $client $mnt (opts:$force)"
638 do_node $client lsof -t $mnt || need_kill=no
639 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
640 pids=$(do_node $client lsof -t $mnt | sort -u);
641 if [ -n $pids ]; then
642 do_node $client kill -9 $pids || true
646 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
647 if [ $busy -ne 0 ] ; then
648 echo "$mnt is still busy, wait one second" && sleep 1
649 do_node $client umount $force $mnt
654 # nodes is comma list
655 sanity_mount_check_nodes () {
661 # FIXME: assume that all cluster nodes run the same os
662 [ "$(uname)" = Linux ] || return 0
665 for mnt in $mnts ; do
666 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
667 mpts=\\\$(mount | grep -w -c $mnt);
668 if [ \\\$running -ne \\\$mpts ]; then
669 echo \\\$(hostname) env are INSANE!;
677 sanity_mount_check_servers () {
679 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
680 echo Checking servers environments
682 # FIXME: modify get_facets to display all facets wo params
683 local facets="$(get_facets OST),$(get_facets MDS),mgs"
687 for facet in ${facets//,/ }; do
688 node=$(facet_host ${facet})
689 mnt=${MOUNT%/*}/${facet}
690 sanity_mount_check_nodes $node $mnt ||
691 { error "server $node environments are insane!"; return 1; }
695 sanity_mount_check_clients () {
696 local clients=${1:-$CLIENTS}
697 local mntpt=${2:-$MOUNT}
698 local mntpt2=${3:-$MOUNT2}
700 [ -z $clients ] && clients=$(hostname)
701 echo Checking clients $clients environments
703 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
704 error "clients environments are insane!"
707 sanity_mount_check () {
708 sanity_mount_check_servers || return 1
709 sanity_mount_check_clients || return 2
712 # mount clients if not mouted
713 zconf_mount_clients() {
716 local OPTIONS=${3:-$MOUNTOPT}
718 # Only supply -o to mount if we have options
719 if [ "$OPTIONS" ]; then
720 OPTIONS="-o $OPTIONS"
722 local device=$MGSNID:/$FSNAME
723 if [ -z "$mnt" -o -z "$FSNAME" ]; then
724 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
728 echo "Starting client $clients: $OPTIONS $device $mnt"
731 running=\\\$(mount | grep -c $mnt' ');
733 if [ \\\$running -eq 0 ] ; then
735 mount -t lustre $OPTIONS $device $mnt;
738 exit \\\$rc" || return ${PIPESTATUS[0]}
740 echo "Started clients $clients: "
741 do_nodes $clients "mount | grep -w $mnt"
743 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
744 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
745 lctl set_param debug_mb=${DEBUG_SIZE};"
750 zconf_umount_clients() {
757 echo "Stopping clients: $clients $mnt (opts:$force)"
758 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
759 if [ \\\$running -ne 0 ] ; then
760 echo Stopping client \\\$(hostname) $mnt opts:$force;
761 lsof -t $mnt || need_kill=no;
762 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
763 pids=\\\$(lsof -t $mnt | sort -u);
764 if [ -n \\\"\\\$pids\\\" ]; then
768 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
769 if [ \\\$busy -ne 0 ] ; then
770 echo "$mnt is still busy, wait one second" && sleep 1;
776 shudown_node_hard () {
780 for i in $(seq $attempts) ; do
783 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
784 echo "waiting for $host to fail attempts=$attempts"
785 [ $i -lt $attempts ] || \
786 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
792 local mnt=${2:-$MOUNT}
795 if [ "$FAILURE_MODE" = HARD ]; then
796 shudown_node_hard $client
798 zconf_umount_clients $client $mnt -f
804 if [ "$FAILURE_MODE" = HARD ]; then
805 shudown_node_hard $(facet_active_host $facet)
806 elif [ "$FAILURE_MODE" = SOFT ]; then
813 if [ "$FAILURE_MODE" = HARD ]; then
814 $POWER_UP `facet_active_host $facet`
822 if [ "$FAILURE_MODE" = HARD ]; then
828 # recovery-scale functions
829 check_progs_installed () {
834 do_nodes $clients "PATH=:$PATH; status=true;
835 for prog in $progs; do
836 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
837 echo \\\$prog missing on \\\$(hostname);
845 echo __$(echo $1 | tr '-' 'X')
848 start_client_load() {
851 local var=$(client_var_name $client)_load
852 eval export ${var}=$load
854 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
855 BREAK_ON_ERROR=$BREAK_ON_ERROR \
856 END_RUN_FILE=$END_RUN_FILE \
857 LOAD_PID_FILE=$LOAD_PID_FILE \
858 TESTSUITELOG=$TESTSUITELOG \
860 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
861 log "Started client load: ${load} on $client"
866 start_client_loads () {
867 local -a clients=(${1//,/ })
868 local numloads=${#CLIENT_LOADS[@]}
871 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
872 testnum=$((nodenum % numloads))
873 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
877 # only for remote client
878 check_client_load () {
880 local var=$(client_var_name $client)_load
881 local TESTLOAD=run_${!var}.sh
883 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
885 # bug 18914: try to connect several times not only when
886 # check ps, but while check_catastrophe also
889 while [ $RC = 254 -a $tries -gt 0 ]; do
893 if ! check_catastrophe $client; then
895 if [ $RC -eq 254 ]; then
896 # FIXME: not sure how long we shuold sleep here
900 echo "check catastrophe failed: RC=$RC "
904 # We can continue try to connect if RC=254
905 # Just print the warning about this
906 if [ $RC = 254 ]; then
907 echo "got a return status of $RC from do_node while checking catastrophe on $client"
910 # see if the load is still on the client
913 while [ $RC = 254 -a $tries -gt 0 ]; do
917 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
922 if [ $RC = 254 ]; then
923 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
924 # see if we can diagnose a bit why this is
929 check_client_loads () {
930 local clients=${1//,/ }
934 for client in $clients; do
935 check_client_load $client
937 if [ "$rc" != 0 ]; then
938 log "Client load failed on node $client, rc=$rc"
944 restart_client_loads () {
945 local clients=${1//,/ }
946 local expectedfail=${2:-""}
950 for client in $clients; do
951 check_client_load $client
953 if [ "$rc" != 0 -a "$expectedfail" ]; then
954 local var=$(client_var_name $client)_load
955 start_client_load $client ${!var}
956 echo "Restarted client load ${!var}: on $client. Checking ..."
957 check_client_load $client
959 if [ "$rc" != 0 ]; then
960 log "Client load failed to restart on node $client, rc=$rc"
961 # failure one client load means test fail
962 # we do not need to check other
970 # End recovery-scale functions
972 # verify that lustre actually cleaned up properly
974 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
975 error "LBUG/LASSERT detected"
976 BUSY=`dmesg | grep -i destruct || true`
979 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
983 check_mem_leak || exit 204
985 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
986 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
988 if module_loaded lnet || module_loaded libcfs; then
989 echo "$0: modules still loaded..." 1>&2
1006 RESULT=$(do_node $node "$TEST")
1007 if [ "$RESULT" == "$FINAL" ]; then
1008 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1011 [ $WAIT -ge $MAX ] && break
1012 echo "Waiting $((MAX - WAIT)) secs for update"
1013 WAIT=$((WAIT + sleep))
1016 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1020 wait_update_facet () {
1022 wait_update $(facet_active_host $facet) "$@"
1025 wait_delete_completed () {
1026 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1027 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1031 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1033 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1034 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1035 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1036 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1040 echo "Delete is not completed in $MAX_WAIT sec"
1046 check_network "$host" 900
1047 while ! do_node $host hostname > /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"
1081 wait_mds_ost_sync () {
1082 # just because recovery is done doesn't mean we've finished
1083 # orphan cleanup. Wait for llogs to get synchronized.
1084 echo "Waiting for orphan cleanup..."
1085 # MAX value includes time needed for MDS-OST reconnection
1086 local MAX=$(( TIMEOUT * 2 ))
1088 while [ $WAIT -lt $MAX ]; do
1089 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1090 "$LCTL get_param -n obdfilter.*.mds_sync"))
1092 for ((i=0; i<${#sync[@]}; i++)); do
1093 [ ${sync[$i]} -eq 0 ] && continue
1094 # there is a not finished MDS-OST synchronization
1098 sleep 2 # increase waiting time and cover statfs cache
1099 [ ${con} -eq 1 ] && return 0
1100 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1103 echo "$facet recovery not done in $MAX sec. $STATUS"
1107 wait_destroy_complete () {
1108 echo "Waiting for destroy to be done..."
1109 # MAX value shouldn't be big as this mean server responsiveness
1110 # never increase this just to make test pass but investigate
1111 # why it takes so long time
1114 while [ $WAIT -lt $MAX ]; do
1115 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1117 for ((i=0; i<${#RPCs[@]}; i++)); do
1118 [ ${RPCs[$i]} -eq 0 ] && continue
1119 # there are still some destroy RPCs in flight
1124 [ ${con} -eq 1 ] && return 0 # done waiting
1125 echo "Waiting $WAIT secs for destroys to be done."
1128 echo "Destroys weren't done in $MAX sec."
1138 # conf-sanity 31 takes a long time cleanup
1139 while [ $WAIT -lt 300 ]; do
1140 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1141 [ -z "${running}" ] && return 0
1142 echo "waited $WAIT for${running}"
1143 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1145 WAIT=$((WAIT + INTERVAL))
1147 echo "service didn't stop after $WAIT seconds. Still running:"
1152 wait_remote_prog () {
1158 [ "$PDSH" = "no_dsh" ] && return 0
1160 while [ $WAIT -lt $2 ]; do
1161 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1162 [ -z "${running}" ] && return 0 || true
1163 echo "waited $WAIT for: "
1165 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1167 WAIT=$((WAIT + INTERVAL))
1169 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1170 [ -z "$pids" ] && return 0
1171 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1172 # FIXME: not portable
1173 for pid in $pids; do
1174 cat /proc/${pid}/status || true
1175 cat /proc/${pid}/wchan || true
1177 kill -9 $pid || true
1186 # not every config has many clients
1188 if [ ! -z "$CLIENTS" ]; then
1189 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1191 stat -f $MOUNT > /dev/null
1197 # usually checked on particular client or locally
1199 if [ ! -z "$client" ]; then
1200 $PDSH $client "stat -f $MOUNT" > /dev/null
1202 stat -f $MOUNT > /dev/null
1210 client_reconnect() {
1211 uname -n >> $MOUNT/recon
1212 if [ -z "$CLIENTS" ]; then
1213 df $MOUNT; uname -n >> $MOUNT/recon
1215 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1217 echo Connected clients:
1219 ls -l $MOUNT/recon > /dev/null
1226 echo "Failing $facet on node `facet_active_host $facet`"
1227 shutdown_facet $facet
1228 [ -n "$sleep_time" ] && sleep $sleep_time
1230 change_active $facet
1231 local TO=`facet_active_host $facet`
1232 echo "Failover $facet to $TO"
1234 mount_facet $facet || error "Restart of $facet failed"
1243 do_facet $facet sync
1245 local svc=${facet}_svc
1246 do_facet $facet $LCTL --device %${!svc} notransno
1247 do_facet $facet $LCTL --device %${!svc} readonly
1248 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1249 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1252 replay_barrier_nodf() {
1253 local facet=$1 echo running=${running}
1254 do_facet $facet sync
1255 local svc=${facet}_svc
1256 echo Replay barrier on ${!svc}
1257 do_facet $facet $LCTL --device %${!svc} notransno
1258 do_facet $facet $LCTL --device %${!svc} readonly
1259 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1260 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1263 replay_barrier_nosync() {
1264 local facet=$1 echo running=${running}
1265 local svc=${facet}_svc
1266 echo Replay barrier on ${!svc}
1267 do_facet $facet $LCTL --device %${!svc} notransno
1268 do_facet $facet $LCTL --device %${!svc} readonly
1269 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1270 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1273 mds_evict_client() {
1274 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1275 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1278 ost_evict_client() {
1279 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1280 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1284 facet_failover $* || error "failover: $?"
1285 clients_up || error "post-failover df: $?"
1290 facet_failover $facet
1296 change_active $facet
1297 mount_facet $facet -o abort_recovery
1298 clients_up || echo "first df failed: $?"
1299 clients_up || error "post-failover df: $?"
1303 echo There is no lmc. This is mountconf, baby.
1308 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1309 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1315 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1321 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1322 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1323 if [ -z "$ID" ]; then
1324 echo "Could not get a ptl id for $1..."
1333 h2name_or_ip "$1" "tcp"
1338 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1339 if type __h2elan >/dev/null 2>&1; then
1342 ID=`echo $1 | sed 's/[^0-9]*//g'`
1350 h2name_or_ip "$1" "openib"
1352 declare -fx h2openib
1355 h2name_or_ip "$1" "o2ib"
1362 [ "$facet" == client ] && echo -n $HOSTNAME && return
1363 varname=${facet}_HOST
1364 if [ -z "${!varname}" ]; then
1365 if [ "${facet:0:3}" == "ost" ]; then
1366 eval ${facet}_HOST=${ost_HOST}
1374 local activevar=${facet}active
1376 if [ -f $TMP/${facet}active ] ; then
1377 source $TMP/${facet}active
1380 active=${!activevar}
1381 if [ -z "$active" ] ; then
1388 facet_active_host() {
1390 local active=`facet_active $facet`
1391 if [ "$facet" == client ]; then
1394 echo `facet_host $active`
1400 local failover=${facet}failover
1401 host=`facet_host $failover`
1402 [ -z "$host" ] && return
1403 local curactive=`facet_active $facet`
1404 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1405 eval export ${facet}active=$facet
1407 eval export ${facet}active=$failover
1409 # save the active host for this facet
1410 local activevar=${facet}active
1411 echo "$activevar=${!activevar}" > $TMP/$activevar
1416 # do not stripe off hostname if verbose, bug 19215
1417 if [ x$1 = x--verbose ]; then
1425 if [ "$HOST" = "$HOSTNAME" ]; then
1427 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1428 echo "cannot run remote command on $HOST with $myPDSH"
1432 echo "CMD: $HOST $@" >&2
1433 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1436 if [ "$myPDSH" = "rsh" ]; then
1437 # we need this because rsh does not return exit code of an executed command
1438 local command_status="$TMP/cs"
1439 rsh $HOST ":> $command_status"
1440 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1441 cd $RPWD; sh -c \"$@\") ||
1442 echo command failed >$command_status"
1443 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1448 # print HOSTNAME for myPDSH="no_dsh"
1449 if [[ $myPDSH = no_dsh ]]; then
1450 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1452 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1455 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1457 return ${PIPESTATUS[0]}
1460 single_local_node () {
1461 [ "$1" = "$HOSTNAME" ]
1466 # do not stripe off hostname if verbose, bug 19215
1467 if [ x$1 = x--verbose ]; then
1475 if $(single_local_node $rnodes); then
1477 do_node --verbose $rnodes $@
1484 # This is part from do_node
1487 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1488 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1491 echo "CMD: $rnodes $@" >&2
1492 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1496 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1498 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1500 return ${PIPESTATUS[0]}
1506 local HOST=`facet_active_host $facet`
1507 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1514 # make sure its not already running
1516 rm -f $TMP/${facet}active
1517 do_facet ${facet} $MKFS $*
1523 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1524 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1531 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1532 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1540 # make sure we are using the primary server, so test-framework will
1541 # be able to clean up properly.
1542 activemds=`facet_active mds1`
1543 if [ $activemds != "mds1" ]; then
1547 local clients=$CLIENTS
1548 [ -z $clients ] && clients=$(hostname)
1550 zconf_umount_clients $clients $MOUNT "$*" || true
1551 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1553 [ "$CLIENTONLY" ] && return
1554 # The add fn does rm ${facet}active file, this would be enough
1555 # if we use do_facet <facet> only after the facet added, but
1556 # currently we use do_facet mds in local.sh
1557 for num in `seq $MDSCOUNT`; do
1559 rm -f ${TMP}/mds${num}active
1562 for num in `seq $OSTCOUNT`; do
1564 rm -f $TMP/ost${num}active
1571 nfs_client_mode && return
1581 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1585 if [ "$IAMDIR" == "yes" ]; then
1586 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1587 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1590 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1592 if [ ! -z $SEC ]; then
1593 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1594 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1595 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1599 # We need ldiskfs here, may as well load them all
1601 [ "$CLIENTONLY" ] && return
1602 echo Formatting mgs, mds, osts
1603 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1604 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1607 for num in `seq $MDSCOUNT`; do
1608 echo "Format mds$num: $(mdsdevname $num)"
1610 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1612 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1616 for num in `seq $OSTCOUNT`; do
1617 echo "Format ost$num: $(ostdevname $num)"
1619 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1621 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1627 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1631 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1635 # 0: success, the old identity set already.
1636 # 1: success, the old identity does not set.
1641 local j=`expr $num - 1`
1642 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1644 if [ -z "$MDT" ]; then
1648 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1651 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1653 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1656 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1658 if [ $old = "NONE" ]; then
1667 zconf_umount `hostname` $1 || error "umount failed"
1668 zconf_mount `hostname` $1 || error "mount failed"
1671 writeconf_facet () {
1675 do_facet $facet "$TUNEFS --writeconf $dev"
1679 for num in `seq $MDSCOUNT`; do
1680 DEVNAME=$(mdsdevname $num)
1681 writeconf_facet mds$num $DEVNAME
1684 for num in `seq $OSTCOUNT`; do
1685 DEVNAME=$(ostdevname $num)
1686 writeconf_facet ost$num $DEVNAME
1691 nfs_client_mode && return
1693 sanity_mount_check ||
1694 error "environments are insane!"
1698 if [ -z "$CLIENTONLY" ]; then
1699 echo Setup mgs, mdt, osts
1700 echo $WRITECONF | grep -q "writeconf" && \
1702 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1703 start mgs $MGSDEV $mgs_MOUNT_OPTS
1706 for num in `seq $MDSCOUNT`; do
1707 DEVNAME=$(mdsdevname $num)
1708 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1710 # We started mds, now we should set failover variables properly.
1711 # Set mds${num}failover_HOST if it is not set (the default failnode).
1712 local varname=mds${num}failover_HOST
1713 if [ -z "${!varname}" ]; then
1714 eval mds${num}failover_HOST=$(facet_host mds$num)
1717 if [ $IDENTITY_UPCALL != "default" ]; then
1718 switch_identity $num $IDENTITY_UPCALL
1721 for num in `seq $OSTCOUNT`; do
1722 DEVNAME=$(ostdevname $num)
1723 start ost$num $DEVNAME $OST_MOUNT_OPTS
1725 # We started ost$num, now we should set ost${num}failover variable properly.
1726 # Set ost${num}failover_HOST if it is not set (the default failnode).
1727 varname=ost${num}failover_HOST
1728 if [ -z "${!varname}" ]; then
1729 eval ost${num}failover_HOST=$(facet_host ost${num})
1734 # wait a while to allow sptlrpc configuration be propogated to targets,
1735 # only needed when mounting new target devices.
1738 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1740 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1742 if [ "$MOUNT_2" ]; then
1743 mount_client $MOUNT2
1744 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1749 # by remounting mdt before ost, initial connect from mdt to ost might
1750 # timeout because ost is not ready yet. wait some time to its fully
1751 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1752 # by a context negotiation rpc with $TIMEOUT.
1753 # FIXME better by monitoring import status.
1755 sleep $((TIMEOUT + 5))
1761 mounted_lustre_filesystems() {
1762 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1765 init_facet_vars () {
1766 [ "$CLIENTONLY" ] && return 0
1773 eval export ${facet}_dev=${device}
1774 eval export ${facet}_opt=\"$@\"
1776 local dev=${facet}_dev
1777 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1778 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1780 eval export ${facet}_svc=${label}
1782 local varname=${facet}failover_HOST
1783 if [ -z "${!varname}" ]; then
1784 eval $varname=$(facet_host $facet)
1787 # ${facet}failover_dev is set in cfg file
1788 varname=${facet}failover_dev
1789 if [ -n "${!varname}" ] ; then
1790 eval export ${facet}failover_dev=${!varname}
1792 eval export ${facet}failover_dev=$device
1796 init_facets_vars () {
1799 if ! remote_mds_nodsh; then
1800 for num in `seq $MDSCOUNT`; do
1801 DEVNAME=`mdsdevname $num`
1802 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1806 remote_ost_nodsh && return
1808 for num in `seq $OSTCOUNT`; do
1809 DEVNAME=`ostdevname $num`
1810 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1814 osc_ensure_active () {
1820 while [ $period -lt $timeout ]; do
1821 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1822 if [ $count -eq 0 ]; then
1826 echo "There are $count OST are inactive, wait $period seconds, and try again"
1828 period=$((period+3))
1831 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1835 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1839 init_param_vars () {
1840 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1841 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1842 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1843 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1847 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1849 log "Using TIMEOUT=$TIMEOUT"
1851 osc_ensure_active $SINGLEMDS M $TIMEOUT
1852 osc_ensure_active client c $TIMEOUT
1854 if [ x"$(som_check)" = x"enabled" ]; then
1856 echo "disable quota temporary when SOM enabled"
1858 if [ $QUOTA_AUTO -ne 0 ]; then
1859 if [ "$ENABLE_QUOTA" ]; then
1860 echo "enable quota as required"
1861 setup_quota $MOUNT || return 2
1863 echo "disable quota as required"
1864 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1871 nfs_client_mode () {
1872 if [ "$NFSCLIENT" ]; then
1873 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1874 local clients=$CLIENTS
1875 [ -z $clients ] && clients=$(hostname)
1877 # FIXME: remove hostname when 19215 fixed
1878 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1879 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1880 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1886 check_config_client () {
1889 local mounted=$(mount | grep " $mntpt ")
1890 if [ "$CLIENTONLY" ]; then
1892 # CLIENTONLY should not depend on *_HOST settings
1893 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1894 # in theory someone could create a new,
1895 # client-only config file that assumed lustre was already
1896 # configured and didn't set the MGSNID. If MGSNID is not set,
1897 # then we should use the mgs nid currently being used
1898 # as the default value. bug 18021
1899 [[ x$MGSNID = x ]] &&
1902 if [[ x$mgc != xMGC$MGSNID ]]; then
1903 if [ "$mgs_HOST" ]; then
1904 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1905 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1906 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1912 local myMGS_host=$mgs_HOST
1913 if [ "$NETTYPE" = "ptl" ]; then
1914 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1917 echo Checking config lustre mounted on $mntpt
1918 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1919 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1921 # if [ "$mgshost" != "$myMGS_host" ]; then
1922 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1923 # Please use correct config or set mds_HOST correctly!"
1928 check_config_clients () {
1929 local clients=${CLIENTS:-$HOSTNAME}
1932 nfs_client_mode && return
1934 do_rpc_nodes $clients check_config_client $mntpt
1936 sanity_mount_check ||
1937 error "environments are insane!"
1941 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1942 local cltimeout=$(lctl get_param -n timeout)
1943 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1944 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1951 local mounted=$(mounted_lustre_filesystems)
1953 echo $mounted' ' | grep -w -q $mntpt' '
1956 check_and_setup_lustre() {
1957 nfs_client_mode && return
1959 local MOUNTED=$(mounted_lustre_filesystems)
1963 # both MOUNT and MOUNT2 are not mounted
1964 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
1965 [ "$REFORMAT" ] && formatall
1966 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
1968 is_mounted $MOUNT || error "NAME=$NAME not mounted"
1969 export I_MOUNTED=yes
1973 elif is_mounted $MOUNT2; then
1975 # MOUNT2 is mounted, while MOUNT_2 is not set
1976 if ! [ "$MOUNT_2" ]; then
1977 cleanup_mount $MOUNT2
1978 export I_UMOUNTED2=yes
1981 # MOUNT2 is mounted, MOUNT_2 is set
1983 # FIXME: what to do if check_config failed?
1985 # 1) remote client has mounted other Lustre fs ?
1986 # 2) it has insane env ?
1987 # let's try umount MOUNT2 on all clients and mount it again:
1988 if ! check_config_clients $MOUNT2; then
1989 cleanup_mount $MOUNT2
1990 restore_mount $MOUNT2
1991 export I_MOUNTED2=yes
1996 # MOUNT is mounted MOUNT2 is not mounted
1997 elif [ "$MOUNT_2" ]; then
1998 restore_mount $MOUNT2
1999 export I_MOUNTED2=yes
2003 # FIXME: what to do if check_config failed?
2005 # 1) remote client has mounted other Lustre fs?
2006 # 2) lustre is mounted on remote_clients atall ?
2007 check_config_clients $MOUNT
2011 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2012 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2013 lctl set_param debug_mb=${DEBUG_SIZE};
2016 if [ "$ONLY" == "setup" ]; then
2022 local clients=${CLIENTS:-$HOSTNAME}
2025 zconf_mount_clients $clients $mntpt
2029 local clients=${CLIENTS:-$HOSTNAME}
2032 zconf_umount_clients $clients $mntpt
2035 cleanup_and_setup_lustre() {
2036 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2037 lctl set_param debug=0 || true
2039 if [ "$ONLY" == "cleanup" ]; then
2043 check_and_setup_lustre
2046 check_and_cleanup_lustre() {
2047 if is_mounted $MOUNT; then
2048 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2049 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2052 if [ "$I_UMOUNTED2" = "yes" ]; then
2053 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2056 if [ "$I_MOUNTED2" = "yes" ]; then
2057 cleanup_mount $MOUNT2
2060 if [ "$I_MOUNTED" = "yes" ]; then
2061 cleanupall -f || error "cleanup failed"
2073 while [ $NETWORK -eq 0 ]; do
2074 if ping -c 1 -w 3 $1 > /dev/null; then
2078 echo "waiting for $1, $((MAX - WAIT)) secs left"
2081 if [ $WAIT -gt $MAX ]; then
2082 echo "Network not available"
2088 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2099 # the sed converts spaces to commas, but leaves the last space
2100 # alone, so the line doesn't end with a comma.
2101 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2104 # list, excluded are the comma separated lists
2105 exclude_items_from_list () {
2111 for item in ${excluded//,/ }; do
2112 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2114 echo $(comma_list $list)
2117 # list, expand are the comma separated lists
2119 local list=${1//,/ }
2120 local expand=${2//,/ }
2123 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2124 echo $(comma_list $expanded)
2127 testslist_filter () {
2128 local script=$LUSTRE/tests/${TESTSUITE}.sh
2130 [ -f $script ] || return 0
2132 local start_at=$START_AT
2133 local stop_at=$STOP_AT
2135 local var=${TESTSUITE//-/_}_START_AT
2136 [ x"${!var}" != x ] && start_at=${!var}
2137 var=${TESTSUITE//-/_}_STOP_AT
2138 [ x"${!var}" != x ] && stop_at=${!var}
2140 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2141 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2142 /^'${start_at}'$/ {flag = 0}
2143 {if (flag == 1) print $0}
2144 /^'${stop_at}'$/ { flag = 1 }'
2148 (cd `dirname $1`; echo $PWD/`basename $1`)
2152 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2153 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2156 local count=${type}COUNT
2157 for ((i=1; i<=${!count}; i++)) do
2158 list="$list ${name}$i"
2160 echo $(comma_list $list)
2163 ##################################
2164 # Adaptive Timeouts funcs
2167 # only check mds, we assume at_max is the same on all nodes
2168 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2169 if [ $at_max -eq 0 ]; then
2179 # suppose that all ost-s has the same at_max set
2180 if [ $facet == "ost" ]; then
2181 do_facet ost1 "lctl get_param -n at_max"
2183 do_facet $facet "lctl get_param -n at_max"
2193 if [ $facet == "ost" ]; then
2194 for i in `seq $OSTCOUNT`; do
2195 do_facet ost$i "lctl set_param at_max=$at_max"
2198 elif [ $facet == "mds" ]; then
2199 for i in `seq $MDSCOUNT`; do
2200 do_facet mds$i "lctl set_param at_max=$at_max"
2203 do_facet $facet "lctl set_param at_max=$at_max"
2208 ##################################
2212 # OBD_FAIL_MDS_ALL_REQUEST_NET
2214 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2215 do_facet client "$1" || RC=$?
2216 do_facet $SINGLEMDS lctl set_param fail_loc=0
2221 # OBD_FAIL_MDS_ALL_REPLY_NET
2223 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2224 do_facet client "$@" || RC=$?
2225 do_facet $SINGLEMDS lctl set_param fail_loc=0
2229 drop_reint_reply() {
2230 # OBD_FAIL_MDS_REINT_NET_REP
2232 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2233 do_facet client "$@" || RC=$?
2234 do_facet $SINGLEMDS lctl set_param fail_loc=0
2239 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2241 do_facet ost1 lctl set_param fail_loc=0x214
2242 do_facet client "$1" || RC=$?
2243 do_facet client "sync"
2244 do_facet ost1 lctl set_param fail_loc=0
2248 drop_ldlm_cancel() {
2249 #define OBD_FAIL_LDLM_CANCEL 0x304
2251 do_facet client lctl set_param fail_loc=0x304
2252 do_facet client "$@" || RC=$?
2253 do_facet client lctl set_param fail_loc=0
2257 drop_bl_callback() {
2258 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2260 do_facet client lctl set_param fail_loc=0x305
2261 do_facet client "$@" || RC=$?
2262 do_facet client lctl set_param fail_loc=0
2267 #define OBD_FAIL_LDLM_REPLY 0x30c
2269 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2270 do_facet client "$@" || RC=$?
2271 do_facet $SINGLEMDS lctl set_param fail_loc=0
2279 echo "clearing fail_loc on $facet"
2280 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2283 set_nodes_failloc () {
2284 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2287 cancel_lru_locks() {
2288 $LCTL mark "cancel_lru_locks $1 start"
2289 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2290 $LCTL set_param -n $d=clear
2292 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2293 $LCTL mark "cancel_lru_locks $1 stop"
2298 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2299 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2300 echo "$DEFAULT_LRU_SIZE"
2305 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2308 lru_resize_disable()
2310 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2315 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2316 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2317 echo there is still data in page cache $FILE ?
2318 lctl get_param -n $FILE
2322 if [[ $MDSDEV1 != $MGSDEV ]]; then
2330 DEBUGSAVE="$(lctl get_param -n debug)"
2334 [ -n "$DEBUGSAVE" ] && \
2335 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2340 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2343 debug_size_restore() {
2344 [ -n "$DEBUG_SIZE_SAVED" ] && \
2345 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2349 start_full_debug_logging() {
2354 local DEBUG_SIZE=150
2356 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2357 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2360 stop_full_debug_logging() {
2365 ##################################
2367 ##################################
2370 local TYPE=${TYPE:-"FAIL"}
2374 # do not dump logs if $1=false
2375 if [ "x$1" = "xfalse" ]; then
2380 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2383 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2384 echo "Dumping lctl log to $ERRLOG"
2385 # We need to dump the logs on all nodes
2386 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2389 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2395 if $FAIL_ON_ERROR; then
2406 # use only if we are ignoring failures for this test, bugno required.
2407 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2408 # e.g. error_ignore 5494 "your message"
2410 local TYPE="IGNORE (bz$1)"
2416 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2421 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2422 [ "$TESTSUITELOG" ] && \
2423 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2426 build_test_filter() {
2427 EXCEPT="$EXCEPT $(testslist_filter)"
2429 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2433 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2434 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2435 [ "$EXCEPT_SLOW" ] && \
2436 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2437 for E in $EXCEPT $ALWAYS_EXCEPT; do
2438 eval EXCEPT_${E}=true
2440 for E in $EXCEPT_SLOW; do
2441 eval EXCEPT_SLOW_${E}=true
2443 for G in $GRANT_CHECK_LIST; do
2444 eval GCHECK_ONLY_${G}=true
2449 if [[ $1 = [a-z]* ]]; then
2456 # print a newline if the last test was skipped
2457 export LAST_SKIPPED=
2461 export base=`basetest $1`
2462 if [ ! -z "$ONLY" ]; then
2464 if [ ${!testname}x != x ]; then
2465 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2470 if [ ${!testname}x != x ]; then
2471 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2480 if [ ${!testname}x != x ]; then
2482 TESTNAME=test_$1 skip "skipping excluded test $1"
2485 testname=EXCEPT_$base
2486 if [ ${!testname}x != x ]; then
2488 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2491 testname=EXCEPT_SLOW_$1
2492 if [ ${!testname}x != x ]; then
2494 TESTNAME=test_$1 skip "skipping SLOW test $1"
2497 testname=EXCEPT_SLOW_$base
2498 if [ ${!testname}x != x ]; then
2500 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2510 EQUALS="======================================================================"
2514 local suffixlen=$((${#EQUALS} - ${#msg}))
2515 [ $suffixlen -lt 5 ] && suffixlen=5
2516 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2521 module_loaded lnet || load_modules
2533 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2538 strace -o $TMP/$1.strace -ttt $*
2540 log "FINISHED: $*: rc $RC"
2545 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2550 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2551 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2552 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2556 echo -n "Resetting fail_loc on all nodes..."
2557 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2565 export tdir=d0.${TESTSUITE}/d${base}
2567 local SAVE_UMASK=`umask`
2570 local BEFORE=`date +%s`
2572 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2574 export TESTNAME=test_$testnum
2576 test_${testnum} || error "test_$testnum failed with $?"
2580 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2581 check_catastrophe || error "LBUG/LASSERT detected"
2582 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2583 pass "($((`date +%s` - $BEFORE))s)"
2591 (cd `dirname $1`; echo $PWD/`basename $1`)
2595 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2596 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2601 export base=`basetest $1`
2602 [ "$CHECK_GRANT" == "no" ] && return 0
2604 testname=GCHECK_ONLY_${base}
2605 [ ${!testname}x == x ] && return 0
2607 echo -n "checking grant......"
2609 # write some data to sync client lost_grant
2610 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2611 for i in `seq $OSTCOUNT`; do
2612 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2613 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2614 count=1 > /dev/null 2>&1
2616 # sync all the data and make sure no pending data on server
2619 #get client grant and server grant
2621 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2622 client_grant=$((client_grant + $d))
2625 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2626 server_grant=$((server_grant + $d))
2629 # cleanup the check_grant file
2630 for i in `seq $OSTCOUNT`; do
2631 rm $DIR1/${tfile}_check_grant_$i
2634 #check whether client grant == server grant
2635 if [ $client_grant != $server_grant ]; then
2636 echo "failed: client:${client_grant} server: ${server_grant}"
2643 ########################
2649 ost=`echo $1 | awk -F_ '{print $3}'`
2650 if [ -z $ost ]; then
2651 ost=`echo $1 | sed 's/-osc.*//'`
2658 [ "$node" != "$(hostname)" ]
2664 for node in $(mdts_nodes); do
2665 remote_node $node && return 0
2672 [ "$CLIENTONLY" ] && return 0 || true
2673 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2679 for node in $(osts_nodes) ; do
2680 remote_node $node && return 0
2687 [ "$CLIENTONLY" ] && return 0 || true
2688 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2694 MGS=$(facet_host mgs)
2695 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2701 for num in `seq $MDSCOUNT`; do
2702 MDSNODES="$MDSNODES $(facet_host mds$num)"
2704 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2710 remote_ost && remote_mds
2714 local OSTNODES=$(facet_host ost1)
2717 for num in `seq $OSTCOUNT`; do
2718 local myOST=$(facet_host ost$num)
2719 OSTNODES="$OSTNODES $myOST"
2721 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2727 # FIXME. We need a list of clients
2728 local myNODES=$HOSTNAME
2731 # CLIENTS (if specified) contains the local client
2732 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2734 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2735 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2738 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2743 remote_nodes_list () {
2744 local rnodes=$(nodes_list)
2745 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2749 init_clients_lists () {
2750 # Sanity check: exclude the local client from RCLIENTS
2751 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2753 # Sanity check: exclude the dup entries
2754 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2756 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2758 # Sanity check: exclude the dup entries from CLIENTS
2759 # for those configs which has SINGLCLIENT set to local client
2760 clients=$(for i in $clients; do echo $i; done | sort -u)
2762 CLIENTS=`comma_list $clients`
2763 local -a remoteclients=($rclients)
2764 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2765 varname=CLIENT$((i + 2))
2766 eval $varname=${remoteclients[i]}
2769 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2772 get_random_entry () {
2775 rnodes=${rnodes//,/ }
2777 local -a nodes=($rnodes)
2778 local num=${#nodes[@]}
2779 local i=$((RANDOM * num * 2 / 65536))
2785 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2790 lctl get_param version | grep -q patchless
2794 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2799 echo $nodes | wc -w || true
2803 local nodes=$(osts_nodes)
2804 local osscount=$(get_node_count "$nodes")
2805 [ ! "$OSTCOUNT" = "$osscount" ]
2809 local nodes=$(mdts_nodes)
2810 local mdtcount=$(get_node_count "$nodes")
2811 [ ! "$MDSCOUNT" = "$mdtcount" ]
2814 generate_machine_file() {
2815 local nodes=${1//,/ }
2816 local machinefile=$2
2817 rm -f $machinefile || error "can't rm $machinefile"
2818 for node in $nodes; do
2819 echo $node >>$machinefile
2824 local file=$1/stripe
2826 $LFS getstripe -v $file || error
2830 check_runas_id_ret() {
2832 local myRUNAS_UID=$1
2833 local myRUNAS_GID=$2
2836 if [ -z "$myRUNAS" ]; then
2837 error_exit "myRUNAS command must be specified for check_runas_id"
2840 $myRUNAS krb5_login.sh || \
2841 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2843 mkdir $DIR/d0_runas_test
2845 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2846 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2847 rm -rf $DIR/d0_runas_test
2852 local myRUNAS_UID=$1
2853 local myRUNAS_GID=$2
2856 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2857 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2858 Please set RUNAS_ID to some UID which exists on MDS and client or
2859 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2862 # obtain the UID/GID for MPI_USER
2866 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2867 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2869 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2870 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2873 # obtain and cache Kerberos ticket-granting ticket
2874 refresh_krb5_tgt() {
2875 local myRUNAS_UID=$1
2876 local myRUNAS_GID=$2
2879 if [ -z "$myRUNAS" ]; then
2880 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2883 CLIENTS=${CLIENTS:-$HOSTNAME}
2884 do_nodes $CLIENTS "set -x
2885 if ! $myRUNAS krb5_login.sh; then
2886 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2891 # Run multiop in the background, but wait for it to print
2892 # "PAUSING" to its stdout before returning from this function.
2893 multiop_bg_pause() {
2894 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2898 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2901 echo "$MULTIOP_PROG $FILE v$ARGS"
2902 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2904 echo "TMPPIPE=${TMPPIPE}"
2905 read -t 60 multiop_output < $TMPPIPE
2906 if [ $? -ne 0 ]; then
2911 if [ "$multiop_output" != "PAUSING" ]; then
2912 echo "Incorrect multiop output: $multiop_output"
2927 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2933 inodes_available () {
2934 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2938 # reset llite stat counters
2939 clear_llite_stats(){
2940 lctl set_param -n llite.*.stats 0
2943 # sum llite stat items
2944 calc_llite_stats() {
2945 local res=$(lctl get_param -n llite.*.stats |
2946 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2950 # reset osc stat counters
2952 lctl set_param -n osc.*.osc_stats 0
2955 # sum osc stat items
2957 local res=$(lctl get_param -n osc.*.osc_stats |
2958 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2963 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2966 calc_osc_kbytes () {
2967 df $MOUNT > /dev/null
2968 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2971 # save_lustre_params(node, parameter_mask)
2972 # generate a stream of formatted strings (<node> <param name>=<param value>)
2973 save_lustre_params() {
2975 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2978 # restore lustre parameters from input stream, produces by save_lustre_params
2979 restore_lustre_params() {
2983 while IFS=" =" read node name val; do
2984 do_node ${node//:/} "lctl set_param -n $name $val"
2988 check_catastrophe() {
2989 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2990 local C=$CATASTROPHE
2991 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2993 if [ $rnodes ]; then
2994 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2995 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3011 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3013 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3014 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3015 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3019 # CMD: determine mds index where directory inode presents
3022 local file=$dir/f0.get_mds_dir_tmpfile
3027 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3028 local -a oldused=($iused)
3030 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3032 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3033 local -a newused=($iused)
3036 for ((i=0; i<${#newused[@]}; i++)); do
3037 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3043 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3046 mdsrate_cleanup () {
3048 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3053 delayed_recovery_enabled () {
3054 local var=${SINGLEMDS}_svc
3055 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3058 ########################
3060 convert_facet2label() {
3063 if [ x$facet = xost ]; then
3067 local varsvc=${facet}_svc
3069 if [ -n ${!varsvc} ]; then
3072 error "No lablel for $facet!"
3076 get_clientosc_proc_path() {
3082 get_lustre_version () {
3083 local node=${1:-"mds"}
3084 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3087 get_mds_version_major () {
3088 local version=$(get_lustre_version mds)
3089 echo $version | awk -F. '{print $1}'
3092 get_mds_version_minor () {
3093 local version=$(get_lustre_version mds)
3094 echo $version | awk -F. '{print $2}'
3097 get_mdtosc_proc_path() {
3099 local major=$(get_mds_version_major)
3100 local minor=$(get_mds_version_minor)
3101 if [ $major -le 1 -a $minor -le 8 ] ; then
3104 echo "${ost}-osc-MDT0000"
3108 get_osc_import_name() {
3111 local label=$(convert_facet2label $ost)
3113 if [ "$facet" == "mds" ]; then
3114 get_mdtosc_proc_path $label
3118 get_clientosc_proc_path $label
3122 wait_import_state () {
3128 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3129 while [ "${CONN_STATE}" != "${expected}" ]; do
3130 if [ "${expected}" == "DISCONN" ]; then
3131 # for disconn we can check after proc entry is removed
3132 [ "x${CONN_STATE}" == "x" ] && return 0
3133 # with AT we can have connect request timeout ~ reconnect timeout
3134 # and test can't see real disconnect
3135 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3137 # disconnect rpc should be wait not more obd_timeout
3138 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3139 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3141 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3145 log "$CONN_PROC now in ${CONN_STATE} state"
3149 wait_osc_import_state() {
3153 local ost=$(get_osc_import_name $facet $ost_facet)
3158 CONN_PROC="osc.${ost}.ost_server_uuid"
3159 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3160 while [ "${CONN_STATE}" != "${expected}" ]; do
3161 if [ "${expected}" == "DISCONN" ]; then
3162 # for disconn we can check after proc entry is removed
3163 [ "x${CONN_STATE}" == "x" ] && return 0
3164 # with AT we can have connect request timeout ~ reconnect timeout
3165 # and test can't see real disconnect
3166 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3168 # disconnect rpc should be wait not more obd_timeout
3169 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3170 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3172 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3176 log "${ost_facet} now in ${CONN_STATE} state"
3180 get_clientmdc_proc_path() {
3188 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3191 wait_clients_import_state () {
3197 local label=$(convert_facet2label $facet)
3200 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3201 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3202 *) error "unknown facet!" ;;
3205 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3206 error "import is not in ${expected} state"
3215 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3216 $LCTL get_param obdfilter.*.kbytesavail))
3217 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3218 $LCTL get_param -n obdfilter.*.tot_granted))
3219 for ((i=0; i<${#AVAILA[@]}; i++)); do
3220 local -a AVAIL1=(${AVAILA[$i]//=/ })
3221 GRANT=$((${GRANTA[$i]}/1024))
3222 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3223 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3229 do_facet mgs lctl pool_list $1
3233 local fsname=${1%%.*}
3234 local poolname=${1##$fsname.}
3236 do_facet mgs lctl pool_new $1
3238 # get param should return err unless pool is created
3239 [[ $RC -ne 0 ]] && return $RC
3241 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3242 2>/dev/null || echo foo" "" || RC=1
3243 if [[ $RC -eq 0 ]]; then
3246 error "pool_new failed $1"
3251 add_pool_to_list () {
3252 local fsname=${1%%.*}
3253 local poolname=${1##$fsname.}
3255 local listvar=${fsname}_CREATED_POOLS
3256 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3259 remove_pool_from_list () {
3260 local fsname=${1%%.*}
3261 local poolname=${1##$fsname.}
3263 local listvar=${fsname}_CREATED_POOLS
3264 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3267 destroy_pool_int() {
3269 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3270 awk '$1 !~ /^Pool:/ {print $1}')
3271 for ost in $OSTS; do
3272 do_facet mgs lctl pool_remove $1 $ost
3274 do_facet mgs lctl pool_destroy $1
3277 # <fsname>.<poolname> or <poolname>
3279 local fsname=${1%%.*}
3280 local poolname=${1##$fsname.}
3282 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3286 pool_list $fsname.$poolname || return $?
3288 destroy_pool_int $fsname.$poolname
3290 [[ $RC -ne 0 ]] && return $RC
3292 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3293 2>/dev/null || echo foo" "foo" || RC=1
3295 if [[ $RC -eq 0 ]]; then
3296 remove_pool_from_list $fsname.$poolname
3298 error "destroy pool failed $1"
3304 local fsname=${1:-$FSNAME}
3306 local listvar=${fsname}_CREATED_POOLS
3310 [ x${!listvar} = x ] && return 0
3312 echo destroy the created pools: ${!listvar}
3313 for poolname in ${!listvar//,/ }; do
3314 destroy_pool $fsname.$poolname
3319 local fsname=${1:-$FSNAME}
3321 destroy_pools $fsname
3327 local ts=$(date +%s)
3329 # bug 20237, comment 11
3330 # It would also be useful to provide the option
3331 # of writing the file to an NFS directory so it doesn't need to be copied.
3334 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3336 # dump lustre logs, dmesg
3337 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3338 lctl dk \\\$log >/dev/null;
3339 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3342 # FIXME: does it make sense to collect the logs for $ts only, but all
3344 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3345 local logs=$TMP/'*'${TESTSUITE}'*'
3347 logs=$logs' '$tmp/'*'$ts'*'
3349 for node in ${list//,/ }; do
3350 rsync -az $node:"$logs" $TMP
3353 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3354 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3360 local list=${1:-$(comma_list $(nodes_list))}
3362 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3374 for i in $(seq 0 $num_mntpts); do
3375 cmd="ls -laf ${mntpt_root}$i/$dir"
3381 for pid in $pids; do