2 # vim:expandtab:shiftwidth=4:softtabstop=4:tabstop=4:
4 trap 'print_summary && echo "test-framework exiting on error"' ERR
9 export REFORMAT=${REFORMAT:-""}
10 export WRITECONF=${WRITECONF:-""}
12 export GMNALNID=${GMNALNID:-/usr/sbin/gmlndnid}
13 export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
16 export GSS_PIPEFS=false
17 export IDENTITY_UPCALL=default
20 #export PDSH="pdsh -S -Rssh -w"
22 # function used by scripts run on remote nodes
23 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
24 . $LUSTRE/tests/functions.sh
25 . $LUSTRE/tests/yaml.sh
27 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
29 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
31 if [ -f "$EXCEPT_LIST_FILE" ]; then
32 echo "Reading test skip list from $EXCEPT_LIST_FILE"
39 [[ $DIR/ = $MOUNT/* ]] || \
40 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
41 [[ $DIR1/ = $MOUNT1/* ]] || \
42 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
43 [[ $DIR2/ = $MOUNT2/* ]] || \
44 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
46 [ -n "$failed" ] && exit 99 || true
50 echo "usage: $0 [-r] [-f cfgfile]"
58 [ "$TESTSUITE" == "lfsck" ] && return 0
59 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
60 local form="%-13s %-17s %s\n"
61 printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
62 echo "------------------------------------------------------------------------------------"
63 for O in $DEFAULT_SUITES; do
66 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
67 local o=$(echo $O | tr "[:upper:]" "[:lower:]")
69 local log=${TMP}/${o}.log
70 [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
71 [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
72 [ "${!O}" = "done" ] && \
73 printf "$form" "Done" "$O" "E=$skipped" && \
74 [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
78 for O in $DEFAULT_SUITES; do
79 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
80 if [ "${!O}" = "no" ]; then
82 # only for those tests suits which are run directly from acc-sm script:
83 # bonnie, iozone, etc.
84 if [ -f "$TESTSUITELOG" ] && grep FAIL $TESTSUITELOG | grep -q ' '$O ; then
85 printf "$form" "UNFINISHED" "$O" ""
87 printf "$form" "Skipped" "$O" ""
92 for O in $DEFAULT_SUITES; do
93 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
94 [ "${!O}" = "done" -o "${!O}" = "no" ] || \
95 printf "$form" "UNFINISHED" "$O" ""
100 export LUSTRE=`absolute_path $LUSTRE`
101 export TESTSUITE=`basename $0 .sh`
102 export TEST_FAILED=false
103 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
105 export MKE2FS=${MKE2FS:-mke2fs}
106 export DEBUGFS=${DEBUGFS:-debugfs}
107 export TUNE2FS=${TUNE2FS:-tune2fs}
108 export E2LABEL=${E2LABEL:-e2label}
109 export DUMPE2FS=${DUMPE2FS:-dumpe2fs}
110 export E2FSCK=${E2FSCK:-e2fsck}
112 #[ -d /r ] && export ROOT=${ROOT:-/r}
113 export TMP=${TMP:-$ROOT/tmp}
114 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
115 if [[ -z $LOGDIRSET ]]; then
116 export LOGDIR=${LOGDIR:-${TMP}/test_logs/}/$(date +%s)
117 export LOGDIRSET=true
119 export HOSTNAME=${HOSTNAME:-`hostname`}
120 if ! echo $PATH | grep -q $LUSTRE/utils; then
121 export PATH=$PATH:$LUSTRE/utils
123 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
124 export PATH=$PATH:$LUSTRE/utils/gss
126 if ! echo $PATH | grep -q $LUSTRE/tests; then
127 export PATH=$PATH:$LUSTRE/tests
129 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
130 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
131 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
132 export PATH=$LUSTRE/tests/racer:$PATH:
134 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
135 export PATH=$PATH:$LUSTRE/tests/mpi
137 export RSYNC_RSH=${RSYNC_RSH:-rsh}
138 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
139 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
140 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
141 [ ! -f "$LFS" ] && export LFS=$(which lfs)
142 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
143 if [ ! -f "$L_GETIDENTITY" ]; then
144 if `which l_getidentity > /dev/null 2>&1`; then
145 export L_GETIDENTITY=$(which l_getidentity)
147 export L_GETIDENTITY=NONE
150 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
151 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
152 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
153 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
154 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
155 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
156 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
157 export FSTYPE=${FSTYPE:-"ldiskfs"}
158 export NAME=${NAME:-local}
159 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
160 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
161 export LGSSD=$(which lgssd)
162 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
163 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
164 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
166 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
169 if [ "$ACCEPTOR_PORT" ]; then
170 export PORT_OPT="--port $ACCEPTOR_PORT"
175 echo "Using GSS/krb5 ptlrpc security flavor"
176 which lgss_keyring > /dev/null 2>&1 || \
177 error_exit "built with gss disabled! SEC=$SEC"
188 IDENTITY_UPCALL=false
191 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
193 # Paths on remote nodes, if different
194 export RLUSTRE=${RLUSTRE:-$LUSTRE}
195 export RPWD=${RPWD:-$PWD}
196 export I_MOUNTED=${I_MOUNTED:-"no"}
197 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
198 ! -f `dirname $0`/../mds/mds.ko ]; then
199 export CLIENTMODSONLY=yes
204 while getopts "rvwf:" opt $*; do
207 r) REFORMAT=--reformat;;
209 w) WRITECONF=writeconf;;
214 shift $((OPTIND - 1))
217 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
222 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
223 *) EXT=".ko"; USE_QUOTA=yes;;
228 /sbin/lsmod | grep -q $1
235 BASE=`basename $module $EXT`
237 module_loaded ${BASE} && return
239 if [ -f ${LUSTRE}/${module}${EXT} ]; then
240 insmod ${LUSTRE}/${module}${EXT} $@
242 # must be testing a "make install" or "rpm" installation
243 # note failed to load ptlrpc_gss is considered not fatal
244 if [ "$BASE" == "ptlrpc_gss" ]; then
245 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
252 load_modules_local() {
253 if [ -n "$MODPROBE" ]; then
257 if [ "$HAVE_MODULES" = true ]; then
263 echo Loading modules from $LUSTRE
264 load_module ../libcfs/libcfs/libcfs
265 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
266 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
268 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
269 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
270 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
271 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
272 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
273 echo "lnet options: '$LNETOPTS'"
274 # note that insmod will ignore anything in modprobe.conf
275 load_module ../lnet/lnet/lnet $LNETOPTS
276 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
277 load_module ../lnet/klnds/$LNETLND
278 load_module lvfs/lvfs
279 load_module obdclass/obdclass
280 load_module ptlrpc/ptlrpc
281 load_module ptlrpc/gss/ptlrpc_gss
282 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
290 if ! client_only; then
291 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
292 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
293 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
298 load_module lvfs/fsfilt_$FSTYPE
302 load_module obdfilter/obdfilter
305 load_module llite/lustre
306 load_module llite/llite_lloop
307 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
309 rm -f $OGDB/ogdb-$HOSTNAME
310 $LCTL modules > $OGDB/ogdb-$HOSTNAME
312 # 'mount' doesn't look in $PATH, just sbin
313 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
319 # load modules on remote nodes optionally
320 # lustre-tests have to be installed on these nodes
321 if $LOAD_MODULES_REMOTE ; then
322 local list=$(comma_list $(remote_nodes_list))
323 echo loading modules on $list
324 do_rpc_nodes $list load_modules
329 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
330 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
331 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
332 echo "$LEAK_LUSTRE" 1>&2
333 echo "$LEAK_PORTALS" 1>&2
334 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
335 echo "Memory leaks detected"
336 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
342 wait_exit_ST client # bug 12845
344 $LUSTRE_RMMOD $FSTYPE || return 2
346 if $LOAD_MODULES_REMOTE ; then
347 local list=$(comma_list $(remote_nodes_list))
348 echo unloading modules on $list
349 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
350 do_rpc_nodes $list check_mem_leak
355 check_mem_leak || return 254
357 echo "modules unloaded."
361 check_gss_daemon_nodes() {
365 do_nodes --verbose $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
366 if [ \\\"\\\$num\\\" -ne 1 ]; then
367 echo \\\$num instance of $dname;
372 check_gss_daemon_facet() {
376 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
377 if [ $num -ne 1 ]; then
378 echo "$num instance of $dname on $facet"
387 echo Stopping $@ on $list
388 do_nodes $list "killall -2 $@ 2>/dev/null || true"
391 # start gss daemons on all nodes, or
392 # "daemon" on "list" if set
393 start_gss_daemons() {
397 if [ "$list" ] && [ "$daemon" ] ; then
398 echo "Starting gss daemon on nodes: $list"
399 do_nodes $list "$daemon" || return 8
403 local list=$(comma_list $(mdts_nodes))
405 echo "Starting gss daemon on mds: $list"
406 do_nodes $list "$LSVCGSSD -v" || return 1
408 do_nodes $list "$LGSSD -v" || return 2
411 list=$(comma_list $(osts_nodes))
412 echo "Starting gss daemon on ost: $list"
413 do_nodes $list "$LSVCGSSD -v" || return 3
414 # starting on clients
416 local clients=${CLIENTS:-`hostname`}
418 echo "Starting $LGSSD on clients $clients "
419 do_nodes $clients "$LGSSD -v" || return 4
422 # wait daemons entering "stable" status
426 # check daemons are running
428 list=$(comma_list $(mdts_nodes) $(osts_nodes))
429 check_gss_daemon_nodes $list lsvcgssd || return 5
431 list=$(comma_list $(mdts_nodes))
432 check_gss_daemon_nodes $list lgssd || return 6
435 check_gss_daemon_nodes $clients lgssd || return 7
440 local list=$(comma_list $(mdts_nodes))
442 send_sigint $list lsvcgssd lgssd
444 list=$(comma_list $(osts_nodes))
445 send_sigint $list lsvcgssd
447 list=${CLIENTS:-`hostname`}
448 send_sigint $list lgssd
453 if ! module_loaded ptlrpc_gss; then
454 load_module ptlrpc/gss/ptlrpc_gss
455 module_loaded ptlrpc_gss ||
456 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
458 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
460 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
461 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
469 # maybe cleanup credential cache?
475 local device=`mdsdevname $num`
476 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
482 local device=`ostdevname $num`
483 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
491 local dev=$(facet_active $facet)_dev
492 local opt=${facet}_opt
493 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
494 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
496 if [ $RC -ne 0 ]; then
497 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
498 echo "Start of ${!dev} on ${facet} failed ${RC}"
500 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
501 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
502 lctl set_param debug_mb=${DEBUG_SIZE}; \
505 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
506 [ -z "$label" ] && echo no label for ${!dev} && exit 1
507 eval export ${facet}_svc=${label}
508 echo Started ${label}
513 # start facet device options
519 eval export ${facet}_dev=${device}
520 eval export ${facet}_opt=\"$@\"
522 local varname=${facet}failover_dev
523 if [ -n "${!varname}" ] ; then
524 eval export ${facet}failover_dev=${!varname}
526 eval export ${facet}failover_dev=$device
529 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
539 HOST=`facet_active_host $facet`
540 [ -z $HOST ] && echo stop: no host for $facet && return 0
542 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
543 if [ ${running} -ne 0 ]; then
544 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
545 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
548 # umount should block, but we should wait for unrelated obd's
549 # like the MGS or MGC to also stop.
550 wait_exit_ST ${facet}
553 # save quota version (both administrative and operational quotas)
554 # add an additional parameter if mountpoint is ever different from $MOUNT
555 quota_save_version() {
556 local fsname=${2:-$FSNAME}
558 local ver=$(tr -c -d "123" <<< $spec)
559 local type=$(tr -c -d "ug" <<< $spec)
561 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
563 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
565 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
567 local osts=$(get_facets OST)
568 for ost in ${osts//,/ }; do
570 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
574 # client could mount several lustre
576 local fsname=${1:-$FSNAME}
578 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
579 do_nodes $(comma_list $(osts_nodes)) \
580 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
584 restore_quota_type () {
585 local mntpt=${1:-$MOUNT}
586 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
587 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
590 quota_save_version $old_QUOTA_TYPE
596 # We need save the original quota_type params, and restore them after testing
598 # Suppose that quota type the same on mds and ost
599 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
600 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
601 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
602 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
603 export old_QUOTA_TYPE=$quota_type
604 quota_save_version $QUOTA_TYPE
606 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
607 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
610 local quota_usrs=$QUOTA_USERS
612 # get_filesystem_size
613 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
614 local blk_soft=$((disksz + 1024))
615 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
617 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
619 local i_hard=$((i_soft + i_soft / 20))
621 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
622 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
625 for usr in $quota_usrs; do
626 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
628 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
630 eval $cmd || error "$cmd FAILED!"
632 # display the quota status
633 echo "Quota settings for $usr : "
634 $LFS quota -v -u $usr $mntpt || true
642 # Only supply -o to mount if we have options
643 if [ -n "$MOUNTOPT" ]; then
644 OPTIONS="-o $MOUNTOPT"
646 local device=$MGSNID:/$FSNAME
647 if [ -z "$mnt" -o -z "$FSNAME" ]; then
648 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
652 echo "Starting client: $client: $OPTIONS $device $mnt"
653 do_node $client mkdir -p $mnt
654 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
656 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
657 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
658 lctl set_param debug_mb=${DEBUG_SIZE}"
671 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
672 if [ $running -ne 0 ]; then
673 echo "Stopping client $client $mnt (opts:$force)"
674 do_node $client lsof -t $mnt || need_kill=no
675 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
676 pids=$(do_node $client lsof -t $mnt | sort -u);
677 if [ -n $pids ]; then
678 do_node $client kill -9 $pids || true
682 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
683 if [ $busy -ne 0 ] ; then
684 echo "$mnt is still busy, wait one second" && sleep 1
685 do_node $client umount $force $mnt
690 # nodes is comma list
691 sanity_mount_check_nodes () {
697 # FIXME: assume that all cluster nodes run the same os
698 [ "$(uname)" = Linux ] || return 0
701 for mnt in $mnts ; do
702 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
703 mpts=\\\$(mount | grep -w -c $mnt);
704 if [ \\\$running -ne \\\$mpts ]; then
705 echo \\\$(hostname) env are INSANE!;
713 sanity_mount_check_servers () {
715 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
716 echo Checking servers environments
718 # FIXME: modify get_facets to display all facets wo params
719 local facets="$(get_facets OST),$(get_facets MDS),mgs"
723 for facet in ${facets//,/ }; do
724 node=$(facet_host ${facet})
725 mnt=${MOUNT%/*}/${facet}
726 sanity_mount_check_nodes $node $mnt ||
727 { error "server $node environments are insane!"; return 1; }
731 sanity_mount_check_clients () {
732 local clients=${1:-$CLIENTS}
733 local mntpt=${2:-$MOUNT}
734 local mntpt2=${3:-$MOUNT2}
736 [ -z $clients ] && clients=$(hostname)
737 echo Checking clients $clients environments
739 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
740 error "clients environments are insane!"
743 sanity_mount_check () {
744 sanity_mount_check_servers || return 1
745 sanity_mount_check_clients || return 2
748 # mount clients if not mouted
749 zconf_mount_clients() {
752 local OPTIONS=${3:-$MOUNTOPT}
754 # Only supply -o to mount if we have options
755 if [ "$OPTIONS" ]; then
756 OPTIONS="-o $OPTIONS"
758 local device=$MGSNID:/$FSNAME
759 if [ -z "$mnt" -o -z "$FSNAME" ]; then
760 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
764 echo "Starting client $clients: $OPTIONS $device $mnt"
767 running=\\\$(mount | grep -c $mnt' ');
769 if [ \\\$running -eq 0 ] ; then
771 mount -t lustre $OPTIONS $device $mnt;
774 exit \\\$rc" || return ${PIPESTATUS[0]}
776 echo "Started clients $clients: "
777 do_nodes $clients "mount | grep -w $mnt"
779 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
780 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
781 lctl set_param debug_mb=${DEBUG_SIZE};"
786 zconf_umount_clients() {
793 echo "Stopping clients: $clients $mnt (opts:$force)"
794 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
795 if [ \\\$running -ne 0 ] ; then
796 echo Stopping client \\\$(hostname) $mnt opts:$force;
797 lsof -t $mnt || need_kill=no;
798 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
799 pids=\\\$(lsof -t $mnt | sort -u);
800 if [ -n \\\"\\\$pids\\\" ]; then
804 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
805 if [ \\\$busy -ne 0 ] ; then
806 echo "$mnt is still busy, wait one second" && sleep 1;
812 shudown_node_hard () {
816 for i in $(seq $attempts) ; do
819 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
820 echo "waiting for $host to fail attempts=$attempts"
821 [ $i -lt $attempts ] || \
822 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
828 local mnt=${2:-$MOUNT}
831 if [ "$FAILURE_MODE" = HARD ]; then
832 shudown_node_hard $client
834 zconf_umount_clients $client $mnt -f
840 if [ "$FAILURE_MODE" = HARD ]; then
841 shudown_node_hard $(facet_active_host $facet)
842 elif [ "$FAILURE_MODE" = SOFT ]; then
849 if [ "$FAILURE_MODE" = HARD ]; then
850 $POWER_UP `facet_active_host $facet`
858 if [ "$FAILURE_MODE" = HARD ]; then
864 # recovery-scale functions
865 check_progs_installed () {
870 do_nodes $clients "PATH=:$PATH; status=true;
871 for prog in $progs; do
872 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
873 echo \\\$prog missing on \\\$(hostname);
881 echo __$(echo $1 | tr '-' 'X')
884 start_client_load() {
887 local var=$(client_var_name $client)_load
888 eval export ${var}=$load
890 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
891 BREAK_ON_ERROR=$BREAK_ON_ERROR \
892 END_RUN_FILE=$END_RUN_FILE \
893 LOAD_PID_FILE=$LOAD_PID_FILE \
894 TESTSUITELOG=$TESTSUITELOG \
896 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
897 log "Started client load: ${load} on $client"
902 start_client_loads () {
903 local -a clients=(${1//,/ })
904 local numloads=${#CLIENT_LOADS[@]}
907 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
908 testnum=$((nodenum % numloads))
909 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
913 # only for remote client
914 check_client_load () {
916 local var=$(client_var_name $client)_load
917 local TESTLOAD=run_${!var}.sh
919 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
921 # bug 18914: try to connect several times not only when
922 # check ps, but while check_catastrophe also
925 while [ $RC = 254 -a $tries -gt 0 ]; do
929 if ! check_catastrophe $client; then
931 if [ $RC -eq 254 ]; then
932 # FIXME: not sure how long we shuold sleep here
936 echo "check catastrophe failed: RC=$RC "
940 # We can continue try to connect if RC=254
941 # Just print the warning about this
942 if [ $RC = 254 ]; then
943 echo "got a return status of $RC from do_node while checking catastrophe on $client"
946 # see if the load is still on the client
949 while [ $RC = 254 -a $tries -gt 0 ]; do
953 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
958 if [ $RC = 254 ]; then
959 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
960 # see if we can diagnose a bit why this is
965 check_client_loads () {
966 local clients=${1//,/ }
970 for client in $clients; do
971 check_client_load $client
973 if [ "$rc" != 0 ]; then
974 log "Client load failed on node $client, rc=$rc"
980 restart_client_loads () {
981 local clients=${1//,/ }
982 local expectedfail=${2:-""}
986 for client in $clients; do
987 check_client_load $client
989 if [ "$rc" != 0 -a "$expectedfail" ]; then
990 local var=$(client_var_name $client)_load
991 start_client_load $client ${!var}
992 echo "Restarted client load ${!var}: on $client. Checking ..."
993 check_client_load $client
995 if [ "$rc" != 0 ]; then
996 log "Client load failed to restart on node $client, rc=$rc"
997 # failure one client load means test fail
998 # we do not need to check other
1006 # End recovery-scale functions
1008 # verify that lustre actually cleaned up properly
1010 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1011 error "LBUG/LASSERT detected"
1012 BUSY=`dmesg | grep -i destruct || true`
1013 if [ "$BUSY" ]; then
1015 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1019 check_mem_leak || exit 204
1021 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1022 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1024 if module_loaded lnet || module_loaded libcfs; then
1025 echo "$0: modules still loaded..." 1>&2
1042 RESULT=$(do_node $node "$TEST")
1043 if [ "$RESULT" == "$FINAL" ]; then
1044 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1047 [ $WAIT -ge $MAX ] && break
1048 echo "Waiting $((MAX - WAIT)) secs for update"
1049 WAIT=$((WAIT + sleep))
1052 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1056 wait_update_facet () {
1058 wait_update $(facet_active_host $facet) "$@"
1061 wait_delete_completed () {
1062 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1063 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1067 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1069 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1070 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1071 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1072 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1076 echo "Delete is not completed in $MAX_WAIT sec"
1082 check_network "$host" 900
1083 while ! do_node $host hostname > /dev/null; do sleep 5; done
1088 local host=`facet_active_host $facet`
1092 wait_recovery_complete () {
1095 # Use default policy if $2 is not passed by caller.
1096 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1097 # as we are in process of changing obd_timeout in different ways
1098 # let's set MAX longer than that
1099 local MAX=${2:-$(( TIMEOUT * 4 ))}
1101 local var_svc=${facet}_svc
1102 local procfile="*.${!var_svc}.recovery_status"
1106 while [ $WAIT -lt $MAX ]; do
1107 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1108 [[ $STATUS = "status: COMPLETE" ]] && return 0
1111 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1113 echo "$facet recovery not done in $MAX sec. $STATUS"
1117 wait_mds_ost_sync () {
1118 # just because recovery is done doesn't mean we've finished
1119 # orphan cleanup. Wait for llogs to get synchronized.
1120 echo "Waiting for orphan cleanup..."
1121 # MAX value includes time needed for MDS-OST reconnection
1122 local MAX=$(( TIMEOUT * 2 ))
1124 while [ $WAIT -lt $MAX ]; do
1125 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1126 "$LCTL get_param -n obdfilter.*.mds_sync"))
1128 for ((i=0; i<${#sync[@]}; i++)); do
1129 [ ${sync[$i]} -eq 0 ] && continue
1130 # there is a not finished MDS-OST synchronization
1134 sleep 2 # increase waiting time and cover statfs cache
1135 [ ${con} -eq 1 ] && return 0
1136 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1139 echo "$facet recovery not done in $MAX sec. $STATUS"
1143 wait_destroy_complete () {
1144 echo "Waiting for destroy to be done..."
1145 # MAX value shouldn't be big as this mean server responsiveness
1146 # never increase this just to make test pass but investigate
1147 # why it takes so long time
1150 while [ $WAIT -lt $MAX ]; do
1151 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1153 for ((i=0; i<${#RPCs[@]}; i++)); do
1154 [ ${RPCs[$i]} -eq 0 ] && continue
1155 # there are still some destroy RPCs in flight
1160 [ ${con} -eq 1 ] && return 0 # done waiting
1161 echo "Waiting $WAIT secs for destroys to be done."
1164 echo "Destroys weren't done in $MAX sec."
1174 # conf-sanity 31 takes a long time cleanup
1175 while [ $WAIT -lt 300 ]; do
1176 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1177 [ -z "${running}" ] && return 0
1178 echo "waited $WAIT for${running}"
1179 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1181 WAIT=$((WAIT + INTERVAL))
1183 echo "service didn't stop after $WAIT seconds. Still running:"
1188 wait_remote_prog () {
1194 [ "$PDSH" = "no_dsh" ] && return 0
1196 while [ $WAIT -lt $2 ]; do
1197 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1198 [ -z "${running}" ] && return 0 || true
1199 echo "waited $WAIT for: "
1201 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1203 WAIT=$((WAIT + INTERVAL))
1205 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1206 [ -z "$pids" ] && return 0
1207 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1208 # FIXME: not portable
1209 for pid in $pids; do
1210 cat /proc/${pid}/status || true
1211 cat /proc/${pid}/wchan || true
1213 kill -9 $pid || true
1222 # not every config has many clients
1224 if [ ! -z "$CLIENTS" ]; then
1225 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1227 stat -f $MOUNT > /dev/null
1233 # usually checked on particular client or locally
1235 if [ ! -z "$client" ]; then
1236 $PDSH $client "stat -f $MOUNT" > /dev/null
1238 stat -f $MOUNT > /dev/null
1246 client_reconnect() {
1247 uname -n >> $MOUNT/recon
1248 if [ -z "$CLIENTS" ]; then
1249 df $MOUNT; uname -n >> $MOUNT/recon
1251 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1253 echo Connected clients:
1255 ls -l $MOUNT/recon > /dev/null
1262 echo "Failing $facet on node `facet_active_host $facet`"
1263 shutdown_facet $facet
1264 [ -n "$sleep_time" ] && sleep $sleep_time
1266 change_active $facet
1267 local TO=`facet_active_host $facet`
1268 echo "Failover $facet to $TO"
1270 mount_facet $facet || error "Restart of $facet failed"
1279 do_facet $facet sync
1281 local svc=${facet}_svc
1282 do_facet $facet $LCTL --device %${!svc} notransno
1283 do_facet $facet $LCTL --device %${!svc} readonly
1284 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1285 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1288 replay_barrier_nodf() {
1289 local facet=$1 echo running=${running}
1290 do_facet $facet sync
1291 local svc=${facet}_svc
1292 echo Replay barrier on ${!svc}
1293 do_facet $facet $LCTL --device %${!svc} notransno
1294 do_facet $facet $LCTL --device %${!svc} readonly
1295 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1296 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1299 replay_barrier_nosync() {
1300 local facet=$1 echo running=${running}
1301 local svc=${facet}_svc
1302 echo Replay barrier on ${!svc}
1303 do_facet $facet $LCTL --device %${!svc} notransno
1304 do_facet $facet $LCTL --device %${!svc} readonly
1305 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1306 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1309 mds_evict_client() {
1310 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1311 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1314 ost_evict_client() {
1315 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1316 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1320 facet_failover $* || error "failover: $?"
1321 clients_up || error "post-failover df: $?"
1326 facet_failover $facet
1332 change_active $facet
1333 mount_facet $facet -o abort_recovery
1334 clients_up || echo "first df failed: $?"
1335 clients_up || error "post-failover df: $?"
1339 echo There is no lmc. This is mountconf, baby.
1344 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1345 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1351 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1357 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1358 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1359 if [ -z "$ID" ]; then
1360 echo "Could not get a ptl id for $1..."
1369 h2name_or_ip "$1" "tcp"
1374 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1375 if type __h2elan >/dev/null 2>&1; then
1378 ID=`echo $1 | sed 's/[^0-9]*//g'`
1386 h2name_or_ip "$1" "openib"
1388 declare -fx h2openib
1391 h2name_or_ip "$1" "o2ib"
1398 [ "$facet" == client ] && echo -n $HOSTNAME && return
1399 varname=${facet}_HOST
1400 if [ -z "${!varname}" ]; then
1401 if [ "${facet:0:3}" == "ost" ]; then
1402 eval ${facet}_HOST=${ost_HOST}
1410 local activevar=${facet}active
1412 if [ -f $TMP/${facet}active ] ; then
1413 source $TMP/${facet}active
1416 active=${!activevar}
1417 if [ -z "$active" ] ; then
1424 facet_active_host() {
1426 local active=`facet_active $facet`
1427 if [ "$facet" == client ]; then
1430 echo `facet_host $active`
1436 local failover=${facet}failover
1437 host=`facet_host $failover`
1438 [ -z "$host" ] && return
1439 local curactive=`facet_active $facet`
1440 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1441 eval export ${facet}active=$facet
1443 eval export ${facet}active=$failover
1445 # save the active host for this facet
1446 local activevar=${facet}active
1447 echo "$activevar=${!activevar}" > $TMP/$activevar
1452 # do not stripe off hostname if verbose, bug 19215
1453 if [ x$1 = x--verbose ]; then
1461 if [ "$HOST" = "$HOSTNAME" ]; then
1463 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1464 echo "cannot run remote command on $HOST with $myPDSH"
1468 echo "CMD: $HOST $@" >&2
1469 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1472 if [ "$myPDSH" = "rsh" ]; then
1473 # we need this because rsh does not return exit code of an executed command
1474 local command_status="$TMP/cs"
1475 rsh $HOST ":> $command_status"
1476 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1477 cd $RPWD; sh -c \"$@\") ||
1478 echo command failed >$command_status"
1479 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1484 # print HOSTNAME for myPDSH="no_dsh"
1485 if [[ $myPDSH = no_dsh ]]; then
1486 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1488 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1491 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed "s/^${HOST}: //"
1493 return ${PIPESTATUS[0]}
1496 single_local_node () {
1497 [ "$1" = "$HOSTNAME" ]
1502 # do not stripe off hostname if verbose, bug 19215
1503 if [ x$1 = x--verbose ]; then
1511 if single_local_node $rnodes; then
1513 do_node --verbose $rnodes $@
1520 # This is part from do_node
1523 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1524 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1527 echo "CMD: $rnodes $@" >&2
1528 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1532 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")"
1534 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1536 return ${PIPESTATUS[0]}
1542 local HOST=`facet_active_host $facet`
1543 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1550 # make sure its not already running
1552 rm -f $TMP/${facet}active
1553 do_facet ${facet} $MKFS $*
1559 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1560 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1567 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1568 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1576 # make sure we are using the primary server, so test-framework will
1577 # be able to clean up properly.
1578 activemds=`facet_active mds1`
1579 if [ $activemds != "mds1" ]; then
1583 local clients=$CLIENTS
1584 [ -z $clients ] && clients=$(hostname)
1586 zconf_umount_clients $clients $MOUNT "$*" || true
1587 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1589 [ "$CLIENTONLY" ] && return
1590 # The add fn does rm ${facet}active file, this would be enough
1591 # if we use do_facet <facet> only after the facet added, but
1592 # currently we use do_facet mds in local.sh
1593 for num in `seq $MDSCOUNT`; do
1595 rm -f ${TMP}/mds${num}active
1598 for num in `seq $OSTCOUNT`; do
1600 rm -f $TMP/ost${num}active
1607 nfs_client_mode && return
1617 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1621 if [ "$IAMDIR" == "yes" ]; then
1622 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1623 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1626 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1629 # We need ldiskfs here, may as well load them all
1631 [ "$CLIENTONLY" ] && return
1632 echo Formatting mgs, mds, osts
1633 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1634 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1637 for num in `seq $MDSCOUNT`; do
1638 echo "Format mds$num: $(mdsdevname $num)"
1640 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1642 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1646 for num in `seq $OSTCOUNT`; do
1647 echo "Format ost$num: $(ostdevname $num)"
1649 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1651 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1657 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1661 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1665 # 0: success, the old identity set already.
1666 # 1: success, the old identity does not set.
1671 local j=`expr $num - 1`
1672 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1674 if [ -z "$MDT" ]; then
1678 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1681 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1683 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1686 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1688 if [ $old = "NONE" ]; then
1697 zconf_umount `hostname` $1 || error "umount failed"
1698 zconf_mount `hostname` $1 || error "mount failed"
1701 writeconf_facet () {
1705 do_facet $facet "$TUNEFS --writeconf $dev"
1709 for num in `seq $MDSCOUNT`; do
1710 DEVNAME=$(mdsdevname $num)
1711 writeconf_facet mds$num $DEVNAME
1714 for num in `seq $OSTCOUNT`; do
1715 DEVNAME=$(ostdevname $num)
1716 writeconf_facet ost$num $DEVNAME
1721 nfs_client_mode && return
1723 sanity_mount_check ||
1724 error "environments are insane!"
1728 if [ -z "$CLIENTONLY" ]; then
1729 echo Setup mgs, mdt, osts
1730 echo $WRITECONF | grep -q "writeconf" && \
1732 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1733 start mgs $MGSDEV $mgs_MOUNT_OPTS
1736 for num in `seq $MDSCOUNT`; do
1737 DEVNAME=$(mdsdevname $num)
1738 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1740 # We started mds, now we should set failover variables properly.
1741 # Set mds${num}failover_HOST if it is not set (the default failnode).
1742 local varname=mds${num}failover_HOST
1743 if [ -z "${!varname}" ]; then
1744 eval mds${num}failover_HOST=$(facet_host mds$num)
1747 if [ $IDENTITY_UPCALL != "default" ]; then
1748 switch_identity $num $IDENTITY_UPCALL
1751 for num in `seq $OSTCOUNT`; do
1752 DEVNAME=$(ostdevname $num)
1753 start ost$num $DEVNAME $OST_MOUNT_OPTS
1755 # We started ost$num, now we should set ost${num}failover variable properly.
1756 # Set ost${num}failover_HOST if it is not set (the default failnode).
1757 varname=ost${num}failover_HOST
1758 if [ -z "${!varname}" ]; then
1759 eval ost${num}failover_HOST=$(facet_host ost${num})
1767 # wait a while to allow sptlrpc configuration be propogated to targets,
1768 # only needed when mounting new target devices.
1773 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1775 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1777 if [ "$MOUNT_2" ]; then
1778 mount_client $MOUNT2
1779 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1784 # by remounting mdt before ost, initial connect from mdt to ost might
1785 # timeout because ost is not ready yet. wait some time to its fully
1786 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1787 # by a context negotiation rpc with $TIMEOUT.
1788 # FIXME better by monitoring import status.
1791 sleep $((TIMEOUT + 5))
1797 mounted_lustre_filesystems() {
1798 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1801 init_facet_vars () {
1802 [ "$CLIENTONLY" ] && return 0
1809 eval export ${facet}_dev=${device}
1810 eval export ${facet}_opt=\"$@\"
1812 local dev=${facet}_dev
1813 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1814 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1816 eval export ${facet}_svc=${label}
1818 local varname=${facet}failover_HOST
1819 if [ -z "${!varname}" ]; then
1820 eval $varname=$(facet_host $facet)
1823 # ${facet}failover_dev is set in cfg file
1824 varname=${facet}failover_dev
1825 if [ -n "${!varname}" ] ; then
1826 eval export ${facet}failover_dev=${!varname}
1828 eval export ${facet}failover_dev=$device
1832 init_facets_vars () {
1835 if ! remote_mds_nodsh; then
1836 for num in `seq $MDSCOUNT`; do
1837 DEVNAME=`mdsdevname $num`
1838 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1842 remote_ost_nodsh && return
1844 for num in `seq $OSTCOUNT`; do
1845 DEVNAME=`ostdevname $num`
1846 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1850 osc_ensure_active () {
1856 while [ $period -lt $timeout ]; do
1857 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1858 if [ $count -eq 0 ]; then
1862 echo "There are $count OST are inactive, wait $period seconds, and try again"
1864 period=$((period+3))
1867 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1871 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1875 init_param_vars () {
1876 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1877 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1878 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1879 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1883 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1885 log "Using TIMEOUT=$TIMEOUT"
1887 osc_ensure_active $SINGLEMDS M $TIMEOUT
1888 osc_ensure_active client c $TIMEOUT
1890 if [ x"$(som_check)" = x"enabled" ]; then
1892 echo "disable quota temporary when SOM enabled"
1894 if [ $QUOTA_AUTO -ne 0 ]; then
1895 if [ "$ENABLE_QUOTA" ]; then
1896 echo "enable quota as required"
1897 setup_quota $MOUNT || return 2
1899 echo "disable quota as required"
1900 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1907 nfs_client_mode () {
1908 if [ "$NFSCLIENT" ]; then
1909 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1910 local clients=$CLIENTS
1911 [ -z $clients ] && clients=$(hostname)
1913 # FIXME: remove hostname when 19215 fixed
1914 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1915 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1916 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1922 check_config_client () {
1925 local mounted=$(mount | grep " $mntpt ")
1926 if [ "$CLIENTONLY" ]; then
1928 # CLIENTONLY should not depend on *_HOST settings
1929 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1930 # in theory someone could create a new,
1931 # client-only config file that assumed lustre was already
1932 # configured and didn't set the MGSNID. If MGSNID is not set,
1933 # then we should use the mgs nid currently being used
1934 # as the default value. bug 18021
1935 [[ x$MGSNID = x ]] &&
1938 if [[ x$mgc != xMGC$MGSNID ]]; then
1939 if [ "$mgs_HOST" ]; then
1940 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1941 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1942 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1948 local myMGS_host=$mgs_HOST
1949 if [ "$NETTYPE" = "ptl" ]; then
1950 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1953 echo Checking config lustre mounted on $mntpt
1954 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1955 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1957 # if [ "$mgshost" != "$myMGS_host" ]; then
1958 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1959 # Please use correct config or set mds_HOST correctly!"
1964 check_config_clients () {
1965 local clients=${CLIENTS:-$HOSTNAME}
1968 nfs_client_mode && return
1970 do_rpc_nodes $clients check_config_client $mntpt
1972 sanity_mount_check ||
1973 error "environments are insane!"
1977 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1978 local cltimeout=$(lctl get_param -n timeout)
1979 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1980 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1987 local mounted=$(mounted_lustre_filesystems)
1989 echo $mounted' ' | grep -w -q $mntpt' '
1992 check_and_setup_lustre() {
1993 nfs_client_mode && return
1995 local MOUNTED=$(mounted_lustre_filesystems)
1999 # both MOUNT and MOUNT2 are not mounted
2000 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2001 [ "$REFORMAT" ] && formatall
2002 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2004 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2005 export I_MOUNTED=yes
2009 elif is_mounted $MOUNT2; then
2011 # MOUNT2 is mounted, while MOUNT_2 is not set
2012 if ! [ "$MOUNT_2" ]; then
2013 cleanup_mount $MOUNT2
2014 export I_UMOUNTED2=yes
2017 # MOUNT2 is mounted, MOUNT_2 is set
2019 # FIXME: what to do if check_config failed?
2021 # 1) remote client has mounted other Lustre fs ?
2022 # 2) it has insane env ?
2023 # let's try umount MOUNT2 on all clients and mount it again:
2024 if ! check_config_clients $MOUNT2; then
2025 cleanup_mount $MOUNT2
2026 restore_mount $MOUNT2
2027 export I_MOUNTED2=yes
2032 # MOUNT is mounted MOUNT2 is not mounted
2033 elif [ "$MOUNT_2" ]; then
2034 restore_mount $MOUNT2
2035 export I_MOUNTED2=yes
2039 # FIXME: what to do if check_config failed?
2041 # 1) remote client has mounted other Lustre fs?
2042 # 2) lustre is mounted on remote_clients atall ?
2043 check_config_clients $MOUNT
2047 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2048 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2049 lctl set_param debug_mb=${DEBUG_SIZE};
2056 if [ "$ONLY" == "setup" ]; then
2062 local clients=${CLIENTS:-$HOSTNAME}
2065 zconf_mount_clients $clients $mntpt
2069 local clients=${CLIENTS:-$HOSTNAME}
2072 zconf_umount_clients $clients $mntpt
2075 cleanup_and_setup_lustre() {
2076 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2077 lctl set_param debug=0 || true
2079 if [ "$ONLY" == "cleanup" ]; then
2083 check_and_setup_lustre
2086 check_and_cleanup_lustre() {
2087 if is_mounted $MOUNT; then
2088 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2089 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2092 if [ "$I_UMOUNTED2" = "yes" ]; then
2093 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2096 if [ "$I_MOUNTED2" = "yes" ]; then
2097 cleanup_mount $MOUNT2
2100 if [ "$I_MOUNTED" = "yes" ]; then
2101 cleanupall -f || error "cleanup failed"
2113 while [ $NETWORK -eq 0 ]; do
2114 if ping -c 1 -w 3 $1 > /dev/null; then
2118 echo "waiting for $1, $((MAX - WAIT)) secs left"
2121 if [ $WAIT -gt $MAX ]; then
2122 echo "Network not available"
2128 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2139 # the sed converts spaces to commas, but leaves the last space
2140 # alone, so the line doesn't end with a comma.
2141 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2144 # list, excluded are the comma separated lists
2145 exclude_items_from_list () {
2151 for item in ${excluded//,/ }; do
2152 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2154 echo $(comma_list $list)
2157 # list, expand are the comma separated lists
2159 local list=${1//,/ }
2160 local expand=${2//,/ }
2163 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2164 echo $(comma_list $expanded)
2167 testslist_filter () {
2168 local script=$LUSTRE/tests/${TESTSUITE}.sh
2170 [ -f $script ] || return 0
2172 local start_at=$START_AT
2173 local stop_at=$STOP_AT
2175 local var=${TESTSUITE//-/_}_START_AT
2176 [ x"${!var}" != x ] && start_at=${!var}
2177 var=${TESTSUITE//-/_}_STOP_AT
2178 [ x"${!var}" != x ] && stop_at=${!var}
2180 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2181 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2182 /^'${start_at}'$/ {flag = 0}
2183 {if (flag == 1) print $0}
2184 /^'${stop_at}'$/ { flag = 1 }'
2188 (cd `dirname $1`; echo $PWD/`basename $1`)
2192 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2193 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2196 local count=${type}COUNT
2197 for ((i=1; i<=${!count}; i++)) do
2198 list="$list ${name}$i"
2200 echo $(comma_list $list)
2203 ##################################
2204 # Adaptive Timeouts funcs
2207 # only check mds, we assume at_max is the same on all nodes
2208 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2209 if [ $at_max -eq 0 ]; then
2219 # suppose that all ost-s has the same at_max set
2220 if [ $facet == "ost" ]; then
2221 do_facet ost1 "lctl get_param -n at_max"
2223 do_facet $facet "lctl get_param -n at_max"
2233 if [ $facet == "ost" ]; then
2234 for i in `seq $OSTCOUNT`; do
2235 do_facet ost$i "lctl set_param at_max=$at_max"
2238 elif [ $facet == "mds" ]; then
2239 for i in `seq $MDSCOUNT`; do
2240 do_facet mds$i "lctl set_param at_max=$at_max"
2243 do_facet $facet "lctl set_param at_max=$at_max"
2248 ##################################
2252 # OBD_FAIL_MDS_ALL_REQUEST_NET
2254 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2255 do_facet client "$1" || RC=$?
2256 do_facet $SINGLEMDS lctl set_param fail_loc=0
2261 # OBD_FAIL_MDS_ALL_REPLY_NET
2263 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2264 do_facet client "$@" || RC=$?
2265 do_facet $SINGLEMDS lctl set_param fail_loc=0
2269 drop_reint_reply() {
2270 # OBD_FAIL_MDS_REINT_NET_REP
2272 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2273 do_facet client "$@" || RC=$?
2274 do_facet $SINGLEMDS lctl set_param fail_loc=0
2279 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2281 do_facet ost1 lctl set_param fail_loc=0x214
2282 do_facet client "$1" || RC=$?
2283 do_facet client "sync"
2284 do_facet ost1 lctl set_param fail_loc=0
2288 drop_ldlm_cancel() {
2289 #define OBD_FAIL_LDLM_CANCEL 0x304
2291 do_facet client lctl set_param fail_loc=0x304
2292 do_facet client "$@" || RC=$?
2293 do_facet client lctl set_param fail_loc=0
2297 drop_bl_callback() {
2298 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2300 do_facet client lctl set_param fail_loc=0x305
2301 do_facet client "$@" || RC=$?
2302 do_facet client lctl set_param fail_loc=0
2307 #define OBD_FAIL_LDLM_REPLY 0x30c
2309 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2310 do_facet client "$@" || RC=$?
2311 do_facet $SINGLEMDS lctl set_param fail_loc=0
2319 echo "clearing fail_loc on $facet"
2320 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2323 set_nodes_failloc () {
2324 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2327 cancel_lru_locks() {
2328 $LCTL mark "cancel_lru_locks $1 start"
2329 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2330 $LCTL set_param -n $d=clear
2332 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2333 $LCTL mark "cancel_lru_locks $1 stop"
2338 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2339 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2340 echo "$DEFAULT_LRU_SIZE"
2345 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2348 lru_resize_disable()
2350 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2355 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2356 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2357 echo there is still data in page cache $FILE ?
2358 lctl get_param -n $FILE
2362 if [[ $MDSDEV1 != $MGSDEV ]]; then
2370 DEBUGSAVE="$(lctl get_param -n debug)"
2374 [ -n "$DEBUGSAVE" ] && \
2375 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2380 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2383 debug_size_restore() {
2384 [ -n "$DEBUG_SIZE_SAVED" ] && \
2385 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2389 start_full_debug_logging() {
2394 local DEBUG_SIZE=150
2396 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2397 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2400 stop_full_debug_logging() {
2405 ##################################
2407 ##################################
2410 local TYPE=${TYPE:-"FAIL"}
2413 # do not dump logs if $1=false
2414 if [ "x$1" = "xfalse" ]; then
2419 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2421 # We need to dump the logs on all nodes
2423 gather_logs $(comma_list $(nodes_list))
2427 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2428 echo "$@" > $LOGDIR/err
2433 if $FAIL_ON_ERROR; then
2444 # use only if we are ignoring failures for this test, bugno required.
2445 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2446 # e.g. error_ignore 5494 "your message"
2448 local TYPE="IGNORE (bz$1)"
2454 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2459 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2460 [ "$TESTSUITELOG" ] && \
2461 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2464 build_test_filter() {
2465 EXCEPT="$EXCEPT $(testslist_filter)"
2467 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2471 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2472 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2473 [ "$EXCEPT_SLOW" ] && \
2474 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2475 for E in $EXCEPT $ALWAYS_EXCEPT; do
2476 eval EXCEPT_${E}=true
2478 for E in $EXCEPT_SLOW; do
2479 eval EXCEPT_SLOW_${E}=true
2481 for G in $GRANT_CHECK_LIST; do
2482 eval GCHECK_ONLY_${G}=true
2487 if [[ $1 = [a-z]* ]]; then
2494 # print a newline if the last test was skipped
2495 export LAST_SKIPPED=
2499 export base=`basetest $1`
2500 if [ ! -z "$ONLY" ]; then
2502 if [ ${!testname}x != x ]; then
2503 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2504 run_one_logged $1 "$2"
2508 if [ ${!testname}x != x ]; then
2509 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2510 run_one_logged $1 "$2"
2518 if [ ${!testname}x != x ]; then
2520 TESTNAME=test_$1 skip "skipping excluded test $1"
2523 testname=EXCEPT_$base
2524 if [ ${!testname}x != x ]; then
2526 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2529 testname=EXCEPT_SLOW_$1
2530 if [ ${!testname}x != x ]; then
2532 TESTNAME=test_$1 skip "skipping SLOW test $1"
2535 testname=EXCEPT_SLOW_$base
2536 if [ ${!testname}x != x ]; then
2538 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2543 run_one_logged $1 "$2"
2548 EQUALS="======================================================================"
2552 local suffixlen=$((${#EQUALS} - ${#msg}))
2553 [ $suffixlen -lt 5 ] && suffixlen=5
2554 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2559 module_loaded lnet || load_modules
2571 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2576 strace -o $TMP/$1.strace -ttt $*
2578 log "FINISHED: $*: rc $RC"
2583 # Set TEST_STATUS here; will be used for logging the result
2584 if [ -f $LOGDIR/err ]; then
2589 echo $TEST_STATUS " " $@
2593 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2594 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2595 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2599 echo -n "Resetting fail_loc on all nodes..."
2600 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2608 export tdir=d0.${TESTSUITE}/d${base}
2609 export TESTNAME=test_$testnum
2610 local SAVE_UMASK=`umask`
2614 log "== test $testnum: $message == `date +%H:%M:%S`"
2615 test_${testnum} || error "test_$testnum failed with $?"
2618 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2619 check_catastrophe || error "LBUG/LASSERT detected"
2620 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2628 local BEFORE=`date +%s`
2630 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
2631 local test_log=$LOGDIR/$name
2634 run_one $1 "$2" 2>&1 | tee $test_log
2635 local RC=${PIPESTATUS[0]}
2637 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2638 echo "test_$1 returned $RC" | tee $LOGDIR/err
2640 duration=$((`date +%s` - $BEFORE))
2641 pass "(${duration}s)"
2642 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2643 log_sub_test test_${1} $TEST_STATUS $duration "$RC" "$TEST_ERROR"
2645 if [ -f $LOGDIR/err ]; then
2646 $FAIL_ON_ERROR && exit $RC
2653 (cd `dirname $1`; echo $PWD/`basename $1`)
2657 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2658 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2663 export base=`basetest $1`
2664 [ "$CHECK_GRANT" == "no" ] && return 0
2666 testname=GCHECK_ONLY_${base}
2667 [ ${!testname}x == x ] && return 0
2669 echo -n "checking grant......"
2671 # write some data to sync client lost_grant
2672 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2673 for i in `seq $OSTCOUNT`; do
2674 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2675 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2676 count=1 > /dev/null 2>&1
2678 # sync all the data and make sure no pending data on server
2681 #get client grant and server grant
2683 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2684 client_grant=$((client_grant + $d))
2687 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2688 server_grant=$((server_grant + $d))
2691 # cleanup the check_grant file
2692 for i in `seq $OSTCOUNT`; do
2693 rm $DIR1/${tfile}_check_grant_$i
2696 #check whether client grant == server grant
2697 if [ $client_grant != $server_grant ]; then
2698 echo "failed: client:${client_grant} server: ${server_grant}"
2705 ########################
2711 ost=`echo $1 | awk -F_ '{print $3}'`
2712 if [ -z $ost ]; then
2713 ost=`echo $1 | sed 's/-osc.*//'`
2720 [ "$node" != "$(hostname)" ]
2726 for node in $(mdts_nodes); do
2727 remote_node $node && return 0
2734 [ "$CLIENTONLY" ] && return 0 || true
2735 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2740 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
2741 MSKIPPED=1 && return 1
2748 for node in $(osts_nodes) ; do
2749 remote_node $node && return 0
2756 [ "$CLIENTONLY" ] && return 0 || true
2757 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2762 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
2763 OSKIPPED=1 && return 1
2770 MGS=$(facet_host mgs)
2771 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2777 for num in `seq $MDSCOUNT`; do
2778 MDSNODES="$MDSNODES $(facet_host mds$num)"
2780 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2786 remote_ost && remote_mds
2790 local OSTNODES=$(facet_host ost1)
2793 for num in `seq $OSTCOUNT`; do
2794 local myOST=$(facet_host ost$num)
2795 OSTNODES="$OSTNODES $myOST"
2797 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2803 # FIXME. We need a list of clients
2804 local myNODES=$HOSTNAME
2807 # CLIENTS (if specified) contains the local client
2808 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2810 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2811 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2814 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2819 remote_nodes_list () {
2820 local rnodes=$(nodes_list)
2821 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2825 init_clients_lists () {
2826 # Sanity check: exclude the local client from RCLIENTS
2827 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2829 # Sanity check: exclude the dup entries
2830 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2832 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2834 # Sanity check: exclude the dup entries from CLIENTS
2835 # for those configs which has SINGLCLIENT set to local client
2836 clients=$(for i in $clients; do echo $i; done | sort -u)
2838 CLIENTS=`comma_list $clients`
2839 local -a remoteclients=($rclients)
2840 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2841 varname=CLIENT$((i + 2))
2842 eval $varname=${remoteclients[i]}
2845 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2848 get_random_entry () {
2851 rnodes=${rnodes//,/ }
2853 local -a nodes=($rnodes)
2854 local num=${#nodes[@]}
2855 local i=$((RANDOM * num * 2 / 65536))
2861 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2866 lctl get_param version | grep -q patchless
2870 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2875 echo $nodes | wc -w || true
2879 local nodes=$(osts_nodes)
2880 local osscount=$(get_node_count "$nodes")
2881 [ ! "$OSTCOUNT" = "$osscount" ]
2885 local nodes=$(mdts_nodes)
2886 local mdtcount=$(get_node_count "$nodes")
2887 [ ! "$MDSCOUNT" = "$mdtcount" ]
2890 generate_machine_file() {
2891 local nodes=${1//,/ }
2892 local machinefile=$2
2893 rm -f $machinefile || error "can't rm $machinefile"
2894 for node in $nodes; do
2895 echo $node >>$machinefile
2900 local file=$1/stripe
2902 $LFS getstripe -v $file || error
2906 check_runas_id_ret() {
2908 local myRUNAS_UID=$1
2909 local myRUNAS_GID=$2
2912 if [ -z "$myRUNAS" ]; then
2913 error_exit "myRUNAS command must be specified for check_runas_id"
2916 $myRUNAS krb5_login.sh || \
2917 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2919 mkdir $DIR/d0_runas_test
2921 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2922 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2923 rm -rf $DIR/d0_runas_test
2928 local myRUNAS_UID=$1
2929 local myRUNAS_GID=$2
2932 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2933 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2934 Please set RUNAS_ID to some UID which exists on MDS and client or
2935 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2938 # obtain the UID/GID for MPI_USER
2942 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2943 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2945 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2946 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2949 # obtain and cache Kerberos ticket-granting ticket
2950 refresh_krb5_tgt() {
2951 local myRUNAS_UID=$1
2952 local myRUNAS_GID=$2
2955 if [ -z "$myRUNAS" ]; then
2956 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2959 CLIENTS=${CLIENTS:-$HOSTNAME}
2960 do_nodes $CLIENTS "set -x
2961 if ! $myRUNAS krb5_login.sh; then
2962 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2967 # Run multiop in the background, but wait for it to print
2968 # "PAUSING" to its stdout before returning from this function.
2969 multiop_bg_pause() {
2970 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2974 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2977 echo "$MULTIOP_PROG $FILE v$ARGS"
2978 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2980 echo "TMPPIPE=${TMPPIPE}"
2981 read -t 60 multiop_output < $TMPPIPE
2982 if [ $? -ne 0 ]; then
2987 if [ "$multiop_output" != "PAUSING" ]; then
2988 echo "Incorrect multiop output: $multiop_output"
3003 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3009 inodes_available () {
3010 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3014 # reset llite stat counters
3015 clear_llite_stats(){
3016 lctl set_param -n llite.*.stats 0
3019 # sum llite stat items
3020 calc_llite_stats() {
3021 local res=$(lctl get_param -n llite.*.stats |
3022 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3026 # reset osc stat counters
3028 lctl set_param -n osc.*.osc_stats 0
3031 # sum osc stat items
3033 local res=$(lctl get_param -n osc.*.osc_stats |
3034 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3039 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3042 calc_osc_kbytes () {
3043 df $MOUNT > /dev/null
3044 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3047 # save_lustre_params(node, parameter_mask)
3048 # generate a stream of formatted strings (<node> <param name>=<param value>)
3049 save_lustre_params() {
3051 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3054 # restore lustre parameters from input stream, produces by save_lustre_params
3055 restore_lustre_params() {
3059 while IFS=" =" read node name val; do
3060 do_node ${node//:/} "lctl set_param -n $name $val"
3064 check_catastrophe() {
3065 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3066 local C=$CATASTROPHE
3067 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3069 if [ $rnodes ]; then
3070 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3071 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3087 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3089 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3090 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3091 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3095 # CMD: determine mds index where directory inode presents
3098 local file=$dir/f0.get_mds_dir_tmpfile
3103 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3104 local -a oldused=($iused)
3106 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3108 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3109 local -a newused=($iused)
3112 for ((i=0; i<${#newused[@]}; i++)); do
3113 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3119 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3122 mdsrate_cleanup () {
3124 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3129 delayed_recovery_enabled () {
3130 local var=${SINGLEMDS}_svc
3131 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3134 ########################
3136 convert_facet2label() {
3139 if [ x$facet = xost ]; then
3143 local varsvc=${facet}_svc
3145 if [ -n ${!varsvc} ]; then
3148 error "No lablel for $facet!"
3152 get_clientosc_proc_path() {
3158 get_lustre_version () {
3159 local node=${1:-"mds"}
3160 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3163 get_mds_version_major () {
3164 local version=$(get_lustre_version mds)
3165 echo $version | awk -F. '{print $1}'
3168 get_mds_version_minor () {
3169 local version=$(get_lustre_version mds)
3170 echo $version | awk -F. '{print $2}'
3173 get_mdtosc_proc_path() {
3175 local major=$(get_mds_version_major)
3176 local minor=$(get_mds_version_minor)
3177 if [ $major -le 1 -a $minor -le 8 ] ; then
3180 echo "${ost}-osc-MDT0000"
3184 get_osc_import_name() {
3187 local label=$(convert_facet2label $ost)
3189 if [ "$facet" == "mds" ]; then
3190 get_mdtosc_proc_path $label
3194 get_clientosc_proc_path $label
3198 wait_import_state () {
3204 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3205 while [ "${CONN_STATE}" != "${expected}" ]; do
3206 if [ "${expected}" == "DISCONN" ]; then
3207 # for disconn we can check after proc entry is removed
3208 [ "x${CONN_STATE}" == "x" ] && return 0
3209 # with AT we can have connect request timeout ~ reconnect timeout
3210 # and test can't see real disconnect
3211 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3213 # disconnect rpc should be wait not more obd_timeout
3214 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3215 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3217 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3221 log "$CONN_PROC now in ${CONN_STATE} state"
3225 wait_osc_import_state() {
3229 local ost=$(get_osc_import_name $facet $ost_facet)
3234 CONN_PROC="osc.${ost}.ost_server_uuid"
3235 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3236 while [ "${CONN_STATE}" != "${expected}" ]; do
3237 if [ "${expected}" == "DISCONN" ]; then
3238 # for disconn we can check after proc entry is removed
3239 [ "x${CONN_STATE}" == "x" ] && return 0
3240 # with AT we can have connect request timeout ~ reconnect timeout
3241 # and test can't see real disconnect
3242 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3244 # disconnect rpc should be wait not more obd_timeout
3245 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3246 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3248 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3252 log "${ost_facet} now in ${CONN_STATE} state"
3255 get_clientmdc_proc_path() {
3263 # Add paths to lustre tests for 32 and 64 bit systems.
3264 local RPATH="$LUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3265 do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
3268 wait_clients_import_state () {
3274 local label=$(convert_facet2label $facet)
3277 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3278 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3279 *) error "unknown facet!" ;;
3282 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3283 error "import is not in ${expected} state"
3292 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3293 $LCTL get_param obdfilter.*.kbytesavail))
3294 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3295 $LCTL get_param -n obdfilter.*.tot_granted))
3296 for ((i=0; i<${#AVAILA[@]}; i++)); do
3297 local -a AVAIL1=(${AVAILA[$i]//=/ })
3298 GRANT=$((${GRANTA[$i]}/1024))
3299 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3300 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3306 do_facet mgs lctl pool_list $1
3310 local fsname=${1%%.*}
3311 local poolname=${1##$fsname.}
3313 do_facet mgs lctl pool_new $1
3315 # get param should return err unless pool is created
3316 [[ $RC -ne 0 ]] && return $RC
3318 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3319 2>/dev/null || echo foo" "" || RC=1
3320 if [[ $RC -eq 0 ]]; then
3323 error "pool_new failed $1"
3328 add_pool_to_list () {
3329 local fsname=${1%%.*}
3330 local poolname=${1##$fsname.}
3332 local listvar=${fsname}_CREATED_POOLS
3333 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3336 remove_pool_from_list () {
3337 local fsname=${1%%.*}
3338 local poolname=${1##$fsname.}
3340 local listvar=${fsname}_CREATED_POOLS
3341 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3344 destroy_pool_int() {
3346 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3347 awk '$1 !~ /^Pool:/ {print $1}')
3348 for ost in $OSTS; do
3349 do_facet mgs lctl pool_remove $1 $ost
3351 do_facet mgs lctl pool_destroy $1
3354 # <fsname>.<poolname> or <poolname>
3356 local fsname=${1%%.*}
3357 local poolname=${1##$fsname.}
3359 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3363 pool_list $fsname.$poolname || return $?
3365 destroy_pool_int $fsname.$poolname
3367 [[ $RC -ne 0 ]] && return $RC
3369 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3370 2>/dev/null || echo foo" "foo" || RC=1
3372 if [[ $RC -eq 0 ]]; then
3373 remove_pool_from_list $fsname.$poolname
3375 error "destroy pool failed $1"
3381 local fsname=${1:-$FSNAME}
3383 local listvar=${fsname}_CREATED_POOLS
3387 [ x${!listvar} = x ] && return 0
3389 echo destroy the created pools: ${!listvar}
3390 for poolname in ${!listvar//,/ }; do
3391 destroy_pool $fsname.$poolname
3396 local fsname=${1:-$FSNAME}
3398 destroy_pools $fsname
3404 local ts=$(date +%s)
3406 # bug 20237, comment 11
3407 # It would also be useful to provide the option
3408 # of writing the file to an NFS directory so it doesn't need to be copied.
3411 [ -f $LOGDIR/shared ] && docp=false
3413 # dump lustre logs, dmesg
3415 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3417 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3419 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3420 echo "Dumping logs only on local client."
3421 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3422 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3426 do_nodes --verbose $list \
3427 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3428 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3429 if [ ! -f $LOGDIR/shared ]; then
3430 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3433 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3434 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3440 local list=${1:-$(comma_list $(nodes_list))}
3442 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3454 for i in $(seq 0 $num_mntpts); do
3455 cmd="ls -laf ${mntpt_root}$i/$dir"
3461 for pid in $pids; do
3468 get_clients_mount_count () {
3469 local clients=${CLIENTS:-`hostname`}
3471 # we need to take into account the clients mounts and
3472 # exclude mds/ost mounts if any;
3473 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
3477 PROC_CLI="srpc_info"
3485 if [ $M -lt $N ]; then
3489 while [ $N -le $M ]; do
3499 calc_connection_cnt() {
3502 # MDT->MDT = 2 * C(M, 2)
3506 comb_m2=$(combination $MDSCOUNT 2)
3508 local num_clients=$(get_clients_mount_count)
3510 local cnt_mdt2mdt=$((comb_m2 * 2))
3511 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
3512 local cnt_cli2ost=$((num_clients * OSTCOUNT))
3513 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
3514 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
3515 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
3516 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
3530 local cmd="$tgt.srpc.flavor"
3532 if [ $net == "any" ]; then
3537 if [ $dir != "any" ]; then
3542 log "Setting sptlrpc rule: $cmd"
3543 do_facet mgs "$LCTL conf_param $cmd"
3552 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
3553 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
3555 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
3557 if [ "x$bulkspec" != "x" ]; then
3558 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
3560 if [ "x$algs" != "x" ]; then
3561 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
3563 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
3564 if [ $bulk == "bulkn" ]; then
3565 bulk_count=`echo "$output" | grep "bulk flavor" \
3566 | grep "null/null" | wc -l`
3567 elif [ $bulk == "bulki" ]; then
3568 bulk_count=`echo "$output" | grep "bulk flavor" \
3569 | grep "/null" | grep -v "null/" | wc -l`
3571 bulk_count=`echo "$output" | grep "bulk flavor" \
3572 | grep -v "/null" | grep -v "null/" | wc -l`
3576 [ $bulk_count -lt $count ] && count=$bulk_count
3587 local clients=${CLIENTS:-`hostname`}
3589 for c in ${clients//,/ }; do
3590 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
3591 tmpcnt=`count_flvr "$output" $flavor`
3592 cnt=$((cnt + tmpcnt))
3602 local clients=${CLIENTS:-`hostname`}
3604 for c in ${clients//,/ }; do
3605 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
3606 tmpcnt=`count_flvr "$output" $flavor`
3607 cnt=$((cnt + tmpcnt))
3617 if [ $MDSCOUNT -le 1 ]; then
3622 for num in `seq $MDSCOUNT`; do
3623 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
3624 tmpcnt=`count_flvr "$output" $flavor`
3625 cnt=$((cnt + tmpcnt))
3635 for num in `seq $MDSCOUNT`; do
3636 output=`do_facet mds$num lctl get_param -n osc.*OST*-osc-MDT*.$PROC_CLI 2>/dev/null`
3637 tmpcnt=`count_flvr "$output" $flavor`
3638 cnt=$((cnt + tmpcnt))
3647 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
3648 count_flvr "$output" $flavor
3653 local dir=$1 # from to
3654 local flavor=$2 # flavor expected
3657 if [ $dir == "cli2mdt" ]; then
3658 res=`flvr_cnt_cli2mdt $flavor`
3659 elif [ $dir == "cli2ost" ]; then
3660 res=`flvr_cnt_cli2ost $flavor`
3661 elif [ $dir == "mdt2mdt" ]; then
3662 res=`flvr_cnt_mdt2mdt $flavor`
3663 elif [ $dir == "mdt2ost" ]; then
3664 res=`flvr_cnt_mdt2ost $flavor`
3665 elif [ $dir == "all2ost" ]; then
3666 res1=`flvr_cnt_mdt2ost $flavor`
3667 res2=`flvr_cnt_cli2ost $flavor`
3668 res=$((res1 + res2))
3669 elif [ $dir == "all2mdt" ]; then
3670 res1=`flvr_cnt_mdt2mdt $flavor`
3671 res2=`flvr_cnt_cli2mdt $flavor`
3672 res=$((res1 + res2))
3673 elif [ $dir == "all2all" ]; then
3674 res1=`flvr_cnt_mdt2ost $flavor`
3675 res2=`flvr_cnt_cli2ost $flavor`
3676 res3=`flvr_cnt_mdt2mdt $flavor`
3677 res4=`flvr_cnt_cli2mdt $flavor`
3678 res=$((res1 + res2 + res3 + res4))
3686 local dir=$1 # from to
3687 local flavor=$2 # flavor expected
3688 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
3692 for ((i=0;i<20;i++)); do
3693 echo -n "checking..."
3694 res=$(do_check_flavor $dir $flavor)
3695 if [ $res -eq $expect ]; then
3696 echo "found $res $flavor connections of $dir, OK"
3699 echo "found $res $flavor connections of $dir, not ready ($expect)"
3704 echo "Error checking $flavor of $dir: expect $expect, actual $res"
3708 restore_to_default_flavor()
3710 local proc="mgs.MGS.live.$FSNAME"
3712 echo "restoring to default flavor..."
3714 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3716 # remove all existing rules if any
3717 if [ $nrule -ne 0 ]; then
3718 echo "$nrule existing rules"
3719 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
3720 echo "remove rule: $rule"
3721 spec=`echo $rule | awk -F = '{print $1}'`
3722 do_facet mgs "$LCTL conf_param $spec="
3726 # verify no rules left
3727 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3728 [ $nrule -ne 0 ] && error "still $nrule rules left"
3730 # wait for default flavor to be applied
3731 # currently default flavor for all connections are 'null'
3732 wait_flavor all2all null
3733 echo "now at default flavor settings"
3738 local flavor=${1:-null}
3740 echo "setting all flavor to $flavor"
3742 # FIXME need parameter to this fn
3743 # and remove global vars
3744 local cnt_all2all=$(calc_connection_cnt all2all)
3746 local res=$(do_check_flavor all2all $flavor)
3747 if [ $res -eq $cnt_all2all ]; then
3748 echo "already have total $res $flavor connections"
3752 echo "found $res $flavor out of total $cnt_all2all connections"
3753 restore_to_default_flavor
3755 [[ $flavor = null ]] && return 0
3757 set_rule $FSNAME any any $flavor
3758 wait_flavor all2all $flavor
3764 # Checking for shared logdir
3765 if [ ! -d $dir ]; then
3766 # Not found. Create local logdir
3769 touch $dir/node.$(hostname).yml
3774 check_write_access() {
3776 for node in $(nodes_list); do
3777 if [ ! -f "$dir/node.${node}.yml" ]; then
3778 # Logdir not accessible/writable from this node.
3786 if [[ -n $YAML_LOG ]]; then
3789 export YAML_LOG=${LOGDIR}/results.yml
3793 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
3794 if check_write_access $LOGDIR; then
3795 touch $LOGDIR/shared
3796 echo "Logging to shared log directory: $LOGDIR"
3798 echo "Logging to local directory: $LOGDIR"
3801 yml_nodes_file $LOGDIR
3802 yml_results_file >> $YAML_LOG
3806 yml_log_test $1 >> $YAML_LOG
3810 yml_log_sub_test $@ >> $YAML_LOG