3 trap 'print_summary && touch $TF_FAIL && \
4 echo "test-framework exiting on error"' ERR
9 export EJOURNAL=${EJOURNAL:-""}
10 export REFORMAT=${REFORMAT:-""}
11 export WRITECONF=${WRITECONF:-""}
12 export VERBOSE=${VERBOSE:-false}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
18 # specify environment variable containing batch job name for server statistics
19 export JOBID_VAR=${JOBID_VAR:-"procname_uid"} # or "existing" or "disable"
21 # LOAD_LLOOP: LU-409: only load llite_lloop module if kernel < 2.6.32 or
22 # LOAD_LLOOP is true. LOAD_LLOOP is false by default.
23 export LOAD_LLOOP=${LOAD_LLOOP:-false}
25 #export PDSH="pdsh -S -Rssh -w"
26 export MOUNT_CMD=${MOUNT_CMD:-"mount -t lustre"}
28 # function used by scripts run on remote nodes
29 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
30 . $LUSTRE/tests/functions.sh
31 . $LUSTRE/tests/yaml.sh
33 export LD_LIBRARY_PATH=${LUSTRE}/utils:${LD_LIBRARY_PATH}
35 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
37 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
39 if [ -f "$EXCEPT_LIST_FILE" ]; then
40 echo "Reading test skip list from $EXCEPT_LIST_FILE"
45 # check config files for options in decreasing order of preference
46 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/lustre.conf ] &&
47 MODPROBECONF=/etc/modprobe.d/lustre.conf
48 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] &&
49 MODPROBECONF=/etc/modprobe.d/Lustre
50 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] &&
51 MODPROBECONF=/etc/modprobe.conf
55 [[ $DIR/ = $MOUNT/* ]] || \
56 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
57 [[ $DIR1/ = $MOUNT1/* ]] || \
58 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
59 [[ $DIR2/ = $MOUNT2/* ]] || \
60 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
62 [ -n "$failed" ] && exit 99 || true
66 echo "usage: $0 [-r] [-f cfgfile]"
74 [ "$TESTSUITE" == "lfsck" ] && return 0
75 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
77 local form="%-13s %-17s %-9s %s %s\n"
78 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
79 echo "------------------------------------------------------------------------------------"
80 for O in $DEFAULT_SUITES; do
81 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
82 [ "${!O}" = "no" ] && continue || true
83 local o=$(echo $O | tr "[:upper:]_" "[:lower:]-")
84 local log=${TMP}/${o}.log
85 if is_sanity_benchmark $o; then
86 log=${TMP}/sanity-benchmark.log
91 local status=Unfinished
93 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' |
95 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g |
96 sort -nr -k 3 | head -n5 | awk '{ print $2":"$3"s" }')
97 total=$(grep duration $log | awk '{ print $2 }')
98 if [ "${!O}" = "done" ]; then
102 local durations=$(egrep "^PASS|^FAIL" $log |
103 tr -d "("| sed s/s\)$//g |
104 awk '{ print $2":"$3"|" }')
105 details=$(printf "%s\n%s %s %s\n" "$details" \
106 "DDETAILS" "$O" "$(echo $durations)")
109 printf "$form" $status "$O" "${total}" "E=$skipped"
110 printf "$form" "-" "-" "-" "S=$(echo $slow)"
113 for O in $DEFAULT_SUITES; do
114 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
115 if [ "${!O}" = "no" ]; then
116 printf "$form" "Skipped" "$O" ""
120 # print the detailed tests durations if DDETAILS=true
127 export LUSTRE=$(absolute_path $LUSTRE)
128 export TESTSUITE=$(basename $0 .sh)
129 export TEST_FAILED=false
130 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
131 export RPC_MODE=${RPC_MODE:-false}
133 export MKE2FS=$MKE2FS
134 if [ -z "$MKE2FS" ]; then
135 if which mkfs.ldiskfs >/dev/null 2>&1; then
136 export MKE2FS=mkfs.ldiskfs
142 export DEBUGFS=$DEBUGFS
143 if [ -z "$DEBUGFS" ]; then
144 if which debugfs.ldiskfs >/dev/null 2>&1; then
145 export DEBUGFS=debugfs.ldiskfs
147 export DEBUGFS=debugfs
151 export TUNE2FS=$TUNE2FS
152 if [ -z "$TUNE2FS" ]; then
153 if which tunefs.ldiskfs >/dev/null 2>&1; then
154 export TUNE2FS=tunefs.ldiskfs
156 export TUNE2FS=tune2fs
160 export E2LABEL=$E2LABEL
161 if [ -z "$E2LABEL" ]; then
162 if which label.ldiskfs >/dev/null 2>&1; then
163 export E2LABEL=label.ldiskfs
165 export E2LABEL=e2label
169 export DUMPE2FS=$DUMPE2FS
170 if [ -z "$DUMPE2FS" ]; then
171 if which dumpfs.ldiskfs >/dev/null 2>&1; then
172 export DUMPE2FS=dumpfs.ldiskfs
174 export DUMPE2FS=dumpe2fs
178 export E2FSCK=$E2FSCK
179 if [ -z "$E2FSCK" ]; then
180 if which fsck.ldiskfs >/dev/null 2>&1; then
181 export E2FSCK=fsck.ldiskfs
187 export RESIZE2FS=$RESIZE2FS
188 if [ -z "$RESIZE2FS" ]; then
189 if which resizefs.ldiskfs >/dev/null 2>&1; then
190 export RESIZE2FS=resizefs.ldiskfs
192 export RESIZE2FS=resize2fs
196 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
197 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
198 export FSCK_MAX_ERR=4 # File system errors left uncorrected
200 export ZFS=${ZFS:-zfs}
201 export ZPOOL=${ZPOOL:-zpool}
202 export ZDB=${ZDB:-zdb}
203 export PARTPROBE=${PARTPROBE:-partprobe}
205 #[ -d /r ] && export ROOT=${ROOT:-/r}
206 export TMP=${TMP:-$ROOT/tmp}
207 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
208 export LOGDIR=${LOGDIR:-${TMP}/test_logs/$(date +%s)}
209 export TESTLOG_PREFIX=$LOGDIR/$TESTSUITE
211 export HOSTNAME=${HOSTNAME:-$(hostname -s)}
212 if ! echo $PATH | grep -q $LUSTRE/utils; then
213 export PATH=$LUSTRE/utils:$PATH
215 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
216 export PATH=$LUSTRE/utils/gss:$PATH
218 if ! echo $PATH | grep -q $LUSTRE/tests; then
219 export PATH=$LUSTRE/tests:$PATH
221 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
222 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
224 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
225 [ ! -f "$LST" ] && export LST=$(which lst)
226 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
227 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
228 export MCREATE=${MCREATE:-mcreate}
229 # Ubuntu, at least, has a truncate command in /usr/bin
230 # so fully path our truncate command.
231 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
232 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
233 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
234 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
235 export PATH=$LUSTRE/tests/racer:$PATH:
237 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
238 export PATH=$LUSTRE/tests/mpi:$PATH
240 export RSYNC_RSH=${RSYNC_RSH:-rsh}
242 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
243 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
244 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
245 [ ! -f "$LFS" ] && export LFS=$(which lfs)
246 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
247 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
249 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
250 if [ ! -f "$L_GETIDENTITY" ]; then
251 if `which l_getidentity > /dev/null 2>&1`; then
252 export L_GETIDENTITY=$(which l_getidentity)
254 export L_GETIDENTITY=NONE
257 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
258 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID="ll_decode_filter_fid"
259 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
260 [ ! -f "$MKFS" ] && export MKFS="mkfs.lustre"
261 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
262 [ ! -f "$TUNEFS" ] && export TUNEFS="tunefs.lustre"
263 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
264 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
265 [ ! -f "$LUSTRE_RMMOD" ] &&
266 export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
267 export LFS_MIGRATE=${LFS_MIGRATE:-$LUSTRE/scripts/lfs_migrate}
268 [ ! -f "$LFS_MIGRATE" ] &&
269 export LFS_MIGRATE=$(which lfs_migrate 2> /dev/null)
270 export NAME=${NAME:-local}
271 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
272 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
273 export LGSSD=$(which lgssd)
274 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
275 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
276 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
278 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
281 if [ "$ACCEPTOR_PORT" ]; then
282 export PORT_OPT="--port $ACCEPTOR_PORT"
287 echo "Using GSS/krb5 ptlrpc security flavor"
288 which lgss_keyring > /dev/null 2>&1 || \
289 error_exit "built with gss disabled! SEC=$SEC"
300 IDENTITY_UPCALL=false
304 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
306 # Paths on remote nodes, if different
307 export RLUSTRE=${RLUSTRE:-$LUSTRE}
308 export RPWD=${RPWD:-$PWD}
309 export I_MOUNTED=${I_MOUNTED:-"no"}
310 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mdt.ko -a \
311 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mdt.ko -a \
312 ! -f /lib/modules/$(uname -r)/extra/kernel/fs/lustre/mdt.ko -a \
313 ! -f $LUSTRE/mdt/mdt.ko ]; then
314 export CLIENTMODSONLY=yes
317 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
318 export OSD_TRACK_DECLARES_LBUG=${OSD_TRACK_DECLARES_LBUG:-"yes"}
322 while getopts "rvwf:" opt $*; do
325 r) REFORMAT=--reformat;;
327 w) WRITECONF=writeconf;;
332 shift $((OPTIND - 1))
335 # print the durations of each test if "true"
336 DDETAILS=${DDETAILS:-false}
337 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
347 ncpts=$(do_facet $facet "lctl get_param -n " \
348 "cpu_partition_table 2>/dev/null| wc -l" || echo 1)
350 if [ $ncpts -eq 0 ]; then
358 # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
359 eval set -- $(tr "[:punct:]" " " <<< $*)
361 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
364 export LINUX_VERSION=$(uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
365 export LINUX_VERSION_CODE=$(version_code ${LINUX_VERSION//\./ })
368 /sbin/lsmod | grep -q "^\<$1\>"
371 # Load a module on the system where this is running.
373 # usage: load_module module_name [module arguments for insmod/modprobe]
375 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
376 # will be used as the arguments. Otherwise arguments will be obtained from
377 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
384 BASE=`basename $module $EXT`
386 module_loaded ${BASE} && return
388 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
390 if [ $# -eq 0 ]; then
391 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
392 # Bash until 4.x, so we resort to eval.
393 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
394 eval set -- \$$optvar
395 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
396 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
398 opt=$(awk -v var="^options $BASE" '$0 ~ var \
399 {gsub("'"options $BASE"'",""); print}' $MODPROBECONF)
400 set -- $(echo -n $opt)
402 # Ensure we have accept=all for lnet
403 if [ $(basename $module) = lnet ]; then
404 # OK, this is a bit wordy...
405 local arg accept_all_present=false
408 [ "$arg" = accept=all ] && \
409 accept_all_present=true
411 $accept_all_present || set -- "$@" accept=all
417 [ $# -gt 0 ] && echo "${module} options: '$*'"
419 # Note that insmod will ignore anything in modprobe.conf, which is why
420 # we're passing options on the command-line.
421 if [[ "$BASE" == "lnet_selftest" ]] &&
422 [[ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]]; then
423 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
424 elif [[ -f ${LUSTRE}/${module}${EXT} ]]; then
425 [[ "$BASE" != "ptlrpc_gss" ]] || modprobe sunrpc
426 insmod ${LUSTRE}/${module}${EXT} "$@"
428 # must be testing a "make install" or "rpm" installation
429 # note failed to load ptlrpc_gss is considered not fatal
430 if [[ "$BASE" == "ptlrpc_gss" ]]; then
431 modprobe $BASE "$@" 2>/dev/null ||
432 echo "gss/krb5 is not supported"
439 llite_lloop_enabled() {
440 local n1=$(uname -r | cut -d. -f1)
441 local n2=$(uname -r | cut -d. -f2)
442 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
444 # load the llite_lloop module for < 2.6.32 kernels
445 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
446 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
453 load_modules_local() {
454 if [ -n "$MODPROBE" ]; then
456 echo "Using modprobe to load modules"
460 echo Loading modules from $LUSTRE
464 if [ -f /sys/devices/system/cpu/online ]; then
465 ncpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/online) + 1))
466 echo "detected $ncpus online CPUs by sysfs"
468 ncpus=$(getconf _NPROCESSORS_CONF 2>/dev/null)
470 if [ $rc -eq 0 ]; then
471 echo "detected $ncpus online CPUs by getconf"
473 echo "Can't detect number of CPUs"
478 # if there is only one CPU core, libcfs can only create one partition
479 # if there is more than 4 CPU cores, libcfs should create multiple CPU
480 # partitions. So we just force libcfs to create 2 partitions for
481 # system with 2 or 4 cores
482 if [ $ncpus -le 4 ] && [ $ncpus -gt 1 ]; then
483 # force to enable multiple CPU partitions
484 echo "Force libcfs to create 2 CPU partitions"
485 MODOPTS_LIBCFS="cpu_npartitions=2 $MODOPTS_LIBCFS"
487 echo "libcfs will create CPU partition based on online CPUs"
490 load_module ../libcfs/libcfs/libcfs
492 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
493 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
494 load_module ../lnet/lnet/lnet
495 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
496 load_module ../lnet/klnds/$LNETLND
497 load_module obdclass/obdclass
498 load_module ptlrpc/ptlrpc
499 load_module ptlrpc/gss/ptlrpc_gss
507 load_module obdecho/obdecho
508 if ! client_only; then
509 SYMLIST=/proc/kallsyms
510 grep -q crc16 $SYMLIST || { modprobe crc16 2>/dev/null || true; }
511 grep -q -w jbd $SYMLIST || { modprobe jbd 2>/dev/null || true; }
512 grep -q -w jbd2 $SYMLIST || { modprobe jbd2 2>/dev/null || true; }
513 load_module lfsck/lfsck
514 [ "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
515 if [[ $(node_fstypes $HOSTNAME) == *zfs* ]]; then
517 load_module osd-zfs/osd_zfs
519 if [[ $(node_fstypes $HOSTNAME) == *ldiskfs* ]]; then
520 grep -q exportfs_decode_fh $SYMLIST ||
521 { modprobe exportfs 2> /dev/null || true; }
522 load_module ../ldiskfs/ldiskfs
523 load_module osd-ldiskfs/osd_ldiskfs
535 load_module llite/lustre
536 llite_lloop_enabled && load_module llite/llite_lloop
537 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
539 rm -f $OGDB/ogdb-$HOSTNAME
540 $LCTL modules > $OGDB/ogdb-$HOSTNAME
542 # 'mount' doesn't look in $PATH, just sbin
543 local mount_lustre=$LUSTRE/utils/mount.lustre
544 if [ -f $mount_lustre ]; then
545 local sbin_mount=/sbin/mount.lustre
546 if grep -qw "$sbin_mount" /proc/mounts; then
547 cmp -s $mount_lustre $sbin_mount || umount $sbin_mount
549 if ! grep -qw "$sbin_mount" /proc/mounts; then
550 [ ! -f "$sbin_mount" ] && touch "$sbin_mount"
551 if [ ! -s "$sbin_mount" -a -w "$sbin_mount" ]; then
552 cat <<- EOF > "$sbin_mount"
555 echo "This $sbin_mount just a mountpoint." 1>&2
556 echo "It is never supposed to be run." 1>&2
557 logger -p emerg -- "using stub $sbin_mount $@"
560 chmod a+x $sbin_mount
562 mount --bind $mount_lustre $sbin_mount ||
563 error "can't bind $mount_lustre to $sbin_mount"
571 # load modules on remote nodes optionally
572 # lustre-tests have to be installed on these nodes
573 if $LOAD_MODULES_REMOTE; then
574 local list=$(comma_list $(remote_nodes_list))
575 if [ -n "$list" ]; then
576 echo "loading modules on: '$list'"
577 do_rpc_nodes "$list" load_modules_local
583 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
584 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
585 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
586 echo "$LEAK_LUSTRE" 1>&2
587 echo "$LEAK_PORTALS" 1>&2
588 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
589 echo "Memory leaks detected"
590 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
596 wait_exit_ST client # bug 12845
598 $LUSTRE_RMMOD ldiskfs || return 2
600 if $LOAD_MODULES_REMOTE; then
601 local list=$(comma_list $(remote_nodes_list))
602 if [ -n "$list" ]; then
603 echo "unloading modules on: '$list'"
604 do_rpc_nodes "$list" $LUSTRE_RMMOD ldiskfs
605 do_rpc_nodes "$list" check_mem_leak
609 local sbin_mount=/sbin/mount.lustre
610 if grep -qe "$sbin_mount " /proc/mounts; then
611 umount $sbin_mount || true
612 [ -s $sbin_mount ] && ! grep -q "STUB MARK" $sbin_mount ||
616 check_mem_leak || return 254
618 echo "modules unloaded."
623 local facet=${1:-$SINGLEMDS}
624 local fstype=$(facet_fstype $facet)
627 ldiskfs) size=50;; # largest seen is 44, leave some headroom
628 zfs) size=400;; # largest seen is 384
634 check_gss_daemon_nodes() {
638 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
639 if [ \\\"\\\$num\\\" -ne 1 ]; then
640 echo \\\$num instance of $dname;
645 check_gss_daemon_facet() {
649 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
650 if [ $num -ne 1 ]; then
651 echo "$num instance of $dname on $facet"
660 echo Stopping $@ on $list
661 do_nodes $list "killall -2 $@ 2>/dev/null || true"
664 # start gss daemons on all nodes, or
665 # "daemon" on "list" if set
666 start_gss_daemons() {
670 if [ "$list" ] && [ "$daemon" ] ; then
671 echo "Starting gss daemon on nodes: $list"
672 do_nodes $list "$daemon" || return 8
676 local list=$(comma_list $(mdts_nodes))
677 echo "Starting gss daemon on mds: $list"
678 do_nodes $list "$LSVCGSSD -v" || return 1
680 do_nodes $list "$LGSSD -v" || return 2
683 list=$(comma_list $(osts_nodes))
684 echo "Starting gss daemon on ost: $list"
685 do_nodes $list "$LSVCGSSD -v" || return 3
686 # starting on clients
688 local clients=${CLIENTS:-`hostname`}
690 echo "Starting $LGSSD on clients $clients "
691 do_nodes $clients "$LGSSD -v" || return 4
694 # wait daemons entering "stable" status
698 # check daemons are running
700 list=$(comma_list $(mdts_nodes) $(osts_nodes))
701 check_gss_daemon_nodes $list lsvcgssd || return 5
703 list=$(comma_list $(mdts_nodes))
704 check_gss_daemon_nodes $list lgssd || return 6
707 check_gss_daemon_nodes $clients lgssd || return 7
712 local list=$(comma_list $(mdts_nodes))
714 send_sigint $list lsvcgssd lgssd
716 list=$(comma_list $(osts_nodes))
717 send_sigint $list lsvcgssd
719 list=${CLIENTS:-`hostname`}
720 send_sigint $list lgssd
725 if ! module_loaded ptlrpc_gss; then
726 load_module ptlrpc/gss/ptlrpc_gss
727 module_loaded ptlrpc_gss ||
728 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
731 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
734 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
736 sptlrpc.gss.lgss_keyring.debug_level=$LGSS_KEYRING_DEBUG
744 # maybe cleanup credential cache?
750 local var=${facet}_svc
758 echo -n $facet | sed -e 's/^fs[0-9]\+//' -e 's/[0-9_]\+//' |
759 tr '[:lower:]' '[:upper:]'
765 if [ $facet == mgs ]; then
769 echo -n $facet | sed -e 's/^fs[0-9]\+//' | sed -e 's/^[a-z]\+//'
777 if [ -n "${!var}" ]; then
782 var=$(facet_type $facet)FSTYPE
783 if [ -n "${!var}" ]; then
788 if [ -n "$FSTYPE" ]; then
793 if [[ $facet == mgs ]] && combined_mgs_mds; then
805 local facets=$(get_facets)
808 for facet in ${facets//,/ }; do
809 if [ $node == $(facet_host $facet) ] ||
810 [ $node == "$(facet_failover_host $facet)" ]; then
811 fstype=$(facet_fstype $facet)
812 if [[ $fstypes != *$fstype* ]]; then
813 fstypes+="${fstypes:+,}$fstype"
822 local num=$(facet_number $facet)
825 if [[ $(facet_type $facet) = OST ]]; then
827 if [[ -n "${!index}" ]]; then
832 index=${OST_INDICES[num - 1]}
835 [[ -n "$index" ]] || index=$((num - 1))
843 local fstype=$(facet_fstype $facet)
847 label=$(do_facet ${facet} "$E2LABEL ${dev} 2>/dev/null");;
849 label=$(do_facet ${facet} "$ZFS get -H -o value lustre:svname \
850 ${dev} 2>/dev/null");;
852 error "unknown fstype!";;
860 local device=$(mdsdevname $num)
861 local label=$(devicelabel mds$num ${device} | grep -v "CMD: ")
867 local device=$(ostdevname $num)
868 local label=$(devicelabel ost$num ${device} | grep -v "CMD: ")
873 # Get the device of a facet.
880 mgs) device=$(mgsdevname) ;;
881 mds*) device=$(mdsdevname $(facet_number $facet)) ;;
882 ost*) device=$(ostdevname $(facet_number $facet)) ;;
883 fs2mds) device=$(mdsdevname 1_2) ;;
884 fs2ost) device=$(ostdevname 1_2) ;;
885 fs3ost) device=$(ostdevname 2_2) ;;
893 # Get the virtual device of a facet.
900 mgs) device=$(mgsvdevname) ;;
901 mds*) device=$(mdsvdevname $(facet_number $facet)) ;;
902 ost*) device=$(ostvdevname $(facet_number $facet)) ;;
903 fs2mds) device=$(mdsvdevname 1_2) ;;
904 fs2ost) device=$(ostvdevname 1_2) ;;
905 fs3ost) device=$(ostvdevname 2_2) ;;
913 # Re-read the partition table on failover partner host.
914 # After a ZFS storage pool is created on a shared device, the partition table
915 # on the device may change. However, the operating system on the failover
916 # host may not notice the change automatically. Without the up-to-date partition
917 # block devices, 'zpool import ..' cannot find the labels, whose positions are
918 # relative to partition rather than disk beginnings.
920 # This function performs partprobe on the failover host to make it re-read the
923 refresh_partition_table() {
928 host=$(facet_passive_host $facet)
929 if [[ -n "$host" ]]; then
930 do_node $host "$PARTPROBE $device"
935 # Get ZFS storage pool name.
942 device=$(facet_device $facet)
943 # poolname is string before "/"
944 poolname="${device%%/*}"
950 # Create ZFS storage pool.
957 local opts=${@:-"-o cachefile=none"}
959 do_facet $facet "$ZPOOL list -H $poolname >/dev/null 2>&1 ||
960 $ZPOOL create -f $opts $poolname $vdev"
964 # Create ZFS file system.
970 local opts=${@:-"-o mountpoint=legacy"}
972 do_facet $facet "$ZFS list -H $dataset >/dev/null 2>&1 ||
973 $ZFS create $opts $dataset"
977 # Export ZFS storage pool.
978 # Before exporting the pool, all datasets within the pool should be unmounted.
986 poolname=$(zpool_name $facet)
988 if [[ -n "$poolname" ]]; then
989 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
990 grep -q ^$poolname/ /proc/mounts ||
991 $ZPOOL export $opts $poolname"
996 # Destroy ZFS storage pool.
997 # Destroy the given pool and free up any devices for other use. This command
998 # tries to unmount any active datasets before destroying the pool.
999 # -f Force any active datasets contained within the pool to be unmounted.
1003 local poolname=${2:-$(zpool_name $facet)}
1005 if [[ -n "$poolname" ]]; then
1006 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1007 $ZPOOL destroy -f $poolname"
1012 # Import ZFS storage pool.
1013 # Force importing, even if the pool appears to be potentially active.
1018 local opts=${@:-"-o cachefile=none"}
1021 poolname=$(zpool_name $facet)
1023 if [[ -n "$poolname" ]]; then
1024 opts+=" -d $(dirname $(facet_vdevice $facet))"
1025 do_facet $facet "$ZPOOL list -H $poolname >/dev/null 2>&1 ||
1026 $ZPOOL import -f $opts $poolname"
1031 # Set the "cachefile=none" property on ZFS storage pool so that the pool
1032 # is not automatically imported on system startup.
1034 # In a failover environment, this will provide resource level fencing which
1035 # will ensure that the same ZFS storage pool will not be imported concurrently
1036 # on different nodes.
1038 disable_zpool_cache() {
1042 poolname=$(zpool_name $facet)
1044 if [[ -n "$poolname" ]]; then
1045 do_facet $facet "$ZPOOL set cachefile=none $poolname"
1050 # This and set_osd_param() shall be used to access OSD parameters
1051 # once existed under "obdfilter":
1056 # writethrough_cache_enable
1060 local device=${2:-$FSNAME-OST*}
1063 do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
1064 osd-*.$device.$name 2>&1" | grep -v 'Found no match'
1069 local device=${2:-$FSNAME-OST*}
1073 do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
1074 osd-*.$device.$name=$value 2>&1" | grep -v 'Found no match'
1078 local dz=${1:-$DEBUG_SIZE}
1080 if [ -f /sys/devices/system/cpu/possible ]; then
1081 local cpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/possible)+1))
1083 local cpus=$(getconf _NPROCESSORS_CONF)
1086 # bug 19944, adjust size to be -gt num_possible_cpus()
1087 # promise 2MB for every cpu at least
1088 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
1091 lctl set_param debug_mb=$dz
1094 set_default_debug () {
1095 local debug=${1:-"$PTLDEBUG"}
1096 local subsys=${2:-"$SUBSYSTEM"}
1097 local debug_size=${3:-$DEBUG_SIZE}
1099 [ -n "$debug" ] && lctl set_param debug="$debug" >/dev/null
1100 [ -n "$subsys" ] && lctl set_param subsystem_debug="${subsys# }" >/dev/null
1102 [ -n "$debug_size" ] && set_debug_size $debug_size > /dev/null
1105 set_default_debug_nodes () {
1108 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
1109 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
1113 do_rpc_nodes "$nodes" set_default_debug \
1114 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
1117 set_default_debug_facet () {
1119 local node=$(facet_active_host $facet)
1120 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
1122 set_default_debug_nodes $node
1127 local facets=${1:-$(get_facets)}
1130 for facet in ${facets//,/ }; do
1133 [ $RC -eq 0 ] && continue
1135 if [ "$TESTSUITE.$TESTNAME" = "replay-dual.test_0a" ]; then
1136 skip "Restart of $facet failed!." && touch $LU482_FAILED
1138 error "Restart of $facet failed!"
1145 # Add argument "arg" (e.g., "loop") to the comma-separated list
1146 # of arguments for option "opt" (e.g., "-o") on command
1147 # line "opts" (e.g., "-o flock").
1153 local opt_pattern="\([[:space:]]\+\|^\)$opt"
1155 if echo "$opts" | grep -q $opt_pattern; then
1156 opts=$(echo "$opts" | sed -e \
1157 "s/$opt_pattern[[:space:]]*[^[:space:]]\+/&,$arg/")
1159 opts+="${opts:+ }$opt $arg"
1167 local dev=$(facet_active $facet)_dev
1168 local opt=${facet}_opt
1169 local mntpt=$(facet_mntpt $facet)
1170 local opts="${!opt} $@"
1172 if [ $(facet_fstype $facet) == ldiskfs ] &&
1173 ! do_facet $facet test -b ${!dev}; then
1174 opts=$(csa_add "$opts" -o loop)
1177 if [[ $(facet_fstype $facet) == zfs ]]; then
1178 # import ZFS storage pool
1179 import_zpool $facet || return ${PIPESTATUS[0]}
1182 echo "Starting ${facet}: $opts ${!dev} $mntpt"
1183 # for testing LU-482 error handling in mount_facets() and test_0a()
1184 if [ -f $TMP/test-lu482-trigger ]; then
1187 do_facet ${facet} "mkdir -p $mntpt; $MOUNT_CMD $opts \
1191 if [ $RC -ne 0 ]; then
1192 echo "Start of ${!dev} on ${facet} failed ${RC}"
1194 set_default_debug_facet $facet
1196 if [[ $facet == mds* ]]; then
1198 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1202 label=$(devicelabel ${facet} ${!dev})
1203 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1204 eval export ${facet}_svc=${label}
1205 echo Started ${label}
1210 # start facet device options
1216 eval export ${facet}_dev=${device}
1217 eval export ${facet}_opt=\"$@\"
1219 local varname=${facet}failover_dev
1220 if [ -n "${!varname}" ] ; then
1221 eval export ${facet}failover_dev=${!varname}
1223 eval export ${facet}failover_dev=$device
1226 local mntpt=$(facet_mntpt $facet)
1227 do_facet ${facet} mkdir -p $mntpt
1228 eval export ${facet}_MOUNT=$mntpt
1229 mount_facet ${facet}
1232 if [[ $facet == mds* ]]; then
1234 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1245 local HOST=`facet_active_host $facet`
1246 [ -z $HOST ] && echo stop: no host for $facet && return 0
1248 local mntpt=$(facet_mntpt $facet)
1249 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
1250 if [ ${running} -ne 0 ]; then
1251 echo "Stopping $mntpt (opts:$@) on $HOST"
1252 do_facet ${facet} umount -d $@ $mntpt
1255 # umount should block, but we should wait for unrelated obd's
1256 # like the MGS or MGC to also stop.
1257 wait_exit_ST ${facet} || return ${PIPESTATUS[0]}
1259 if [[ $(facet_fstype $facet) == zfs ]]; then
1260 # export ZFS storage pool
1265 # save quota version (both administrative and operational quotas)
1266 # add an additional parameter if mountpoint is ever different from $MOUNT
1268 # XXX This function is kept for interoperability with old server (< 2.3.50),
1269 # it should be removed whenever we drop the interoperability for such
1271 quota_save_version() {
1272 local fsname=${2:-$FSNAME}
1274 local ver=$(tr -c -d "123" <<< $spec)
1275 local type=$(tr -c -d "ug" <<< $spec)
1277 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
1279 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
1281 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
1283 local osts=$(get_facets OST)
1284 for ost in ${osts//,/ }; do
1286 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
1290 # client could mount several lustre
1292 # XXX This function is kept for interoperability with old server (< 2.3.50),
1293 # it should be removed whenever we drop the interoperability for such
1296 local fsname=${1:-$FSNAME}
1298 do_facet $SINGLEMDS lctl get_param mdd.${fsname}-MDT*.quota_type ||
1300 do_nodes $(comma_list $(osts_nodes)) \
1301 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
1305 # XXX This function is kept for interoperability with old server (< 2.3.50),
1306 # it should be removed whenever we drop the interoperability for such
1308 restore_quota_old() {
1309 local mntpt=${1:-$MOUNT}
1310 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
1311 if [ ! "$old_QUOTA_TYPE" ] ||
1312 [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
1315 quota_save_version $old_QUOTA_TYPE
1318 # XXX This function is kept for interoperability with old server (< 2.3.50),
1319 # it should be removed whenever we drop the interoperability for such
1324 # no quota enforcement for now and accounting works out of the box
1327 # We need save the original quota_type params, and restore them after testing
1329 # Suppose that quota type the same on mds and ost
1330 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
1331 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
1332 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
1333 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
1334 export old_QUOTA_TYPE=$quota_type
1335 quota_save_version $QUOTA_TYPE
1337 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
1338 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
1341 local quota_usrs=$QUOTA_USERS
1343 # get_filesystem_size
1344 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1345 local blk_soft=$((disksz + 1024))
1346 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1348 local Inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1349 local i_soft=$Inodes
1350 local i_hard=$((i_soft + i_soft / 20))
1352 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
1353 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
1356 for usr in $quota_usrs; do
1357 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1359 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1361 eval $cmd || error "$cmd FAILED!"
1363 # display the quota status
1364 echo "Quota settings for $usr : "
1365 $LFS quota -v -u $usr $mntpt || true
1369 # get mdt quota type
1371 local varsvc=${SINGLEMDS}_svc
1372 do_facet $SINGLEMDS $LCTL get_param -n \
1373 osd-$(facet_fstype $SINGLEMDS).${!varsvc}.quota_slave.enabled
1376 # get ost quota type
1378 # All OSTs should have same quota type
1379 local varsvc=ost1_svc
1380 do_facet ost1 $LCTL get_param -n \
1381 osd-$(facet_fstype ost1).${!varsvc}.quota_slave.enabled
1384 # restore old quota type settings
1386 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1391 if [ "$old_MDT_QUOTA_TYPE" ]; then
1392 do_facet mgs $LCTL conf_param \
1393 $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
1395 if [ "$old_OST_QUOTA_TYPE" ]; then
1396 do_facet mgs $LCTL conf_param \
1397 $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
1401 # Handle the case when there is a space in the lfs df
1402 # "filesystem summary" line the same as when there is no space.
1403 # This will allow fixing the "lfs df" summary line in the future.
1405 $LFS df $* | sed -e 's/filesystem /filesystem_/'
1408 # Get free inodes on the MDT specified by mdt index, free indoes on
1409 # the whole filesystem will be returned when index == -1.
1415 if [ $index -eq -1 ]; then
1418 mdt_uuid=$(mdtuuid_from_index $index)
1421 free_inodes=$(lfs_df -i $MOUNT | grep $mdt_uuid | awk '{print $4}')
1426 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1433 # save old quota type & set new quota type
1434 local mdt_qtype=$(mdt_quota_type)
1435 local ost_qtype=$(ost_quota_type)
1437 echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
1438 "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
1440 export old_MDT_QUOTA_TYPE=$mdt_qtype
1441 export old_OST_QUOTA_TYPE=$ost_qtype
1443 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$QUOTA_TYPE ||
1444 error "set mdt quota type failed"
1445 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$QUOTA_TYPE ||
1446 error "set ost quota type failed"
1448 local quota_usrs=$QUOTA_USERS
1450 # get_filesystem_size
1451 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1452 local blk_soft=$((disksz + 1024))
1453 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1455 local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1456 local i_soft=$inodes
1457 local i_hard=$((i_soft + i_soft / 20))
1459 echo "Total disk size: $disksz block-softlimit: $blk_soft" \
1460 "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
1461 "inode-hardlimit: $i_hard"
1464 for usr in $quota_usrs; do
1465 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1467 cmd="$LFS setquota -$type $usr -b $blk_soft"
1468 cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1470 eval $cmd || error "$cmd FAILED!"
1472 # display the quota status
1473 echo "Quota settings for $usr : "
1474 $LFS quota -v -u $usr $mntpt || true
1481 local opts=${3:-$MOUNT_OPTS}
1482 opts=${opts:+-o $opts}
1483 local flags=${4:-$MOUNT_FLAGS}
1485 local device=$MGSNID:/$FSNAME
1486 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1487 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1491 echo "Starting client: $client: $flags $opts $device $mnt"
1492 do_node $client mkdir -p $mnt
1493 do_node $client $MOUNT_CMD $flags $opts $device $mnt || return 1
1495 set_default_debug_nodes $client
1507 [ "$3" ] && force=-f
1508 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
1509 if [ $running -ne 0 ]; then
1510 echo "Stopping client $client $mnt (opts:$force)"
1511 do_node $client lsof -t $mnt || need_kill=no
1512 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
1513 pids=$(do_node $client lsof -t $mnt | sort -u);
1514 if [ -n $pids ]; then
1515 do_node $client kill -9 $pids || true
1519 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
1520 if [ $busy -ne 0 ] ; then
1521 echo "$mnt is still busy, wait one second" && sleep 1
1522 do_node $client umount $force $mnt
1527 # nodes is comma list
1528 sanity_mount_check_nodes () {
1534 # FIXME: assume that all cluster nodes run the same os
1535 [ "$(uname)" = Linux ] || return 0
1538 for mnt in $mnts ; do
1539 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
1540 mpts=\\\$(mount | grep -c $mnt' ');
1541 if [ \\\$running -ne \\\$mpts ]; then
1542 echo \\\$(hostname) env are INSANE!;
1545 [ $? -eq 0 ] || rc=1
1550 sanity_mount_check_servers () {
1551 [ "$CLIENTONLY" ] &&
1552 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
1553 echo Checking servers environments
1555 # FIXME: modify get_facets to display all facets wo params
1556 local facets="$(get_facets OST),$(get_facets MDS),mgs"
1560 for facet in ${facets//,/ }; do
1561 node=$(facet_host ${facet})
1562 mntpt=$(facet_mntpt $facet)
1563 sanity_mount_check_nodes $node $mntpt ||
1564 { error "server $node environments are insane!"; return 1; }
1568 sanity_mount_check_clients () {
1569 local clients=${1:-$CLIENTS}
1570 local mntpt=${2:-$MOUNT}
1571 local mntpt2=${3:-$MOUNT2}
1573 [ -z $clients ] && clients=$(hostname)
1574 echo Checking clients $clients environments
1576 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
1577 error "clients environments are insane!"
1580 sanity_mount_check () {
1581 sanity_mount_check_servers || return 1
1582 sanity_mount_check_clients || return 2
1585 # mount clients if not mouted
1586 zconf_mount_clients() {
1589 local opts=${3:-$MOUNT_OPTS}
1590 opts=${opts:+-o $opts}
1591 local flags=${4:-$MOUNT_FLAGS}
1593 local device=$MGSNID:/$FSNAME
1594 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1595 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1599 echo "Starting client $clients: $flags $opts $device $mnt"
1602 running=\\\$(mount | grep -c $mnt' ');
1604 if [ \\\$running -eq 0 ] ; then
1606 $MOUNT_CMD $flags $opts $device $mnt;
1609 exit \\\$rc" || return ${PIPESTATUS[0]}
1611 echo "Started clients $clients: "
1612 do_nodes $clients "mount | grep $mnt' '"
1614 set_default_debug_nodes $clients
1619 zconf_umount_clients() {
1624 [ "$3" ] && force=-f
1626 echo "Stopping clients: $clients $mnt (opts:$force)"
1627 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
1628 if [ \\\$running -ne 0 ] ; then
1629 echo Stopping client \\\$(hostname) $mnt opts:$force;
1630 lsof $mnt || need_kill=no;
1631 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
1632 pids=\\\$(lsof -t $mnt | sort -u);
1633 if [ -n \\\"\\\$pids\\\" ]; then
1637 while umount $force $mnt 2>&1 | grep -q "busy"; do
1638 echo "$mnt is still busy, wait one second" && sleep 1;
1645 echo + $POWER_DOWN $node
1649 shutdown_node_hard () {
1651 local attempts=$SHUTDOWN_ATTEMPTS
1653 for i in $(seq $attempts) ; do
1656 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
1657 echo "waiting for $host to fail attempts=$attempts"
1658 [ $i -lt $attempts ] || \
1659 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
1665 local mnt=${2:-$MOUNT}
1668 if [ "$FAILURE_MODE" = HARD ]; then
1669 shutdown_node_hard $client
1671 zconf_umount_clients $client $mnt -f
1677 local facets="$(get_facets OST),$(get_facets MDS)"
1680 combined_mgs_mds || facets="$facets,mgs"
1682 for facet in ${facets//,/ }; do
1683 if [ $(facet_active_host $facet) == $host ]; then
1684 affected="$affected $facet"
1688 echo $(comma_list $affected)
1693 local host=${2:-$(facet_host $facet)}
1695 local label=$(convert_facet2label $facet)
1696 do_node $host $LCTL dl | awk '{ print $4 }' | grep -q "^$label\$"
1699 facets_up_on_host () {
1701 local facets=$(facets_on_host $host)
1704 for facet in ${facets//,/ }; do
1705 if $(facet_up $facet $host); then
1706 affected_up="$affected_up $facet"
1710 echo $(comma_list $affected_up)
1716 if [ "$FAILURE_MODE" = HARD ]; then
1717 shutdown_node_hard $(facet_active_host $facet)
1725 echo + $POWER_UP $node
1738 if [ "$FAILURE_MODE" = HARD ]; then
1739 reboot_node $(facet_active_host $facet)
1747 if [ "$FAILURE_MODE" = HARD ]; then
1757 for facet in ${facets//,/ }; do
1758 hosts=$(expand_list $hosts $(facet_host $facet) )
1764 _check_progs_installed () {
1768 for prog in $progs; do
1769 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1770 echo $prog missing on $(hostname)
1777 check_progs_installed () {
1781 do_rpc_nodes "$nodes" _check_progs_installed $@
1784 # recovery-scale functions
1786 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1789 start_client_load() {
1792 local var=$(node_var_name $client)_load
1793 eval export ${var}=$load
1795 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1796 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1797 END_RUN_FILE=$END_RUN_FILE \
1798 LOAD_PID_FILE=$LOAD_PID_FILE \
1799 TESTLOG_PREFIX=$TESTLOG_PREFIX \
1800 TESTNAME=$TESTNAME \
1801 DBENCH_LIB=$DBENCH_LIB \
1802 DBENCH_SRC=$DBENCH_SRC \
1803 CLIENT_COUNT=$((CLIENTCOUNT - 1)) \
1807 log "Started client load: ${load} on $client"
1809 # get the children process IDs
1810 local pids=$(ps --ppid $ppid -o pid= | xargs)
1811 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
1815 start_client_loads () {
1816 local -a clients=(${1//,/ })
1817 local numloads=${#CLIENT_LOADS[@]}
1820 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1821 testnum=$((nodenum % numloads))
1822 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1824 # bug 22169: wait the background threads to start
1828 # only for remote client
1829 check_client_load () {
1831 local var=$(node_var_name $client)_load
1832 local TESTLOAD=run_${!var}.sh
1834 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1836 # bug 18914: try to connect several times not only when
1837 # check ps, but while check_catastrophe also
1840 while [ $RC = 254 -a $tries -gt 0 ]; do
1844 if ! check_catastrophe $client; then
1846 if [ $RC -eq 254 ]; then
1847 # FIXME: not sure how long we shuold sleep here
1851 echo "check catastrophe failed: RC=$RC "
1855 # We can continue try to connect if RC=254
1856 # Just print the warning about this
1857 if [ $RC = 254 ]; then
1858 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1861 # see if the load is still on the client
1864 while [ $RC = 254 -a $tries -gt 0 ]; do
1868 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1873 if [ $RC = 254 ]; then
1874 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1875 # see if we can diagnose a bit why this is
1880 check_client_loads () {
1881 local clients=${1//,/ }
1885 for client in $clients; do
1886 check_client_load $client
1888 if [ "$rc" != 0 ]; then
1889 log "Client load failed on node $client, rc=$rc"
1895 restart_client_loads () {
1896 local clients=${1//,/ }
1897 local expectedfail=${2:-""}
1901 for client in $clients; do
1902 check_client_load $client
1904 if [ "$rc" != 0 -a "$expectedfail" ]; then
1905 local var=$(node_var_name $client)_load
1906 start_client_load $client ${!var}
1907 echo "Restarted client load ${!var}: on $client. Checking ..."
1908 check_client_load $client
1910 if [ "$rc" != 0 ]; then
1911 log "Client load failed to restart on node $client, rc=$rc"
1912 # failure one client load means test fail
1913 # we do not need to check other
1922 # Start vmstat and save its process ID in a file.
1927 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1930 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
1931 2>/dev/null </dev/null & echo \\\$! > $pid_file"
1934 # Display the nodes on which client loads failed.
1935 print_end_run_file() {
1939 [ -s $file ] || return 0
1941 echo "Found the END_RUN_FILE file: $file"
1944 # A client load will stop if it finds the END_RUN_FILE file.
1945 # That does not mean the client load actually failed though.
1946 # The first node in END_RUN_FILE is the one we are interested in.
1949 if [ -n "$node" ]; then
1950 local var=$(node_var_name $node)_load
1952 local prefix=$TESTLOG_PREFIX
1953 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
1954 local stdout_log=$prefix.run_${!var}_stdout.$node.log
1955 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
1957 echo "Client load ${!var} failed on node $node:"
1963 # Stop the process which had its PID saved in a file.
1968 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1970 do_nodes $nodes "test -f $pid_file &&
1971 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
1974 # Stop all client loads.
1975 stop_client_loads() {
1976 local nodes=${1:-$CLIENTS}
1979 # stop the client loads
1980 stop_process $nodes $pid_file
1982 # clean up the processes that started them
1983 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
1985 # End recovery-scale functions
1987 # verify that lustre actually cleaned up properly
1989 VAR=$(lctl get_param -n catastrophe 2>&1)
1990 if [ $? = 0 ] ; then
1991 if [ $VAR != 0 ]; then
1992 error "LBUG/LASSERT detected"
1995 BUSY=$(dmesg | grep -i destruct || true)
1996 if [ -n "$BUSY" ]; then
1998 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.$(date +%s)
2002 check_mem_leak || exit 204
2004 [[ $($LCTL dl 2>/dev/null | wc -l) -gt 0 ]] && $LCTL dl &&
2005 echo "$TESTSUITE: lustre didn't clean up..." 1>&2 &&
2008 if module_loaded lnet || module_loaded libcfs; then
2009 echo "$TESTSUITE: modules still loaded..." 1>&2
2018 if [[ "$1" == "--verbose" ]]; then
2033 PREV_RESULT=$(do_node $node "$TEST")
2035 RESULT=$(do_node $node "$TEST")
2036 if [[ "$RESULT" == "$FINAL" ]]; then
2037 [[ -z "$RESULT" || $WAIT -le $sleep ]] ||
2038 echo "Updated after ${WAIT}s: wanted '$FINAL'"\
2042 if [[ $verbose && "$RESULT" != "$PREV_RESULT" ]]; then
2043 echo "Changed after ${WAIT}s: from '$PREV_RESULT'"\
2047 [[ $WAIT -ge $MAX ]] && break
2048 [[ $((WAIT % print)) -eq 0 ]] &&
2049 echo "Waiting $((MAX - WAIT)) secs for update"
2050 WAIT=$((WAIT + sleep))
2053 echo "Update not seen after ${MAX}s: wanted '$FINAL' got '$RESULT'"
2057 wait_update_facet() {
2060 wait_update $(facet_active_host $facet) "$@"
2064 do_nodes $(comma_list $(mdts_nodes)) \
2065 "lctl set_param -n osd*.*MDT*.force_sync 1"
2066 do_nodes $(comma_list $(osts_nodes)) \
2067 "lctl set_param -n osd*.*OS*.force_sync 1" 2>&1 |
2068 grep -v 'Found no match'
2071 wait_delete_completed_mds() {
2072 local MAX_WAIT=${1:-20}
2073 # for ZFS, waiting more time for DMUs to be committed
2074 local ZFS_WAIT=${2:-5}
2076 local stime=$(date +%s)
2081 # find MDS with pending deletions
2082 for node in $(mdts_nodes); do
2083 changes=$(do_node $node "$LCTL get_param -n osc.*MDT*.sync_*" \
2084 2>/dev/null | calc_sum)
2085 if [[ $changes -eq 0 ]]; then
2088 mds2sync="$mds2sync $node"
2090 if [ -z "$mds2sync" ]; then
2093 mds2sync=$(comma_list $mds2sync)
2095 # sync MDS transactions
2096 do_nodes $mds2sync "$LCTL set_param -n osd*.*MD*.force_sync 1"
2098 # wait till all changes are sent and commmitted by OSTs
2099 # for ldiskfs space is released upon execution, but DMU
2100 # do this upon commit
2103 while [[ $WAIT -ne $MAX_WAIT ]]; do
2104 changes=$(do_nodes $mds2sync \
2105 "$LCTL get_param -n osc.*MDT*.sync_*" | calc_sum)
2106 #echo "$node: $changes changes on all"
2107 if [[ $changes -eq 0 ]]; then
2109 #echo "delete took $((etime - stime)) seconds"
2111 # the occupied disk space will be released
2112 # only after DMUs are committed
2113 if [[ $(facet_fstype $SINGLEMDS) == zfs ]]; then
2114 echo "sleep $ZFS_WAIT for ZFS OSD"
2125 echo "Delete is not completed in $((etime - stime)) seconds"
2126 do_nodes $mds2sync "$LCTL get_param osc.*MDT*.sync_*"
2132 # we can use "for" here because we are waiting the slowest
2133 for host in ${hostlist//,/ }; do
2134 check_network "$host" 900
2136 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
2143 for facet in ${facetlist//,/ }; do
2144 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
2146 wait_for_host $hostlist
2149 _wait_recovery_complete () {
2152 # Use default policy if $2 is not passed by caller.
2153 local MAX=${2:-$(max_recovery_time)}
2158 while [ $WAIT -lt $MAX ]; do
2159 STATUS=$(lctl get_param -n $param | grep status)
2161 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
2164 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
2166 echo "$param recovery not done in $MAX sec. $STATUS"
2170 wait_recovery_complete () {
2173 # with an assumption that at_max is the same on all nodes
2174 local MAX=${2:-$(max_recovery_time)}
2177 if [ "$FAILURE_MODE" = HARD ]; then
2178 facets=$(facets_on_host $(facet_active_host $facet))
2180 echo affected facets: $facets
2182 # we can use "for" here because we are waiting the slowest
2183 for facet in ${facets//,/ }; do
2184 local var_svc=${facet}_svc
2185 local param="*.${!var_svc}.recovery_status"
2187 local host=$(facet_active_host $facet)
2188 do_rpc_nodes "$host" _wait_recovery_complete $param $MAX
2192 wait_mds_ost_sync () {
2193 # just because recovery is done doesn't mean we've finished
2194 # orphan cleanup. Wait for llogs to get synchronized.
2195 echo "Waiting for orphan cleanup..."
2196 # MAX value includes time needed for MDS-OST reconnection
2197 local MAX=$(( TIMEOUT * 2 ))
2198 local WAIT_TIMEOUT=${1:-$MAX}
2201 local list=$(comma_list $(mdts_nodes))
2202 local cmd="$LCTL get_param -n osp.*osc*.old_sync_processed"
2203 if ! do_facet $SINGLEMDS \
2204 "$LCTL list_param osp.*osc*.old_sync_processed 2> /dev/null"
2206 # old way, use mds_sync
2208 list=$(comma_list $(osts_nodes))
2209 cmd="$LCTL get_param -n obdfilter.*.mds_sync"
2212 echo "wait $WAIT_TIMEOUT secs maximumly for $list mds-ost sync done."
2213 while [ $WAIT -lt $WAIT_TIMEOUT ]; do
2214 local -a sync=($(do_nodes $list "$cmd"))
2217 for ((i=0; i<${#sync[@]}; i++)); do
2219 [ ${sync[$i]} -eq 1 ] && continue
2221 [ ${sync[$i]} -eq 0 ] && continue
2223 # there is a not finished MDS-OST synchronization
2227 sleep 2 # increase waiting time and cover statfs cache
2228 [ ${con} -eq 1 ] && return 0
2229 echo "Waiting $WAIT secs for $list $i mds-ost sync done."
2233 # show which nodes are not finished.
2234 do_nodes $list "$cmd"
2235 echo "$facet recovery node $i not done in $WAIT_TIMEOUT sec. $STATUS"
2239 wait_destroy_complete () {
2240 echo "Waiting for local destroys to complete"
2241 # MAX value shouldn't be big as this mean server responsiveness
2242 # never increase this just to make test pass but investigate
2243 # why it takes so long time
2246 while [ $WAIT -lt $MAX ]; do
2247 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
2251 for ((i=0; i<${#RPCs[@]}; i++)); do
2252 [ ${RPCs[$i]} -eq 0 ] && continue
2253 # there are still some destroy RPCs in flight
2258 [ ${con} -eq 1 ] && return 0 # done waiting
2259 echo "Waiting ${WAIT}s for local destroys to complete"
2262 echo "Local destroys weren't done in $MAX sec."
2266 wait_delete_completed() {
2267 wait_delete_completed_mds $1 || return $?
2268 wait_destroy_complete
2277 # conf-sanity 31 takes a long time cleanup
2278 while [ $WAIT -lt 300 ]; do
2279 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
2280 [ -z "${running}" ] && return 0
2281 echo "waited $WAIT for${running}"
2282 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
2284 WAIT=$((WAIT + INTERVAL))
2286 echo "service didn't stop after $WAIT seconds. Still running:"
2291 wait_remote_prog () {
2297 [ "$PDSH" = "no_dsh" ] && return 0
2299 while [ $WAIT -lt $2 ]; do
2300 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
2301 [ -z "${running}" ] && return 0 || true
2302 echo "waited $WAIT for: "
2304 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
2306 WAIT=$((WAIT + INTERVAL))
2308 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
2309 [ -z "$pids" ] && return 0
2310 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
2311 # FIXME: not portable
2312 for pid in $pids; do
2313 cat /proc/${pid}/status || true
2314 cat /proc/${pid}/wchan || true
2316 kill -9 $pid || true
2325 # not every config has many clients
2327 if [ ! -z "$CLIENTS" ]; then
2328 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
2330 stat -f $MOUNT > /dev/null
2336 # usually checked on particular client or locally
2338 if [ ! -z "$client" ]; then
2339 $PDSH $client "stat -f $MOUNT" > /dev/null
2341 stat -f $MOUNT > /dev/null
2349 client_reconnect_try() {
2350 uname -n >> $MOUNT/recon
2351 if [ -z "$CLIENTS" ]; then
2352 df $MOUNT; uname -n >> $MOUNT/recon
2354 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
2356 echo Connected clients:
2358 ls -l $MOUNT/recon > /dev/null
2362 client_reconnect() {
2363 # one client_reconnect_try call does not always do the job...
2365 client_reconnect_try && break
2370 affected_facets () {
2373 local host=$(facet_active_host $facet)
2374 local affected=$facet
2376 if [ "$FAILURE_MODE" = HARD ]; then
2377 affected=$(facets_up_on_host $host)
2391 #Because it will only get up facets, we need get affected
2392 #facets before shutdown
2393 #For HARD Failure mode, it needs make sure facets on the same
2394 #HOST will only be shutdown and reboot once
2395 for facet in ${facets//,/ }; do
2396 local affected_facet
2398 #check whether facet has been included in other affected facets
2399 for ((index=0; index<$total; index++)); do
2400 [[ *,$facet,* == ,${affecteds[index]}, ]] && skip=1
2403 if [ $skip -eq 0 ]; then
2404 affecteds[$total]=$(affected_facets $facet)
2409 for ((index=0; index<$total; index++)); do
2410 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2411 local host=$(facet_active_host $facet)
2412 echo "Failing ${affecteds[index]} on $host"
2413 shutdown_facet $facet
2416 for ((index=0; index<$total; index++)); do
2417 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2418 echo reboot facets: ${affecteds[index]}
2422 change_active ${affecteds[index]}
2424 wait_for_facet ${affecteds[index]}
2425 # start mgs first if it is affected
2426 if ! combined_mgs_mds &&
2427 list_member ${affecteds[index]} mgs; then
2428 mount_facet mgs || error "Restart of mgs failed"
2430 # FIXME; has to be changed to mount all facets concurrently
2431 affected=$(exclude_items_from_list ${affecteds[index]} mgs)
2432 echo mount facets: ${affecteds[index]}
2433 mount_facets ${affecteds[index]}
2443 do_facet $facet "sync; sync; sync"
2446 # make sure there will be no seq change
2447 local clients=${CLIENTS:-$HOSTNAME}
2448 local f=fsa-\\\$\(hostname\)
2449 do_nodes $clients "mcreate $MOUNT/$f; rm $MOUNT/$f"
2450 do_nodes $clients "if [ -d $MOUNT2 ]; then mcreate $MOUNT2/$f; rm $MOUNT2/$f; fi"
2452 local svc=${facet}_svc
2453 do_facet $facet $LCTL --device ${!svc} notransno
2455 # If a ZFS OSD is made read-only here, its pool is "freezed". This
2456 # in-memory state has to be cleared by either rebooting the host or
2457 # exporting and reimporting the pool.
2459 # Although the uberblocks are not updated when a pool is freezed,
2460 # transactions are still written to the disks. Modified blocks may be
2461 # cached in memory when tests try reading them back. The
2462 # export-and-reimport process also evicts any cached pool data from
2463 # memory to provide the correct "data loss" semantics.
2465 # In the test framework, the exporting and importing operations are
2466 # handled by stop() and mount_facet() separately, which are used
2467 # inside fail() and fail_abort().
2469 do_facet $facet $LCTL --device ${!svc} readonly
2470 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2471 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2474 replay_barrier_nodf() {
2475 local facet=$1 echo running=${running}
2476 do_facet $facet "sync; sync; sync"
2477 local svc=${facet}_svc
2478 echo Replay barrier on ${!svc}
2479 do_facet $facet $LCTL --device ${!svc} notransno
2480 do_facet $facet $LCTL --device ${!svc} readonly
2481 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2482 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2485 replay_barrier_nosync() {
2486 local facet=$1 echo running=${running}
2487 local svc=${facet}_svc
2488 echo Replay barrier on ${!svc}
2489 do_facet $facet $LCTL --device ${!svc} notransno
2490 do_facet $facet $LCTL --device ${!svc} readonly
2491 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2492 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2496 # Get Lustre client uuid for a given Lustre mount point.
2499 local mntpnt=${1:-$MOUNT}
2501 local name=$($LFS getname $mntpnt | cut -d' ' -f1)
2502 local uuid=$($LCTL get_param -n llite.$name.uuid)
2507 mds_evict_client() {
2508 local mntpnt=${1:-$MOUNT}
2509 local uuid=$(get_client_uuid $mntpnt)
2511 do_facet $SINGLEMDS \
2512 "$LCTL set_param -n mdt.${mds1_svc}.evict_client $uuid"
2515 ost_evict_client() {
2516 local mntpnt=${1:-$MOUNT}
2517 local uuid=$(get_client_uuid $mntpnt)
2520 "$LCTL set_param -n obdfilter.${ost1_svc}.evict_client $uuid"
2525 local clients=${CLIENTS:-$HOSTNAME}
2527 facet_failover $* || error "failover: $?"
2528 wait_clients_import_state "$clients" "$facets" FULL
2529 clients_up || error "post-failover df: $?"
2534 facet_failover $facet
2540 change_active $facet
2541 wait_for_facet $facet
2542 mount_facet $facet -o abort_recovery
2543 clients_up || echo "first df failed: $?"
2544 clients_up || error "post-failover df: $?"
2548 echo There is no lmc. This is mountconf, baby.
2552 host_nids_address() {
2556 if [ -n "$kind" ]; then
2557 nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'")
2559 nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'")
2565 if [ "$1" = "'*'" ]; then echo \'*\'; else
2571 if [ "$1" = "'*'" ]; then echo \'*\'; else
2572 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | \
2574 if [ -z "$ID" ]; then
2575 echo "Could not get a ptl id for $1..."
2584 h2name_or_ip "$1" "tcp"
2589 if [ "$1" = "'*'" ]; then echo \'*\'; else
2590 if type __h2elan >/dev/null 2>&1; then
2593 ID=`echo $1 | sed 's/[^0-9]*//g'`
2601 h2name_or_ip "$1" "o2ib"
2605 # This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST
2606 # expressions format. As a bonus we can then just pass in those variables
2607 # to pdsh. What this function does is take a HOSTLIST type string and
2608 # expand it into a space deliminated list for us.
2616 [ -z "$hostlist" ] && return
2618 # Translate the case of [..],..,[..] to [..] .. [..]
2619 list="${hostlist/],/] }"
2621 [[ "$front" == *,* ]] && {
2624 list=${list/${old}/${new}}
2627 for item in $list; do
2628 # Test if we have any []'s at all
2629 if [ "$item" != "${item/\[/}" ]; then {
2630 # Expand the [*] into list
2634 if [ "$name" != "$item" ]; then
2635 group=${item#$name[*}
2638 for range in ${group//,/ }; do
2642 # Number of leading zeros
2645 end=$(echo $end | sed 's/0*//')
2646 [[ -z "$end" ]] && end=0
2647 [[ $padlen2 -gt $padlen ]] && {
2648 [[ $padlen2 -eq ${#end} ]] && padlen2=0
2651 begin=$(echo $begin | sed 's/0*//')
2652 [ -z $begin ] && begin=0
2654 for num in $(seq -f "%0${padlen}g" $begin $end); do
2655 value="${name#*,}${num}${back}"
2656 [ "$value" != "${value/\[/}" ] && {
2657 value=$(hostlist_expand "$value")
2659 myList="$myList $value"
2664 myList="$myList $item"
2667 myList=${myList//,/ }
2668 myList=${myList:1} # Remove first character which is a space
2670 # Filter any duplicates without sorting
2672 myList="${list%% *}"
2674 while [[ "$list" != ${myList##* } ]]; do
2675 list=${list//${list%% *} /}
2676 myList="$myList ${list%% *}"
2678 myList="${myList%* }";
2680 # We can select an object at an offset in the list
2683 for item in $myList; do
2685 [ $cnt -eq $offset ] && {
2689 [ $(get_node_count $myList) -ne 1 ] && myList=""
2698 [ "$facet" == client ] && echo -n $HOSTNAME && return
2699 varname=${facet}_HOST
2700 if [ -z "${!varname}" ]; then
2701 if [ "${facet:0:3}" == "ost" ]; then
2702 local fh=${facet%failover}_HOST
2703 eval export ${facet}_HOST=${!fh}
2704 if [ -z "${!varname}" ]; then
2705 eval export ${facet}_HOST=${ost_HOST}
2707 elif [ "${facet:0:3}" == "mdt" -o \
2708 "${facet:0:3}" == "mds" -o \
2709 "${facet:0:3}" == "mgs" ]; then
2710 eval export ${facet}_HOST=${mds_HOST}
2716 facet_failover_host() {
2720 var=${facet}failover_HOST
2721 if [ -n "${!var}" ]; then
2726 if [ "${facet:0:3}" == "mdt" -o "${facet:0:3}" == "mds" -o \
2727 "${facet:0:3}" == "mgs" ]; then
2729 eval export ${facet}failover_host=${mds_HOST}
2734 if [[ $facet == ost* ]]; then
2735 eval export ${facet}failover_host=${ost_HOST}
2743 local activevar=${facet}active
2745 if [ -f $TMP/${facet}active ] ; then
2746 source $TMP/${facet}active
2749 active=${!activevar}
2750 if [ -z "$active" ] ; then
2757 facet_active_host() {
2759 local active=`facet_active $facet`
2760 if [ "$facet" == client ]; then
2763 echo `facet_host $active`
2767 # Get the passive failover partner host of facet.
2768 facet_passive_host() {
2770 [[ $facet = client ]] && return
2772 local host=${facet}_HOST
2773 local failover_host=${facet}failover_HOST
2774 local active_host=$(facet_active_host $facet)
2776 [[ -z ${!failover_host} || ${!failover_host} = ${!host} ]] && return
2778 if [[ $active_host = ${!host} ]]; then
2779 echo -n ${!failover_host}
2789 facetlist=$(exclude_items_from_list $facetlist mgs)
2791 for facet in ${facetlist//,/ }; do
2792 local failover=${facet}failover
2793 local host=`facet_host $failover`
2794 [ -z "$host" ] && return
2796 local curactive=`facet_active $facet`
2797 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
2798 eval export ${facet}active=$facet
2800 eval export ${facet}active=$failover
2802 # save the active host for this facet
2803 local activevar=${facet}active
2804 echo "$activevar=${!activevar}" > $TMP/$activevar
2805 [[ $facet = mds1 ]] && combined_mgs_mds && \
2806 echo "mgsactive=${!activevar}" > $TMP/mgsactive
2807 local TO=`facet_active_host $facet`
2808 echo "Failover $facet to $TO"
2814 # do not stripe off hostname if verbose, bug 19215
2815 if [ x$1 = x--verbose ]; then
2823 if [ "$HOST" = "$HOSTNAME" ]; then
2825 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
2826 echo "cannot run remote command on $HOST with $myPDSH"
2830 echo "CMD: $HOST $@" >&2
2831 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2834 if [ "$myPDSH" = "rsh" ]; then
2835 # we need this because rsh does not return exit code of an executed command
2836 local command_status="$TMP/cs"
2837 rsh $HOST ":> $command_status"
2838 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
2839 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
2840 echo command failed >$command_status"
2841 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
2846 # print HOSTNAME for myPDSH="no_dsh"
2847 if [[ $myPDSH = no_dsh ]]; then
2848 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
2850 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
2853 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
2855 return ${PIPESTATUS[0]}
2859 do_node --verbose "$@"
2862 single_local_node () {
2863 [ "$1" = "$HOSTNAME" ]
2866 # Outputs environment variable assignments that should be passed to remote nodes
2870 local facets=$(get_facets)
2873 for var in ${!MODOPTS_*}; do
2874 value=${!var//\"/\\\"}
2875 echo -n " ${var}=\"$value\""
2878 for facet in ${facets//,/ }; do
2880 if [ -n "${!var}" ]; then
2881 echo -n " $var=${!var}"
2885 for var in MGSFSTYPE MDSFSTYPE OSTFSTYPE; do
2886 if [ -n "${!var}" ]; then
2887 echo -n " $var=${!var}"
2891 if [ -n "$FSTYPE" ]; then
2892 echo -n " FSTYPE=$FSTYPE"
2898 # do not stripe off hostname if verbose, bug 19215
2899 if [ x$1 = x--verbose ]; then
2907 if single_local_node $rnodes; then
2909 do_nodev $rnodes "$@"
2911 do_node $rnodes "$@"
2916 # This is part from do_node
2919 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
2920 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
2922 export FANOUT=$(get_node_count "${rnodes//,/ }")
2924 echo "CMD: $rnodes $@" >&2
2925 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2928 # do not replace anything from pdsh output if -N is used
2929 # -N Disable hostname: prefix on lines of output.
2930 if $verbose || [[ $myPDSH = *-N* ]]; then
2931 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
2933 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
2935 return ${PIPESTATUS[0]}
2941 local HOST=`facet_active_host $facet`
2942 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
2946 # Function: do_facet_random_file $FACET $FILE $SIZE
2947 # Creates FILE with random content on the given FACET of given SIZE
2949 do_facet_random_file() {
2953 local cmd="dd if=/dev/urandom of='$fpath' bs=$fsize count=1"
2954 do_facet $facet "$cmd 2>/dev/null"
2957 do_facet_create_file() {
2961 local cmd="dd if=/dev/zero of='$fpath' bs=$fsize count=1"
2962 do_facet $facet "$cmd 2>/dev/null"
2966 do_nodes --verbose "$@"
2972 # make sure its not already running
2974 rm -f $TMP/${facet}active
2975 [[ $facet = mds1 ]] && combined_mgs_mds && rm -f $TMP/mgsactive
2976 do_facet ${facet} $MKFS $* || return ${PIPESTATUS[0]}
2978 if [[ $(facet_fstype $facet) == zfs ]]; then
2980 # After formatting a ZFS target, "cachefile=none" property will
2981 # be set on the ZFS storage pool so that the pool is not
2982 # automatically imported on system startup. And then the pool
2983 # will be exported so as to leave the importing and exporting
2984 # operations handled by mount_facet() and stop() separately.
2986 refresh_partition_table $facet $(facet_vdevice $facet)
2987 disable_zpool_cache $facet
2992 # Device formatted as ost
2995 local DEVNAME=OSTDEV$num
2997 local fstype=$(facet_fstype ost$num)
3001 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
3002 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
3004 #try $OSTZFSDEVn - independent of vdev
3005 DEVNAME=OSTZFSDEV$num
3006 eval DEVPTR=${!DEVNAME:=${FSNAME}-ost${num}/ost${num}};;
3008 error "unknown fstype!";;
3014 # Physical device location of data
3020 local fstype=$(facet_fstype ost$num)
3024 # vdevs are not supported by ldiskfs
3027 #if $OSTDEVn isn't defined, default is $OSTDEVBASE{n}
3028 # Device formatted by zfs
3030 eval VDEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
3032 error "unknown fstype!";;
3038 # Logical device formatted for lustre
3041 local DEVNAME=MDSDEV$num
3043 local fstype=$(facet_fstype mds$num)
3047 #if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3048 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3050 # try $MDSZFSDEVn - independent of vdev
3051 DEVNAME=MDSZFSDEV$num
3052 eval DEVPTR=${!DEVNAME:=${FSNAME}-mdt${num}/mdt${num}};;
3054 error "unknown fstype!";;
3060 # Physical location of data
3064 local fstype=$(facet_fstype mds$num)
3068 # vdevs are not supported by ldiskfs
3071 # if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3072 # Device formatted by ZFS
3073 local DEVNAME=MDSDEV$num
3074 eval VDEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3076 error "unknown fstype!";;
3084 local fstype=$(facet_fstype mgs)
3088 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3089 ( [ -z "$MGSDEV" ] || [ $MGSDEV = $(mdsdevname 1) ] ); then
3090 DEVPTR=$(mdsdevname 1)
3095 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3096 ( [ -z "$MGSZFSDEV" ] &&
3097 [ -z "$MGSDEV" -o "$MGSDEV" = $(mdsvdevname 1) ] ); then
3098 DEVPTR=$(mdsdevname 1)
3100 DEVPTR=${MGSZFSDEV:-${FSNAME}-mgs/mgs}
3103 error "unknown fstype!";;
3112 local fstype=$(facet_fstype mgs)
3116 # vdevs are not supported by ldiskfs
3119 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3120 ( [ -z "$MGSDEV" ] &&
3121 [ -z "$MGSZFSDEV" -o "$MGSZFSDEV" = $(mdsdevname 1) ]); then
3122 VDEVPTR=$(mdsvdevname 1)
3123 elif [ -n "$MGSDEV" ]; then
3127 error "unknown fstype!";;
3135 [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
3137 local var=${facet}_MOUNT
3138 eval mntpt=${!var:-${MOUNT%/*}/$facet}
3145 local dev=$(facet_device $facet)
3146 local mnt=$(facet_mntpt $facet)
3149 if ! do_facet $facet test -b $dev; then
3152 do_facet $facet mount -t ldiskfs $opts $dev $mnt
3157 local dev=$(facet_device $facet)
3158 local mnt=$(facet_mntpt $facet)
3160 do_facet $facet umount -d $mnt
3164 echo -n "$1" | tr -c '[:alnum:]\n' '_'
3169 local ds=$(facet_device $facet)
3170 local mnt=$(facet_mntpt $facet)
3175 canmnt=$(do_facet $facet $ZFS get -H -o value canmount $ds)
3176 mntpt=$(do_facet $facet $ZFS get -H -o value mountpoint $ds)
3177 do_facet $facet $ZFS set canmount=noauto $ds
3179 # The "legacy" mount method is used here because "zfs unmount $mnt"
3180 # calls stat(2) on $mnt/../*, which may include $MOUNT. If certain
3181 # targets are not available at the time, the stat(2) on $MOUNT will
3184 do_facet $facet $ZFS set mountpoint=legacy $ds
3185 do_facet $facet mount -t zfs $ds $mnt
3186 eval export mz_$(var_name ${facet}_$ds)_canmount=$canmnt
3187 eval export mz_$(var_name ${facet}_$ds)_mountpoint=$mntpt
3192 local ds=$(facet_device $facet)
3193 local mnt=$(facet_mntpt $facet)
3194 local var_mntpt=mz_$(var_name ${facet}_$ds)_mountpoint
3195 local var_canmnt=mz_$(var_name ${facet}_$ds)_canmount
3196 local mntpt=${!var_mntpt}
3197 local canmnt=${!var_canmnt}
3201 do_facet $facet umount $mnt
3202 do_facet $facet $ZFS set mountpoint=$mntpt $ds
3203 do_facet $facet $ZFS set canmount=$canmnt $ds
3209 local fstype=$(facet_fstype $facet)
3211 mount_$fstype $facet
3216 local fstype=$(facet_fstype $facet)
3218 unmount_$fstype $facet
3225 # make sure we are using the primary server, so test-framework will
3226 # be able to clean up properly.
3227 activemds=`facet_active mds1`
3228 if [ $activemds != "mds1" ]; then
3232 local clients=$CLIENTS
3233 [ -z $clients ] && clients=$(hostname)
3235 zconf_umount_clients $clients $MOUNT "$*" || true
3236 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
3238 [ "$CLIENTONLY" ] && return
3239 # The add fn does rm ${facet}active file, this would be enough
3240 # if we use do_facet <facet> only after the facet added, but
3241 # currently we use do_facet mds in local.sh
3242 for num in `seq $MDSCOUNT`; do
3244 rm -f ${TMP}/mds${num}active
3246 combined_mgs_mds && rm -f $TMP/mgsactive
3248 for num in `seq $OSTCOUNT`; do
3250 rm -f $TMP/ost${num}active
3253 if ! combined_mgs_mds ; then
3260 cleanup_echo_devs () {
3261 local devs=$($LCTL dl | grep echo | awk '{print $4}')
3263 for dev in $devs; do
3264 $LCTL --device $dev cleanup
3265 $LCTL --device $dev detach
3270 nfs_client_mode && return
3279 combined_mgs_mds () {
3280 [[ "$(mdsdevname 1)" = "$(mgsdevname)" ]] &&
3281 [[ "$(facet_host mds1)" = "$(facet_host mgs)" ]]
3285 echo -n "$1" | tr '[:upper:]' '[:lower:]'
3289 echo -n "$1" | tr '[:lower:]' '[:upper:]'
3295 local fsname=${3:-"$FSNAME"}
3296 local type=$(facet_type $facet)
3297 local index=$(facet_index $facet)
3298 local fstype=$(facet_fstype $facet)
3299 local host=$(facet_host $facet)
3304 if [ $type == MGS ] || ( [ $type == MDS ] &&
3305 [ "$dev" == $(mgsdevname) ] &&
3306 [ "$host" == "$(facet_host mgs)" ] ); then
3309 opts="--mgsnode=$MGSNID"
3312 if [ $type != MGS ]; then
3313 opts+=" --fsname=$fsname --$(lower ${type/MDS/MDT}) \
3317 var=${facet}failover_HOST
3318 if [ -n "${!var}" ] && [ ${!var} != $(facet_host $facet) ]; then
3319 opts+=" --failnode=$(h2$NETTYPE ${!var})"
3322 opts+=${TIMEOUT:+" --param=sys.timeout=$TIMEOUT"}
3323 opts+=${LDLM_TIMEOUT:+" --param=sys.ldlm_timeout=$LDLM_TIMEOUT"}
3325 if [ $type == MDS ]; then
3326 opts+=${SECLEVEL:+" --param=mdt.sec_level"}
3327 opts+=${MDSCAPA:+" --param-mdt.capa=$MDSCAPA"}
3328 opts+=${STRIPE_BYTES:+" --param=lov.stripesize=$STRIPE_BYTES"}
3329 opts+=${STRIPES_PER_OBJ:+" --param=lov.stripecount=$STRIPES_PER_OBJ"}
3330 opts+=${L_GETIDENTITY:+" --param=mdt.identity_upcall=$L_GETIDENTITY"}
3332 if [ $fstype == ldiskfs ]; then
3333 # Check for wide striping
3334 if [ $OSTCOUNT -gt 160 ]; then
3335 MDSJOURNALSIZE=${MDSJOURNALSIZE:-4096}
3336 fs_mkfs_opts+="-O large_xattr"
3339 fs_mkfs_opts+=${MDSJOURNALSIZE:+" -J size=$MDSJOURNALSIZE"}
3340 if [ ! -z $EJOURNAL ]; then
3341 fs_mkfs_opts+=${MDSJOURNALSIZE:+" device=$EJOURNAL"}
3343 fs_mkfs_opts+=${MDSISIZE:+" -i $MDSISIZE"}
3347 if [ $type == OST ]; then
3348 opts+=${SECLEVEL:+" --param=ost.sec_level"}
3349 opts+=${OSSCAPA:+" --param=ost.capa=$OSSCAPA"}
3351 if [ $fstype == ldiskfs ]; then
3352 fs_mkfs_opts+=${OSTJOURNALSIZE:+" -J size=$OSTJOURNALSIZE"}
3356 opts+=" --backfstype=$fstype"
3359 if [ -n "${!var}" ]; then
3360 opts+=" --device-size=${!var}"
3363 var=$(upper $fstype)_MKFS_OPTS
3364 fs_mkfs_opts+=${!var:+" ${!var}"}
3366 var=${type}_FS_MKFS_OPTS
3367 fs_mkfs_opts+=${!var:+" ${!var}"}
3369 if [ -n "${fs_mkfs_opts## }" ]; then
3370 opts+=" --mkfsoptions=\\\"${fs_mkfs_opts## }\\\""
3374 opts+=${!var:+" ${!var}"}
3379 check_ost_indices() {
3380 local index_count=${#OST_INDICES[@]}
3381 [[ $index_count -eq 0 || $OSTCOUNT -le $index_count ]] && return 0
3383 # OST count is greater than the index count in $OST_INDEX_LIST.
3384 # We need check whether there are duplicate indices.
3388 for i in $(seq $((index_count + 1)) $OSTCOUNT); do
3389 index=$(facet_index ost$i)
3390 for j in $(seq 0 $((index_count - 1))); do
3391 [[ $index -ne ${OST_INDICES[j]} ]] ||
3392 error "ost$i has the same index $index as ost$((j+1))"
3405 # We need ldiskfs here, may as well load them all
3407 [ "$CLIENTONLY" ] && return
3408 echo Formatting mgs, mds, osts
3409 if ! combined_mgs_mds ; then
3410 echo "Format mgs: $(mgsdevname)"
3411 add mgs $(mkfs_opts mgs $(mgsdevname)) --reformat \
3412 $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} ||
3416 for num in $(seq $MDSCOUNT); do
3417 echo "Format mds$num: $(mdsdevname $num)"
3418 add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
3419 --reformat $(mdsdevname $num) $(mdsvdevname $num) \
3420 ${quiet:+>/dev/null} || exit 10
3423 export OST_INDICES=($(hostlist_expand "$OST_INDEX_LIST"))
3425 for num in $(seq $OSTCOUNT); do
3426 echo "Format ost$num: $(ostdevname $num)"
3427 add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
3428 --reformat $(ostdevname $num) $(ostvdevname ${num}) \
3429 ${quiet:+>/dev/null} || exit 10
3434 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
3438 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
3442 # 0: success, the old identity set already.
3443 # 1: success, the old identity does not set.
3448 local j=`expr $num - 1`
3449 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
3451 if [ -z "$MDT" ]; then
3455 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
3458 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
3460 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
3463 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
3465 if [ $old = "NONE" ]; then
3474 zconf_umount `hostname` $1 || error "umount failed"
3475 zconf_mount `hostname` $1 || error "mount failed"
3483 rm -f $TMP/${facet}active
3484 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" || return 1
3489 local mdt_count=${1:-$MDSCOUNT}
3490 local ost_count=${2:-$OSTCOUNT}
3493 for num in $(seq $mdt_count); do
3494 DEVNAME=$(mdsdevname $num)
3495 writeconf_facet mds$num $DEVNAME || rc=$?
3498 for num in $(seq $ost_count); do
3499 DEVNAME=$(ostdevname $num)
3500 writeconf_facet ost$num $DEVNAME || rc=$?
3506 nfs_client_mode && return
3508 sanity_mount_check ||
3509 error "environments are insane!"
3513 if [ -z "$CLIENTONLY" ]; then
3514 echo Setup mgs, mdt, osts
3515 echo $WRITECONF | grep -q "writeconf" && \
3517 if ! combined_mgs_mds ; then
3518 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
3521 for num in `seq $MDSCOUNT`; do
3522 DEVNAME=$(mdsdevname $num)
3523 start mds$num $DEVNAME $MDS_MOUNT_OPTS
3525 # We started mds, now we should set failover variables properly.
3526 # Set mds${num}failover_HOST if it is not set (the default failnode).
3527 local varname=mds${num}failover_HOST
3528 if [ -z "${!varname}" ]; then
3529 eval mds${num}failover_HOST=$(facet_host mds$num)
3532 if [ $IDENTITY_UPCALL != "default" ]; then
3533 switch_identity $num $IDENTITY_UPCALL
3536 for num in `seq $OSTCOUNT`; do
3537 DEVNAME=$(ostdevname $num)
3538 start ost$num $DEVNAME $OST_MOUNT_OPTS
3540 # We started ost$num, now we should set ost${num}failover variable properly.
3541 # Set ost${num}failover_HOST if it is not set (the default failnode).
3542 varname=ost${num}failover_HOST
3543 if [ -z "${!varname}" ]; then
3544 eval ost${num}failover_HOST=$(facet_host ost${num})
3552 # wait a while to allow sptlrpc configuration be propogated to targets,
3553 # only needed when mounting new target devices.
3558 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
3560 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
3563 if [ "$MOUNT_2" ]; then
3564 mount_client $MOUNT2
3565 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
3570 # by remounting mdt before ost, initial connect from mdt to ost might
3571 # timeout because ost is not ready yet. wait some time to its fully
3572 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
3573 # by a context negotiation rpc with $TIMEOUT.
3574 # FIXME better by monitoring import status.
3577 sleep $((TIMEOUT + 5))
3583 mounted_lustre_filesystems() {
3584 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
3587 init_facet_vars () {
3588 [ "$CLIENTONLY" ] && return 0
3595 eval export ${facet}_dev=${device}
3596 eval export ${facet}_opt=\"$@\"
3598 local dev=${facet}_dev
3600 # We need to loop for the label
3601 # in case its not initialized yet.
3602 for wait_time in {0,1,3,5,10}; do
3604 if [ $wait_time -gt 0 ]; then
3605 echo "${!dev} not yet initialized,"\
3606 "waiting ${wait_time} seconds."
3610 local label=$(devicelabel ${facet} ${!dev})
3612 # Check to make sure the label does
3613 # not include ffff at the end of the label.
3614 # This indicates it has not been initialized yet.
3616 if [[ $label =~ [f|F]{4}$ ]]; then
3617 # label is not initialized, unset the result
3618 # and either try again or fail
3625 [ -z "$label" ] && echo no label for ${!dev} && exit 1
3627 eval export ${facet}_svc=${label}
3629 local varname=${facet}failover_HOST
3630 if [ -z "${!varname}" ]; then
3631 eval export $varname=$(facet_host $facet)
3634 varname=${facet}_HOST
3635 if [ -z "${!varname}" ]; then
3636 eval export $varname=$(facet_host $facet)
3639 # ${facet}failover_dev is set in cfg file
3640 varname=${facet}failover_dev
3641 if [ -n "${!varname}" ] ; then
3642 eval export ${facet}failover_dev=${!varname}
3644 eval export ${facet}failover_dev=$device
3647 # get mount point of already mounted device
3648 # is facet_dev is already mounted then use the real
3649 # mount point of this facet; otherwise use $(facet_mntpt $facet)
3650 # i.e. ${facet}_MOUNT if specified by user or default
3651 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
3652 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
3653 if [ -z $mntpt ]; then
3654 mntpt=$(facet_mntpt $facet)
3656 eval export ${facet}_MOUNT=$mntpt
3659 init_facets_vars () {
3662 if ! remote_mds_nodsh; then
3663 for num in $(seq $MDSCOUNT); do
3664 DEVNAME=`mdsdevname $num`
3665 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
3669 combined_mgs_mds || init_facet_vars mgs $(mgsdevname) $MGS_MOUNT_OPTS
3671 if ! remote_ost_nodsh; then
3672 for num in $(seq $OSTCOUNT); do
3673 DEVNAME=$(ostdevname $num)
3674 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
3679 osc_ensure_active () {
3684 while [ $period -lt $timeout ]; do
3685 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
3686 if [ $count -eq 0 ]; then
3690 echo "There are $count OST are inactive, wait $period seconds, and try again"
3692 period=$((period+3))
3695 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
3698 set_conf_param_and_check() {
3702 local ORIG=$(do_facet $myfacet "$TEST")
3703 if [ $# -gt 3 ]; then
3709 echo "Setting $PARAM from $ORIG to $FINAL"
3710 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" ||
3711 error "conf_param $PARAM failed"
3713 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" ||
3714 error "check $PARAM failed!"
3717 init_param_vars () {
3719 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3721 log "Using TIMEOUT=$TIMEOUT"
3723 osc_ensure_active $SINGLEMDS $TIMEOUT
3724 osc_ensure_active client $TIMEOUT
3726 if [ -n "$(lctl get_param -n mdc.*.connect_flags|grep jobstats)" ]; then
3727 local current_jobid_var=$($LCTL get_param -n jobid_var)
3729 if [ $JOBID_VAR = "existing" ]; then
3730 echo "keeping jobstats as $current_jobid_var"
3731 elif [ $current_jobid_var != $JOBID_VAR ]; then
3732 echo "seting jobstats to $JOBID_VAR"
3734 set_conf_param_and_check client \
3735 "$LCTL get_param -n jobid_var" \
3736 "$FSNAME.sys.jobid_var" $JOBID_VAR
3739 echo "jobstats not supported by server"
3742 if [ $QUOTA_AUTO -ne 0 ]; then
3743 if [ "$ENABLE_QUOTA" ]; then
3744 echo "enable quota as required"
3745 setup_quota $MOUNT || return 2
3747 echo "disable quota as required"
3748 # $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
3754 nfs_client_mode () {
3755 if [ "$NFSCLIENT" ]; then
3756 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
3757 local clients=$CLIENTS
3758 [ -z $clients ] && clients=$(hostname)
3760 # FIXME: remove hostname when 19215 fixed
3761 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
3762 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
3763 if [[ ${#nfsexport[@]} -eq 0 ]]; then
3764 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
3766 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
3772 check_config_client () {
3775 local mounted=$(mount | grep " $mntpt ")
3776 if [ "$CLIENTONLY" ]; then
3778 # CLIENTONLY should not depend on *_HOST settings
3779 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
3780 # in theory someone could create a new,
3781 # client-only config file that assumed lustre was already
3782 # configured and didn't set the MGSNID. If MGSNID is not set,
3783 # then we should use the mgs nid currently being used
3784 # as the default value. bug 18021
3785 [[ x$MGSNID = x ]] &&
3788 if [[ x$mgc != xMGC$MGSNID ]]; then
3789 if [ "$mgs_HOST" ]; then
3790 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
3791 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
3792 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
3798 local myMGS_host=$mgs_HOST
3799 if [ "$NETTYPE" = "ptl" ]; then
3800 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
3803 echo Checking config lustre mounted on $mntpt
3804 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
3805 mgshost=$(echo $mgshost | awk -F: '{print $1}')
3807 # if [ "$mgshost" != "$myMGS_host" ]; then
3808 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
3809 # Please use correct config or set mds_HOST correctly!"
3814 check_config_clients () {
3815 local clients=${CLIENTS:-$HOSTNAME}
3818 nfs_client_mode && return
3820 do_rpc_nodes "$clients" check_config_client $mntpt
3822 sanity_mount_check || error "environments are insane!"
3826 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3827 local cltimeout=$(lctl get_param -n timeout)
3828 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
3829 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
3836 [ -z $mntpt ] && return 1
3837 local mounted=$(mounted_lustre_filesystems)
3839 echo $mounted' ' | grep -w -q $mntpt' '
3843 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
3847 # empty lustre filesystem may have empty directories lost+found and .lustre
3849 # exclude .lustre & lost+found
3850 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
3851 -print | wc -l) = 1 ] || return 1
3852 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found || return 1
3853 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.4.0) ]; then
3854 # exclude .lustre/fid (LU-2780)
3855 [ $(find $1/.lustre -maxdepth 1 -name fid -prune -o \
3856 -print | wc -l) = 1 ] || return 1
3858 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre || return 1
3863 check_and_setup_lustre() {
3864 nfs_client_mode && return
3866 local MOUNTED=$(mounted_lustre_filesystems)
3870 # both MOUNT and MOUNT2 are not mounted
3871 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
3872 [ "$REFORMAT" ] && formatall
3873 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
3875 is_mounted $MOUNT || error "NAME=$NAME not mounted"
3876 export I_MOUNTED=yes
3880 elif is_mounted $MOUNT2; then
3882 # MOUNT2 is mounted, while MOUNT_2 is not set
3883 if ! [ "$MOUNT_2" ]; then
3884 cleanup_mount $MOUNT2
3885 export I_UMOUNTED2=yes
3888 # MOUNT2 is mounted, MOUNT_2 is set
3890 # FIXME: what to do if check_config failed?
3892 # 1) remote client has mounted other Lustre fs ?
3893 # 2) it has insane env ?
3894 # let's try umount MOUNT2 on all clients and mount it again:
3895 if ! check_config_clients $MOUNT2; then
3896 cleanup_mount $MOUNT2
3897 restore_mount $MOUNT2
3898 export I_MOUNTED2=yes
3903 # MOUNT is mounted MOUNT2 is not mounted
3904 elif [ "$MOUNT_2" ]; then
3905 restore_mount $MOUNT2
3906 export I_MOUNTED2=yes
3910 # FIXME: what to do if check_config failed?
3912 # 1) remote client has mounted other Lustre fs?
3913 # 2) lustre is mounted on remote_clients atall ?
3914 check_config_clients $MOUNT
3918 set_default_debug_nodes $(comma_list $(nodes_list))
3921 if [ $(lower $OSD_TRACK_DECLARES_LBUG) == 'yes' ] ; then
3923 [ "$(facet_fstype ost1)" = "ldiskfs" ] &&
3924 facets="$(get_facets OST)"
3925 [ "$(facet_fstype mds1)" = "ldiskfs" ] &&
3926 facets="$facets,$(get_facets MDS)"
3927 [ "$(facet_fstype mgs)" = "ldiskfs" ] &&
3928 facets="$facets,mgs"
3929 local nodes="$(facets_hosts ${facets})"
3930 if [ -n "$nodes" ] ; then
3931 do_nodes $nodes "$LCTL set_param \
3932 osd-ldiskfs.track_declares_assert=1 || true"
3941 #Enable remote MDT create for testing
3942 for num in $(seq $MDSCOUNT); do
3944 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
3948 if [ "$ONLY" == "setup" ]; then
3954 local clients=${CLIENTS:-$HOSTNAME}
3957 zconf_mount_clients $clients $mntpt
3961 local clients=${CLIENTS:-$HOSTNAME}
3964 zconf_umount_clients $clients $mntpt
3967 cleanup_and_setup_lustre() {
3968 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
3969 lctl set_param debug=0 || true
3971 if [ "$ONLY" == "cleanup" ]; then
3975 check_and_setup_lustre
3978 # Get all of the server target devices from a given server node and type.
3985 if [ "$type" == ost ]; then
3986 devs=$(get_osd_param $node "" mntdev)
3988 devs=$(do_node $node $LCTL get_param -n osd-*.$FSNAME-M*.mntdev)
3990 for dev in $devs; do
3992 *loop*) do_node $node "losetup $dev" | \
3993 sed -e "s/.*(//" -e "s/).*//" ;;
3999 # Get all of the server target devices.
4004 # Master MDS parameters used by lfsck
4005 MDTNODE=$(facet_active_host $SINGLEMDS)
4006 MDTDEV=$(echo $(get_mnt_devs $MDTNODE mdt) | awk '{print $1}')
4010 for node in $(mdts_nodes); do
4011 MDTDEVS[i]=$(get_mnt_devs $node mdt)
4017 for node in $(osts_nodes); do
4018 OSTDEVS[i]=$(get_mnt_devs $node ost)
4023 # Run e2fsck on MDT or OST device.
4028 local cmd="$E2FSCK -d -v -t -t -f $extra_opts $target_dev"
4029 local log=$TMP/e2fsck.log
4033 do_node $node $cmd 2>&1 | tee $log
4035 if [ -n "$(grep "DNE mode isn't supported" $log)" ]; then
4037 if [ $MDSCOUNT -gt 1 ]; then
4038 skip "DNE mode isn't supported!"
4042 error "It's not DNE mode."
4047 [ $rc -le $FSCK_MAX_ERR ] ||
4048 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4054 # Run resize2fs on MDT or OST device.
4063 do_facet $facet "$RESIZE2FS $opts $device $size"
4066 # verify a directory is shared among nodes.
4067 check_shared_dir() {
4069 local list=${2:-$(comma_list $(nodes_list))}
4071 [ -z "$dir" ] && return 1
4072 do_rpc_nodes "$list" check_logdir $dir
4073 check_write_access $dir "$list" || return 1
4077 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
4084 [[ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]] ||
4085 { skip "Lustre 2.2.0 lacks the patch for LU-1255"; exit 0; }
4087 check_shared_dir $SHARED_DIRECTORY ||
4088 error "$SHARED_DIRECTORY isn't a shared directory"
4090 export MDSDB=$SHARED_DIRECTORY/mdsdb
4091 export OSTDB=$SHARED_DIRECTORY/ostdb
4093 # DNE is not supported, so when running e2fsck on a DNE filesystem,
4094 # we only pass master MDS parameters.
4095 run_e2fsck $MDTNODE $MDTDEV "-n --mdsdb $MDSDB"
4100 for node in $(osts_nodes); do
4101 for dev in ${OSTDEVS[i]}; do
4102 run_e2fsck $node $dev "-n --mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
4103 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
4104 ostidx=$((ostidx + 1))
4110 # Run lfsck on server node if lfsck can't be found on client (LU-2571)
4111 run_lfsck_remote() {
4112 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
4117 #Check if lustre is already mounted
4118 do_rpc_nodes $client is_mounted $MOUNT || mounted=false
4120 zconf_mount $client $MOUNT ||
4121 error "failed to mount Lustre on $client"
4125 do_node $client $cmd || rc=$?
4126 #Umount if necessary
4128 zconf_umount $client $MOUNT ||
4129 error "failed to unmount Lustre on $client"
4132 [ $rc -le $FSCK_MAX_ERR ] ||
4133 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4134 echo "lfsck finished with rc=$rc"
4140 local facets="client $SINGLEMDS"
4146 for facet in $facets; do
4147 node=$(facet_active_host $facet)
4148 if check_progs_installed $node $LFSCK_BIN; then
4153 ! $found && error "None of \"$facets\" supports lfsck"
4155 run_lfsck_remote $node || rc=$?
4157 rm -rvf $MDSDB* $OSTDB* || true
4161 dump_file_contents() {
4167 if [ -z "$nodes" -o -z "$dir" -o -z "$logname" ]; then
4168 error_noexit false \
4169 "Invalid parameters for dump_file_contents()"
4172 for node in ${nodes}; do
4173 do_node $node "for i in \\\$(find $dir -type f); do
4174 echo ====\\\${i}=======================;
4176 done" >> ${logname}.${node}.log
4180 dump_command_output() {
4186 if [ -z "$nodes" -o -z "$cmd" -o -z "$logname" ]; then
4187 error_noexit false \
4188 "Invalid parameters for dump_command_output()"
4192 for node in ${nodes}; do
4193 do_node $node "echo ====${cmd}=======================;
4194 $cmd" >> ${logname}.${node}.log
4201 # dump file contents from /proc/spl in case of zfs test
4202 if [ "$(facet_fstype ost1)" = "zfs" ]; then
4203 dump_file_contents "$(osts_nodes)" "/proc/spl" "${logname}"
4204 dump_command_output \
4205 "$(osts_nodes)" "zpool events -v" "${logname}"
4208 if [ "$(facet_fstype $SINGLEMDS)" = "zfs" ]; then
4209 dump_file_contents "$(mdts_nodes)" "/proc/spl" "${logname}"
4210 dump_command_output \
4211 "$(mdts_nodes)" "zpool events -v" "${logname}"
4215 check_and_cleanup_lustre() {
4216 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
4222 if is_mounted $MOUNT; then
4223 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
4224 error "remove sub-test dirs failed"
4225 [ "$ENABLE_QUOTA" ] && restore_quota || true
4228 if [ "$I_UMOUNTED2" = "yes" ]; then
4229 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
4232 if [ "$I_MOUNTED2" = "yes" ]; then
4233 cleanup_mount $MOUNT2
4236 if [ "$I_MOUNTED" = "yes" ]; then
4237 cleanupall -f || error "cleanup failed"
4245 wait_for_function () {
4248 # suppress fn both stderr and stdout
4249 if [ "$1" = "--quiet" ]; then
4251 quiet=" > /dev/null 2>&1"
4263 eval $fn $quiet && return 0
4265 wait=$((wait + sleep))
4266 [ $wait -lt $max ] || return 1
4267 echo waiting $fn, $((max - wait)) secs left ...
4277 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
4278 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
4279 echo "Network not available!"
4283 echo `date +"%H:%M:%S (%s)"` network interface is UP
4291 # Convert a space-delimited list to a comma-delimited list. If the input is
4292 # only whitespace, ensure the output is empty (i.e. "") so [ -n $list ] works
4294 # echo is used to convert newlines to spaces, since it doesn't
4295 # introduce a trailing space as using "tr '\n' ' '" does
4296 echo $(tr -s " " "\n" <<< $* | sort -b -u) | tr ' ' ','
4302 echo $list | grep -qw $item
4305 # list, excluded are the comma separated lists
4306 exclude_items_from_list () {
4312 for item in ${excluded//,/ }; do
4313 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
4315 echo $(comma_list $list)
4318 # list, expand are the comma separated lists
4320 local list=${1//,/ }
4321 local expand=${2//,/ }
4324 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
4325 echo $(comma_list $expanded)
4328 testslist_filter () {
4329 local script=$LUSTRE/tests/${TESTSUITE}.sh
4331 [ -f $script ] || return 0
4333 local start_at=$START_AT
4334 local stop_at=$STOP_AT
4336 local var=${TESTSUITE//-/_}_START_AT
4337 [ x"${!var}" != x ] && start_at=${!var}
4338 var=${TESTSUITE//-/_}_STOP_AT
4339 [ x"${!var}" != x ] && stop_at=${!var}
4341 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
4342 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
4343 /^'${start_at}'$/ {flag = 0}
4344 {if (flag == 1) print $0}
4345 /^'${stop_at}'$/ { flag = 1 }'
4349 (cd `dirname $1`; echo $PWD/`basename $1`)
4353 local types=${1:-"OST MDS MGS"}
4357 for entry in $types; do
4358 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
4359 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
4362 MGS ) list="$list $name";;
4363 MDS|OST|AGT ) local count=${type}COUNT
4364 for ((i=1; i<=${!count}; i++)) do
4365 list="$list ${name}$i"
4367 * ) error "Invalid facet type"
4371 echo $(comma_list $list)
4374 ##################################
4375 # Adaptive Timeouts funcs
4378 # only check mds, we assume at_max is the same on all nodes
4379 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
4380 if [ $at_max -eq 0 ]; then
4391 # suppose that all ost-s have the same $at value set
4392 [ $facet != "ost" ] || facet=ost1
4394 do_facet $facet "lctl get_param -n $at"
4412 if [ $facet == "ost" ]; then
4413 facet=$(get_facets OST)
4414 elif [ $facet == "mds" ]; then
4415 facet=$(get_facets MDS)
4417 hosts=$(expand_list $hosts $(facets_hosts $facet))
4420 do_nodes $hosts lctl set_param at_max=$at_max
4423 ##################################
4427 # OBD_FAIL_MDS_ALL_REQUEST_NET
4429 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
4430 do_facet client "$1" || RC=$?
4431 do_facet $SINGLEMDS lctl set_param fail_loc=0
4436 # OBD_FAIL_MDS_ALL_REPLY_NET
4438 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x122
4440 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4444 drop_reint_reply() {
4445 # OBD_FAIL_MDS_REINT_NET_REP
4447 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x119
4449 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4453 drop_update_reply() {
4454 # OBD_FAIL_UPDATE_OBJ_NET_REP
4458 do_facet mds${index} lctl set_param fail_loc=0x1701
4459 do_facet client "$@" || RC=$?
4460 do_facet mds${index} lctl set_param fail_loc=0
4465 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4468 local timeout=${2:-0}
4469 # default is (obd_timeout / 4) if unspecified
4470 echo "timeout is $timeout/$2"
4471 do_facet ost1 lctl set_param fail_val=$timeout fail_loc=0x80000214
4472 do_facet client "$1" || RC=$?
4473 do_facet client "sync"
4474 do_facet ost1 lctl set_param fail_loc=0
4478 drop_ldlm_cancel() {
4479 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
4481 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4482 do_nodes $list lctl set_param fail_loc=0x304
4484 do_facet client "$@" || RC=$?
4486 do_nodes $list lctl set_param fail_loc=0
4490 drop_bl_callback_once() {
4492 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
4493 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
4494 do_facet client lctl set_param fail_loc=0x80000305
4495 do_facet client "$@" || rc=$?
4496 do_facet client lctl set_param fail_loc=0
4497 do_facet client lctl set_param fail_val=0
4498 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
4502 drop_bl_callback() {
4504 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
4505 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
4506 do_facet client lctl set_param fail_loc=0x305
4507 do_facet client "$@" || rc=$?
4508 do_facet client lctl set_param fail_loc=0
4509 do_facet client lctl set_param fail_val=0
4510 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
4515 #define OBD_FAIL_LDLM_REPLY 0x30c
4517 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4518 do_nodes $list lctl set_param fail_loc=0x30c
4520 do_facet client "$@" || RC=$?
4522 do_nodes $list lctl set_param fail_loc=0
4526 drop_ldlm_reply_once() {
4527 #define OBD_FAIL_LDLM_REPLY 0x30c
4529 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4530 do_nodes $list lctl set_param fail_loc=0x8000030c
4532 do_facet client "$@" || RC=$?
4534 do_nodes $list lctl set_param fail_loc=0
4542 echo "clearing fail_loc on $facet"
4543 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
4546 set_nodes_failloc () {
4547 do_nodes $(comma_list $1) lctl set_param fail_val=0 fail_loc=$2
4550 cancel_lru_locks() {
4551 $LCTL mark "cancel_lru_locks $1 start"
4553 if [ $1 != "MGC" ]; then
4554 for d in $(lctl get_param -N ldlm.namespaces.*.lru_size |
4556 $LCTL set_param -n $d=clear
4558 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 |
4562 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lru_size \
4568 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lock_unused_count \
4570 if [ $(cat $d) != 0 ]; then
4571 echo "ldlm.namespaces.$(echo "$d" |
4572 cut -f 7 -d'/').lock_unused_count=$(cat $d)"
4577 $LCTL mark "cancel_lru_locks $1 stop"
4582 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
4583 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
4584 echo "$DEFAULT_LRU_SIZE"
4589 lctl set_param ldlm.namespaces.*$1*.lru_size=0
4592 lru_resize_disable()
4594 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
4600 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] && RC=1
4606 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
4607 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
4608 echo there is still data in page cache $FILE ?
4609 lctl get_param -n $FILE
4617 DEBUGSAVE="$(lctl get_param -n debug)"
4621 [ -n "$DEBUGSAVE" ] && \
4622 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
4627 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
4630 debug_size_restore() {
4631 [ -n "$DEBUG_SIZE_SAVED" ] && \
4632 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
4636 start_full_debug_logging() {
4641 local DEBUG_SIZE=150
4643 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
4644 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
4647 stop_full_debug_logging() {
4652 # prints bash call stack
4653 print_stack_trace() {
4655 for (( i=1; i < ${#BASH_LINENO[*]} ; i++ )) ; do
4656 local s=${BASH_SOURCE[$i]}
4657 local l=${BASH_LINENO[$i-1]}
4658 local f=${FUNCNAME[$i]}
4659 echo " = $s:$l:$f()"
4663 ##################################
4665 ##################################
4668 local TYPE=${TYPE:-"FAIL"}
4671 # do not dump logs if $1=false
4672 if [ "x$1" = "xfalse" ]; then
4678 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
4679 print_stack_trace >&2
4682 # We need to dump the logs on all nodes
4684 gather_logs $(comma_list $(nodes_list))
4688 [ "$TESTSUITELOG" ] &&
4689 echo "$TESTSUITE: $TYPE: $TESTNAME $@" >> $TESTSUITELOG
4690 if [ -z "$*" ]; then
4691 echo "error() without useful message, please fix" > $LOGDIR/err
4693 if [[ `echo $TYPE | grep ^IGNORE` ]]; then
4694 echo "$@" > $LOGDIR/ignore
4696 echo "$@" > $LOGDIR/err
4703 local log=$TESTSUITELOG
4705 [ -f "$log" ] && grep -q FAIL $log && status=1
4718 # use only if we are ignoring failures for this test, bugno required.
4719 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
4720 # e.g. error_ignore bz5494 "your message" or
4721 # error_ignore LU-5494 "your message"
4723 local TYPE="IGNORE ($1)"
4728 error_and_remount() {
4730 remount_client $MOUNT
4735 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
4740 log " SKIP: $TESTSUITE $TESTNAME $@"
4742 if [[ -n "$ALWAYS_SKIPPED" ]]; then
4743 skip_logged $TESTNAME "$@"
4746 echo "$@" > $LOGDIR/skip
4749 [[ -n "$TESTSUITELOG" ]] &&
4750 echo "$TESTSUITE: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
4753 build_test_filter() {
4754 EXCEPT="$EXCEPT $(testslist_filter)"
4757 if [[ $O = [0-9]*-[0-9]* ]]; then
4758 for num in $(seq $(echo $O | tr '-' ' ')); do
4766 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
4767 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
4768 [ "$EXCEPT_SLOW" ] && \
4769 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
4770 for E in $EXCEPT; do
4771 eval EXCEPT_${E}=true
4773 for E in $ALWAYS_EXCEPT; do
4774 eval EXCEPT_ALWAYS_${E}=true
4776 for E in $EXCEPT_SLOW; do
4777 eval EXCEPT_SLOW_${E}=true
4779 for G in $GRANT_CHECK_LIST; do
4780 eval GCHECK_ONLY_${G}=true
4785 if [[ $1 = [a-z]* ]]; then
4792 # print a newline if the last test was skipped
4793 export LAST_SKIPPED=
4794 export ALWAYS_SKIPPED=
4796 # Main entry into test-framework. This is called with the name and
4797 # description of a test. The name is used to find the function to run
4798 # the test using "test_$name".
4800 # This supports a variety of methods of specifying specific test to
4801 # run or not run. These need to be documented...
4806 export base=$(basetest $1)
4807 if [ -n "$ONLY" ]; then
4809 if [ ${!testname}x != x ]; then
4810 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4811 run_one_logged $1 "$2"
4815 if [ ${!testname}x != x ]; then
4816 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4817 run_one_logged $1 "$2"
4827 if [ ${!testname}x != x ]; then
4828 TESTNAME=test_$1 skip "skipping excluded test $1"
4831 testname=EXCEPT_$base
4832 if [ ${!testname}x != x ]; then
4833 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
4836 testname=EXCEPT_ALWAYS_$1
4837 if [ ${!testname}x != x ]; then
4838 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
4841 testname=EXCEPT_ALWAYS_$base
4842 if [ ${!testname}x != x ]; then
4843 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
4846 testname=EXCEPT_SLOW_$1
4847 if [ ${!testname}x != x ]; then
4848 TESTNAME=test_$1 skip "skipping SLOW test $1"
4851 testname=EXCEPT_SLOW_$base
4852 if [ ${!testname}x != x ]; then
4853 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
4859 run_one_logged $1 "$2"
4866 module_loaded lnet || load_modules
4878 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
4883 strace -o $TMP/$1.strace -ttt $*
4885 log "FINISHED: $*: rc $RC"
4892 banner test complete, duration $duration sec
4893 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
4894 echo duration $duration >>$TESTSUITELOG
4898 # Set TEST_STATUS here. It will be used for logging the result.
4901 if [[ -f $LOGDIR/err ]]; then
4903 elif [[ -f $LOGDIR/skip ]]; then
4906 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
4910 local FFREE=$(do_node $SINGLEMDS \
4911 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
4912 local FTOTAL=$(do_node $SINGLEMDS \
4913 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
4915 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
4919 echo -n "Resetting fail_loc on all nodes..."
4920 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 \
4921 fail_val=0 2>/dev/null || true"
4927 # Log a message (on all nodes) padded with "=" before and after.
4928 # Also appends a timestamp and prepends the testsuite name.
4931 EQUALS="===================================================================================================="
4933 msg="== ${TESTSUITE} $*"
4935 [[ $last != "=" && $last != " " ]] && msg="$msg "
4936 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
4937 # always include at least == after the message
4938 log "$msg== $(date +"%H:%M:%S (%s)")"
4942 # Run a single test function and cleanup after it.
4944 # This function should be run in a subshell so the test func can
4945 # exit() without stopping the whole script.
4950 export tfile=f${testnum}.${TESTSUITE}
4951 export tdir=d${testnum}.${TESTSUITE}
4952 export TESTNAME=test_$testnum
4953 local SAVE_UMASK=`umask`
4956 banner "test $testnum: $message"
4957 test_${testnum} || error "test_$testnum failed with $?"
4960 check_grant ${testnum} || error "check_grant $testnum failed with $?"
4961 check_catastrophe || error "LBUG/LASSERT detected"
4962 if [ "$PARALLEL" != "yes" ]; then
4963 ps auxww | grep -v grep | grep -q multiop &&
4964 error "multiop still running"
4974 # Wrapper around run_one to ensure:
4975 # - test runs in subshell
4976 # - output of test is saved to separate log file for error reporting
4977 # - test result is saved to data file
4980 local BEFORE=$(date +%s)
4982 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
4983 local test_log=$LOGDIR/$name
4984 local zfs_log_name=${TESTSUITE}.test_${1}.zfs_log
4985 local zfs_debug_log=$LOGDIR/$zfs_log_name
4987 rm -rf $LOGDIR/ignore
4989 local SAVE_UMASK=$(umask)
4993 log_sub_test_begin test_${1}
4994 (run_one $1 "$2") 2>&1 | tee -i $test_log
4995 local RC=${PIPESTATUS[0]}
4997 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] &&
4998 echo "test_$1 returned $RC" | tee $LOGDIR/err
5000 duration=$(($(date +%s) - $BEFORE))
5001 pass "$1" "(${duration}s)"
5003 if [[ -f $LOGDIR/err ]]; then
5004 TEST_ERROR=$(cat $LOGDIR/err)
5005 elif [[ -f $LOGDIR/ignore ]]; then
5006 TEST_ERROR=$(cat $LOGDIR/ignore)
5007 elif [[ -f $LOGDIR/skip ]]; then
5008 TEST_ERROR=$(cat $LOGDIR/skip)
5010 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
5012 if [[ "$TEST_STATUS" != "SKIP" ]] && [[ -f $TF_SKIP ]]; then
5016 if [ -f $LOGDIR/err ]; then
5017 log_zfs_info "$zfs_debug_log"
5018 $FAIL_ON_ERROR && exit $RC
5027 # Print information of skipped tests to result.yml
5030 log_sub_test_begin $1
5032 log_sub_test_end "SKIP" "0" "0" "$@"
5036 (cd $(dirname $1); echo $PWD/$(basename $1))
5041 export base=$(basetest $1)
5042 [ "$CHECK_GRANT" == "no" ] && return 0
5044 testname=GCHECK_ONLY_${base}
5045 [ ${!testname}x == x ] && return 0
5047 echo -n "checking grant......"
5049 local clients=$CLIENTS
5050 [ -z "$clients" ] && clients=$(hostname)
5052 # sync all the data and make sure no pending data on server
5053 do_nodes $clients sync
5056 client_grant=$(do_nodes $clients \
5057 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" |
5058 awk '{ total += $1 } END { printf("%0.0f", total) }')
5061 server_grant=$(do_nodes $(comma_list $(osts_nodes)) \
5062 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" |
5063 awk '{ total += $1 } END { printf("%0.0f", total) }')
5065 # check whether client grant == server grant
5066 if [[ $client_grant -ne $server_grant ]]; then
5067 echo "failed: client:${client_grant} server: ${server_grant}."
5068 do_nodes $(comma_list $(osts_nodes)) \
5069 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
5070 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
5073 echo "pass: client:${client_grant} server: ${server_grant}"
5077 ########################
5083 ost=`echo $1 | awk -F_ '{print $3}'`
5084 if [ -z $ost ]; then
5085 ost=`echo $1 | sed 's/-osc.*//'`
5090 ostuuid_from_index()
5092 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5095 ostname_from_index() {
5096 local uuid=$(ostuuid_from_index $1)
5100 index_from_ostuuid()
5102 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
5105 mdtuuid_from_index()
5107 $LFS mdts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5111 # Return unique identifier for given hostname
5114 echo $host_name | md5sum | cut -d' ' -f1
5118 # Returns list of ip addresses for each interface
5120 ip addr | awk '/inet\ / {print $2}' | awk -F\/ '{print $1}'
5125 # Cache address list to avoid mutiple execution of local_addr_list
5126 LOCAL_ADDR_LIST=${LOCAL_ADDR_LIST:-$(local_addr_list)}
5128 for i in $LOCAL_ADDR_LIST ; do
5129 [[ "$i" == "$addr" ]] && return 0
5136 local is_local="IS_LOCAL_$(host_id $host_name)"
5137 if [ -z "${!is_local-}" ] ; then
5139 local host_ip=$($LUSTRE/tests/resolveip $host_name)
5140 is_local_addr "$host_ip" && eval $is_local=1
5142 [[ "${!is_local}" == "1" ]]
5147 local_node $node && return 1
5154 for node in $(mdts_nodes); do
5155 remote_node $node && return 0
5162 [ "$CLIENTONLY" ] && return 0 || true
5163 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
5168 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
5169 MSKIPPED=1 && return 1
5176 for node in $(osts_nodes) ; do
5177 remote_node $node && return 0
5184 [ "$CLIENTONLY" ] && return 0 || true
5185 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5190 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
5191 OSKIPPED=1 && return 1
5198 MGS=$(facet_host mgs)
5199 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5204 remote_mds_nodsh || remote_ost_nodsh || \
5205 $(single_local_node $(comma_list $(nodes_list)))
5209 remote_ost && remote_mds
5212 # Get the active nodes for facets.
5220 for facet in ${facets//,/ }; do
5221 nodes="$nodes $(facet_active_host $facet)"
5224 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5228 # Get all of the active MDS nodes.
5230 echo -n $(facets_nodes $(get_facets MDS))
5233 # Get all of the active OSS nodes.
5235 echo -n $(facets_nodes $(get_facets OST))
5238 # Get all of the active AGT (HSM agent) nodes.
5240 echo -n $(facets_nodes $(get_facets AGT))
5243 # Get all of the client nodes and active server nodes.
5245 local nodes=$HOSTNAME
5249 # CLIENTS (if specified) contains the local client
5250 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5252 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5253 nodes="$nodes $(facets_nodes $(get_facets))"
5256 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5260 # Get all of the remote client nodes and remote active server nodes.
5261 remote_nodes_list () {
5262 echo -n $(nodes_list) | sed -re "s/\<$HOSTNAME\>//g"
5265 # Get all of the MDS nodes, including active and passive nodes.
5273 for i in $(seq $MDSCOUNT); do
5275 failover_host=mds${i}failover_HOST
5276 nodes="$nodes ${!host} ${!failover_host}"
5279 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5283 # Get all of the OSS nodes, including active and passive nodes.
5291 for i in $(seq $OSTCOUNT); do
5293 failover_host=ost${i}failover_HOST
5294 nodes="$nodes ${!host} ${!failover_host}"
5297 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5301 # Get all of the server nodes, including active and passive nodes.
5302 all_server_nodes () {
5307 nodes="$mgs_HOST $mgsfailover_HOST $(all_mdts_nodes) $(all_osts_nodes)"
5309 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5313 # Get all of the client and server nodes, including active and passive nodes.
5315 local nodes=$HOSTNAME
5319 # CLIENTS (if specified) contains the local client
5320 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5322 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5323 nodes="$nodes $(all_server_nodes)"
5326 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5330 init_clients_lists () {
5331 # Sanity check: exclude the local client from RCLIENTS
5332 local clients=$(hostlist_expand "$RCLIENTS")
5333 local rclients=$(exclude_items_from_list "$clients" $HOSTNAME)
5335 # Sanity check: exclude the dup entries
5336 RCLIENTS=$(for i in ${rclients//,/ }; do echo $i; done | sort -u)
5338 clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
5340 # Sanity check: exclude the dup entries from CLIENTS
5341 # for those configs which has SINGLCLIENT set to local client
5342 clients=$(for i in $clients; do echo $i; done | sort -u)
5344 CLIENTS=$(comma_list $clients)
5345 local -a remoteclients=($RCLIENTS)
5346 for ((i=0; $i<${#remoteclients[@]}; i++)); do
5347 varname=CLIENT$((i + 2))
5348 eval $varname=${remoteclients[i]}
5351 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
5354 get_random_entry () {
5357 rnodes=${rnodes//,/ }
5359 local -a nodes=($rnodes)
5360 local num=${#nodes[@]}
5361 local i=$((RANDOM * num * 2 / 65536))
5367 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
5372 lctl get_param version | grep -q patchless
5376 [ "$(lustre_version_code client)" = "$(lustre_version_code $SINGLEMDS)" -a \
5377 "$(lustre_version_code client)" = "$(lustre_version_code ost1)" ]
5382 echo $nodes | wc -w || true
5386 local nodes=$(osts_nodes)
5387 local osscount=$(get_node_count "$nodes")
5388 [ ! "$OSTCOUNT" = "$osscount" ]
5392 local nodes=$(mdts_nodes)
5393 local mdtcount=$(get_node_count "$nodes")
5394 [ ! "$MDSCOUNT" = "$mdtcount" ]
5397 generate_machine_file() {
5398 local nodes=${1//,/ }
5399 local machinefile=$2
5401 for node in $nodes; do
5402 echo $node >>$machinefile || \
5403 { echo "can not generate machinefile $machinefile" && return 1; }
5408 local file=$1/stripe
5411 $LFS getstripe -v $file || error "getstripe $file failed"
5415 setstripe_nfsserver () {
5418 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
5419 { print $1 }' /proc/mounts | cut -f 1 -d : | head -n1)
5421 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
5423 do_nodev $nfsserver lfs setstripe "$@"
5426 # Check and add a test group.
5432 local gid=$(getent group $group_name | cut -d: -f3)
5433 if [[ -n "$gid" ]]; then
5434 [[ "$gid" -eq "$group_id" ]] || {
5435 error_noexit "inconsistent group ID:" \
5436 "new: $group_id, old: $gid"
5440 groupadd -g $group_id $group_name
5447 # Check and add a test user.
5460 local uid=$(getent passwd $user_name | cut -d: -f3)
5461 if [[ -n "$uid" ]]; then
5462 if [[ "$uid" -eq "$user_id" ]]; then
5463 local dir=$(getent passwd $user_name | cut -d: -f6)
5464 if [[ "$dir" != "$home" ]]; then
5466 usermod -d $home $user_name
5470 error_noexit "inconsistent user ID:" \
5471 "new: $user_id, old: $uid"
5476 useradd -M -u $user_id -d $home -g $group_name $opts $user_name
5483 check_runas_id_ret() {
5485 local myRUNAS_UID=$1
5486 local myRUNAS_GID=$2
5489 if [ -z "$myRUNAS" ]; then
5490 error_exit "myRUNAS command must be specified for check_runas_id"
5493 $myRUNAS krb5_login.sh || \
5494 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
5496 mkdir $DIR/d0_runas_test
5498 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
5499 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
5500 rm -rf $DIR/d0_runas_test
5505 local myRUNAS_UID=$1
5506 local myRUNAS_GID=$2
5509 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
5510 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
5511 Please set RUNAS_ID to some UID which exists on MDS and client or
5512 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
5515 # obtain the UID/GID for MPI_USER
5519 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
5520 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
5522 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
5523 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
5526 # obtain and cache Kerberos ticket-granting ticket
5527 refresh_krb5_tgt() {
5528 local myRUNAS_UID=$1
5529 local myRUNAS_GID=$2
5532 if [ -z "$myRUNAS" ]; then
5533 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
5536 CLIENTS=${CLIENTS:-$HOSTNAME}
5537 do_nodes $CLIENTS "set -x
5538 if ! $myRUNAS krb5_login.sh; then
5539 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
5544 # Run multiop in the background, but wait for it to print
5545 # "PAUSING" to its stdout before returning from this function.
5546 multiop_bg_pause() {
5547 MULTIOP_PROG=${MULTIOP_PROG:-$MULTIOP}
5551 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
5554 echo "$MULTIOP_PROG $FILE v$ARGS"
5555 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
5557 echo "TMPPIPE=${TMPPIPE}"
5558 read -t 60 multiop_output < $TMPPIPE
5559 if [ $? -ne 0 ]; then
5564 if [ "$multiop_output" != "PAUSING" ]; then
5565 echo "Incorrect multiop output: $multiop_output"
5580 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
5586 inodes_available () {
5587 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{ print $4 }' |
5588 sort -un | head -n1) || return 1
5592 mdsrate_inodes_available () {
5593 local min_inodes=$(inodes_available)
5594 echo $((min_inodes * 99 / 100))
5597 # reset llite stat counters
5598 clear_llite_stats(){
5599 lctl set_param -n llite.*.stats 0
5602 # sum llite stat items
5603 calc_llite_stats() {
5604 local res=$(lctl get_param -n llite.*.stats |
5605 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5609 # reset osc stat counters
5611 lctl set_param -n osc.*.osc_stats 0
5614 # sum osc stat items
5616 local res=$(lctl get_param -n osc.*.osc_stats |
5617 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5622 awk '{sum += $1} END { printf("%0.0f", sum) }'
5625 calc_osc_kbytes () {
5626 df $MOUNT > /dev/null
5627 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
5630 # save_lustre_params(comma separated facet list, parameter_mask)
5631 # generate a stream of formatted strings (<facet> <param name>=<param value>)
5632 save_lustre_params() {
5638 for facet in ${facets//,/ }; do
5639 node=$(facet_active_host $facet)
5640 [[ *\ $node\ * = " $nodes " ]] && continue
5641 nodes="$nodes $node"
5643 do_node $node "$LCTL get_param $2 |
5644 while read s; do echo $facet \\\$s; done"
5648 # restore lustre parameters from input stream, produces by save_lustre_params
5649 restore_lustre_params() {
5654 while IFS=" =" read facet name val; do
5655 do_facet $facet "$LCTL set_param -n $name $val"
5659 check_catastrophe() {
5660 local nodes=${1:-$(comma_list $(nodes_list))}
5662 do_nodes $nodes "rc=0;
5663 val=\\\$($LCTL get_param -n catastrophe 2>&1);
5664 if [[ \\\$? -eq 0 && \\\$val -ne 0 ]]; then
5665 echo \\\$(hostname -s): \\\$val;
5671 mdsrate_cleanup () {
5673 mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \
5674 --nfiles $3 --dir $4 --filefmt $5 $6
5679 delayed_recovery_enabled () {
5680 local var=${SINGLEMDS}_svc
5681 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
5684 ########################
5686 convert_facet2label() {
5689 if [ x$facet = xost ]; then
5693 local varsvc=${facet}_svc
5695 if [ -n ${!varsvc} ]; then
5698 error "No lablel for $facet!"
5702 get_clientosc_proc_path() {
5706 get_lustre_version () {
5707 local facet=${1:-"$SINGLEMDS"}
5708 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
5711 lustre_version_code() {
5712 local facet=${1:-"$SINGLEMDS"}
5713 version_code $(get_lustre_version $1)
5716 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
5717 # used by MDT would not be changed.
5718 # mdt lov: fsname-mdtlov
5719 # mdt osc: fsname-OSTXXXX-osc
5720 mds_on_old_device() {
5721 local mds=${1:-"$SINGLEMDS"}
5723 if [ $(lustre_version_code $mds) -gt $(version_code 1.9.0) ]; then
5724 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
5725 > /dev/null 2>&1" && return 0
5730 get_mdtosc_proc_path() {
5732 local ost_label=${2:-"*OST*"}
5734 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
5735 local mdt_label=$(convert_facet2label $mds_facet)
5736 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
5738 if [ $(lustre_version_code $mds_facet) -le $(version_code 1.8.0) ] ||
5739 mds_on_old_device $mds_facet; then
5740 echo "${ost_label}-osc"
5742 echo "${ost_label}-osc-${mdt_index}"
5746 get_osc_import_name() {
5749 local label=$(convert_facet2label $ost)
5751 if [ "${facet:0:3}" = "mds" ]; then
5752 get_mdtosc_proc_path $facet $label
5756 get_clientosc_proc_path $label
5760 _wait_import_state () {
5763 local maxtime=${3:-$(max_recovery_time)}
5767 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5768 while [ "${CONN_STATE}" != "${expected}" ]; do
5769 if [ "${expected}" == "DISCONN" ]; then
5770 # for disconn we can check after proc entry is removed
5771 [ "x${CONN_STATE}" == "x" ] && return 0
5772 # with AT enabled, we can have connect request timeout near of
5773 # reconnect timeout and test can't see real disconnect
5774 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
5776 [ $i -ge $maxtime ] && \
5777 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
5780 # Add uniq for multi-mount case
5781 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5785 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
5789 wait_import_state() {
5792 local maxtime=${3:-$(max_recovery_time)}
5795 for param in ${params//,/ }; do
5796 _wait_import_state $state $param $maxtime || return
5800 wait_import_state_mount() {
5801 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
5805 wait_import_state $*
5808 # One client request could be timed out because server was not ready
5809 # when request was sent by client.
5810 # The request timeout calculation details :
5812 # /* We give the server rq_timeout secs to process the req, and
5813 # add the network latency for our local timeout. */
5814 # request->rq_deadline = request->rq_sent + request->rq_timeout +
5815 # ptlrpc_at_get_net_latency(request) ;
5817 # ptlrpc_connect_import ()
5818 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5821 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
5822 # ptlrpc_at_get_net_latency(request) ->
5823 # at_get (max (iat_net_latency=0, at_min)) = at_min
5826 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
5827 # INITIAL_CONNECT_TIMEOUT + at_min
5829 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
5830 # because we can not get this value in runtime,
5831 # the value depends on configure options, and it is not stored in /proc.
5833 # #define CONNECTION_SWITCH_MIN 5U
5834 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
5836 request_timeout () {
5839 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5840 local init_connect_timeout=$TIMEOUT
5841 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
5843 local at_min=$(at_get $facet at_min)
5845 echo $(( init_connect_timeout + at_min ))
5848 _wait_osc_import_state() {
5852 local ost=$(get_osc_import_name $facet $ost_facet)
5853 local param="osc.${ost}.ost_server_uuid"
5857 # 1. wait the deadline of client 1st request (it could be skipped)
5858 # 2. wait the deadline of client 2nd request
5859 local maxtime=$(( 2 * $(request_timeout $facet)))
5861 if [[ $facet == client* ]]; then
5862 # During setup time, the osc might not be setup, it need wait
5863 # until list_param can return valid value. And also if there
5864 # are mulitple osc entries we should list all of them before
5866 params=$($LCTL list_param $param 2>/dev/null || true)
5867 while [ -z "$params" ]; do
5868 if [ $i -ge $maxtime ]; then
5869 echo "can't get $param in $maxtime secs"
5874 params=$($LCTL list_param $param 2>/dev/null || true)
5877 if ! do_rpc_nodes "$(facet_active_host $facet)" \
5878 wait_import_state $expected "$params" $maxtime; then
5879 error "import is not in ${expected} state"
5886 wait_osc_import_state() {
5892 if [[ $facet = mds ]]; then
5893 for num in $(seq $MDSCOUNT); do
5894 _wait_osc_import_state mds$num "$ost_facet" "$expected"
5897 _wait_osc_import_state "$facet" "$ost_facet" "$expected"
5901 get_clientmdc_proc_path() {
5909 [ -z "$list" ] && return 0
5911 # Add paths to lustre tests for 32 and 64 bit systems.
5912 local LIBPATH="/usr/lib/lustre/tests:/usr/lib64/lustre/tests:"
5913 local TESTPATH="$RLUSTRE/tests:"
5914 local RPATH="PATH=${TESTPATH}${LIBPATH}${PATH}:/sbin:/bin:/usr/sbin:"
5915 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
5918 wait_clients_import_state () {
5925 if [ "$FAILURE_MODE" = HARD ]; then
5926 facets=$(facets_on_host $(facet_active_host $facet))
5929 for facet in ${facets//,/ }; do
5930 local label=$(convert_facet2label $facet)
5933 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
5934 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
5935 *) error "unknown facet!" ;;
5937 local params=$(expand_list $params $proc_path)
5940 if ! do_rpc_nodes "$list" wait_import_state_mount $expected $params; then
5941 error "import is not in ${expected} state"
5951 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
5952 $LCTL get_param obdfilter.*.kbytesavail))
5953 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
5954 $LCTL get_param -n obdfilter.*.tot_granted))
5955 TOTALA=($(do_nodes $(comma_list $(osts_nodes)) \
5956 $LCTL get_param -n obdfilter.*.kbytestotal))
5957 for ((i=0; i<${#AVAILA[@]}; i++)); do
5958 local -a AVAIL1=(${AVAILA[$i]//=/ })
5959 local -a TOTAL=(${TOTALA[$i]//=/ })
5960 GRANT=$((${GRANTA[$i]}/1024))
5961 # allow 1% of total space in bavail because of delayed
5962 # allocation with ZFS which might release some free space after
5963 # txg commit. For small devices, we set a mininum of 8MB
5964 local LIMIT=$((${TOTAL} / 100 + 8000))
5965 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} \
5966 grnt=$GRANT diff=$((AVAIL1[1] - GRANT)) limit=${LIMIT}
5967 [ $((AVAIL1[1] - GRANT)) -lt $LIMIT ] && OSCFULL=0 && \
5968 echo " FULL" || echo
5974 do_facet mgs lctl pool_list $1
5978 local fsname=${1%%.*}
5979 local poolname=${1##$fsname.}
5981 do_facet mgs lctl pool_new $1
5983 # get param should return err unless pool is created
5984 [[ $RC -ne 0 ]] && return $RC
5986 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
5987 2>/dev/null || echo foo" "" || RC=1
5988 if [[ $RC -eq 0 ]]; then
5991 error "pool_new failed $1"
5996 add_pool_to_list () {
5997 local fsname=${1%%.*}
5998 local poolname=${1##$fsname.}
6000 local listvar=${fsname}_CREATED_POOLS
6001 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
6004 remove_pool_from_list () {
6005 local fsname=${1%%.*}
6006 local poolname=${1##$fsname.}
6008 local listvar=${fsname}_CREATED_POOLS
6009 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
6012 destroy_pool_int() {
6014 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
6015 awk '$1 !~ /^Pool:/ {print $1}')
6016 for ost in $OSTS; do
6017 do_facet mgs lctl pool_remove $1 $ost
6019 do_facet mgs lctl pool_destroy $1
6022 # <fsname>.<poolname> or <poolname>
6024 local fsname=${1%%.*}
6025 local poolname=${1##$fsname.}
6027 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
6031 pool_list $fsname.$poolname || return $?
6033 destroy_pool_int $fsname.$poolname
6035 [[ $RC -ne 0 ]] && return $RC
6037 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
6038 2>/dev/null || echo foo" "foo" || RC=1
6040 if [[ $RC -eq 0 ]]; then
6041 remove_pool_from_list $fsname.$poolname
6043 error "destroy pool failed $1"
6049 local fsname=${1:-$FSNAME}
6051 local listvar=${fsname}_CREATED_POOLS
6055 [ x${!listvar} = x ] && return 0
6057 echo destroy the created pools: ${!listvar}
6058 for poolname in ${!listvar//,/ }; do
6059 destroy_pool $fsname.$poolname
6064 local fsname=${1:-$FSNAME}
6066 destroy_pools $fsname
6072 local ts=$(date +%s)
6075 if [[ ! -f "$YAML_LOG" ]]; then
6076 # init_logging is not performed before gather_logs,
6077 # so the $LOGDIR needs to be checked here
6078 check_shared_dir $LOGDIR && touch $LOGDIR/shared
6081 [ -f $LOGDIR/shared ] && docp=false
6083 # dump lustre logs, dmesg
6085 prefix="$TESTLOG_PREFIX.$TESTNAME"
6087 echo "Dumping lctl log to ${prefix}.*.${suffix}"
6089 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
6090 echo "Dumping logs only on local client."
6091 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
6092 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
6097 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
6098 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
6099 if [ ! -f $LOGDIR/shared ]; then
6100 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
6113 for i in $(seq 0 $num_mntpts); do
6114 cmd="ls -laf ${mntpt_root}$i/$dir"
6120 for pid in $pids; do
6127 # check_and_start_recovery_timer()
6128 # service_time = at_est2timeout(service_time);
6129 # service_time += 2 * INITIAL_CONNECT_TIMEOUT;
6130 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC);
6132 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN, obd_timeout/20)
6133 #define CONNECTION_SWITCH_MAX min(50, max(CONNECTION_SWITCH_MIN, obd_timeout))
6134 #define CONNECTION_SWITCH_MIN 5
6135 #define CONNECTION_SWITCH_INC 5
6136 max_recovery_time() {
6137 local init_connect_timeout=$((TIMEOUT / 20))
6138 ((init_connect_timeout >= 5)) || init_connect_timeout=5
6140 local service_time=$(($(at_max_get client) * 9 / 4 + 5))
6141 service_time=$((service_time + 2 * (init_connect_timeout + 50 + 5)))
6143 echo -n $service_time
6146 get_clients_mount_count () {
6147 local clients=${CLIENTS:-`hostname`}
6149 # we need to take into account the clients mounts and
6150 # exclude mds/ost mounts if any;
6151 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
6155 PROC_CLI="srpc_info"
6163 if [ $M -lt $N ]; then
6167 while [ $N -lt $M ]; do
6177 calc_connection_cnt() {
6180 # MDT->MDT = 2 * C(M, 2)
6184 comb_m2=$(combination $MDSCOUNT 2)
6186 local num_clients=$(get_clients_mount_count)
6188 local cnt_mdt2mdt=$((comb_m2 * 2))
6189 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
6190 local cnt_cli2ost=$((num_clients * OSTCOUNT))
6191 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
6192 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
6193 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
6194 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
6208 local cmd="$tgt.srpc.flavor"
6210 if [ $net == "any" ]; then
6215 if [ $dir != "any" ]; then
6220 log "Setting sptlrpc rule: $cmd"
6221 do_facet mgs "$LCTL conf_param $cmd"
6230 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
6231 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
6233 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
6235 if [ "x$bulkspec" != "x" ]; then
6236 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
6238 if [ "x$algs" != "x" ]; then
6239 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
6241 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
6242 if [ $bulk == "bulkn" ]; then
6243 bulk_count=`echo "$output" | grep "bulk flavor" \
6244 | grep "null/null" | wc -l`
6245 elif [ $bulk == "bulki" ]; then
6246 bulk_count=`echo "$output" | grep "bulk flavor" \
6247 | grep "/null" | grep -v "null/" | wc -l`
6249 bulk_count=`echo "$output" | grep "bulk flavor" \
6250 | grep -v "/null" | grep -v "null/" | wc -l`
6254 [ $bulk_count -lt $count ] && count=$bulk_count
6265 local clients=${CLIENTS:-`hostname`}
6267 for c in ${clients//,/ }; do
6268 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
6269 tmpcnt=`count_flvr "$output" $flavor`
6270 cnt=$((cnt + tmpcnt))
6280 local clients=${CLIENTS:-`hostname`}
6282 for c in ${clients//,/ }; do
6283 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
6284 tmpcnt=`count_flvr "$output" $flavor`
6285 cnt=$((cnt + tmpcnt))
6295 if [ $MDSCOUNT -le 1 ]; then
6300 for num in `seq $MDSCOUNT`; do
6301 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
6302 tmpcnt=`count_flvr "$output" $flavor`
6303 cnt=$((cnt + tmpcnt))
6314 for num in `seq $MDSCOUNT`; do
6315 mdtosc=$(get_mdtosc_proc_path mds$num)
6316 mdtosc=${mdtosc/-MDT*/-MDT\*}
6317 output=$(do_facet mds$num lctl get_param -n \
6318 osc.$mdtosc.$PROC_CLI 2>/dev/null)
6319 tmpcnt=`count_flvr "$output" $flavor`
6320 cnt=$((cnt + tmpcnt))
6329 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
6330 count_flvr "$output" $flavor
6335 local dir=$1 # from to
6336 local flavor=$2 # flavor expected
6339 if [ $dir == "cli2mdt" ]; then
6340 res=`flvr_cnt_cli2mdt $flavor`
6341 elif [ $dir == "cli2ost" ]; then
6342 res=`flvr_cnt_cli2ost $flavor`
6343 elif [ $dir == "mdt2mdt" ]; then
6344 res=`flvr_cnt_mdt2mdt $flavor`
6345 elif [ $dir == "mdt2ost" ]; then
6346 res=`flvr_cnt_mdt2ost $flavor`
6347 elif [ $dir == "all2ost" ]; then
6348 res1=`flvr_cnt_mdt2ost $flavor`
6349 res2=`flvr_cnt_cli2ost $flavor`
6350 res=$((res1 + res2))
6351 elif [ $dir == "all2mdt" ]; then
6352 res1=`flvr_cnt_mdt2mdt $flavor`
6353 res2=`flvr_cnt_cli2mdt $flavor`
6354 res=$((res1 + res2))
6355 elif [ $dir == "all2all" ]; then
6356 res1=`flvr_cnt_mdt2ost $flavor`
6357 res2=`flvr_cnt_cli2ost $flavor`
6358 res3=`flvr_cnt_mdt2mdt $flavor`
6359 res4=`flvr_cnt_cli2mdt $flavor`
6360 res=$((res1 + res2 + res3 + res4))
6368 local dir=$1 # from to
6369 local flavor=$2 # flavor expected
6370 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
6374 for ((i=0;i<20;i++)); do
6375 echo -n "checking $dir..."
6376 res=$(do_check_flavor $dir $flavor)
6377 echo "found $res/$expect $flavor connections"
6378 [ $res -ge $expect ] && return 0
6382 echo "Error checking $flavor of $dir: expect $expect, actual $res"
6386 restore_to_default_flavor()
6388 local proc="mgs.MGS.live.$FSNAME"
6390 echo "restoring to default flavor..."
6392 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6394 # remove all existing rules if any
6395 if [ $nrule -ne 0 ]; then
6396 echo "$nrule existing rules"
6397 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
6398 echo "remove rule: $rule"
6399 spec=`echo $rule | awk -F = '{print $1}'`
6400 do_facet mgs "$LCTL conf_param -d $spec"
6404 # verify no rules left
6405 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6406 [ $nrule -ne 0 ] && error "still $nrule rules left"
6408 # wait for default flavor to be applied
6409 # currently default flavor for all connections are 'null'
6410 wait_flavor all2all null
6411 echo "now at default flavor settings"
6416 local flavor=${1:-null}
6418 echo "setting all flavor to $flavor"
6420 # FIXME need parameter to this fn
6421 # and remove global vars
6422 local cnt_all2all=$(calc_connection_cnt all2all)
6424 local res=$(do_check_flavor all2all $flavor)
6425 if [ $res -eq $cnt_all2all ]; then
6426 echo "already have total $res $flavor connections"
6430 echo "found $res $flavor out of total $cnt_all2all connections"
6431 restore_to_default_flavor
6433 [[ $flavor = null ]] && return 0
6435 set_rule $FSNAME any any $flavor
6436 wait_flavor all2all $flavor
6442 # Checking for shared logdir
6443 if [ ! -d $dir ]; then
6444 # Not found. Create local logdir
6447 touch $dir/check_file.$(hostname -s)
6452 check_write_access() {
6454 local list=${2:-$(comma_list $(nodes_list))}
6458 for node in ${list//,/ }; do
6459 file=$dir/check_file.$(short_nodename $node)
6460 if [[ ! -f "$file" ]]; then
6461 # Logdir not accessible/writable from this node.
6464 rm -f $file || return 1
6470 if [[ -n $YAML_LOG ]]; then
6473 local SAVE_UMASK=`umask`
6476 export YAML_LOG=${LOGDIR}/results.yml
6480 if [ ! -f $YAML_LOG ]; then # If the yaml log already exists then we will just append to it
6481 if check_shared_dir $LOGDIR; then
6482 touch $LOGDIR/shared
6483 echo "Logging to shared log directory: $LOGDIR"
6485 echo "Logging to local directory: $LOGDIR"
6488 yml_nodes_file $LOGDIR >> $YAML_LOG
6489 yml_results_file >> $YAML_LOG
6496 yml_log_test $1 >> $YAML_LOG
6500 yml_log_test_status $@ >> $YAML_LOG
6503 log_sub_test_begin() {
6504 yml_log_sub_test_begin "$@" >> $YAML_LOG
6507 log_sub_test_end() {
6508 yml_log_sub_test_end "$@" >> $YAML_LOG
6514 local llverdev_opts=$2
6515 local devname=$(basename $1)
6516 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
6517 # loop devices aren't in /proc/partitions
6518 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
6520 size=$(($size / 1024 / 1024)) # Gb
6522 local partial_arg=""
6523 # Run in partial (fast) mode if the size
6524 # of a partition > 1 GB
6525 [ $size -gt 1 ] && partial_arg="-p"
6527 llverdev --force $partial_arg $llverdev_opts $dev
6533 local llverfs_opts=$2
6534 local use_partial_arg=$3
6535 local partial_arg=""
6536 local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
6538 # Run in partial (fast) mode if the size
6539 # of a partition > 1 GB
6540 [ "x$use_partial_arg" != "xno" ] && [ $size -gt 1 ] && partial_arg="-p"
6542 llverfs $partial_arg $llverfs_opts $dir
6545 #Remove objects from OST
6546 remove_ost_objects() {
6552 local mntpt=$(facet_mntpt $facet)
6553 local opts=$OST_MOUNT_OPTS
6557 echo "removing objects from $ostdev on $facet: $objids"
6558 if ! test -b $ostdev; then
6559 opts=$(csa_add "$opts" -o loop)
6561 mount -t $(facet_fstype $facet) $opts $ostdev $mntpt ||
6564 for i in $objids; do
6565 rm $mntpt/O/$group/d$((i % 32))/$i || { rc=$?; break; }
6567 umount -f $mntpt || return $?
6571 #Remove files from MDT
6572 remove_mdt_files() {
6577 local mntpt=$(facet_mntpt $facet)
6578 local opts=$MDS_MOUNT_OPTS
6580 echo "removing files from $mdtdev on $facet: $files"
6581 if [ $(facet_fstype $facet) == ldiskfs ] &&
6582 ! do_facet $facet test -b $mdtdev; then
6583 opts=$(csa_add "$opts" -o loop)
6585 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6589 rm $mntpt/ROOT/$f || { rc=$?; break; }
6591 umount -f $mntpt || return $?
6595 duplicate_mdt_files() {
6600 local mntpt=$(facet_mntpt $facet)
6601 local opts=$MDS_MOUNT_OPTS
6603 echo "duplicating files on $mdtdev on $facet: $files"
6604 mkdir -p $mntpt || return $?
6605 if [ $(facet_fstype $facet) == ldiskfs ] &&
6606 ! do_facet $facet test -b $mdtdev; then
6607 opts=$(csa_add "$opts" -o loop)
6609 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6620 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
6621 pushd $mntpt/ROOT > /dev/null || return $?
6624 touch $f.bad || return $?
6625 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
6627 [ $rc -eq 0 ] || return $rc
6628 setfattr --restore $tmp || return $?
6634 local devs=${1//,/ }
6637 local rslt=$TMP/sgpdd_survey
6639 # sgpdd-survey cleanups ${rslt}.* files
6641 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
6647 # returns the canonical name for an ldiskfs device
6652 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
6653 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
6654 echo dm-\\\${foo##*:};
6656 echo \\\$(basename \\\$dv);
6660 is_sanity_benchmark() {
6661 local benchmarks="dbench bonnie iozone fsx"
6663 for b in $benchmarks; do
6664 if [ "$b" == "$suite" ]; then
6672 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
6676 # Get the available size (KB) of a given obd target.
6683 [[ $facet != client ]] || return 0
6685 size=$(do_facet $facet $LCTL get_param -n *.$obd.kbytesavail | head -n1)
6690 # Get the page size (bytes) on a given facet node.
6696 size=$(do_facet $facet getconf PAGE_SIZE)
6697 [[ ${PIPESTATUS[0]} = 0 && -n "$size" ]] || size=4096
6702 # Get the block count of the filesystem.
6709 count=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6710 awk '/^Block count:/ {print $3}')
6714 # Get the block size of the filesystem.
6720 size=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6721 awk '/^Block size:/ {print $3}')
6725 # Check whether the "large_xattr" feature is enabled or not.
6726 large_xattr_enabled() {
6727 [[ $(facet_fstype $SINGLEMDS) == zfs ]] && return 0
6729 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6731 do_facet $SINGLEMDS "$DUMPE2FS -h $mds_dev 2>&1 |
6732 grep -E -q '(ea_inode|large_xattr)'"
6733 return ${PIPESTATUS[0]}
6736 # Get the maximum xattr size supported by the filesystem.
6740 if large_xattr_enabled; then
6741 # include/linux/limits.h: #define XATTR_SIZE_MAX 65536
6744 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6745 local block_size=$(get_block_size $SINGLEMDS $mds_dev)
6747 # maximum xattr size = size of block - size of header -
6748 # size of 1 entry - 4 null bytes
6749 size=$((block_size - 32 - 32 - 4))
6755 # Dump the value of the named xattr from a file.
6760 echo "$(getfattr -n $xattr_name --absolute-names --only-values $file)"
6763 # Generate a string with size of $size bytes.
6765 local size=${1:-1024} # in bytes
6767 echo "$(head -c $size < /dev/zero | tr '\0' y)"
6770 reformat_external_journal() {
6773 if [ ! -z ${EJOURNAL} ]; then
6774 local rcmd="do_facet $facet"
6776 echo "reformat external journal on $facet:${EJOURNAL}"
6777 ${rcmd} mke2fs -O journal_dev ${EJOURNAL} || return 1
6781 # MDT file-level backup/restore
6782 mds_backup_restore() {
6785 local devname=$(mdsdevname $(facet_number $facet))
6786 local mntpt=$(facet_mntpt brpt)
6787 local rcmd="do_facet $facet"
6788 local metaea=${TMP}/backup_restore.ea
6789 local metadata=${TMP}/backup_restore.tgz
6790 local opts=${MDS_MOUNT_OPTS}
6791 local svc=${facet}_svc
6793 if ! ${rcmd} test -b ${devname}; then
6794 opts=$(csa_add "$opts" -o loop)
6797 echo "file-level backup/restore on $facet:${devname}"
6799 # step 1: build mount point
6800 ${rcmd} mkdir -p $mntpt
6801 # step 2: cleanup old backup
6802 ${rcmd} rm -f $metaea $metadata
6804 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6805 if [ ! -z $igif ]; then
6806 # step 3.5: rm .lustre
6807 ${rcmd} rm -rf $mntpt/ROOT/.lustre || return 1
6809 # step 4: backup metaea
6811 ${rcmd} "cd $mntpt && getfattr -R -d -m '.*' -P . > $metaea && cd -" ||
6813 # step 5: backup metadata
6815 ${rcmd} tar zcf $metadata -C $mntpt/ . > /dev/null 2>&1 || return 3
6817 ${rcmd} umount -d $mntpt || return 4
6818 # step 7: reformat external journal if needed
6819 reformat_external_journal $facet || return 5
6820 # step 8: reformat dev
6821 echo "reformat new device"
6822 add $facet $(mkfs_opts $facet ${devname}) --backfstype ldiskfs \
6823 --reformat ${devname} $(mdsvdevname $(facet_number $facet)) \
6824 > /dev/null || exit 6
6826 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 7
6827 # step 10: restore metadata
6829 ${rcmd} tar zxfp $metadata -C $mntpt > /dev/null 2>&1 || return 8
6830 # step 11: restore metaea
6832 ${rcmd} "cd $mntpt && setfattr --restore=$metaea && cd - " || return 9
6833 # step 12: remove recovery logs
6834 echo "remove recovery logs"
6835 ${rcmd} rm -fv $mntpt/OBJECTS/* $mntpt/CATALOGS
6836 # step 13: umount dev
6837 ${rcmd} umount -d $mntpt || return 10
6838 # step 14: cleanup tmp backup
6839 ${rcmd} rm -f $metaea $metadata
6840 # step 15: reset device label - it's not virgin on
6841 ${rcmd} e2label $devname ${!svc}
6848 local devname=$(mdsdevname $(facet_number $facet))
6849 local mntpt=$(facet_mntpt brpt)
6850 local rcmd="do_facet $facet"
6851 local opts=${MDS_MOUNT_OPTS}
6853 if ! ${rcmd} test -b ${devname}; then
6854 opts=$(csa_add "$opts" -o loop)
6857 echo "removing OI files on $facet: idx=${idx}"
6859 # step 1: build mount point
6860 ${rcmd} mkdir -p $mntpt
6862 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6863 if [ -z $idx ]; then
6864 # step 3: remove all OI files
6865 ${rcmd} rm -fv $mntpt/oi.16*
6866 elif [ $idx -lt 2 ]; then
6867 ${rcmd} rm -fv $mntpt/oi.16.${idx}
6871 # others, rm oi.16.[idx, idx * idx, idx ** ...]
6872 for ((i=${idx}; i<64; i=$((i * idx)))); do
6873 ${rcmd} rm -fv $mntpt/oi.16.${i}
6877 ${rcmd} umount -d $mntpt || return 2
6878 # OI files will be recreated when mounted as lustre next time.
6881 # generate maloo upload-able log file name
6882 # \param logname specify unique part of file name
6883 generate_logname() {
6884 local logname=${1:-"default_logname"}
6886 echo "$TESTLOG_PREFIX.$TESTNAME.$logname.$(hostname -s).log"
6889 # make directory on different MDTs
6893 local stripe_count=2
6894 local stripe_index=-1
6897 while getopts "c:i:p" opt; do
6899 c) stripe_count=$OPTARG;;
6900 i) stripe_index=$OPTARG;;
6902 \?) error "only support -i -c -p";;
6906 shift $((OPTIND - 1))
6907 [ $# -eq 1 ] || error "Only creating single directory is supported"
6910 if [ "$p_option" == "-p" ]; then
6911 local parent=$(dirname $path)
6913 [ -d $path ] && return 0
6914 [ ! -d ${parent} ] && mkdir -p ${parent}
6917 if [ $MDSCOUNT -le 1 ]; then
6920 local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
6923 if [ $stripe_index -eq -1 ]; then
6924 mdt_index=$((test_num % MDSCOUNT))
6926 mdt_index=$stripe_index
6928 echo "striped dir -i$mdt_index -c$stripe_count $path"
6929 $LFS setdirstripe -i$mdt_index -c$stripe_count $path
6933 # find the smallest and not in use file descriptor
6936 local max_fd=$(ulimit -n)
6938 while [[ $fd -le $max_fd && -e /proc/self/fd/$fd ]]; do
6941 [ $fd -lt $max_fd ] || error "finding free file descriptor failed"
6945 check_mount_and_prep()
6947 is_mounted $MOUNT || setupall
6949 rm -rf $DIR/[df][0-9]* || error "Fail to cleanup the env!"
6950 mkdir $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
6951 for idx in $(seq $MDSCOUNT); do
6952 local name="MDT$(printf '%04x' $((idx - 1)))"
6953 rm -rf $MOUNT/.lustre/lost+found/$name/*
6957 # calcule how many ost-objects to be created.
6958 precreated_ost_obj_count()
6962 local mdt_name="MDT$(printf '%04x' $mdt_idx)"
6963 local ost_name="OST$(printf '%04x' $ost_idx)"
6964 local proc_path="${FSNAME}-${ost_name}-osc-${mdt_name}"
6965 local last_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
6966 osp.$proc_path.prealloc_last_id)
6967 local next_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
6968 osp.$proc_path.prealloc_next_id)
6969 echo $((last_id - next_id + 1))
6972 check_file_in_pool()
6977 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
6980 for t in $tlist ; do
6981 [ "$i" -eq "$t" ] && continue 2
6984 echo "pool list: $tlist"
6985 echo "striping: $res"
6986 error_noexit "$file not allocated in $pool"
6993 echo "Creating new pool"
6996 create_pool $FSNAME.$pool ||
6997 { error_noexit "No pool created, result code $?"; return 1; }
6998 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
6999 { error_noexit "$pool not in lfs pool_list"; return 2; }
7002 pool_add_targets() {
7003 echo "Adding targets to pool"
7009 local list=$(seq $first $step $last)
7011 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
7012 do_facet mgs $LCTL pool_add \
7013 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
7014 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
7015 | sort -u | tr '\n' ' ' " "$t" || {
7016 error_noexit "Add to pool failed"
7019 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
7020 local addcount=$(((last - first) / step + 1))
7021 [ $lfscount -eq $addcount ] || {
7022 error_noexit "lfs pool_list bad ost count" \
7023 "$lfscount != $addcount"
7031 echo "Setting pool on directory $tdir"
7033 $SETSTRIPE -c 2 -p $pool $tdir && return 0
7035 error_noexit "Cannot set pool $pool to $tdir"
7042 echo "Checking pool on directory $tdir"
7044 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
7045 [ "$res" = "$pool" ] && return 0
7047 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
7051 pool_dir_rel_path() {
7052 echo "Testing relative path works well"
7057 mkdir -p $root/$tdir/$tdir
7059 pool_set_dir $pool $tdir || return 1
7060 pool_set_dir $pool ./$tdir || return 2
7061 pool_set_dir $pool ../$tdir || return 3
7062 pool_set_dir $pool ../$tdir/$tdir || return 4
7063 rm -rf $tdir; cd - > /dev/null
7066 pool_alloc_files() {
7067 echo "Checking files allocation from directory pool"
7074 for i in $(seq -w 1 $count)
7076 local file=$tdir/file-$i
7078 check_file_in_pool $file $pool "$tlist" || \
7079 failed=$((failed + 1))
7081 [ "$failed" = 0 ] && return 0
7083 error_noexit "$failed files not allocated in $pool"
7087 pool_create_files() {
7088 echo "Creating files in pool"
7096 for i in $(seq -w 1 $count)
7098 local file=$tdir/spoo-$i
7099 $SETSTRIPE -p $pool $file
7100 check_file_in_pool $file $pool "$tlist" || \
7101 failed=$((failed + 1))
7103 [ "$failed" = 0 ] && return 0
7105 error_noexit "$failed files not allocated in $pool"
7110 echo "Checking 'lfs df' output"
7113 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
7115 local res=$($LFS df --pool $FSNAME.$pool |
7117 grep "$FSNAME-OST" |
7119 [ "$res" = "$t" ] && return 0
7121 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
7125 pool_file_rel_path() {
7126 echo "Creating files in a pool with relative pathname"
7131 { error_noexit "unable to create $tdir"; return 1 ; }
7132 local file="/..$tdir/$tfile-1"
7133 $SETSTRIPE -p $pool $file ||
7134 { error_noexit "unable to create $file" ; return 2 ; }
7137 $SETSTRIPE -p $pool $tfile-2 || {
7138 error_noexit "unable to create $tfile-2 in $tdir"
7143 pool_remove_first_target() {
7144 echo "Removing first target from a pool"
7147 local pname="lov.$FSNAME-*.pools.$pool"
7148 local t=$($LCTL get_param -n $pname | head -1)
7149 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7150 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
7151 error_noexit "$t not removed from $FSNAME.$pool"
7156 pool_remove_all_targets() {
7157 echo "Removing all targets from pool"
7160 local pname="lov.$FSNAME-*.pools.$pool"
7161 for t in $($LCTL get_param -n $pname | sort -u)
7163 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7165 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
7166 error_noexit "Pool $FSNAME.$pool cannot be drained"
7169 # striping on an empty/nonexistant pool should fall back
7170 # to "pool of everything"
7172 error_noexit "failed to use fallback striping for empty pool"
7175 # setstripe on an empty pool should fail
7176 $SETSTRIPE -p $pool $file 2>/dev/null && {
7177 error_noexit "expected failure when creating file" \
7185 echo "Destroying pool"
7189 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
7192 # striping on an empty/nonexistant pool should fall back
7193 # to "pool of everything"
7195 error_noexit "failed to use fallback striping for missing pool"
7198 # setstripe on an empty pool should fail
7199 $SETSTRIPE -p $pool $file 2>/dev/null && {
7200 error_noexit "expected failure when creating file" \
7205 # get param should return err once pool is gone
7206 if wait_update $HOSTNAME "lctl get_param -n \
7207 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
7209 remove_pool_from_list $FSNAME.$pool
7212 error_noexit "Pool $FSNAME.$pool is not destroyed"
7216 # Get and check the actual stripe count of one file.
7217 # Usage: check_stripe_count <file> <expected_stripe_count>
7218 check_stripe_count() {
7223 [[ -z "$file" || -z "$expected" ]] &&
7224 error "check_stripe_count: invalid argument"
7226 local cmd="$GETSTRIPE -c $file"
7227 actual=$($cmd) || error "$cmd failed"
7228 actual=${actual%% *}
7230 if [[ $actual -ne $expected ]]; then
7231 [[ $expected -eq -1 ]] ||
7232 error "$cmd wrong: found $actual, expected $expected"
7233 [[ $actual -eq $OSTCOUNT ]] ||
7234 error "$cmd wrong: found $actual, expected $OSTCOUNT"
7238 # Get and check the actual list of OST indices on one file.
7239 # Usage: check_obdidx <file> <expected_comma_separated_list_of_ost_indices>
7245 [[ -z "$file" || -z "$expected" ]] &&
7246 error "check_obdidx: invalid argument!"
7248 obdidx=$(comma_list $($GETSTRIPE $file | grep -A $OSTCOUNT obdidx |
7249 grep -v obdidx | awk '{print $1}' | xargs))
7251 [[ $obdidx = $expected ]] ||
7252 error "list of OST indices on $file is $obdidx," \
7253 "should be $expected"
7256 # Get and check the actual OST index of the first stripe on one file.
7257 # Usage: check_start_ost_idx <file> <expected_start_ost_idx>
7258 check_start_ost_idx() {
7263 [[ -z "$file" || -z "$expected" ]] &&
7264 error "check_start_ost_idx: invalid argument!"
7266 start_ost_idx=$($GETSTRIPE $file | grep -A 1 obdidx | grep -v obdidx |
7269 [[ $start_ost_idx = $expected ]] ||
7270 error "OST index of the first stripe on $file is" \
7271 "$start_ost_idx, should be $expected"