2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
19 #export PDSH="pdsh -S -Rssh -w"
21 # function used by scripts run on remote nodes
22 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
23 . $LUSTRE/tests/functions.sh
27 [[ $DIR/ = $MOUNT/* ]] || \
28 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
29 [[ $DIR1/ = $MOUNT1/* ]] || \
30 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
31 [[ $DIR2/ = $MOUNT2/* ]] || \
32 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
34 [ -n "$failed" ] && exit 99 || true
38 echo "usage: $0 [-r] [-f cfgfile]"
46 [ "$TESTSUITE" == "lfscktest" ] && return 0
47 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
48 local form="%-13s %-17s %s\n"
49 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
50 echo "------------------------------------------------------------------------------------"
51 for O in $TESTSUITE_LIST; do
54 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
57 local log=${TMP}/${o}.log
58 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
59 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
60 [ "${!O}" = "done" ] && \
61 printf "$form" "Done" "$O" "E=$skipped" && \
62 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
66 for O in $TESTSUITE_LIST; do
67 if [ "${!O}" = "no" ]; then
69 # only for those tests suits which are run directly from acc-sm script:
70 # bonnie, iozone, etc.
71 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
72 printf "$form" "UNFINISHED" "$O" ""
74 printf "$form" "Skipped" "$O" ""
79 for O in $TESTSUITE_LIST; do
80 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
81 printf "$form" "UNFINISHED" "$O" ""
86 export LUSTRE=`absolute_path $LUSTRE`
87 export TESTSUITE=`basename $0 .sh`
88 export TEST_FAILED=false
89 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
91 export MKE2FS=${MKE2FS:-mke2fs}
92 export DEBUGFS=${DEBUGFS:-debugfs}
93 export TUNE2FS=${TUNE2FS:-tune2fs}
94 export E2LABEL=${E2LABEL:-e2label}
95 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
96 export E2FSCK=${E2FSCK:-e2fsck}
98 #[ -d /r ] && export ROOT=${ROOT:-/r}
99 export TMP=${TMP:-$ROOT/tmp}
100 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
101 export HOSTNAME=${HOSTNAME:-`hostname`}
102 if ! echo $PATH | grep -q $LUSTRE/utils; then
103 export PATH=$PATH:$LUSTRE/utils
105 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
106 export PATH=$PATH:$LUSTRE/utils/gss
108 if ! echo $PATH | grep -q $LUSTRE/tests; then
109 export PATH=$PATH:$LUSTRE/tests
111 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
112 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
113 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
114 export PATH=$PATH:$LUSTRE/tests/racer
116 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
117 export PATH=$PATH:$LUSTRE/tests/mpi
119 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
120 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
121 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
122 [ ! -f "$LFS" ] && export LFS=$(which lfs)
123 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
124 if [ ! -f "$L_GETIDENTITY" ]; then
125 if `which l_getidentity > /dev/null 2>&1`; then
126 export L_GETIDENTITY=$(which l_getidentity)
128 export L_GETIDENTITY=NONE
131 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
132 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
133 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
134 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
135 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
136 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
137 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
138 export FSTYPE=${FSTYPE:-"ldiskfs"}
139 export NAME=${NAME:-local}
140 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
141 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
142 export LGSSD=$(which lgssd)
143 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
144 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
145 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
147 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
150 if [ "$ACCEPTOR_PORT" ]; then
151 export PORT_OPT="--port $ACCEPTOR_PORT"
156 echo "Using GSS/krb5 ptlrpc security flavor"
157 which lgss_keyring > /dev/null 2>&1 || \
158 error "built with gss disabled! SEC=$SEC"
169 IDENTITY_UPCALL=false
172 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
174 # Paths on remote nodes, if different
175 export RLUSTRE=${RLUSTRE:-$LUSTRE}
176 export RPWD=${RPWD:-$PWD}
177 export I_MOUNTED=${I_MOUNTED:-"no"}
178 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
179 ! -f `dirname $0`/../mds/mds.ko ]; then
180 export CLIENTMODSONLY=yes
185 while getopts "rvwf:" opt $*; do
188 r) REFORMAT=--reformat;;
190 w) WRITECONF=writeconf;;
195 shift $((OPTIND - 1))
198 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
203 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
204 *) EXT=".ko"; USE_QUOTA=yes;;
209 /sbin/lsmod | grep -q $1
216 BASE=`basename $module $EXT`
218 module_loaded ${BASE} && return
220 if [ -f ${LUSTRE}/${module}${EXT} ]; then
221 insmod ${LUSTRE}/${module}${EXT} $@
223 # must be testing a "make install" or "rpm" installation
224 # note failed to load ptlrpc_gss is considered not fatal
225 if [ "$BASE" == "ptlrpc_gss" ]; then
226 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
233 load_modules_local() {
234 if [ -n "$MODPROBE" ]; then
238 if [ "$HAVE_MODULES" = true ]; then
244 echo Loading modules from $LUSTRE
245 load_module ../libcfs/libcfs/libcfs
246 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
247 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
249 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
250 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
251 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
252 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
253 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
254 echo "lnet options: '$LNETOPTS'"
255 # note that insmod will ignore anything in modprobe.conf
256 load_module ../lnet/lnet/lnet $LNETOPTS
257 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
258 load_module ../lnet/klnds/$LNETLND
259 load_module lvfs/lvfs
260 load_module obdclass/obdclass
261 load_module ptlrpc/ptlrpc
262 load_module ptlrpc/gss/ptlrpc_gss
263 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
271 if ! client_only; then
272 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
273 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
274 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
279 load_module lvfs/fsfilt_$FSTYPE
283 load_module obdfilter/obdfilter
286 load_module llite/lustre
287 load_module llite/llite_lloop
288 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
290 rm -f $OGDB/ogdb-$HOSTNAME
291 $LCTL modules > $OGDB/ogdb-$HOSTNAME
293 # 'mount' doesn't look in $PATH, just sbin
294 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
300 # load modules on remote nodes optionally
301 # lustre-tests have to be installed on these nodes
302 if $LOAD_MODULES_REMOTE ; then
303 local list=$(comma_list $(remote_nodes_list))
304 echo loading modules on $list
305 do_rpc_nodes $list load_modules
310 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
311 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
312 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
313 echo "$LEAK_LUSTRE" 1>&2
314 echo "$LEAK_PORTALS" 1>&2
315 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
316 echo "Memory leaks detected"
317 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
323 wait_exit_ST client # bug 12845
325 $LUSTRE_RMMOD $FSTYPE || return 2
327 if $LOAD_MODULES_REMOTE ; then
328 local list=$(comma_list $(remote_nodes_list))
329 echo unloading modules on $list
330 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
331 do_rpc_nodes $list check_mem_leak
336 check_mem_leak || return 254
338 echo "modules unloaded."
342 check_gss_daemon_facet() {
346 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
347 if [ $num -ne 1 ]; then
348 echo "$num instance of $dname on $facet"
357 do_facet $facet "killall -2 $@ 2>/dev/null || true"
360 start_gss_daemons() {
362 for num in `seq $MDSCOUNT`; do
363 do_facet mds$num "$LSVCGSSD -v"
365 do_facet mds$num "$LGSSD -v"
369 for num in `seq $OSTCOUNT`; do
370 do_facet ost$num "$LSVCGSSD -v"
373 # FIXME: is "client" the right facet name?
375 do_facet client "$LGSSD -v"
378 # wait daemons entering "stable" status
382 # check daemons are running
384 for num in `seq $MDSCOUNT`; do
385 check_gss_daemon_facet mds$num lsvcgssd
387 check_gss_daemon_facet mds$num lgssd
390 for num in `seq $OSTCOUNT`; do
391 check_gss_daemon_facet ost$num lsvcgssd
394 check_gss_daemon_facet client lgssd
399 for num in `seq $MDSCOUNT`; do
400 send_sigint mds$num lsvcgssd lgssd
402 for num in `seq $OSTCOUNT`; do
403 send_sigint ost$num lsvcgssd
405 send_sigint client lgssd
412 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
413 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
421 # maybe cleanup credential cache?
427 local device=`mdsdevname $num`
428 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
434 local device=`ostdevname $num`
435 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
443 local dev=$(facet_active $facet)_dev
444 local opt=${facet}_opt
445 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
446 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
448 if [ $RC -ne 0 ]; then
449 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
450 echo "Start of ${!dev} on ${facet} failed ${RC}"
452 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
453 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
454 lctl set_param debug_mb=${DEBUG_SIZE}; \
457 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
458 [ -z "$label" ] && echo no label for ${!dev} && exit 1
459 eval export ${facet}_svc=${label}
460 echo Started ${label}
465 # start facet device options
471 eval export ${facet}_dev=${device}
472 eval export ${facet}_opt=\"$@\"
474 local varname=${facet}failover_dev
475 if [ -n "${!varname}" ] ; then
476 eval export ${facet}failover_dev=${!varname}
478 eval export ${facet}failover_dev=$device
481 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
491 HOST=`facet_active_host $facet`
492 [ -z $HOST ] && echo stop: no host for $facet && return 0
494 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
495 if [ ${running} -ne 0 ]; then
496 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
497 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
500 # umount should block, but we should wait for unrelated obd's
501 # like the MGS or MGC to also stop.
502 wait_exit_ST ${facet}
505 # save quota version (both administrative and operational quotas)
506 # add an additional parameter if mountpoint is ever different from $MOUNT
507 quota_save_version() {
508 local fsname=${2:-$FSNAME}
510 local ver=$(tr -c -d "123" <<< $spec)
511 local type=$(tr -c -d "ug" <<< $spec)
513 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
515 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
517 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
519 local osts=$(get_facets OST)
520 for ost in ${osts//,/ }; do
522 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
526 # client could mount several lustre
528 local fsname=${1:-$FSNAME}
530 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
531 do_nodes $(comma_list $(osts_nodes)) \
532 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
536 restore_quota_type () {
537 local mntpt=${1:-$MOUNT}
538 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
539 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
542 quota_save_version $old_QUOTA_TYPE
549 # 1. run quotacheck only if quota is off
550 # 2. save the original quota_type params, restore them after testing
552 # Suppose that quota type the same on mds and ost
553 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
554 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
555 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
556 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
557 export old_QUOTA_TYPE=$quota_type
558 quota_save_version $QUOTA_TYPE
561 local quota_usrs=$QUOTA_USERS
563 # get_filesystem_size
564 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
565 local blk_soft=$((disksz + 1024))
566 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
568 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
570 local i_hard=$((i_soft + i_soft / 20))
572 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
573 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
576 for usr in $quota_usrs; do
577 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
579 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
581 eval $cmd || error "$cmd FAILED!"
583 # display the quota status
584 echo "Quota settings for $usr : "
585 $LFS quota -v -u $usr $mntpt || true
593 # Only supply -o to mount if we have options
594 if [ -n "$MOUNTOPT" ]; then
595 OPTIONS="-o $MOUNTOPT"
597 local device=$MGSNID:/$FSNAME
598 if [ -z "$mnt" -o -z "$FSNAME" ]; then
599 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
603 echo "Starting client: $client: $OPTIONS $device $mnt"
604 do_node $client mkdir -p $mnt
605 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
607 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
608 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
609 lctl set_param debug_mb=${DEBUG_SIZE}"
622 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
623 if [ $running -ne 0 ]; then
624 echo "Stopping client $client $mnt (opts:$force)"
625 do_node $client lsof -t $mnt || need_kill=no
626 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
627 pids=$(do_node $client lsof -t $mnt | sort -u);
628 if [ -n $pids ]; then
629 do_node $client kill -9 $pids || true
633 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
634 if [ $busy -ne 0 ] ; then
635 echo "$mnt is still busy, wait one second" && sleep 1
636 do_node $client umount $force $mnt
641 # nodes is comma list
642 sanity_mount_check_nodes () {
648 # FIXME: assume that all cluster nodes run the same os
649 [ "$(uname)" = Linux ] || return 0
652 for mnt in $mnts ; do
653 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
654 mpts=\\\$(mount | grep -w -c $mnt);
655 if [ \\\$running -ne \\\$mpts ]; then
656 echo \\\$(hostname) env are INSANE!;
664 sanity_mount_check_servers () {
666 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
667 echo Checking servers environments
669 # FIXME: modify get_facets to display all facets wo params
670 local facets="$(get_facets OST),$(get_facets MDS),mgs"
674 for facet in ${facets//,/ }; do
675 node=$(facet_host ${facet})
676 mnt=${MOUNT%/*}/${facet}
677 sanity_mount_check_nodes $node $mnt ||
678 { error "server $node environments are insane!"; return 1; }
682 sanity_mount_check_clients () {
683 local clients=${1:-$CLIENTS}
684 local mntpt=${2:-$MOUNT}
685 local mntpt2=${3:-$MOUNT2}
687 [ -z $clients ] && clients=$(hostname)
688 echo Checking clients $clients environments
690 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
691 error "clients environments are insane!"
694 sanity_mount_check () {
695 sanity_mount_check_servers || return 1
696 sanity_mount_check_clients || return 2
699 # mount clients if not mouted
700 zconf_mount_clients() {
706 # Only supply -o to mount if we have options
707 if [ -n "$MOUNTOPT" ]; then
708 OPTIONS="-o $MOUNTOPT"
710 local device=$MGSNID:/$FSNAME
711 if [ -z "$mnt" -o -z "$FSNAME" ]; then
712 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
716 echo "Starting client $clients: $OPTIONS $device $mnt"
719 running=\\\$(mount | grep -c $mnt' ');
721 if [ \\\$running -eq 0 ] ; then
723 mount -t lustre $OPTIONS $device $mnt;
726 exit \\\$rc" || return ${PIPESTATUS[0]}
728 echo "Started clients $clients: "
729 do_nodes $clients "mount | grep -w $mnt"
731 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
732 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
733 lctl set_param debug_mb=${DEBUG_SIZE};"
738 zconf_umount_clients() {
745 echo "Stopping clients: $clients $mnt (opts:$force)"
746 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
747 if [ \\\$running -ne 0 ] ; then
748 echo Stopping client \\\$(hostname) client $mnt opts:$force;
749 lsof -t $mnt || need_kill=no;
750 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
751 pids=\\\$(lsof -t $mnt | sort -u);
752 if [ -n \\\"\\\$pids\\\" ]; then
756 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
757 if [ \\\$busy -ne 0 ] ; then
758 echo "$mnt is still busy, wait one second" && sleep 1;
764 shudown_node_hard () {
768 for i in $(seq $attempts) ; do
771 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
772 echo "waiting for $host to fail attempts=$attempts"
773 [ $i -lt $attempts ] || \
774 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
780 local mnt=${2:-$MOUNT}
783 if [ "$FAILURE_MODE" = HARD ]; then
784 shudown_node_hard $client
786 zconf_umount_clients $client $mnt -f
792 if [ "$FAILURE_MODE" = HARD ]; then
793 shudown_node_hard $(facet_active_host $facet)
794 elif [ "$FAILURE_MODE" = SOFT ]; then
801 if [ "$FAILURE_MODE" = HARD ]; then
802 $POWER_UP `facet_active_host $facet`
810 if [ "$FAILURE_MODE" = HARD ]; then
816 # recovery-scale functions
817 check_progs_installed () {
822 do_nodes $clients "PATH=:$PATH; status=true;
823 for prog in $progs; do
824 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
825 echo \\\$prog missing on \\\$(hostname);
833 echo __$(echo $1 | tr '-' 'X')
836 start_client_load() {
839 local var=$(client_var_name $client)_load
840 eval export ${var}=$load
842 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
843 BREAK_ON_ERROR=$BREAK_ON_ERROR \
844 END_RUN_FILE=$END_RUN_FILE \
845 LOAD_PID_FILE=$LOAD_PID_FILE \
846 TESTSUITELOG=$TESTSUITELOG \
848 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
849 log "Started client load: ${load} on $client"
854 start_client_loads () {
855 local -a clients=(${1//,/ })
856 local numloads=${#CLIENT_LOADS[@]}
859 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
860 testnum=$((nodenum % numloads))
861 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
865 # only for remote client
866 check_client_load () {
868 local var=$(client_var_name $client)_load
869 local TESTLOAD=run_${!var}.sh
871 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
873 # bug 18914: try to connect several times not only when
874 # check ps, but while check_catastrophe also
877 while [ $RC = 254 -a $tries -gt 0 ]; do
881 if ! check_catastrophe $client; then
883 if [ $RC -eq 254 ]; then
884 # FIXME: not sure how long we shuold sleep here
888 echo "check catastrophe failed: RC=$RC "
892 # We can continue try to connect if RC=254
893 # Just print the warning about this
894 if [ $RC = 254 ]; then
895 echo "got a return status of $RC from do_node while checking catastrophe on $client"
898 # see if the load is still on the client
901 while [ $RC = 254 -a $tries -gt 0 ]; do
905 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
910 if [ $RC = 254 ]; then
911 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
912 # see if we can diagnose a bit why this is
917 check_client_loads () {
918 local clients=${1//,/ }
922 for client in $clients; do
923 check_client_load $client
925 if [ "$rc" != 0 ]; then
926 log "Client load failed on node $client, rc=$rc"
932 restart_client_loads () {
933 local clients=${1//,/ }
934 local expectedfail=${2:-""}
938 for client in $clients; do
939 check_client_load $client
941 if [ "$rc" != 0 -a "$expectedfail" ]; then
942 local var=$(client_var_name $client)_load
943 start_client_load $client ${!var}
944 echo "Restarted client load ${!var}: on $client. Checking ..."
945 check_client_load $client
947 if [ "$rc" != 0 ]; then
948 log "Client load failed to restart on node $client, rc=$rc"
949 # failure one client load means test fail
950 # we do not need to check other
958 # End recovery-scale functions
960 # verify that lustre actually cleaned up properly
962 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
963 error "LBUG/LASSERT detected"
964 BUSY=`dmesg | grep -i destruct || true`
967 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
971 check_mem_leak || exit 204
973 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
974 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
976 if module_loaded lnet || module_loaded libcfs; then
977 echo "$0: modules still loaded..." 1>&2
994 RESULT=$(do_node $node "$TEST")
995 if [ "$RESULT" == "$FINAL" ]; then
996 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
999 [ $WAIT -ge $MAX ] && break
1000 echo "Waiting $((MAX - WAIT)) secs for update"
1001 WAIT=$((WAIT + sleep))
1004 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1008 wait_update_facet () {
1010 wait_update $(facet_active_host $facet) "$@"
1013 wait_delete_completed () {
1014 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1015 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1019 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1021 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1022 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1023 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1024 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1028 echo "Delete is not completed in $MAX_WAIT sec"
1034 check_network "$host" 900
1035 while ! do_node $host hostname > /dev/null; do sleep 5; done
1040 local host=`facet_active_host $facet`
1044 wait_recovery_complete () {
1047 # Use default policy if $2 is not passed by caller.
1048 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1049 # as we are in process of changing obd_timeout in different ways
1050 # let's set MAX longer than that
1051 local MAX=${2:-$(( TIMEOUT * 4 ))}
1053 local var_svc=${facet}_svc
1054 local procfile="*.${!var_svc}.recovery_status"
1058 while [ $WAIT -lt $MAX ]; do
1059 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1060 [[ $STATUS = "status: COMPLETE" ]] && return 0
1063 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1065 echo "$facet recovery not done in $MAX sec. $STATUS"
1069 wait_mds_ost_sync () {
1070 # just because recovery is done doesn't mean we've finished
1071 # orphan cleanup. Wait for llogs to get synchronized.
1072 echo "Waiting for orphan cleanup..."
1073 # MAX value includes time needed for MDS-OST reconnection
1074 local MAX=$(( TIMEOUT * 2 ))
1076 while [ $WAIT -lt $MAX ]; do
1077 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1078 "$LCTL get_param -n obdfilter.*.mds_sync"))
1080 for ((i=0; i<${#sync[@]}; i++)); do
1081 [ ${sync[$i]} -eq 0 ] && continue
1082 # there is a not finished MDS-OST synchronization
1086 sleep 2 # increase waiting time and cover statfs cache
1087 [ ${con} -eq 1 ] && return 0
1088 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1091 echo "$facet recovery not done in $MAX sec. $STATUS"
1095 wait_destroy_complete () {
1096 echo "Waiting for destroy to be done..."
1097 # MAX value shouldn't be big as this mean server responsiveness
1098 # never increase this just to make test pass but investigate
1099 # why it takes so long time
1102 while [ $WAIT -lt $MAX ]; do
1103 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1105 for ((i=0; i<${#RPCs[@]}; i++)); do
1106 [ ${RPCs[$i]} -eq 0 ] && continue
1107 # there are still some destroy RPCs in flight
1112 [ ${con} -eq 1 ] && return 0 # done waiting
1113 echo "Waiting $WAIT secs for destroys to be done."
1116 echo "Destroys weren't done in $MAX sec."
1126 # conf-sanity 31 takes a long time cleanup
1127 while [ $WAIT -lt 300 ]; do
1128 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1129 [ -z "${running}" ] && return 0
1130 echo "waited $WAIT for${running}"
1131 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1133 WAIT=$((WAIT + INTERVAL))
1135 echo "service didn't stop after $WAIT seconds. Still running:"
1140 wait_remote_prog () {
1146 [ "$PDSH" = "no_dsh" ] && return 0
1148 while [ $WAIT -lt $2 ]; do
1149 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1150 [ -z "${running}" ] && return 0 || true
1151 echo "waited $WAIT for: "
1153 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1155 WAIT=$((WAIT + INTERVAL))
1157 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1158 [ -z "$pids" ] && return 0
1159 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1160 # FIXME: not portable
1161 for pid in $pids; do
1162 cat /proc/${pid}/status || true
1163 cat /proc/${pid}/wchan || true
1165 kill -9 $pid || true
1174 # not every config has many clients
1175 if [ ! -z "$CLIENTS" ]; then
1176 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1178 df $MOUNT > /dev/null
1182 client_reconnect() {
1183 uname -n >> $MOUNT/recon
1184 if [ -z "$CLIENTS" ]; then
1185 df $MOUNT; uname -n >> $MOUNT/recon
1187 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1189 echo Connected clients:
1191 ls -l $MOUNT/recon > /dev/null
1198 echo "Failing $facet on node `facet_active_host $facet`"
1199 shutdown_facet $facet
1200 [ -n "$sleep_time" ] && sleep $sleep_time
1202 change_active $facet
1203 local TO=`facet_active_host $facet`
1204 echo "Failover $facet to $TO"
1206 mount_facet $facet || error "Restart of $facet failed"
1215 do_facet $facet sync
1217 local svc=${facet}_svc
1218 do_facet $facet $LCTL --device %${!svc} notransno
1219 do_facet $facet $LCTL --device %${!svc} readonly
1220 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1221 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1224 replay_barrier_nodf() {
1225 local facet=$1 echo running=${running}
1226 do_facet $facet sync
1227 local svc=${facet}_svc
1228 echo Replay barrier on ${!svc}
1229 do_facet $facet $LCTL --device %${!svc} notransno
1230 do_facet $facet $LCTL --device %${!svc} readonly
1231 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1232 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1235 replay_barrier_nosync() {
1236 local facet=$1 echo running=${running}
1237 local svc=${facet}_svc
1238 echo Replay barrier on ${!svc}
1239 do_facet $facet $LCTL --device %${!svc} notransno
1240 do_facet $facet $LCTL --device %${!svc} readonly
1241 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1242 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1245 mds_evict_client() {
1246 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1247 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1250 ost_evict_client() {
1251 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1252 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1256 facet_failover $* || error "failover: $?"
1257 client_df || error "post-failover df: $?"
1262 facet_failover $facet
1268 change_active $facet
1269 mount_facet $facet -o abort_recovery
1270 client_df || echo "first df failed: $?"
1272 client_df || error "post-failover df: $?"
1276 echo There is no lmc. This is mountconf, baby.
1281 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1282 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1288 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1294 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1295 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1296 if [ -z "$ID" ]; then
1297 echo "Could not get a ptl id for $1..."
1306 h2name_or_ip "$1" "tcp"
1311 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1312 if type __h2elan >/dev/null 2>&1; then
1315 ID=`echo $1 | sed 's/[^0-9]*//g'`
1323 h2name_or_ip "$1" "openib"
1325 declare -fx h2openib
1328 h2name_or_ip "$1" "o2ib"
1335 [ "$facet" == client ] && echo -n $HOSTNAME && return
1336 varname=${facet}_HOST
1337 if [ -z "${!varname}" ]; then
1338 if [ "${facet:0:3}" == "ost" ]; then
1339 eval ${facet}_HOST=${ost_HOST}
1347 local activevar=${facet}active
1349 if [ -f $TMP/${facet}active ] ; then
1350 source $TMP/${facet}active
1353 active=${!activevar}
1354 if [ -z "$active" ] ; then
1361 facet_active_host() {
1363 local active=`facet_active $facet`
1364 if [ "$facet" == client ]; then
1367 echo `facet_host $active`
1373 local failover=${facet}failover
1374 host=`facet_host $failover`
1375 [ -z "$host" ] && return
1376 local curactive=`facet_active $facet`
1377 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1378 eval export ${facet}active=$facet
1380 eval export ${facet}active=$failover
1382 # save the active host for this facet
1383 local activevar=${facet}active
1384 echo "$activevar=${!activevar}" > $TMP/$activevar
1389 # do not stripe off hostname if verbose, bug 19215
1390 if [ x$1 = x--verbose ]; then
1398 if [ "$HOST" = "$HOSTNAME" ]; then
1400 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1401 echo "cannot run remote command on $HOST with $myPDSH"
1405 echo "CMD: $HOST $@" >&2
1406 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1409 if [ "$myPDSH" = "rsh" ]; then
1410 # we need this because rsh does not return exit code of an executed command
1411 local command_status="$TMP/cs"
1412 rsh $HOST ":> $command_status"
1413 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1414 cd $RPWD; sh -c \"$@\") ||
1415 echo command failed >$command_status"
1416 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1421 # print HOSTNAME for myPDSH="no_dsh"
1422 if [[ $myPDSH = no_dsh ]]; then
1423 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1425 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1428 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1430 return ${PIPESTATUS[0]}
1433 single_local_node () {
1434 [ "$1" = "$HOSTNAME" ]
1439 # do not stripe off hostname if verbose, bug 19215
1440 if [ x$1 = x--verbose ]; then
1448 if $(single_local_node $rnodes); then
1450 do_node --verbose $rnodes $@
1457 # This is part from do_node
1460 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1461 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1464 echo "CMD: $rnodes $@" >&2
1465 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1469 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1471 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1473 return ${PIPESTATUS[0]}
1479 local HOST=`facet_active_host $facet`
1480 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1487 # make sure its not already running
1489 rm -f $TMP/${facet}active
1490 do_facet ${facet} $MKFS $*
1496 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1497 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1504 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1505 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1513 # make sure we are using the primary server, so test-framework will
1514 # be able to clean up properly.
1515 activemds=`facet_active mds1`
1516 if [ $activemds != "mds1" ]; then
1520 local clients=$CLIENTS
1521 [ -z $clients ] && clients=$(hostname)
1523 zconf_umount_clients $clients $MOUNT "$*" || true
1524 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1526 [ "$CLIENTONLY" ] && return
1527 # The add fn does rm ${facet}active file, this would be enough
1528 # if we use do_facet <facet> only after the facet added, but
1529 # currently we use do_facet mds in local.sh
1530 for num in `seq $MDSCOUNT`; do
1532 rm -f ${TMP}/mds${num}active
1535 for num in `seq $OSTCOUNT`; do
1537 rm -f $TMP/ost${num}active
1544 nfs_client_mode && return
1554 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1558 if [ "$IAMDIR" == "yes" ]; then
1559 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1560 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1563 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1565 if [ ! -z $SEC ]; then
1566 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1567 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1568 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1572 # We need ldiskfs here, may as well load them all
1574 [ "$CLIENTONLY" ] && return
1575 echo Formatting mgs, mds, osts
1576 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1577 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1580 for num in `seq $MDSCOUNT`; do
1581 echo "Format mds$num: $(mdsdevname $num)"
1583 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1585 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1589 for num in `seq $OSTCOUNT`; do
1590 echo "Format ost$num: $(ostdevname $num)"
1592 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1594 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1600 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1604 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1608 # 0: success, the old identity set already.
1609 # 1: success, the old identity does not set.
1614 local j=`expr $num - 1`
1615 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1617 if [ -z "$MDT" ]; then
1621 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1624 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1626 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1629 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1631 if [ $old = "NONE" ]; then
1640 zconf_umount `hostname` $1 || error "umount failed"
1641 zconf_mount `hostname` $1 || error "mount failed"
1644 writeconf_facet () {
1648 do_facet $facet "$TUNEFS --writeconf $dev"
1652 for num in `seq $MDSCOUNT`; do
1653 DEVNAME=$(mdsdevname $num)
1654 writeconf_facet mds$num $DEVNAME
1657 for num in `seq $OSTCOUNT`; do
1658 DEVNAME=$(ostdevname $num)
1659 writeconf_facet ost$num $DEVNAME
1664 nfs_client_mode && return
1666 sanity_mount_check ||
1667 error "environments are insane!"
1671 if [ -z "$CLIENTONLY" ]; then
1672 echo Setup mgs, mdt, osts
1673 echo $WRITECONF | grep -q "writeconf" && \
1675 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1676 start mgs $MGSDEV $mgs_MOUNT_OPTS
1679 for num in `seq $MDSCOUNT`; do
1680 DEVNAME=$(mdsdevname $num)
1681 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1683 # We started mds, now we should set failover variables properly.
1684 # Set mds${num}failover_HOST if it is not set (the default failnode).
1685 local varname=mds${num}failover_HOST
1686 if [ -z "${!varname}" ]; then
1687 eval mds${num}failover_HOST=$(facet_host mds$num)
1690 if [ $IDENTITY_UPCALL != "default" ]; then
1691 switch_identity $num $IDENTITY_UPCALL
1694 for num in `seq $OSTCOUNT`; do
1695 DEVNAME=$(ostdevname $num)
1696 start ost$num $DEVNAME $OST_MOUNT_OPTS
1698 # We started ost$num, now we should set ost${num}failover variable properly.
1699 # Set ost${num}failover_HOST if it is not set (the default failnode).
1700 varname=ost${num}failover_HOST
1701 if [ -z "${!varname}" ]; then
1702 eval ost${num}failover_HOST=$(facet_host ost${num})
1707 # wait a while to allow sptlrpc configuration be propogated to targets,
1708 # only needed when mounting new target devices.
1711 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1713 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1715 if [ "$MOUNT_2" ]; then
1716 mount_client $MOUNT2
1717 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1722 # by remounting mdt before ost, initial connect from mdt to ost might
1723 # timeout because ost is not ready yet. wait some time to its fully
1724 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1725 # by a context negotiation rpc with $TIMEOUT.
1726 # FIXME better by monitoring import status.
1728 sleep $((TIMEOUT + 5))
1734 mounted_lustre_filesystems() {
1735 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1738 init_facet_vars () {
1739 [ "$CLIENTONLY" ] && return 0
1746 eval export ${facet}_dev=${device}
1747 eval export ${facet}_opt=\"$@\"
1749 local dev=${facet}_dev
1750 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1751 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1753 eval export ${facet}_svc=${label}
1755 local varname=${facet}failover_HOST
1756 if [ -z "${!varname}" ]; then
1757 eval $varname=$(facet_host $facet)
1760 # ${facet}failover_dev is set in cfg file
1761 varname=${facet}failover_dev
1762 if [ -n "${!varname}" ] ; then
1763 eval export ${facet}failover_dev=${!varname}
1765 eval export ${facet}failover_dev=$device
1769 init_facets_vars () {
1772 if ! remote_mds_nodsh; then
1773 for num in `seq $MDSCOUNT`; do
1774 DEVNAME=`mdsdevname $num`
1775 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1779 remote_ost_nodsh && return
1781 for num in `seq $OSTCOUNT`; do
1782 DEVNAME=`ostdevname $num`
1783 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1787 osc_ensure_active () {
1793 while [ $period -lt $timeout ]; do
1794 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1795 if [ $count -eq 0 ]; then
1799 echo "There are $count OST are inactive, wait $period seconds, and try again"
1801 period=$((period+3))
1804 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1808 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1812 init_param_vars () {
1813 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1814 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1815 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1816 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1820 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1822 log "Using TIMEOUT=$TIMEOUT"
1824 osc_ensure_active $SINGLEMDS M $TIMEOUT
1825 osc_ensure_active client c $TIMEOUT
1827 if [ x"$(som_check)" = x"enabled" ]; then
1830 if [ "$ENABLE_QUOTA" ]; then
1831 setup_quota $MOUNT || return 2
1835 nfs_client_mode () {
1836 if [ "$NFSCLIENT" ]; then
1837 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1838 local clients=$CLIENTS
1839 [ -z $clients ] && clients=$(hostname)
1841 # FIXME: remove hostname when 19215 fixed
1842 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1843 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1844 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1851 nfs_client_mode && return
1855 local mounted=$(mount | grep " $mntpt ")
1856 if [ "$CLIENTONLY" ]; then
1858 # CLIENTONLY should not depend on *_HOST settings
1859 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1860 # in theory someone could create a new,
1861 # client-only config file that assumed lustre was already
1862 # configured and didn't set the MGSNID. If MGSNID is not set,
1863 # then we should use the mgs nid currently being used
1864 # as the default value. bug 18021
1865 [[ x$MGSNID = x ]] &&
1868 if [[ x$mgc != xMGC$MGSNID ]]; then
1869 if [ "$mgs_HOST" ]; then
1870 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1871 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1872 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1878 local myMGS_host=$mgs_HOST
1879 if [ "$NETTYPE" = "ptl" ]; then
1880 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1883 echo Checking config lustre mounted on $mntpt
1884 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1885 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1887 # if [ "$mgshost" != "$myMGS_host" ]; then
1888 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1889 # Please use correct config or set mds_HOST correctly!"
1892 sanity_mount_check ||
1893 error "environments are insane!"
1897 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1898 local cltimeout=$(lctl get_param -n timeout)
1899 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1900 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1905 check_and_setup_lustre() {
1906 nfs_client_mode && return
1908 local MOUNTED=$(mounted_lustre_filesystems)
1911 # MOUNT is not mounted
1912 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1913 [ "$REFORMAT" ] && formatall
1915 MOUNTED=$(mounted_lustre_filesystems | head -1)
1916 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1917 export I_MOUNTED=yes
1920 # MOUNT and MOUNT2 are mounted
1921 elif $(echo $MOUNTED | grep -w -q $MOUNT2); then
1923 # MOUNT2 is mounted, MOUNT_2 is not set
1924 if ! [ "$MOUNT_2" ]; then
1925 zconf_umount `hostname` $MOUNT2
1926 export I_UMOUNTED2=yes
1928 # MOUNT2 is mounted, MOUNT_2 is set
1930 check_config $MOUNT2
1939 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1940 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1941 lctl set_param debug_mb=${DEBUG_SIZE};
1944 if [ "$ONLY" == "setup" ]; then
1949 cleanup_and_setup_lustre() {
1950 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1951 lctl set_param debug=0 || true
1953 if [ "$ONLY" == "cleanup" ]; then
1957 check_and_setup_lustre
1960 check_and_cleanup_lustre() {
1961 if [ "`mount | grep $MOUNT`" ]; then
1962 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1963 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1965 if [ "$I_UMOUNTED2" = "yes" ]; then
1966 mount_client $MOUNT2 || error "restore $MOUNT2 failed"
1969 if [ "$I_MOUNTED" = "yes" ]; then
1970 cleanupall -f || error "cleanup failed"
1982 while [ $NETWORK -eq 0 ]; do
1983 if ping -c 1 -w 3 $1 > /dev/null; then
1987 echo "waiting for $1, $((MAX - WAIT)) secs left"
1990 if [ $WAIT -gt $MAX ]; then
1991 echo "Network not available"
1997 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2008 # the sed converts spaces to commas, but leaves the last space
2009 # alone, so the line doesn't end with a comma.
2010 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2013 # list, excluded are the comma separated lists
2014 exclude_items_from_list () {
2020 for item in ${excluded//,/ }; do
2021 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2023 echo $(comma_list $list)
2026 # list, expand are the comma separated lists
2028 local list=${1//,/ }
2029 local expand=${2//,/ }
2032 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2033 echo $(comma_list $expanded)
2036 testslist_filter () {
2037 local script=$LUSTRE/tests/${TESTSUITE}.sh
2039 [ -f $script ] || return 0
2041 local start_at=$START_AT
2042 local stop_at=$STOP_AT
2044 local var=${TESTSUITE}_START_AT
2045 [ x"${!var}" != x ] && start_at=${!var}
2046 var=${TESTSUITE}_STOP_AT
2047 [ x"${!var}" != x ] && stop_at=${!var}
2049 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2050 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2051 /^'${start_at}'$/ {flag = 0}
2052 {if (flag == 1) print $0}
2053 /^'${stop_at}'$/ { flag = 1 }'
2057 (cd `dirname $1`; echo $PWD/`basename $1`)
2061 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2062 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2065 local count=${type}COUNT
2066 for ((i=1; i<=${!count}; i++)) do
2067 list="$list ${name}$i"
2069 echo $(comma_list $list)
2072 ##################################
2073 # Adaptive Timeouts funcs
2076 # only check mds, we assume at_max is the same on all nodes
2077 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2078 if [ $at_max -eq 0 ]; then
2088 # suppose that all ost-s has the same at_max set
2089 if [ $facet == "ost" ]; then
2090 do_facet ost1 "lctl get_param -n at_max"
2092 do_facet $facet "lctl get_param -n at_max"
2102 if [ $facet == "ost" ]; then
2103 for i in `seq $OSTCOUNT`; do
2104 do_facet ost$i "lctl set_param at_max=$at_max"
2107 elif [ $facet == "mds" ]; then
2108 for i in `seq $MDSCOUNT`; do
2109 do_facet mds$i "lctl set_param at_max=$at_max"
2112 do_facet $facet "lctl set_param at_max=$at_max"
2117 ##################################
2121 # OBD_FAIL_MDS_ALL_REQUEST_NET
2123 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2124 do_facet client "$1" || RC=$?
2125 do_facet $SINGLEMDS lctl set_param fail_loc=0
2130 # OBD_FAIL_MDS_ALL_REPLY_NET
2132 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2133 do_facet client "$@" || RC=$?
2134 do_facet $SINGLEMDS lctl set_param fail_loc=0
2138 drop_reint_reply() {
2139 # OBD_FAIL_MDS_REINT_NET_REP
2141 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2142 do_facet client "$@" || RC=$?
2143 do_facet $SINGLEMDS lctl set_param fail_loc=0
2148 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2150 do_facet ost1 lctl set_param fail_loc=0x214
2151 do_facet client "$1" || RC=$?
2152 do_facet client "sync"
2153 do_facet ost1 lctl set_param fail_loc=0
2157 drop_ldlm_cancel() {
2158 #define OBD_FAIL_LDLM_CANCEL 0x304
2160 do_facet client lctl set_param fail_loc=0x304
2161 do_facet client "$@" || RC=$?
2162 do_facet client lctl set_param fail_loc=0
2166 drop_bl_callback() {
2167 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2169 do_facet client lctl set_param fail_loc=0x305
2170 do_facet client "$@" || RC=$?
2171 do_facet client lctl set_param fail_loc=0
2176 #define OBD_FAIL_LDLM_REPLY 0x30c
2178 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2179 do_facet client "$@" || RC=$?
2180 do_facet $SINGLEMDS lctl set_param fail_loc=0
2188 echo "clearing fail_loc on $facet"
2189 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2192 set_nodes_failloc () {
2193 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2196 cancel_lru_locks() {
2197 $LCTL mark "cancel_lru_locks $1 start"
2198 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2199 $LCTL set_param -n $d=clear
2201 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2202 $LCTL mark "cancel_lru_locks $1 stop"
2207 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2208 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2209 echo "$DEFAULT_LRU_SIZE"
2214 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2217 lru_resize_disable()
2219 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2224 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2225 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2226 echo there is still data in page cache $FILE ?
2227 lctl get_param -n $FILE
2231 if [[ $MDSDEV1 != $MGSDEV ]]; then
2239 DEBUGSAVE="$(lctl get_param -n debug)"
2243 [ -n "$DEBUGSAVE" ] && \
2244 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2249 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2252 debug_size_restore() {
2253 [ -n "$DEBUG_SIZE_SAVED" ] && \
2254 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2258 start_full_debug_logging() {
2263 local DEBUG_SIZE=150
2265 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2266 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2269 stop_full_debug_logging() {
2274 ##################################
2276 ##################################
2279 local TYPE=${TYPE:-"FAIL"}
2281 lctl set_param fail_loc=0 2>/dev/null || true
2284 # do not dump logs if $1=false
2285 if [ "x$1" = "xfalse" ]; then
2290 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2293 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2294 echo "Dumping lctl log to $ERRLOG"
2295 # We need to dump the logs on all nodes
2296 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2299 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2305 $FAIL_ON_ERROR && exit 1 || true
2313 # use only if we are ignoring failures for this test, bugno required.
2314 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2315 # e.g. error_ignore 5494 "your message"
2317 local TYPE="IGNORE (bz$1)"
2323 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2328 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2329 [ "$TESTSUITELOG" ] && \
2330 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2333 build_test_filter() {
2334 EXCEPT="$EXCEPT $(testslist_filter)"
2336 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2340 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2341 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2342 [ "$EXCEPT_SLOW" ] && \
2343 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2344 for E in $EXCEPT $ALWAYS_EXCEPT; do
2345 eval EXCEPT_${E}=true
2347 for E in $EXCEPT_SLOW; do
2348 eval EXCEPT_SLOW_${E}=true
2350 for G in $GRANT_CHECK_LIST; do
2351 eval GCHECK_ONLY_${G}=true
2356 if [[ $1 = [a-z]* ]]; then
2363 # print a newline if the last test was skipped
2364 export LAST_SKIPPED=
2368 export base=`basetest $1`
2369 if [ ! -z "$ONLY" ]; then
2371 if [ ${!testname}x != x ]; then
2372 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2377 if [ ${!testname}x != x ]; then
2378 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2387 if [ ${!testname}x != x ]; then
2389 TESTNAME=test_$1 skip "skipping excluded test $1"
2392 testname=EXCEPT_$base
2393 if [ ${!testname}x != x ]; then
2395 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2398 testname=EXCEPT_SLOW_$1
2399 if [ ${!testname}x != x ]; then
2401 TESTNAME=test_$1 skip "skipping SLOW test $1"
2404 testname=EXCEPT_SLOW_$base
2405 if [ ${!testname}x != x ]; then
2407 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2417 EQUALS="======================================================================"
2421 local suffixlen=$((${#EQUALS} - ${#msg}))
2422 [ $suffixlen -lt 5 ] && suffixlen=5
2423 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2428 module_loaded lnet || load_modules
2440 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2445 strace -o $TMP/$1.strace -ttt $*
2447 log "FINISHED: $*: rc $RC"
2452 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2457 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2458 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2459 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2463 echo -n "Resetting fail_loc on all nodes..."
2464 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2472 export tdir=d0.${TESTSUITE}/d${base}
2474 local SAVE_UMASK=`umask`
2477 local BEFORE=`date +%s`
2479 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2481 export TESTNAME=test_$testnum
2483 test_${testnum} || error "test_$testnum failed with $?"
2487 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2488 check_catastrophe || error "LBUG/LASSERT detected"
2489 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2490 pass "($((`date +%s` - $BEFORE))s)"
2498 (cd `dirname $1`; echo $PWD/`basename $1`)
2502 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2503 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2508 export base=`basetest $1`
2509 [ "$CHECK_GRANT" == "no" ] && return 0
2511 testname=GCHECK_ONLY_${base}
2512 [ ${!testname}x == x ] && return 0
2514 echo -n "checking grant......"
2516 # write some data to sync client lost_grant
2517 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2518 for i in `seq $OSTCOUNT`; do
2519 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2520 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2521 count=1 > /dev/null 2>&1
2523 # sync all the data and make sure no pending data on server
2526 #get client grant and server grant
2528 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2529 client_grant=$((client_grant + $d))
2532 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2533 server_grant=$((server_grant + $d))
2536 # cleanup the check_grant file
2537 for i in `seq $OSTCOUNT`; do
2538 rm $DIR1/${tfile}_check_grant_$i
2541 #check whether client grant == server grant
2542 if [ $client_grant != $server_grant ]; then
2543 echo "failed: client:${client_grant} server: ${server_grant}"
2550 ########################
2556 ost=`echo $1 | awk -F_ '{print $3}'`
2557 if [ -z $ost ]; then
2558 ost=`echo $1 | sed 's/-osc.*//'`
2565 [ "$node" != "$(hostname)" ]
2571 for node in $(mdts_nodes); do
2572 remote_node $node && return 0
2579 [ "$CLIENTONLY" ] && return 0 || true
2580 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2586 for node in $(osts_nodes) ; do
2587 remote_node $node && return 0
2594 [ "$CLIENTONLY" ] && return 0 || true
2595 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2601 MGS=$(facet_host mgs)
2602 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2608 for num in `seq $MDSCOUNT`; do
2609 MDSNODES="$MDSNODES $(facet_host mds$num)"
2611 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2617 remote_ost && remote_mds
2621 local OSTNODES=$(facet_host ost1)
2624 for num in `seq $OSTCOUNT`; do
2625 local myOST=$(facet_host ost$num)
2626 OSTNODES="$OSTNODES $myOST"
2628 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2634 # FIXME. We need a list of clients
2635 local myNODES=$HOSTNAME
2638 # CLIENTS (if specified) contains the local client
2639 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2641 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2642 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2645 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2650 remote_nodes_list () {
2651 local rnodes=$(nodes_list)
2652 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2656 init_clients_lists () {
2657 # Sanity check: exclude the local client from RCLIENTS
2658 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2660 # Sanity check: exclude the dup entries
2661 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2663 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2665 # Sanity check: exclude the dup entries from CLIENTS
2666 # for those configs which has SINGLCLIENT set to local client
2667 clients=$(for i in $clients; do echo $i; done | sort -u)
2669 CLIENTS=`comma_list $clients`
2670 local -a remoteclients=($rclients)
2671 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2672 varname=CLIENT$((i + 2))
2673 eval $varname=${remoteclients[i]}
2676 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2679 get_random_entry () {
2682 rnodes=${rnodes//,/ }
2684 local -a nodes=($rnodes)
2685 local num=${#nodes[@]}
2686 local i=$((RANDOM * num * 2 / 65536))
2692 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2697 lctl get_param version | grep -q patchless
2701 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2706 echo $nodes | wc -w || true
2710 local nodes=$(osts_nodes)
2711 local osscount=$(get_node_count "$nodes")
2712 [ ! "$OSTCOUNT" = "$osscount" ]
2716 local nodes=$(mdts_nodes)
2717 local mdtcount=$(get_node_count "$nodes")
2718 [ ! "$MDSCOUNT" = "$mdtcount" ]
2721 generate_machine_file() {
2722 local nodes=${1//,/ }
2723 local machinefile=$2
2724 rm -f $machinefile || error "can't rm $machinefile"
2725 for node in $nodes; do
2726 echo $node >>$machinefile
2731 local file=$1/stripe
2733 $LFS getstripe -v $file || error
2737 check_runas_id_ret() {
2739 local myRUNAS_UID=$1
2740 local myRUNAS_GID=$2
2743 if [ -z "$myRUNAS" ]; then
2744 error_exit "myRUNAS command must be specified for check_runas_id"
2747 $myRUNAS krb5_login.sh || \
2748 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2750 mkdir $DIR/d0_runas_test
2752 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2753 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2754 rm -rf $DIR/d0_runas_test
2759 local myRUNAS_UID=$1
2760 local myRUNAS_GID=$2
2763 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2764 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2765 Please set RUNAS_ID to some UID which exists on MDS and client or
2766 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2769 # obtain the UID/GID for MPI_USER
2773 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2774 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2776 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2777 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2780 # obtain and cache Kerberos ticket-granting ticket
2781 refresh_krb5_tgt() {
2782 local myRUNAS_UID=$1
2783 local myRUNAS_GID=$2
2786 if [ -z "$myRUNAS" ]; then
2787 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2790 CLIENTS=${CLIENTS:-$HOSTNAME}
2791 do_nodes $CLIENTS "set -x
2792 if ! $myRUNAS krb5_login.sh; then
2793 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2798 # Run multiop in the background, but wait for it to print
2799 # "PAUSING" to its stdout before returning from this function.
2800 multiop_bg_pause() {
2801 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2805 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2808 echo "$MULTIOP_PROG $FILE v$ARGS"
2809 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2811 echo "TMPPIPE=${TMPPIPE}"
2812 read -t 60 multiop_output < $TMPPIPE
2813 if [ $? -ne 0 ]; then
2818 if [ "$multiop_output" != "PAUSING" ]; then
2819 echo "Incorrect multiop output: $multiop_output"
2834 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2840 inodes_available () {
2841 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2845 # reset llite stat counters
2846 clear_llite_stats(){
2847 lctl set_param -n llite.*.stats 0
2850 # sum llite stat items
2851 calc_llite_stats() {
2852 local res=$(lctl get_param -n llite.*.stats |
2853 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2857 # reset osc stat counters
2859 lctl set_param -n osc.*.osc_stats 0
2862 # sum osc stat items
2864 local res=$(lctl get_param -n osc.*.osc_stats |
2865 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2870 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2873 calc_osc_kbytes () {
2874 df $MOUNT > /dev/null
2875 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2878 # save_lustre_params(node, parameter_mask)
2879 # generate a stream of formatted strings (<node> <param name>=<param value>)
2880 save_lustre_params() {
2882 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2885 # restore lustre parameters from input stream, produces by save_lustre_params
2886 restore_lustre_params() {
2890 while IFS=" =" read node name val; do
2891 do_node ${node//:/} "lctl set_param -n $name $val"
2895 check_catastrophe() {
2896 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2897 local C=$CATASTROPHE
2898 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2900 if [ $rnodes ]; then
2901 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2902 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2918 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2920 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2921 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2922 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2926 # CMD: determine mds index where directory inode presents
2929 local file=$dir/f0.get_mds_dir_tmpfile
2933 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2934 local -a oldused=($iused)
2938 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2939 local -a newused=($iused)
2942 for ((i=0; i<${#newused[@]}; i++)); do
2943 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2949 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2952 mdsrate_cleanup () {
2954 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2959 delayed_recovery_enabled () {
2960 local var=${SINGLEMDS}_svc
2961 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2964 ########################
2966 convert_facet2label() {
2969 if [ x$facet = xost ]; then
2973 local varsvc=${facet}_svc
2975 if [ -n ${!varsvc} ]; then
2978 error "No lablel for $facet!"
2982 get_clientosc_proc_path() {
2988 get_lustre_version () {
2989 local node=${1:-"mds"}
2990 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2993 get_mds_version_major () {
2994 local version=$(get_lustre_version mds)
2995 echo $version | awk -F. '{print $1}'
2998 get_mds_version_minor () {
2999 local version=$(get_lustre_version mds)
3000 echo $version | awk -F. '{print $2}'
3003 get_mdtosc_proc_path() {
3005 local major=$(get_mds_version_major)
3006 local minor=$(get_mds_version_minor)
3007 if [ $major -le 1 -a $minor -le 8 ] ; then
3010 echo "${ost}-osc-MDT0000"
3014 get_osc_import_name() {
3017 local label=$(convert_facet2label $ost)
3019 if [ "$facet" == "mds" ]; then
3020 get_mdtosc_proc_path $label
3024 get_clientosc_proc_path $label
3028 wait_import_state () {
3034 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3035 while [ "${CONN_STATE}" != "${expected}" ]; do
3036 if [ "${expected}" == "DISCONN" ]; then
3037 # for disconn we can check after proc entry is removed
3038 [ "x${CONN_STATE}" == "x" ] && return 0
3039 # with AT we can have connect request timeout ~ reconnect timeout
3040 # and test can't see real disconnect
3041 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3043 # disconnect rpc should be wait not more obd_timeout
3044 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3045 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3047 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3051 log "$CONN_PROC now in ${CONN_STATE} state"
3055 wait_osc_import_state() {
3059 local ost=$(get_osc_import_name $facet $ost_facet)
3064 CONN_PROC="osc.${ost}.ost_server_uuid"
3065 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3066 while [ "${CONN_STATE}" != "${expected}" ]; do
3067 if [ "${expected}" == "DISCONN" ]; then
3068 # for disconn we can check after proc entry is removed
3069 [ "x${CONN_STATE}" == "x" ] && return 0
3070 # with AT we can have connect request timeout ~ reconnect timeout
3071 # and test can't see real disconnect
3072 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3074 # disconnect rpc should be wait not more obd_timeout
3075 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3076 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3078 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3082 log "${ost_facet} now in ${CONN_STATE} state"
3086 get_clientmdc_proc_path() {
3094 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3097 wait_clients_import_state () {
3103 local label=$(convert_facet2label $facet)
3106 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3107 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3108 *) error "unknown facet!" ;;
3112 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3113 error "import is not in ${expected} state"
3122 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3123 $LCTL get_param obdfilter.*.kbytesavail))
3124 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3125 $LCTL get_param -n obdfilter.*.tot_granted))
3126 for ((i=0; i<${#AVAILA[@]}; i++)); do
3127 local -a AVAIL1=(${AVAILA[$i]//=/ })
3128 GRANT=$((${GRANTA[$i]}/1024))
3129 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3130 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3138 local ts=$(date +%s)
3140 # bug 20237, comment 11
3141 # It would also be useful to provide the option
3142 # of writing the file to an NFS directory so it doesn't need to be copied.
3145 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3147 # dump lustre logs, dmesg
3148 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3149 lctl dk \\\$log >/dev/null;
3150 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3153 # FIXME: does it make sense to collect the logs for $ts only, but all
3155 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3156 local logs=$TMP/'*'${TESTSUITE}'*'
3158 logs=$logs' '$tmp/'*'$ts'*'
3160 for node in ${list//,/ }; do
3161 rsync -az $node:"$logs" $TMP
3164 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3165 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3171 local list=${1:-$(comma_list $(nodes_list))}
3173 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true