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 # Synopsis: 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 -qe "$sbin_mount " /proc/mounts; then
547 cmp $mount_lustre $sbin_mount || umount $sbin_mount
549 if ! grep -qe "$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 label=$(devicelabel ${facet} ${!dev})
1197 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1198 eval export ${facet}_svc=${label}
1199 echo Started ${label}
1204 # start facet device options
1210 eval export ${facet}_dev=${device}
1211 eval export ${facet}_opt=\"$@\"
1213 local varname=${facet}failover_dev
1214 if [ -n "${!varname}" ] ; then
1215 eval export ${facet}failover_dev=${!varname}
1217 eval export ${facet}failover_dev=$device
1220 local mntpt=$(facet_mntpt $facet)
1221 do_facet ${facet} mkdir -p $mntpt
1222 eval export ${facet}_MOUNT=$mntpt
1223 mount_facet ${facet}
1226 if [[ $facet == mds* ]]; then
1228 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1239 local HOST=`facet_active_host $facet`
1240 [ -z $HOST ] && echo stop: no host for $facet && return 0
1242 local mntpt=$(facet_mntpt $facet)
1243 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
1244 if [ ${running} -ne 0 ]; then
1245 echo "Stopping $mntpt (opts:$@) on $HOST"
1246 do_facet ${facet} umount -d $@ $mntpt
1249 # umount should block, but we should wait for unrelated obd's
1250 # like the MGS or MGC to also stop.
1251 wait_exit_ST ${facet} || return ${PIPESTATUS[0]}
1253 if [[ $(facet_fstype $facet) == zfs ]]; then
1254 # export ZFS storage pool
1259 # save quota version (both administrative and operational quotas)
1260 # add an additional parameter if mountpoint is ever different from $MOUNT
1262 # XXX This function is kept for interoperability with old server (< 2.3.50),
1263 # it should be removed whenever we drop the interoperability for such
1265 quota_save_version() {
1266 local fsname=${2:-$FSNAME}
1268 local ver=$(tr -c -d "123" <<< $spec)
1269 local type=$(tr -c -d "ug" <<< $spec)
1271 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
1273 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
1275 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
1277 local osts=$(get_facets OST)
1278 for ost in ${osts//,/ }; do
1280 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
1284 # client could mount several lustre
1286 # XXX This function is kept for interoperability with old server (< 2.3.50),
1287 # it should be removed whenever we drop the interoperability for such
1290 local fsname=${1:-$FSNAME}
1292 do_facet $SINGLEMDS lctl get_param mdd.${fsname}-MDT*.quota_type ||
1294 do_nodes $(comma_list $(osts_nodes)) \
1295 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
1299 # XXX This function is kept for interoperability with old server (< 2.3.50),
1300 # it should be removed whenever we drop the interoperability for such
1302 restore_quota_old() {
1303 local mntpt=${1:-$MOUNT}
1304 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
1305 if [ ! "$old_QUOTA_TYPE" ] ||
1306 [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
1309 quota_save_version $old_QUOTA_TYPE
1312 # XXX This function is kept for interoperability with old server (< 2.3.50),
1313 # it should be removed whenever we drop the interoperability for such
1318 # no quota enforcement for now and accounting works out of the box
1321 # We need save the original quota_type params, and restore them after testing
1323 # Suppose that quota type the same on mds and ost
1324 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
1325 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
1326 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
1327 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
1328 export old_QUOTA_TYPE=$quota_type
1329 quota_save_version $QUOTA_TYPE
1331 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
1332 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
1335 local quota_usrs=$QUOTA_USERS
1337 # get_filesystem_size
1338 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1339 local blk_soft=$((disksz + 1024))
1340 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1342 local Inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1343 local i_soft=$Inodes
1344 local i_hard=$((i_soft + i_soft / 20))
1346 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
1347 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
1350 for usr in $quota_usrs; do
1351 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1353 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1355 eval $cmd || error "$cmd FAILED!"
1357 # display the quota status
1358 echo "Quota settings for $usr : "
1359 $LFS quota -v -u $usr $mntpt || true
1363 # get mdt quota type
1365 local varsvc=${SINGLEMDS}_svc
1366 do_facet $SINGLEMDS $LCTL get_param -n \
1367 osd-$(facet_fstype $SINGLEMDS).${!varsvc}.quota_slave.enabled
1370 # get ost quota type
1372 # All OSTs should have same quota type
1373 local varsvc=ost1_svc
1374 do_facet ost1 $LCTL get_param -n \
1375 osd-$(facet_fstype ost1).${!varsvc}.quota_slave.enabled
1378 # restore old quota type settings
1380 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1385 if [ "$old_MDT_QUOTA_TYPE" ]; then
1386 do_facet mgs $LCTL conf_param \
1387 $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
1389 if [ "$old_OST_QUOTA_TYPE" ]; then
1390 do_facet mgs $LCTL conf_param \
1391 $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
1395 # Handle the case when there is a space in the lfs df
1396 # "filesystem summary" line the same as when there is no space.
1397 # This will allow fixing the "lfs df" summary line in the future.
1399 $LFS df $* | sed -e 's/filesystem /filesystem_/'
1402 # Get free inodes on the MDT specified by mdt index, free indoes on
1403 # the whole filesystem will be returned when index == -1.
1409 if [ $index -eq -1 ]; then
1412 mdt_uuid=$(mdtuuid_from_index $index)
1415 free_inodes=$(lfs_df -i $MOUNT | grep $mdt_uuid | awk '{print $4}')
1420 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1427 # save old quota type & set new quota type
1428 local mdt_qtype=$(mdt_quota_type)
1429 local ost_qtype=$(ost_quota_type)
1431 echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
1432 "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
1434 export old_MDT_QUOTA_TYPE=$mdt_qtype
1435 export old_OST_QUOTA_TYPE=$ost_qtype
1437 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$QUOTA_TYPE ||
1438 error "set mdt quota type failed"
1439 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$QUOTA_TYPE ||
1440 error "set ost quota type failed"
1442 local quota_usrs=$QUOTA_USERS
1444 # get_filesystem_size
1445 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1446 local blk_soft=$((disksz + 1024))
1447 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1449 local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1450 local i_soft=$inodes
1451 local i_hard=$((i_soft + i_soft / 20))
1453 echo "Total disk size: $disksz block-softlimit: $blk_soft" \
1454 "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
1455 "inode-hardlimit: $i_hard"
1458 for usr in $quota_usrs; do
1459 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1461 cmd="$LFS setquota -$type $usr -b $blk_soft"
1462 cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1464 eval $cmd || error "$cmd FAILED!"
1466 # display the quota status
1467 echo "Quota settings for $usr : "
1468 $LFS quota -v -u $usr $mntpt || true
1475 local opts=${3:-$MOUNT_OPTS}
1476 opts=${opts:+-o $opts}
1477 local flags=${4:-$MOUNT_FLAGS}
1479 local device=$MGSNID:/$FSNAME
1480 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1481 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1485 echo "Starting client: $client: $flags $opts $device $mnt"
1486 do_node $client mkdir -p $mnt
1487 do_node $client $MOUNT_CMD $flags $opts $device $mnt || return 1
1489 set_default_debug_nodes $client
1501 [ "$3" ] && force=-f
1502 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
1503 if [ $running -ne 0 ]; then
1504 echo "Stopping client $client $mnt (opts:$force)"
1505 do_node $client lsof -t $mnt || need_kill=no
1506 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
1507 pids=$(do_node $client lsof -t $mnt | sort -u);
1508 if [ -n $pids ]; then
1509 do_node $client kill -9 $pids || true
1513 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
1514 if [ $busy -ne 0 ] ; then
1515 echo "$mnt is still busy, wait one second" && sleep 1
1516 do_node $client umount $force $mnt
1521 # nodes is comma list
1522 sanity_mount_check_nodes () {
1528 # FIXME: assume that all cluster nodes run the same os
1529 [ "$(uname)" = Linux ] || return 0
1532 for mnt in $mnts ; do
1533 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
1534 mpts=\\\$(mount | grep -c $mnt' ');
1535 if [ \\\$running -ne \\\$mpts ]; then
1536 echo \\\$(hostname) env are INSANE!;
1539 [ $? -eq 0 ] || rc=1
1544 sanity_mount_check_servers () {
1545 [ "$CLIENTONLY" ] &&
1546 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
1547 echo Checking servers environments
1549 # FIXME: modify get_facets to display all facets wo params
1550 local facets="$(get_facets OST),$(get_facets MDS),mgs"
1554 for facet in ${facets//,/ }; do
1555 node=$(facet_host ${facet})
1556 mntpt=$(facet_mntpt $facet)
1557 sanity_mount_check_nodes $node $mntpt ||
1558 { error "server $node environments are insane!"; return 1; }
1562 sanity_mount_check_clients () {
1563 local clients=${1:-$CLIENTS}
1564 local mntpt=${2:-$MOUNT}
1565 local mntpt2=${3:-$MOUNT2}
1567 [ -z $clients ] && clients=$(hostname)
1568 echo Checking clients $clients environments
1570 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
1571 error "clients environments are insane!"
1574 sanity_mount_check () {
1575 sanity_mount_check_servers || return 1
1576 sanity_mount_check_clients || return 2
1579 # mount clients if not mouted
1580 zconf_mount_clients() {
1583 local opts=${3:-$MOUNT_OPTS}
1584 opts=${opts:+-o $opts}
1585 local flags=${4:-$MOUNT_FLAGS}
1587 local device=$MGSNID:/$FSNAME
1588 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1589 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1593 echo "Starting client $clients: $flags $opts $device $mnt"
1596 running=\\\$(mount | grep -c $mnt' ');
1598 if [ \\\$running -eq 0 ] ; then
1600 $MOUNT_CMD $flags $opts $device $mnt;
1603 exit \\\$rc" || return ${PIPESTATUS[0]}
1605 echo "Started clients $clients: "
1606 do_nodes $clients "mount | grep $mnt' '"
1608 set_default_debug_nodes $clients
1613 zconf_umount_clients() {
1618 [ "$3" ] && force=-f
1620 echo "Stopping clients: $clients $mnt (opts:$force)"
1621 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
1622 if [ \\\$running -ne 0 ] ; then
1623 echo Stopping client \\\$(hostname) $mnt opts:$force;
1624 lsof $mnt || need_kill=no;
1625 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
1626 pids=\\\$(lsof -t $mnt | sort -u);
1627 if [ -n \\\"\\\$pids\\\" ]; then
1631 while umount $force $mnt 2>&1 | grep -q "busy"; do
1632 echo "$mnt is still busy, wait one second" && sleep 1;
1639 echo + $POWER_DOWN $node
1643 shutdown_node_hard () {
1645 local attempts=$SHUTDOWN_ATTEMPTS
1647 for i in $(seq $attempts) ; do
1650 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
1651 echo "waiting for $host to fail attempts=$attempts"
1652 [ $i -lt $attempts ] || \
1653 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
1659 local mnt=${2:-$MOUNT}
1662 if [ "$FAILURE_MODE" = HARD ]; then
1663 shutdown_node_hard $client
1665 zconf_umount_clients $client $mnt -f
1671 local facets="$(get_facets OST),$(get_facets MDS)"
1674 combined_mgs_mds || facets="$facets,mgs"
1676 for facet in ${facets//,/ }; do
1677 if [ $(facet_active_host $facet) == $host ]; then
1678 affected="$affected $facet"
1682 echo $(comma_list $affected)
1687 local host=${2:-$(facet_host $facet)}
1689 local label=$(convert_facet2label $facet)
1690 do_node $host $LCTL dl | awk '{ print $4 }' | grep -q "^$label\$"
1693 facets_up_on_host () {
1695 local facets=$(facets_on_host $host)
1698 for facet in ${facets//,/ }; do
1699 if $(facet_up $facet $host); then
1700 affected_up="$affected_up $facet"
1704 echo $(comma_list $affected_up)
1710 if [ "$FAILURE_MODE" = HARD ]; then
1711 shutdown_node_hard $(facet_active_host $facet)
1719 echo + $POWER_UP $node
1732 if [ "$FAILURE_MODE" = HARD ]; then
1733 reboot_node $(facet_active_host $facet)
1741 if [ "$FAILURE_MODE" = HARD ]; then
1751 for facet in ${facets//,/ }; do
1752 hosts=$(expand_list $hosts $(facet_host $facet) )
1758 _check_progs_installed () {
1762 for prog in $progs; do
1763 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1764 echo $prog missing on $(hostname)
1771 check_progs_installed () {
1775 do_rpc_nodes "$nodes" _check_progs_installed $@
1778 # recovery-scale functions
1780 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1783 start_client_load() {
1786 local var=$(node_var_name $client)_load
1787 eval export ${var}=$load
1789 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1790 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1791 END_RUN_FILE=$END_RUN_FILE \
1792 LOAD_PID_FILE=$LOAD_PID_FILE \
1793 TESTLOG_PREFIX=$TESTLOG_PREFIX \
1794 TESTNAME=$TESTNAME \
1795 DBENCH_LIB=$DBENCH_LIB \
1796 DBENCH_SRC=$DBENCH_SRC \
1797 CLIENT_COUNT=$((CLIENTCOUNT - 1)) \
1801 log "Started client load: ${load} on $client"
1803 # get the children process IDs
1804 local pids=$(ps --ppid $ppid -o pid= | xargs)
1805 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
1809 start_client_loads () {
1810 local -a clients=(${1//,/ })
1811 local numloads=${#CLIENT_LOADS[@]}
1814 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1815 testnum=$((nodenum % numloads))
1816 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1818 # bug 22169: wait the background threads to start
1822 # only for remote client
1823 check_client_load () {
1825 local var=$(node_var_name $client)_load
1826 local TESTLOAD=run_${!var}.sh
1828 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1830 # bug 18914: try to connect several times not only when
1831 # check ps, but while check_catastrophe also
1834 while [ $RC = 254 -a $tries -gt 0 ]; do
1838 if ! check_catastrophe $client; then
1840 if [ $RC -eq 254 ]; then
1841 # FIXME: not sure how long we shuold sleep here
1845 echo "check catastrophe failed: RC=$RC "
1849 # We can continue try to connect if RC=254
1850 # Just print the warning about this
1851 if [ $RC = 254 ]; then
1852 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1855 # see if the load is still on the client
1858 while [ $RC = 254 -a $tries -gt 0 ]; do
1862 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1867 if [ $RC = 254 ]; then
1868 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1869 # see if we can diagnose a bit why this is
1874 check_client_loads () {
1875 local clients=${1//,/ }
1879 for client in $clients; do
1880 check_client_load $client
1882 if [ "$rc" != 0 ]; then
1883 log "Client load failed on node $client, rc=$rc"
1889 restart_client_loads () {
1890 local clients=${1//,/ }
1891 local expectedfail=${2:-""}
1895 for client in $clients; do
1896 check_client_load $client
1898 if [ "$rc" != 0 -a "$expectedfail" ]; then
1899 local var=$(node_var_name $client)_load
1900 start_client_load $client ${!var}
1901 echo "Restarted client load ${!var}: on $client. Checking ..."
1902 check_client_load $client
1904 if [ "$rc" != 0 ]; then
1905 log "Client load failed to restart on node $client, rc=$rc"
1906 # failure one client load means test fail
1907 # we do not need to check other
1916 # Start vmstat and save its process ID in a file.
1921 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1924 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
1925 2>/dev/null </dev/null & echo \\\$! > $pid_file"
1928 # Display the nodes on which client loads failed.
1929 print_end_run_file() {
1933 [ -s $file ] || return 0
1935 echo "Found the END_RUN_FILE file: $file"
1938 # A client load will stop if it finds the END_RUN_FILE file.
1939 # That does not mean the client load actually failed though.
1940 # The first node in END_RUN_FILE is the one we are interested in.
1943 if [ -n "$node" ]; then
1944 local var=$(node_var_name $node)_load
1946 local prefix=$TESTLOG_PREFIX
1947 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
1948 local stdout_log=$prefix.run_${!var}_stdout.$node.log
1949 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
1951 echo "Client load ${!var} failed on node $node:"
1957 # Stop the process which had its PID saved in a file.
1962 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1964 do_nodes $nodes "test -f $pid_file &&
1965 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
1968 # Stop all client loads.
1969 stop_client_loads() {
1970 local nodes=${1:-$CLIENTS}
1973 # stop the client loads
1974 stop_process $nodes $pid_file
1976 # clean up the processes that started them
1977 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
1979 # End recovery-scale functions
1981 # verify that lustre actually cleaned up properly
1983 VAR=$(lctl get_param -n catastrophe 2>&1)
1984 if [ $? = 0 ] ; then
1985 if [ $VAR != 0 ]; then
1986 error "LBUG/LASSERT detected"
1989 BUSY=$(dmesg | grep -i destruct || true)
1990 if [ -n "$BUSY" ]; then
1992 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.$(date +%s)
1996 check_mem_leak || exit 204
1998 [[ $($LCTL dl 2>/dev/null | wc -l) -gt 0 ]] && $LCTL dl &&
1999 echo "$TESTSUITE: lustre didn't clean up..." 1>&2 &&
2002 if module_loaded lnet || module_loaded libcfs; then
2003 echo "$TESTSUITE: modules still loaded..." 1>&2
2012 if [[ "$1" == "--verbose" ]]; then
2027 PREV_RESULT=$(do_node $node "$TEST")
2029 RESULT=$(do_node $node "$TEST")
2030 if [[ "$RESULT" == "$FINAL" ]]; then
2031 [[ -z "$RESULT" || $WAIT -le $sleep ]] ||
2032 echo "Updated after ${WAIT}s: wanted '$FINAL'"\
2036 if [[ $verbose && "$RESULT" != "$PREV_RESULT" ]]; then
2037 echo "Changed after ${WAIT}s: from '$PREV_RESULT'"\
2041 [[ $WAIT -ge $MAX ]] && break
2042 [[ $((WAIT % print)) -eq 0 ]] &&
2043 echo "Waiting $((MAX - WAIT)) secs for update"
2044 WAIT=$((WAIT + sleep))
2047 echo "Update not seen after ${MAX}s: wanted '$FINAL' got '$RESULT'"
2051 wait_update_facet() {
2054 wait_update $(facet_active_host $facet) "$@"
2058 do_nodes $(comma_list $(mdts_nodes)) \
2059 "lctl set_param -n osd*.*MDT*.force_sync 1"
2060 do_nodes $(comma_list $(osts_nodes)) \
2061 "lctl set_param -n osd*.*OS*.force_sync 1" 2>&1 |
2062 grep -v 'Found no match'
2065 wait_delete_completed_mds() {
2066 local MAX_WAIT=${1:-20}
2068 local stime=$(date +%s)
2073 # find MDS with pending deletions
2074 for node in $(mdts_nodes); do
2075 changes=$(do_node $node "$LCTL get_param -n osc.*MDT*.sync_*" \
2076 2>/dev/null | calc_sum)
2077 if [[ $changes -eq 0 ]]; then
2080 mds2sync="$mds2sync $node"
2082 if [ -z "$mds2sync" ]; then
2085 mds2sync=$(comma_list $mds2sync)
2087 # sync MDS transactions
2088 do_nodes $mds2sync "$LCTL set_param -n osd*.*MD*.force_sync 1"
2090 # wait till all changes are sent and commmitted by OSTs
2091 # for ldiskfs space is released upon execution, but DMU
2092 # do this upon commit
2095 while [[ $WAIT -ne $MAX_WAIT ]]; do
2096 changes=$(do_nodes $mds2sync \
2097 "$LCTL get_param -n osc.*MDT*.sync_*" | calc_sum)
2098 #echo "$node: $changes changes on all"
2099 if [[ $changes -eq 0 ]]; then
2101 #echo "delete took $((etime - stime)) seconds"
2109 echo "Delete is not completed in $((etime - stime)) seconds"
2110 do_nodes $mds2sync "$LCTL get_param osc.*MDT*.sync_*"
2116 # we can use "for" here because we are waiting the slowest
2117 for host in ${hostlist//,/ }; do
2118 check_network "$host" 900
2120 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
2127 for facet in ${facetlist//,/ }; do
2128 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
2130 wait_for_host $hostlist
2133 _wait_recovery_complete () {
2136 # Use default policy if $2 is not passed by caller.
2137 local MAX=${2:-$(max_recovery_time)}
2142 while [ $WAIT -lt $MAX ]; do
2143 STATUS=$(lctl get_param -n $param | grep status)
2145 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
2148 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
2150 echo "$param recovery not done in $MAX sec. $STATUS"
2154 wait_recovery_complete () {
2157 # with an assumption that at_max is the same on all nodes
2158 local MAX=${2:-$(max_recovery_time)}
2161 if [ "$FAILURE_MODE" = HARD ]; then
2162 facets=$(facets_on_host $(facet_active_host $facet))
2164 echo affected facets: $facets
2166 # we can use "for" here because we are waiting the slowest
2167 for facet in ${facets//,/ }; do
2168 local var_svc=${facet}_svc
2169 local param="*.${!var_svc}.recovery_status"
2171 local host=$(facet_active_host $facet)
2172 do_rpc_nodes "$host" _wait_recovery_complete $param $MAX
2176 wait_mds_ost_sync () {
2177 # just because recovery is done doesn't mean we've finished
2178 # orphan cleanup. Wait for llogs to get synchronized.
2179 echo "Waiting for orphan cleanup..."
2180 # MAX value includes time needed for MDS-OST reconnection
2181 local MAX=$(( TIMEOUT * 2 ))
2182 local WAIT_TIMEOUT=${1:-$MAX}
2185 local list=$(comma_list $(mdts_nodes))
2186 local cmd="$LCTL get_param -n osp.*osc*.old_sync_processed"
2187 if ! do_facet $SINGLEMDS \
2188 "$LCTL list_param osp.*osc*.old_sync_processed 2> /dev/null"
2190 # old way, use mds_sync
2192 list=$(comma_list $(osts_nodes))
2193 cmd="$LCTL get_param -n obdfilter.*.mds_sync"
2196 echo "wait $WAIT_TIMEOUT secs maximumly for $list mds-ost sync done."
2197 while [ $WAIT -lt $WAIT_TIMEOUT ]; do
2198 local -a sync=($(do_nodes $list "$cmd"))
2201 for ((i=0; i<${#sync[@]}; i++)); do
2203 [ ${sync[$i]} -eq 1 ] && continue
2205 [ ${sync[$i]} -eq 0 ] && continue
2207 # there is a not finished MDS-OST synchronization
2211 sleep 2 # increase waiting time and cover statfs cache
2212 [ ${con} -eq 1 ] && return 0
2213 echo "Waiting $WAIT secs for $list $i mds-ost sync done."
2217 # show which nodes are not finished.
2218 do_nodes $list "$cmd"
2219 echo "$facet recovery node $i not done in $WAIT_TIMEOUT sec. $STATUS"
2223 wait_destroy_complete () {
2224 echo "Waiting for local destroys to complete"
2225 # MAX value shouldn't be big as this mean server responsiveness
2226 # never increase this just to make test pass but investigate
2227 # why it takes so long time
2230 while [ $WAIT -lt $MAX ]; do
2231 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
2235 for ((i=0; i<${#RPCs[@]}; i++)); do
2236 [ ${RPCs[$i]} -eq 0 ] && continue
2237 # there are still some destroy RPCs in flight
2242 [ ${con} -eq 1 ] && return 0 # done waiting
2243 echo "Waiting ${WAIT}s for local destroys to complete"
2246 echo "Local destroys weren't done in $MAX sec."
2250 wait_delete_completed() {
2251 wait_delete_completed_mds $1 || return $?
2252 wait_destroy_complete
2261 # conf-sanity 31 takes a long time cleanup
2262 while [ $WAIT -lt 300 ]; do
2263 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
2264 [ -z "${running}" ] && return 0
2265 echo "waited $WAIT for${running}"
2266 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
2268 WAIT=$((WAIT + INTERVAL))
2270 echo "service didn't stop after $WAIT seconds. Still running:"
2275 wait_remote_prog () {
2281 [ "$PDSH" = "no_dsh" ] && return 0
2283 while [ $WAIT -lt $2 ]; do
2284 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
2285 [ -z "${running}" ] && return 0 || true
2286 echo "waited $WAIT for: "
2288 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
2290 WAIT=$((WAIT + INTERVAL))
2292 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
2293 [ -z "$pids" ] && return 0
2294 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
2295 # FIXME: not portable
2296 for pid in $pids; do
2297 cat /proc/${pid}/status || true
2298 cat /proc/${pid}/wchan || true
2300 kill -9 $pid || true
2309 # not every config has many clients
2311 if [ ! -z "$CLIENTS" ]; then
2312 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
2314 stat -f $MOUNT > /dev/null
2320 # usually checked on particular client or locally
2322 if [ ! -z "$client" ]; then
2323 $PDSH $client "stat -f $MOUNT" > /dev/null
2325 stat -f $MOUNT > /dev/null
2333 client_reconnect_try() {
2334 uname -n >> $MOUNT/recon
2335 if [ -z "$CLIENTS" ]; then
2336 df $MOUNT; uname -n >> $MOUNT/recon
2338 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
2340 echo Connected clients:
2342 ls -l $MOUNT/recon > /dev/null
2346 client_reconnect() {
2347 # one client_reconnect_try call does not always do the job...
2349 client_reconnect_try && break
2354 affected_facets () {
2357 local host=$(facet_active_host $facet)
2358 local affected=$facet
2360 if [ "$FAILURE_MODE" = HARD ]; then
2361 affected=$(facets_up_on_host $host)
2375 #Because it will only get up facets, we need get affected
2376 #facets before shutdown
2377 #For HARD Failure mode, it needs make sure facets on the same
2378 #HOST will only be shutdown and reboot once
2379 for facet in ${facets//,/ }; do
2380 local affected_facet
2382 #check whether facet has been included in other affected facets
2383 for ((index=0; index<$total; index++)); do
2384 [[ *,$facet,* == ,${affecteds[index]}, ]] && skip=1
2387 if [ $skip -eq 0 ]; then
2388 affecteds[$total]=$(affected_facets $facet)
2393 for ((index=0; index<$total; index++)); do
2394 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2395 local host=$(facet_active_host $facet)
2396 echo "Failing ${affecteds[index]} on $host"
2397 shutdown_facet $facet
2400 for ((index=0; index<$total; index++)); do
2401 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2402 echo reboot facets: ${affecteds[index]}
2406 change_active ${affecteds[index]}
2408 wait_for_facet ${affecteds[index]}
2409 # start mgs first if it is affected
2410 if ! combined_mgs_mds &&
2411 list_member ${affecteds[index]} mgs; then
2412 mount_facet mgs || error "Restart of mgs failed"
2414 # FIXME; has to be changed to mount all facets concurrently
2415 affected=$(exclude_items_from_list ${affecteds[index]} mgs)
2416 echo mount facets: ${affecteds[index]}
2417 mount_facets ${affecteds[index]}
2427 do_facet $facet "sync; sync; sync"
2430 # make sure there will be no seq change
2431 local clients=${CLIENTS:-$HOSTNAME}
2432 local f=fsa-\\\$\(hostname\)
2433 do_nodes $clients "mcreate $MOUNT/$f; rm $MOUNT/$f"
2434 do_nodes $clients "if [ -d $MOUNT2 ]; then mcreate $MOUNT2/$f; rm $MOUNT2/$f; fi"
2436 local svc=${facet}_svc
2437 do_facet $facet $LCTL --device ${!svc} notransno
2439 # If a ZFS OSD is made read-only here, its pool is "freezed". This
2440 # in-memory state has to be cleared by either rebooting the host or
2441 # exporting and reimporting the pool.
2443 # Although the uberblocks are not updated when a pool is freezed,
2444 # transactions are still written to the disks. Modified blocks may be
2445 # cached in memory when tests try reading them back. The
2446 # export-and-reimport process also evicts any cached pool data from
2447 # memory to provide the correct "data loss" semantics.
2449 # In the test framework, the exporting and importing operations are
2450 # handled by stop() and mount_facet() separately, which are used
2451 # inside fail() and fail_abort().
2453 do_facet $facet $LCTL --device ${!svc} readonly
2454 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2455 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2458 replay_barrier_nodf() {
2459 local facet=$1 echo running=${running}
2460 do_facet $facet "sync; sync; sync"
2461 local svc=${facet}_svc
2462 echo Replay barrier on ${!svc}
2463 do_facet $facet $LCTL --device ${!svc} notransno
2464 do_facet $facet $LCTL --device ${!svc} readonly
2465 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2466 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2469 replay_barrier_nosync() {
2470 local facet=$1 echo running=${running}
2471 local svc=${facet}_svc
2472 echo Replay barrier on ${!svc}
2473 do_facet $facet $LCTL --device ${!svc} notransno
2474 do_facet $facet $LCTL --device ${!svc} readonly
2475 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2476 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2480 # Get Lustre client uuid for a given Lustre mount point.
2483 local mntpnt=${1:-$MOUNT}
2485 local name=$($LFS getname $mntpnt | cut -d' ' -f1)
2486 local uuid=$($LCTL get_param -n llite.$name.uuid)
2491 mds_evict_client() {
2492 local mntpnt=${1:-$MOUNT}
2493 local uuid=$(get_client_uuid $mntpnt)
2495 do_facet $SINGLEMDS \
2496 "$LCTL set_param -n mdt.${mds1_svc}.evict_client $uuid"
2499 ost_evict_client() {
2500 local mntpnt=${1:-$MOUNT}
2501 local uuid=$(get_client_uuid $mntpnt)
2504 "$LCTL set_param -n obdfilter.${ost1_svc}.evict_client $uuid"
2509 local clients=${CLIENTS:-$HOSTNAME}
2511 facet_failover $* || error "failover: $?"
2512 wait_clients_import_state "$clients" "$facets" FULL
2513 clients_up || error "post-failover df: $?"
2518 facet_failover $facet
2524 change_active $facet
2525 wait_for_facet $facet
2526 mount_facet $facet -o abort_recovery
2527 clients_up || echo "first df failed: $?"
2528 clients_up || error "post-failover df: $?"
2532 echo There is no lmc. This is mountconf, baby.
2536 host_nids_address() {
2540 if [ -n "$kind" ]; then
2541 nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'")
2543 nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'")
2549 if [ "$1" = "'*'" ]; then echo \'*\'; else
2555 if [ "$1" = "'*'" ]; then echo \'*\'; else
2556 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | \
2558 if [ -z "$ID" ]; then
2559 echo "Could not get a ptl id for $1..."
2568 h2name_or_ip "$1" "tcp"
2573 if [ "$1" = "'*'" ]; then echo \'*\'; else
2574 if type __h2elan >/dev/null 2>&1; then
2577 ID=`echo $1 | sed 's/[^0-9]*//g'`
2585 h2name_or_ip "$1" "o2ib"
2589 # This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST
2590 # expressions format. As a bonus we can then just pass in those variables
2591 # to pdsh. What this function does is take a HOSTLIST type string and
2592 # expand it into a space deliminated list for us.
2600 [ -z "$hostlist" ] && return
2602 # Translate the case of [..],..,[..] to [..] .. [..]
2603 list="${hostlist/],/] }"
2605 [[ "$front" == *,* ]] && {
2608 list=${list/${old}/${new}}
2611 for item in $list; do
2612 # Test if we have any []'s at all
2613 if [ "$item" != "${item/\[/}" ]; then {
2614 # Expand the [*] into list
2618 if [ "$name" != "$item" ]; then
2619 group=${item#$name[*}
2622 for range in ${group//,/ }; do
2626 # Number of leading zeros
2629 end=$(echo $end | sed 's/0*//')
2630 [[ -z "$end" ]] && end=0
2631 [[ $padlen2 -gt $padlen ]] && {
2632 [[ $padlen2 -eq ${#end} ]] && padlen2=0
2635 begin=$(echo $begin | sed 's/0*//')
2636 [ -z $begin ] && begin=0
2638 for num in $(seq -f "%0${padlen}g" $begin $end); do
2639 value="${name#*,}${num}${back}"
2640 [ "$value" != "${value/\[/}" ] && {
2641 value=$(hostlist_expand "$value")
2643 myList="$myList $value"
2648 myList="$myList $item"
2651 myList=${myList//,/ }
2652 myList=${myList:1} # Remove first character which is a space
2654 # Filter any duplicates without sorting
2656 myList="${list%% *}"
2658 while [[ "$list" != ${myList##* } ]]; do
2659 list=${list//${list%% *} /}
2660 myList="$myList ${list%% *}"
2662 myList="${myList%* }";
2664 # We can select an object at a offset in the list
2667 for item in $myList; do
2669 [ $cnt -eq $offset ] && {
2673 [ $(get_node_count $myList) -ne 1 ] && myList=""
2682 [ "$facet" == client ] && echo -n $HOSTNAME && return
2683 varname=${facet}_HOST
2684 if [ -z "${!varname}" ]; then
2685 if [ "${facet:0:3}" == "ost" ]; then
2686 local fh=${facet%failover}_HOST
2687 eval export ${facet}_HOST=${!fh}
2688 if [ -z "${!varname}" ]; then
2689 eval export ${facet}_HOST=${ost_HOST}
2691 elif [ "${facet:0:3}" == "mdt" -o \
2692 "${facet:0:3}" == "mds" -o \
2693 "${facet:0:3}" == "mgs" ]; then
2694 eval export ${facet}_HOST=${mds_HOST}
2700 facet_failover_host() {
2704 var=${facet}failover_HOST
2705 if [ -n "${!var}" ]; then
2710 if [ "${facet:0:3}" == "mdt" -o "${facet:0:3}" == "mds" -o \
2711 "${facet:0:3}" == "mgs" ]; then
2713 eval export ${facet}failover_host=${mds_HOST}
2718 if [[ $facet == ost* ]]; then
2719 eval export ${facet}failover_host=${ost_HOST}
2727 local activevar=${facet}active
2729 if [ -f $TMP/${facet}active ] ; then
2730 source $TMP/${facet}active
2733 active=${!activevar}
2734 if [ -z "$active" ] ; then
2741 facet_active_host() {
2743 local active=`facet_active $facet`
2744 if [ "$facet" == client ]; then
2747 echo `facet_host $active`
2751 # Get the passive failover partner host of facet.
2752 facet_passive_host() {
2754 [[ $facet = client ]] && return
2756 local host=${facet}_HOST
2757 local failover_host=${facet}failover_HOST
2758 local active_host=$(facet_active_host $facet)
2760 [[ -z ${!failover_host} || ${!failover_host} = ${!host} ]] && return
2762 if [[ $active_host = ${!host} ]]; then
2763 echo -n ${!failover_host}
2773 facetlist=$(exclude_items_from_list $facetlist mgs)
2775 for facet in ${facetlist//,/ }; do
2776 local failover=${facet}failover
2777 local host=`facet_host $failover`
2778 [ -z "$host" ] && return
2780 local curactive=`facet_active $facet`
2781 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
2782 eval export ${facet}active=$facet
2784 eval export ${facet}active=$failover
2786 # save the active host for this facet
2787 local activevar=${facet}active
2788 echo "$activevar=${!activevar}" > $TMP/$activevar
2789 [[ $facet = mds1 ]] && combined_mgs_mds && \
2790 echo "mgsactive=${!activevar}" > $TMP/mgsactive
2791 local TO=`facet_active_host $facet`
2792 echo "Failover $facet to $TO"
2798 # do not stripe off hostname if verbose, bug 19215
2799 if [ x$1 = x--verbose ]; then
2807 if [ "$HOST" = "$HOSTNAME" ]; then
2809 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
2810 echo "cannot run remote command on $HOST with $myPDSH"
2814 echo "CMD: $HOST $@" >&2
2815 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2818 if [ "$myPDSH" = "rsh" ]; then
2819 # we need this because rsh does not return exit code of an executed command
2820 local command_status="$TMP/cs"
2821 rsh $HOST ":> $command_status"
2822 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
2823 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
2824 echo command failed >$command_status"
2825 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
2830 # print HOSTNAME for myPDSH="no_dsh"
2831 if [[ $myPDSH = no_dsh ]]; then
2832 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
2834 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
2837 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
2839 return ${PIPESTATUS[0]}
2843 do_node --verbose "$@"
2846 single_local_node () {
2847 [ "$1" = "$HOSTNAME" ]
2850 # Outputs environment variable assignments that should be passed to remote nodes
2854 local facets=$(get_facets)
2857 for var in ${!MODOPTS_*}; do
2858 value=${!var//\"/\\\"}
2859 echo -n " ${var}=\"$value\""
2862 for facet in ${facets//,/ }; do
2864 if [ -n "${!var}" ]; then
2865 echo -n " $var=${!var}"
2869 for var in MGSFSTYPE MDSFSTYPE OSTFSTYPE; do
2870 if [ -n "${!var}" ]; then
2871 echo -n " $var=${!var}"
2875 if [ -n "$FSTYPE" ]; then
2876 echo -n " FSTYPE=$FSTYPE"
2882 # do not stripe off hostname if verbose, bug 19215
2883 if [ x$1 = x--verbose ]; then
2891 if single_local_node $rnodes; then
2893 do_nodev $rnodes "$@"
2895 do_node $rnodes "$@"
2900 # This is part from do_node
2903 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
2904 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
2906 export FANOUT=$(get_node_count "${rnodes//,/ }")
2908 echo "CMD: $rnodes $@" >&2
2909 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2912 # do not replace anything from pdsh output if -N is used
2913 # -N Disable hostname: prefix on lines of output.
2914 if $verbose || [[ $myPDSH = *-N* ]]; then
2915 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
2917 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
2919 return ${PIPESTATUS[0]}
2925 local HOST=`facet_active_host $facet`
2926 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
2930 # Function: do_facet_random_file $FACET $FILE $SIZE
2931 # Creates FILE with random content on the given FACET of given SIZE
2933 do_facet_random_file() {
2937 local cmd="dd if=/dev/urandom of='$fpath' bs=$fsize count=1"
2938 do_facet $facet "$cmd 2>/dev/null"
2941 do_facet_create_file() {
2945 local cmd="dd if=/dev/zero of='$fpath' bs=$fsize count=1"
2946 do_facet $facet "$cmd 2>/dev/null"
2950 do_nodes --verbose "$@"
2956 # make sure its not already running
2958 rm -f $TMP/${facet}active
2959 [[ $facet = mds1 ]] && combined_mgs_mds && rm -f $TMP/mgsactive
2960 do_facet ${facet} $MKFS $* || return ${PIPESTATUS[0]}
2962 if [[ $(facet_fstype $facet) == zfs ]]; then
2964 # After formatting a ZFS target, "cachefile=none" property will
2965 # be set on the ZFS storage pool so that the pool is not
2966 # automatically imported on system startup. And then the pool
2967 # will be exported so as to leave the importing and exporting
2968 # operations handled by mount_facet() and stop() separately.
2970 refresh_partition_table $facet $(facet_vdevice $facet)
2971 disable_zpool_cache $facet
2976 # Device formatted as ost
2979 local DEVNAME=OSTDEV$num
2981 local fstype=$(facet_fstype ost$num)
2985 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
2986 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
2988 #try $OSTZFSDEVn - independent of vdev
2989 DEVNAME=OSTZFSDEV$num
2990 eval DEVPTR=${!DEVNAME:=${FSNAME}-ost${num}/ost${num}};;
2992 error "unknown fstype!";;
2998 # Physical device location of data
3004 local fstype=$(facet_fstype ost$num)
3008 # vdevs are not supported by ldiskfs
3011 #if $OSTDEVn isn't defined, default is $OSTDEVBASE{n}
3012 # Device formated by zfs
3014 eval VDEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
3016 error "unknown fstype!";;
3022 # Logical device formated for lustre
3025 local DEVNAME=MDSDEV$num
3027 local fstype=$(facet_fstype mds$num)
3031 #if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3032 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3034 # try $MDSZFSDEVn - independent of vdev
3035 DEVNAME=MDSZFSDEV$num
3036 eval DEVPTR=${!DEVNAME:=${FSNAME}-mdt${num}/mdt${num}};;
3038 error "unknown fstype!";;
3044 # Physical location of data
3048 local fstype=$(facet_fstype mds$num)
3052 # vdevs are not supported by ldiskfs
3055 # if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3056 # Device formated by ZFS
3057 local DEVNAME=MDSDEV$num
3058 eval VDEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3060 error "unknown fstype!";;
3068 local fstype=$(facet_fstype mgs)
3072 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3073 ( [ -z "$MGSDEV" ] || [ $MGSDEV = $(mdsdevname 1) ] ); then
3074 DEVPTR=$(mdsdevname 1)
3079 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3080 ( [ -z "$MGSZFSDEV" ] &&
3081 [ -z "$MGSDEV" -o "$MGSDEV" = $(mdsvdevname 1) ] ); then
3082 DEVPTR=$(mdsdevname 1)
3084 DEVPTR=${MGSZFSDEV:-${FSNAME}-mgs/mgs}
3087 error "unknown fstype!";;
3096 local fstype=$(facet_fstype mgs)
3100 # vdevs are not supported by ldiskfs
3103 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3104 ( [ -z "$MGSDEV" ] &&
3105 [ -z "$MGSZFSDEV" -o "$MGSZFSDEV" = $(mdsdevname 1) ]); then
3106 VDEVPTR=$(mdsvdevname 1)
3107 elif [ -n "$MGSDEV" ]; then
3111 error "unknown fstype!";;
3119 [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
3121 local var=${facet}_MOUNT
3122 eval mntpt=${!var:-${MOUNT%/*}/$facet}
3129 local dev=$(facet_device $facet)
3130 local mnt=$(facet_mntpt $facet)
3133 if ! do_facet $facet test -b $dev; then
3136 do_facet $facet mount -t ldiskfs $opts $dev $mnt
3141 local dev=$(facet_device $facet)
3142 local mnt=$(facet_mntpt $facet)
3144 do_facet $facet umount -d $mnt
3148 echo -n "$1" | tr -c '[:alnum:]\n' '_'
3153 local ds=$(facet_device $facet)
3154 local mnt=$(facet_mntpt $facet)
3159 canmnt=$(do_facet $facet $ZFS get -H -o value canmount $ds)
3160 mntpt=$(do_facet $facet $ZFS get -H -o value mountpoint $ds)
3161 do_facet $facet $ZFS set canmount=noauto $ds
3163 # The "legacy" mount method is used here because "zfs unmount $mnt"
3164 # calls stat(2) on $mnt/../*, which may include $MOUNT. If certain
3165 # targets are not available at the time, the stat(2) on $MOUNT will
3168 do_facet $facet $ZFS set mountpoint=legacy $ds
3169 do_facet $facet mount -t zfs $ds $mnt
3170 eval export mz_$(var_name ${facet}_$ds)_canmount=$canmnt
3171 eval export mz_$(var_name ${facet}_$ds)_mountpoint=$mntpt
3176 local ds=$(facet_device $facet)
3177 local mnt=$(facet_mntpt $facet)
3178 local var_mntpt=mz_$(var_name ${facet}_$ds)_mountpoint
3179 local var_canmnt=mz_$(var_name ${facet}_$ds)_canmount
3180 local mntpt=${!var_mntpt}
3181 local canmnt=${!var_canmnt}
3185 do_facet $facet umount $mnt
3186 do_facet $facet $ZFS set mountpoint=$mntpt $ds
3187 do_facet $facet $ZFS set canmount=$canmnt $ds
3193 local fstype=$(facet_fstype $facet)
3195 mount_$fstype $facet
3200 local fstype=$(facet_fstype $facet)
3202 unmount_$fstype $facet
3209 # make sure we are using the primary server, so test-framework will
3210 # be able to clean up properly.
3211 activemds=`facet_active mds1`
3212 if [ $activemds != "mds1" ]; then
3216 local clients=$CLIENTS
3217 [ -z $clients ] && clients=$(hostname)
3219 zconf_umount_clients $clients $MOUNT "$*" || true
3220 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
3222 [ "$CLIENTONLY" ] && return
3223 # The add fn does rm ${facet}active file, this would be enough
3224 # if we use do_facet <facet> only after the facet added, but
3225 # currently we use do_facet mds in local.sh
3226 for num in `seq $MDSCOUNT`; do
3228 rm -f ${TMP}/mds${num}active
3230 combined_mgs_mds && rm -f $TMP/mgsactive
3232 for num in `seq $OSTCOUNT`; do
3234 rm -f $TMP/ost${num}active
3237 if ! combined_mgs_mds ; then
3244 cleanup_echo_devs () {
3245 local devs=$($LCTL dl | grep echo | awk '{print $4}')
3247 for dev in $devs; do
3248 $LCTL --device $dev cleanup
3249 $LCTL --device $dev detach
3254 nfs_client_mode && return
3263 combined_mgs_mds () {
3264 [[ "$(mdsdevname 1)" = "$(mgsdevname)" ]] &&
3265 [[ "$(facet_host mds1)" = "$(facet_host mgs)" ]]
3269 echo -n "$1" | tr '[:upper:]' '[:lower:]'
3273 echo -n "$1" | tr '[:lower:]' '[:upper:]'
3279 local fsname=${3:-"$FSNAME"}
3280 local type=$(facet_type $facet)
3281 local index=$(facet_index $facet)
3282 local fstype=$(facet_fstype $facet)
3283 local host=$(facet_host $facet)
3288 if [ $type == MGS ] && combined_mgs_mds; then
3292 if [ $type == MGS ] || ( [ $type == MDS ] &&
3293 [ "$dev" == $(mgsdevname) ] &&
3294 [ "$host" == "$(facet_host mgs)" ] ); then
3297 opts="--mgsnode=$MGSNID"
3300 if [ $type != MGS ]; then
3301 opts+=" --fsname=$fsname --$(lower ${type/MDS/MDT}) \
3305 var=${facet}failover_HOST
3306 if [ -n "${!var}" ] && [ ${!var} != $(facet_host $facet) ]; then
3307 opts+=" --failnode=$(h2$NETTYPE ${!var})"
3310 opts+=${TIMEOUT:+" --param=sys.timeout=$TIMEOUT"}
3311 opts+=${LDLM_TIMEOUT:+" --param=sys.ldlm_timeout=$LDLM_TIMEOUT"}
3313 if [ $type == MDS ]; then
3314 opts+=${SECLEVEL:+" --param=mdt.sec_level"}
3315 opts+=${MDSCAPA:+" --param-mdt.capa=$MDSCAPA"}
3316 opts+=${STRIPE_BYTES:+" --param=lov.stripesize=$STRIPE_BYTES"}
3317 opts+=${STRIPES_PER_OBJ:+" --param=lov.stripecount=$STRIPES_PER_OBJ"}
3318 opts+=${L_GETIDENTITY:+" --param=mdt.identity_upcall=$L_GETIDENTITY"}
3320 if [ $fstype == ldiskfs ]; then
3321 # Check for wide striping
3322 if [ $OSTCOUNT -gt 160 ]; then
3323 MDSJOURNALSIZE=${MDSJOURNALSIZE:-4096}
3324 fs_mkfs_opts+="-O large_xattr"
3327 fs_mkfs_opts+=${MDSJOURNALSIZE:+" -J size=$MDSJOURNALSIZE"}
3328 if [ ! -z $EJOURNAL ]; then
3329 fs_mkfs_opts+=${MDSJOURNALSIZE:+" device=$EJOURNAL"}
3331 fs_mkfs_opts+=${MDSISIZE:+" -i $MDSISIZE"}
3335 if [ $type == OST ]; then
3336 opts+=${SECLEVEL:+" --param=ost.sec_level"}
3337 opts+=${OSSCAPA:+" --param=ost.capa=$OSSCAPA"}
3339 if [ $fstype == ldiskfs ]; then
3340 fs_mkfs_opts+=${OSTJOURNALSIZE:+" -J size=$OSTJOURNALSIZE"}
3344 opts+=" --backfstype=$fstype"
3347 if [ -n "${!var}" ]; then
3348 opts+=" --device-size=${!var}"
3351 var=$(upper $fstype)_MKFS_OPTS
3352 fs_mkfs_opts+=${!var:+" ${!var}"}
3354 var=${type}_FS_MKFS_OPTS
3355 fs_mkfs_opts+=${!var:+" ${!var}"}
3357 if [ -n "${fs_mkfs_opts## }" ]; then
3358 opts+=" --mkfsoptions=\\\"${fs_mkfs_opts## }\\\""
3362 opts+=${!var:+" ${!var}"}
3367 check_ost_indices() {
3368 local index_count=${#OST_INDICES[@]}
3369 [[ $index_count -eq 0 || $OSTCOUNT -le $index_count ]] && return 0
3371 # OST count is greater than the index count in $OST_INDEX_LIST.
3372 # We need check whether there are duplicate indices.
3376 for i in $(seq $((index_count + 1)) $OSTCOUNT); do
3377 index=$(facet_index ost$i)
3378 for j in $(seq 0 $((index_count - 1))); do
3379 [[ $index -ne ${OST_INDICES[j]} ]] ||
3380 error "ost$i has the same index $index as ost$((j+1))"
3393 # We need ldiskfs here, may as well load them all
3395 [ "$CLIENTONLY" ] && return
3396 echo Formatting mgs, mds, osts
3397 if ! combined_mgs_mds ; then
3398 echo "Format mgs: $(mgsdevname)"
3399 add mgs $(mkfs_opts mgs $(mgsdevname)) --reformat \
3400 $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} ||
3404 for num in $(seq $MDSCOUNT); do
3405 echo "Format mds$num: $(mdsdevname $num)"
3406 add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
3407 --reformat $(mdsdevname $num) $(mdsvdevname $num) \
3408 ${quiet:+>/dev/null} || exit 10
3411 export OST_INDICES=($(hostlist_expand "$OST_INDEX_LIST"))
3413 for num in $(seq $OSTCOUNT); do
3414 echo "Format ost$num: $(ostdevname $num)"
3415 add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
3416 --reformat $(ostdevname $num) $(ostvdevname ${num}) \
3417 ${quiet:+>/dev/null} || exit 10
3422 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
3426 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
3430 # 0: success, the old identity set already.
3431 # 1: success, the old identity does not set.
3436 local j=`expr $num - 1`
3437 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
3439 if [ -z "$MDT" ]; then
3443 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
3446 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
3448 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
3451 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
3453 if [ $old = "NONE" ]; then
3462 zconf_umount `hostname` $1 || error "umount failed"
3463 zconf_mount `hostname` $1 || error "mount failed"
3471 rm -f $TMP/${facet}active
3472 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" || return 1
3477 local mdt_count=${1:-$MDSCOUNT}
3478 local ost_count=${2:-$OSTCOUNT}
3481 for num in $(seq $mdt_count); do
3482 DEVNAME=$(mdsdevname $num)
3483 writeconf_facet mds$num $DEVNAME || rc=$?
3486 for num in $(seq $ost_count); do
3487 DEVNAME=$(ostdevname $num)
3488 writeconf_facet ost$num $DEVNAME || rc=$?
3494 nfs_client_mode && return
3496 sanity_mount_check ||
3497 error "environments are insane!"
3501 if [ -z "$CLIENTONLY" ]; then
3502 echo Setup mgs, mdt, osts
3503 echo $WRITECONF | grep -q "writeconf" && \
3505 if ! combined_mgs_mds ; then
3506 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
3509 for num in `seq $MDSCOUNT`; do
3510 DEVNAME=$(mdsdevname $num)
3511 start mds$num $DEVNAME $MDS_MOUNT_OPTS
3513 # We started mds, now we should set failover variables properly.
3514 # Set mds${num}failover_HOST if it is not set (the default failnode).
3515 local varname=mds${num}failover_HOST
3516 if [ -z "${!varname}" ]; then
3517 eval mds${num}failover_HOST=$(facet_host mds$num)
3520 if [ $IDENTITY_UPCALL != "default" ]; then
3521 switch_identity $num $IDENTITY_UPCALL
3524 for num in `seq $OSTCOUNT`; do
3525 DEVNAME=$(ostdevname $num)
3526 start ost$num $DEVNAME $OST_MOUNT_OPTS
3528 # We started ost$num, now we should set ost${num}failover variable properly.
3529 # Set ost${num}failover_HOST if it is not set (the default failnode).
3530 varname=ost${num}failover_HOST
3531 if [ -z "${!varname}" ]; then
3532 eval ost${num}failover_HOST=$(facet_host ost${num})
3540 # wait a while to allow sptlrpc configuration be propogated to targets,
3541 # only needed when mounting new target devices.
3546 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
3548 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
3551 if [ "$MOUNT_2" ]; then
3552 mount_client $MOUNT2
3553 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
3558 # by remounting mdt before ost, initial connect from mdt to ost might
3559 # timeout because ost is not ready yet. wait some time to its fully
3560 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
3561 # by a context negotiation rpc with $TIMEOUT.
3562 # FIXME better by monitoring import status.
3565 sleep $((TIMEOUT + 5))
3571 mounted_lustre_filesystems() {
3572 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
3575 init_facet_vars () {
3576 [ "$CLIENTONLY" ] && return 0
3583 eval export ${facet}_dev=${device}
3584 eval export ${facet}_opt=\"$@\"
3586 local dev=${facet}_dev
3588 # We need to loop for the label
3589 # in case its not initialized yet.
3590 for wait_time in {0,1,3,5,10}; do
3592 if [ $wait_time -gt 0 ]; then
3593 echo "${!dev} not yet initialized,"\
3594 "waiting ${wait_time} seconds."
3598 local label=$(devicelabel ${facet} ${!dev})
3600 # Check to make sure the label does
3601 # not include ffff at the end of the label.
3602 # This indicates it has not been initialized yet.
3604 if [[ $label =~ [f|F]{4}$ ]]; then
3605 # label is not initialized, unset the result
3606 # and either try again or fail
3613 [ -z "$label" ] && echo no label for ${!dev} && exit 1
3615 eval export ${facet}_svc=${label}
3617 local varname=${facet}failover_HOST
3618 if [ -z "${!varname}" ]; then
3619 eval export $varname=$(facet_host $facet)
3622 varname=${facet}_HOST
3623 if [ -z "${!varname}" ]; then
3624 eval export $varname=$(facet_host $facet)
3627 # ${facet}failover_dev is set in cfg file
3628 varname=${facet}failover_dev
3629 if [ -n "${!varname}" ] ; then
3630 eval export ${facet}failover_dev=${!varname}
3632 eval export ${facet}failover_dev=$device
3635 # get mount point of already mounted device
3636 # is facet_dev is already mounted then use the real
3637 # mount point of this facet; otherwise use $(facet_mntpt $facet)
3638 # i.e. ${facet}_MOUNT if specified by user or default
3639 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
3640 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
3641 if [ -z $mntpt ]; then
3642 mntpt=$(facet_mntpt $facet)
3644 eval export ${facet}_MOUNT=$mntpt
3647 init_facets_vars () {
3650 if ! remote_mds_nodsh; then
3651 for num in $(seq $MDSCOUNT); do
3652 DEVNAME=`mdsdevname $num`
3653 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
3657 combined_mgs_mds || init_facet_vars mgs $(mgsdevname) $MGS_MOUNT_OPTS
3659 if ! remote_ost_nodsh; then
3660 for num in $(seq $OSTCOUNT); do
3661 DEVNAME=$(ostdevname $num)
3662 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
3667 osc_ensure_active () {
3672 while [ $period -lt $timeout ]; do
3673 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
3674 if [ $count -eq 0 ]; then
3678 echo "There are $count OST are inactive, wait $period seconds, and try again"
3680 period=$((period+3))
3683 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
3686 set_conf_param_and_check() {
3690 local ORIG=$(do_facet $myfacet "$TEST")
3691 if [ $# -gt 3 ]; then
3697 echo "Setting $PARAM from $ORIG to $FINAL"
3698 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" ||
3699 error "conf_param $PARAM failed"
3701 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" ||
3702 error "check $PARAM failed!"
3705 init_param_vars () {
3707 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3709 log "Using TIMEOUT=$TIMEOUT"
3711 osc_ensure_active $SINGLEMDS $TIMEOUT
3712 osc_ensure_active client $TIMEOUT
3714 if [ -n "$(lctl get_param -n mdc.*.connect_flags|grep jobstats)" ]; then
3715 local current_jobid_var=$($LCTL get_param -n jobid_var)
3717 if [ $JOBID_VAR = "existing" ]; then
3718 echo "keeping jobstats as $current_jobid_var"
3719 elif [ $current_jobid_var != $JOBID_VAR ]; then
3720 echo "seting jobstats to $JOBID_VAR"
3722 set_conf_param_and_check client \
3723 "$LCTL get_param -n jobid_var" \
3724 "$FSNAME.sys.jobid_var" $JOBID_VAR
3727 echo "jobstats not supported by server"
3730 if [ $QUOTA_AUTO -ne 0 ]; then
3731 if [ "$ENABLE_QUOTA" ]; then
3732 echo "enable quota as required"
3733 setup_quota $MOUNT || return 2
3735 echo "disable quota as required"
3736 # $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
3742 nfs_client_mode () {
3743 if [ "$NFSCLIENT" ]; then
3744 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
3745 local clients=$CLIENTS
3746 [ -z $clients ] && clients=$(hostname)
3748 # FIXME: remove hostname when 19215 fixed
3749 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
3750 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
3751 if [[ ${#nfsexport[@]} -eq 0 ]]; then
3752 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
3754 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
3760 check_config_client () {
3763 local mounted=$(mount | grep " $mntpt ")
3764 if [ "$CLIENTONLY" ]; then
3766 # CLIENTONLY should not depend on *_HOST settings
3767 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
3768 # in theory someone could create a new,
3769 # client-only config file that assumed lustre was already
3770 # configured and didn't set the MGSNID. If MGSNID is not set,
3771 # then we should use the mgs nid currently being used
3772 # as the default value. bug 18021
3773 [[ x$MGSNID = x ]] &&
3776 if [[ x$mgc != xMGC$MGSNID ]]; then
3777 if [ "$mgs_HOST" ]; then
3778 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
3779 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
3780 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
3786 local myMGS_host=$mgs_HOST
3787 if [ "$NETTYPE" = "ptl" ]; then
3788 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
3791 echo Checking config lustre mounted on $mntpt
3792 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
3793 mgshost=$(echo $mgshost | awk -F: '{print $1}')
3795 # if [ "$mgshost" != "$myMGS_host" ]; then
3796 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
3797 # Please use correct config or set mds_HOST correctly!"
3802 check_config_clients () {
3803 local clients=${CLIENTS:-$HOSTNAME}
3806 nfs_client_mode && return
3808 do_rpc_nodes "$clients" check_config_client $mntpt
3810 sanity_mount_check || error "environments are insane!"
3814 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3815 local cltimeout=$(lctl get_param -n timeout)
3816 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
3817 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
3824 [ -z $mntpt ] && return 1
3825 local mounted=$(mounted_lustre_filesystems)
3827 echo $mounted' ' | grep -w -q $mntpt' '
3831 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
3835 # empty lustre filesystem may have empty directories lost+found and .lustre
3837 # exclude .lustre & lost+found
3838 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
3839 -print | wc -l) = 1 ] || return 1
3840 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found || return 1
3841 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.4.0) ]; then
3842 # exclude .lustre/fid (LU-2780)
3843 [ $(find $1/.lustre -maxdepth 1 -name fid -prune -o \
3844 -print | wc -l) = 1 ] || return 1
3846 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre || return 1
3851 check_and_setup_lustre() {
3852 nfs_client_mode && return
3854 local MOUNTED=$(mounted_lustre_filesystems)
3858 # both MOUNT and MOUNT2 are not mounted
3859 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
3860 [ "$REFORMAT" ] && formatall
3861 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
3863 is_mounted $MOUNT || error "NAME=$NAME not mounted"
3864 export I_MOUNTED=yes
3868 elif is_mounted $MOUNT2; then
3870 # MOUNT2 is mounted, while MOUNT_2 is not set
3871 if ! [ "$MOUNT_2" ]; then
3872 cleanup_mount $MOUNT2
3873 export I_UMOUNTED2=yes
3876 # MOUNT2 is mounted, MOUNT_2 is set
3878 # FIXME: what to do if check_config failed?
3880 # 1) remote client has mounted other Lustre fs ?
3881 # 2) it has insane env ?
3882 # let's try umount MOUNT2 on all clients and mount it again:
3883 if ! check_config_clients $MOUNT2; then
3884 cleanup_mount $MOUNT2
3885 restore_mount $MOUNT2
3886 export I_MOUNTED2=yes
3891 # MOUNT is mounted MOUNT2 is not mounted
3892 elif [ "$MOUNT_2" ]; then
3893 restore_mount $MOUNT2
3894 export I_MOUNTED2=yes
3898 # FIXME: what to do if check_config failed?
3900 # 1) remote client has mounted other Lustre fs?
3901 # 2) lustre is mounted on remote_clients atall ?
3902 check_config_clients $MOUNT
3906 set_default_debug_nodes $(comma_list $(nodes_list))
3909 if [ $(lower $OSD_TRACK_DECLARES_LBUG) == 'yes' ] ; then
3911 [ "$(facet_fstype ost1)" = "ldiskfs" ] &&
3912 facets="$(get_facets OST)"
3913 [ "$(facet_fstype mds1)" = "ldiskfs" ] &&
3914 facets="$facets,$(get_facets MDS)"
3915 [ "$(facet_fstype mgs)" = "ldiskfs" ] &&
3916 facets="$facets,mgs"
3917 local nodes="$(facets_hosts ${facets})"
3918 if [ -n "$nodes" ] ; then
3919 do_nodes $nodes "$LCTL set_param \
3920 osd-ldiskfs.track_declares_assert=1 || true"
3929 #Enable remote MDT create for testing
3930 for num in $(seq $MDSCOUNT); do
3932 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
3936 if [ "$ONLY" == "setup" ]; then
3942 local clients=${CLIENTS:-$HOSTNAME}
3945 zconf_mount_clients $clients $mntpt
3949 local clients=${CLIENTS:-$HOSTNAME}
3952 zconf_umount_clients $clients $mntpt
3955 cleanup_and_setup_lustre() {
3956 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
3957 lctl set_param debug=0 || true
3959 if [ "$ONLY" == "cleanup" ]; then
3963 check_and_setup_lustre
3966 # Get all of the server target devices from a given server node and type.
3973 if [ "$type" == ost ]; then
3974 devs=$(get_osd_param $node "" mntdev)
3976 devs=$(do_node $node $LCTL get_param -n osd-*.$FSNAME-M*.mntdev)
3978 for dev in $devs; do
3980 *loop*) do_node $node "losetup $dev" | \
3981 sed -e "s/.*(//" -e "s/).*//" ;;
3987 # Get all of the server target devices.
3992 # Master MDS parameters used by lfsck
3993 MDTNODE=$(facet_active_host $SINGLEMDS)
3994 MDTDEV=$(echo $(get_mnt_devs $MDTNODE mdt) | awk '{print $1}')
3998 for node in $(mdts_nodes); do
3999 MDTDEVS[i]=$(get_mnt_devs $node mdt)
4005 for node in $(osts_nodes); do
4006 OSTDEVS[i]=$(get_mnt_devs $node ost)
4011 # Run e2fsck on MDT or OST device.
4016 local cmd="$E2FSCK -d -v -t -t -f $extra_opts $target_dev"
4017 local log=$TMP/e2fsck.log
4021 do_node $node $cmd 2>&1 | tee $log
4023 if [ -n "$(grep "DNE mode isn't supported" $log)" ]; then
4025 if [ $MDSCOUNT -gt 1 ]; then
4026 skip "DNE mode isn't supported!"
4030 error "It's not DNE mode."
4035 [ $rc -le $FSCK_MAX_ERR ] ||
4036 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4042 # Run resize2fs on MDT or OST device.
4051 do_facet $facet "$RESIZE2FS $opts $device $size"
4054 # verify a directory is shared among nodes.
4055 check_shared_dir() {
4057 local list=${2:-$(comma_list $(nodes_list))}
4059 [ -z "$dir" ] && return 1
4060 do_rpc_nodes "$list" check_logdir $dir
4061 check_write_access $dir "$list" || return 1
4065 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
4072 [[ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]] ||
4073 { skip "Lustre 2.2.0 lacks the patch for LU-1255"; exit 0; }
4075 check_shared_dir $SHARED_DIRECTORY ||
4076 error "$SHARED_DIRECTORY isn't a shared directory"
4078 export MDSDB=$SHARED_DIRECTORY/mdsdb
4079 export OSTDB=$SHARED_DIRECTORY/ostdb
4081 # DNE is not supported, so when running e2fsck on a DNE filesystem,
4082 # we only pass master MDS parameters.
4083 run_e2fsck $MDTNODE $MDTDEV "-n --mdsdb $MDSDB"
4088 for node in $(osts_nodes); do
4089 for dev in ${OSTDEVS[i]}; do
4090 run_e2fsck $node $dev "-n --mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
4091 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
4092 ostidx=$((ostidx + 1))
4098 # Run lfsck on server node if lfsck can't be found on client (LU-2571)
4099 run_lfsck_remote() {
4100 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
4105 #Check if lustre is already mounted
4106 do_rpc_nodes $client is_mounted $MOUNT || mounted=false
4108 zconf_mount $client $MOUNT ||
4109 error "failed to mount Lustre on $client"
4113 do_node $client $cmd || rc=$?
4114 #Umount if necessary
4116 zconf_umount $client $MOUNT ||
4117 error "failed to unmount Lustre on $client"
4120 [ $rc -le $FSCK_MAX_ERR ] ||
4121 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4122 echo "lfsck finished with rc=$rc"
4128 local facets="client $SINGLEMDS"
4134 for facet in $facets; do
4135 node=$(facet_active_host $facet)
4136 if check_progs_installed $node $LFSCK_BIN; then
4141 ! $found && error "None of \"$facets\" supports lfsck"
4143 run_lfsck_remote $node || rc=$?
4145 rm -rvf $MDSDB* $OSTDB* || true
4149 dump_file_contents() {
4155 if [ -z "$nodes" -o -z "$dir" -o -z "$logname" ]; then
4156 error_noexit false \
4157 "Invalid parameters for dump_file_contents()"
4160 for node in ${nodes}; do
4161 do_node $node "for i in \\\$(find $dir -type f); do
4162 echo ====\\\${i}=======================;
4164 done" >> ${logname}.${node}.log
4168 dump_command_output() {
4174 if [ -z "$nodes" -o -z "$cmd" -o -z "$logname" ]; then
4175 error_noexit false \
4176 "Invalid parameters for dump_command_output()"
4180 for node in ${nodes}; do
4181 do_node $node "echo ====${cmd}=======================;
4182 $cmd" >> ${logname}.${node}.log
4189 # dump file contents from /proc/spl in case of zfs test
4190 if [ "$(facet_fstype ost1)" = "zfs" ]; then
4191 dump_file_contents "$(osts_nodes)" "/proc/spl" "${logname}"
4192 dump_command_output \
4193 "$(osts_nodes)" "zpool events -v" "${logname}"
4196 if [ "$(facet_fstype $SINGLEMDS)" = "zfs" ]; then
4197 dump_file_contents "$(mdts_nodes)" "/proc/spl" "${logname}"
4198 dump_command_output \
4199 "$(mdts_nodes)" "zpool events -v" "${logname}"
4203 check_and_cleanup_lustre() {
4204 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
4210 if is_mounted $MOUNT; then
4211 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
4212 error "remove sub-test dirs failed"
4213 [ "$ENABLE_QUOTA" ] && restore_quota || true
4216 if [ "$I_UMOUNTED2" = "yes" ]; then
4217 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
4220 if [ "$I_MOUNTED2" = "yes" ]; then
4221 cleanup_mount $MOUNT2
4224 if [ "$I_MOUNTED" = "yes" ]; then
4225 cleanupall -f || error "cleanup failed"
4233 wait_for_function () {
4236 # suppress fn both stderr and stdout
4237 if [ "$1" = "--quiet" ]; then
4239 quiet=" > /dev/null 2>&1"
4251 eval $fn $quiet && return 0
4253 wait=$((wait + sleep))
4254 [ $wait -lt $max ] || return 1
4255 echo waiting $fn, $((max - wait)) secs left ...
4265 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
4266 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
4267 echo "Network not available!"
4271 echo `date +"%H:%M:%S (%s)"` network interface is UP
4279 # Convert a space-delimited list to a comma-delimited list. If the input is
4280 # only whitespace, ensure the output is empty (i.e. "") so [ -n $list ] works
4282 # echo is used to convert newlines to spaces, since it doesn't
4283 # introduce a trailing space as using "tr '\n' ' '" does
4284 echo $(tr -s " " "\n" <<< $* | sort -b -u) | tr ' ' ','
4290 echo $list | grep -qw $item
4293 # list, excluded are the comma separated lists
4294 exclude_items_from_list () {
4300 for item in ${excluded//,/ }; do
4301 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
4303 echo $(comma_list $list)
4306 # list, expand are the comma separated lists
4308 local list=${1//,/ }
4309 local expand=${2//,/ }
4312 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
4313 echo $(comma_list $expanded)
4316 testslist_filter () {
4317 local script=$LUSTRE/tests/${TESTSUITE}.sh
4319 [ -f $script ] || return 0
4321 local start_at=$START_AT
4322 local stop_at=$STOP_AT
4324 local var=${TESTSUITE//-/_}_START_AT
4325 [ x"${!var}" != x ] && start_at=${!var}
4326 var=${TESTSUITE//-/_}_STOP_AT
4327 [ x"${!var}" != x ] && stop_at=${!var}
4329 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
4330 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
4331 /^'${start_at}'$/ {flag = 0}
4332 {if (flag == 1) print $0}
4333 /^'${stop_at}'$/ { flag = 1 }'
4337 (cd `dirname $1`; echo $PWD/`basename $1`)
4341 local types=${1:-"OST MDS MGS"}
4345 for entry in $types; do
4346 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
4347 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
4350 MGS ) list="$list $name";;
4351 MDS|OST|AGT ) local count=${type}COUNT
4352 for ((i=1; i<=${!count}; i++)) do
4353 list="$list ${name}$i"
4355 * ) error "Invalid facet type"
4359 echo $(comma_list $list)
4362 ##################################
4363 # Adaptive Timeouts funcs
4366 # only check mds, we assume at_max is the same on all nodes
4367 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
4368 if [ $at_max -eq 0 ]; then
4379 # suppose that all ost-s have the same $at value set
4380 [ $facet != "ost" ] || facet=ost1
4382 do_facet $facet "lctl get_param -n $at"
4400 if [ $facet == "ost" ]; then
4401 facet=$(get_facets OST)
4402 elif [ $facet == "mds" ]; then
4403 facet=$(get_facets MDS)
4405 hosts=$(expand_list $hosts $(facets_hosts $facet))
4408 do_nodes $hosts lctl set_param at_max=$at_max
4411 ##################################
4415 # OBD_FAIL_MDS_ALL_REQUEST_NET
4417 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
4418 do_facet client "$1" || RC=$?
4419 do_facet $SINGLEMDS lctl set_param fail_loc=0
4424 # OBD_FAIL_MDS_ALL_REPLY_NET
4426 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x122
4428 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4432 drop_reint_reply() {
4433 # OBD_FAIL_MDS_REINT_NET_REP
4435 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x119
4437 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4441 drop_update_reply() {
4442 # OBD_FAIL_UPDATE_OBJ_NET_REP
4446 do_facet mds${index} lctl set_param fail_loc=0x1701
4447 do_facet client "$@" || RC=$?
4448 do_facet mds${index} lctl set_param fail_loc=0
4453 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4456 local timeout=${2:-0}
4457 # default is (obd_timeout / 4) if unspecified
4458 echo "timeout is $timeout/$2"
4459 do_facet ost1 lctl set_param fail_val=$timeout fail_loc=0x80000214
4460 do_facet client "$1" || RC=$?
4461 do_facet client "sync"
4462 do_facet ost1 lctl set_param fail_loc=0
4466 drop_ldlm_cancel() {
4467 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
4469 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4470 do_nodes $list lctl set_param fail_loc=0x304
4472 do_facet client "$@" || RC=$?
4474 do_nodes $list lctl set_param fail_loc=0
4478 drop_bl_callback_once() {
4480 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
4481 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
4482 do_facet client lctl set_param fail_loc=0x80000305
4483 do_facet client "$@" || rc=$?
4484 do_facet client lctl set_param fail_loc=0
4485 do_facet client lctl set_param fail_val=0
4486 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
4490 drop_bl_callback() {
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=0x305
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
4503 #define OBD_FAIL_LDLM_REPLY 0x30c
4505 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4506 do_nodes $list lctl set_param fail_loc=0x30c
4508 do_facet client "$@" || RC=$?
4510 do_nodes $list lctl set_param fail_loc=0
4514 drop_ldlm_reply_once() {
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=0x8000030c
4520 do_facet client "$@" || RC=$?
4522 do_nodes $list lctl set_param fail_loc=0
4530 echo "clearing fail_loc on $facet"
4531 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
4534 set_nodes_failloc () {
4535 do_nodes $(comma_list $1) lctl set_param fail_val=0 fail_loc=$2
4538 cancel_lru_locks() {
4539 $LCTL mark "cancel_lru_locks $1 start"
4541 if [ $1 != "MGC" ]; then
4542 for d in $(lctl get_param -N ldlm.namespaces.*.lru_size |
4544 $LCTL set_param -n $d=clear
4546 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 |
4550 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lru_size \
4556 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lock_unused_count \
4558 if [ $(cat $d) != 0 ]; then
4559 echo "ldlm.namespaces.$(echo "$d" |
4560 cut -f 7 -d'/').lock_unused_count=$(cat $d)"
4565 $LCTL mark "cancel_lru_locks $1 stop"
4570 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
4571 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
4572 echo "$DEFAULT_LRU_SIZE"
4577 lctl set_param ldlm.namespaces.*$1*.lru_size=0
4580 lru_resize_disable()
4582 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
4588 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] && RC=1
4594 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
4595 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
4596 echo there is still data in page cache $FILE ?
4597 lctl get_param -n $FILE
4605 DEBUGSAVE="$(lctl get_param -n debug)"
4609 [ -n "$DEBUGSAVE" ] && \
4610 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
4615 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
4618 debug_size_restore() {
4619 [ -n "$DEBUG_SIZE_SAVED" ] && \
4620 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
4624 start_full_debug_logging() {
4629 local DEBUG_SIZE=150
4631 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
4632 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
4635 stop_full_debug_logging() {
4640 # prints bash call stack
4643 for (( i=1; i < ${#BASH_LINENO[*]} ; i++ )) ; do
4644 local s=${BASH_SOURCE[$i]}
4645 local l=${BASH_LINENO[$i-1]}
4646 local f=${FUNCNAME[$i]}
4647 echo " = $s:$l:$f()"
4651 ##################################
4653 ##################################
4656 local TYPE=${TYPE:-"FAIL"}
4659 # do not dump logs if $1=false
4660 if [ "x$1" = "xfalse" ]; then
4666 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
4670 # We need to dump the logs on all nodes
4672 gather_logs $(comma_list $(nodes_list))
4676 [ "$TESTSUITELOG" ] &&
4677 echo "$TESTSUITE: $TYPE: $TESTNAME $@" >> $TESTSUITELOG
4678 if [ -z "$*" ]; then
4679 echo "error() without useful message, please fix" > $LOGDIR/err
4681 if [[ `echo $TYPE | grep ^IGNORE` ]]; then
4682 echo "$@" > $LOGDIR/ignore
4684 echo "$@" > $LOGDIR/err
4691 local log=$TESTSUITELOG
4693 [ -f "$log" ] && grep -q FAIL $log && status=1
4706 # use only if we are ignoring failures for this test, bugno required.
4707 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
4708 # e.g. error_ignore bz5494 "your message" or
4709 # error_ignore LU-5494 "your message"
4711 local TYPE="IGNORE ($1)"
4716 error_and_remount() {
4718 remount_client $MOUNT
4723 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
4728 log " SKIP: $TESTSUITE $TESTNAME $@"
4730 if [[ -n "$ALWAYS_SKIPPED" ]]; then
4731 skip_logged $TESTNAME "$@"
4734 echo "$@" > $LOGDIR/skip
4737 [[ -n "$TESTSUITELOG" ]] &&
4738 echo "$TESTSUITE: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
4741 build_test_filter() {
4742 EXCEPT="$EXCEPT $(testslist_filter)"
4745 if [[ $O = [0-9]*-[0-9]* ]]; then
4746 for num in $(seq $(echo $O | tr '-' ' ')); do
4754 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
4755 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
4756 [ "$EXCEPT_SLOW" ] && \
4757 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
4758 for E in $EXCEPT; do
4759 eval EXCEPT_${E}=true
4761 for E in $ALWAYS_EXCEPT; do
4762 eval EXCEPT_ALWAYS_${E}=true
4764 for E in $EXCEPT_SLOW; do
4765 eval EXCEPT_SLOW_${E}=true
4767 for G in $GRANT_CHECK_LIST; do
4768 eval GCHECK_ONLY_${G}=true
4773 if [[ $1 = [a-z]* ]]; then
4780 # print a newline if the last test was skipped
4781 export LAST_SKIPPED=
4782 export ALWAYS_SKIPPED=
4784 # Main entry into test-framework. This is called with the name and
4785 # description of a test. The name is used to find the function to run
4786 # the test using "test_$name".
4788 # This supports a variety of methods of specifying specific test to
4789 # run or not run. These need to be documented...
4794 export base=$(basetest $1)
4795 if [ -n "$ONLY" ]; then
4797 if [ ${!testname}x != x ]; then
4798 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4799 run_one_logged $1 "$2"
4803 if [ ${!testname}x != x ]; then
4804 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4805 run_one_logged $1 "$2"
4815 if [ ${!testname}x != x ]; then
4816 TESTNAME=test_$1 skip "skipping excluded test $1"
4819 testname=EXCEPT_$base
4820 if [ ${!testname}x != x ]; then
4821 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
4824 testname=EXCEPT_ALWAYS_$1
4825 if [ ${!testname}x != x ]; then
4826 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
4829 testname=EXCEPT_ALWAYS_$base
4830 if [ ${!testname}x != x ]; then
4831 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
4834 testname=EXCEPT_SLOW_$1
4835 if [ ${!testname}x != x ]; then
4836 TESTNAME=test_$1 skip "skipping SLOW test $1"
4839 testname=EXCEPT_SLOW_$base
4840 if [ ${!testname}x != x ]; then
4841 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
4847 run_one_logged $1 "$2"
4854 module_loaded lnet || load_modules
4866 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
4871 strace -o $TMP/$1.strace -ttt $*
4873 log "FINISHED: $*: rc $RC"
4880 banner test complete, duration $duration sec
4881 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
4882 echo duration $duration >>$TESTSUITELOG
4886 # Set TEST_STATUS here. It will be used for logging the result.
4889 if [[ -f $LOGDIR/err ]]; then
4891 elif [[ -f $LOGDIR/skip ]]; then
4894 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
4898 local FFREE=$(do_node $SINGLEMDS \
4899 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
4900 local FTOTAL=$(do_node $SINGLEMDS \
4901 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
4903 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
4907 echo -n "Resetting fail_loc on all nodes..."
4908 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 \
4909 fail_val=0 2>/dev/null || true"
4915 # Log a message (on all nodes) padded with "=" before and after.
4916 # Also appends a timestamp and prepends the testsuite name.
4919 EQUALS="===================================================================================================="
4921 msg="== ${TESTSUITE} $*"
4923 [[ $last != "=" && $last != " " ]] && msg="$msg "
4924 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
4925 # always include at least == after the message
4926 log "$msg== $(date +"%H:%M:%S (%s)")"
4930 # Run a single test function and cleanup after it.
4932 # This function should be run in a subshell so the test func can
4933 # exit() without stopping the whole script.
4938 export tfile=f${testnum}.${TESTSUITE}
4939 export tdir=d${testnum}.${TESTSUITE}
4940 export TESTNAME=test_$testnum
4941 local SAVE_UMASK=`umask`
4944 banner "test $testnum: $message"
4945 test_${testnum} || error "test_$testnum failed with $?"
4948 check_grant ${testnum} || error "check_grant $testnum failed with $?"
4949 check_catastrophe || error "LBUG/LASSERT detected"
4950 if [ "$PARALLEL" != "yes" ]; then
4951 ps auxww | grep -v grep | grep -q multiop &&
4952 error "multiop still running"
4962 # Wrapper around run_one to ensure:
4963 # - test runs in subshell
4964 # - output of test is saved to separate log file for error reporting
4965 # - test result is saved to data file
4968 local BEFORE=$(date +%s)
4970 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
4971 local test_log=$LOGDIR/$name
4972 local zfs_log_name=${TESTSUITE}.test_${1}.zfs_log
4973 local zfs_debug_log=$LOGDIR/$zfs_log_name
4975 rm -rf $LOGDIR/ignore
4977 local SAVE_UMASK=$(umask)
4981 log_sub_test_begin test_${1}
4982 (run_one $1 "$2") 2>&1 | tee -i $test_log
4983 local RC=${PIPESTATUS[0]}
4985 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] &&
4986 echo "test_$1 returned $RC" | tee $LOGDIR/err
4988 duration=$(($(date +%s) - $BEFORE))
4989 pass "$1" "(${duration}s)"
4991 if [[ -f $LOGDIR/err ]]; then
4992 TEST_ERROR=$(cat $LOGDIR/err)
4993 elif [[ -f $LOGDIR/ignore ]]; then
4994 TEST_ERROR=$(cat $LOGDIR/ignore)
4995 elif [[ -f $LOGDIR/skip ]]; then
4996 TEST_ERROR=$(cat $LOGDIR/skip)
4998 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
5000 if [[ "$TEST_STATUS" != "SKIP" ]] && [[ -f $TF_SKIP ]]; then
5004 if [ -f $LOGDIR/err ]; then
5005 log_zfs_info "$zfs_debug_log"
5006 $FAIL_ON_ERROR && exit $RC
5015 # Print information of skipped tests to result.yml
5018 log_sub_test_begin $1
5020 log_sub_test_end "SKIP" "0" "0" "$@"
5024 (cd $(dirname $1); echo $PWD/$(basename $1))
5029 export base=$(basetest $1)
5030 [ "$CHECK_GRANT" == "no" ] && return 0
5032 testname=GCHECK_ONLY_${base}
5033 [ ${!testname}x == x ] && return 0
5035 echo -n "checking grant......"
5037 local clients=$CLIENTS
5038 [ -z "$clients" ] && clients=$(hostname)
5040 # sync all the data and make sure no pending data on server
5041 do_nodes $clients sync
5044 client_grant=$(do_nodes $clients \
5045 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" |
5046 awk '{ total += $1 } END { printf("%0.0f", total) }')
5049 server_grant=$(do_nodes $(comma_list $(osts_nodes)) \
5050 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" |
5051 awk '{ total += $1 } END { printf("%0.0f", total) }')
5053 # check whether client grant == server grant
5054 if [[ $client_grant -ne $server_grant ]]; then
5055 echo "failed: client:${client_grant} server: ${server_grant}."
5056 do_nodes $(comma_list $(osts_nodes)) \
5057 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
5058 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
5061 echo "pass: client:${client_grant} server: ${server_grant}"
5065 ########################
5071 ost=`echo $1 | awk -F_ '{print $3}'`
5072 if [ -z $ost ]; then
5073 ost=`echo $1 | sed 's/-osc.*//'`
5078 ostuuid_from_index()
5080 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5083 ostname_from_index() {
5084 local uuid=$(ostuuid_from_index $1)
5088 index_from_ostuuid()
5090 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
5093 mdtuuid_from_index()
5095 $LFS mdts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5099 # Return unique identifier for given hostname
5102 echo $host_name | md5sum | cut -d' ' -f1
5106 # Returns list of ip addresses for each interface
5108 ip addr | awk '/inet\ / {print $2}' | awk -F\/ '{print $1}'
5113 # Cache address list to avoid mutiple execution of local_addr_list
5114 LOCAL_ADDR_LIST=${LOCAL_ADDR_LIST:-$(local_addr_list)}
5116 for i in $LOCAL_ADDR_LIST ; do
5117 [[ "$i" == "$addr" ]] && return 0
5124 local is_local="IS_LOCAL_$(host_id $host_name)"
5125 if [ -z "${!is_local-}" ] ; then
5127 local host_ip=$($LUSTRE/tests/resolveip $host_name)
5128 is_local_addr "$host_ip" && eval $is_local=1
5130 [[ "${!is_local}" == "1" ]]
5135 local_node $node && return 1
5142 for node in $(mdts_nodes); do
5143 remote_node $node && return 0
5150 [ "$CLIENTONLY" ] && return 0 || true
5151 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
5156 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
5157 MSKIPPED=1 && return 1
5164 for node in $(osts_nodes) ; do
5165 remote_node $node && return 0
5172 [ "$CLIENTONLY" ] && return 0 || true
5173 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5178 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
5179 OSKIPPED=1 && return 1
5186 MGS=$(facet_host mgs)
5187 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5192 remote_mds_nodsh || remote_ost_nodsh || \
5193 $(single_local_node $(comma_list $(nodes_list)))
5197 remote_ost && remote_mds
5200 # Get the active nodes for facets.
5208 for facet in ${facets//,/ }; do
5209 nodes="$nodes $(facet_active_host $facet)"
5212 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5216 # Get all of the active MDS nodes.
5218 echo -n $(facets_nodes $(get_facets MDS))
5221 # Get all of the active OSS nodes.
5223 echo -n $(facets_nodes $(get_facets OST))
5226 # Get all of the active AGT (HSM agent) nodes.
5228 echo -n $(facets_nodes $(get_facets AGT))
5231 # Get all of the client nodes and active server nodes.
5233 local nodes=$HOSTNAME
5237 # CLIENTS (if specified) contains the local client
5238 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5240 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5241 nodes="$nodes $(facets_nodes $(get_facets))"
5244 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5248 # Get all of the remote client nodes and remote active server nodes.
5249 remote_nodes_list () {
5250 echo -n $(nodes_list) | sed -re "s/\<$HOSTNAME\>//g"
5253 # Get all of the MDS nodes, including active and passive nodes.
5261 for i in $(seq $MDSCOUNT); do
5263 failover_host=mds${i}failover_HOST
5264 nodes="$nodes ${!host} ${!failover_host}"
5267 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5271 # Get all of the OSS nodes, including active and passive nodes.
5279 for i in $(seq $OSTCOUNT); do
5281 failover_host=ost${i}failover_HOST
5282 nodes="$nodes ${!host} ${!failover_host}"
5285 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5289 # Get all of the server nodes, including active and passive nodes.
5290 all_server_nodes () {
5295 nodes="$mgs_HOST $mgsfailover_HOST $(all_mdts_nodes) $(all_osts_nodes)"
5297 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5301 # Get all of the client and server nodes, including active and passive nodes.
5303 local nodes=$HOSTNAME
5307 # CLIENTS (if specified) contains the local client
5308 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5310 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5311 nodes="$nodes $(all_server_nodes)"
5314 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5318 init_clients_lists () {
5319 # Sanity check: exclude the local client from RCLIENTS
5320 local clients=$(hostlist_expand "$RCLIENTS")
5321 local rclients=$(exclude_items_from_list "$clients" $HOSTNAME)
5323 # Sanity check: exclude the dup entries
5324 RCLIENTS=$(for i in ${rclients//,/ }; do echo $i; done | sort -u)
5326 clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
5328 # Sanity check: exclude the dup entries from CLIENTS
5329 # for those configs which has SINGLCLIENT set to local client
5330 clients=$(for i in $clients; do echo $i; done | sort -u)
5332 CLIENTS=$(comma_list $clients)
5333 local -a remoteclients=($RCLIENTS)
5334 for ((i=0; $i<${#remoteclients[@]}; i++)); do
5335 varname=CLIENT$((i + 2))
5336 eval $varname=${remoteclients[i]}
5339 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
5342 get_random_entry () {
5345 rnodes=${rnodes//,/ }
5347 local -a nodes=($rnodes)
5348 local num=${#nodes[@]}
5349 local i=$((RANDOM * num * 2 / 65536))
5355 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
5360 lctl get_param version | grep -q patchless
5364 [ "$(lustre_version_code client)" = "$(lustre_version_code $SINGLEMDS)" -a \
5365 "$(lustre_version_code client)" = "$(lustre_version_code ost1)" ]
5370 echo $nodes | wc -w || true
5374 local nodes=$(osts_nodes)
5375 local osscount=$(get_node_count "$nodes")
5376 [ ! "$OSTCOUNT" = "$osscount" ]
5380 local nodes=$(mdts_nodes)
5381 local mdtcount=$(get_node_count "$nodes")
5382 [ ! "$MDSCOUNT" = "$mdtcount" ]
5385 generate_machine_file() {
5386 local nodes=${1//,/ }
5387 local machinefile=$2
5389 for node in $nodes; do
5390 echo $node >>$machinefile || \
5391 { echo "can not generate machinefile $machinefile" && return 1; }
5396 local file=$1/stripe
5399 $LFS getstripe -v $file || error "getstripe $file failed"
5403 setstripe_nfsserver () {
5406 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
5407 { print $1 }' /proc/mounts | cut -f 1 -d : | head -n1)
5409 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
5411 do_nodev $nfsserver lfs setstripe "$@"
5414 # Check and add a test group.
5420 local gid=$(getent group $group_name | cut -d: -f3)
5421 if [[ -n "$gid" ]]; then
5422 [[ "$gid" -eq "$group_id" ]] || {
5423 error_noexit "inconsistent group ID:" \
5424 "new: $group_id, old: $gid"
5428 groupadd -g $group_id $group_name
5435 # Check and add a test user.
5448 local uid=$(getent passwd $user_name | cut -d: -f3)
5449 if [[ -n "$uid" ]]; then
5450 if [[ "$uid" -eq "$user_id" ]]; then
5451 local dir=$(getent passwd $user_name | cut -d: -f6)
5452 if [[ "$dir" != "$home" ]]; then
5454 usermod -d $home $user_name
5458 error_noexit "inconsistent user ID:" \
5459 "new: $user_id, old: $uid"
5464 useradd -M -u $user_id -d $home -g $group_name $opts $user_name
5471 check_runas_id_ret() {
5473 local myRUNAS_UID=$1
5474 local myRUNAS_GID=$2
5477 if [ -z "$myRUNAS" ]; then
5478 error_exit "myRUNAS command must be specified for check_runas_id"
5481 $myRUNAS krb5_login.sh || \
5482 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
5484 mkdir $DIR/d0_runas_test
5486 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
5487 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
5488 rm -rf $DIR/d0_runas_test
5493 local myRUNAS_UID=$1
5494 local myRUNAS_GID=$2
5497 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
5498 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
5499 Please set RUNAS_ID to some UID which exists on MDS and client or
5500 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
5503 # obtain the UID/GID for MPI_USER
5507 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
5508 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
5510 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
5511 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
5514 # obtain and cache Kerberos ticket-granting ticket
5515 refresh_krb5_tgt() {
5516 local myRUNAS_UID=$1
5517 local myRUNAS_GID=$2
5520 if [ -z "$myRUNAS" ]; then
5521 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
5524 CLIENTS=${CLIENTS:-$HOSTNAME}
5525 do_nodes $CLIENTS "set -x
5526 if ! $myRUNAS krb5_login.sh; then
5527 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
5532 # Run multiop in the background, but wait for it to print
5533 # "PAUSING" to its stdout before returning from this function.
5534 multiop_bg_pause() {
5535 MULTIOP_PROG=${MULTIOP_PROG:-$MULTIOP}
5539 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
5542 echo "$MULTIOP_PROG $FILE v$ARGS"
5543 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
5545 echo "TMPPIPE=${TMPPIPE}"
5546 read -t 60 multiop_output < $TMPPIPE
5547 if [ $? -ne 0 ]; then
5552 if [ "$multiop_output" != "PAUSING" ]; then
5553 echo "Incorrect multiop output: $multiop_output"
5568 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
5574 inodes_available () {
5575 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{ print $4 }' |
5576 sort -un | head -n1) || return 1
5580 mdsrate_inodes_available () {
5581 local min_inodes=$(inodes_available)
5582 echo $((min_inodes * 99 / 100))
5585 # reset llite stat counters
5586 clear_llite_stats(){
5587 lctl set_param -n llite.*.stats 0
5590 # sum llite stat items
5591 calc_llite_stats() {
5592 local res=$(lctl get_param -n llite.*.stats |
5593 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5597 # reset osc stat counters
5599 lctl set_param -n osc.*.osc_stats 0
5602 # sum osc stat items
5604 local res=$(lctl get_param -n osc.*.osc_stats |
5605 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5610 awk '{sum += $1} END { printf("%0.0f", sum) }'
5613 calc_osc_kbytes () {
5614 df $MOUNT > /dev/null
5615 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
5618 # save_lustre_params(comma separated facet list, parameter_mask)
5619 # generate a stream of formatted strings (<facet> <param name>=<param value>)
5620 save_lustre_params() {
5626 for facet in ${facets//,/ }; do
5627 node=$(facet_active_host $facet)
5628 [[ *\ $node\ * = " $nodes " ]] && continue
5629 nodes="$nodes $node"
5631 do_node $node "$LCTL get_param $2 |
5632 while read s; do echo $facet \\\$s; done"
5636 # restore lustre parameters from input stream, produces by save_lustre_params
5637 restore_lustre_params() {
5642 while IFS=" =" read facet name val; do
5643 do_facet $facet "$LCTL set_param -n $name $val"
5647 check_catastrophe() {
5648 local nodes=${1:-$(comma_list $(nodes_list))}
5650 do_nodes $nodes "rc=0;
5651 val=\\\$($LCTL get_param -n catastrophe 2>&1);
5652 if [[ \\\$? -eq 0 && \\\$val -ne 0 ]]; then
5653 echo \\\$(hostname -s): \\\$val;
5659 # CMD: determine mds index where directory inode presents
5664 SEQ=$(lfs path2fid $dir | tr '[:]' ' '|cut -f2 -d ' ')
5665 if [ "$SEQ" == "" ]; then
5666 error "can't get sequence for $dir"
5671 do_facet mds1 "cat /proc/fs/lustre/fld/srv-*-MDT0000/fldb" | \
5673 while read SS EE IDX TYP; do \
5674 if let "SEQ >= SS && SEQ < EE"; then \
5680 mdsrate_cleanup () {
5682 mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \
5683 --nfiles $3 --dir $4 --filefmt $5 $6
5688 delayed_recovery_enabled () {
5689 local var=${SINGLEMDS}_svc
5690 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
5693 ########################
5695 convert_facet2label() {
5698 if [ x$facet = xost ]; then
5702 local varsvc=${facet}_svc
5704 if [ -n ${!varsvc} ]; then
5707 error "No lablel for $facet!"
5711 get_clientosc_proc_path() {
5715 get_lustre_version () {
5716 local facet=${1:-"$SINGLEMDS"}
5717 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
5720 lustre_version_code() {
5721 local facet=${1:-"$SINGLEMDS"}
5722 version_code $(get_lustre_version $1)
5725 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
5726 # used by MDT would not be changed.
5727 # mdt lov: fsname-mdtlov
5728 # mdt osc: fsname-OSTXXXX-osc
5729 mds_on_old_device() {
5730 local mds=${1:-"$SINGLEMDS"}
5732 if [ $(lustre_version_code $mds) -gt $(version_code 1.9.0) ]; then
5733 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
5734 > /dev/null 2>&1" && return 0
5739 get_mdtosc_proc_path() {
5741 local ost_label=${2:-"*OST*"}
5743 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
5744 local mdt_label=$(convert_facet2label $mds_facet)
5745 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
5747 if [ $(lustre_version_code $mds_facet) -le $(version_code 1.8.0) ] ||
5748 mds_on_old_device $mds_facet; then
5749 echo "${ost_label}-osc"
5751 echo "${ost_label}-osc-${mdt_index}"
5755 get_osc_import_name() {
5758 local label=$(convert_facet2label $ost)
5760 if [ "${facet:0:3}" = "mds" ]; then
5761 get_mdtosc_proc_path $facet $label
5765 get_clientosc_proc_path $label
5769 _wait_import_state () {
5772 local maxtime=${3:-$(max_recovery_time)}
5776 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5777 while [ "${CONN_STATE}" != "${expected}" ]; do
5778 if [ "${expected}" == "DISCONN" ]; then
5779 # for disconn we can check after proc entry is removed
5780 [ "x${CONN_STATE}" == "x" ] && return 0
5781 # with AT enabled, we can have connect request timeout near of
5782 # reconnect timeout and test can't see real disconnect
5783 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
5785 [ $i -ge $maxtime ] && \
5786 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
5789 # Add uniq for multi-mount case
5790 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5794 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
5798 wait_import_state() {
5801 local maxtime=${3:-$(max_recovery_time)}
5804 for param in ${params//,/ }; do
5805 _wait_import_state $state $param $maxtime || return
5809 wait_import_state_mount() {
5810 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
5814 wait_import_state $*
5817 # One client request could be timed out because server was not ready
5818 # when request was sent by client.
5819 # The request timeout calculation details :
5821 # /* We give the server rq_timeout secs to process the req, and
5822 # add the network latency for our local timeout. */
5823 # request->rq_deadline = request->rq_sent + request->rq_timeout +
5824 # ptlrpc_at_get_net_latency(request) ;
5826 # ptlrpc_connect_import ()
5827 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5830 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
5831 # ptlrpc_at_get_net_latency(request) ->
5832 # at_get (max (iat_net_latency=0, at_min)) = at_min
5835 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
5836 # INITIAL_CONNECT_TIMEOUT + at_min
5838 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
5839 # because we can not get this value in runtime,
5840 # the value depends on configure options, and it is not stored in /proc.
5842 # #define CONNECTION_SWITCH_MIN 5U
5843 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
5845 request_timeout () {
5848 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5849 local init_connect_timeout=$TIMEOUT
5850 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
5852 local at_min=$(at_get $facet at_min)
5854 echo $(( init_connect_timeout + at_min ))
5857 _wait_osc_import_state() {
5861 local ost=$(get_osc_import_name $facet $ost_facet)
5862 local param="osc.${ost}.ost_server_uuid"
5866 # 1. wait the deadline of client 1st request (it could be skipped)
5867 # 2. wait the deadline of client 2nd request
5868 local maxtime=$(( 2 * $(request_timeout $facet)))
5870 if [[ $facet == client* ]]; then
5871 # During setup time, the osc might not be setup, it need wait
5872 # until list_param can return valid value. And also if there
5873 # are mulitple osc entries we should list all of them before
5875 params=$($LCTL list_param $param 2>/dev/null || true)
5876 while [ -z "$params" ]; do
5877 if [ $i -ge $maxtime ]; then
5878 echo "can't get $param in $maxtime secs"
5883 params=$($LCTL list_param $param 2>/dev/null || true)
5886 if ! do_rpc_nodes "$(facet_active_host $facet)" \
5887 wait_import_state $expected "$params" $maxtime; then
5888 error "import is not in ${expected} state"
5895 wait_osc_import_state() {
5901 if [[ $facet = mds ]]; then
5902 for num in $(seq $MDSCOUNT); do
5903 _wait_osc_import_state mds$num "$ost_facet" "$expected"
5906 _wait_osc_import_state "$facet" "$ost_facet" "$expected"
5910 get_clientmdc_proc_path() {
5918 [ -z "$list" ] && return 0
5920 # Add paths to lustre tests for 32 and 64 bit systems.
5921 local LIBPATH="/usr/lib/lustre/tests:/usr/lib64/lustre/tests:"
5922 local TESTPATH="$RLUSTRE/tests:"
5923 local RPATH="PATH=${TESTPATH}${LIBPATH}${PATH}:/sbin:/bin:/usr/sbin:"
5924 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
5927 wait_clients_import_state () {
5934 if [ "$FAILURE_MODE" = HARD ]; then
5935 facets=$(facets_on_host $(facet_active_host $facet))
5938 for facet in ${facets//,/ }; do
5939 local label=$(convert_facet2label $facet)
5942 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
5943 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
5944 *) error "unknown facet!" ;;
5946 local params=$(expand_list $params $proc_path)
5949 if ! do_rpc_nodes "$list" wait_import_state_mount $expected $params; then
5950 error "import is not in ${expected} state"
5960 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
5961 $LCTL get_param obdfilter.*.kbytesavail))
5962 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
5963 $LCTL get_param -n obdfilter.*.tot_granted))
5964 TOTALA=($(do_nodes $(comma_list $(osts_nodes)) \
5965 $LCTL get_param -n obdfilter.*.kbytestotal))
5966 for ((i=0; i<${#AVAILA[@]}; i++)); do
5967 local -a AVAIL1=(${AVAILA[$i]//=/ })
5968 local -a TOTAL=(${TOTALA[$i]//=/ })
5969 GRANT=$((${GRANTA[$i]}/1024))
5970 # allow 1% of total space in bavail because of delayed
5971 # allocation with ZFS which might release some free space after
5972 # txg commit. For small devices, we set a mininum of 8MB
5973 local LIMIT=$((${TOTAL} / 100 + 8000))
5974 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} \
5975 grnt=$GRANT diff=$((AVAIL1[1] - GRANT)) limit=${LIMIT}
5976 [ $((AVAIL1[1] - GRANT)) -lt $LIMIT ] && OSCFULL=0 && \
5977 echo " FULL" || echo
5983 do_facet mgs lctl pool_list $1
5987 local fsname=${1%%.*}
5988 local poolname=${1##$fsname.}
5990 do_facet mgs lctl pool_new $1
5992 # get param should return err unless pool is created
5993 [[ $RC -ne 0 ]] && return $RC
5995 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
5996 2>/dev/null || echo foo" "" || RC=1
5997 if [[ $RC -eq 0 ]]; then
6000 error "pool_new failed $1"
6005 add_pool_to_list () {
6006 local fsname=${1%%.*}
6007 local poolname=${1##$fsname.}
6009 local listvar=${fsname}_CREATED_POOLS
6010 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
6013 remove_pool_from_list () {
6014 local fsname=${1%%.*}
6015 local poolname=${1##$fsname.}
6017 local listvar=${fsname}_CREATED_POOLS
6018 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
6021 destroy_pool_int() {
6023 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
6024 awk '$1 !~ /^Pool:/ {print $1}')
6025 for ost in $OSTS; do
6026 do_facet mgs lctl pool_remove $1 $ost
6028 do_facet mgs lctl pool_destroy $1
6031 # <fsname>.<poolname> or <poolname>
6033 local fsname=${1%%.*}
6034 local poolname=${1##$fsname.}
6036 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
6040 pool_list $fsname.$poolname || return $?
6042 destroy_pool_int $fsname.$poolname
6044 [[ $RC -ne 0 ]] && return $RC
6046 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
6047 2>/dev/null || echo foo" "foo" || RC=1
6049 if [[ $RC -eq 0 ]]; then
6050 remove_pool_from_list $fsname.$poolname
6052 error "destroy pool failed $1"
6058 local fsname=${1:-$FSNAME}
6060 local listvar=${fsname}_CREATED_POOLS
6064 [ x${!listvar} = x ] && return 0
6066 echo destroy the created pools: ${!listvar}
6067 for poolname in ${!listvar//,/ }; do
6068 destroy_pool $fsname.$poolname
6073 local fsname=${1:-$FSNAME}
6075 destroy_pools $fsname
6081 local ts=$(date +%s)
6084 if [[ ! -f "$YAML_LOG" ]]; then
6085 # init_logging is not performed before gather_logs,
6086 # so the $LOGDIR needs to be checked here
6087 check_shared_dir $LOGDIR && touch $LOGDIR/shared
6090 [ -f $LOGDIR/shared ] && docp=false
6092 # dump lustre logs, dmesg
6094 prefix="$TESTLOG_PREFIX.$TESTNAME"
6096 echo "Dumping lctl log to ${prefix}.*.${suffix}"
6098 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
6099 echo "Dumping logs only on local client."
6100 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
6101 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
6106 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
6107 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
6108 if [ ! -f $LOGDIR/shared ]; then
6109 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
6122 for i in $(seq 0 $num_mntpts); do
6123 cmd="ls -laf ${mntpt_root}$i/$dir"
6129 for pid in $pids; do
6136 # check_and_start_recovery_timer()
6137 # service_time = at_est2timeout(service_time);
6138 # service_time += 2 * INITIAL_CONNECT_TIMEOUT;
6139 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC);
6141 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN, obd_timeout/20)
6142 #define CONNECTION_SWITCH_MAX min(50, max(CONNECTION_SWITCH_MIN, obd_timeout))
6143 #define CONNECTION_SWITCH_MIN 5
6144 #define CONNECTION_SWITCH_INC 5
6145 max_recovery_time() {
6146 local init_connect_timeout=$((TIMEOUT / 20))
6147 ((init_connect_timeout >= 5)) || init_connect_timeout=5
6149 local service_time=$(($(at_max_get client) * 9 / 4 + 5))
6150 service_time=$((service_time + 2 * (init_connect_timeout + 50 + 5)))
6152 echo -n $service_time
6155 get_clients_mount_count () {
6156 local clients=${CLIENTS:-`hostname`}
6158 # we need to take into account the clients mounts and
6159 # exclude mds/ost mounts if any;
6160 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
6164 PROC_CLI="srpc_info"
6172 if [ $M -lt $N ]; then
6176 while [ $N -lt $M ]; do
6186 calc_connection_cnt() {
6189 # MDT->MDT = 2 * C(M, 2)
6193 comb_m2=$(combination $MDSCOUNT 2)
6195 local num_clients=$(get_clients_mount_count)
6197 local cnt_mdt2mdt=$((comb_m2 * 2))
6198 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
6199 local cnt_cli2ost=$((num_clients * OSTCOUNT))
6200 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
6201 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
6202 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
6203 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
6217 local cmd="$tgt.srpc.flavor"
6219 if [ $net == "any" ]; then
6224 if [ $dir != "any" ]; then
6229 log "Setting sptlrpc rule: $cmd"
6230 do_facet mgs "$LCTL conf_param $cmd"
6239 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
6240 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
6242 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
6244 if [ "x$bulkspec" != "x" ]; then
6245 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
6247 if [ "x$algs" != "x" ]; then
6248 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
6250 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
6251 if [ $bulk == "bulkn" ]; then
6252 bulk_count=`echo "$output" | grep "bulk flavor" \
6253 | grep "null/null" | wc -l`
6254 elif [ $bulk == "bulki" ]; then
6255 bulk_count=`echo "$output" | grep "bulk flavor" \
6256 | grep "/null" | grep -v "null/" | wc -l`
6258 bulk_count=`echo "$output" | grep "bulk flavor" \
6259 | grep -v "/null" | grep -v "null/" | wc -l`
6263 [ $bulk_count -lt $count ] && count=$bulk_count
6274 local clients=${CLIENTS:-`hostname`}
6276 for c in ${clients//,/ }; do
6277 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
6278 tmpcnt=`count_flvr "$output" $flavor`
6279 cnt=$((cnt + tmpcnt))
6289 local clients=${CLIENTS:-`hostname`}
6291 for c in ${clients//,/ }; do
6292 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
6293 tmpcnt=`count_flvr "$output" $flavor`
6294 cnt=$((cnt + tmpcnt))
6304 if [ $MDSCOUNT -le 1 ]; then
6309 for num in `seq $MDSCOUNT`; do
6310 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
6311 tmpcnt=`count_flvr "$output" $flavor`
6312 cnt=$((cnt + tmpcnt))
6323 for num in `seq $MDSCOUNT`; do
6324 mdtosc=$(get_mdtosc_proc_path mds$num)
6325 mdtosc=${mdtosc/-MDT*/-MDT\*}
6326 output=$(do_facet mds$num lctl get_param -n \
6327 osc.$mdtosc.$PROC_CLI 2>/dev/null)
6328 tmpcnt=`count_flvr "$output" $flavor`
6329 cnt=$((cnt + tmpcnt))
6338 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
6339 count_flvr "$output" $flavor
6344 local dir=$1 # from to
6345 local flavor=$2 # flavor expected
6348 if [ $dir == "cli2mdt" ]; then
6349 res=`flvr_cnt_cli2mdt $flavor`
6350 elif [ $dir == "cli2ost" ]; then
6351 res=`flvr_cnt_cli2ost $flavor`
6352 elif [ $dir == "mdt2mdt" ]; then
6353 res=`flvr_cnt_mdt2mdt $flavor`
6354 elif [ $dir == "mdt2ost" ]; then
6355 res=`flvr_cnt_mdt2ost $flavor`
6356 elif [ $dir == "all2ost" ]; then
6357 res1=`flvr_cnt_mdt2ost $flavor`
6358 res2=`flvr_cnt_cli2ost $flavor`
6359 res=$((res1 + res2))
6360 elif [ $dir == "all2mdt" ]; then
6361 res1=`flvr_cnt_mdt2mdt $flavor`
6362 res2=`flvr_cnt_cli2mdt $flavor`
6363 res=$((res1 + res2))
6364 elif [ $dir == "all2all" ]; then
6365 res1=`flvr_cnt_mdt2ost $flavor`
6366 res2=`flvr_cnt_cli2ost $flavor`
6367 res3=`flvr_cnt_mdt2mdt $flavor`
6368 res4=`flvr_cnt_cli2mdt $flavor`
6369 res=$((res1 + res2 + res3 + res4))
6377 local dir=$1 # from to
6378 local flavor=$2 # flavor expected
6379 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
6383 for ((i=0;i<20;i++)); do
6384 echo -n "checking $dir..."
6385 res=$(do_check_flavor $dir $flavor)
6386 echo "found $res/$expect $flavor connections"
6387 [ $res -ge $expect ] && return 0
6391 echo "Error checking $flavor of $dir: expect $expect, actual $res"
6395 restore_to_default_flavor()
6397 local proc="mgs.MGS.live.$FSNAME"
6399 echo "restoring to default flavor..."
6401 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6403 # remove all existing rules if any
6404 if [ $nrule -ne 0 ]; then
6405 echo "$nrule existing rules"
6406 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
6407 echo "remove rule: $rule"
6408 spec=`echo $rule | awk -F = '{print $1}'`
6409 do_facet mgs "$LCTL conf_param -d $spec"
6413 # verify no rules left
6414 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6415 [ $nrule -ne 0 ] && error "still $nrule rules left"
6417 # wait for default flavor to be applied
6418 # currently default flavor for all connections are 'null'
6419 wait_flavor all2all null
6420 echo "now at default flavor settings"
6425 local flavor=${1:-null}
6427 echo "setting all flavor to $flavor"
6429 # FIXME need parameter to this fn
6430 # and remove global vars
6431 local cnt_all2all=$(calc_connection_cnt all2all)
6433 local res=$(do_check_flavor all2all $flavor)
6434 if [ $res -eq $cnt_all2all ]; then
6435 echo "already have total $res $flavor connections"
6439 echo "found $res $flavor out of total $cnt_all2all connections"
6440 restore_to_default_flavor
6442 [[ $flavor = null ]] && return 0
6444 set_rule $FSNAME any any $flavor
6445 wait_flavor all2all $flavor
6451 # Checking for shared logdir
6452 if [ ! -d $dir ]; then
6453 # Not found. Create local logdir
6456 touch $dir/check_file.$(hostname -s)
6461 check_write_access() {
6463 local list=${2:-$(comma_list $(nodes_list))}
6467 for node in ${list//,/ }; do
6468 file=$dir/check_file.$(short_nodename $node)
6469 if [[ ! -f "$file" ]]; then
6470 # Logdir not accessible/writable from this node.
6473 rm -f $file || return 1
6479 if [[ -n $YAML_LOG ]]; then
6482 local SAVE_UMASK=`umask`
6485 export YAML_LOG=${LOGDIR}/results.yml
6489 if [ ! -f $YAML_LOG ]; then # If the yaml log already exists then we will just append to it
6490 if check_shared_dir $LOGDIR; then
6491 touch $LOGDIR/shared
6492 echo "Logging to shared log directory: $LOGDIR"
6494 echo "Logging to local directory: $LOGDIR"
6497 yml_nodes_file $LOGDIR >> $YAML_LOG
6498 yml_results_file >> $YAML_LOG
6505 yml_log_test $1 >> $YAML_LOG
6509 yml_log_test_status $@ >> $YAML_LOG
6512 log_sub_test_begin() {
6513 yml_log_sub_test_begin "$@" >> $YAML_LOG
6516 log_sub_test_end() {
6517 yml_log_sub_test_end "$@" >> $YAML_LOG
6523 local llverdev_opts=$2
6524 local devname=$(basename $1)
6525 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
6526 # loop devices aren't in /proc/partitions
6527 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
6529 size=$(($size / 1024 / 1024)) # Gb
6531 local partial_arg=""
6532 # Run in partial (fast) mode if the size
6533 # of a partition > 1 GB
6534 [ $size -gt 1 ] && partial_arg="-p"
6536 llverdev --force $partial_arg $llverdev_opts $dev
6542 local llverfs_opts=$2
6543 local use_partial_arg=$3
6544 local partial_arg=""
6545 local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
6547 # Run in partial (fast) mode if the size
6548 # of a partition > 1 GB
6549 [ "x$use_partial_arg" != "xno" ] && [ $size -gt 1 ] && partial_arg="-p"
6551 llverfs $partial_arg $llverfs_opts $dir
6554 #Remove objects from OST
6555 remove_ost_objects() {
6561 local mntpt=$(facet_mntpt $facet)
6562 local opts=$OST_MOUNT_OPTS
6566 echo "removing objects from $ostdev on $facet: $objids"
6567 if ! test -b $ostdev; then
6568 opts=$(csa_add "$opts" -o loop)
6570 mount -t $(facet_fstype $facet) $opts $ostdev $mntpt ||
6573 for i in $objids; do
6574 rm $mntpt/O/$group/d$((i % 32))/$i || { rc=$?; break; }
6576 umount -f $mntpt || return $?
6580 #Remove files from MDT
6581 remove_mdt_files() {
6586 local mntpt=$(facet_mntpt $facet)
6587 local opts=$MDS_MOUNT_OPTS
6589 echo "removing files from $mdtdev on $facet: $files"
6590 if [ $(facet_fstype $facet) == ldiskfs ] &&
6591 ! do_facet $facet test -b $mdtdev; then
6592 opts=$(csa_add "$opts" -o loop)
6594 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6598 rm $mntpt/ROOT/$f || { rc=$?; break; }
6600 umount -f $mntpt || return $?
6604 duplicate_mdt_files() {
6609 local mntpt=$(facet_mntpt $facet)
6610 local opts=$MDS_MOUNT_OPTS
6612 echo "duplicating files on $mdtdev on $facet: $files"
6613 mkdir -p $mntpt || return $?
6614 if [ $(facet_fstype $facet) == ldiskfs ] &&
6615 ! do_facet $facet test -b $mdtdev; then
6616 opts=$(csa_add "$opts" -o loop)
6618 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6629 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
6630 pushd $mntpt/ROOT > /dev/null || return $?
6633 touch $f.bad || return $?
6634 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
6636 [ $rc -eq 0 ] || return $rc
6637 setfattr --restore $tmp || return $?
6643 local devs=${1//,/ }
6646 local rslt=$TMP/sgpdd_survey
6648 # sgpdd-survey cleanups ${rslt}.* files
6650 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
6656 # returns the canonical name for an ldiskfs device
6661 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
6662 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
6663 echo dm-\\\${foo##*:};
6665 echo \\\$(basename \\\$dv);
6669 is_sanity_benchmark() {
6670 local benchmarks="dbench bonnie iozone fsx"
6672 for b in $benchmarks; do
6673 if [ "$b" == "$suite" ]; then
6681 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
6685 # Get the available size (KB) of a given obd target.
6692 [[ $facet != client ]] || return 0
6694 size=$(do_facet $facet $LCTL get_param -n *.$obd.kbytesavail | head -n1)
6699 # Get the page size (bytes) on a given facet node.
6705 size=$(do_facet $facet getconf PAGE_SIZE)
6706 [[ ${PIPESTATUS[0]} = 0 && -n "$size" ]] || size=4096
6711 # Get the block count of the filesystem.
6718 count=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6719 awk '/^Block count:/ {print $3}')
6723 # Get the block size of the filesystem.
6729 size=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6730 awk '/^Block size:/ {print $3}')
6734 # Check whether the "large_xattr" feature is enabled or not.
6735 large_xattr_enabled() {
6736 [[ $(facet_fstype $SINGLEMDS) == zfs ]] && return 0
6738 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6740 do_facet $SINGLEMDS "$DUMPE2FS -h $mds_dev 2>&1 |
6741 grep -E -q '(ea_inode|large_xattr)'"
6742 return ${PIPESTATUS[0]}
6745 # Get the maximum xattr size supported by the filesystem.
6749 if large_xattr_enabled; then
6750 # include/linux/limits.h: #define XATTR_SIZE_MAX 65536
6753 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6754 local block_size=$(get_block_size $SINGLEMDS $mds_dev)
6756 # maximum xattr size = size of block - size of header -
6757 # size of 1 entry - 4 null bytes
6758 size=$((block_size - 32 - 32 - 4))
6764 # Dump the value of the named xattr from a file.
6769 echo "$(getfattr -n $xattr_name --absolute-names --only-values $file)"
6772 # Generate a string with size of $size bytes.
6774 local size=${1:-1024} # in bytes
6776 echo "$(head -c $size < /dev/zero | tr '\0' y)"
6779 reformat_external_journal() {
6782 if [ ! -z ${EJOURNAL} ]; then
6783 local rcmd="do_facet $facet"
6785 echo "reformat external journal on $facet:${EJOURNAL}"
6786 ${rcmd} mke2fs -O journal_dev ${EJOURNAL} || return 1
6790 # MDT file-level backup/restore
6791 mds_backup_restore() {
6794 local devname=$(mdsdevname $(facet_number $facet))
6795 local mntpt=$(facet_mntpt brpt)
6796 local rcmd="do_facet $facet"
6797 local metaea=${TMP}/backup_restore.ea
6798 local metadata=${TMP}/backup_restore.tgz
6799 local opts=${MDS_MOUNT_OPTS}
6800 local svc=${facet}_svc
6802 if ! ${rcmd} test -b ${devname}; then
6803 opts=$(csa_add "$opts" -o loop)
6806 echo "file-level backup/restore on $facet:${devname}"
6808 # step 1: build mount point
6809 ${rcmd} mkdir -p $mntpt
6810 # step 2: cleanup old backup
6811 ${rcmd} rm -f $metaea $metadata
6813 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6814 if [ ! -z $igif ]; then
6815 # step 3.5: rm .lustre
6816 ${rcmd} rm -rf $mntpt/ROOT/.lustre || return 1
6818 # step 4: backup metaea
6820 ${rcmd} "cd $mntpt && getfattr -R -d -m '.*' -P . > $metaea && cd -" ||
6822 # step 5: backup metadata
6824 ${rcmd} tar zcf $metadata -C $mntpt/ . > /dev/null 2>&1 || return 3
6826 ${rcmd} umount -d $mntpt || return 4
6827 # step 7: reformat external journal if needed
6828 reformat_external_journal $facet || return 5
6829 # step 8: reformat dev
6830 echo "reformat new device"
6831 add $facet $(mkfs_opts $facet ${devname}) --backfstype ldiskfs \
6832 --reformat ${devname} $(mdsvdevname $(facet_number $facet)) \
6833 > /dev/null || exit 6
6835 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 7
6836 # step 10: restore metadata
6838 ${rcmd} tar zxfp $metadata -C $mntpt > /dev/null 2>&1 || return 8
6839 # step 11: restore metaea
6841 ${rcmd} "cd $mntpt && setfattr --restore=$metaea && cd - " || return 9
6842 # step 12: remove recovery logs
6843 echo "remove recovery logs"
6844 ${rcmd} rm -fv $mntpt/OBJECTS/* $mntpt/CATALOGS
6845 # step 13: umount dev
6846 ${rcmd} umount -d $mntpt || return 10
6847 # step 14: cleanup tmp backup
6848 ${rcmd} rm -f $metaea $metadata
6849 # step 15: reset device label - it's not virgin on
6850 ${rcmd} e2label $devname ${!svc}
6857 local devname=$(mdsdevname $(facet_number $facet))
6858 local mntpt=$(facet_mntpt brpt)
6859 local rcmd="do_facet $facet"
6860 local opts=${MDS_MOUNT_OPTS}
6862 if ! ${rcmd} test -b ${devname}; then
6863 opts=$(csa_add "$opts" -o loop)
6866 echo "removing OI files on $facet: idx=${idx}"
6868 # step 1: build mount point
6869 ${rcmd} mkdir -p $mntpt
6871 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6872 if [ -z $idx ]; then
6873 # step 3: remove all OI files
6874 ${rcmd} rm -fv $mntpt/oi.16*
6875 elif [ $idx -lt 2 ]; then
6876 ${rcmd} rm -fv $mntpt/oi.16.${idx}
6880 # others, rm oi.16.[idx, idx * idx, idx ** ...]
6881 for ((i=${idx}; i<64; i=$((i * idx)))); do
6882 ${rcmd} rm -fv $mntpt/oi.16.${i}
6886 ${rcmd} umount -d $mntpt || return 2
6887 # OI files will be recreated when mounted as lustre next time.
6890 # generate maloo upload-able log file name
6891 # \param logname specify unique part of file name
6892 generate_logname() {
6893 local logname=${1:-"default_logname"}
6895 echo "$TESTLOG_PREFIX.$TESTNAME.$logname.$(hostname -s).log"
6898 # make directory on different MDTs
6906 local stripe_count=2
6916 *) error "Only creating single directory is supported";;
6919 child=$(basename $path)
6920 parent=$(dirname $path)
6922 if [ "$option" == "-p" -o "$option2" == "-p" ]; then
6923 if [ -d $parent/$child ]; then
6929 if [ "${option:0:2}" == "-c" ]; then
6930 stripe_count=$(echo $option | sed 's/^-c//')
6933 if [ "${option2:0:2}" == "-c" ]; then
6934 stripe_count=$(echo $option2 | sed 's/^-c//')
6937 if [ ! -d ${parent} ]; then
6938 if [ "$p_option" == "-p" ]; then
6945 if [ $MDSCOUNT -le 1 ]; then
6946 mkdir $p_option $parent/$child || rc=$?
6948 local mdt_idx=$($LFS getstripe -M $parent)
6949 local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
6951 mdt_idx=$((test_num % MDSCOUNT))
6952 echo "striped dir -i$mdt_idx -c$stripe_count $path"
6953 $LFS setdirstripe -i$mdt_idx -c$stripe_count $path || rc=$?
6958 # find the smallest and not in use file descriptor
6961 local max_fd=$(ulimit -n)
6963 while [[ $fd -le $max_fd && -e /proc/self/fd/$fd ]]; do
6966 [ $fd -lt $max_fd ] || error "finding free file descriptor failed"
6970 check_mount_and_prep()
6972 is_mounted $MOUNT || setupall
6974 rm -rf $DIR/[df][0-9]* || error "Fail to cleanup the env!"
6975 mkdir $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
6976 for idx in $(seq $MDSCOUNT); do
6977 local name="MDT$(printf '%04x' $((idx - 1)))"
6978 rm -rf $MOUNT/.lustre/lost+found/$name/*
6982 # calcule how many ost-objects to be created.
6983 precreated_ost_obj_count()
6987 local mdt_name="MDT$(printf '%04x' $mdt_idx)"
6988 local ost_name="OST$(printf '%04x' $ost_idx)"
6989 local proc_path="${FSNAME}-${ost_name}-osc-${mdt_name}"
6990 local last_id=$(do_facet mds${mdt_idx} lctl get_param -n \
6991 osp.$proc_path.prealloc_last_id)
6992 local next_id=$(do_facet mds${mdt_idx} lctl get_param -n \
6993 osp.$proc_path.prealloc_next_id)
6995 echo $((last_id - next_id + 1))
6998 check_file_in_pool()
7003 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
7006 for t in $tlist ; do
7007 [ "$i" -eq "$t" ] && continue 2
7010 echo "pool list: $tlist"
7011 echo "striping: $res"
7012 error_noexit "$file not allocated in $pool"
7019 echo "Creating new pool"
7022 create_pool $FSNAME.$pool ||
7023 { error_noexit "No pool created, result code $?"; return 1; }
7024 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
7025 { error_noexit "$pool not in lfs pool_list"; return 2; }
7028 pool_add_targets() {
7029 echo "Adding targets to pool"
7035 local list=$(seq $first $step $last)
7037 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
7038 do_facet mgs $LCTL pool_add \
7039 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
7040 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
7041 | sort -u | tr '\n' ' ' " "$t" || {
7042 error_noexit "Add to pool failed"
7045 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
7046 local addcount=$(((last - first) / step + 1))
7047 [ $lfscount -eq $addcount ] || {
7048 error_noexit "lfs pool_list bad ost count" \
7049 "$lfscount != $addcount"
7057 echo "Setting pool on directory $tdir"
7059 $SETSTRIPE -c 2 -p $pool $tdir && return 0
7061 error_noexit "Cannot set pool $pool to $tdir"
7068 echo "Checking pool on directory $tdir"
7070 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
7071 [ "$res" = "$pool" ] && return 0
7073 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
7077 pool_dir_rel_path() {
7078 echo "Testing relative path works well"
7083 mkdir -p $root/$tdir/$tdir
7085 pool_set_dir $pool $tdir || return 1
7086 pool_set_dir $pool ./$tdir || return 2
7087 pool_set_dir $pool ../$tdir || return 3
7088 pool_set_dir $pool ../$tdir/$tdir || return 4
7089 rm -rf $tdir; cd - > /dev/null
7092 pool_alloc_files() {
7093 echo "Checking files allocation from directory pool"
7100 for i in $(seq -w 1 $count)
7102 local file=$tdir/file-$i
7104 check_file_in_pool $file $pool "$tlist" || \
7105 failed=$((failed + 1))
7107 [ "$failed" = 0 ] && return 0
7109 error_noexit "$failed files not allocated in $pool"
7113 pool_create_files() {
7114 echo "Creating files in pool"
7122 for i in $(seq -w 1 $count)
7124 local file=$tdir/spoo-$i
7125 $SETSTRIPE -p $pool $file
7126 check_file_in_pool $file $pool "$tlist" || \
7127 failed=$((failed + 1))
7129 [ "$failed" = 0 ] && return 0
7131 error_noexit "$failed files not allocated in $pool"
7136 echo "Checking 'lfs df' output"
7139 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
7141 local res=$($LFS df --pool $FSNAME.$pool |
7143 grep "$FSNAME-OST" |
7145 [ "$res" = "$t" ] && return 0
7147 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
7151 pool_file_rel_path() {
7152 echo "Creating files in a pool with relative pathname"
7157 { error_noexit "unable to create $tdir"; return 1 ; }
7158 local file="/..$tdir/$tfile-1"
7159 $SETSTRIPE -p $pool $file ||
7160 { error_noexit "unable to create $file" ; return 2 ; }
7163 $SETSTRIPE -p $pool $tfile-2 || {
7164 error_noexit "unable to create $tfile-2 in $tdir"
7169 pool_remove_first_target() {
7170 echo "Removing first target from a pool"
7173 local pname="lov.$FSNAME-*.pools.$pool"
7174 local t=$($LCTL get_param -n $pname | head -1)
7175 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7176 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
7177 error_noexit "$t not removed from $FSNAME.$pool"
7182 pool_remove_all_targets() {
7183 echo "Removing all targets from pool"
7186 local pname="lov.$FSNAME-*.pools.$pool"
7187 for t in $($LCTL get_param -n $pname | sort -u)
7189 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7191 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
7192 error_noexit "Pool $FSNAME.$pool cannot be drained"
7195 # striping on an empty/nonexistant pool should fall back
7196 # to "pool of everything"
7198 error_noexit "failed to use fallback striping for empty pool"
7201 # setstripe on an empty pool should fail
7202 $SETSTRIPE -p $pool $file 2>/dev/null && {
7203 error_noexit "expected failure when creating file" \
7211 echo "Destroying pool"
7215 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
7218 # striping on an empty/nonexistant pool should fall back
7219 # to "pool of everything"
7221 error_noexit "failed to use fallback striping for missing pool"
7224 # setstripe on an empty pool should fail
7225 $SETSTRIPE -p $pool $file 2>/dev/null && {
7226 error_noexit "expected failure when creating file" \
7231 # get param should return err once pool is gone
7232 if wait_update $HOSTNAME "lctl get_param -n \
7233 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
7235 remove_pool_from_list $FSNAME.$pool
7238 error_noexit "Pool $FSNAME.$pool is not destroyed"
7242 # Get and check the actual stripe count of one file.
7243 # Usage: check_stripe_count <file> <expected_stripe_count>
7244 check_stripe_count() {
7249 [[ -z "$file" || -z "$expected" ]] &&
7250 error "check_stripe_count: invalid argument"
7252 local cmd="$GETSTRIPE -c $file"
7253 actual=$($cmd) || error "$cmd failed"
7254 actual=${actual%% *}
7256 if [[ $actual -ne $expected ]]; then
7257 [[ $expected -eq -1 ]] ||
7258 error "$cmd wrong: found $actual, expected $expected"
7259 [[ $actual -eq $OSTCOUNT ]] ||
7260 error "$cmd wrong: found $actual, expected $OSTCOUNT"
7264 # Get and check the actual list of OST indices on one file.
7265 # Usage: check_obdidx <file> <expected_comma_separated_list_of_ost_indices>
7271 [[ -z "$file" || -z "$expected" ]] &&
7272 error "check_obdidx: invalid argument!"
7274 obdidx=$(comma_list $($GETSTRIPE $file | grep -A $OSTCOUNT obdidx |
7275 grep -v obdidx | awk '{print $1}' | xargs))
7277 [[ $obdidx = $expected ]] ||
7278 error "list of OST indices on $file is $obdidx," \
7279 "should be $expected"
7282 # Get and check the actual OST index of the first stripe on one file.
7283 # Usage: check_start_ost_idx <file> <expected_start_ost_idx>
7284 check_start_ost_idx() {
7289 [[ -z "$file" || -z "$expected" ]] &&
7290 error "check_start_ost_idx: invalid argument!"
7292 start_ost_idx=$($GETSTRIPE $file | grep -A 1 obdidx | grep -v obdidx |
7295 [[ $start_ost_idx = $expected ]] ||
7296 error "OST index of the first stripe on $file is" \
7297 "$start_ost_idx, should be $expected"