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 LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
130 [ ! -f "$LST" ] && export LST=$(which lst)
131 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
132 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
133 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
134 export PATH=$LUSTRE/tests/racer:$PATH:
136 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
137 export PATH=$PATH:$LUSTRE/tests/mpi
139 export RSYNC_RSH=${RSYNC_RSH:-rsh}
140 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
141 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
142 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
143 [ ! -f "$LFS" ] && export LFS=$(which lfs)
144 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
145 if [ ! -f "$L_GETIDENTITY" ]; then
146 if `which l_getidentity > /dev/null 2>&1`; then
147 export L_GETIDENTITY=$(which l_getidentity)
149 export L_GETIDENTITY=NONE
152 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
153 [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
154 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
155 [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
156 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
157 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
158 [ ! -f "$LUSTRE_RMMOD" ] && export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
159 export FSTYPE=${FSTYPE:-"ldiskfs"}
160 export NAME=${NAME:-local}
161 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
162 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
163 export LGSSD=$(which lgssd)
164 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
165 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
166 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
168 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
171 if [ "$ACCEPTOR_PORT" ]; then
172 export PORT_OPT="--port $ACCEPTOR_PORT"
177 echo "Using GSS/krb5 ptlrpc security flavor"
178 which lgss_keyring > /dev/null 2>&1 || \
179 error_exit "built with gss disabled! SEC=$SEC"
190 IDENTITY_UPCALL=false
193 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
195 # Paths on remote nodes, if different
196 export RLUSTRE=${RLUSTRE:-$LUSTRE}
197 export RPWD=${RPWD:-$PWD}
198 export I_MOUNTED=${I_MOUNTED:-"no"}
199 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mds.ko -a \
200 ! -f `dirname $0`/../mds/mds.ko ]; then
201 export CLIENTMODSONLY=yes
206 while getopts "rvwf:" opt $*; do
209 r) REFORMAT=--reformat;;
211 w) WRITECONF=writeconf;;
216 shift $((OPTIND - 1))
219 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
224 2.4.*) EXT=".o"; USE_QUOTA=no; [ ! "$CLIENTONLY" ] && FSTYPE=ext3;;
225 *) EXT=".ko"; USE_QUOTA=yes;;
230 /sbin/lsmod | grep -q $1
237 BASE=`basename $module $EXT`
239 module_loaded ${BASE} && return
241 if [ "$BASE" == "lnet_selftest" ] && \
242 [ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]; then
243 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
245 elif [ -f ${LUSTRE}/${module}${EXT} ]; then
246 insmod ${LUSTRE}/${module}${EXT} $@
248 # must be testing a "make install" or "rpm" installation
249 # note failed to load ptlrpc_gss is considered not fatal
250 if [ "$BASE" == "ptlrpc_gss" ]; then
251 modprobe $BASE $@ 2>/dev/null || echo "gss/krb5 is not supported"
258 load_modules_local() {
259 if [ -n "$MODPROBE" ]; then
263 if [ "$HAVE_MODULES" = true ]; then
269 echo Loading modules from $LUSTRE
270 load_module ../libcfs/libcfs/libcfs
271 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
272 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
274 [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
275 [ ! "$MODPROBECONF" -a -d /etc/modprobe.d ] && MODPROBECONF=/etc/modprobe.d/Lustre
276 [ -z "$LNETOPTS" -a "$MODPROBECONF" ] && \
277 LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
278 echo $LNETOPTS | grep -q "accept=all" || LNETOPTS="$LNETOPTS accept=all";
279 echo "lnet options: '$LNETOPTS'"
280 # note that insmod will ignore anything in modprobe.conf
281 load_module ../lnet/lnet/lnet $LNETOPTS
282 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
283 load_module ../lnet/klnds/$LNETLND
284 load_module lvfs/lvfs
285 load_module obdclass/obdclass
286 load_module ptlrpc/ptlrpc
287 load_module ptlrpc/gss/ptlrpc_gss
288 [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
296 if ! client_only; then
297 grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
298 grep -q jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
299 [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
304 load_module lvfs/fsfilt_$FSTYPE
308 load_module obdfilter/obdfilter
311 load_module llite/lustre
312 load_module llite/llite_lloop
313 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
315 rm -f $OGDB/ogdb-$HOSTNAME
316 $LCTL modules > $OGDB/ogdb-$HOSTNAME
318 # 'mount' doesn't look in $PATH, just sbin
319 [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
325 # load modules on remote nodes optionally
326 # lustre-tests have to be installed on these nodes
327 if $LOAD_MODULES_REMOTE ; then
328 local list=$(comma_list $(remote_nodes_list))
329 echo loading modules on $list
330 do_rpc_nodes $list load_modules
335 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
336 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
337 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
338 echo "$LEAK_LUSTRE" 1>&2
339 echo "$LEAK_PORTALS" 1>&2
340 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
341 echo "Memory leaks detected"
342 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
348 wait_exit_ST client # bug 12845
350 $LUSTRE_RMMOD $FSTYPE || return 2
352 if $LOAD_MODULES_REMOTE ; then
353 local list=$(comma_list $(remote_nodes_list))
354 if [ ! -z $list ]; then
355 echo unloading modules on $list
356 do_rpc_nodes $list $LUSTRE_RMMOD $FSTYPE
357 do_rpc_nodes $list check_mem_leak
363 check_mem_leak || return 254
365 echo "modules unloaded."
369 check_gss_daemon_nodes() {
373 do_nodes --verbose $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
374 if [ \\\"\\\$num\\\" -ne 1 ]; then
375 echo \\\$num instance of $dname;
380 check_gss_daemon_facet() {
384 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
385 if [ $num -ne 1 ]; then
386 echo "$num instance of $dname on $facet"
395 echo Stopping $@ on $list
396 do_nodes $list "killall -2 $@ 2>/dev/null || true"
399 # start gss daemons on all nodes, or
400 # "daemon" on "list" if set
401 start_gss_daemons() {
405 if [ "$list" ] && [ "$daemon" ] ; then
406 echo "Starting gss daemon on nodes: $list"
407 do_nodes $list "$daemon" || return 8
411 local list=$(comma_list $(mdts_nodes))
413 echo "Starting gss daemon on mds: $list"
414 do_nodes $list "$LSVCGSSD -v" || return 1
416 do_nodes $list "$LGSSD -v" || return 2
419 list=$(comma_list $(osts_nodes))
420 echo "Starting gss daemon on ost: $list"
421 do_nodes $list "$LSVCGSSD -v" || return 3
422 # starting on clients
424 local clients=${CLIENTS:-`hostname`}
426 echo "Starting $LGSSD on clients $clients "
427 do_nodes $clients "$LGSSD -v" || return 4
430 # wait daemons entering "stable" status
434 # check daemons are running
436 list=$(comma_list $(mdts_nodes) $(osts_nodes))
437 check_gss_daemon_nodes $list lsvcgssd || return 5
439 list=$(comma_list $(mdts_nodes))
440 check_gss_daemon_nodes $list lgssd || return 6
443 check_gss_daemon_nodes $clients lgssd || return 7
448 local list=$(comma_list $(mdts_nodes))
450 send_sigint $list lsvcgssd lgssd
452 list=$(comma_list $(osts_nodes))
453 send_sigint $list lsvcgssd
455 list=${CLIENTS:-`hostname`}
456 send_sigint $list lgssd
461 if ! module_loaded ptlrpc_gss; then
462 load_module ptlrpc/gss/ptlrpc_gss
463 module_loaded ptlrpc_gss ||
464 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
466 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
468 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
469 echo $LGSS_KEYRING_DEBUG > /proc/fs/lustre/sptlrpc/gss/lgss_keyring/debug_level
477 # maybe cleanup credential cache?
483 local device=`mdsdevname $num`
484 local label=`do_facet mds$num "e2label ${device}" | grep -v "CMD: "`
490 local device=`ostdevname $num`
491 local label=`do_facet ost$num "e2label ${device}" | grep -v "CMD: "`
499 local dev=$(facet_active $facet)_dev
500 local opt=${facet}_opt
501 echo "Starting ${facet}: ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}"
502 do_facet ${facet} mount -t lustre ${!opt} $@ ${!dev} ${MOUNT%/*}/${facet}
504 if [ $RC -ne 0 ]; then
505 echo "mount -t lustre $@ ${!dev} ${MOUNT%/*}/${facet}"
506 echo "Start of ${!dev} on ${facet} failed ${RC}"
508 do_facet ${facet} "lctl set_param debug=\\\"$PTLDEBUG\\\"; \
509 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\"; \
510 lctl set_param debug_mb=${DEBUG_SIZE}; \
513 label=$(do_facet ${facet} "$E2LABEL ${!dev}")
514 [ -z "$label" ] && echo no label for ${!dev} && exit 1
515 eval export ${facet}_svc=${label}
516 echo Started ${label}
521 # start facet device options
527 eval export ${facet}_dev=${device}
528 eval export ${facet}_opt=\"$@\"
530 local varname=${facet}failover_dev
531 if [ -n "${!varname}" ] ; then
532 eval export ${facet}failover_dev=${!varname}
534 eval export ${facet}failover_dev=$device
537 do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
547 HOST=`facet_active_host $facet`
548 [ -z $HOST ] && echo stop: no host for $facet && return 0
550 running=$(do_facet ${facet} "grep -c ${MOUNT%/*}/${facet}' ' /proc/mounts") || true
551 if [ ${running} -ne 0 ]; then
552 echo "Stopping ${MOUNT%/*}/${facet} (opts:$@)"
553 do_facet ${facet} umount -d $@ ${MOUNT%/*}/${facet}
556 # umount should block, but we should wait for unrelated obd's
557 # like the MGS or MGC to also stop.
558 wait_exit_ST ${facet}
561 # save quota version (both administrative and operational quotas)
562 # add an additional parameter if mountpoint is ever different from $MOUNT
563 quota_save_version() {
564 local fsname=${2:-$FSNAME}
566 local ver=$(tr -c -d "123" <<< $spec)
567 local type=$(tr -c -d "ug" <<< $spec)
569 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
571 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
573 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
575 local osts=$(get_facets OST)
576 for ost in ${osts//,/ }; do
578 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
582 # client could mount several lustre
584 local fsname=${1:-$FSNAME}
586 do_facet mgs lctl get_param mdd.${fsname}-MDT*.quota_type || rc=$?
587 do_nodes $(comma_list $(osts_nodes)) \
588 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
592 restore_quota_type () {
593 local mntpt=${1:-$MOUNT}
594 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
595 if [ ! "$old_QUOTA_TYPE" ] || [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
598 quota_save_version $old_QUOTA_TYPE
604 # We need save the original quota_type params, and restore them after testing
606 # Suppose that quota type the same on mds and ost
607 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
608 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
609 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
610 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
611 export old_QUOTA_TYPE=$quota_type
612 quota_save_version $QUOTA_TYPE
614 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
615 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
618 local quota_usrs=$QUOTA_USERS
620 # get_filesystem_size
621 local disksz=$(lfs df $mntpt | grep "filesystem summary:" | awk '{print $3}')
622 local blk_soft=$((disksz + 1024))
623 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
625 local Inodes=$(lfs df -i $mntpt | grep "filesystem summary:" | awk '{print $3}')
627 local i_hard=$((i_soft + i_soft / 20))
629 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
630 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
633 for usr in $quota_usrs; do
634 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
636 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
638 eval $cmd || error "$cmd FAILED!"
640 # display the quota status
641 echo "Quota settings for $usr : "
642 $LFS quota -v -u $usr $mntpt || true
650 # Only supply -o to mount if we have options
651 if [ -n "$MOUNTOPT" ]; then
652 OPTIONS="-o $MOUNTOPT"
654 local device=$MGSNID:/$FSNAME
655 if [ -z "$mnt" -o -z "$FSNAME" ]; then
656 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
660 echo "Starting client: $client: $OPTIONS $device $mnt"
661 do_node $client mkdir -p $mnt
662 do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
664 do_node $client "lctl set_param debug=\\\"$PTLDEBUG\\\";
665 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
666 lctl set_param debug_mb=${DEBUG_SIZE}"
679 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
680 if [ $running -ne 0 ]; then
681 echo "Stopping client $client $mnt (opts:$force)"
682 do_node $client lsof -t $mnt || need_kill=no
683 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
684 pids=$(do_node $client lsof -t $mnt | sort -u);
685 if [ -n $pids ]; then
686 do_node $client kill -9 $pids || true
690 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
691 if [ $busy -ne 0 ] ; then
692 echo "$mnt is still busy, wait one second" && sleep 1
693 do_node $client umount $force $mnt
698 # nodes is comma list
699 sanity_mount_check_nodes () {
705 # FIXME: assume that all cluster nodes run the same os
706 [ "$(uname)" = Linux ] || return 0
709 for mnt in $mnts ; do
710 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
711 mpts=\\\$(mount | grep -w -c $mnt);
712 if [ \\\$running -ne \\\$mpts ]; then
713 echo \\\$(hostname) env are INSANE!;
721 sanity_mount_check_servers () {
723 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
724 echo Checking servers environments
726 # FIXME: modify get_facets to display all facets wo params
727 local facets="$(get_facets OST),$(get_facets MDS),mgs"
731 for facet in ${facets//,/ }; do
732 node=$(facet_host ${facet})
733 mnt=${MOUNT%/*}/${facet}
734 sanity_mount_check_nodes $node $mnt ||
735 { error "server $node environments are insane!"; return 1; }
739 sanity_mount_check_clients () {
740 local clients=${1:-$CLIENTS}
741 local mntpt=${2:-$MOUNT}
742 local mntpt2=${3:-$MOUNT2}
744 [ -z $clients ] && clients=$(hostname)
745 echo Checking clients $clients environments
747 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
748 error "clients environments are insane!"
751 sanity_mount_check () {
752 sanity_mount_check_servers || return 1
753 sanity_mount_check_clients || return 2
756 # mount clients if not mouted
757 zconf_mount_clients() {
760 local OPTIONS=${3:-$MOUNTOPT}
762 # Only supply -o to mount if we have options
763 if [ "$OPTIONS" ]; then
764 OPTIONS="-o $OPTIONS"
766 local device=$MGSNID:/$FSNAME
767 if [ -z "$mnt" -o -z "$FSNAME" ]; then
768 echo Bad zconf mount command: opt=$OPTIONS dev=$device mnt=$mnt
772 echo "Starting client $clients: $OPTIONS $device $mnt"
775 running=\\\$(mount | grep -c $mnt' ');
777 if [ \\\$running -eq 0 ] ; then
779 mount -t lustre $OPTIONS $device $mnt;
782 exit \\\$rc" || return ${PIPESTATUS[0]}
784 echo "Started clients $clients: "
785 do_nodes $clients "mount | grep -w $mnt"
787 do_nodes $clients "lctl set_param debug=\\\"$PTLDEBUG\\\";
788 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
789 lctl set_param debug_mb=${DEBUG_SIZE};"
794 zconf_umount_clients() {
801 echo "Stopping clients: $clients $mnt (opts:$force)"
802 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
803 if [ \\\$running -ne 0 ] ; then
804 echo Stopping client \\\$(hostname) $mnt opts:$force;
805 lsof -t $mnt || need_kill=no;
806 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
807 pids=\\\$(lsof -t $mnt | sort -u);
808 if [ -n \\\"\\\$pids\\\" ]; then
812 busy=\\\$(umount $force $mnt 2>&1 | grep -c "busy");
813 if [ \\\$busy -ne 0 ] ; then
814 echo "$mnt is still busy, wait one second" && sleep 1;
820 shudown_node_hard () {
824 for i in $(seq $attempts) ; do
827 ping -w 3 -c 1 $host > /dev/null 2>&1 || return 0
828 echo "waiting for $host to fail attempts=$attempts"
829 [ $i -lt $attempts ] || \
830 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
836 local mnt=${2:-$MOUNT}
839 if [ "$FAILURE_MODE" = HARD ]; then
840 shudown_node_hard $client
842 zconf_umount_clients $client $mnt -f
848 if [ "$FAILURE_MODE" = HARD ]; then
849 shudown_node_hard $(facet_active_host $facet)
850 elif [ "$FAILURE_MODE" = SOFT ]; then
857 if [ "$FAILURE_MODE" = HARD ]; then
858 $POWER_UP `facet_active_host $facet`
866 if [ "$FAILURE_MODE" = HARD ]; then
872 # recovery-scale functions
873 check_progs_installed () {
878 do_nodes $clients "PATH=:$PATH; status=true;
879 for prog in $progs; do
880 if ! [ \\\"\\\$(which \\\$prog)\\\" -o \\\"\\\${!prog}\\\" ]; then
881 echo \\\$prog missing on \\\$(hostname);
889 echo __$(echo $1 | tr '-' 'X')
892 start_client_load() {
895 local var=$(client_var_name $client)_load
896 eval export ${var}=$load
898 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
899 BREAK_ON_ERROR=$BREAK_ON_ERROR \
900 END_RUN_FILE=$END_RUN_FILE \
901 LOAD_PID_FILE=$LOAD_PID_FILE \
902 TESTSUITELOG=$TESTSUITELOG \
904 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $!"
905 log "Started client load: ${load} on $client"
910 start_client_loads () {
911 local -a clients=(${1//,/ })
912 local numloads=${#CLIENT_LOADS[@]}
915 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
916 testnum=$((nodenum % numloads))
917 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
921 # only for remote client
922 check_client_load () {
924 local var=$(client_var_name $client)_load
925 local TESTLOAD=run_${!var}.sh
927 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
929 # bug 18914: try to connect several times not only when
930 # check ps, but while check_catastrophe also
933 while [ $RC = 254 -a $tries -gt 0 ]; do
937 if ! check_catastrophe $client; then
939 if [ $RC -eq 254 ]; then
940 # FIXME: not sure how long we shuold sleep here
944 echo "check catastrophe failed: RC=$RC "
948 # We can continue try to connect if RC=254
949 # Just print the warning about this
950 if [ $RC = 254 ]; then
951 echo "got a return status of $RC from do_node while checking catastrophe on $client"
954 # see if the load is still on the client
957 while [ $RC = 254 -a $tries -gt 0 ]; do
961 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
966 if [ $RC = 254 ]; then
967 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
968 # see if we can diagnose a bit why this is
973 check_client_loads () {
974 local clients=${1//,/ }
978 for client in $clients; do
979 check_client_load $client
981 if [ "$rc" != 0 ]; then
982 log "Client load failed on node $client, rc=$rc"
988 restart_client_loads () {
989 local clients=${1//,/ }
990 local expectedfail=${2:-""}
994 for client in $clients; do
995 check_client_load $client
997 if [ "$rc" != 0 -a "$expectedfail" ]; then
998 local var=$(client_var_name $client)_load
999 start_client_load $client ${!var}
1000 echo "Restarted client load ${!var}: on $client. Checking ..."
1001 check_client_load $client
1003 if [ "$rc" != 0 ]; then
1004 log "Client load failed to restart on node $client, rc=$rc"
1005 # failure one client load means test fail
1006 # we do not need to check other
1014 # End recovery-scale functions
1016 # verify that lustre actually cleaned up properly
1018 [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
1019 error "LBUG/LASSERT detected"
1020 BUSY=`dmesg | grep -i destruct || true`
1021 if [ "$BUSY" ]; then
1023 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.`date +%s`
1027 check_mem_leak || exit 204
1029 [ "`lctl dl 2> /dev/null | wc -l`" -gt 0 ] && lctl dl && \
1030 echo "$0: lustre didn't clean up..." 1>&2 && return 202 || true
1032 if module_loaded lnet || module_loaded libcfs; then
1033 echo "$0: modules still loaded..." 1>&2
1050 RESULT=$(do_node $node "$TEST")
1051 if [ "$RESULT" == "$FINAL" ]; then
1052 echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
1055 [ $WAIT -ge $MAX ] && break
1056 echo "Waiting $((MAX - WAIT)) secs for update"
1057 WAIT=$((WAIT + sleep))
1060 echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
1064 wait_update_facet () {
1066 wait_update $(facet_active_host $facet) "$@"
1069 wait_delete_completed () {
1070 local TOTALPREV=`lctl get_param -n osc.*.kbytesavail | \
1071 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1075 while [ "$WAIT" -ne "$MAX_WAIT" ]; do
1077 TOTAL=`lctl get_param -n osc.*.kbytesavail | \
1078 awk 'BEGIN{total=0}; {total+=$1}; END{print total}'`
1079 [ "$TOTAL" -eq "$TOTALPREV" ] && return 0
1080 echo "Waiting delete completed ... prev: $TOTALPREV current: $TOTAL "
1084 echo "Delete is not completed in $MAX_WAIT sec"
1090 check_network "$host" 900
1091 while ! do_node $host hostname > /dev/null; do sleep 5; done
1096 local host=`facet_active_host $facet`
1100 wait_recovery_complete () {
1103 # Use default policy if $2 is not passed by caller.
1104 #define OBD_RECOVERY_TIMEOUT (obd_timeout * 5 / 2)
1105 # as we are in process of changing obd_timeout in different ways
1106 # let's set MAX longer than that
1107 local MAX=${2:-$(( TIMEOUT * 4 ))}
1109 local var_svc=${facet}_svc
1110 local procfile="*.${!var_svc}.recovery_status"
1114 while [ $WAIT -lt $MAX ]; do
1115 STATUS=$(do_facet $facet lctl get_param -n $procfile | grep status)
1116 [[ $STATUS = "status: COMPLETE" ]] && return 0
1119 echo "Waiting $((MAX - WAIT)) secs for $facet recovery done. $STATUS"
1121 echo "$facet recovery not done in $MAX sec. $STATUS"
1125 wait_mds_ost_sync () {
1126 # just because recovery is done doesn't mean we've finished
1127 # orphan cleanup. Wait for llogs to get synchronized.
1128 echo "Waiting for orphan cleanup..."
1129 # MAX value includes time needed for MDS-OST reconnection
1130 local MAX=$(( TIMEOUT * 2 ))
1132 while [ $WAIT -lt $MAX ]; do
1133 local -a sync=($(do_nodes $(comma_list $(osts_nodes)) \
1134 "$LCTL get_param -n obdfilter.*.mds_sync"))
1136 for ((i=0; i<${#sync[@]}; i++)); do
1137 [ ${sync[$i]} -eq 0 ] && continue
1138 # there is a not finished MDS-OST synchronization
1142 sleep 2 # increase waiting time and cover statfs cache
1143 [ ${con} -eq 1 ] && return 0
1144 echo "Waiting $WAIT secs for $facet mds-ost sync done."
1147 echo "$facet recovery not done in $MAX sec. $STATUS"
1151 wait_destroy_complete () {
1152 echo "Waiting for destroy to be done..."
1153 # MAX value shouldn't be big as this mean server responsiveness
1154 # never increase this just to make test pass but investigate
1155 # why it takes so long time
1158 while [ $WAIT -lt $MAX ]; do
1159 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
1161 for ((i=0; i<${#RPCs[@]}; i++)); do
1162 [ ${RPCs[$i]} -eq 0 ] && continue
1163 # there are still some destroy RPCs in flight
1168 [ ${con} -eq 1 ] && return 0 # done waiting
1169 echo "Waiting $WAIT secs for destroys to be done."
1172 echo "Destroys weren't done in $MAX sec."
1182 # conf-sanity 31 takes a long time cleanup
1183 while [ $WAIT -lt 300 ]; do
1184 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
1185 [ -z "${running}" ] && return 0
1186 echo "waited $WAIT for${running}"
1187 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
1189 WAIT=$((WAIT + INTERVAL))
1191 echo "service didn't stop after $WAIT seconds. Still running:"
1196 wait_remote_prog () {
1202 [ "$PDSH" = "no_dsh" ] && return 0
1204 while [ $WAIT -lt $2 ]; do
1205 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
1206 [ -z "${running}" ] && return 0 || true
1207 echo "waited $WAIT for: "
1209 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
1211 WAIT=$((WAIT + INTERVAL))
1213 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
1214 [ -z "$pids" ] && return 0
1215 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
1216 # FIXME: not portable
1217 for pid in $pids; do
1218 cat /proc/${pid}/status || true
1219 cat /proc/${pid}/wchan || true
1221 kill -9 $pid || true
1230 # not every config has many clients
1232 if [ ! -z "$CLIENTS" ]; then
1233 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
1235 stat -f $MOUNT > /dev/null
1241 # usually checked on particular client or locally
1243 if [ ! -z "$client" ]; then
1244 $PDSH $client "stat -f $MOUNT" > /dev/null
1246 stat -f $MOUNT > /dev/null
1254 client_reconnect() {
1255 uname -n >> $MOUNT/recon
1256 if [ -z "$CLIENTS" ]; then
1257 df $MOUNT; uname -n >> $MOUNT/recon
1259 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
1261 echo Connected clients:
1263 ls -l $MOUNT/recon > /dev/null
1270 echo "Failing $facet on node `facet_active_host $facet`"
1271 shutdown_facet $facet
1272 [ -n "$sleep_time" ] && sleep $sleep_time
1274 change_active $facet
1275 local TO=`facet_active_host $facet`
1276 echo "Failover $facet to $TO"
1278 mount_facet $facet || error "Restart of $facet failed"
1287 do_facet $facet sync
1289 local svc=${facet}_svc
1290 do_facet $facet $LCTL --device %${!svc} notransno
1291 do_facet $facet $LCTL --device %${!svc} readonly
1292 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1293 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1296 replay_barrier_nodf() {
1297 local facet=$1 echo running=${running}
1298 do_facet $facet sync
1299 local svc=${facet}_svc
1300 echo Replay barrier on ${!svc}
1301 do_facet $facet $LCTL --device %${!svc} notransno
1302 do_facet $facet $LCTL --device %${!svc} readonly
1303 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1304 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1307 replay_barrier_nosync() {
1308 local facet=$1 echo running=${running}
1309 local svc=${facet}_svc
1310 echo Replay barrier on ${!svc}
1311 do_facet $facet $LCTL --device %${!svc} notransno
1312 do_facet $facet $LCTL --device %${!svc} readonly
1313 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
1314 $LCTL mark "local REPLAY BARRIER on ${!svc}"
1317 mds_evict_client() {
1318 UUID=`lctl get_param -n mdc.${mds1_svc}-mdc-*.uuid`
1319 do_facet mds1 "lctl set_param -n mdt.${mds1_svc}.evict_client $UUID"
1322 ost_evict_client() {
1323 UUID=`lctl get_param -n devices| grep ${ost1_svc}-osc- | egrep -v 'MDT' | awk '{print $5}'`
1324 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.evict_client $UUID"
1328 facet_failover $* || error "failover: $?"
1329 clients_up || error "post-failover df: $?"
1334 facet_failover $facet
1340 change_active $facet
1341 mount_facet $facet -o abort_recovery
1342 clients_up || echo "first df failed: $?"
1343 clients_up || error "post-failover df: $?"
1347 echo There is no lmc. This is mountconf, baby.
1352 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1353 ID=`$PDSH $1 $GMNALNID -l | cut -d\ -f2`
1359 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1365 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1366 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | awk '{print $1}'`
1367 if [ -z "$ID" ]; then
1368 echo "Could not get a ptl id for $1..."
1377 h2name_or_ip "$1" "tcp"
1382 if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
1383 if type __h2elan >/dev/null 2>&1; then
1386 ID=`echo $1 | sed 's/[^0-9]*//g'`
1394 h2name_or_ip "$1" "openib"
1396 declare -fx h2openib
1399 h2name_or_ip "$1" "o2ib"
1406 [ "$facet" == client ] && echo -n $HOSTNAME && return
1407 varname=${facet}_HOST
1408 if [ -z "${!varname}" ]; then
1409 if [ "${facet:0:3}" == "ost" ]; then
1410 eval ${facet}_HOST=${ost_HOST}
1418 local activevar=${facet}active
1420 if [ -f $TMP/${facet}active ] ; then
1421 source $TMP/${facet}active
1424 active=${!activevar}
1425 if [ -z "$active" ] ; then
1432 facet_active_host() {
1434 local active=`facet_active $facet`
1435 if [ "$facet" == client ]; then
1438 echo `facet_host $active`
1444 local failover=${facet}failover
1445 host=`facet_host $failover`
1446 [ -z "$host" ] && return
1447 local curactive=`facet_active $facet`
1448 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
1449 eval export ${facet}active=$facet
1451 eval export ${facet}active=$failover
1453 # save the active host for this facet
1454 local activevar=${facet}active
1455 echo "$activevar=${!activevar}" > $TMP/$activevar
1460 # do not stripe off hostname if verbose, bug 19215
1461 if [ x$1 = x--verbose ]; then
1469 if [ "$HOST" = "$HOSTNAME" ]; then
1471 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
1472 echo "cannot run remote command on $HOST with $myPDSH"
1476 echo "CMD: $HOST $@" >&2
1477 $myPDSH $HOST $LCTL mark "$@" > /dev/null 2>&1 || :
1480 if [ "$myPDSH" = "rsh" ]; then
1481 # we need this because rsh does not return exit code of an executed command
1482 local command_status="$TMP/cs"
1483 rsh $HOST ":> $command_status"
1484 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
1485 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
1486 echo command failed >$command_status"
1487 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
1492 # print HOSTNAME for myPDSH="no_dsh"
1493 if [[ $myPDSH = no_dsh ]]; then
1494 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
1496 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1499 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
1501 return ${PIPESTATUS[0]}
1504 single_local_node () {
1505 [ "$1" = "$HOSTNAME" ]
1510 # do not stripe off hostname if verbose, bug 19215
1511 if [ x$1 = x--verbose ]; then
1519 if single_local_node $rnodes; then
1521 do_node --verbose $rnodes $@
1528 # This is part from do_node
1531 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
1532 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
1535 echo "CMD: $rnodes $@" >&2
1536 $myPDSH $rnodes $LCTL mark "$@" > /dev/null 2>&1 || :
1540 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
1542 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -re "s/\w+:\s//g"
1544 return ${PIPESTATUS[0]}
1550 local HOST=`facet_active_host $facet`
1551 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
1558 # make sure its not already running
1560 rm -f $TMP/${facet}active
1561 do_facet ${facet} $MKFS $*
1567 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
1568 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}}
1575 #if $MDSDEVn isn't defined, default is $MDSDEVBASE + num
1576 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}}
1584 # make sure we are using the primary server, so test-framework will
1585 # be able to clean up properly.
1586 activemds=`facet_active mds1`
1587 if [ $activemds != "mds1" ]; then
1591 local clients=$CLIENTS
1592 [ -z $clients ] && clients=$(hostname)
1594 zconf_umount_clients $clients $MOUNT "$*" || true
1595 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
1597 [ "$CLIENTONLY" ] && return
1598 # The add fn does rm ${facet}active file, this would be enough
1599 # if we use do_facet <facet> only after the facet added, but
1600 # currently we use do_facet mds in local.sh
1601 for num in `seq $MDSCOUNT`; do
1603 rm -f ${TMP}/mds${num}active
1606 for num in `seq $OSTCOUNT`; do
1608 rm -f $TMP/ost${num}active
1615 nfs_client_mode && return
1625 test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
1629 if [ "$IAMDIR" == "yes" ]; then
1630 MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
1631 MDSn_MKFS_OPTS="$MDSn_MKFS_OPTS --iam-dir"
1634 [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
1637 # We need ldiskfs here, may as well load them all
1639 [ "$CLIENTONLY" ] && return
1640 echo Formatting mgs, mds, osts
1641 if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
1642 add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
1645 for num in `seq $MDSCOUNT`; do
1646 echo "Format mds$num: $(mdsdevname $num)"
1648 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` || exit 9
1650 add mds$num `mdsmkfsopts $num` $FSTYPE_OPT --reformat `mdsdevname $num` > /dev/null || exit 9
1654 for num in `seq $OSTCOUNT`; do
1655 echo "Format ost$num: $(ostdevname $num)"
1657 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` || exit 10
1659 add ost$num $OST_MKFS_OPTS --reformat `ostdevname $num` > /dev/null || exit 10
1665 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
1669 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
1673 # 0: success, the old identity set already.
1674 # 1: success, the old identity does not set.
1679 local j=`expr $num - 1`
1680 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
1682 if [ -z "$MDT" ]; then
1686 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
1689 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
1691 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
1694 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush \"-1\""
1696 if [ $old = "NONE" ]; then
1705 zconf_umount `hostname` $1 || error "umount failed"
1706 zconf_mount `hostname` $1 || error "mount failed"
1709 writeconf_facet () {
1713 do_facet $facet "$TUNEFS --writeconf $dev"
1717 for num in `seq $MDSCOUNT`; do
1718 DEVNAME=$(mdsdevname $num)
1719 writeconf_facet mds$num $DEVNAME
1722 for num in `seq $OSTCOUNT`; do
1723 DEVNAME=$(ostdevname $num)
1724 writeconf_facet ost$num $DEVNAME
1729 nfs_client_mode && return
1731 sanity_mount_check ||
1732 error "environments are insane!"
1736 if [ -z "$CLIENTONLY" ]; then
1737 echo Setup mgs, mdt, osts
1738 echo $WRITECONF | grep -q "writeconf" && \
1740 if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
1741 start mgs $MGSDEV $mgs_MOUNT_OPTS
1744 for num in `seq $MDSCOUNT`; do
1745 DEVNAME=$(mdsdevname $num)
1746 start mds$num $DEVNAME $MDS_MOUNT_OPTS
1748 # We started mds, now we should set failover variables properly.
1749 # Set mds${num}failover_HOST if it is not set (the default failnode).
1750 local varname=mds${num}failover_HOST
1751 if [ -z "${!varname}" ]; then
1752 eval mds${num}failover_HOST=$(facet_host mds$num)
1755 if [ $IDENTITY_UPCALL != "default" ]; then
1756 switch_identity $num $IDENTITY_UPCALL
1759 for num in `seq $OSTCOUNT`; do
1760 DEVNAME=$(ostdevname $num)
1761 start ost$num $DEVNAME $OST_MOUNT_OPTS
1763 # We started ost$num, now we should set ost${num}failover variable properly.
1764 # Set ost${num}failover_HOST if it is not set (the default failnode).
1765 varname=ost${num}failover_HOST
1766 if [ -z "${!varname}" ]; then
1767 eval ost${num}failover_HOST=$(facet_host ost${num})
1775 # wait a while to allow sptlrpc configuration be propogated to targets,
1776 # only needed when mounting new target devices.
1781 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
1783 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
1785 if [ "$MOUNT_2" ]; then
1786 mount_client $MOUNT2
1787 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
1792 # by remounting mdt before ost, initial connect from mdt to ost might
1793 # timeout because ost is not ready yet. wait some time to its fully
1794 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
1795 # by a context negotiation rpc with $TIMEOUT.
1796 # FIXME better by monitoring import status.
1799 sleep $((TIMEOUT + 5))
1805 mounted_lustre_filesystems() {
1806 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
1809 init_facet_vars () {
1810 [ "$CLIENTONLY" ] && return 0
1817 eval export ${facet}_dev=${device}
1818 eval export ${facet}_opt=\"$@\"
1820 local dev=${facet}_dev
1821 local label=$(do_facet ${facet} "$E2LABEL ${!dev}")
1822 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1824 eval export ${facet}_svc=${label}
1826 local varname=${facet}failover_HOST
1827 if [ -z "${!varname}" ]; then
1828 eval $varname=$(facet_host $facet)
1831 # ${facet}failover_dev is set in cfg file
1832 varname=${facet}failover_dev
1833 if [ -n "${!varname}" ] ; then
1834 eval export ${facet}failover_dev=${!varname}
1836 eval export ${facet}failover_dev=$device
1840 init_facets_vars () {
1843 if ! remote_mds_nodsh; then
1844 for num in `seq $MDSCOUNT`; do
1845 DEVNAME=`mdsdevname $num`
1846 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
1850 remote_ost_nodsh && return
1852 for num in `seq $OSTCOUNT`; do
1853 DEVNAME=`ostdevname $num`
1854 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
1858 osc_ensure_active () {
1864 while [ $period -lt $timeout ]; do
1865 count=$(do_facet $facet "lctl dl | grep '${FSNAME}-OST.*-osc-${type}' | grep ' IN ' 2>/dev/null | wc -l")
1866 if [ $count -eq 0 ]; then
1870 echo "There are $count OST are inactive, wait $period seconds, and try again"
1872 period=$((period+3))
1875 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
1879 SOM_ENABLED=$(do_facet $SINGLEMDS "$LCTL get_param mdt.*.som" | awk -F= ' {print $2}' | head -n 1)
1883 init_param_vars () {
1884 if ! remote_ost_nodsh && ! remote_mds_nodsh; then
1885 export MDSVER=$(do_facet $SINGLEMDS "lctl get_param version" | cut -d. -f1,2)
1886 export OSTVER=$(do_facet ost1 "lctl get_param version" | cut -d. -f1,2)
1887 export CLIVER=$(lctl get_param version | cut -d. -f 1,2)
1891 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1893 log "Using TIMEOUT=$TIMEOUT"
1895 osc_ensure_active $SINGLEMDS M $TIMEOUT
1896 osc_ensure_active client c $TIMEOUT
1898 if [ x"$(som_check)" = x"enabled" ]; then
1900 echo "disable quota temporary when SOM enabled"
1902 if [ $QUOTA_AUTO -ne 0 ]; then
1903 if [ "$ENABLE_QUOTA" ]; then
1904 echo "enable quota as required"
1905 setup_quota $MOUNT || return 2
1907 echo "disable quota as required"
1908 $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
1915 nfs_client_mode () {
1916 if [ "$NFSCLIENT" ]; then
1917 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
1918 local clients=$CLIENTS
1919 [ -z $clients ] && clients=$(hostname)
1921 # FIXME: remove hostname when 19215 fixed
1922 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
1923 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
1924 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
1930 check_config_client () {
1933 local mounted=$(mount | grep " $mntpt ")
1934 if [ "$CLIENTONLY" ]; then
1936 # CLIENTONLY should not depend on *_HOST settings
1937 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
1938 # in theory someone could create a new,
1939 # client-only config file that assumed lustre was already
1940 # configured and didn't set the MGSNID. If MGSNID is not set,
1941 # then we should use the mgs nid currently being used
1942 # as the default value. bug 18021
1943 [[ x$MGSNID = x ]] &&
1946 if [[ x$mgc != xMGC$MGSNID ]]; then
1947 if [ "$mgs_HOST" ]; then
1948 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
1949 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
1950 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
1956 local myMGS_host=$mgs_HOST
1957 if [ "$NETTYPE" = "ptl" ]; then
1958 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
1961 echo Checking config lustre mounted on $mntpt
1962 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
1963 mgshost=$(echo $mgshost | awk -F: '{print $1}')
1965 # if [ "$mgshost" != "$myMGS_host" ]; then
1966 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
1967 # Please use correct config or set mds_HOST correctly!"
1972 check_config_clients () {
1973 local clients=${CLIENTS:-$HOSTNAME}
1976 nfs_client_mode && return
1978 do_rpc_nodes $clients check_config_client $mntpt
1980 sanity_mount_check ||
1981 error "environments are insane!"
1985 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
1986 local cltimeout=$(lctl get_param -n timeout)
1987 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
1988 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
1995 local mounted=$(mounted_lustre_filesystems)
1997 echo $mounted' ' | grep -w -q $mntpt' '
2000 check_and_setup_lustre() {
2001 nfs_client_mode && return
2003 local MOUNTED=$(mounted_lustre_filesystems)
2007 # both MOUNT and MOUNT2 are not mounted
2008 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
2009 [ "$REFORMAT" ] && formatall
2010 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
2012 is_mounted $MOUNT || error "NAME=$NAME not mounted"
2013 export I_MOUNTED=yes
2017 elif is_mounted $MOUNT2; then
2019 # MOUNT2 is mounted, while MOUNT_2 is not set
2020 if ! [ "$MOUNT_2" ]; then
2021 cleanup_mount $MOUNT2
2022 export I_UMOUNTED2=yes
2025 # MOUNT2 is mounted, MOUNT_2 is set
2027 # FIXME: what to do if check_config failed?
2029 # 1) remote client has mounted other Lustre fs ?
2030 # 2) it has insane env ?
2031 # let's try umount MOUNT2 on all clients and mount it again:
2032 if ! check_config_clients $MOUNT2; then
2033 cleanup_mount $MOUNT2
2034 restore_mount $MOUNT2
2035 export I_MOUNTED2=yes
2040 # MOUNT is mounted MOUNT2 is not mounted
2041 elif [ "$MOUNT_2" ]; then
2042 restore_mount $MOUNT2
2043 export I_MOUNTED2=yes
2047 # FIXME: what to do if check_config failed?
2049 # 1) remote client has mounted other Lustre fs?
2050 # 2) lustre is mounted on remote_clients atall ?
2051 check_config_clients $MOUNT
2055 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=\\\"$PTLDEBUG\\\";
2056 lctl set_param subsystem_debug=\\\"${SUBSYSTEM# }\\\";
2057 lctl set_param debug_mb=${DEBUG_SIZE};
2064 if [ "$ONLY" == "setup" ]; then
2070 local clients=${CLIENTS:-$HOSTNAME}
2073 zconf_mount_clients $clients $mntpt
2077 local clients=${CLIENTS:-$HOSTNAME}
2080 zconf_umount_clients $clients $mntpt
2083 cleanup_and_setup_lustre() {
2084 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
2085 lctl set_param debug=0 || true
2087 if [ "$ONLY" == "cleanup" ]; then
2091 check_and_setup_lustre
2094 check_and_cleanup_lustre() {
2095 if is_mounted $MOUNT; then
2096 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
2097 [ "$ENABLE_QUOTA" ] && restore_quota_type || true
2100 if [ "$I_UMOUNTED2" = "yes" ]; then
2101 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
2104 if [ "$I_MOUNTED2" = "yes" ]; then
2105 cleanup_mount $MOUNT2
2108 if [ "$I_MOUNTED" = "yes" ]; then
2109 cleanupall -f || error "cleanup failed"
2121 while [ $NETWORK -eq 0 ]; do
2122 if ping -c 1 -w 3 $1 > /dev/null; then
2126 echo "waiting for $1, $((MAX - WAIT)) secs left"
2129 if [ $WAIT -gt $MAX ]; then
2130 echo "Network not available"
2136 while( !($DSH2 $1 "netstat -tna | grep -q $2") ) ; do
2147 # the sed converts spaces to commas, but leaves the last space
2148 # alone, so the line doesn't end with a comma.
2149 echo "$*" | tr -s " " "\n" | sort -b -u | tr "\n" " " | sed 's/ \([^$]\)/,\1/g'
2152 # list, excluded are the comma separated lists
2153 exclude_items_from_list () {
2159 for item in ${excluded//,/ }; do
2160 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
2162 echo $(comma_list $list)
2165 # list, expand are the comma separated lists
2167 local list=${1//,/ }
2168 local expand=${2//,/ }
2171 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
2172 echo $(comma_list $expanded)
2175 testslist_filter () {
2176 local script=$LUSTRE/tests/${TESTSUITE}.sh
2178 [ -f $script ] || return 0
2180 local start_at=$START_AT
2181 local stop_at=$STOP_AT
2183 local var=${TESTSUITE//-/_}_START_AT
2184 [ x"${!var}" != x ] && start_at=${!var}
2185 var=${TESTSUITE//-/_}_STOP_AT
2186 [ x"${!var}" != x ] && stop_at=${!var}
2188 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
2189 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
2190 /^'${start_at}'$/ {flag = 0}
2191 {if (flag == 1) print $0}
2192 /^'${stop_at}'$/ { flag = 1 }'
2196 (cd `dirname $1`; echo $PWD/`basename $1`)
2200 local name=$(echo $1 | tr "[:upper:]" "[:lower:]")
2201 local type=$(echo $1 | tr "[:lower:]" "[:upper:]")
2204 local count=${type}COUNT
2205 for ((i=1; i<=${!count}; i++)) do
2206 list="$list ${name}$i"
2208 echo $(comma_list $list)
2211 ##################################
2212 # Adaptive Timeouts funcs
2215 # only check mds, we assume at_max is the same on all nodes
2216 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
2217 if [ $at_max -eq 0 ]; then
2227 # suppose that all ost-s has the same at_max set
2228 if [ $facet == "ost" ]; then
2229 do_facet ost1 "lctl get_param -n at_max"
2231 do_facet $facet "lctl get_param -n at_max"
2241 if [ $facet == "ost" ]; then
2242 for i in `seq $OSTCOUNT`; do
2243 do_facet ost$i "lctl set_param at_max=$at_max"
2246 elif [ $facet == "mds" ]; then
2247 for i in `seq $MDSCOUNT`; do
2248 do_facet mds$i "lctl set_param at_max=$at_max"
2251 do_facet $facet "lctl set_param at_max=$at_max"
2256 ##################################
2260 # OBD_FAIL_MDS_ALL_REQUEST_NET
2262 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
2263 do_facet client "$1" || RC=$?
2264 do_facet $SINGLEMDS lctl set_param fail_loc=0
2269 # OBD_FAIL_MDS_ALL_REPLY_NET
2271 do_facet $SINGLEMDS lctl set_param fail_loc=0x122
2272 do_facet client "$@" || RC=$?
2273 do_facet $SINGLEMDS lctl set_param fail_loc=0
2277 drop_reint_reply() {
2278 # OBD_FAIL_MDS_REINT_NET_REP
2280 do_facet $SINGLEMDS lctl set_param fail_loc=0x119
2281 do_facet client "$@" || RC=$?
2282 do_facet $SINGLEMDS lctl set_param fail_loc=0
2287 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
2289 do_facet ost1 lctl set_param fail_loc=0x214
2290 do_facet client "$1" || RC=$?
2291 do_facet client "sync"
2292 do_facet ost1 lctl set_param fail_loc=0
2296 drop_ldlm_cancel() {
2297 #define OBD_FAIL_LDLM_CANCEL 0x304
2299 do_facet client lctl set_param fail_loc=0x304
2300 do_facet client "$@" || RC=$?
2301 do_facet client lctl set_param fail_loc=0
2305 drop_bl_callback() {
2306 #define OBD_FAIL_LDLM_BL_CALLBACK 0x305
2308 do_facet client lctl set_param fail_loc=0x305
2309 do_facet client "$@" || RC=$?
2310 do_facet client lctl set_param fail_loc=0
2315 #define OBD_FAIL_LDLM_REPLY 0x30c
2317 do_facet $SINGLEMDS lctl set_param fail_loc=0x30c
2318 do_facet client "$@" || RC=$?
2319 do_facet $SINGLEMDS lctl set_param fail_loc=0
2327 echo "clearing fail_loc on $facet"
2328 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
2331 set_nodes_failloc () {
2332 do_nodes $(comma_list $1) lctl set_param fail_loc=$2
2335 cancel_lru_locks() {
2336 $LCTL mark "cancel_lru_locks $1 start"
2337 for d in `lctl get_param -N ldlm.namespaces.*.lru_size | egrep -i $1`; do
2338 $LCTL set_param -n $d=clear
2340 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 | grep -v '=0'
2341 $LCTL mark "cancel_lru_locks $1 stop"
2346 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
2347 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
2348 echo "$DEFAULT_LRU_SIZE"
2353 lctl set_param ldlm.namespaces.*$1*.lru_size=0
2356 lru_resize_disable()
2358 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
2363 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
2364 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
2365 echo there is still data in page cache $FILE ?
2366 lctl get_param -n $FILE
2370 if [[ $MDSDEV1 != $MGSDEV ]]; then
2378 DEBUGSAVE="$(lctl get_param -n debug)"
2382 [ -n "$DEBUGSAVE" ] && \
2383 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
2388 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
2391 debug_size_restore() {
2392 [ -n "$DEBUG_SIZE_SAVED" ] && \
2393 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
2397 start_full_debug_logging() {
2402 local DEBUG_SIZE=150
2404 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
2405 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
2408 stop_full_debug_logging() {
2413 ##################################
2415 ##################################
2418 local TYPE=${TYPE:-"FAIL"}
2421 # do not dump logs if $1=false
2422 if [ "x$1" = "xfalse" ]; then
2427 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
2429 # We need to dump the logs on all nodes
2431 gather_logs $(comma_list $(nodes_list))
2435 [ "$TESTSUITELOG" ] && echo "$0: ${TYPE}: $TESTNAME $@" >> $TESTSUITELOG
2436 echo "$@" > $LOGDIR/err
2441 if $FAIL_ON_ERROR; then
2452 # use only if we are ignoring failures for this test, bugno required.
2453 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
2454 # e.g. error_ignore 5494 "your message"
2456 local TYPE="IGNORE (bz$1)"
2462 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
2467 log " SKIP: ${TESTSUITE} ${TESTNAME} $@"
2468 [ "$TESTSUITELOG" ] && \
2469 echo "${TESTSUITE}: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
2472 build_test_filter() {
2473 EXCEPT="$EXCEPT $(testslist_filter)"
2475 [ "$ONLY" ] && log "only running test `echo $ONLY`"
2479 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
2480 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
2481 [ "$EXCEPT_SLOW" ] && \
2482 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
2483 for E in $EXCEPT $ALWAYS_EXCEPT; do
2484 eval EXCEPT_${E}=true
2486 for E in $EXCEPT_SLOW; do
2487 eval EXCEPT_SLOW_${E}=true
2489 for G in $GRANT_CHECK_LIST; do
2490 eval GCHECK_ONLY_${G}=true
2495 if [[ $1 = [a-z]* ]]; then
2502 # print a newline if the last test was skipped
2503 export LAST_SKIPPED=
2507 export base=`basetest $1`
2508 if [ ! -z "$ONLY" ]; then
2510 if [ ${!testname}x != x ]; then
2511 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2512 run_one_logged $1 "$2"
2516 if [ ${!testname}x != x ]; then
2517 [ "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
2518 run_one_logged $1 "$2"
2526 if [ ${!testname}x != x ]; then
2528 TESTNAME=test_$1 skip "skipping excluded test $1"
2531 testname=EXCEPT_$base
2532 if [ ${!testname}x != x ]; then
2534 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
2537 testname=EXCEPT_SLOW_$1
2538 if [ ${!testname}x != x ]; then
2540 TESTNAME=test_$1 skip "skipping SLOW test $1"
2543 testname=EXCEPT_SLOW_$base
2544 if [ ${!testname}x != x ]; then
2546 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
2551 run_one_logged $1 "$2"
2556 EQUALS="======================================================================"
2560 local suffixlen=$((${#EQUALS} - ${#msg}))
2561 [ $suffixlen -lt 5 ] && suffixlen=5
2562 log `echo $(printf '===== %s %.*s\n' "$msg" $suffixlen $EQUALS)`
2567 module_loaded lnet || load_modules
2579 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
2584 strace -o $TMP/$1.strace -ttt $*
2586 log "FINISHED: $*: rc $RC"
2591 # Set TEST_STATUS here; will be used for logging the result
2592 if [ -f $LOGDIR/err ]; then
2597 echo $TEST_STATUS " " $@
2601 FFREE=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filesfree | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2602 FTOTAL=$(do_node $SINGLEMDS lctl get_param -n osd.*MDT*.filestotal | awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}')
2603 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
2607 echo -n "Resetting fail_loc on all nodes..."
2608 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 2>/dev/null || true"
2616 export tdir=d0.${TESTSUITE}/d${base}
2617 export TESTNAME=test_$testnum
2618 local SAVE_UMASK=`umask`
2622 log "== test $testnum: $message == `date +%H:%M:%S`"
2623 test_${testnum} || error "test_$testnum failed with $?"
2626 check_grant ${testnum} || error "check_grant $testnum failed with $?"
2627 check_catastrophe || error "LBUG/LASSERT detected"
2628 ps auxww | grep -v grep | grep -q multiop && error "multiop still running"
2636 local BEFORE=`date +%s`
2638 local name=${TESTSUITE}.test_${1}.test_log.$(hostname).log
2639 local test_log=$LOGDIR/$name
2642 run_one $1 "$2" 2>&1 | tee $test_log
2643 local RC=${PIPESTATUS[0]}
2645 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
2646 echo "test_$1 returned $RC" | tee $LOGDIR/err
2648 duration=$((`date +%s` - $BEFORE))
2649 pass "(${duration}s)"
2650 [ -f $LOGDIR/err ] && TEST_ERROR=$(cat $LOGDIR/err)
2651 log_sub_test test_${1} $TEST_STATUS $duration "$RC" "$TEST_ERROR"
2653 if [ -f $LOGDIR/err ]; then
2654 $FAIL_ON_ERROR && exit $RC
2661 (cd `dirname $1`; echo $PWD/`basename $1`)
2665 [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
2666 [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
2671 export base=`basetest $1`
2672 [ "$CHECK_GRANT" == "no" ] && return 0
2674 testname=GCHECK_ONLY_${base}
2675 [ ${!testname}x == x ] && return 0
2677 echo -n "checking grant......"
2679 # write some data to sync client lost_grant
2680 rm -f $DIR1/${tfile}_check_grant_* 2>&1
2681 for i in `seq $OSTCOUNT`; do
2682 $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
2683 dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
2684 count=1 > /dev/null 2>&1
2686 # sync all the data and make sure no pending data on server
2689 #get client grant and server grant
2691 for d in `lctl get_param -n osc.*.cur_grant_bytes`; do
2692 client_grant=$((client_grant + $d))
2695 for d in `lctl get_param -n obdfilter.*.tot_granted`; do
2696 server_grant=$((server_grant + $d))
2699 # cleanup the check_grant file
2700 for i in `seq $OSTCOUNT`; do
2701 rm $DIR1/${tfile}_check_grant_$i
2704 #check whether client grant == server grant
2705 if [ $client_grant != $server_grant ]; then
2706 echo "failed: client:${client_grant} server: ${server_grant}"
2713 ########################
2719 ost=`echo $1 | awk -F_ '{print $3}'`
2720 if [ -z $ost ]; then
2721 ost=`echo $1 | sed 's/-osc.*//'`
2728 [ "$node" != "$(hostname)" ]
2734 for node in $(mdts_nodes); do
2735 remote_node $node && return 0
2742 [ "$CLIENTONLY" ] && return 0 || true
2743 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
2748 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
2749 MSKIPPED=1 && return 1
2756 for node in $(osts_nodes) ; do
2757 remote_node $node && return 0
2764 [ "$CLIENTONLY" ] && return 0 || true
2765 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2770 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
2771 OSKIPPED=1 && return 1
2778 MGS=$(facet_host mgs)
2779 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
2784 remote_mds_nodsh || remote_ost_nodsh || \
2785 $(single_local_node $(comma_list $(nodes_list)))
2791 for num in `seq $MDSCOUNT`; do
2792 MDSNODES="$MDSNODES $(facet_host mds$num)"
2794 NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
2800 remote_ost && remote_mds
2804 local OSTNODES=$(facet_host ost1)
2807 for num in `seq $OSTCOUNT`; do
2808 local myOST=$(facet_host ost$num)
2809 OSTNODES="$OSTNODES $myOST"
2811 NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
2817 # FIXME. We need a list of clients
2818 local myNODES=$HOSTNAME
2821 # CLIENTS (if specified) contains the local client
2822 [ -n "$CLIENTS" ] && myNODES=${CLIENTS//,/ }
2824 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
2825 myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
2828 myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
2833 remote_nodes_list () {
2834 local rnodes=$(nodes_list)
2835 rnodes=$(echo " $rnodes " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2839 init_clients_lists () {
2840 # Sanity check: exclude the local client from RCLIENTS
2841 local rclients=$(echo " $RCLIENTS " | sed -re "s/\s+$HOSTNAME\s+/ /g")
2843 # Sanity check: exclude the dup entries
2844 rclients=$(for i in $rclients; do echo $i; done | sort -u)
2846 local clients="$SINGLECLIENT $HOSTNAME $rclients"
2848 # Sanity check: exclude the dup entries from CLIENTS
2849 # for those configs which has SINGLCLIENT set to local client
2850 clients=$(for i in $clients; do echo $i; done | sort -u)
2852 CLIENTS=`comma_list $clients`
2853 local -a remoteclients=($rclients)
2854 for ((i=0; $i<${#remoteclients[@]}; i++)); do
2855 varname=CLIENT$((i + 2))
2856 eval $varname=${remoteclients[i]}
2859 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
2862 get_random_entry () {
2865 rnodes=${rnodes//,/ }
2867 local -a nodes=($rnodes)
2868 local num=${#nodes[@]}
2869 local i=$((RANDOM * num * 2 / 65536))
2875 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
2880 lctl get_param version | grep -q patchless
2884 [ "$MDSVER" = "$CLIVER" -a "$OSTVER" = "$CLIVER" ]
2889 echo $nodes | wc -w || true
2893 local nodes=$(osts_nodes)
2894 local osscount=$(get_node_count "$nodes")
2895 [ ! "$OSTCOUNT" = "$osscount" ]
2899 local nodes=$(mdts_nodes)
2900 local mdtcount=$(get_node_count "$nodes")
2901 [ ! "$MDSCOUNT" = "$mdtcount" ]
2904 generate_machine_file() {
2905 local nodes=${1//,/ }
2906 local machinefile=$2
2907 rm -f $machinefile || error "can't rm $machinefile"
2908 for node in $nodes; do
2909 echo $node >>$machinefile
2914 local file=$1/stripe
2916 $LFS getstripe -v $file || error
2920 check_runas_id_ret() {
2922 local myRUNAS_UID=$1
2923 local myRUNAS_GID=$2
2926 if [ -z "$myRUNAS" ]; then
2927 error_exit "myRUNAS command must be specified for check_runas_id"
2930 $myRUNAS krb5_login.sh || \
2931 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
2933 mkdir $DIR/d0_runas_test
2935 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
2936 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
2937 rm -rf $DIR/d0_runas_test
2942 local myRUNAS_UID=$1
2943 local myRUNAS_GID=$2
2946 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
2947 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
2948 Please set RUNAS_ID to some UID which exists on MDS and client or
2949 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
2952 # obtain the UID/GID for MPI_USER
2956 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
2957 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
2959 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
2960 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
2963 # obtain and cache Kerberos ticket-granting ticket
2964 refresh_krb5_tgt() {
2965 local myRUNAS_UID=$1
2966 local myRUNAS_GID=$2
2969 if [ -z "$myRUNAS" ]; then
2970 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
2973 CLIENTS=${CLIENTS:-$HOSTNAME}
2974 do_nodes $CLIENTS "set -x
2975 if ! $myRUNAS krb5_login.sh; then
2976 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
2981 # Run multiop in the background, but wait for it to print
2982 # "PAUSING" to its stdout before returning from this function.
2983 multiop_bg_pause() {
2984 MULTIOP_PROG=${MULTIOP_PROG:-multiop}
2988 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
2991 echo "$MULTIOP_PROG $FILE v$ARGS"
2992 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
2994 echo "TMPPIPE=${TMPPIPE}"
2995 read -t 60 multiop_output < $TMPPIPE
2996 if [ $? -ne 0 ]; then
3001 if [ "$multiop_output" != "PAUSING" ]; then
3002 echo "Incorrect multiop output: $multiop_output"
3017 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
3023 inodes_available () {
3024 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{print $4}' | sort -un | head -1) || return 1
3028 # reset llite stat counters
3029 clear_llite_stats(){
3030 lctl set_param -n llite.*.stats 0
3033 # sum llite stat items
3034 calc_llite_stats() {
3035 local res=$(lctl get_param -n llite.*.stats |
3036 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3040 # reset osc stat counters
3042 lctl set_param -n osc.*.osc_stats 0
3045 # sum osc stat items
3047 local res=$(lctl get_param -n osc.*.osc_stats |
3048 awk 'BEGIN {s = 0} END {print s} /^'"$1"'/ {s += $2}')
3053 awk 'BEGIN {s = 0}; {s += $1}; END {print s}'
3056 calc_osc_kbytes () {
3057 df $MOUNT > /dev/null
3058 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
3061 # save_lustre_params(node, parameter_mask)
3062 # generate a stream of formatted strings (<node> <param name>=<param value>)
3063 save_lustre_params() {
3065 do_nodes --verbose $1 "lctl get_param $2 | while read s; do echo \\\$s; done"
3068 # restore lustre parameters from input stream, produces by save_lustre_params
3069 restore_lustre_params() {
3073 while IFS=" =" read node name val; do
3074 do_node ${node//:/} "lctl set_param -n $name $val"
3078 check_catastrophe() {
3079 local rnodes=${1:-$(comma_list $(remote_nodes_list))}
3080 local C=$CATASTROPHE
3081 [ -f $C ] && [ $(cat $C) -ne 0 ] && return 1
3083 if [ $rnodes ]; then
3084 do_nodes $rnodes "rc=\\\$([ -f $C ] && echo \\\$(< $C) || echo 0);
3085 if [ \\\$rc -ne 0 ]; then echo \\\$(hostname): \\\$rc; fi
3101 do_facet $1 $3 lfs getstripe -v $2 > $tmp_file
3103 stripe_size=`awk '$1 ~ /size/ {print $2}' $tmp_file`
3104 stripe_count=`awk '$1 ~ /count/ {print $2}' $tmp_file`
3105 stripe_index=`awk '$1 ~ /stripe_offset/ {print $2}' $tmp_file`
3109 # CMD: determine mds index where directory inode presents
3112 local file=$dir/f0.get_mds_dir_tmpfile
3117 local iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3118 local -a oldused=($iused)
3120 openfile -f O_CREAT:O_LOV_DELAY_CREATE -m 0644 $file > /dev/null
3122 iused=$(lfs df -i $dir | grep MDT | awk '{print $3}')
3123 local -a newused=($iused)
3126 for ((i=0; i<${#newused[@]}; i++)); do
3127 if [ ${oldused[$i]} -lt ${newused[$i]} ]; then
3133 error "mdt-s : inodes count OLD ${oldused[@]} NEW ${newused[@]}"
3136 mdsrate_cleanup () {
3138 mpi_run -np $1 -machinefile $2 ${MDSRATE} --unlink --nfiles $3 --dir $4 --filefmt $5 $6
3143 delayed_recovery_enabled () {
3144 local var=${SINGLEMDS}_svc
3145 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
3148 ########################
3150 convert_facet2label() {
3153 if [ x$facet = xost ]; then
3157 local varsvc=${facet}_svc
3159 if [ -n ${!varsvc} ]; then
3162 error "No lablel for $facet!"
3166 get_clientosc_proc_path() {
3172 get_lustre_version () {
3173 local node=${1:-"mds"}
3174 do_facet $node $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
3177 get_mds_version_major () {
3178 local version=$(get_lustre_version mds)
3179 echo $version | awk -F. '{print $1}'
3182 get_mds_version_minor () {
3183 local version=$(get_lustre_version mds)
3184 echo $version | awk -F. '{print $2}'
3187 get_mdtosc_proc_path() {
3189 local major=$(get_mds_version_major)
3190 local minor=$(get_mds_version_minor)
3191 if [ $major -le 1 -a $minor -le 8 ] ; then
3194 echo "${ost}-osc-MDT0000"
3198 get_osc_import_name() {
3201 local label=$(convert_facet2label $ost)
3203 if [ "$facet" == "mds" ]; then
3204 get_mdtosc_proc_path $label
3208 get_clientosc_proc_path $label
3212 wait_import_state () {
3218 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3219 while [ "${CONN_STATE}" != "${expected}" ]; do
3220 if [ "${expected}" == "DISCONN" ]; then
3221 # for disconn we can check after proc entry is removed
3222 [ "x${CONN_STATE}" == "x" ] && return 0
3223 # with AT we can have connect request timeout ~ reconnect timeout
3224 # and test can't see real disconnect
3225 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3227 # disconnect rpc should be wait not more obd_timeout
3228 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3229 error "can't put import for $CONN_PROC into ${expected} state" && return 1
3231 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3235 log "$CONN_PROC now in ${CONN_STATE} state"
3239 wait_osc_import_state() {
3243 local ost=$(get_osc_import_name $facet $ost_facet)
3248 CONN_PROC="osc.${ost}.ost_server_uuid"
3249 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3250 while [ "${CONN_STATE}" != "${expected}" ]; do
3251 if [ "${expected}" == "DISCONN" ]; then
3252 # for disconn we can check after proc entry is removed
3253 [ "x${CONN_STATE}" == "x" ] && return 0
3254 # with AT we can have connect request timeout ~ reconnect timeout
3255 # and test can't see real disconnect
3256 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
3258 # disconnect rpc should be wait not more obd_timeout
3259 [ $i -ge $(($TIMEOUT * 3 / 2)) ] && \
3260 error "can't put import for ${ost}(${ost_facet}) into ${expected} state" && return 1
3262 CONN_STATE=$(do_facet $facet lctl get_param -n $CONN_PROC 2>/dev/null | cut -f2)
3266 log "${ost_facet} now in ${CONN_STATE} state"
3269 get_clientmdc_proc_path() {
3277 # Add paths to lustre tests for 32 and 64 bit systems.
3278 local RPATH="$RLUSTRE/tests:/usr/lib/lustre/tests:/usr/lib64/lustre/tests:$PATH"
3279 do_nodes --verbose $list "PATH=$RPATH sh rpc.sh $@ "
3282 wait_clients_import_state () {
3288 local label=$(convert_facet2label $facet)
3291 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
3292 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
3293 *) error "unknown facet!" ;;
3296 if ! do_rpc_nodes $list wait_import_state $expected $proc_path; then
3297 error "import is not in ${expected} state"
3306 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
3307 $LCTL get_param obdfilter.*.kbytesavail))
3308 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
3309 $LCTL get_param -n obdfilter.*.tot_granted))
3310 for ((i=0; i<${#AVAILA[@]}; i++)); do
3311 local -a AVAIL1=(${AVAILA[$i]//=/ })
3312 GRANT=$((${GRANTA[$i]}/1024))
3313 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} grnt=$GRANT diff=$((AVAIL1[1] - GRANT))
3314 [ $((AVAIL1[1] - GRANT)) -lt 400 ] && OSCFULL=0 && echo " FULL" || echo
3320 do_facet mgs lctl pool_list $1
3324 local fsname=${1%%.*}
3325 local poolname=${1##$fsname.}
3327 do_facet mgs lctl pool_new $1
3329 # get param should return err unless pool is created
3330 [[ $RC -ne 0 ]] && return $RC
3332 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3333 2>/dev/null || echo foo" "" || RC=1
3334 if [[ $RC -eq 0 ]]; then
3337 error "pool_new failed $1"
3342 add_pool_to_list () {
3343 local fsname=${1%%.*}
3344 local poolname=${1##$fsname.}
3346 local listvar=${fsname}_CREATED_POOLS
3347 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
3350 remove_pool_from_list () {
3351 local fsname=${1%%.*}
3352 local poolname=${1##$fsname.}
3354 local listvar=${fsname}_CREATED_POOLS
3355 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
3358 destroy_pool_int() {
3360 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
3361 awk '$1 !~ /^Pool:/ {print $1}')
3362 for ost in $OSTS; do
3363 do_facet mgs lctl pool_remove $1 $ost
3365 do_facet mgs lctl pool_destroy $1
3368 # <fsname>.<poolname> or <poolname>
3370 local fsname=${1%%.*}
3371 local poolname=${1##$fsname.}
3373 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
3377 pool_list $fsname.$poolname || return $?
3379 destroy_pool_int $fsname.$poolname
3381 [[ $RC -ne 0 ]] && return $RC
3383 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
3384 2>/dev/null || echo foo" "foo" || RC=1
3386 if [[ $RC -eq 0 ]]; then
3387 remove_pool_from_list $fsname.$poolname
3389 error "destroy pool failed $1"
3395 local fsname=${1:-$FSNAME}
3397 local listvar=${fsname}_CREATED_POOLS
3401 [ x${!listvar} = x ] && return 0
3403 echo destroy the created pools: ${!listvar}
3404 for poolname in ${!listvar//,/ }; do
3405 destroy_pool $fsname.$poolname
3410 local fsname=${1:-$FSNAME}
3412 destroy_pools $fsname
3418 local ts=$(date +%s)
3420 # bug 20237, comment 11
3421 # It would also be useful to provide the option
3422 # of writing the file to an NFS directory so it doesn't need to be copied.
3425 [ -f $LOGDIR/shared ] && docp=false
3427 # dump lustre logs, dmesg
3429 prefix="$LOGDIR/${TESTSUITE}.${TESTNAME}"
3431 echo "Dumping lctl log to ${prefix}.*.${suffix}"
3433 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
3434 echo "Dumping logs only on local client."
3435 $LCTL dk > ${prefix}.debug_log.$(hostname).${suffix}
3436 dmesg > ${prefix}.dmesg.$(hostname).${suffix}
3440 do_nodes --verbose $list \
3441 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname).${suffix};
3442 dmesg > ${prefix}.dmesg.\\\$(hostname).${suffix}"
3443 if [ ! -f $LOGDIR/shared ]; then
3444 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
3447 local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
3448 tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
3454 local list=${1:-$(comma_list $(nodes_list))}
3456 [ -n ${TESTSUITE} ] && do_nodes $list "rm -f $TMP/*${TESTSUITE}*" || true
3468 for i in $(seq 0 $num_mntpts); do
3469 cmd="ls -laf ${mntpt_root}$i/$dir"
3475 for pid in $pids; do
3482 get_clients_mount_count () {
3483 local clients=${CLIENTS:-`hostname`}
3485 # we need to take into account the clients mounts and
3486 # exclude mds/ost mounts if any;
3487 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
3491 PROC_CLI="srpc_info"
3499 if [ $M -lt $N ]; then
3503 while [ $N -le $M ]; do
3513 calc_connection_cnt() {
3516 # MDT->MDT = 2 * C(M, 2)
3520 comb_m2=$(combination $MDSCOUNT 2)
3522 local num_clients=$(get_clients_mount_count)
3524 local cnt_mdt2mdt=$((comb_m2 * 2))
3525 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
3526 local cnt_cli2ost=$((num_clients * OSTCOUNT))
3527 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
3528 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
3529 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
3530 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
3544 local cmd="$tgt.srpc.flavor"
3546 if [ $net == "any" ]; then
3551 if [ $dir != "any" ]; then
3556 log "Setting sptlrpc rule: $cmd"
3557 do_facet mgs "$LCTL conf_param $cmd"
3566 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
3567 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
3569 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
3571 if [ "x$bulkspec" != "x" ]; then
3572 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
3574 if [ "x$algs" != "x" ]; then
3575 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
3577 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
3578 if [ $bulk == "bulkn" ]; then
3579 bulk_count=`echo "$output" | grep "bulk flavor" \
3580 | grep "null/null" | wc -l`
3581 elif [ $bulk == "bulki" ]; then
3582 bulk_count=`echo "$output" | grep "bulk flavor" \
3583 | grep "/null" | grep -v "null/" | wc -l`
3585 bulk_count=`echo "$output" | grep "bulk flavor" \
3586 | grep -v "/null" | grep -v "null/" | wc -l`
3590 [ $bulk_count -lt $count ] && count=$bulk_count
3601 local clients=${CLIENTS:-`hostname`}
3603 for c in ${clients//,/ }; do
3604 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
3605 tmpcnt=`count_flvr "$output" $flavor`
3606 cnt=$((cnt + tmpcnt))
3616 local clients=${CLIENTS:-`hostname`}
3618 for c in ${clients//,/ }; do
3619 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
3620 tmpcnt=`count_flvr "$output" $flavor`
3621 cnt=$((cnt + tmpcnt))
3631 if [ $MDSCOUNT -le 1 ]; then
3636 for num in `seq $MDSCOUNT`; do
3637 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
3638 tmpcnt=`count_flvr "$output" $flavor`
3639 cnt=$((cnt + tmpcnt))
3649 for num in `seq $MDSCOUNT`; do
3650 output=`do_facet mds$num lctl get_param -n osc.*OST*-osc-MDT*.$PROC_CLI 2>/dev/null`
3651 tmpcnt=`count_flvr "$output" $flavor`
3652 cnt=$((cnt + tmpcnt))
3661 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
3662 count_flvr "$output" $flavor
3667 local dir=$1 # from to
3668 local flavor=$2 # flavor expected
3671 if [ $dir == "cli2mdt" ]; then
3672 res=`flvr_cnt_cli2mdt $flavor`
3673 elif [ $dir == "cli2ost" ]; then
3674 res=`flvr_cnt_cli2ost $flavor`
3675 elif [ $dir == "mdt2mdt" ]; then
3676 res=`flvr_cnt_mdt2mdt $flavor`
3677 elif [ $dir == "mdt2ost" ]; then
3678 res=`flvr_cnt_mdt2ost $flavor`
3679 elif [ $dir == "all2ost" ]; then
3680 res1=`flvr_cnt_mdt2ost $flavor`
3681 res2=`flvr_cnt_cli2ost $flavor`
3682 res=$((res1 + res2))
3683 elif [ $dir == "all2mdt" ]; then
3684 res1=`flvr_cnt_mdt2mdt $flavor`
3685 res2=`flvr_cnt_cli2mdt $flavor`
3686 res=$((res1 + res2))
3687 elif [ $dir == "all2all" ]; then
3688 res1=`flvr_cnt_mdt2ost $flavor`
3689 res2=`flvr_cnt_cli2ost $flavor`
3690 res3=`flvr_cnt_mdt2mdt $flavor`
3691 res4=`flvr_cnt_cli2mdt $flavor`
3692 res=$((res1 + res2 + res3 + res4))
3700 local dir=$1 # from to
3701 local flavor=$2 # flavor expected
3702 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
3706 for ((i=0;i<20;i++)); do
3707 echo -n "checking..."
3708 res=$(do_check_flavor $dir $flavor)
3709 if [ $res -eq $expect ]; then
3710 echo "found $res $flavor connections of $dir, OK"
3713 echo "found $res $flavor connections of $dir, not ready ($expect)"
3718 echo "Error checking $flavor of $dir: expect $expect, actual $res"
3722 restore_to_default_flavor()
3724 local proc="mgs.MGS.live.$FSNAME"
3726 echo "restoring to default flavor..."
3728 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3730 # remove all existing rules if any
3731 if [ $nrule -ne 0 ]; then
3732 echo "$nrule existing rules"
3733 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
3734 echo "remove rule: $rule"
3735 spec=`echo $rule | awk -F = '{print $1}'`
3736 do_facet mgs "$LCTL conf_param $spec="
3740 # verify no rules left
3741 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
3742 [ $nrule -ne 0 ] && error "still $nrule rules left"
3744 # wait for default flavor to be applied
3745 # currently default flavor for all connections are 'null'
3746 wait_flavor all2all null
3747 echo "now at default flavor settings"
3752 local flavor=${1:-null}
3754 echo "setting all flavor to $flavor"
3756 # FIXME need parameter to this fn
3757 # and remove global vars
3758 local cnt_all2all=$(calc_connection_cnt all2all)
3760 local res=$(do_check_flavor all2all $flavor)
3761 if [ $res -eq $cnt_all2all ]; then
3762 echo "already have total $res $flavor connections"
3766 echo "found $res $flavor out of total $cnt_all2all connections"
3767 restore_to_default_flavor
3769 [[ $flavor = null ]] && return 0
3771 set_rule $FSNAME any any $flavor
3772 wait_flavor all2all $flavor
3778 # Checking for shared logdir
3779 if [ ! -d $dir ]; then
3780 # Not found. Create local logdir
3783 touch $dir/node.$(hostname).yml
3788 check_write_access() {
3790 for node in $(nodes_list); do
3791 if [ ! -f "$dir/node.${node}.yml" ]; then
3792 # Logdir not accessible/writable from this node.
3800 if [[ -n $YAML_LOG ]]; then
3803 export YAML_LOG=${LOGDIR}/results.yml
3807 do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
3808 if check_write_access $LOGDIR; then
3809 touch $LOGDIR/shared
3810 echo "Logging to shared log directory: $LOGDIR"
3812 echo "Logging to local directory: $LOGDIR"
3815 yml_nodes_file $LOGDIR
3816 yml_results_file >> $YAML_LOG
3820 yml_log_test $1 >> $YAML_LOG
3824 yml_log_sub_test $@ >> $YAML_LOG