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 LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
131 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
132 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
133 [ ! -f "$LFS" ] && export LFS=$(which lfs)
134 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
135 if [ ! -f "$L_GETIDENTITY" ]; then
136 if `which l_getidentity > /dev/null 2>&1`; then
137 export L_GETIDENTITY=$(which l_getidentity)
139 export L_GETIDENTITY=NONE
142 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
143 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
144 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
145 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
146 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
147 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
148 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
149 export FSTYPE=${FSTYPE:-"ldiskfs"}
150 export NAME=${NAME:-local}
151 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
152 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
153 export LGSSD=$(which lgssd)
154 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
155 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
156 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
158 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
161 if [ "$ACCEPTOR_PORT" ]; then
162 export PORT_OPT="--port $ACCEPTOR_PORT"
167 echo "Using GSS/krb5 ptlrpc security flavor"
168 which lgss_keyring > /dev/null 2>&1 || \
169 error "built with gss disabled! SEC=$SEC"
180 IDENTITY_UPCALL=false
183 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
185 # Paths on remote nodes, if different
186 export RLUSTRE=${RLUSTRE:-$LUSTRE}
187 export RPWD=${RPWD:-$PWD}
188 export I_MOUNTED=${I_MOUNTED:-"no"}
189 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
190 ! -f `dirname $0`/../mds/mds.ko ]; then
191 export CLIENTMODSONLY=yes
196 while getopts "rvwf:" opt $*; do
199 r) REFORMAT=--reformat;;
201 w) WRITECONF=writeconf;;
206 shift $((OPTIND - 1))
209 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
214 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
215 *) EXT=".ko"; USE_QUOTA=yes;;
220 /sbin/lsmod | grep -q $1
227 BASE=`basename $module $EXT`
229 module_loaded ${BASE} && return
231 if [ -f ${LUSTRE}/${module}${EXT} ]; then
232 insmod ${LUSTRE}/${module}${EXT} $@
234 # must be testing a "make install" or "rpm" installation
235 # note failed to load ptlrpc_gss is considered not fatal
236 if [ "$BASE" == "ptlrpc_gss" ]; then
237 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
244 load_modules_local() {
245 if [ -n "$MODPROBE" ]; then
249 if [ "$HAVE_MODULES" = true ]; then
255 echo Loading modules from $LUSTRE
256 load_module ../libcfs/libcfs/libcfs
257 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
258 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
260 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
261 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
262 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
263 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
264 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
265 echo "lnet options: '$LNETOPTS'"
266 # note that insmod will ignore anything in modprobe.conf
267 load_module ../lnet/lnet/lnet $LNETOPTS
268 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
269 load_module ../lnet/klnds/$LNETLND
270 load_module lvfs/lvfs
271 load_module obdclass/obdclass
272 load_module ptlrpc/ptlrpc
273 load_module ptlrpc/gss/ptlrpc_gss
274 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
282 if ! client_only; then
283 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
284 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
285 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
290 load_module lvfs/fsfilt_$FSTYPE
294 load_module obdfilter/obdfilter
297 load_module llite/lustre
298 load_module llite/llite_lloop
299 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
301 rm -f $OGDB/ogdb-$HOSTNAME
302 $LCTL modules > $OGDB/ogdb-$HOSTNAME
304 # 'mount' doesn't look in $PATH, just sbin
305 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
311 # load modules on remote nodes optionally
312 # lustre-tests have to be installed on these nodes
313 if $LOAD_MODULES_REMOTE ; then
314 local list=$(comma_list $(remote_nodes_list))
315 echo loading modules on $list
316 do_rpc_nodes $list load_modules
321 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
322 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
323 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
324 echo "$LEAK_LUSTRE" 1>&2
325 echo "$LEAK_PORTALS" 1>&2
326 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
327 echo "Memory leaks detected"
328 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
334 wait_exit_ST client # bug 12845
336 $LUSTRE_RMMOD $FSTYPE || return 2
338 if $LOAD_MODULES_REMOTE ; then
339 local list=$(comma_list $(remote_nodes_list))
340 echo unloading modules on $list
341 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
342 do_rpc_nodes $list check_mem_leak
347 check_mem_leak || return 254
349 echo "modules unloaded."
353 check_gss_daemon_facet() {
357 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
358 if [ $num -ne 1 ]; then
359 echo "$num instance of $dname on $facet"
368 do_facet $facet "killall -2 $@ 2>/dev/null || true"
371 start_gss_daemons() {
373 for num in `seq $MDSCOUNT`; do
374 do_facet mds$num "$LSVCGSSD -v"
376 do_facet mds$num "$LGSSD -v"
380 for num in `seq $OSTCOUNT`; do
381 do_facet ost$num "$LSVCGSSD -v"
384 # FIXME: is "client" the right facet name?
386 do_facet client "$LGSSD -v"
389 # wait daemons entering "stable" status
393 # check daemons are running
395 for num in `seq $MDSCOUNT`; do
396 check_gss_daemon_facet mds$num lsvcgssd
398 check_gss_daemon_facet mds$num lgssd
401 for num in `seq $OSTCOUNT`; do
402 check_gss_daemon_facet ost$num lsvcgssd
405 check_gss_daemon_facet client lgssd
410 for num in `seq $MDSCOUNT`; do
411 send_sigint mds$num lsvcgssd lgssd
413 for num in `seq $OSTCOUNT`; do
414 send_sigint ost$num lsvcgssd
416 send_sigint client lgssd
423 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
424 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
432 # maybe cleanup credential cache?
438 local device=`mdsdevname $num`
439 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
445 local device=`ostdevname $num`
446 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
454 local dev=$(facet_active $facet)_dev
455 local opt=${facet}_opt
456 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
457 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
459 if [ $RC -ne 0 ]; then
460 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
461 echo "Start of ${!dev} on ${facet} failed ${RC}"
463 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
464 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
465 lctl set_param debug_mb=${DEBUG_SIZE}; \
468 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
469 [ -z "$label" ] && echo no label for ${!dev} && exit 1
470 eval export ${facet}_svc=${label}
471 echo Started ${label}
476 # start facet device options
482 eval export ${facet}_dev=${device}
483 eval export ${facet}_opt=\"$@\"
485 local varname=${facet}failover_dev
486 if [ -n "${!varname}" ] ; then
487 eval export ${facet}failover_dev=${!varname}
489 eval export ${facet}failover_dev=$device
492 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
502 HOST=`facet_active_host $facet`
503 [ -z $HOST ] && echo stop: no host for $facet && return 0
505 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
506 if [ ${running} -ne 0 ]; then
507 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
508 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
511 # umount should block, but we should wait for unrelated obd's
512 # like the MGS or MGC to also stop.
513 wait_exit_ST ${facet}
516 # save quota version (both administrative and operational quotas)
517 # add an additional parameter if mountpoint is ever different from $MOUNT
518 quota_save_version() {
519 local fsname=${2:-$FSNAME}
521 local ver=$(tr -c -d "123" <<< $spec)
522 local type=$(tr -c -d "ug" <<< $spec)
524 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
526 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
528 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
530 local osts=$(get_facets OST)
531 for ost in ${osts//,/ }; do
533 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
537 # client could mount several lustre
539 local fsname=${1:-$FSNAME}
541 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
542 do_nodes $(comma_list $(osts_nodes)) \
543 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
547 restore_quota_type () {
548 local mntpt=${1:-$MOUNT}
549 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
550 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
553 quota_save_version $old_QUOTA_TYPE
559 # We need save the original quota_type params, and restore them after testing
561 # Suppose that quota type the same on mds and ost
562 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
563 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
564 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
565 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
566 export old_QUOTA_TYPE=$quota_type
567 quota_save_version $QUOTA_TYPE
569 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
570 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
573 local quota_usrs=$QUOTA_USERS
575 # get_filesystem_size
576 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
577 local blk_soft=$((disksz + 1024))
578 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
580 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
582 local i_hard=$((i_soft + i_soft / 20))
584 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
585 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
588 for usr in $quota_usrs; do
589 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
591 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
593 eval $cmd || error "$cmd FAILED!"
595 # display the quota status
596 echo "Quota settings for $usr : "
597 $LFS quota -v -u $usr $mntpt || true
605 # Only supply -o to mount if we have options
606 if [ -n "$MOUNTOPT" ]; then
607 OPTIONS="-o $MOUNTOPT"
609 local device=$MGSNID:/$FSNAME
610 if [ -z "$mnt" -o -z "$FSNAME" ]; then
611 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
615 echo "Starting client: $client: $OPTIONS $device $mnt"
616 do_node $client mkdir -p $mnt
617 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
619 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
620 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
621 lctl set_param debug_mb=${DEBUG_SIZE}"
634 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
635 if [ $running -ne 0 ]; then
636 echo "Stopping client $client $mnt (opts:$force)"
637 do_node $client lsof -t $mnt || need_kill=no
638 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
639 pids=$(do_node $client lsof -t $mnt | sort -u);
640 if [ -n $pids ]; then
641 do_node $client kill -9 $pids || true
645 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
646 if [ $busy -ne 0 ] ; then
647 echo "$mnt is still busy, wait one second" && sleep 1
648 do_node $client umount $force $mnt
653 # nodes is comma list
654 sanity_mount_check_nodes () {
660 # FIXME: assume that all cluster nodes run the same os
661 [ "$(uname)" = Linux ] || return 0
664 for mnt in $mnts ; do
665 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
666 mpts=\\\$(mount | grep -w -c $mnt);
667 if [ \\\$running -ne \\\$mpts ]; then
668 echo \\\$(hostname) env are INSANE!;
676 sanity_mount_check_servers () {
678 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
679 echo Checking servers environments
681 # FIXME: modify get_facets to display all facets wo params
682 local facets="$(get_facets OST),$(get_facets MDS),mgs"
686 for facet in ${facets//,/ }; do
687 node=$(facet_host ${facet})
688 mnt=${MOUNT%/*}/${facet}
689 sanity_mount_check_nodes $node $mnt ||
690 { error "server $node environments are insane!"; return 1; }
694 sanity_mount_check_clients () {
695 local clients=${1:-$CLIENTS}
696 local mntpt=${2:-$MOUNT}
697 local mntpt2=${3:-$MOUNT2}
699 [ -z $clients ] && clients=$(hostname)
700 echo Checking clients $clients environments
702 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
703 error "clients environments are insane!"
706 sanity_mount_check () {
707 sanity_mount_check_servers || return 1
708 sanity_mount_check_clients || return 2
711 # mount clients if not mouted
712 zconf_mount_clients() {
715 local OPTIONS=${3:-$MOUNTOPT}
717 # Only supply -o to mount if we have options
718 if [ "$OPTIONS" ]; then
719 OPTIONS="-o $OPTIONS"
721 local device=$MGSNID:/$FSNAME
722 if [ -z "$mnt" -o -z "$FSNAME" ]; then
723 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
727 echo "Starting client $clients: $OPTIONS $device $mnt"
730 running=\\\$(mount | grep -c $mnt' ');
732 if [ \\\$running -eq 0 ] ; then
734 mount -t lustre $OPTIONS $device $mnt;
737 exit \\\$rc" || return ${PIPESTATUS[0]}
739 echo "Started clients $clients: "
740 do_nodes $clients "mount | grep -w $mnt"
742 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
743 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
744 lctl set_param debug_mb=${DEBUG_SIZE};"
749 zconf_umount_clients() {
756 echo "Stopping clients: $clients $mnt (opts:$force)"
757 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
758 if [ \\\$running -ne 0 ] ; then
759 echo Stopping client \\\$(hostname) $mnt opts:$force;
760 lsof -t $mnt || need_kill=no;
761 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
762 pids=\\\$(lsof -t $mnt | sort -u);
763 if [ -n \\\"\\\$pids\\\" ]; then
767 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
768 if [ \\\$busy -ne 0 ] ; then
769 echo "$mnt is still busy, wait one second" && sleep 1;
775 shudown_node_hard () {
779 for i in $(seq $attempts) ; do
782 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
783 echo "waiting for $host to fail attempts=$attempts"
784 [ $i -lt $attempts ] || \
785 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
791 local mnt=${2:-$MOUNT}
794 if [ "$FAILURE_MODE" = HARD ]; then
795 shudown_node_hard $client
797 zconf_umount_clients $client $mnt -f
803 if [ "$FAILURE_MODE" = HARD ]; then
804 shudown_node_hard $(facet_active_host $facet)
805 elif [ "$FAILURE_MODE" = SOFT ]; then
812 if [ "$FAILURE_MODE" = HARD ]; then
813 $POWER_UP `facet_active_host $facet`
821 if [ "$FAILURE_MODE" = HARD ]; then
827 # recovery-scale functions
828 check_progs_installed () {
833 do_nodes $clients "PATH=:$PATH; status=true;
834 for prog in $progs; do
835 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
836 echo \\\$prog missing on \\\$(hostname);
844 echo __$(echo $1 | tr '-' 'X')
847 start_client_load() {
850 local var=$(client_var_name $client)_load
851 eval export ${var}=$load
853 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
854 BREAK_ON_ERROR=$BREAK_ON_ERROR \
855 END_RUN_FILE=$END_RUN_FILE \
856 LOAD_PID_FILE=$LOAD_PID_FILE \
857 TESTSUITELOG=$TESTSUITELOG \
859 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
860 log "Started client load: ${load} on $client"
865 start_client_loads () {
866 local -a clients=(${1//,/ })
867 local numloads=${#CLIENT_LOADS[@]}
870 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
871 testnum=$((nodenum % numloads))
872 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
876 # only for remote client
877 check_client_load () {
879 local var=$(client_var_name $client)_load
880 local TESTLOAD=run_${!var}.sh
882 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
884 # bug 18914: try to connect several times not only when
885 # check ps, but while check_catastrophe also
888 while [ $RC = 254 -a $tries -gt 0 ]; do
892 if ! check_catastrophe $client; then
894 if [ $RC -eq 254 ]; then
895 # FIXME: not sure how long we shuold sleep here
899 echo "check catastrophe failed: RC=$RC "
903 # We can continue try to connect if RC=254
904 # Just print the warning about this
905 if [ $RC = 254 ]; then
906 echo "got a return status of $RC from do_node while checking catastrophe on $client"
909 # see if the load is still on the client
912 while [ $RC = 254 -a $tries -gt 0 ]; do
916 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
921 if [ $RC = 254 ]; then
922 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
923 # see if we can diagnose a bit why this is
928 check_client_loads () {
929 local clients=${1//,/ }
933 for client in $clients; do
934 check_client_load $client
936 if [ "$rc" != 0 ]; then
937 log "Client load failed on node $client, rc=$rc"
943 restart_client_loads () {
944 local clients=${1//,/ }
945 local expectedfail=${2:-""}
949 for client in $clients; do
950 check_client_load $client
952 if [ "$rc" != 0 -a "$expectedfail" ]; then
953 local var=$(client_var_name $client)_load
954 start_client_load $client ${!var}
955 echo "Restarted client load ${!var}: on $client. Checking ..."
956 check_client_load $client
958 if [ "$rc" != 0 ]; then
959 log "Client load failed to restart on node $client, rc=$rc"
960 # failure one client load means test fail
961 # we do not need to check other
969 # End recovery-scale functions
971 # verify that lustre actually cleaned up properly
973 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
974 error "LBUG/LASSERT detected"
975 BUSY=`dmesg | grep -i destruct || true`
978 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
982 check_mem_leak || exit 204
984 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
985 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
987 if module_loaded lnet || module_loaded libcfs; then
988 echo "$0: modules still loaded..." 1>&2
1005 RESULT=$(do_node $node "$TEST")
1006 if [ "$RESULT" == "$FINAL" ]; then
1007 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1010 [ $WAIT -ge $MAX ] && break
1011 echo "Waiting $((MAX - WAIT)) secs for update"
1012 WAIT=$((WAIT + sleep))
1015 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1019 wait_update_facet () {
1021 wait_update $(facet_active_host $facet) "$@"
1024 wait_delete_completed () {
1025 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1026 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1030 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1032 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1033 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1034 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1035 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1039 echo "Delete is not completed in $MAX_WAIT sec"
1045 check_network "$host" 900
1046 while ! do_node $host hostname > /dev/null; do sleep 5; done
1051 local host=`facet_active_host $facet`
1055 wait_recovery_complete () {
1058 # Use default policy if $2 is not passed by caller.
1059 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1060 # as we are in process of changing obd_timeout in different ways
1061 # let's set MAX longer than that
1062 local MAX=${2:-$(( TIMEOUT * 4 ))}
1064 local var_svc=${facet}_svc
1065 local procfile="*.${!var_svc}.recovery_status"
1069 while [ $WAIT -lt $MAX ]; do
1070 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1071 [[ $STATUS = "status: COMPLETE" ]] && return 0
1074 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1076 echo "$facet recovery not done in $MAX sec. $STATUS"
1080 wait_mds_ost_sync () {
1081 # just because recovery is done doesn't mean we've finished
1082 # orphan cleanup. Wait for llogs to get synchronized.
1083 echo "Waiting for orphan cleanup..."
1084 # MAX value includes time needed for MDS-OST reconnection
1085 local MAX=$(( TIMEOUT * 2 ))
1087 while [ $WAIT -lt $MAX ]; do
1088 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1089 "$LCTL get_param -n obdfilter.*.mds_sync"))
1091 for ((i=0; i<${#sync[@]}; i++)); do
1092 [ ${sync[$i]} -eq 0 ] && continue
1093 # there is a not finished MDS-OST synchronization
1097 sleep 2 # increase waiting time and cover statfs cache
1098 [ ${con} -eq 1 ] && return 0
1099 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1102 echo "$facet recovery not done in $MAX sec. $STATUS"
1106 wait_destroy_complete () {
1107 echo "Waiting for destroy to be done..."
1108 # MAX value shouldn't be big as this mean server responsiveness
1109 # never increase this just to make test pass but investigate
1110 # why it takes so long time
1113 while [ $WAIT -lt $MAX ]; do
1114 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1116 for ((i=0; i<${#RPCs[@]}; i++)); do
1117 [ ${RPCs[$i]} -eq 0 ] && continue
1118 # there are still some destroy RPCs in flight
1123 [ ${con} -eq 1 ] && return 0 # done waiting
1124 echo "Waiting $WAIT secs for destroys to be done."
1127 echo "Destroys weren't done in $MAX sec."
1137 # conf-sanity 31 takes a long time cleanup
1138 while [ $WAIT -lt 300 ]; do
1139 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1140 [ -z "${running}" ] && return 0
1141 echo "waited $WAIT for${running}"
1142 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1144 WAIT=$((WAIT + INTERVAL))
1146 echo "service didn't stop after $WAIT seconds. Still running:"
1151 wait_remote_prog () {
1157 [ "$PDSH" = "no_dsh" ] && return 0
1159 while [ $WAIT -lt $2 ]; do
1160 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1161 [ -z "${running}" ] && return 0 || true
1162 echo "waited $WAIT for: "
1164 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1166 WAIT=$((WAIT + INTERVAL))
1168 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1169 [ -z "$pids" ] && return 0
1170 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1171 # FIXME: not portable
1172 for pid in $pids; do
1173 cat /proc/${pid}/status || true
1174 cat /proc/${pid}/wchan || true
1176 kill -9 $pid || true
1185 # not every config has many clients
1187 if [ ! -z "$CLIENTS" ]; then
1188 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1190 stat -f $MOUNT > /dev/null
1196 # usually checked on particular client or locally
1198 if [ ! -z "$client" ]; then
1199 $PDSH $client "stat -f $MOUNT" > /dev/null
1201 stat -f $MOUNT > /dev/null
1209 client_reconnect() {
1210 uname -n >> $MOUNT/recon
1211 if [ -z "$CLIENTS" ]; then
1212 df $MOUNT; uname -n >> $MOUNT/recon
1214 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1216 echo Connected clients:
1218 ls -l $MOUNT/recon > /dev/null
1225 echo "Failing $facet on node `facet_active_host $facet`"
1226 shutdown_facet $facet
1227 [ -n "$sleep_time" ] && sleep $sleep_time
1229 change_active $facet
1230 local TO=`facet_active_host $facet`
1231 echo "Failover $facet to $TO"
1233 mount_facet $facet || error "Restart of $facet failed"
1242 do_facet $facet sync
1244 local svc=${facet}_svc
1245 do_facet $facet $LCTL --device %${!svc} notransno
1246 do_facet $facet $LCTL --device %${!svc} readonly
1247 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1248 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1251 replay_barrier_nodf() {
1252 local facet=$1 echo running=${running}
1253 do_facet $facet sync
1254 local svc=${facet}_svc
1255 echo Replay barrier on ${!svc}
1256 do_facet $facet $LCTL --device %${!svc} notransno
1257 do_facet $facet $LCTL --device %${!svc} readonly
1258 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1259 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1262 replay_barrier_nosync() {
1263 local facet=$1 echo running=${running}
1264 local svc=${facet}_svc
1265 echo Replay barrier on ${!svc}
1266 do_facet $facet $LCTL --device %${!svc} notransno
1267 do_facet $facet $LCTL --device %${!svc} readonly
1268 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1269 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1272 mds_evict_client() {
1273 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1274 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1277 ost_evict_client() {
1278 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1279 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1283 facet_failover $* || error "failover: $?"
1284 clients_up || error "post-failover df: $?"
1289 facet_failover $facet
1295 change_active $facet
1296 mount_facet $facet -o abort_recovery
1297 clients_up || echo "first df failed: $?"
1298 clients_up || error "post-failover df: $?"
1302 echo There is no lmc. This is mountconf, baby.
1307 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1308 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1314 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1320 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1321 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1322 if [ -z "$ID" ]; then
1323 echo "Could not get a ptl id for $1..."
1332 h2name_or_ip "$1" "tcp"
1337 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1338 if type __h2elan >/dev/null 2>&1; then
1341 ID=`echo $1 | sed 's/[^0-9]*//g'`
1349 h2name_or_ip "$1" "openib"
1351 declare -fx h2openib
1354 h2name_or_ip "$1" "o2ib"
1361 [ "$facet" == client ] && echo -n $HOSTNAME && return
1362 varname=${facet}_HOST
1363 if [ -z "${!varname}" ]; then
1364 if [ "${facet:0:3}" == "ost" ]; then
1365 eval ${facet}_HOST=${ost_HOST}
1373 local activevar=${facet}active
1375 if [ -f $TMP/${facet}active ] ; then
1376 source $TMP/${facet}active
1379 active=${!activevar}
1380 if [ -z "$active" ] ; then
1387 facet_active_host() {
1389 local active=`facet_active $facet`
1390 if [ "$facet" == client ]; then
1393 echo `facet_host $active`
1399 local failover=${facet}failover
1400 host=`facet_host $failover`
1401 [ -z "$host" ] && return
1402 local curactive=`facet_active $facet`
1403 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1404 eval export ${facet}active=$facet
1406 eval export ${facet}active=$failover
1408 # save the active host for this facet
1409 local activevar=${facet}active
1410 echo "$activevar=${!activevar}" > $TMP/$activevar
1415 # do not stripe off hostname if verbose, bug 19215
1416 if [ x$1 = x--verbose ]; then
1424 if [ "$HOST" = "$HOSTNAME" ]; then
1426 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1427 echo "cannot run remote command on $HOST with $myPDSH"
1431 echo "CMD: $HOST $@" >&2
1432 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1435 if [ "$myPDSH" = "rsh" ]; then
1436 # we need this because rsh does not return exit code of an executed command
1437 local command_status="$TMP/cs"
1438 rsh $HOST ":> $command_status"
1439 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1440 cd $RPWD; sh -c \"$@\") ||
1441 echo command failed >$command_status"
1442 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1447 # print HOSTNAME for myPDSH="no_dsh"
1448 if [[ $myPDSH = no_dsh ]]; then
1449 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1451 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1454 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1456 return ${PIPESTATUS[0]}
1459 single_local_node () {
1460 [ "$1" = "$HOSTNAME" ]
1465 # do not stripe off hostname if verbose, bug 19215
1466 if [ x$1 = x--verbose ]; then
1474 if $(single_local_node $rnodes); then
1476 do_node --verbose $rnodes $@
1483 # This is part from do_node
1486 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1487 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1490 echo "CMD: $rnodes $@" >&2
1491 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1495 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1497 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1499 return ${PIPESTATUS[0]}
1505 local HOST=`facet_active_host $facet`
1506 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1513 # make sure its not already running
1515 rm -f $TMP/${facet}active
1516 do_facet ${facet} $MKFS $*
1522 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1523 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1530 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1531 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1539 # make sure we are using the primary server, so test-framework will
1540 # be able to clean up properly.
1541 activemds=`facet_active mds1`
1542 if [ $activemds != "mds1" ]; then
1546 local clients=$CLIENTS
1547 [ -z $clients ] && clients=$(hostname)
1549 zconf_umount_clients $clients $MOUNT "$*" || true
1550 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1552 [ "$CLIENTONLY" ] && return
1553 # The add fn does rm ${facet}active file, this would be enough
1554 # if we use do_facet <facet> only after the facet added, but
1555 # currently we use do_facet mds in local.sh
1556 for num in `seq $MDSCOUNT`; do
1558 rm -f ${TMP}/mds${num}active
1561 for num in `seq $OSTCOUNT`; do
1563 rm -f $TMP/ost${num}active
1570 nfs_client_mode && return
1580 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1584 if [ "$IAMDIR" == "yes" ]; then
1585 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1586 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1589 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1591 if [ ! -z $SEC ]; then
1592 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1593 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1594 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1598 # We need ldiskfs here, may as well load them all
1600 [ "$CLIENTONLY" ] && return
1601 echo Formatting mgs, mds, osts
1602 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1603 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1606 for num in `seq $MDSCOUNT`; do
1607 echo "Format mds$num: $(mdsdevname $num)"
1609 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1611 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1615 for num in `seq $OSTCOUNT`; do
1616 echo "Format ost$num: $(ostdevname $num)"
1618 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1620 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1626 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1630 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1634 # 0: success, the old identity set already.
1635 # 1: success, the old identity does not set.
1640 local j=`expr $num - 1`
1641 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1643 if [ -z "$MDT" ]; then
1647 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1650 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1652 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1655 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1657 if [ $old = "NONE" ]; then
1666 zconf_umount `hostname` $1 || error "umount failed"
1667 zconf_mount `hostname` $1 || error "mount failed"
1670 writeconf_facet () {
1674 do_facet $facet "$TUNEFS --writeconf $dev"
1678 for num in `seq $MDSCOUNT`; do
1679 DEVNAME=$(mdsdevname $num)
1680 writeconf_facet mds$num $DEVNAME
1683 for num in `seq $OSTCOUNT`; do
1684 DEVNAME=$(ostdevname $num)
1685 writeconf_facet ost$num $DEVNAME
1690 nfs_client_mode && return
1692 sanity_mount_check ||
1693 error "environments are insane!"
1697 if [ -z "$CLIENTONLY" ]; then
1698 echo Setup mgs, mdt, osts
1699 echo $WRITECONF | grep -q "writeconf" && \
1701 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1702 start mgs $MGSDEV $mgs_MOUNT_OPTS
1705 for num in `seq $MDSCOUNT`; do
1706 DEVNAME=$(mdsdevname $num)
1707 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1709 # We started mds, now we should set failover variables properly.
1710 # Set mds${num}failover_HOST if it is not set (the default failnode).
1711 local varname=mds${num}failover_HOST
1712 if [ -z "${!varname}" ]; then
1713 eval mds${num}failover_HOST=$(facet_host mds$num)
1716 if [ $IDENTITY_UPCALL != "default" ]; then
1717 switch_identity $num $IDENTITY_UPCALL
1720 for num in `seq $OSTCOUNT`; do
1721 DEVNAME=$(ostdevname $num)
1722 start ost$num $DEVNAME $OST_MOUNT_OPTS
1724 # We started ost$num, now we should set ost${num}failover variable properly.
1725 # Set ost${num}failover_HOST if it is not set (the default failnode).
1726 varname=ost${num}failover_HOST
1727 if [ -z "${!varname}" ]; then
1728 eval ost${num}failover_HOST=$(facet_host ost${num})
1733 # wait a while to allow sptlrpc configuration be propogated to targets,
1734 # only needed when mounting new target devices.
1737 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1739 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1741 if [ "$MOUNT_2" ]; then
1742 mount_client $MOUNT2
1743 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1748 # by remounting mdt before ost, initial connect from mdt to ost might
1749 # timeout because ost is not ready yet. wait some time to its fully
1750 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1751 # by a context negotiation rpc with $TIMEOUT.
1752 # FIXME better by monitoring import status.
1754 sleep $((TIMEOUT + 5))
1760 mounted_lustre_filesystems() {
1761 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1764 init_facet_vars () {
1765 [ "$CLIENTONLY" ] && return 0
1772 eval export ${facet}_dev=${device}
1773 eval export ${facet}_opt=\"$@\"
1775 local dev=${facet}_dev
1776 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1777 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1779 eval export ${facet}_svc=${label}
1781 local varname=${facet}failover_HOST
1782 if [ -z "${!varname}" ]; then
1783 eval $varname=$(facet_host $facet)
1786 # ${facet}failover_dev is set in cfg file
1787 varname=${facet}failover_dev
1788 if [ -n "${!varname}" ] ; then
1789 eval export ${facet}failover_dev=${!varname}
1791 eval export ${facet}failover_dev=$device
1795 init_facets_vars () {
1798 if ! remote_mds_nodsh; then
1799 for num in `seq $MDSCOUNT`; do
1800 DEVNAME=`mdsdevname $num`
1801 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1805 remote_ost_nodsh && return
1807 for num in `seq $OSTCOUNT`; do
1808 DEVNAME=`ostdevname $num`
1809 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1813 osc_ensure_active () {
1819 while [ $period -lt $timeout ]; do
1820 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1821 if [ $count -eq 0 ]; then
1825 echo "There are $count OST are inactive, wait $period seconds, and try again"
1827 period=$((period+3))
1830 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1834 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1838 init_param_vars () {
1839 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1840 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1841 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1842 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1846 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1848 log "Using TIMEOUT=$TIMEOUT"
1850 osc_ensure_active $SINGLEMDS M $TIMEOUT
1851 osc_ensure_active client c $TIMEOUT
1853 if [ x"$(som_check)" = x"enabled" ]; then
1855 echo "disable quota temporary when SOM enabled"
1857 if [ $QUOTA_AUTO -ne 0 ]; then
1858 if [ "$ENABLE_QUOTA" ]; then
1859 echo "enable quota as required"
1860 setup_quota $MOUNT || return 2
1862 echo "disable quota as required"
1863 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1870 nfs_client_mode () {
1871 if [ "$NFSCLIENT" ]; then
1872 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1873 local clients=$CLIENTS
1874 [ -z $clients ] && clients=$(hostname)
1876 # FIXME: remove hostname when 19215 fixed
1877 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1878 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1879 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1886 nfs_client_mode && return
1890 local mounted=$(mount | grep " $mntpt ")
1891 if [ "$CLIENTONLY" ]; then
1893 # CLIENTONLY should not depend on *_HOST settings
1894 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1895 # in theory someone could create a new,
1896 # client-only config file that assumed lustre was already
1897 # configured and didn't set the MGSNID. If MGSNID is not set,
1898 # then we should use the mgs nid currently being used
1899 # as the default value. bug 18021
1900 [[ x$MGSNID = x ]] &&
1903 if [[ x$mgc != xMGC$MGSNID ]]; then
1904 if [ "$mgs_HOST" ]; then
1905 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1906 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1907 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1913 local myMGS_host=$mgs_HOST
1914 if [ "$NETTYPE" = "ptl" ]; then
1915 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1918 echo Checking config lustre mounted on $mntpt
1919 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1920 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1922 if [ "$mgshost" != "$myMGS_host" ]; then
1923 log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1924 Please use correct config or set mds_HOST correctly!"
1927 sanity_mount_check ||
1928 error "environments are insane!"
1932 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1933 local cltimeout=$(lctl get_param -n timeout)
1934 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1935 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1940 check_and_setup_lustre() {
1941 nfs_client_mode && return
1943 local MOUNTED=$(mounted_lustre_filesystems)
1946 # MOUNT is not mounted
1947 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1948 [ "$REFORMAT" ] && formatall
1950 MOUNTED=$(mounted_lustre_filesystems | head -1)
1951 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1952 export I_MOUNTED=yes
1955 # MOUNT and MOUNT2 are mounted
1956 elif $(echo $MOUNTED | grep -w -q $MOUNT2); then
1958 # MOUNT2 is mounted, MOUNT_2 is not set
1959 if ! [ "$MOUNT_2" ]; then
1960 zconf_umount `hostname` $MOUNT2
1961 export I_UMOUNTED2=yes
1963 # MOUNT2 is mounted, MOUNT_2 is set
1965 check_config $MOUNT2
1974 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1975 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1976 lctl set_param debug_mb=${DEBUG_SIZE};
1979 if [ "$ONLY" == "setup" ]; then
1984 cleanup_and_setup_lustre() {
1985 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1986 lctl set_param debug=0 || true
1988 if [ "$ONLY" == "cleanup" ]; then
1992 check_and_setup_lustre
1995 check_and_cleanup_lustre() {
1996 if [ "`mount | grep $MOUNT`" ]; then
1997 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1998 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2000 if [ "$I_UMOUNTED2" = "yes" ]; then
2001 mount_client $MOUNT2 || error "restore $MOUNT2 failed"
2004 if [ "$I_MOUNTED" = "yes" ]; then
2005 cleanupall -f || error "cleanup failed"
2017 while [ $NETWORK -eq 0 ]; do
2018 if ping -c 1 -w 3 $1 > /dev/null; then
2022 echo "waiting for $1, $((MAX - WAIT)) secs left"
2025 if [ $WAIT -gt $MAX ]; then
2026 echo "Network not available"
2032 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2043 # the sed converts spaces to commas, but leaves the last space
2044 # alone, so the line doesn't end with a comma.
2045 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2048 # list, excluded are the comma separated lists
2049 exclude_items_from_list () {
2055 for item in ${excluded//,/ }; do
2056 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2058 echo $(comma_list $list)
2061 # list, expand are the comma separated lists
2063 local list=${1//,/ }
2064 local expand=${2//,/ }
2067 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2068 echo $(comma_list $expanded)
2071 testslist_filter () {
2072 local script=$LUSTRE/tests/${TESTSUITE}.sh
2074 [ -f $script ] || return 0
2076 local start_at=$START_AT
2077 local stop_at=$STOP_AT
2079 local var=${TESTSUITE//-/_}_START_AT
2080 [ x"${!var}" != x ] && start_at=${!var}
2081 var=${TESTSUITE//-/_}_STOP_AT
2082 [ x"${!var}" != x ] && stop_at=${!var}
2084 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2085 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2086 /^'${start_at}'$/ {flag = 0}
2087 {if (flag == 1) print $0}
2088 /^'${stop_at}'$/ { flag = 1 }'
2092 (cd `dirname $1`; echo $PWD/`basename $1`)
2096 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2097 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2100 local count=${type}COUNT
2101 for ((i=1; i<=${!count}; i++)) do
2102 list="$list ${name}$i"
2104 echo $(comma_list $list)
2107 ##################################
2108 # Adaptive Timeouts funcs
2111 # only check mds, we assume at_max is the same on all nodes
2112 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2113 if [ $at_max -eq 0 ]; then
2123 # suppose that all ost-s has the same at_max set
2124 if [ $facet == "ost" ]; then
2125 do_facet ost1 "lctl get_param -n at_max"
2127 do_facet $facet "lctl get_param -n at_max"
2137 if [ $facet == "ost" ]; then
2138 for i in `seq $OSTCOUNT`; do
2139 do_facet ost$i "lctl set_param at_max=$at_max"
2142 elif [ $facet == "mds" ]; then
2143 for i in `seq $MDSCOUNT`; do
2144 do_facet mds$i "lctl set_param at_max=$at_max"
2147 do_facet $facet "lctl set_param at_max=$at_max"
2152 ##################################
2156 # OBD_FAIL_MDS_ALL_REQUEST_NET
2158 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2159 do_facet client "$1" || RC=$?
2160 do_facet $SINGLEMDS lctl set_param fail_loc=0
2165 # OBD_FAIL_MDS_ALL_REPLY_NET
2167 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2168 do_facet client "$@" || RC=$?
2169 do_facet $SINGLEMDS lctl set_param fail_loc=0
2173 drop_reint_reply() {
2174 # OBD_FAIL_MDS_REINT_NET_REP
2176 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2177 do_facet client "$@" || RC=$?
2178 do_facet $SINGLEMDS lctl set_param fail_loc=0
2183 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2185 do_facet ost1 lctl set_param fail_loc=0x214
2186 do_facet client "$1" || RC=$?
2187 do_facet client "sync"
2188 do_facet ost1 lctl set_param fail_loc=0
2192 drop_ldlm_cancel() {
2193 #define OBD_FAIL_LDLM_CANCEL 0x304
2195 do_facet client lctl set_param fail_loc=0x304
2196 do_facet client "$@" || RC=$?
2197 do_facet client lctl set_param fail_loc=0
2201 drop_bl_callback() {
2202 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2204 do_facet client lctl set_param fail_loc=0x305
2205 do_facet client "$@" || RC=$?
2206 do_facet client lctl set_param fail_loc=0
2211 #define OBD_FAIL_LDLM_REPLY 0x30c
2213 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2214 do_facet client "$@" || RC=$?
2215 do_facet $SINGLEMDS lctl set_param fail_loc=0
2223 echo "clearing fail_loc on $facet"
2224 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2227 set_nodes_failloc () {
2228 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2231 cancel_lru_locks() {
2232 $LCTL mark "cancel_lru_locks $1 start"
2233 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2234 $LCTL set_param -n $d=clear
2236 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2237 $LCTL mark "cancel_lru_locks $1 stop"
2242 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2243 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2244 echo "$DEFAULT_LRU_SIZE"
2249 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2252 lru_resize_disable()
2254 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2259 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2260 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2261 echo there is still data in page cache $FILE ?
2262 lctl get_param -n $FILE
2266 if [[ $MDSDEV1 != $MGSDEV ]]; then
2274 DEBUGSAVE="$(lctl get_param -n debug)"
2278 [ -n "$DEBUGSAVE" ] && \
2279 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2284 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2287 debug_size_restore() {
2288 [ -n "$DEBUG_SIZE_SAVED" ] && \
2289 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2293 start_full_debug_logging() {
2298 local DEBUG_SIZE=150
2300 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2301 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2304 stop_full_debug_logging() {
2309 ##################################
2311 ##################################
2314 local TYPE=${TYPE:-"FAIL"}
2318 # do not dump logs if $1=false
2319 if [ "x$1" = "xfalse" ]; then
2324 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2327 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2328 echo "Dumping lctl log to $ERRLOG"
2329 # We need to dump the logs on all nodes
2330 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2333 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2339 if $FAIL_ON_ERROR; then
2350 # use only if we are ignoring failures for this test, bugno required.
2351 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2352 # e.g. error_ignore 5494 "your message"
2354 local TYPE="IGNORE (bz$1)"
2360 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2365 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2366 [ "$TESTSUITELOG" ] && \
2367 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2370 build_test_filter() {
2371 EXCEPT="$EXCEPT $(testslist_filter)"
2373 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2377 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2378 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2379 [ "$EXCEPT_SLOW" ] && \
2380 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2381 for E in $EXCEPT $ALWAYS_EXCEPT; do
2382 eval EXCEPT_${E}=true
2384 for E in $EXCEPT_SLOW; do
2385 eval EXCEPT_SLOW_${E}=true
2387 for G in $GRANT_CHECK_LIST; do
2388 eval GCHECK_ONLY_${G}=true
2393 if [[ $1 = [a-z]* ]]; then
2400 # print a newline if the last test was skipped
2401 export LAST_SKIPPED=
2405 export base=`basetest $1`
2406 if [ ! -z "$ONLY" ]; then
2408 if [ ${!testname}x != x ]; then
2409 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2414 if [ ${!testname}x != x ]; then
2415 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2424 if [ ${!testname}x != x ]; then
2426 TESTNAME=test_$1 skip "skipping excluded test $1"
2429 testname=EXCEPT_$base
2430 if [ ${!testname}x != x ]; then
2432 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2435 testname=EXCEPT_SLOW_$1
2436 if [ ${!testname}x != x ]; then
2438 TESTNAME=test_$1 skip "skipping SLOW test $1"
2441 testname=EXCEPT_SLOW_$base
2442 if [ ${!testname}x != x ]; then
2444 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2454 EQUALS="======================================================================"
2458 local suffixlen=$((${#EQUALS} - ${#msg}))
2459 [ $suffixlen -lt 5 ] && suffixlen=5
2460 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2465 module_loaded lnet || load_modules
2477 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2482 strace -o $TMP/$1.strace -ttt $*
2484 log "FINISHED: $*: rc $RC"
2489 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2494 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2495 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2496 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2500 echo -n "Resetting fail_loc on all nodes..."
2501 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2509 export tdir=d0.${TESTSUITE}/d${base}
2511 local SAVE_UMASK=`umask`
2514 local BEFORE=`date +%s`
2516 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2518 export TESTNAME=test_$testnum
2520 test_${testnum} || error "test_$testnum failed with $?"
2524 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2525 check_catastrophe || error "LBUG/LASSERT detected"
2526 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2527 pass "($((`date +%s` - $BEFORE))s)"
2535 (cd `dirname $1`; echo $PWD/`basename $1`)
2539 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2540 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2545 export base=`basetest $1`
2546 [ "$CHECK_GRANT" == "no" ] && return 0
2548 testname=GCHECK_ONLY_${base}
2549 [ ${!testname}x == x ] && return 0
2551 echo -n "checking grant......"
2553 # write some data to sync client lost_grant
2554 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2555 for i in `seq $OSTCOUNT`; do
2556 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2557 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2558 count=1 > /dev/null 2>&1
2560 # sync all the data and make sure no pending data on server
2563 #get client grant and server grant
2565 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2566 client_grant=$((client_grant + $d))
2569 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2570 server_grant=$((server_grant + $d))
2573 # cleanup the check_grant file
2574 for i in `seq $OSTCOUNT`; do
2575 rm $DIR1/${tfile}_check_grant_$i
2578 #check whether client grant == server grant
2579 if [ $client_grant != $server_grant ]; then
2580 echo "failed: client:${client_grant} server: ${server_grant}"
2587 ########################
2593 ost=`echo $1 | awk -F_ '{print $3}'`
2594 if [ -z $ost ]; then
2595 ost=`echo $1 | sed 's/-osc.*//'`
2602 [ "$node" != "$(hostname)" ]
2608 for node in $(mdts_nodes); do
2609 remote_node $node && return 0
2616 [ "$CLIENTONLY" ] && return 0 || true
2617 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2623 for node in $(osts_nodes) ; do
2624 remote_node $node && return 0
2631 [ "$CLIENTONLY" ] && return 0 || true
2632 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2638 MGS=$(facet_host mgs)
2639 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2645 for num in `seq $MDSCOUNT`; do
2646 MDSNODES="$MDSNODES $(facet_host mds$num)"
2648 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2654 remote_ost && remote_mds
2658 local OSTNODES=$(facet_host ost1)
2661 for num in `seq $OSTCOUNT`; do
2662 local myOST=$(facet_host ost$num)
2663 OSTNODES="$OSTNODES $myOST"
2665 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2671 # FIXME. We need a list of clients
2672 local myNODES=$HOSTNAME
2675 # CLIENTS (if specified) contains the local client
2676 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2678 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2679 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2682 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2687 remote_nodes_list () {
2688 local rnodes=$(nodes_list)
2689 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2693 init_clients_lists () {
2694 # Sanity check: exclude the local client from RCLIENTS
2695 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2697 # Sanity check: exclude the dup entries
2698 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2700 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2702 # Sanity check: exclude the dup entries from CLIENTS
2703 # for those configs which has SINGLCLIENT set to local client
2704 clients=$(for i in $clients; do echo $i; done | sort -u)
2706 CLIENTS=`comma_list $clients`
2707 local -a remoteclients=($rclients)
2708 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2709 varname=CLIENT$((i + 2))
2710 eval $varname=${remoteclients[i]}
2713 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2716 get_random_entry () {
2719 rnodes=${rnodes//,/ }
2721 local -a nodes=($rnodes)
2722 local num=${#nodes[@]}
2723 local i=$((RANDOM * num * 2 / 65536))
2729 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2734 lctl get_param version | grep -q patchless
2738 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2743 echo $nodes | wc -w || true
2747 local nodes=$(osts_nodes)
2748 local osscount=$(get_node_count "$nodes")
2749 [ ! "$OSTCOUNT" = "$osscount" ]
2753 local nodes=$(mdts_nodes)
2754 local mdtcount=$(get_node_count "$nodes")
2755 [ ! "$MDSCOUNT" = "$mdtcount" ]
2758 generate_machine_file() {
2759 local nodes=${1//,/ }
2760 local machinefile=$2
2761 rm -f $machinefile || error "can't rm $machinefile"
2762 for node in $nodes; do
2763 echo $node >>$machinefile
2768 local file=$1/stripe
2770 $LFS getstripe -v $file || error
2774 check_runas_id_ret() {
2776 local myRUNAS_UID=$1
2777 local myRUNAS_GID=$2
2780 if [ -z "$myRUNAS" ]; then
2781 error_exit "myRUNAS command must be specified for check_runas_id"
2784 $myRUNAS krb5_login.sh || \
2785 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2787 mkdir $DIR/d0_runas_test
2789 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2790 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2791 rm -rf $DIR/d0_runas_test
2796 local myRUNAS_UID=$1
2797 local myRUNAS_GID=$2
2800 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2801 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2802 Please set RUNAS_ID to some UID which exists on MDS and client or
2803 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2806 # obtain the UID/GID for MPI_USER
2810 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2811 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2813 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2814 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2817 # obtain and cache Kerberos ticket-granting ticket
2818 refresh_krb5_tgt() {
2819 local myRUNAS_UID=$1
2820 local myRUNAS_GID=$2
2823 if [ -z "$myRUNAS" ]; then
2824 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2827 CLIENTS=${CLIENTS:-$HOSTNAME}
2828 do_nodes $CLIENTS "set -x
2829 if ! $myRUNAS krb5_login.sh; then
2830 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2835 # Run multiop in the background, but wait for it to print
2836 # "PAUSING" to its stdout before returning from this function.
2837 multiop_bg_pause() {
2838 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2842 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2845 echo "$MULTIOP_PROG $FILE v$ARGS"
2846 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2848 echo "TMPPIPE=${TMPPIPE}"
2849 read -t 60 multiop_output < $TMPPIPE
2850 if [ $? -ne 0 ]; then
2855 if [ "$multiop_output" != "PAUSING" ]; then
2856 echo "Incorrect multiop output: $multiop_output"
2871 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2877 inodes_available () {
2878 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2882 # reset llite stat counters
2883 clear_llite_stats(){
2884 lctl set_param -n llite.*.stats 0
2887 # sum llite stat items
2888 calc_llite_stats() {
2889 local res=$(lctl get_param -n llite.*.stats |
2890 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2894 # reset osc stat counters
2896 lctl set_param -n osc.*.osc_stats 0
2899 # sum osc stat items
2901 local res=$(lctl get_param -n osc.*.osc_stats |
2902 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2907 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2910 calc_osc_kbytes () {
2911 df $MOUNT > /dev/null
2912 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2915 # save_lustre_params(node, parameter_mask)
2916 # generate a stream of formatted strings (<node> <param name>=<param value>)
2917 save_lustre_params() {
2919 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2922 # restore lustre parameters from input stream, produces by save_lustre_params
2923 restore_lustre_params() {
2927 while IFS=" =" read node name val; do
2928 do_node ${node//:/} "lctl set_param -n $name $val"
2932 check_catastrophe() {
2933 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2934 local C=$CATASTROPHE
2935 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2937 if [ $rnodes ]; then
2938 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2939 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2955 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2957 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2958 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2959 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2963 # CMD: determine mds index where directory inode presents
2966 local file=$dir/f0.get_mds_dir_tmpfile
2971 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2972 local -a oldused=($iused)
2974 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
2976 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2977 local -a newused=($iused)
2980 for ((i=0; i<${#newused[@]}; i++)); do
2981 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2987 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2990 mdsrate_cleanup () {
2992 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2997 delayed_recovery_enabled () {
2998 local var=${SINGLEMDS}_svc
2999 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3002 ########################
3004 convert_facet2label() {
3007 if [ x$facet = xost ]; then
3011 local varsvc=${facet}_svc
3013 if [ -n ${!varsvc} ]; then
3016 error "No lablel for $facet!"
3020 get_clientosc_proc_path() {
3026 get_lustre_version () {
3027 local node=${1:-"mds"}
3028 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3031 get_mds_version_major () {
3032 local version=$(get_lustre_version mds)
3033 echo $version | awk -F. '{print $1}'
3036 get_mds_version_minor () {
3037 local version=$(get_lustre_version mds)
3038 echo $version | awk -F. '{print $2}'
3041 get_mdtosc_proc_path() {
3043 local major=$(get_mds_version_major)
3044 local minor=$(get_mds_version_minor)
3045 if [ $major -le 1 -a $minor -le 8 ] ; then
3048 echo "${ost}-osc-MDT0000"
3052 get_osc_import_name() {
3055 local label=$(convert_facet2label $ost)
3057 if [ "$facet" == "mds" ]; then
3058 get_mdtosc_proc_path $label
3062 get_clientosc_proc_path $label
3066 wait_import_state () {
3072 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3073 while [ "${CONN_STATE}" != "${expected}" ]; do
3074 if [ "${expected}" == "DISCONN" ]; then
3075 # for disconn we can check after proc entry is removed
3076 [ "x${CONN_STATE}" == "x" ] && return 0
3077 # with AT we can have connect request timeout ~ reconnect timeout
3078 # and test can't see real disconnect
3079 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3081 # disconnect rpc should be wait not more obd_timeout
3082 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3083 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3085 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3089 log "$CONN_PROC now in ${CONN_STATE} state"
3093 wait_osc_import_state() {
3097 local ost=$(get_osc_import_name $facet $ost_facet)
3102 CONN_PROC="osc.${ost}.ost_server_uuid"
3103 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3104 while [ "${CONN_STATE}" != "${expected}" ]; do
3105 if [ "${expected}" == "DISCONN" ]; then
3106 # for disconn we can check after proc entry is removed
3107 [ "x${CONN_STATE}" == "x" ] && return 0
3108 # with AT we can have connect request timeout ~ reconnect timeout
3109 # and test can't see real disconnect
3110 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3112 # disconnect rpc should be wait not more obd_timeout
3113 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3114 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3116 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3120 log "${ost_facet} now in ${CONN_STATE} state"
3124 get_clientmdc_proc_path() {
3132 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3135 wait_clients_import_state () {
3141 local label=$(convert_facet2label $facet)
3144 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3145 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3146 *) error "unknown facet!" ;;
3149 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3150 error "import is not in ${expected} state"
3159 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3160 $LCTL get_param obdfilter.*.kbytesavail))
3161 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3162 $LCTL get_param -n obdfilter.*.tot_granted))
3163 for ((i=0; i<${#AVAILA[@]}; i++)); do
3164 local -a AVAIL1=(${AVAILA[$i]//=/ })
3165 GRANT=$((${GRANTA[$i]}/1024))
3166 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3167 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3173 do_facet mgs lctl pool_list $1
3177 local fsname=${1%%.*}
3178 local poolname=${1##$fsname.}
3180 do_facet mgs lctl pool_new $1
3182 # get param should return err unless pool is created
3183 [[ $RC -ne 0 ]] && return $RC
3185 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3186 2>/dev/null || echo foo" "" || RC=1
3187 if [[ $RC -eq 0 ]]; then
3190 error "pool_new failed $1"
3195 add_pool_to_list () {
3196 local fsname=${1%%.*}
3197 local poolname=${1##$fsname.}
3199 local listvar=${fsname}_CREATED_POOLS
3200 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3203 remove_pool_from_list () {
3204 local fsname=${1%%.*}
3205 local poolname=${1##$fsname.}
3207 local listvar=${fsname}_CREATED_POOLS
3208 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3211 destroy_pool_int() {
3213 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3214 awk '$1 !~ /^Pool:/ {print $1}')
3215 for ost in $OSTS; do
3216 do_facet mgs lctl pool_remove $1 $ost
3218 do_facet mgs lctl pool_destroy $1
3221 # <fsname>.<poolname> or <poolname>
3223 local fsname=${1%%.*}
3224 local poolname=${1##$fsname.}
3226 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3230 pool_list $fsname.$poolname || return $?
3232 destroy_pool_int $fsname.$poolname
3234 [[ $RC -ne 0 ]] && return $RC
3236 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3237 2>/dev/null || echo foo" "foo" || RC=1
3239 if [[ $RC -eq 0 ]]; then
3240 remove_pool_from_list $fsname.$poolname
3242 error "destroy pool failed $1"
3248 local fsname=${1:-$FSNAME}
3250 local listvar=${fsname}_CREATED_POOLS
3254 [ x${!listvar} = x ] && return 0
3256 echo destroy the created pools: ${!listvar}
3257 for poolname in ${!listvar//,/ }; do
3258 destroy_pool $fsname.$poolname
3263 local fsname=${1:-$FSNAME}
3265 destroy_pools $fsname
3271 local ts=$(date +%s)
3273 # bug 20237, comment 11
3274 # It would also be useful to provide the option
3275 # of writing the file to an NFS directory so it doesn't need to be copied.
3278 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3280 # dump lustre logs, dmesg
3281 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3282 lctl dk \\\$log >/dev/null;
3283 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3286 # FIXME: does it make sense to collect the logs for $ts only, but all
3288 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3289 local logs=$TMP/'*'${TESTSUITE}'*'
3291 logs=$logs' '$tmp/'*'$ts'*'
3293 for node in ${list//,/ }; do
3294 rsync -az $node:"$logs" $TMP
3297 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3298 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3304 local list=${1:-$(comma_list $(nodes_list))}
3306 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3318 for i in $(seq 0 $num_mntpts); do
3319 cmd="ls -laf ${mntpt_root}$i/$dir"
3325 for pid in $pids; do