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;;
211 BASE=`basename $module $EXT`
212 lsmod | grep -q ${BASE} || \
213 if [ -f ${LUSTRE}/${module}${EXT} ]; then
214 insmod ${LUSTRE}/${module}${EXT} $@
216 # must be testing a "make install" or "rpm" installation
217 # note failed to load ptlrpc_gss is considered not fatal
218 if [ "$BASE" == "ptlrpc_gss" ]; then
219 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
226 load_modules_local() {
227 if [ -n "$MODPROBE" ]; then
231 if [ "$HAVE_MODULES" = true ]; then
237 echo Loading modules from $LUSTRE
238 load_module ../libcfs/libcfs/libcfs
239 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
240 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
242 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
243 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
244 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
245 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
246 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
247 echo "lnet options: '$LNETOPTS'"
248 # note that insmod will ignore anything in modprobe.conf
249 load_module ../lnet/lnet/lnet $LNETOPTS
250 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
251 load_module ../lnet/klnds/$LNETLND
252 load_module lvfs/lvfs
253 load_module obdclass/obdclass
254 load_module ptlrpc/ptlrpc
255 load_module ptlrpc/gss/ptlrpc_gss
256 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
264 if ! client_only; then
265 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
266 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
267 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
272 load_module lvfs/fsfilt_$FSTYPE
276 load_module obdfilter/obdfilter
279 load_module llite/lustre
280 load_module llite/llite_lloop
281 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
283 rm -f $OGDB/ogdb-$HOSTNAME
284 $LCTL modules > $OGDB/ogdb-$HOSTNAME
286 # 'mount' doesn't look in $PATH, just sbin
287 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
293 # load modules on remote nodes optionally
294 # lustre-tests have to be installed on these nodes
295 if $LOAD_MODULES_REMOTE ; then
296 local list=$(comma_list $(remote_nodes_list))
297 echo loading modules on $list
298 do_rpc_nodes $list load_modules
303 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
304 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
305 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
306 echo "$LEAK_LUSTRE" 1>&2
307 echo "$LEAK_PORTALS" 1>&2
308 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
309 echo "Memory leaks detected"
310 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
316 wait_exit_ST client # bug 12845
318 $LUSTRE_RMMOD $FSTYPE || return 2
320 if $LOAD_MODULES_REMOTE ; then
321 local list=$(comma_list $(remote_nodes_list))
322 echo unloading modules on $list
323 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
324 do_rpc_nodes $list check_mem_leak
329 check_mem_leak || return 254
331 echo "modules unloaded."
335 check_gss_daemon_facet() {
339 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
340 if [ $num -ne 1 ]; then
341 echo "$num instance of $dname on $facet"
350 do_facet $facet "killall -2 $@ 2>/dev/null || true"
353 start_gss_daemons() {
355 for num in `seq $MDSCOUNT`; do
356 do_facet mds$num "$LSVCGSSD -v"
358 do_facet mds$num "$LGSSD -v"
362 for num in `seq $OSTCOUNT`; do
363 do_facet ost$num "$LSVCGSSD -v"
366 # FIXME: is "client" the right facet name?
368 do_facet client "$LGSSD -v"
371 # wait daemons entering "stable" status
375 # check daemons are running
377 for num in `seq $MDSCOUNT`; do
378 check_gss_daemon_facet mds$num lsvcgssd
380 check_gss_daemon_facet mds$num lgssd
383 for num in `seq $OSTCOUNT`; do
384 check_gss_daemon_facet ost$num lsvcgssd
387 check_gss_daemon_facet client lgssd
392 for num in `seq $MDSCOUNT`; do
393 send_sigint mds$num lsvcgssd lgssd
395 for num in `seq $OSTCOUNT`; do
396 send_sigint ost$num lsvcgssd
398 send_sigint client lgssd
405 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
406 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
414 # maybe cleanup credential cache?
420 local device=`mdsdevname $num`
421 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
427 local device=`ostdevname $num`
428 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
436 local dev=$(facet_active $facet)_dev
437 local opt=${facet}_opt
438 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
439 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
441 if [ $RC -ne 0 ]; then
442 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
443 echo "Start of ${!dev} on ${facet} failed ${RC}"
445 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
446 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
447 lctl set_param debug_mb=${DEBUG_SIZE}; \
450 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
451 [ -z "$label" ] && echo no label for ${!dev} && exit 1
452 eval export ${facet}_svc=${label}
453 echo Started ${label}
458 # start facet device options
464 eval export ${facet}_dev=${device}
465 eval export ${facet}_opt=\"$@\"
467 local varname=${facet}failover_dev
468 if [ -n "${!varname}" ] ; then
469 eval export ${facet}failover_dev=${!varname}
471 eval export ${facet}failover_dev=$device
474 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
484 HOST=`facet_active_host $facet`
485 [ -z $HOST ] && echo stop: no host for $facet && return 0
487 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
488 if [ ${running} -ne 0 ]; then
489 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
490 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
493 # umount should block, but we should wait for unrelated obd's
494 # like the MGS or MGC to also stop.
495 wait_exit_ST ${facet}
498 # save quota version (both administrative and operational quotas)
499 # add an additional parameter if mountpoint is ever different from $MOUNT
500 quota_save_version() {
501 local fsname=${2:-$FSNAME}
503 local ver=$(tr -c -d "123" <<< $spec)
504 local type=$(tr -c -d "ug" <<< $spec)
506 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
508 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
510 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
512 local osts=$(get_facets OST)
513 for ost in ${osts//,/ }; do
515 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
519 # client could mount several lustre
521 local fsname=${1:-$FSNAME}
523 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
524 do_nodes $(comma_list $(osts_nodes)) \
525 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
529 restore_quota_type () {
530 local mntpt=${1:-$MOUNT}
531 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
532 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
535 quota_save_version $old_QUOTA_TYPE
542 # 1. run quotacheck only if quota is off
543 # 2. save the original quota_type params, restore them after testing
545 # Suppose that quota type the same on mds and ost
546 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
547 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
548 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
549 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
550 export old_QUOTA_TYPE=$quota_type
551 quota_save_version $QUOTA_TYPE
554 local quota_usrs=$QUOTA_USERS
556 # get_filesystem_size
557 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
558 local blk_soft=$((disksz + 1024))
559 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
561 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
563 local i_hard=$((i_soft + i_soft / 20))
565 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
566 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
569 for usr in $quota_usrs; do
570 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
572 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
574 eval $cmd || error "$cmd FAILED!"
576 # display the quota status
577 echo "Quota settings for $usr : "
578 $LFS quota -v -u $usr $mntpt || true
586 # Only supply -o to mount if we have options
587 if [ -n "$MOUNTOPT" ]; then
588 OPTIONS="-o $MOUNTOPT"
590 local device=$MGSNID:/$FSNAME
591 if [ -z "$mnt" -o -z "$FSNAME" ]; then
592 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
596 echo "Starting client: $client: $OPTIONS $device $mnt"
597 do_node $client mkdir -p $mnt
598 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
600 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
601 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
602 lctl set_param debug_mb=${DEBUG_SIZE}"
615 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
616 if [ $running -ne 0 ]; then
617 echo "Stopping client $client $mnt (opts:$force)"
618 do_node $client lsof -t $mnt || need_kill=no
619 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
620 pids=$(do_node $client lsof -t $mnt | sort -u);
621 if [ -n $pids ]; then
622 do_node $client kill -9 $pids || true
626 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
627 if [ $busy -ne 0 ] ; then
628 echo "$mnt is still busy, wait one second" && sleep 1
629 do_node $client umount $force $mnt
634 # nodes is comma list
635 sanity_mount_check_nodes () {
641 # FIXME: assume that all cluster nodes run the same os
642 [ "$(uname)" = Linux ] || return 0
645 for mnt in $mnts ; do
646 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
647 mpts=\\\$(mount | grep -w -c $mnt);
648 if [ \\\$running -ne \\\$mpts ]; then
649 echo \\\$(hostname) env are INSANE!;
657 sanity_mount_check_servers () {
659 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
660 echo Checking servers environments
662 # FIXME: modify get_facets to display all facets wo params
663 local facets="$(get_facets OST),$(get_facets MDS),mgs"
667 for facet in ${facets//,/ }; do
668 node=$(facet_host ${facet})
669 mnt=${MOUNT%/*}/${facet}
670 sanity_mount_check_nodes $node $mnt ||
671 { error "server $node environments are insane!"; return 1; }
675 sanity_mount_check_clients () {
676 local clients=${1:-$CLIENTS}
677 local mntpt=${2:-$MOUNT}
678 local mntpt2=${3:-$MOUNT2}
680 [ -z $clients ] && clients=$(hostname)
681 echo Checking clients $clients environments
683 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
684 error "clients environments are insane!"
687 sanity_mount_check () {
688 sanity_mount_check_servers || return 1
689 sanity_mount_check_clients || return 2
692 # mount clients if not mouted
693 zconf_mount_clients() {
699 # Only supply -o to mount if we have options
700 if [ -n "$MOUNTOPT" ]; then
701 OPTIONS="-o $MOUNTOPT"
703 local device=$MGSNID:/$FSNAME
704 if [ -z "$mnt" -o -z "$FSNAME" ]; then
705 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
709 echo "Starting client $clients: $OPTIONS $device $mnt"
712 running=\\\$(mount | grep -c $mnt' ');
714 if [ \\\$running -eq 0 ] ; then
716 mount -t lustre $OPTIONS $device $mnt;
719 exit \\\$rc" || return ${PIPESTATUS[0]}
721 echo "Started clients $clients: "
722 do_nodes $clients "mount | grep -w $mnt"
724 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
725 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
726 lctl set_param debug_mb=${DEBUG_SIZE};"
731 zconf_umount_clients() {
738 echo "Stopping clients: $clients $mnt (opts:$force)"
739 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
740 if [ \\\$running -ne 0 ] ; then
741 echo Stopping client \\\$(hostname) client $mnt opts:$force;
742 lsof -t $mnt || need_kill=no;
743 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
744 pids=\\\$(lsof -t $mnt | sort -u);
745 if [ -n \\\"\\\$pids\\\" ]; then
749 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
750 if [ \\\$busy -ne 0 ] ; then
751 echo "$mnt is still busy, wait one second" && sleep 1;
757 shudown_node_hard () {
761 for i in $(seq $attempts) ; do
764 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
765 echo "waiting for $host to fail attempts=$attempts"
766 [ $i -lt $attempts ] || \
767 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
773 local mnt=${2:-$MOUNT}
776 if [ "$FAILURE_MODE" = HARD ]; then
777 shudown_node_hard $client
779 zconf_umount_clients $client $mnt -f
785 if [ "$FAILURE_MODE" = HARD ]; then
786 shudown_node_hard $(facet_active_host $facet)
787 elif [ "$FAILURE_MODE" = SOFT ]; then
794 if [ "$FAILURE_MODE" = HARD ]; then
795 $POWER_UP `facet_active_host $facet`
803 if [ "$FAILURE_MODE" = HARD ]; then
809 # recovery-scale functions
810 check_progs_installed () {
815 do_nodes $clients "PATH=:$PATH; status=true;
816 for prog in $progs; do
817 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
818 echo \\\$prog missing on \\\$(hostname);
826 echo __$(echo $1 | tr '-' 'X')
829 start_client_load() {
832 local var=$(client_var_name $client)_load
833 eval export ${var}=$load
835 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
836 BREAK_ON_ERROR=$BREAK_ON_ERROR \
837 END_RUN_FILE=$END_RUN_FILE \
838 LOAD_PID_FILE=$LOAD_PID_FILE \
839 TESTSUITELOG=$TESTSUITELOG \
841 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
842 log "Started client load: ${load} on $client"
847 start_client_loads () {
848 local -a clients=(${1//,/ })
849 local numloads=${#CLIENT_LOADS[@]}
852 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
853 testnum=$((nodenum % numloads))
854 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
858 # only for remote client
859 check_client_load () {
861 local var=$(client_var_name $client)_load
862 local TESTLOAD=run_${!var}.sh
864 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
866 # bug 18914: try to connect several times not only when
867 # check ps, but while check_catastrophe also
870 while [ $RC = 254 -a $tries -gt 0 ]; do
874 if ! check_catastrophe $client; then
876 if [ $RC -eq 254 ]; then
877 # FIXME: not sure how long we shuold sleep here
881 echo "check catastrophe failed: RC=$RC "
885 # We can continue try to connect if RC=254
886 # Just print the warning about this
887 if [ $RC = 254 ]; then
888 echo "got a return status of $RC from do_node while checking catastrophe on $client"
891 # see if the load is still on the client
894 while [ $RC = 254 -a $tries -gt 0 ]; do
898 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
903 if [ $RC = 254 ]; then
904 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
905 # see if we can diagnose a bit why this is
910 check_client_loads () {
911 local clients=${1//,/ }
915 for client in $clients; do
916 check_client_load $client
918 if [ "$rc" != 0 ]; then
919 log "Client load failed on node $client, rc=$rc"
925 restart_client_loads () {
926 local clients=${1//,/ }
927 local expectedfail=${2:-""}
931 for client in $clients; do
932 check_client_load $client
934 if [ "$rc" != 0 -a "$expectedfail" ]; then
935 local var=$(client_var_name $client)_load
936 start_client_load $client ${!var}
937 echo "Restarted client load ${!var}: on $client. Checking ..."
938 check_client_load $client
940 if [ "$rc" != 0 ]; then
941 log "Client load failed to restart on node $client, rc=$rc"
942 # failure one client load means test fail
943 # we do not need to check other
951 # End recovery-scale functions
953 # verify that lustre actually cleaned up properly
955 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
956 error "LBUG/LASSERT detected"
957 BUSY=`dmesg | grep -i destruct || true`
960 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
964 check_mem_leak || exit 204
966 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
967 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
969 if [ "`/sbin/lsmod 2>&1 | egrep 'lnet|libcfs'`" ]; then
970 echo "$0: modules still loaded..." 1>&2
987 RESULT=$(do_node $node "$TEST")
988 if [ "$RESULT" == "$FINAL" ]; then
989 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
992 [ $WAIT -ge $MAX ] && break
993 echo "Waiting $((MAX - WAIT)) secs for update"
994 WAIT=$((WAIT + sleep))
997 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1001 wait_update_facet () {
1003 wait_update $(facet_active_host $facet) "$@"
1006 wait_delete_completed () {
1007 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1008 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1012 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1014 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1015 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1016 [ "$TOTAL" -eq "$TOTALPREV" ] && break
1017 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1021 echo "Delete completed."
1026 check_network "$host" 900
1027 while ! do_node $host hostname > /dev/null; do sleep 5; done
1032 local host=`facet_active_host $facet`
1036 wait_recovery_complete () {
1039 # Use default policy if $2 is not passed by caller.
1040 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1041 # as we are in process of changing obd_timeout in different ways
1042 # let's set MAX longer than that
1043 local MAX=${2:-$(( TIMEOUT * 4 ))}
1045 local var_svc=${facet}_svc
1046 local procfile="*.${!var_svc}.recovery_status"
1050 while [ $WAIT -lt $MAX ]; do
1051 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1052 [[ $STATUS = "status: COMPLETE" ]] && return 0
1055 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1057 echo "$facet recovery not done in $MAX sec. $STATUS"
1067 # conf-sanity 31 takes a long time cleanup
1068 while [ $WAIT -lt 300 ]; do
1069 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1070 [ -z "${running}" ] && return 0
1071 echo "waited $WAIT for${running}"
1072 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1074 WAIT=$((WAIT + INTERVAL))
1076 echo "service didn't stop after $WAIT seconds. Still running:"
1081 wait_remote_prog () {
1087 [ "$PDSH" = "no_dsh" ] && return 0
1089 while [ $WAIT -lt $2 ]; do
1090 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1091 [ -z "${running}" ] && return 0 || true
1092 echo "waited $WAIT for: "
1094 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1096 WAIT=$((WAIT + INTERVAL))
1098 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1099 [ -z "$pids" ] && return 0
1100 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1101 # FIXME: not portable
1102 for pid in $pids; do
1103 cat /proc/${pid}/status || true
1104 cat /proc/${pid}/wchan || true
1106 kill -9 $pid || true
1115 # not every config has many clients
1116 if [ ! -z "$CLIENTS" ]; then
1117 $PDSH $CLIENTS "df $MOUNT" > /dev/null
1119 df $MOUNT > /dev/null
1123 client_reconnect() {
1124 uname -n >> $MOUNT/recon
1125 if [ -z "$CLIENTS" ]; then
1126 df $MOUNT; uname -n >> $MOUNT/recon
1128 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1130 echo Connected clients:
1132 ls -l $MOUNT/recon > /dev/null
1139 echo "Failing $facet on node `facet_active_host $facet`"
1140 shutdown_facet $facet
1141 [ -n "$sleep_time" ] && sleep $sleep_time
1143 change_active $facet
1144 local TO=`facet_active_host $facet`
1145 echo "Failover $facet to $TO"
1147 mount_facet $facet || error "Restart of $facet failed"
1156 do_facet $facet sync
1158 local svc=${facet}_svc
1159 do_facet $facet $LCTL --device %${!svc} notransno
1160 do_facet $facet $LCTL --device %${!svc} readonly
1161 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1162 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1165 replay_barrier_nodf() {
1166 local facet=$1 echo running=${running}
1167 do_facet $facet sync
1168 local svc=${facet}_svc
1169 echo Replay barrier on ${!svc}
1170 do_facet $facet $LCTL --device %${!svc} notransno
1171 do_facet $facet $LCTL --device %${!svc} readonly
1172 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1173 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1176 replay_barrier_nosync() {
1177 local facet=$1 echo running=${running}
1178 local svc=${facet}_svc
1179 echo Replay barrier on ${!svc}
1180 do_facet $facet $LCTL --device %${!svc} notransno
1181 do_facet $facet $LCTL --device %${!svc} readonly
1182 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1183 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1186 mds_evict_client() {
1187 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1188 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1191 ost_evict_client() {
1192 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1193 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1197 facet_failover $* || error "failover: $?"
1198 client_df || error "post-failover df: $?"
1203 facet_failover $facet
1209 change_active $facet
1210 mount_facet $facet -o abort_recovery
1211 client_df || echo "first df failed: $?"
1213 client_df || error "post-failover df: $?"
1217 echo There is no lmc. This is mountconf, baby.
1222 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1223 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1229 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1235 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1236 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1237 if [ -z "$ID" ]; then
1238 echo "Could not get a ptl id for $1..."
1247 h2name_or_ip "$1" "tcp"
1252 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1253 if type __h2elan >/dev/null 2>&1; then
1256 ID=`echo $1 | sed 's/[^0-9]*//g'`
1264 h2name_or_ip "$1" "openib"
1266 declare -fx h2openib
1269 h2name_or_ip "$1" "o2ib"
1276 [ "$facet" == client ] && echo -n $HOSTNAME && return
1277 varname=${facet}_HOST
1278 if [ -z "${!varname}" ]; then
1279 if [ "${facet:0:3}" == "ost" ]; then
1280 eval ${facet}_HOST=${ost_HOST}
1288 local activevar=${facet}active
1290 if [ -f $TMP/${facet}active ] ; then
1291 source $TMP/${facet}active
1294 active=${!activevar}
1295 if [ -z "$active" ] ; then
1302 facet_active_host() {
1304 local active=`facet_active $facet`
1305 if [ "$facet" == client ]; then
1308 echo `facet_host $active`
1314 local failover=${facet}failover
1315 host=`facet_host $failover`
1316 [ -z "$host" ] && return
1317 local curactive=`facet_active $facet`
1318 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1319 eval export ${facet}active=$facet
1321 eval export ${facet}active=$failover
1323 # save the active host for this facet
1324 local activevar=${facet}active
1325 echo "$activevar=${!activevar}" > $TMP/$activevar
1330 # do not stripe off hostname if verbose, bug 19215
1331 if [ x$1 = x--verbose ]; then
1339 if [ "$HOST" = "$HOSTNAME" ]; then
1341 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1342 echo "cannot run remote command on $HOST with $myPDSH"
1346 echo "CMD: $HOST $@" >&2
1347 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1350 if [ "$myPDSH" = "rsh" ]; then
1351 # we need this because rsh does not return exit code of an executed command
1352 local command_status="$TMP/cs"
1353 rsh $HOST ":> $command_status"
1354 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1355 cd $RPWD; sh -c \"$@\") ||
1356 echo command failed >$command_status"
1357 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1362 # print HOSTNAME for myPDSH="no_dsh"
1363 if [[ $myPDSH = no_dsh ]]; then
1364 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1366 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1369 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1371 return ${PIPESTATUS[0]}
1374 single_local_node () {
1375 [ "$1" = "$HOSTNAME" ]
1380 # do not stripe off hostname if verbose, bug 19215
1381 if [ x$1 = x--verbose ]; then
1389 if $(single_local_node $rnodes); then
1391 do_node --verbose $rnodes $@
1398 # This is part from do_node
1401 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1402 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1405 echo "CMD: $rnodes $@" >&2
1406 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1410 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1412 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1414 return ${PIPESTATUS[0]}
1420 local HOST=`facet_active_host $facet`
1421 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1428 # make sure its not already running
1430 rm -f $TMP/${facet}active
1431 do_facet ${facet} $MKFS $*
1437 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1438 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1445 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1446 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1454 # make sure we are using the primary server, so test-framework will
1455 # be able to clean up properly.
1456 activemds=`facet_active mds1`
1457 if [ $activemds != "mds1" ]; then
1461 local clients=$CLIENTS
1462 [ -z $clients ] && clients=$(hostname)
1464 zconf_umount_clients $clients $MOUNT "$*" || true
1465 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1467 [ "$CLIENTONLY" ] && return
1468 # The add fn does rm ${facet}active file, this would be enough
1469 # if we use do_facet <facet> only after the facet added, but
1470 # currently we use do_facet mds in local.sh
1471 for num in `seq $MDSCOUNT`; do
1473 rm -f ${TMP}/mds${num}active
1476 for num in `seq $OSTCOUNT`; do
1478 rm -f $TMP/ost${num}active
1485 nfs_client_mode && return
1495 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1499 if [ "$IAMDIR" == "yes" ]; then
1500 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1501 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1504 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1506 if [ ! -z $SEC ]; then
1507 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
1508 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --param srpc.flavor.default=$SEC"
1509 OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
1513 # We need ldiskfs here, may as well load them all
1515 [ "$CLIENTONLY" ] && return
1516 echo Formatting mgs, mds, osts
1517 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1518 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1521 for num in `seq $MDSCOUNT`; do
1522 echo "Format mds$num: $(mdsdevname $num)"
1524 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1526 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1530 for num in `seq $OSTCOUNT`; do
1531 echo "Format ost$num: $(ostdevname $num)"
1533 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1535 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1541 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1545 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1549 # 0: success, the old identity set already.
1550 # 1: success, the old identity does not set.
1555 local j=`expr $num - 1`
1556 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1558 if [ -z "$MDT" ]; then
1562 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1565 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1567 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1570 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1572 if [ $old = "NONE" ]; then
1581 zconf_umount `hostname` $1 || error "umount failed"
1582 zconf_mount `hostname` $1 || error "mount failed"
1585 writeconf_facet () {
1589 do_facet $facet "$TUNEFS --writeconf $dev"
1593 for num in `seq $MDSCOUNT`; do
1594 DEVNAME=$(mdsdevname $num)
1595 writeconf_facet mds$num $DEVNAME
1598 for num in `seq $OSTCOUNT`; do
1599 DEVNAME=$(ostdevname $num)
1600 writeconf_facet ost$num $DEVNAME
1605 nfs_client_mode && return
1607 sanity_mount_check ||
1608 error "environments are insane!"
1612 if [ -z "$CLIENTONLY" ]; then
1613 echo Setup mgs, mdt, osts
1614 echo $WRITECONF | grep -q "writeconf" && \
1616 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1617 start mgs $MGSDEV $mgs_MOUNT_OPTS
1620 for num in `seq $MDSCOUNT`; do
1621 DEVNAME=$(mdsdevname $num)
1622 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1624 # We started mds, now we should set failover variables properly.
1625 # Set mds${num}failover_HOST if it is not set (the default failnode).
1626 local varname=mds${num}failover_HOST
1627 if [ -z "${!varname}" ]; then
1628 eval mds${num}failover_HOST=$(facet_host mds$num)
1631 if [ $IDENTITY_UPCALL != "default" ]; then
1632 switch_identity $num $IDENTITY_UPCALL
1635 for num in `seq $OSTCOUNT`; do
1636 DEVNAME=$(ostdevname $num)
1637 start ost$num $DEVNAME $OST_MOUNT_OPTS
1639 # We started ost$num, now we should set ost${num}failover variable properly.
1640 # Set ost${num}failover_HOST if it is not set (the default failnode).
1641 varname=ost${num}failover_HOST
1642 if [ -z "${!varname}" ]; then
1643 eval ost${num}failover_HOST=$(facet_host ost${num})
1648 # wait a while to allow sptlrpc configuration be propogated to targets,
1649 # only needed when mounting new target devices.
1652 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1654 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1656 if [ "$MOUNT_2" ]; then
1657 mount_client $MOUNT2
1658 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1663 # by remounting mdt before ost, initial connect from mdt to ost might
1664 # timeout because ost is not ready yet. wait some time to its fully
1665 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1666 # by a context negotiation rpc with $TIMEOUT.
1667 # FIXME better by monitoring import status.
1669 sleep $((TIMEOUT + 5))
1675 mounted_lustre_filesystems() {
1676 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1679 init_facet_vars () {
1680 [ "$CLIENTONLY" ] && return 0
1687 eval export ${facet}_dev=${device}
1688 eval export ${facet}_opt=\"$@\"
1690 local dev=${facet}_dev
1691 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1692 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1694 eval export ${facet}_svc=${label}
1696 local varname=${facet}failover_HOST
1697 if [ -z "${!varname}" ]; then
1698 eval $varname=$(facet_host $facet)
1701 # ${facet}failover_dev is set in cfg file
1702 varname=${facet}failover_dev
1703 if [ -n "${!varname}" ] ; then
1704 eval export ${facet}failover_dev=${!varname}
1706 eval export ${facet}failover_dev=$device
1710 init_facets_vars () {
1713 if ! remote_mds_nodsh; then
1714 for num in `seq $MDSCOUNT`; do
1715 DEVNAME=`mdsdevname $num`
1716 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1720 remote_ost_nodsh && return
1722 for num in `seq $OSTCOUNT`; do
1723 DEVNAME=`ostdevname $num`
1724 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1728 osc_ensure_active () {
1734 while [ $period -lt $timeout ]; do
1735 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1736 if [ $count -eq 0 ]; then
1740 echo "There are $count OST are inactive, wait $period seconds, and try again"
1742 period=$((period+3))
1745 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1749 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1753 init_param_vars () {
1754 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1755 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1756 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1757 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1761 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1763 log "Using TIMEOUT=$TIMEOUT"
1765 osc_ensure_active $SINGLEMDS M $TIMEOUT
1766 osc_ensure_active client c $TIMEOUT
1768 if [ x"$(som_check)" = x"enabled" ]; then
1771 if [ "$ENABLE_QUOTA" ]; then
1772 setup_quota $MOUNT || return 2
1776 nfs_client_mode () {
1777 if [ "$NFSCLIENT" ]; then
1778 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1779 local clients=$CLIENTS
1780 [ -z $clients ] && clients=$(hostname)
1782 # FIXME: remove hostname when 19215 fixed
1783 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1784 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1785 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1792 nfs_client_mode && return
1796 local mounted=$(mount | grep " $mntpt ")
1797 if [ "$CLIENTONLY" ]; then
1799 # CLIENTONLY should not depend on *_HOST settings
1800 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1801 # in theory someone could create a new,
1802 # client-only config file that assumed lustre was already
1803 # configured and didn't set the MGSNID. If MGSNID is not set,
1804 # then we should use the mgs nid currently being used
1805 # as the default value. bug 18021
1806 [[ x$MGSNID = x ]] &&
1809 if [[ x$mgc != xMGC$MGSNID ]]; then
1810 if [ "$mgs_HOST" ]; then
1811 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1812 [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1813 error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1819 local myMGS_host=$mgs_HOST
1820 if [ "$NETTYPE" = "ptl" ]; then
1821 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1824 echo Checking config lustre mounted on $mntpt
1825 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1826 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1828 # if [ "$mgshost" != "$myMGS_host" ]; then
1829 # error_exit "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1830 # Please use correct config or set mds_HOST correctly!"
1833 sanity_mount_check ||
1834 error "environments are insane!"
1838 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1839 local cltimeout=$(lctl get_param -n timeout)
1840 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1841 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1846 check_and_setup_lustre() {
1847 nfs_client_mode && return
1849 local MOUNTED=$(mounted_lustre_filesystems)
1850 if [ -z "$MOUNTED" ] || ! $(echo $MOUNTED | grep -w -q $MOUNT); then
1851 [ "$REFORMAT" ] && formatall
1853 MOUNTED=$(mounted_lustre_filesystems | head -1)
1854 [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
1855 export I_MOUNTED=yes
1861 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
1862 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
1863 lctl set_param debug_mb=${DEBUG_SIZE};
1866 if [ "$ONLY" == "setup" ]; then
1871 cleanup_and_setup_lustre() {
1872 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
1873 lctl set_param debug=0 || true
1875 if [ "$ONLY" == "cleanup" ]; then
1879 check_and_setup_lustre
1882 check_and_cleanup_lustre() {
1883 if [ "`mount | grep $MOUNT`" ]; then
1884 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
1885 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
1887 if [ "$I_MOUNTED" = "yes" ]; then
1888 cleanupall -f || error "cleanup failed"
1900 while [ $NETWORK -eq 0 ]; do
1901 if ping -c 1 -w 3 $1 > /dev/null; then
1905 echo "waiting for $1, $((MAX - WAIT)) secs left"
1908 if [ $WAIT -gt $MAX ]; then
1909 echo "Network not available"
1915 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
1926 # the sed converts spaces to commas, but leaves the last space
1927 # alone, so the line doesn't end with a comma.
1928 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
1931 # list, excluded are the comma separated lists
1932 exclude_items_from_list () {
1938 for item in ${excluded//,/ }; do
1939 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
1941 echo $(comma_list $list)
1944 # list, expand are the comma separated lists
1946 local list=${1//,/ }
1947 local expand=${2//,/ }
1950 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
1951 echo $(comma_list $expanded)
1954 testslist_filter () {
1955 local script=$LUSTRE/tests/${TESTSUITE}.sh
1957 [ -f $script ] || return 0
1959 local start_at=$START_AT
1960 local stop_at=$STOP_AT
1962 local var=${TESTSUITE}_START_AT
1963 [ x"${!var}" != x ] && start_at=${!var}
1964 var=${TESTSUITE}_STOP_AT
1965 [ x"${!var}" != x ] && stop_at=${!var}
1967 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
1968 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
1969 /^'${start_at}'$/ {flag = 0}
1970 {if (flag == 1) print $0}
1971 /^'${stop_at}'$/ { flag = 1 }'
1975 (cd `dirname $1`; echo $PWD/`basename $1`)
1979 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
1980 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
1983 local count=${type}COUNT
1984 for ((i=1; i<=${!count}; i++)) do
1985 list="$list ${name}$i"
1987 echo $(comma_list $list)
1990 ##################################
1991 # Adaptive Timeouts funcs
1994 # only check mds, we assume at_max is the same on all nodes
1995 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
1996 if [ $at_max -eq 0 ]; then
2006 # suppose that all ost-s has the same at_max set
2007 if [ $facet == "ost" ]; then
2008 do_facet ost1 "lctl get_param -n at_max"
2010 do_facet $facet "lctl get_param -n at_max"
2020 if [ $facet == "ost" ]; then
2021 for i in `seq $OSTCOUNT`; do
2022 do_facet ost$i "lctl set_param at_max=$at_max"
2025 elif [ $facet == "mds" ]; then
2026 for i in `seq $MDSCOUNT`; do
2027 do_facet mds$i "lctl set_param at_max=$at_max"
2030 do_facet $facet "lctl set_param at_max=$at_max"
2035 ##################################
2039 # OBD_FAIL_MDS_ALL_REQUEST_NET
2041 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2042 do_facet client "$1" || RC=$?
2043 do_facet $SINGLEMDS lctl set_param fail_loc=0
2048 # OBD_FAIL_MDS_ALL_REPLY_NET
2050 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2051 do_facet client "$@" || RC=$?
2052 do_facet $SINGLEMDS lctl set_param fail_loc=0
2056 drop_reint_reply() {
2057 # OBD_FAIL_MDS_REINT_NET_REP
2059 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2060 do_facet client "$@" || RC=$?
2061 do_facet $SINGLEMDS lctl set_param fail_loc=0
2066 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2068 do_facet ost1 lctl set_param fail_loc=0x214
2069 do_facet client "$1" || RC=$?
2070 do_facet client "sync"
2071 do_facet ost1 lctl set_param fail_loc=0
2075 drop_ldlm_cancel() {
2076 #define OBD_FAIL_LDLM_CANCEL 0x304
2078 do_facet client lctl set_param fail_loc=0x304
2079 do_facet client "$@" || RC=$?
2080 do_facet client lctl set_param fail_loc=0
2084 drop_bl_callback() {
2085 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2087 do_facet client lctl set_param fail_loc=0x305
2088 do_facet client "$@" || RC=$?
2089 do_facet client lctl set_param fail_loc=0
2094 #define OBD_FAIL_LDLM_REPLY 0x30c
2096 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2097 do_facet client "$@" || RC=$?
2098 do_facet $SINGLEMDS lctl set_param fail_loc=0
2106 echo "clearing fail_loc on $facet"
2107 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2110 set_nodes_failloc () {
2111 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2114 cancel_lru_locks() {
2115 $LCTL mark "cancel_lru_locks $1 start"
2116 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2117 $LCTL set_param -n $d=clear
2119 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2120 $LCTL mark "cancel_lru_locks $1 stop"
2125 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2126 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2127 echo "$DEFAULT_LRU_SIZE"
2132 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2135 lru_resize_disable()
2137 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2142 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2143 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2144 echo there is still data in page cache $FILE ?
2145 lctl get_param -n $FILE
2149 if [[ $MDSDEV1 != $MGSDEV ]]; then
2157 DEBUGSAVE="$(lctl get_param -n debug)"
2161 [ -n "$DEBUGSAVE" ] && \
2162 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2167 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2170 debug_size_restore() {
2171 [ -n "$DEBUG_SIZE_SAVED" ] && \
2172 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2176 start_full_debug_logging() {
2181 local DEBUG_SIZE=150
2183 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2184 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2187 stop_full_debug_logging() {
2192 ##################################
2194 ##################################
2197 local TYPE=${TYPE:-"FAIL"}
2199 lctl set_param fail_loc=0 2>/dev/null || true
2202 # do not dump logs if $1=false
2203 if [ "x$1" = "xfalse" ]; then
2208 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2211 ERRLOG=$TMP/lustre_${TESTSUITE}_${TESTNAME}.$(date +%s)
2212 echo "Dumping lctl log to $ERRLOG"
2213 # We need to dump the logs on all nodes
2214 do_nodes $(comma_list $(nodes_list)) $NODE $LCTL dk $ERRLOG
2217 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2223 $FAIL_ON_ERROR && exit 1 || true
2231 # use only if we are ignoring failures for this test, bugno required.
2232 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2233 # e.g. error_ignore 5494 "your message"
2235 local TYPE="IGNORE (bz$1)"
2241 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2246 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2247 [ "$TESTSUITELOG" ] && \
2248 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2251 build_test_filter() {
2252 EXCEPT="$EXCEPT $(testslist_filter)"
2254 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2258 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2259 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2260 [ "$EXCEPT_SLOW" ] && \
2261 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2262 for E in $EXCEPT $ALWAYS_EXCEPT; do
2263 eval EXCEPT_${E}=true
2265 for E in $EXCEPT_SLOW; do
2266 eval EXCEPT_SLOW_${E}=true
2268 for G in $GRANT_CHECK_LIST; do
2269 eval GCHECK_ONLY_${G}=true
2277 # print a newline if the last test was skipped
2278 export LAST_SKIPPED=
2282 export base=`basetest $1`
2283 if [ ! -z "$ONLY" ]; then
2285 if [ ${!testname}x != x ]; then
2286 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2291 if [ ${!testname}x != x ]; then
2292 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2301 if [ ${!testname}x != x ]; then
2303 TESTNAME=test_$1 skip "skipping excluded test $1"
2306 testname=EXCEPT_$base
2307 if [ ${!testname}x != x ]; then
2309 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2312 testname=EXCEPT_SLOW_$1
2313 if [ ${!testname}x != x ]; then
2315 TESTNAME=test_$1 skip "skipping SLOW test $1"
2318 testname=EXCEPT_SLOW_$base
2319 if [ ${!testname}x != x ]; then
2321 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2331 EQUALS="======================================================================"
2335 local suffixlen=$((${#EQUALS} - ${#msg}))
2336 [ $suffixlen -lt 5 ] && suffixlen=5
2337 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2342 lsmod | grep lnet > /dev/null || load_modules
2354 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2359 strace -o $TMP/$1.strace -ttt $*
2361 log "FINISHED: $*: rc $RC"
2366 $TEST_FAILED && echo -n "FAIL " || echo -n "PASS "
2371 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2372 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2373 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2377 echo -n "Resetting fail_loc on all nodes..."
2378 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2386 export tdir=d0.${TESTSUITE}/d${base}
2388 local SAVE_UMASK=`umask`
2391 local BEFORE=`date +%s`
2393 log "== test $testnum: $message == `date +%H:%M:%S` ($BEFORE)"
2395 export TESTNAME=test_$testnum
2397 test_${testnum} || error "test_$testnum failed with $?"
2401 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2402 check_catastrophe || error "LBUG/LASSERT detected"
2403 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2404 pass "($((`date +%s` - $BEFORE))s)"
2412 (cd `dirname $1`; echo $PWD/`basename $1`)
2416 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2417 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2422 export base=`basetest $1`
2423 [ "$CHECK_GRANT" == "no" ] && return 0
2425 testname=GCHECK_ONLY_${base}
2426 [ ${!testname}x == x ] && return 0
2428 echo -n "checking grant......"
2430 # write some data to sync client lost_grant
2431 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2432 for i in `seq $OSTCOUNT`; do
2433 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2434 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2435 count=1 > /dev/null 2>&1
2437 # sync all the data and make sure no pending data on server
2440 #get client grant and server grant
2442 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2443 client_grant=$((client_grant + $d))
2446 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2447 server_grant=$((server_grant + $d))
2450 # cleanup the check_grant file
2451 for i in `seq $OSTCOUNT`; do
2452 rm $DIR1/${tfile}_check_grant_$i
2455 #check whether client grant == server grant
2456 if [ $client_grant != $server_grant ]; then
2457 echo "failed: client:${client_grant} server: ${server_grant}"
2464 ########################
2470 ost=`echo $1 | awk -F_ '{print $3}'`
2471 if [ -z $ost ]; then
2472 ost=`echo $1 | sed 's/-osc.*//'`
2479 [ "$node" != "$(hostname)" ]
2485 for node in $(mdts_nodes); do
2486 remote_node $node && return 0
2493 [ "$CLIENTONLY" ] && return 0 || true
2494 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2500 for node in $(osts_nodes) ; do
2501 remote_node $node && return 0
2508 [ "$CLIENTONLY" ] && return 0 || true
2509 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2515 MGS=$(facet_host mgs)
2516 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2522 for num in `seq $MDSCOUNT`; do
2523 MDSNODES="$MDSNODES $(facet_host mds$num)"
2525 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2531 remote_ost && remote_mds
2535 local OSTNODES=$(facet_host ost1)
2538 for num in `seq $OSTCOUNT`; do
2539 local myOST=$(facet_host ost$num)
2540 OSTNODES="$OSTNODES $myOST"
2542 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2548 # FIXME. We need a list of clients
2549 local myNODES=$HOSTNAME
2552 # CLIENTS (if specified) contains the local client
2553 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2555 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2556 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2559 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2564 remote_nodes_list () {
2565 local rnodes=$(nodes_list)
2566 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2570 init_clients_lists () {
2571 # Sanity check: exclude the local client from RCLIENTS
2572 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2574 # Sanity check: exclude the dup entries
2575 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2577 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2579 # Sanity check: exclude the dup entries from CLIENTS
2580 # for those configs which has SINGLCLIENT set to local client
2581 clients=$(for i in $clients; do echo $i; done | sort -u)
2583 CLIENTS=`comma_list $clients`
2584 local -a remoteclients=($rclients)
2585 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2586 varname=CLIENT$((i + 2))
2587 eval $varname=${remoteclients[i]}
2590 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2593 get_random_entry () {
2596 rnodes=${rnodes//,/ }
2598 local -a nodes=($rnodes)
2599 local num=${#nodes[@]}
2600 local i=$((RANDOM * num * 2 / 65536))
2606 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2611 lctl get_param version | grep -q patchless
2615 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2620 echo $nodes | wc -w || true
2624 local nodes=$(osts_nodes)
2625 local osscount=$(get_node_count "$nodes")
2626 [ ! "$OSTCOUNT" = "$osscount" ]
2630 local nodes=$(mdts_nodes)
2631 local mdtcount=$(get_node_count "$nodes")
2632 [ ! "$MDSCOUNT" = "$mdtcount" ]
2635 generate_machine_file() {
2636 local nodes=${1//,/ }
2637 local machinefile=$2
2638 rm -f $machinefile || error "can't rm $machinefile"
2639 for node in $nodes; do
2640 echo $node >>$machinefile
2645 local file=$1/stripe
2647 $LFS getstripe -v $file || error
2651 check_runas_id_ret() {
2653 local myRUNAS_UID=$1
2654 local myRUNAS_GID=$2
2657 if [ -z "$myRUNAS" ]; then
2658 error_exit "myRUNAS command must be specified for check_runas_id"
2661 $myRUNAS krb5_login.sh || \
2662 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2664 mkdir $DIR/d0_runas_test
2666 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2667 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2668 rm -rf $DIR/d0_runas_test
2673 local myRUNAS_UID=$1
2674 local myRUNAS_GID=$2
2677 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2678 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2679 Please set RUNAS_ID to some UID which exists on MDS and client or
2680 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2683 # obtain the UID/GID for MPI_USER
2687 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2688 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2690 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2691 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2694 # obtain and cache Kerberos ticket-granting ticket
2695 refresh_krb5_tgt() {
2696 local myRUNAS_UID=$1
2697 local myRUNAS_GID=$2
2700 if [ -z "$myRUNAS" ]; then
2701 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2704 CLIENTS=${CLIENTS:-$HOSTNAME}
2705 do_nodes $CLIENTS "set -x
2706 if ! $myRUNAS krb5_login.sh; then
2707 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2712 # Run multiop in the background, but wait for it to print
2713 # "PAUSING" to its stdout before returning from this function.
2714 multiop_bg_pause() {
2715 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2719 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2722 echo "$MULTIOP_PROG $FILE v$ARGS"
2723 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2725 echo "TMPPIPE=${TMPPIPE}"
2726 read -t 60 multiop_output < $TMPPIPE
2727 if [ $? -ne 0 ]; then
2732 if [ "$multiop_output" != "PAUSING" ]; then
2733 echo "Incorrect multiop output: $multiop_output"
2748 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
2754 inodes_available () {
2755 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
2759 # reset llite stat counters
2760 clear_llite_stats(){
2761 lctl set_param -n llite.*.stats 0
2764 # sum llite stat items
2765 calc_llite_stats() {
2766 local res=$(lctl get_param -n llite.*.stats |
2767 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2771 # reset osc stat counters
2773 lctl set_param -n osc.*.osc_stats 0
2776 # sum osc stat items
2778 local res=$(lctl get_param -n osc.*.osc_stats |
2779 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
2784 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
2787 calc_osc_kbytes () {
2788 df $MOUNT > /dev/null
2789 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
2792 # save_lustre_params(node, parameter_mask)
2793 # generate a stream of formatted strings (<node> <param name>=<param value>)
2794 save_lustre_params() {
2796 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
2799 # restore lustre parameters from input stream, produces by save_lustre_params
2800 restore_lustre_params() {
2804 while IFS=" =" read node name val; do
2805 do_node ${node//:/} "lctl set_param -n $name $val"
2809 check_catastrophe() {
2810 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
2811 local C=$CATASTROPHE
2812 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
2814 if [ $rnodes ]; then
2815 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
2816 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
2832 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
2834 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
2835 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
2836 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
2840 # CMD: determine mds index where directory inode presents
2843 local file=$dir/f0.get_mds_dir_tmpfile
2847 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2848 local -a oldused=($iused)
2852 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
2853 local -a newused=($iused)
2856 for ((i=0; i<${#newused[@]}; i++)); do
2857 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
2863 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
2866 mdsrate_cleanup () {
2867 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
2870 delayed_recovery_enabled () {
2871 local var=${SINGLEMDS}_svc
2872 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
2875 ########################
2877 convert_facet2label() {
2880 if [ x$facet = xost ]; then
2884 local varsvc=${facet}_svc
2886 if [ -n ${!varsvc} ]; then
2889 error "No lablel for $facet!"
2893 get_clientosc_proc_path() {
2899 get_lustre_version () {
2900 local node=${1:-"mds"}
2901 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
2904 get_mds_version_major () {
2905 local version=$(get_lustre_version mds)
2906 echo $version | awk -F. '{print $1}'
2909 get_mds_version_minor () {
2910 local version=$(get_lustre_version mds)
2911 echo $version | awk -F. '{print $2}'
2914 get_mdtosc_proc_path() {
2916 local major=$(get_mds_version_major)
2917 local minor=$(get_mds_version_minor)
2918 if [ $major -le 1 -a $minor -le 8 ] ; then
2921 echo "${ost}-osc-MDT0000"
2925 get_osc_import_name() {
2928 local label=$(convert_facet2label $ost)
2930 if [ "$facet" == "mds" ]; then
2931 get_mdtosc_proc_path $label
2935 get_clientosc_proc_path $label
2939 wait_import_state () {
2945 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2946 while [ "${CONN_STATE}" != "${expected}" ]; do
2947 if [ "${expected}" == "DISCONN" ]; then
2948 # for disconn we can check after proc entry is removed
2949 [ "x${CONN_STATE}" == "x" ] && return 0
2950 # with AT we can have connect request timeout ~ reconnect timeout
2951 # and test can't see real disconnect
2952 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2954 # disconnect rpc should be wait not more obd_timeout
2955 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2956 error "can't put import for $CONN_PROC into ${expected} state" && return 1
2958 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2962 log "$CONN_PROC now in ${CONN_STATE} state"
2966 wait_osc_import_state() {
2970 local ost=$(get_osc_import_name $facet $ost_facet)
2975 CONN_PROC="osc.${ost}.ost_server_uuid"
2976 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2977 while [ "${CONN_STATE}" != "${expected}" ]; do
2978 if [ "${expected}" == "DISCONN" ]; then
2979 # for disconn we can check after proc entry is removed
2980 [ "x${CONN_STATE}" == "x" ] && return 0
2981 # with AT we can have connect request timeout ~ reconnect timeout
2982 # and test can't see real disconnect
2983 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
2985 # disconnect rpc should be wait not more obd_timeout
2986 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
2987 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
2989 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
2993 log "${ost_facet} now in ${CONN_STATE} state"
2997 get_clientmdc_proc_path() {
3005 do_nodes --verbose $list "PATH=$LUSTRE/tests/:$PATH sh rpc.sh $@ "
3008 wait_clients_import_state () {
3014 local label=$(convert_facet2label $facet)
3017 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3018 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3019 *) error "unknown facet!" ;;
3023 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3024 error "import is not in ${expected} state"
3033 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3034 $LCTL get_param obdfilter.*.kbytesavail))
3035 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3036 $LCTL get_param -n obdfilter.*.tot_granted))
3037 for ((i=0; i<${#AVAILA[@]}; i++)); do
3038 local -a AVAIL1=(${AVAILA[$i]//=/ })
3039 GRANT=$((${GRANTA[$i]}/1024))
3040 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3041 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3049 local ts=$(date +%s)
3051 # bug 20237, comment 11
3052 # It would also be useful to provide the option
3053 # of writing the file to an NFS directory so it doesn't need to be copied.
3056 [ -d "$SHARED_DIR_LOGS" ] && tmp=$SHARED_DIR_LOGS && docp=false
3058 # dump lustre logs, dmesg
3059 do_nodes $list "log=$tmp/\\\$(hostname)-debug-$ts.log ;
3060 lctl dk \\\$log >/dev/null;
3061 log=$tmp/\\\$(hostname)-dmesg-$ts.log;
3064 # FIXME: does it make sense to collect the logs for $ts only, but all
3066 # rsync $TMP/*${TESTSUITE}* to gather the logs dumped by error fn
3067 local logs=$TMP/'*'${TESTSUITE}'*'
3069 logs=$logs' '$tmp/'*'$ts'*'
3071 for node in ${list//,/ }; do
3072 rsync -az $node:"$logs" $TMP
3075 local archive=$TMP/${TESTSUITE}-$ts.tar.bz2
3076 tar -jcf $archive $tmp/*$ts* $TMP/*${TESTSUITE}*
3082 local list=${1:-$(comma_list $(nodes_list))}
3084 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true