3 trap 'print_summary && touch $TF_FAIL && \
4 echo "test-framework exiting on error"' ERR
9 export EJOURNAL=${EJOURNAL:-""}
10 export REFORMAT=${REFORMAT:-""}
11 export WRITECONF=${WRITECONF:-""}
12 export VERBOSE=${VERBOSE:-false}
15 export GSS_PIPEFS=false
16 export IDENTITY_UPCALL=default
18 # specify environment variable containing batch job name for server statistics
19 export JOBID_VAR=${JOBID_VAR:-"procname_uid"} # or "existing" or "disable"
21 # LOAD_LLOOP: LU-409: only load llite_lloop module if kernel < 2.6.32 or
22 # LOAD_LLOOP is true. LOAD_LLOOP is false by default.
23 export LOAD_LLOOP=${LOAD_LLOOP:-false}
25 #export PDSH="pdsh -S -Rssh -w"
26 export MOUNT_CMD=${MOUNT_CMD:-"mount -t lustre"}
28 # function used by scripts run on remote nodes
29 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
30 . $LUSTRE/tests/functions.sh
31 . $LUSTRE/tests/yaml.sh
33 export LD_LIBRARY_PATH=${LUSTRE}/utils:${LD_LIBRARY_PATH}
35 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
37 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
39 if [ -f "$EXCEPT_LIST_FILE" ]; then
40 echo "Reading test skip list from $EXCEPT_LIST_FILE"
45 # check config files for options in decreasing order of preference
46 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/lustre.conf ] &&
47 MODPROBECONF=/etc/modprobe.d/lustre.conf
48 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] &&
49 MODPROBECONF=/etc/modprobe.d/Lustre
50 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] &&
51 MODPROBECONF=/etc/modprobe.conf
55 [[ $DIR/ = $MOUNT/* ]] || \
56 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
57 [[ $DIR1/ = $MOUNT1/* ]] || \
58 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
59 [[ $DIR2/ = $MOUNT2/* ]] || \
60 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
62 [ -n "$failed" ] && exit 99 || true
66 echo "usage: $0 [-r] [-f cfgfile]"
74 [ "$TESTSUITE" == "lfsck" ] && return 0
75 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
77 local form="%-13s %-17s %-9s %s %s\n"
78 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
79 echo "------------------------------------------------------------------------------------"
80 for O in $DEFAULT_SUITES; do
81 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
82 [ "${!O}" = "no" ] && continue || true
83 local o=$(echo $O | tr "[:upper:]_" "[:lower:]-")
84 local log=${TMP}/${o}.log
85 if is_sanity_benchmark $o; then
86 log=${TMP}/sanity-benchmark.log
91 local status=Unfinished
93 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' |
95 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g |
96 sort -nr -k 3 | head -n5 | awk '{ print $2":"$3"s" }')
97 total=$(grep duration $log | awk '{ print $2 }')
98 if [ "${!O}" = "done" ]; then
102 local durations=$(egrep "^PASS|^FAIL" $log |
103 tr -d "("| sed s/s\)$//g |
104 awk '{ print $2":"$3"|" }')
105 details=$(printf "%s\n%s %s %s\n" "$details" \
106 "DDETAILS" "$O" "$(echo $durations)")
109 printf "$form" $status "$O" "${total}" "E=$skipped"
110 printf "$form" "-" "-" "-" "S=$(echo $slow)"
113 for O in $DEFAULT_SUITES; do
114 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
115 if [ "${!O}" = "no" ]; then
116 printf "$form" "Skipped" "$O" ""
120 # print the detailed tests durations if DDETAILS=true
127 export LUSTRE=$(absolute_path $LUSTRE)
128 export TESTSUITE=$(basename $0 .sh)
129 export TEST_FAILED=false
130 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
131 export RPC_MODE=${RPC_MODE:-false}
133 export MKE2FS=$MKE2FS
134 if [ -z "$MKE2FS" ]; then
135 if which mkfs.ldiskfs >/dev/null 2>&1; then
136 export MKE2FS=mkfs.ldiskfs
142 export DEBUGFS=$DEBUGFS
143 if [ -z "$DEBUGFS" ]; then
144 if which debugfs.ldiskfs >/dev/null 2>&1; then
145 export DEBUGFS=debugfs.ldiskfs
147 export DEBUGFS=debugfs
151 export TUNE2FS=$TUNE2FS
152 if [ -z "$TUNE2FS" ]; then
153 if which tunefs.ldiskfs >/dev/null 2>&1; then
154 export TUNE2FS=tunefs.ldiskfs
156 export TUNE2FS=tune2fs
160 export E2LABEL=$E2LABEL
161 if [ -z "$E2LABEL" ]; then
162 if which label.ldiskfs >/dev/null 2>&1; then
163 export E2LABEL=label.ldiskfs
165 export E2LABEL=e2label
169 export DUMPE2FS=$DUMPE2FS
170 if [ -z "$DUMPE2FS" ]; then
171 if which dumpfs.ldiskfs >/dev/null 2>&1; then
172 export DUMPE2FS=dumpfs.ldiskfs
174 export DUMPE2FS=dumpe2fs
178 export E2FSCK=$E2FSCK
179 if [ -z "$E2FSCK" ]; then
180 if which fsck.ldiskfs >/dev/null 2>&1; then
181 export E2FSCK=fsck.ldiskfs
187 export RESIZE2FS=$RESIZE2FS
188 if [ -z "$RESIZE2FS" ]; then
189 if which resizefs.ldiskfs >/dev/null 2>&1; then
190 export RESIZE2FS=resizefs.ldiskfs
192 export RESIZE2FS=resize2fs
196 export LFSCK_BIN=${LFSCK_BIN:-lfsck}
197 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
198 export FSCK_MAX_ERR=4 # File system errors left uncorrected
200 export ZFS=${ZFS:-zfs}
201 export ZPOOL=${ZPOOL:-zpool}
202 export ZDB=${ZDB:-zdb}
203 export PARTPROBE=${PARTPROBE:-partprobe}
205 #[ -d /r ] && export ROOT=${ROOT:-/r}
206 export TMP=${TMP:-$ROOT/tmp}
207 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
208 export LOGDIR=${LOGDIR:-${TMP}/test_logs/$(date +%s)}
209 export TESTLOG_PREFIX=$LOGDIR/$TESTSUITE
211 export HOSTNAME=${HOSTNAME:-$(hostname -s)}
212 if ! echo $PATH | grep -q $LUSTRE/utils; then
213 export PATH=$LUSTRE/utils:$PATH
215 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
216 export PATH=$LUSTRE/utils/gss:$PATH
218 if ! echo $PATH | grep -q $LUSTRE/tests; then
219 export PATH=$LUSTRE/tests:$PATH
221 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
222 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
224 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
225 [ ! -f "$LST" ] && export LST=$(which lst)
226 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
227 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
228 export MCREATE=${MCREATE:-mcreate}
229 # Ubuntu, at least, has a truncate command in /usr/bin
230 # so fully path our truncate command.
231 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
232 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
233 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
234 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
235 export PATH=$LUSTRE/tests/racer:$PATH:
237 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
238 export PATH=$LUSTRE/tests/mpi:$PATH
240 export RSYNC_RSH=${RSYNC_RSH:-rsh}
242 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
243 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
244 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
245 [ ! -f "$LFS" ] && export LFS=$(which lfs)
246 SETSTRIPE=${SETSTRIPE:-"$LFS setstripe"}
247 GETSTRIPE=${GETSTRIPE:-"$LFS getstripe"}
249 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
250 if [ ! -f "$L_GETIDENTITY" ]; then
251 if `which l_getidentity > /dev/null 2>&1`; then
252 export L_GETIDENTITY=$(which l_getidentity)
254 export L_GETIDENTITY=NONE
257 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
258 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID="ll_decode_filter_fid"
259 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
260 [ ! -f "$MKFS" ] && export MKFS="mkfs.lustre"
261 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
262 [ ! -f "$TUNEFS" ] && export TUNEFS="tunefs.lustre"
263 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
264 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
265 [ ! -f "$LUSTRE_RMMOD" ] &&
266 export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
267 export LFS_MIGRATE=${LFS_MIGRATE:-$LUSTRE/scripts/lfs_migrate}
268 [ ! -f "$LFS_MIGRATE" ] &&
269 export LFS_MIGRATE=$(which lfs_migrate 2> /dev/null)
270 export NAME=${NAME:-local}
271 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
272 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
273 export LGSSD=$(which lgssd)
274 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
275 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
276 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
278 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
281 if [ "$ACCEPTOR_PORT" ]; then
282 export PORT_OPT="--port $ACCEPTOR_PORT"
287 echo "Using GSS/krb5 ptlrpc security flavor"
288 which lgss_keyring > /dev/null 2>&1 || \
289 error_exit "built with gss disabled! SEC=$SEC"
300 IDENTITY_UPCALL=false
304 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
306 # Paths on remote nodes, if different
307 export RLUSTRE=${RLUSTRE:-$LUSTRE}
308 export RPWD=${RPWD:-$PWD}
309 export I_MOUNTED=${I_MOUNTED:-"no"}
310 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mdt.ko -a \
311 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mdt.ko -a \
312 ! -f /lib/modules/$(uname -r)/extra/kernel/fs/lustre/mdt.ko -a \
313 ! -f $LUSTRE/mdt/mdt.ko ]; then
314 export CLIENTMODSONLY=yes
317 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
318 export OSD_TRACK_DECLARES_LBUG=${OSD_TRACK_DECLARES_LBUG:-"yes"}
322 while getopts "rvwf:" opt $*; do
325 r) REFORMAT=--reformat;;
327 w) WRITECONF=writeconf;;
332 shift $((OPTIND - 1))
335 # print the durations of each test if "true"
336 DDETAILS=${DDETAILS:-false}
337 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
347 ncpts=$(do_facet $facet "lctl get_param -n " \
348 "cpu_partition_table 2>/dev/null| wc -l" || echo 1)
350 if [ $ncpts -eq 0 ]; then
358 # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
359 eval set -- $(tr "[:punct:]" " " <<< $*)
361 echo -n "$((($1 << 16) | ($2 << 8) | $3))"
364 export LINUX_VERSION=$(uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
365 export LINUX_VERSION_CODE=$(version_code ${LINUX_VERSION//\./ })
368 /sbin/lsmod | grep -q "^\<$1\>"
371 # Load a module on the system where this is running.
373 # usage: load_module module_name [module arguments for insmod/modprobe]
375 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
376 # will be used as the arguments. Otherwise arguments will be obtained from
377 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
384 BASE=`basename $module $EXT`
386 module_loaded ${BASE} && return
388 # If no module arguments were passed, get them from $MODOPTS_<MODULE>, else from
390 if [ $# -eq 0 ]; then
391 # $MODOPTS_<MODULE>; we could use associative arrays, but that's not in
392 # Bash until 4.x, so we resort to eval.
393 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
394 eval set -- \$$optvar
395 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
396 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
398 opt=$(awk -v var="^options $BASE" '$0 ~ var \
399 {gsub("'"options $BASE"'",""); print}' $MODPROBECONF)
400 set -- $(echo -n $opt)
402 # Ensure we have accept=all for lnet
403 if [ $(basename $module) = lnet ]; then
404 # OK, this is a bit wordy...
405 local arg accept_all_present=false
408 [ "$arg" = accept=all ] && \
409 accept_all_present=true
411 $accept_all_present || set -- "$@" accept=all
417 [ $# -gt 0 ] && echo "${module} options: '$*'"
419 # Note that insmod will ignore anything in modprobe.conf, which is why
420 # we're passing options on the command-line.
421 if [[ "$BASE" == "lnet_selftest" ]] &&
422 [[ -f ${LUSTRE}/../lnet/selftest/${module}${EXT} ]]; then
423 insmod ${LUSTRE}/../lnet/selftest/${module}${EXT}
424 elif [[ -f ${LUSTRE}/${module}${EXT} ]]; then
425 [[ "$BASE" != "ptlrpc_gss" ]] || modprobe sunrpc
426 insmod ${LUSTRE}/${module}${EXT} "$@"
428 # must be testing a "make install" or "rpm" installation
429 # note failed to load ptlrpc_gss is considered not fatal
430 if [[ "$BASE" == "ptlrpc_gss" ]]; then
431 modprobe $BASE "$@" 2>/dev/null ||
432 echo "gss/krb5 is not supported"
439 llite_lloop_enabled() {
440 local n1=$(uname -r | cut -d. -f1)
441 local n2=$(uname -r | cut -d. -f2)
442 local n3=$(uname -r | cut -d- -f1 | cut -d. -f3)
444 # load the llite_lloop module for < 2.6.32 kernels
445 if [[ $n1 -lt 2 ]] || [[ $n1 -eq 2 && $n2 -lt 6 ]] || \
446 [[ $n1 -eq 2 && $n2 -eq 6 && $n3 -lt 32 ]] || \
453 load_modules_local() {
454 if [ -n "$MODPROBE" ]; then
456 echo "Using modprobe to load modules"
460 echo Loading modules from $LUSTRE
464 if [ -f /sys/devices/system/cpu/online ]; then
465 ncpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/online) + 1))
466 echo "detected $ncpus online CPUs by sysfs"
468 ncpus=$(getconf _NPROCESSORS_CONF 2>/dev/null)
470 if [ $rc -eq 0 ]; then
471 echo "detected $ncpus online CPUs by getconf"
473 echo "Can't detect number of CPUs"
478 # if there is only one CPU core, libcfs can only create one partition
479 # if there is more than 4 CPU cores, libcfs should create multiple CPU
480 # partitions. So we just force libcfs to create 2 partitions for
481 # system with 2 or 4 cores
482 if [ $ncpus -le 4 ] && [ $ncpus -gt 1 ]; then
483 # force to enable multiple CPU partitions
484 echo "Force libcfs to create 2 CPU partitions"
485 MODOPTS_LIBCFS="cpu_npartitions=2 $MODOPTS_LIBCFS"
487 echo "libcfs will create CPU partition based on online CPUs"
490 load_module ../libcfs/libcfs/libcfs
492 [ "$PTLDEBUG" ] && lctl set_param debug="$PTLDEBUG"
493 [ "$SUBSYSTEM" ] && lctl set_param subsystem_debug="${SUBSYSTEM# }"
494 load_module ../lnet/lnet/lnet
497 LNETLND="o2iblnd/ko2iblnd"
502 LNETLND=${LNETLND:-"socklnd/ksocklnd"}
503 load_module ../lnet/klnds/$LNETLND
504 load_module obdclass/obdclass
505 load_module ptlrpc/ptlrpc
506 load_module ptlrpc/gss/ptlrpc_gss
514 load_module obdecho/obdecho
515 if ! client_only; then
516 SYMLIST=/proc/kallsyms
517 grep -q crc16 $SYMLIST || { modprobe crc16 2>/dev/null || true; }
518 grep -q -w jbd $SYMLIST || { modprobe jbd 2>/dev/null || true; }
519 grep -q -w jbd2 $SYMLIST || { modprobe jbd2 2>/dev/null || true; }
520 load_module lfsck/lfsck
521 [ "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
522 if [[ $(node_fstypes $HOSTNAME) == *zfs* ]]; then
524 load_module osd-zfs/osd_zfs
526 if [[ $(node_fstypes $HOSTNAME) == *ldiskfs* ]]; then
527 grep -q exportfs_decode_fh $SYMLIST ||
528 { modprobe exportfs 2> /dev/null || true; }
529 load_module ../ldiskfs/ldiskfs
530 load_module osd-ldiskfs/osd_ldiskfs
542 load_module llite/lustre
543 llite_lloop_enabled && load_module llite/llite_lloop
544 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
546 rm -f $OGDB/ogdb-$HOSTNAME
547 $LCTL modules > $OGDB/ogdb-$HOSTNAME
549 # 'mount' doesn't look in $PATH, just sbin
550 local mount_lustre=$LUSTRE/utils/mount.lustre
551 if [ -f $mount_lustre ]; then
552 local sbin_mount=/sbin/mount.lustre
553 if grep -qw "$sbin_mount" /proc/mounts; then
554 cmp -s $mount_lustre $sbin_mount || umount $sbin_mount
556 if ! grep -qw "$sbin_mount" /proc/mounts; then
557 [ ! -f "$sbin_mount" ] && touch "$sbin_mount"
558 if [ ! -s "$sbin_mount" -a -w "$sbin_mount" ]; then
559 cat <<- EOF > "$sbin_mount"
562 echo "This $sbin_mount just a mountpoint." 1>&2
563 echo "It is never supposed to be run." 1>&2
564 logger -p emerg -- "using stub $sbin_mount $@"
567 chmod a+x $sbin_mount
569 mount --bind $mount_lustre $sbin_mount ||
570 error "can't bind $mount_lustre to $sbin_mount"
578 # load modules on remote nodes optionally
579 # lustre-tests have to be installed on these nodes
580 if $LOAD_MODULES_REMOTE; then
581 local list=$(comma_list $(remote_nodes_list))
582 if [ -n "$list" ]; then
583 echo "loading modules on: '$list'"
584 do_rpc_nodes "$list" load_modules_local
590 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
591 LEAK_PORTALS=$(dmesg | tail -n 20 | grep "Portals memory leaked" || true)
592 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
593 echo "$LEAK_LUSTRE" 1>&2
594 echo "$LEAK_PORTALS" 1>&2
595 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
596 echo "Memory leaks detected"
597 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
603 wait_exit_ST client # bug 12845
605 $LUSTRE_RMMOD ldiskfs || return 2
607 if $LOAD_MODULES_REMOTE; then
608 local list=$(comma_list $(remote_nodes_list))
609 if [ -n "$list" ]; then
610 echo "unloading modules on: '$list'"
611 do_rpc_nodes "$list" $LUSTRE_RMMOD ldiskfs
612 do_rpc_nodes "$list" check_mem_leak
616 local sbin_mount=/sbin/mount.lustre
617 if grep -qe "$sbin_mount " /proc/mounts; then
618 umount $sbin_mount || true
619 [ -s $sbin_mount ] && ! grep -q "STUB MARK" $sbin_mount ||
623 check_mem_leak || return 254
625 echo "modules unloaded."
630 local facet=${1:-$SINGLEMDS}
631 local fstype=$(facet_fstype $facet)
634 ldiskfs) size=50;; # largest seen is 44, leave some headroom
635 zfs) size=400;; # largest seen is 384
641 check_gss_daemon_nodes() {
645 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
646 if [ \\\"\\\$num\\\" -ne 1 ]; then
647 echo \\\$num instance of $dname;
652 check_gss_daemon_facet() {
656 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
657 if [ $num -ne 1 ]; then
658 echo "$num instance of $dname on $facet"
667 echo Stopping $@ on $list
668 do_nodes $list "killall -2 $@ 2>/dev/null || true"
671 # start gss daemons on all nodes, or
672 # "daemon" on "list" if set
673 start_gss_daemons() {
677 if [ "$list" ] && [ "$daemon" ] ; then
678 echo "Starting gss daemon on nodes: $list"
679 do_nodes $list "$daemon" || return 8
683 local list=$(comma_list $(mdts_nodes))
684 echo "Starting gss daemon on mds: $list"
685 do_nodes $list "$LSVCGSSD -v" || return 1
687 do_nodes $list "$LGSSD -v" || return 2
690 list=$(comma_list $(osts_nodes))
691 echo "Starting gss daemon on ost: $list"
692 do_nodes $list "$LSVCGSSD -v" || return 3
693 # starting on clients
695 local clients=${CLIENTS:-`hostname`}
697 echo "Starting $LGSSD on clients $clients "
698 do_nodes $clients "$LGSSD -v" || return 4
701 # wait daemons entering "stable" status
705 # check daemons are running
707 list=$(comma_list $(mdts_nodes) $(osts_nodes))
708 check_gss_daemon_nodes $list lsvcgssd || return 5
710 list=$(comma_list $(mdts_nodes))
711 check_gss_daemon_nodes $list lgssd || return 6
714 check_gss_daemon_nodes $clients lgssd || return 7
719 local list=$(comma_list $(mdts_nodes))
721 send_sigint $list lsvcgssd lgssd
723 list=$(comma_list $(osts_nodes))
724 send_sigint $list lsvcgssd
726 list=${CLIENTS:-`hostname`}
727 send_sigint $list lgssd
732 if ! module_loaded ptlrpc_gss; then
733 load_module ptlrpc/gss/ptlrpc_gss
734 module_loaded ptlrpc_gss ||
735 error_exit "init_gss : GSS=$GSS, but gss/krb5 is not supported!"
738 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
741 if [ -n "$LGSS_KEYRING_DEBUG" ]; then
743 sptlrpc.gss.lgss_keyring.debug_level=$LGSS_KEYRING_DEBUG
751 # maybe cleanup credential cache?
757 local var=${facet}_svc
765 echo -n $facet | sed -e 's/^fs[0-9]\+//' -e 's/[0-9_]\+//' |
766 tr '[:lower:]' '[:upper:]'
772 if [ $facet == mgs ]; then
776 echo -n $facet | sed -e 's/^fs[0-9]\+//' | sed -e 's/^[a-z]\+//'
784 if [ -n "${!var}" ]; then
789 var=$(facet_type $facet)FSTYPE
790 if [ -n "${!var}" ]; then
795 if [ -n "$FSTYPE" ]; then
800 if [[ $facet == mgs ]] && combined_mgs_mds; then
812 local facets=$(get_facets)
815 for facet in ${facets//,/ }; do
816 if [ $node == $(facet_host $facet) ] ||
817 [ $node == "$(facet_failover_host $facet)" ]; then
818 fstype=$(facet_fstype $facet)
819 if [[ $fstypes != *$fstype* ]]; then
820 fstypes+="${fstypes:+,}$fstype"
829 local num=$(facet_number $facet)
832 if [[ $(facet_type $facet) = OST ]]; then
834 if [[ -n "${!index}" ]]; then
839 index=${OST_INDICES[num - 1]}
842 [[ -n "$index" ]] || index=$((num - 1))
850 local fstype=$(facet_fstype $facet)
854 label=$(do_facet ${facet} "$E2LABEL ${dev} 2>/dev/null");;
856 label=$(do_facet ${facet} "$ZFS get -H -o value lustre:svname \
857 ${dev} 2>/dev/null");;
859 error "unknown fstype!";;
867 local device=$(mdsdevname $num)
868 local label=$(devicelabel mds$num ${device} | grep -v "CMD: ")
874 local device=$(ostdevname $num)
875 local label=$(devicelabel ost$num ${device} | grep -v "CMD: ")
880 # Get the device of a facet.
887 mgs) device=$(mgsdevname) ;;
888 mds*) device=$(mdsdevname $(facet_number $facet)) ;;
889 ost*) device=$(ostdevname $(facet_number $facet)) ;;
890 fs2mds) device=$(mdsdevname 1_2) ;;
891 fs2ost) device=$(ostdevname 1_2) ;;
892 fs3ost) device=$(ostdevname 2_2) ;;
900 # Get the virtual device of a facet.
907 mgs) device=$(mgsvdevname) ;;
908 mds*) device=$(mdsvdevname $(facet_number $facet)) ;;
909 ost*) device=$(ostvdevname $(facet_number $facet)) ;;
910 fs2mds) device=$(mdsvdevname 1_2) ;;
911 fs2ost) device=$(ostvdevname 1_2) ;;
912 fs3ost) device=$(ostvdevname 2_2) ;;
920 # Re-read the partition table on failover partner host.
921 # After a ZFS storage pool is created on a shared device, the partition table
922 # on the device may change. However, the operating system on the failover
923 # host may not notice the change automatically. Without the up-to-date partition
924 # block devices, 'zpool import ..' cannot find the labels, whose positions are
925 # relative to partition rather than disk beginnings.
927 # This function performs partprobe on the failover host to make it re-read the
930 refresh_partition_table() {
935 host=$(facet_passive_host $facet)
936 if [[ -n "$host" ]]; then
937 do_node $host "$PARTPROBE $device"
942 # Get ZFS storage pool name.
949 device=$(facet_device $facet)
950 # poolname is string before "/"
951 poolname="${device%%/*}"
957 # Create ZFS storage pool.
964 local opts=${@:-"-o cachefile=none"}
966 do_facet $facet "$ZPOOL list -H $poolname >/dev/null 2>&1 ||
967 $ZPOOL create -f $opts $poolname $vdev"
971 # Create ZFS file system.
977 local opts=${@:-"-o mountpoint=legacy"}
979 do_facet $facet "$ZFS list -H $dataset >/dev/null 2>&1 ||
980 $ZFS create $opts $dataset"
984 # Export ZFS storage pool.
985 # Before exporting the pool, all datasets within the pool should be unmounted.
993 poolname=$(zpool_name $facet)
995 if [[ -n "$poolname" ]]; then
996 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
997 grep -q ^$poolname/ /proc/mounts ||
998 $ZPOOL export $opts $poolname"
1003 # Destroy ZFS storage pool.
1004 # Destroy the given pool and free up any devices for other use. This command
1005 # tries to unmount any active datasets before destroying the pool.
1006 # -f Force any active datasets contained within the pool to be unmounted.
1010 local poolname=${2:-$(zpool_name $facet)}
1012 if [[ -n "$poolname" ]]; then
1013 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1014 $ZPOOL destroy -f $poolname"
1019 # Import ZFS storage pool.
1020 # Force importing, even if the pool appears to be potentially active.
1025 local opts=${@:-"-o cachefile=none"}
1028 poolname=$(zpool_name $facet)
1030 if [[ -n "$poolname" ]]; then
1031 opts+=" -d $(dirname $(facet_vdevice $facet))"
1032 do_facet $facet "$ZPOOL list -H $poolname >/dev/null 2>&1 ||
1033 $ZPOOL import -f $opts $poolname"
1038 # Set the "cachefile=none" property on ZFS storage pool so that the pool
1039 # is not automatically imported on system startup.
1041 # In a failover environment, this will provide resource level fencing which
1042 # will ensure that the same ZFS storage pool will not be imported concurrently
1043 # on different nodes.
1045 disable_zpool_cache() {
1049 poolname=$(zpool_name $facet)
1051 if [[ -n "$poolname" ]]; then
1052 do_facet $facet "$ZPOOL set cachefile=none $poolname"
1057 # This and set_osd_param() shall be used to access OSD parameters
1058 # once existed under "obdfilter":
1063 # writethrough_cache_enable
1067 local device=${2:-$FSNAME-OST*}
1070 do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
1071 osd-*.$device.$name 2>&1" | grep -v 'Found no match'
1076 local device=${2:-$FSNAME-OST*}
1080 do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
1081 osd-*.$device.$name=$value 2>&1" | grep -v 'Found no match'
1085 local dz=${1:-$DEBUG_SIZE}
1087 if [ -f /sys/devices/system/cpu/possible ]; then
1088 local cpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/possible)+1))
1090 local cpus=$(getconf _NPROCESSORS_CONF)
1093 # bug 19944, adjust size to be -gt num_possible_cpus()
1094 # promise 2MB for every cpu at least
1095 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
1098 lctl set_param debug_mb=$dz
1101 set_default_debug () {
1102 local debug=${1:-"$PTLDEBUG"}
1103 local subsys=${2:-"$SUBSYSTEM"}
1104 local debug_size=${3:-$DEBUG_SIZE}
1106 [ -n "$debug" ] && lctl set_param debug="$debug" >/dev/null
1107 [ -n "$subsys" ] && lctl set_param subsystem_debug="${subsys# }" >/dev/null
1109 [ -n "$debug_size" ] && set_debug_size $debug_size > /dev/null
1112 set_default_debug_nodes () {
1115 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
1116 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
1120 do_rpc_nodes "$nodes" set_default_debug \
1121 \\\"$PTLDEBUG\\\" \\\"$SUBSYSTEM\\\" $DEBUG_SIZE || true
1124 set_default_debug_facet () {
1126 local node=$(facet_active_host $facet)
1127 [ -z "$node" ] && echo "No host defined for facet $facet" && exit 1
1129 set_default_debug_nodes $node
1134 local facets=${1:-$(get_facets)}
1137 for facet in ${facets//,/ }; do
1140 [ $RC -eq 0 ] && continue
1142 if [ "$TESTSUITE.$TESTNAME" = "replay-dual.test_0a" ]; then
1143 skip "Restart of $facet failed!." && touch $LU482_FAILED
1145 error "Restart of $facet failed!"
1152 # Add argument "arg" (e.g., "loop") to the comma-separated list
1153 # of arguments for option "opt" (e.g., "-o") on command
1154 # line "opts" (e.g., "-o flock").
1160 local opt_pattern="\([[:space:]]\+\|^\)$opt"
1162 if echo "$opts" | grep -q $opt_pattern; then
1163 opts=$(echo "$opts" | sed -e \
1164 "s/$opt_pattern[[:space:]]*[^[:space:]]\+/&,$arg/")
1166 opts+="${opts:+ }$opt $arg"
1174 local dev=$(facet_active $facet)_dev
1175 local opt=${facet}_opt
1176 local mntpt=$(facet_mntpt $facet)
1177 local opts="${!opt} $@"
1179 if [ $(facet_fstype $facet) == ldiskfs ] &&
1180 ! do_facet $facet test -b ${!dev}; then
1181 opts=$(csa_add "$opts" -o loop)
1184 if [[ $(facet_fstype $facet) == zfs ]]; then
1185 # import ZFS storage pool
1186 import_zpool $facet || return ${PIPESTATUS[0]}
1189 echo "Starting ${facet}: $opts ${!dev} $mntpt"
1190 # for testing LU-482 error handling in mount_facets() and test_0a()
1191 if [ -f $TMP/test-lu482-trigger ]; then
1194 do_facet ${facet} "mkdir -p $mntpt; $MOUNT_CMD $opts \
1198 if [ $RC -ne 0 ]; then
1199 echo "Start of ${!dev} on ${facet} failed ${RC}"
1201 set_default_debug_facet $facet
1203 if [[ $facet == mds* ]]; then
1205 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1209 label=$(devicelabel ${facet} ${!dev})
1210 [ -z "$label" ] && echo no label for ${!dev} && exit 1
1211 eval export ${facet}_svc=${label}
1212 echo Started ${label}
1217 # start facet device options
1223 eval export ${facet}_dev=${device}
1224 eval export ${facet}_opt=\"$@\"
1226 local varname=${facet}failover_dev
1227 if [ -n "${!varname}" ] ; then
1228 eval export ${facet}failover_dev=${!varname}
1230 eval export ${facet}failover_dev=$device
1233 local mntpt=$(facet_mntpt $facet)
1234 do_facet ${facet} mkdir -p $mntpt
1235 eval export ${facet}_MOUNT=$mntpt
1236 mount_facet ${facet}
1239 if [[ $facet == mds* ]]; then
1241 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
1252 local HOST=`facet_active_host $facet`
1253 [ -z $HOST ] && echo stop: no host for $facet && return 0
1255 local mntpt=$(facet_mntpt $facet)
1256 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts") || true
1257 if [ ${running} -ne 0 ]; then
1258 echo "Stopping $mntpt (opts:$@) on $HOST"
1259 do_facet ${facet} umount -d $@ $mntpt
1262 # umount should block, but we should wait for unrelated obd's
1263 # like the MGS or MGC to also stop.
1264 wait_exit_ST ${facet} || return ${PIPESTATUS[0]}
1266 if [[ $(facet_fstype $facet) == zfs ]]; then
1267 # export ZFS storage pool
1272 # save quota version (both administrative and operational quotas)
1273 # add an additional parameter if mountpoint is ever different from $MOUNT
1275 # XXX This function is kept for interoperability with old server (< 2.3.50),
1276 # it should be removed whenever we drop the interoperability for such
1278 quota_save_version() {
1279 local fsname=${2:-$FSNAME}
1281 local ver=$(tr -c -d "123" <<< $spec)
1282 local type=$(tr -c -d "ug" <<< $spec)
1284 [ -n "$ver" -a "$ver" != "3" ] && error "wrong quota version specifier"
1286 [ -n "$type" ] && { $LFS quotacheck -$type $MOUNT || error "quotacheck has failed"; }
1288 do_facet mgs "lctl conf_param ${fsname}-MDT*.mdd.quota_type=$spec"
1290 local osts=$(get_facets OST)
1291 for ost in ${osts//,/ }; do
1293 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$spec"
1297 # client could mount several lustre
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
1303 local fsname=${1:-$FSNAME}
1305 do_facet $SINGLEMDS lctl get_param mdd.${fsname}-MDT*.quota_type ||
1307 do_nodes $(comma_list $(osts_nodes)) \
1308 lctl get_param obdfilter.${fsname}-OST*.quota_type || rc=$?
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
1315 restore_quota_old() {
1316 local mntpt=${1:-$MOUNT}
1317 local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
1318 if [ ! "$old_QUOTA_TYPE" ] ||
1319 [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
1322 quota_save_version $old_QUOTA_TYPE
1325 # XXX This function is kept for interoperability with old server (< 2.3.50),
1326 # it should be removed whenever we drop the interoperability for such
1331 # no quota enforcement for now and accounting works out of the box
1334 # We need save the original quota_type params, and restore them after testing
1336 # Suppose that quota type the same on mds and ost
1337 local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
1338 [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
1339 echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
1340 if [ "$quota_type" != "$QUOTA_TYPE" ]; then
1341 export old_QUOTA_TYPE=$quota_type
1342 quota_save_version $QUOTA_TYPE
1344 qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
1345 $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
1348 local quota_usrs=$QUOTA_USERS
1350 # get_filesystem_size
1351 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1352 local blk_soft=$((disksz + 1024))
1353 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1355 local Inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1356 local i_soft=$Inodes
1357 local i_hard=$((i_soft + i_soft / 20))
1359 echo "Total disk size: $disksz block-softlimit: $blk_soft block-hardlimit:
1360 $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
1363 for usr in $quota_usrs; do
1364 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1366 cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1368 eval $cmd || error "$cmd FAILED!"
1370 # display the quota status
1371 echo "Quota settings for $usr : "
1372 $LFS quota -v -u $usr $mntpt || true
1376 # get mdt quota type
1378 local varsvc=${SINGLEMDS}_svc
1379 do_facet $SINGLEMDS $LCTL get_param -n \
1380 osd-$(facet_fstype $SINGLEMDS).${!varsvc}.quota_slave.enabled
1383 # get ost quota type
1385 # All OSTs should have same quota type
1386 local varsvc=ost1_svc
1387 do_facet ost1 $LCTL get_param -n \
1388 osd-$(facet_fstype ost1).${!varsvc}.quota_slave.enabled
1391 # restore old quota type settings
1393 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1398 if [ "$old_MDT_QUOTA_TYPE" ]; then
1399 do_facet mgs $LCTL conf_param \
1400 $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
1402 if [ "$old_OST_QUOTA_TYPE" ]; then
1403 do_facet mgs $LCTL conf_param \
1404 $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
1408 # Handle the case when there is a space in the lfs df
1409 # "filesystem summary" line the same as when there is no space.
1410 # This will allow fixing the "lfs df" summary line in the future.
1412 $LFS df $* | sed -e 's/filesystem /filesystem_/'
1415 # Get free inodes on the MDT specified by mdt index, free indoes on
1416 # the whole filesystem will be returned when index == -1.
1422 if [ $index -eq -1 ]; then
1425 mdt_uuid=$(mdtuuid_from_index $index)
1428 free_inodes=$(lfs_df -i $MOUNT | grep $mdt_uuid | awk '{print $4}')
1433 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
1440 # save old quota type & set new quota type
1441 local mdt_qtype=$(mdt_quota_type)
1442 local ost_qtype=$(ost_quota_type)
1444 echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
1445 "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
1447 export old_MDT_QUOTA_TYPE=$mdt_qtype
1448 export old_OST_QUOTA_TYPE=$ost_qtype
1450 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$QUOTA_TYPE ||
1451 error "set mdt quota type failed"
1452 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$QUOTA_TYPE ||
1453 error "set ost quota type failed"
1455 local quota_usrs=$QUOTA_USERS
1457 # get_filesystem_size
1458 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
1459 local blk_soft=$((disksz + 1024))
1460 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
1462 local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
1463 local i_soft=$inodes
1464 local i_hard=$((i_soft + i_soft / 20))
1466 echo "Total disk size: $disksz block-softlimit: $blk_soft" \
1467 "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
1468 "inode-hardlimit: $i_hard"
1471 for usr in $quota_usrs; do
1472 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
1474 cmd="$LFS setquota -$type $usr -b $blk_soft"
1475 cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
1477 eval $cmd || error "$cmd FAILED!"
1479 # display the quota status
1480 echo "Quota settings for $usr : "
1481 $LFS quota -v -u $usr $mntpt || true
1488 local opts=${3:-$MOUNT_OPTS}
1489 opts=${opts:+-o $opts}
1490 local flags=${4:-$MOUNT_FLAGS}
1492 local device=$MGSNID:/$FSNAME
1493 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1494 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1498 echo "Starting client: $client: $flags $opts $device $mnt"
1499 do_node $client mkdir -p $mnt
1500 do_node $client $MOUNT_CMD $flags $opts $device $mnt || return 1
1502 set_default_debug_nodes $client
1514 [ "$3" ] && force=-f
1515 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
1516 if [ $running -ne 0 ]; then
1517 echo "Stopping client $client $mnt (opts:$force)"
1518 do_node $client lsof -t $mnt || need_kill=no
1519 if [ "x$force" != "x" -a "x$need_kill" != "xno" ]; then
1520 pids=$(do_node $client lsof -t $mnt | sort -u);
1521 if [ -n $pids ]; then
1522 do_node $client kill -9 $pids || true
1526 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") || true
1527 if [ $busy -ne 0 ] ; then
1528 echo "$mnt is still busy, wait one second" && sleep 1
1529 do_node $client umount $force $mnt
1534 # nodes is comma list
1535 sanity_mount_check_nodes () {
1541 # FIXME: assume that all cluster nodes run the same os
1542 [ "$(uname)" = Linux ] || return 0
1545 for mnt in $mnts ; do
1546 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
1547 mpts=\\\$(mount | grep -c $mnt' ');
1548 if [ \\\$running -ne \\\$mpts ]; then
1549 echo \\\$(hostname) env are INSANE!;
1552 [ $? -eq 0 ] || rc=1
1557 sanity_mount_check_servers () {
1558 [ "$CLIENTONLY" ] &&
1559 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
1560 echo Checking servers environments
1562 # FIXME: modify get_facets to display all facets wo params
1563 local facets="$(get_facets OST),$(get_facets MDS),mgs"
1567 for facet in ${facets//,/ }; do
1568 node=$(facet_host ${facet})
1569 mntpt=$(facet_mntpt $facet)
1570 sanity_mount_check_nodes $node $mntpt ||
1571 { error "server $node environments are insane!"; return 1; }
1575 sanity_mount_check_clients () {
1576 local clients=${1:-$CLIENTS}
1577 local mntpt=${2:-$MOUNT}
1578 local mntpt2=${3:-$MOUNT2}
1580 [ -z $clients ] && clients=$(hostname)
1581 echo Checking clients $clients environments
1583 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
1584 error "clients environments are insane!"
1587 sanity_mount_check () {
1588 sanity_mount_check_servers || return 1
1589 sanity_mount_check_clients || return 2
1592 # mount clients if not mouted
1593 zconf_mount_clients() {
1596 local opts=${3:-$MOUNT_OPTS}
1597 opts=${opts:+-o $opts}
1598 local flags=${4:-$MOUNT_FLAGS}
1600 local device=$MGSNID:/$FSNAME
1601 if [ -z "$mnt" -o -z "$FSNAME" ]; then
1602 echo Bad zconf mount command: opt=$flags $opts dev=$device mnt=$mnt
1606 echo "Starting client $clients: $flags $opts $device $mnt"
1609 running=\\\$(mount | grep -c $mnt' ');
1611 if [ \\\$running -eq 0 ] ; then
1613 $MOUNT_CMD $flags $opts $device $mnt;
1616 exit \\\$rc" || return ${PIPESTATUS[0]}
1618 echo "Started clients $clients: "
1619 do_nodes $clients "mount | grep $mnt' '"
1621 set_default_debug_nodes $clients
1626 zconf_umount_clients() {
1631 [ "$3" ] && force=-f
1633 echo "Stopping clients: $clients $mnt (opts:$force)"
1634 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
1635 if [ \\\$running -ne 0 ] ; then
1636 echo Stopping client \\\$(hostname) $mnt opts:$force;
1637 lsof $mnt || need_kill=no;
1638 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
1639 pids=\\\$(lsof -t $mnt | sort -u);
1640 if [ -n \\\"\\\$pids\\\" ]; then
1644 while umount $force $mnt 2>&1 | grep -q "busy"; do
1645 echo "$mnt is still busy, wait one second" && sleep 1;
1652 echo + $POWER_DOWN $node
1656 shutdown_node_hard () {
1658 local attempts=$SHUTDOWN_ATTEMPTS
1660 for i in $(seq $attempts) ; do
1663 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
1664 echo "waiting for $host to fail attempts=$attempts"
1665 [ $i -lt $attempts ] || \
1666 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
1672 local mnt=${2:-$MOUNT}
1675 if [ "$FAILURE_MODE" = HARD ]; then
1676 shutdown_node_hard $client
1678 zconf_umount_clients $client $mnt -f
1684 local facets="$(get_facets OST),$(get_facets MDS)"
1687 combined_mgs_mds || facets="$facets,mgs"
1689 for facet in ${facets//,/ }; do
1690 if [ $(facet_active_host $facet) == $host ]; then
1691 affected="$affected $facet"
1695 echo $(comma_list $affected)
1700 local host=${2:-$(facet_host $facet)}
1702 local label=$(convert_facet2label $facet)
1703 do_node $host $LCTL dl | awk '{ print $4 }' | grep -q "^$label\$"
1706 facets_up_on_host () {
1708 local facets=$(facets_on_host $host)
1711 for facet in ${facets//,/ }; do
1712 if $(facet_up $facet $host); then
1713 affected_up="$affected_up $facet"
1717 echo $(comma_list $affected_up)
1723 if [ "$FAILURE_MODE" = HARD ]; then
1724 shutdown_node_hard $(facet_active_host $facet)
1732 echo + $POWER_UP $node
1745 if [ "$FAILURE_MODE" = HARD ]; then
1746 reboot_node $(facet_active_host $facet)
1754 if [ "$FAILURE_MODE" = HARD ]; then
1764 for facet in ${facets//,/ }; do
1765 hosts=$(expand_list $hosts $(facet_host $facet) )
1771 _check_progs_installed () {
1775 for prog in $progs; do
1776 if ! [ "$(which $prog)" -o "${!prog}" ]; then
1777 echo $prog missing on $(hostname)
1784 check_progs_installed () {
1788 do_rpc_nodes "$nodes" _check_progs_installed $@
1791 # recovery-scale functions
1793 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
1796 start_client_load() {
1799 local var=$(node_var_name $client)_load
1800 eval export ${var}=$load
1802 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
1803 BREAK_ON_ERROR=$BREAK_ON_ERROR \
1804 END_RUN_FILE=$END_RUN_FILE \
1805 LOAD_PID_FILE=$LOAD_PID_FILE \
1806 TESTLOG_PREFIX=$TESTLOG_PREFIX \
1807 TESTNAME=$TESTNAME \
1808 DBENCH_LIB=$DBENCH_LIB \
1809 DBENCH_SRC=$DBENCH_SRC \
1810 CLIENT_COUNT=$((CLIENTCOUNT - 1)) \
1814 log "Started client load: ${load} on $client"
1816 # get the children process IDs
1817 local pids=$(ps --ppid $ppid -o pid= | xargs)
1818 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
1822 start_client_loads () {
1823 local -a clients=(${1//,/ })
1824 local numloads=${#CLIENT_LOADS[@]}
1827 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
1828 testnum=$((nodenum % numloads))
1829 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[testnum]}
1831 # bug 22169: wait the background threads to start
1835 # only for remote client
1836 check_client_load () {
1838 local var=$(node_var_name $client)_load
1839 local TESTLOAD=run_${!var}.sh
1841 ps auxww | grep -v grep | grep $client | grep -q "$TESTLOAD" || return 1
1843 # bug 18914: try to connect several times not only when
1844 # check ps, but while check_catastrophe also
1847 while [ $RC = 254 -a $tries -gt 0 ]; do
1851 if ! check_catastrophe $client; then
1853 if [ $RC -eq 254 ]; then
1854 # FIXME: not sure how long we shuold sleep here
1858 echo "check catastrophe failed: RC=$RC "
1862 # We can continue try to connect if RC=254
1863 # Just print the warning about this
1864 if [ $RC = 254 ]; then
1865 echo "got a return status of $RC from do_node while checking catastrophe on $client"
1868 # see if the load is still on the client
1871 while [ $RC = 254 -a $tries -gt 0 ]; do
1875 if ! do_node $client "ps auxwww | grep -v grep | grep -q $TESTLOAD"; then
1880 if [ $RC = 254 ]; then
1881 echo "got a return status of $RC from do_node while checking (catastrophe and 'ps') the client load on $client"
1882 # see if we can diagnose a bit why this is
1887 check_client_loads () {
1888 local clients=${1//,/ }
1892 for client in $clients; do
1893 check_client_load $client
1895 if [ "$rc" != 0 ]; then
1896 log "Client load failed on node $client, rc=$rc"
1902 restart_client_loads () {
1903 local clients=${1//,/ }
1904 local expectedfail=${2:-""}
1908 for client in $clients; do
1909 check_client_load $client
1911 if [ "$rc" != 0 -a "$expectedfail" ]; then
1912 local var=$(node_var_name $client)_load
1913 start_client_load $client ${!var}
1914 echo "Restarted client load ${!var}: on $client. Checking ..."
1915 check_client_load $client
1917 if [ "$rc" != 0 ]; then
1918 log "Client load failed to restart on node $client, rc=$rc"
1919 # failure one client load means test fail
1920 # we do not need to check other
1929 # Start vmstat and save its process ID in a file.
1934 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1937 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
1938 2>/dev/null </dev/null & echo \\\$! > $pid_file"
1941 # Display the nodes on which client loads failed.
1942 print_end_run_file() {
1946 [ -s $file ] || return 0
1948 echo "Found the END_RUN_FILE file: $file"
1951 # A client load will stop if it finds the END_RUN_FILE file.
1952 # That does not mean the client load actually failed though.
1953 # The first node in END_RUN_FILE is the one we are interested in.
1956 if [ -n "$node" ]; then
1957 local var=$(node_var_name $node)_load
1959 local prefix=$TESTLOG_PREFIX
1960 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
1961 local stdout_log=$prefix.run_${!var}_stdout.$node.log
1962 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
1964 echo "Client load ${!var} failed on node $node:"
1970 # Stop the process which had its PID saved in a file.
1975 [ -z "$nodes" -o -z "$pid_file" ] && return 0
1977 do_nodes $nodes "test -f $pid_file &&
1978 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
1981 # Stop all client loads.
1982 stop_client_loads() {
1983 local nodes=${1:-$CLIENTS}
1986 # stop the client loads
1987 stop_process $nodes $pid_file
1989 # clean up the processes that started them
1990 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
1992 # End recovery-scale functions
1994 # verify that lustre actually cleaned up properly
1996 VAR=$(lctl get_param -n catastrophe 2>&1)
1997 if [ $? = 0 ] ; then
1998 if [ $VAR != 0 ]; then
1999 error "LBUG/LASSERT detected"
2002 BUSY=$(dmesg | grep -i destruct || true)
2003 if [ -n "$BUSY" ]; then
2005 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.$(date +%s)
2009 check_mem_leak || exit 204
2011 [[ $($LCTL dl 2>/dev/null | wc -l) -gt 0 ]] && $LCTL dl &&
2012 echo "$TESTSUITE: lustre didn't clean up..." 1>&2 &&
2015 if module_loaded lnet || module_loaded libcfs; then
2016 echo "$TESTSUITE: modules still loaded..." 1>&2
2025 if [[ "$1" == "--verbose" ]]; then
2040 PREV_RESULT=$(do_node $node "$TEST")
2042 RESULT=$(do_node $node "$TEST")
2043 if [[ "$RESULT" == "$FINAL" ]]; then
2044 [[ -z "$RESULT" || $WAIT -le $sleep ]] ||
2045 echo "Updated after ${WAIT}s: wanted '$FINAL'"\
2049 if [[ $verbose && "$RESULT" != "$PREV_RESULT" ]]; then
2050 echo "Changed after ${WAIT}s: from '$PREV_RESULT'"\
2054 [[ $WAIT -ge $MAX ]] && break
2055 [[ $((WAIT % print)) -eq 0 ]] &&
2056 echo "Waiting $((MAX - WAIT)) secs for update"
2057 WAIT=$((WAIT + sleep))
2060 echo "Update not seen after ${MAX}s: wanted '$FINAL' got '$RESULT'"
2064 wait_update_facet() {
2067 wait_update $(facet_active_host $facet) "$@"
2071 do_nodes $(comma_list $(mdts_nodes)) \
2072 "lctl set_param -n osd*.*MDT*.force_sync 1"
2073 do_nodes $(comma_list $(osts_nodes)) \
2074 "lctl set_param -n osd*.*OS*.force_sync 1" 2>&1 |
2075 grep -v 'Found no match'
2078 wait_delete_completed_mds() {
2079 local MAX_WAIT=${1:-20}
2080 # for ZFS, waiting more time for DMUs to be committed
2081 local ZFS_WAIT=${2:-5}
2083 local stime=$(date +%s)
2088 # find MDS with pending deletions
2089 for node in $(mdts_nodes); do
2090 changes=$(do_node $node "$LCTL get_param -n osc.*MDT*.sync_*" \
2091 2>/dev/null | calc_sum)
2092 if [[ $changes -eq 0 ]]; then
2095 mds2sync="$mds2sync $node"
2097 if [ -z "$mds2sync" ]; then
2100 mds2sync=$(comma_list $mds2sync)
2102 # sync MDS transactions
2103 do_nodes $mds2sync "$LCTL set_param -n osd*.*MD*.force_sync 1"
2105 # wait till all changes are sent and commmitted by OSTs
2106 # for ldiskfs space is released upon execution, but DMU
2107 # do this upon commit
2110 while [[ $WAIT -ne $MAX_WAIT ]]; do
2111 changes=$(do_nodes $mds2sync \
2112 "$LCTL get_param -n osc.*MDT*.sync_*" | calc_sum)
2113 #echo "$node: $changes changes on all"
2114 if [[ $changes -eq 0 ]]; then
2116 #echo "delete took $((etime - stime)) seconds"
2118 # the occupied disk space will be released
2119 # only after DMUs are committed
2120 if [[ $(facet_fstype $SINGLEMDS) == zfs ]]; then
2121 echo "sleep $ZFS_WAIT for ZFS OSD"
2132 echo "Delete is not completed in $((etime - stime)) seconds"
2133 do_nodes $mds2sync "$LCTL get_param osc.*MDT*.sync_*"
2139 # we can use "for" here because we are waiting the slowest
2140 for host in ${hostlist//,/ }; do
2141 check_network "$host" 900
2143 while ! do_nodes $hostlist hostname > /dev/null; do sleep 5; done
2150 for facet in ${facetlist//,/ }; do
2151 hostlist=$(expand_list $hostlist $(facet_active_host $facet))
2153 wait_for_host $hostlist
2156 _wait_recovery_complete () {
2159 # Use default policy if $2 is not passed by caller.
2160 local MAX=${2:-$(max_recovery_time)}
2165 while [ $WAIT -lt $MAX ]; do
2166 STATUS=$(lctl get_param -n $param | grep status)
2168 [[ $STATUS = "status: COMPLETE" || $STATUS = "status: INACTIVE" ]] && return 0
2171 echo "Waiting $((MAX - WAIT)) secs for $param recovery done. $STATUS"
2173 echo "$param recovery not done in $MAX sec. $STATUS"
2177 wait_recovery_complete () {
2180 # with an assumption that at_max is the same on all nodes
2181 local MAX=${2:-$(max_recovery_time)}
2184 if [ "$FAILURE_MODE" = HARD ]; then
2185 facets=$(facets_on_host $(facet_active_host $facet))
2187 echo affected facets: $facets
2189 # we can use "for" here because we are waiting the slowest
2190 for facet in ${facets//,/ }; do
2191 local var_svc=${facet}_svc
2192 local param="*.${!var_svc}.recovery_status"
2194 local host=$(facet_active_host $facet)
2195 do_rpc_nodes "$host" _wait_recovery_complete $param $MAX
2199 wait_mds_ost_sync () {
2200 # just because recovery is done doesn't mean we've finished
2201 # orphan cleanup. Wait for llogs to get synchronized.
2202 echo "Waiting for orphan cleanup..."
2203 # MAX value includes time needed for MDS-OST reconnection
2204 local MAX=$(( TIMEOUT * 2 ))
2205 local WAIT_TIMEOUT=${1:-$MAX}
2208 local list=$(comma_list $(mdts_nodes))
2209 local cmd="$LCTL get_param -n osp.*osc*.old_sync_processed"
2210 if ! do_facet $SINGLEMDS \
2211 "$LCTL list_param osp.*osc*.old_sync_processed 2> /dev/null"
2213 # old way, use mds_sync
2215 list=$(comma_list $(osts_nodes))
2216 cmd="$LCTL get_param -n obdfilter.*.mds_sync"
2219 echo "wait $WAIT_TIMEOUT secs maximumly for $list mds-ost sync done."
2220 while [ $WAIT -lt $WAIT_TIMEOUT ]; do
2221 local -a sync=($(do_nodes $list "$cmd"))
2224 for ((i=0; i<${#sync[@]}; i++)); do
2226 [ ${sync[$i]} -eq 1 ] && continue
2228 [ ${sync[$i]} -eq 0 ] && continue
2230 # there is a not finished MDS-OST synchronization
2234 sleep 2 # increase waiting time and cover statfs cache
2235 [ ${con} -eq 1 ] && return 0
2236 echo "Waiting $WAIT secs for $list $i mds-ost sync done."
2240 # show which nodes are not finished.
2241 do_nodes $list "$cmd"
2242 echo "$facet recovery node $i not done in $WAIT_TIMEOUT sec. $STATUS"
2246 wait_destroy_complete () {
2247 echo "Waiting for local destroys to complete"
2248 # MAX value shouldn't be big as this mean server responsiveness
2249 # never increase this just to make test pass but investigate
2250 # why it takes so long time
2253 while [ $WAIT -lt $MAX ]; do
2254 local -a RPCs=($($LCTL get_param -n osc.*.destroys_in_flight))
2258 for ((i=0; i<${#RPCs[@]}; i++)); do
2259 [ ${RPCs[$i]} -eq 0 ] && continue
2260 # there are still some destroy RPCs in flight
2265 [ ${con} -eq 1 ] && return 0 # done waiting
2266 echo "Waiting ${WAIT}s for local destroys to complete"
2269 echo "Local destroys weren't done in $MAX sec."
2273 wait_delete_completed() {
2274 wait_delete_completed_mds $1 || return $?
2275 wait_destroy_complete
2284 # conf-sanity 31 takes a long time cleanup
2285 while [ $WAIT -lt 300 ]; do
2286 running=$(do_facet ${facet} "lsmod | grep lnet > /dev/null && lctl dl | grep ' ST '") || true
2287 [ -z "${running}" ] && return 0
2288 echo "waited $WAIT for${running}"
2289 [ $INTERVAL -lt 64 ] && INTERVAL=$((INTERVAL + INTERVAL))
2291 WAIT=$((WAIT + INTERVAL))
2293 echo "service didn't stop after $WAIT seconds. Still running:"
2298 wait_remote_prog () {
2304 [ "$PDSH" = "no_dsh" ] && return 0
2306 while [ $WAIT -lt $2 ]; do
2307 running=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep) || true
2308 [ -z "${running}" ] && return 0 || true
2309 echo "waited $WAIT for: "
2311 [ $INTERVAL -lt 60 ] && INTERVAL=$((INTERVAL + INTERVAL))
2313 WAIT=$((WAIT + INTERVAL))
2315 local pids=$(ps uax | grep "$PDSH.*$prog.*$MOUNT" | grep -v grep | awk '{print $2}')
2316 [ -z "$pids" ] && return 0
2317 echo "$PDSH processes still exists after $WAIT seconds. Still running: $pids"
2318 # FIXME: not portable
2319 for pid in $pids; do
2320 cat /proc/${pid}/status || true
2321 cat /proc/${pid}/wchan || true
2323 kill -9 $pid || true
2332 # not every config has many clients
2334 if [ ! -z "$CLIENTS" ]; then
2335 $PDSH $CLIENTS "stat -f $MOUNT" > /dev/null
2337 stat -f $MOUNT > /dev/null
2343 # usually checked on particular client or locally
2345 if [ ! -z "$client" ]; then
2346 $PDSH $client "stat -f $MOUNT" > /dev/null
2348 stat -f $MOUNT > /dev/null
2356 client_reconnect_try() {
2357 uname -n >> $MOUNT/recon
2358 if [ -z "$CLIENTS" ]; then
2359 df $MOUNT; uname -n >> $MOUNT/recon
2361 do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
2363 echo Connected clients:
2365 ls -l $MOUNT/recon > /dev/null
2369 client_reconnect() {
2370 # one client_reconnect_try call does not always do the job...
2372 client_reconnect_try && break
2377 affected_facets () {
2380 local host=$(facet_active_host $facet)
2381 local affected=$facet
2383 if [ "$FAILURE_MODE" = HARD ]; then
2384 affected=$(facets_up_on_host $host)
2398 #Because it will only get up facets, we need get affected
2399 #facets before shutdown
2400 #For HARD Failure mode, it needs make sure facets on the same
2401 #HOST will only be shutdown and reboot once
2402 for facet in ${facets//,/ }; do
2403 local affected_facet
2405 #check whether facet has been included in other affected facets
2406 for ((index=0; index<$total; index++)); do
2407 [[ *,$facet,* == ,${affecteds[index]}, ]] && skip=1
2410 if [ $skip -eq 0 ]; then
2411 affecteds[$total]=$(affected_facets $facet)
2416 for ((index=0; index<$total; index++)); do
2417 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2418 local host=$(facet_active_host $facet)
2419 echo "Failing ${affecteds[index]} on $host"
2420 shutdown_facet $facet
2423 for ((index=0; index<$total; index++)); do
2424 facet=$(echo ${affecteds[index]} | tr -s " " | cut -d"," -f 1)
2425 echo reboot facets: ${affecteds[index]}
2429 change_active ${affecteds[index]}
2431 wait_for_facet ${affecteds[index]}
2432 # start mgs first if it is affected
2433 if ! combined_mgs_mds &&
2434 list_member ${affecteds[index]} mgs; then
2435 mount_facet mgs || error "Restart of mgs failed"
2437 # FIXME; has to be changed to mount all facets concurrently
2438 affected=$(exclude_items_from_list ${affecteds[index]} mgs)
2439 echo mount facets: ${affecteds[index]}
2440 mount_facets ${affecteds[index]}
2450 do_facet $facet "sync; sync; sync"
2453 # make sure there will be no seq change
2454 local clients=${CLIENTS:-$HOSTNAME}
2455 local f=fsa-\\\$\(hostname\)
2456 do_nodes $clients "mcreate $MOUNT/$f; rm $MOUNT/$f"
2457 do_nodes $clients "if [ -d $MOUNT2 ]; then mcreate $MOUNT2/$f; rm $MOUNT2/$f; fi"
2459 local svc=${facet}_svc
2460 do_facet $facet $LCTL --device ${!svc} notransno
2462 # If a ZFS OSD is made read-only here, its pool is "freezed". This
2463 # in-memory state has to be cleared by either rebooting the host or
2464 # exporting and reimporting the pool.
2466 # Although the uberblocks are not updated when a pool is freezed,
2467 # transactions are still written to the disks. Modified blocks may be
2468 # cached in memory when tests try reading them back. The
2469 # export-and-reimport process also evicts any cached pool data from
2470 # memory to provide the correct "data loss" semantics.
2472 # In the test framework, the exporting and importing operations are
2473 # handled by stop() and mount_facet() separately, which are used
2474 # inside fail() and fail_abort().
2476 do_facet $facet $LCTL --device ${!svc} readonly
2477 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2478 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2481 replay_barrier_nodf() {
2482 local facet=$1 echo running=${running}
2483 do_facet $facet "sync; sync; sync"
2484 local svc=${facet}_svc
2485 echo Replay barrier on ${!svc}
2486 do_facet $facet $LCTL --device ${!svc} notransno
2487 do_facet $facet $LCTL --device ${!svc} readonly
2488 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2489 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2492 replay_barrier_nosync() {
2493 local facet=$1 echo running=${running}
2494 local svc=${facet}_svc
2495 echo Replay barrier on ${!svc}
2496 do_facet $facet $LCTL --device ${!svc} notransno
2497 do_facet $facet $LCTL --device ${!svc} readonly
2498 do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
2499 $LCTL mark "local REPLAY BARRIER on ${!svc}"
2503 # Get Lustre client uuid for a given Lustre mount point.
2506 local mntpnt=${1:-$MOUNT}
2508 local name=$($LFS getname $mntpnt | cut -d' ' -f1)
2509 local uuid=$($LCTL get_param -n llite.$name.uuid)
2514 mds_evict_client() {
2515 local mntpnt=${1:-$MOUNT}
2516 local uuid=$(get_client_uuid $mntpnt)
2518 do_facet $SINGLEMDS \
2519 "$LCTL set_param -n mdt.${mds1_svc}.evict_client $uuid"
2522 ost_evict_client() {
2523 local mntpnt=${1:-$MOUNT}
2524 local uuid=$(get_client_uuid $mntpnt)
2527 "$LCTL set_param -n obdfilter.${ost1_svc}.evict_client $uuid"
2532 local clients=${CLIENTS:-$HOSTNAME}
2534 facet_failover $* || error "failover: $?"
2535 wait_clients_import_state "$clients" "$facets" FULL
2536 clients_up || error "post-failover df: $?"
2541 facet_failover $facet
2547 change_active $facet
2548 wait_for_facet $facet
2549 mount_facet $facet -o abort_recovery
2550 clients_up || echo "first df failed: $?"
2551 clients_up || error "post-failover df: $?"
2555 echo There is no lmc. This is mountconf, baby.
2559 host_nids_address() {
2563 if [ -n "$kind" ]; then
2564 nids=$(do_nodes $nodes "$LCTL list_nids | grep $kind | cut -f 1 -d '@'")
2566 nids=$(do_nodes $nodes "$LCTL list_nids all | cut -f 1 -d '@'")
2572 if [ "$1" = "'*'" ]; then echo \'*\'; else
2578 if [ "$1" = "'*'" ]; then echo \'*\'; else
2579 ID=`xtprocadmin -n $1 2>/dev/null | egrep -v 'NID' | \
2581 if [ -z "$ID" ]; then
2582 echo "Could not get a ptl id for $1..."
2591 h2name_or_ip "$1" "tcp"
2596 if [ "$1" = "'*'" ]; then echo \'*\'; else
2597 if type __h2elan >/dev/null 2>&1; then
2600 ID=`echo $1 | sed 's/[^0-9]*//g'`
2608 h2name_or_ip "$1" "o2ib"
2612 # This enables variables in cfg/"setup".sh files to support the pdsh HOSTLIST
2613 # expressions format. As a bonus we can then just pass in those variables
2614 # to pdsh. What this function does is take a HOSTLIST type string and
2615 # expand it into a space deliminated list for us.
2623 [ -z "$hostlist" ] && return
2625 # Translate the case of [..],..,[..] to [..] .. [..]
2626 list="${hostlist/],/] }"
2628 [[ "$front" == *,* ]] && {
2631 list=${list/${old}/${new}}
2634 for item in $list; do
2635 # Test if we have any []'s at all
2636 if [ "$item" != "${item/\[/}" ]; then {
2637 # Expand the [*] into list
2641 if [ "$name" != "$item" ]; then
2642 group=${item#$name[*}
2645 for range in ${group//,/ }; do
2649 # Number of leading zeros
2652 end=$(echo $end | sed 's/0*//')
2653 [[ -z "$end" ]] && end=0
2654 [[ $padlen2 -gt $padlen ]] && {
2655 [[ $padlen2 -eq ${#end} ]] && padlen2=0
2658 begin=$(echo $begin | sed 's/0*//')
2659 [ -z $begin ] && begin=0
2661 for num in $(seq -f "%0${padlen}g" $begin $end); do
2662 value="${name#*,}${num}${back}"
2663 [ "$value" != "${value/\[/}" ] && {
2664 value=$(hostlist_expand "$value")
2666 myList="$myList $value"
2671 myList="$myList $item"
2674 myList=${myList//,/ }
2675 myList=${myList:1} # Remove first character which is a space
2677 # Filter any duplicates without sorting
2679 myList="${list%% *}"
2681 while [[ "$list" != ${myList##* } ]]; do
2682 list=${list//${list%% *} /}
2683 myList="$myList ${list%% *}"
2685 myList="${myList%* }";
2687 # We can select an object at an offset in the list
2690 for item in $myList; do
2692 [ $cnt -eq $offset ] && {
2696 [ $(get_node_count $myList) -ne 1 ] && myList=""
2705 [ "$facet" == client ] && echo -n $HOSTNAME && return
2706 varname=${facet}_HOST
2707 if [ -z "${!varname}" ]; then
2708 if [ "${facet:0:3}" == "ost" ]; then
2709 local fh=${facet%failover}_HOST
2710 eval export ${facet}_HOST=${!fh}
2711 if [ -z "${!varname}" ]; then
2712 eval export ${facet}_HOST=${ost_HOST}
2714 elif [ "${facet:0:3}" == "mdt" -o \
2715 "${facet:0:3}" == "mds" -o \
2716 "${facet:0:3}" == "mgs" ]; then
2717 eval export ${facet}_HOST=${mds_HOST}
2723 facet_failover_host() {
2727 var=${facet}failover_HOST
2728 if [ -n "${!var}" ]; then
2733 if [ "${facet:0:3}" == "mdt" -o "${facet:0:3}" == "mds" -o \
2734 "${facet:0:3}" == "mgs" ]; then
2736 eval export ${facet}failover_host=${mds_HOST}
2741 if [[ $facet == ost* ]]; then
2742 eval export ${facet}failover_host=${ost_HOST}
2750 local activevar=${facet}active
2752 if [ -f $TMP/${facet}active ] ; then
2753 source $TMP/${facet}active
2756 active=${!activevar}
2757 if [ -z "$active" ] ; then
2764 facet_active_host() {
2766 local active=`facet_active $facet`
2767 if [ "$facet" == client ]; then
2770 echo `facet_host $active`
2774 # Get the passive failover partner host of facet.
2775 facet_passive_host() {
2777 [[ $facet = client ]] && return
2779 local host=${facet}_HOST
2780 local failover_host=${facet}failover_HOST
2781 local active_host=$(facet_active_host $facet)
2783 [[ -z ${!failover_host} || ${!failover_host} = ${!host} ]] && return
2785 if [[ $active_host = ${!host} ]]; then
2786 echo -n ${!failover_host}
2796 facetlist=$(exclude_items_from_list $facetlist mgs)
2798 for facet in ${facetlist//,/ }; do
2799 local failover=${facet}failover
2800 local host=`facet_host $failover`
2801 [ -z "$host" ] && return
2803 local curactive=`facet_active $facet`
2804 if [ -z "${curactive}" -o "$curactive" == "$failover" ] ; then
2805 eval export ${facet}active=$facet
2807 eval export ${facet}active=$failover
2809 # save the active host for this facet
2810 local activevar=${facet}active
2811 echo "$activevar=${!activevar}" > $TMP/$activevar
2812 [[ $facet = mds1 ]] && combined_mgs_mds && \
2813 echo "mgsactive=${!activevar}" > $TMP/mgsactive
2814 local TO=`facet_active_host $facet`
2815 echo "Failover $facet to $TO"
2821 # do not stripe off hostname if verbose, bug 19215
2822 if [ x$1 = x--verbose ]; then
2830 if [ "$HOST" = "$HOSTNAME" ]; then
2832 elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
2833 echo "cannot run remote command on $HOST with $myPDSH"
2837 echo "CMD: $HOST $@" >&2
2838 $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2841 if [ "$myPDSH" = "rsh" ]; then
2842 # we need this because rsh does not return exit code of an executed command
2843 local command_status="$TMP/cs"
2844 rsh $HOST ":> $command_status"
2845 rsh $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin;
2846 cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\") ||
2847 echo command failed >$command_status"
2848 [ -n "$($myPDSH $HOST cat $command_status)" ] && return 1 || true
2853 # print HOSTNAME for myPDSH="no_dsh"
2854 if [[ $myPDSH = no_dsh ]]; then
2855 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed -e "s/^/${HOSTNAME}: /"
2857 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")"
2860 $myPDSH $HOST "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" sh -c \"$@\")" | sed "s/^${HOST}: //"
2862 return ${PIPESTATUS[0]}
2866 do_node --verbose "$@"
2869 single_local_node () {
2870 [ "$1" = "$HOSTNAME" ]
2873 # Outputs environment variable assignments that should be passed to remote nodes
2877 local facets=$(get_facets)
2880 for var in ${!MODOPTS_*}; do
2881 value=${!var//\"/\\\"}
2882 echo -n " ${var}=\"$value\""
2885 for facet in ${facets//,/ }; do
2887 if [ -n "${!var}" ]; then
2888 echo -n " $var=${!var}"
2892 for var in MGSFSTYPE MDSFSTYPE OSTFSTYPE; do
2893 if [ -n "${!var}" ]; then
2894 echo -n " $var=${!var}"
2898 if [ -n "$FSTYPE" ]; then
2899 echo -n " FSTYPE=$FSTYPE"
2902 for var in LNETLND NETTYPE; do
2903 if [ -n "${!var}" ]; then
2904 echo -n " $var=${!var}"
2911 # do not stripe off hostname if verbose, bug 19215
2912 if [ x$1 = x--verbose ]; then
2920 if single_local_node $rnodes; then
2922 do_nodev $rnodes "$@"
2924 do_node $rnodes "$@"
2929 # This is part from do_node
2932 [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
2933 echo "cannot run remote command on $rnodes with $myPDSH" && return 128
2935 export FANOUT=$(get_node_count "${rnodes//,/ }")
2937 echo "CMD: $rnodes $@" >&2
2938 $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
2941 # do not replace anything from pdsh output if -N is used
2942 # -N Disable hostname: prefix on lines of output.
2943 if $verbose || [[ $myPDSH = *-N* ]]; then
2944 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")"
2946 $myPDSH $rnodes "(PATH=\$PATH:$RLUSTRE/utils:$RLUSTRE/tests:/sbin:/usr/sbin; cd $RPWD; LUSTRE=\"$RLUSTRE\" $(get_env_vars) sh -c \"$@\")" | sed -re "s/^[^:]*: //g"
2948 return ${PIPESTATUS[0]}
2954 local HOST=`facet_active_host $facet`
2955 [ -z $HOST ] && echo No host defined for facet ${facet} && exit 1
2959 # Function: do_facet_random_file $FACET $FILE $SIZE
2960 # Creates FILE with random content on the given FACET of given SIZE
2962 do_facet_random_file() {
2966 local cmd="dd if=/dev/urandom of='$fpath' bs=$fsize count=1"
2967 do_facet $facet "$cmd 2>/dev/null"
2970 do_facet_create_file() {
2974 local cmd="dd if=/dev/zero of='$fpath' bs=$fsize count=1"
2975 do_facet $facet "$cmd 2>/dev/null"
2979 do_nodes --verbose "$@"
2985 # make sure its not already running
2987 rm -f $TMP/${facet}active
2988 [[ $facet = mds1 ]] && combined_mgs_mds && rm -f $TMP/mgsactive
2989 do_facet ${facet} $MKFS $* || return ${PIPESTATUS[0]}
2991 if [[ $(facet_fstype $facet) == zfs ]]; then
2993 # After formatting a ZFS target, "cachefile=none" property will
2994 # be set on the ZFS storage pool so that the pool is not
2995 # automatically imported on system startup. And then the pool
2996 # will be exported so as to leave the importing and exporting
2997 # operations handled by mount_facet() and stop() separately.
2999 refresh_partition_table $facet $(facet_vdevice $facet)
3000 disable_zpool_cache $facet
3005 # Device formatted as ost
3008 local DEVNAME=OSTDEV$num
3010 local fstype=$(facet_fstype ost$num)
3014 #if $OSTDEVn isn't defined, default is $OSTDEVBASE + num
3015 eval DEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
3017 #try $OSTZFSDEVn - independent of vdev
3018 DEVNAME=OSTZFSDEV$num
3019 eval DEVPTR=${!DEVNAME:=${FSNAME}-ost${num}/ost${num}};;
3021 error "unknown fstype!";;
3027 # Physical device location of data
3033 local fstype=$(facet_fstype ost$num)
3037 # vdevs are not supported by ldiskfs
3040 #if $OSTDEVn isn't defined, default is $OSTDEVBASE{n}
3041 # Device formatted by zfs
3043 eval VDEVPTR=${!DEVNAME:=${OSTDEVBASE}${num}};;
3045 error "unknown fstype!";;
3051 # Logical device formatted for lustre
3054 local DEVNAME=MDSDEV$num
3056 local fstype=$(facet_fstype mds$num)
3060 #if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3061 eval DEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3063 # try $MDSZFSDEVn - independent of vdev
3064 DEVNAME=MDSZFSDEV$num
3065 eval DEVPTR=${!DEVNAME:=${FSNAME}-mdt${num}/mdt${num}};;
3067 error "unknown fstype!";;
3073 # Physical location of data
3077 local fstype=$(facet_fstype mds$num)
3081 # vdevs are not supported by ldiskfs
3084 # if $MDSDEVn isn't defined, default is $MDSDEVBASE{n}
3085 # Device formatted by ZFS
3086 local DEVNAME=MDSDEV$num
3087 eval VDEVPTR=${!DEVNAME:=${MDSDEVBASE}${num}};;
3089 error "unknown fstype!";;
3097 local fstype=$(facet_fstype mgs)
3101 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3102 ( [ -z "$MGSDEV" ] || [ $MGSDEV = $(mdsdevname 1) ] ); then
3103 DEVPTR=$(mdsdevname 1)
3108 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3109 ( [ -z "$MGSZFSDEV" ] &&
3110 [ -z "$MGSDEV" -o "$MGSDEV" = $(mdsvdevname 1) ] ); then
3111 DEVPTR=$(mdsdevname 1)
3113 DEVPTR=${MGSZFSDEV:-${FSNAME}-mgs/mgs}
3116 error "unknown fstype!";;
3125 local fstype=$(facet_fstype mgs)
3129 # vdevs are not supported by ldiskfs
3132 if [ $(facet_host mgs) = $(facet_host mds1) ] &&
3133 ( [ -z "$MGSDEV" ] &&
3134 [ -z "$MGSZFSDEV" -o "$MGSZFSDEV" = $(mdsdevname 1) ]); then
3135 VDEVPTR=$(mdsvdevname 1)
3136 elif [ -n "$MGSDEV" ]; then
3140 error "unknown fstype!";;
3148 [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
3150 local var=${facet}_MOUNT
3151 eval mntpt=${!var:-${MOUNT%/*}/$facet}
3158 local dev=$(facet_device $facet)
3159 local mnt=$(facet_mntpt $facet)
3162 if ! do_facet $facet test -b $dev; then
3165 do_facet $facet mount -t ldiskfs $opts $dev $mnt
3170 local dev=$(facet_device $facet)
3171 local mnt=$(facet_mntpt $facet)
3173 do_facet $facet umount -d $mnt
3177 echo -n "$1" | tr -c '[:alnum:]\n' '_'
3182 local ds=$(facet_device $facet)
3183 local mnt=$(facet_mntpt $facet)
3188 canmnt=$(do_facet $facet $ZFS get -H -o value canmount $ds)
3189 mntpt=$(do_facet $facet $ZFS get -H -o value mountpoint $ds)
3190 do_facet $facet $ZFS set canmount=noauto $ds
3192 # The "legacy" mount method is used here because "zfs unmount $mnt"
3193 # calls stat(2) on $mnt/../*, which may include $MOUNT. If certain
3194 # targets are not available at the time, the stat(2) on $MOUNT will
3197 do_facet $facet $ZFS set mountpoint=legacy $ds
3198 do_facet $facet mount -t zfs $ds $mnt
3199 eval export mz_$(var_name ${facet}_$ds)_canmount=$canmnt
3200 eval export mz_$(var_name ${facet}_$ds)_mountpoint=$mntpt
3205 local ds=$(facet_device $facet)
3206 local mnt=$(facet_mntpt $facet)
3207 local var_mntpt=mz_$(var_name ${facet}_$ds)_mountpoint
3208 local var_canmnt=mz_$(var_name ${facet}_$ds)_canmount
3209 local mntpt=${!var_mntpt}
3210 local canmnt=${!var_canmnt}
3214 do_facet $facet umount $mnt
3215 do_facet $facet $ZFS set mountpoint=$mntpt $ds
3216 do_facet $facet $ZFS set canmount=$canmnt $ds
3222 local fstype=$(facet_fstype $facet)
3224 mount_$fstype $facet
3229 local fstype=$(facet_fstype $facet)
3231 unmount_$fstype $facet
3238 # make sure we are using the primary server, so test-framework will
3239 # be able to clean up properly.
3240 activemds=`facet_active mds1`
3241 if [ $activemds != "mds1" ]; then
3245 local clients=$CLIENTS
3246 [ -z $clients ] && clients=$(hostname)
3248 zconf_umount_clients $clients $MOUNT "$*" || true
3249 [ -n "$MOUNT2" ] && zconf_umount_clients $clients $MOUNT2 "$*" || true
3251 [ "$CLIENTONLY" ] && return
3252 # The add fn does rm ${facet}active file, this would be enough
3253 # if we use do_facet <facet> only after the facet added, but
3254 # currently we use do_facet mds in local.sh
3255 for num in `seq $MDSCOUNT`; do
3257 rm -f ${TMP}/mds${num}active
3259 combined_mgs_mds && rm -f $TMP/mgsactive
3261 for num in `seq $OSTCOUNT`; do
3263 rm -f $TMP/ost${num}active
3266 if ! combined_mgs_mds ; then
3273 cleanup_echo_devs () {
3274 local devs=$($LCTL dl | grep echo | awk '{print $4}')
3276 for dev in $devs; do
3277 $LCTL --device $dev cleanup
3278 $LCTL --device $dev detach
3283 nfs_client_mode && return
3292 combined_mgs_mds () {
3293 [[ "$(mdsdevname 1)" = "$(mgsdevname)" ]] &&
3294 [[ "$(facet_host mds1)" = "$(facet_host mgs)" ]]
3298 echo -n "$1" | tr '[:upper:]' '[:lower:]'
3302 echo -n "$1" | tr '[:lower:]' '[:upper:]'
3308 local fsname=${3:-"$FSNAME"}
3309 local type=$(facet_type $facet)
3310 local index=$(facet_index $facet)
3311 local fstype=$(facet_fstype $facet)
3312 local host=$(facet_host $facet)
3317 if [ $type == MGS ] || ( [ $type == MDS ] &&
3318 [ "$dev" == $(mgsdevname) ] &&
3319 [ "$host" == "$(facet_host mgs)" ] ); then
3322 opts="--mgsnode=$MGSNID"
3325 if [ $type != MGS ]; then
3326 opts+=" --fsname=$fsname --$(lower ${type/MDS/MDT}) \
3330 var=${facet}failover_HOST
3331 if [ -n "${!var}" ] && [ ${!var} != $(facet_host $facet) ]; then
3332 opts+=" --failnode=$(h2$NETTYPE ${!var})"
3335 opts+=${TIMEOUT:+" --param=sys.timeout=$TIMEOUT"}
3336 opts+=${LDLM_TIMEOUT:+" --param=sys.ldlm_timeout=$LDLM_TIMEOUT"}
3338 if [ $type == MDS ]; then
3339 opts+=${SECLEVEL:+" --param=mdt.sec_level"}
3340 opts+=${MDSCAPA:+" --param-mdt.capa=$MDSCAPA"}
3341 opts+=${STRIPE_BYTES:+" --param=lov.stripesize=$STRIPE_BYTES"}
3342 opts+=${STRIPES_PER_OBJ:+" --param=lov.stripecount=$STRIPES_PER_OBJ"}
3343 opts+=${L_GETIDENTITY:+" --param=mdt.identity_upcall=$L_GETIDENTITY"}
3345 if [ $fstype == ldiskfs ]; then
3346 # Check for wide striping
3347 if [ $OSTCOUNT -gt 160 ]; then
3348 MDSJOURNALSIZE=${MDSJOURNALSIZE:-4096}
3349 fs_mkfs_opts+="-O large_xattr"
3352 fs_mkfs_opts+=${MDSJOURNALSIZE:+" -J size=$MDSJOURNALSIZE"}
3353 if [ ! -z $EJOURNAL ]; then
3354 fs_mkfs_opts+=${MDSJOURNALSIZE:+" device=$EJOURNAL"}
3356 fs_mkfs_opts+=${MDSISIZE:+" -i $MDSISIZE"}
3360 if [ $type == OST ]; then
3361 opts+=${SECLEVEL:+" --param=ost.sec_level"}
3362 opts+=${OSSCAPA:+" --param=ost.capa=$OSSCAPA"}
3364 if [ $fstype == ldiskfs ]; then
3365 fs_mkfs_opts+=${OSTJOURNALSIZE:+" -J size=$OSTJOURNALSIZE"}
3369 opts+=" --backfstype=$fstype"
3372 if [ -n "${!var}" ]; then
3373 opts+=" --device-size=${!var}"
3376 var=$(upper $fstype)_MKFS_OPTS
3377 fs_mkfs_opts+=${!var:+" ${!var}"}
3379 var=${type}_FS_MKFS_OPTS
3380 fs_mkfs_opts+=${!var:+" ${!var}"}
3382 if [ -n "${fs_mkfs_opts## }" ]; then
3383 opts+=" --mkfsoptions=\\\"${fs_mkfs_opts## }\\\""
3387 opts+=${!var:+" ${!var}"}
3392 check_ost_indices() {
3393 local index_count=${#OST_INDICES[@]}
3394 [[ $index_count -eq 0 || $OSTCOUNT -le $index_count ]] && return 0
3396 # OST count is greater than the index count in $OST_INDEX_LIST.
3397 # We need check whether there are duplicate indices.
3401 for i in $(seq $((index_count + 1)) $OSTCOUNT); do
3402 index=$(facet_index ost$i)
3403 for j in $(seq 0 $((index_count - 1))); do
3404 [[ $index -ne ${OST_INDICES[j]} ]] ||
3405 error "ost$i has the same index $index as ost$((j+1))"
3418 # We need ldiskfs here, may as well load them all
3420 [ "$CLIENTONLY" ] && return
3421 echo Formatting mgs, mds, osts
3422 if ! combined_mgs_mds ; then
3423 echo "Format mgs: $(mgsdevname)"
3424 add mgs $(mkfs_opts mgs $(mgsdevname)) --reformat \
3425 $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} ||
3429 for num in $(seq $MDSCOUNT); do
3430 echo "Format mds$num: $(mdsdevname $num)"
3431 add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
3432 --reformat $(mdsdevname $num) $(mdsvdevname $num) \
3433 ${quiet:+>/dev/null} || exit 10
3436 export OST_INDICES=($(hostlist_expand "$OST_INDEX_LIST"))
3438 for num in $(seq $OSTCOUNT); do
3439 echo "Format ost$num: $(ostdevname $num)"
3440 add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
3441 --reformat $(ostdevname $num) $(ostvdevname ${num}) \
3442 ${quiet:+>/dev/null} || exit 10
3447 grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
3451 grep " $1 " /proc/mounts && zconf_umount `hostname` $*
3455 # 0: success, the old identity set already.
3456 # 1: success, the old identity does not set.
3461 local j=`expr $num - 1`
3462 local MDT="`(do_facet mds$num lctl get_param -N mdt.*MDT*$j 2>/dev/null | cut -d"." -f2 2>/dev/null) || true`"
3464 if [ -z "$MDT" ]; then
3468 local old="`do_facet mds$num "lctl get_param -n mdt.$MDT.identity_upcall"`"
3471 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"$L_GETIDENTITY\""
3473 do_facet mds$num "lctl set_param -n mdt.$MDT.identity_upcall \"NONE\""
3476 do_facet mds$num "lctl set_param -n mdt/$MDT/identity_flush=-1"
3478 if [ $old = "NONE" ]; then
3487 zconf_umount `hostname` $1 || error "umount failed"
3488 zconf_mount `hostname` $1 || error "mount failed"
3496 rm -f $TMP/${facet}active
3497 do_facet ${facet} "$TUNEFS --quiet --writeconf $dev" || return 1
3502 local mdt_count=${1:-$MDSCOUNT}
3503 local ost_count=${2:-$OSTCOUNT}
3506 for num in $(seq $mdt_count); do
3507 DEVNAME=$(mdsdevname $num)
3508 writeconf_facet mds$num $DEVNAME || rc=$?
3511 for num in $(seq $ost_count); do
3512 DEVNAME=$(ostdevname $num)
3513 writeconf_facet ost$num $DEVNAME || rc=$?
3519 nfs_client_mode && return
3521 sanity_mount_check ||
3522 error "environments are insane!"
3526 if [ -z "$CLIENTONLY" ]; then
3527 echo Setup mgs, mdt, osts
3528 echo $WRITECONF | grep -q "writeconf" && \
3530 if ! combined_mgs_mds ; then
3531 start mgs $(mgsdevname) $MGS_MOUNT_OPTS
3534 for num in `seq $MDSCOUNT`; do
3535 DEVNAME=$(mdsdevname $num)
3536 start mds$num $DEVNAME $MDS_MOUNT_OPTS
3538 # We started mds, now we should set failover variables properly.
3539 # Set mds${num}failover_HOST if it is not set (the default failnode).
3540 local varname=mds${num}failover_HOST
3541 if [ -z "${!varname}" ]; then
3542 eval mds${num}failover_HOST=$(facet_host mds$num)
3545 if [ $IDENTITY_UPCALL != "default" ]; then
3546 switch_identity $num $IDENTITY_UPCALL
3549 for num in `seq $OSTCOUNT`; do
3550 DEVNAME=$(ostdevname $num)
3551 start ost$num $DEVNAME $OST_MOUNT_OPTS
3553 # We started ost$num, now we should set ost${num}failover variable properly.
3554 # Set ost${num}failover_HOST if it is not set (the default failnode).
3555 varname=ost${num}failover_HOST
3556 if [ -z "${!varname}" ]; then
3557 eval ost${num}failover_HOST=$(facet_host ost${num})
3565 # wait a while to allow sptlrpc configuration be propogated to targets,
3566 # only needed when mounting new target devices.
3571 [ "$DAEMONFILE" ] && $LCTL debug_daemon start $DAEMONFILE $DAEMONSIZE
3573 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT
3576 if [ "$MOUNT_2" ]; then
3577 mount_client $MOUNT2
3578 [ -n "$CLIENTS" ] && zconf_mount_clients $CLIENTS $MOUNT2
3583 # by remounting mdt before ost, initial connect from mdt to ost might
3584 # timeout because ost is not ready yet. wait some time to its fully
3585 # recovery. initial obd_connect timeout is 5s; in GSS case it's preceeded
3586 # by a context negotiation rpc with $TIMEOUT.
3587 # FIXME better by monitoring import status.
3590 sleep $((TIMEOUT + 5))
3596 mounted_lustre_filesystems() {
3597 awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
3600 init_facet_vars () {
3601 [ "$CLIENTONLY" ] && return 0
3608 eval export ${facet}_dev=${device}
3609 eval export ${facet}_opt=\"$@\"
3611 local dev=${facet}_dev
3613 # We need to loop for the label
3614 # in case its not initialized yet.
3615 for wait_time in {0,1,3,5,10}; do
3617 if [ $wait_time -gt 0 ]; then
3618 echo "${!dev} not yet initialized,"\
3619 "waiting ${wait_time} seconds."
3623 local label=$(devicelabel ${facet} ${!dev})
3625 # Check to make sure the label does
3626 # not include ffff at the end of the label.
3627 # This indicates it has not been initialized yet.
3629 if [[ $label =~ [f|F]{4}$ ]]; then
3630 # label is not initialized, unset the result
3631 # and either try again or fail
3638 [ -z "$label" ] && echo no label for ${!dev} && exit 1
3640 eval export ${facet}_svc=${label}
3642 local varname=${facet}failover_HOST
3643 if [ -z "${!varname}" ]; then
3644 eval export $varname=$(facet_host $facet)
3647 varname=${facet}_HOST
3648 if [ -z "${!varname}" ]; then
3649 eval export $varname=$(facet_host $facet)
3652 # ${facet}failover_dev is set in cfg file
3653 varname=${facet}failover_dev
3654 if [ -n "${!varname}" ] ; then
3655 eval export ${facet}failover_dev=${!varname}
3657 eval export ${facet}failover_dev=$device
3660 # get mount point of already mounted device
3661 # is facet_dev is already mounted then use the real
3662 # mount point of this facet; otherwise use $(facet_mntpt $facet)
3663 # i.e. ${facet}_MOUNT if specified by user or default
3664 local mntpt=$(do_facet ${facet} cat /proc/mounts | \
3665 awk '"'${!dev}'" == $1 && $3 == "lustre" { print $2 }')
3666 if [ -z $mntpt ]; then
3667 mntpt=$(facet_mntpt $facet)
3669 eval export ${facet}_MOUNT=$mntpt
3672 init_facets_vars () {
3675 if ! remote_mds_nodsh; then
3676 for num in $(seq $MDSCOUNT); do
3677 DEVNAME=`mdsdevname $num`
3678 init_facet_vars mds$num $DEVNAME $MDS_MOUNT_OPTS
3682 combined_mgs_mds || init_facet_vars mgs $(mgsdevname) $MGS_MOUNT_OPTS
3684 if ! remote_ost_nodsh; then
3685 for num in $(seq $OSTCOUNT); do
3686 DEVNAME=$(ostdevname $num)
3687 init_facet_vars ost$num $DEVNAME $OST_MOUNT_OPTS
3692 osc_ensure_active () {
3697 while [ $period -lt $timeout ]; do
3698 count=$(do_facet $facet "lctl dl | grep ' IN osc ' 2>/dev/null | wc -l")
3699 if [ $count -eq 0 ]; then
3703 echo "There are $count OST are inactive, wait $period seconds, and try again"
3705 period=$((period+3))
3708 [ $period -lt $timeout ] || log "$count OST are inactive after $timeout seconds, give up"
3711 set_conf_param_and_check() {
3715 local ORIG=$(do_facet $myfacet "$TEST")
3716 if [ $# -gt 3 ]; then
3722 echo "Setting $PARAM from $ORIG to $FINAL"
3723 do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" ||
3724 error "conf_param $PARAM failed"
3726 wait_update $(facet_host $myfacet) "$TEST" "$FINAL" ||
3727 error "check $PARAM failed!"
3730 init_param_vars () {
3732 TIMEOUT=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3734 log "Using TIMEOUT=$TIMEOUT"
3736 osc_ensure_active $SINGLEMDS $TIMEOUT
3737 osc_ensure_active client $TIMEOUT
3739 if [ -n "$(lctl get_param -n mdc.*.connect_flags|grep jobstats)" ]; then
3740 local current_jobid_var=$($LCTL get_param -n jobid_var)
3742 if [ $JOBID_VAR = "existing" ]; then
3743 echo "keeping jobstats as $current_jobid_var"
3744 elif [ $current_jobid_var != $JOBID_VAR ]; then
3745 echo "seting jobstats to $JOBID_VAR"
3747 set_conf_param_and_check client \
3748 "$LCTL get_param -n jobid_var" \
3749 "$FSNAME.sys.jobid_var" $JOBID_VAR
3752 echo "jobstats not supported by server"
3755 if [ $QUOTA_AUTO -ne 0 ]; then
3756 if [ "$ENABLE_QUOTA" ]; then
3757 echo "enable quota as required"
3758 setup_quota $MOUNT || return 2
3760 echo "disable quota as required"
3761 # $LFS quotaoff -ug $MOUNT > /dev/null 2>&1
3767 nfs_client_mode () {
3768 if [ "$NFSCLIENT" ]; then
3769 echo "NFSCLIENT mode: setup, cleanup, check config skipped"
3770 local clients=$CLIENTS
3771 [ -z $clients ] && clients=$(hostname)
3773 # FIXME: remove hostname when 19215 fixed
3774 do_nodes $clients "echo \\\$(hostname); grep ' '$MOUNT' ' /proc/mounts"
3775 declare -a nfsexport=(`grep ' '$MOUNT' ' /proc/mounts | awk '{print $1}' | awk -F: '{print $1 " " $2}'`)
3776 if [[ ${#nfsexport[@]} -eq 0 ]]; then
3777 error_exit NFSCLIENT=$NFSCLIENT mode, but no NFS export found!
3779 do_nodes ${nfsexport[0]} "echo \\\$(hostname); df -T ${nfsexport[1]}"
3785 check_config_client () {
3788 local mounted=$(mount | grep " $mntpt ")
3789 if [ "$CLIENTONLY" ]; then
3791 # CLIENTONLY should not depend on *_HOST settings
3792 local mgc=$($LCTL device_list | awk '/MGC/ {print $4}')
3793 # in theory someone could create a new,
3794 # client-only config file that assumed lustre was already
3795 # configured and didn't set the MGSNID. If MGSNID is not set,
3796 # then we should use the mgs nid currently being used
3797 # as the default value. bug 18021
3798 [[ x$MGSNID = x ]] &&
3801 if [[ x$mgc != xMGC$MGSNID ]]; then
3802 if [ "$mgs_HOST" ]; then
3803 local mgc_ip=$(ping -q -c1 -w1 $mgs_HOST | grep PING | awk '{print $3}' | sed -e "s/(//g" -e "s/)//g")
3804 # [[ x$mgc = xMGC$mgc_ip@$NETTYPE ]] ||
3805 # error_exit "MGSNID=$MGSNID, mounted: $mounted, MGC : $mgc"
3811 local myMGS_host=$mgs_HOST
3812 if [ "$NETTYPE" = "ptl" ]; then
3813 myMGS_host=$(h2ptl $mgs_HOST | sed -e s/@ptl//)
3816 echo Checking config lustre mounted on $mntpt
3817 local mgshost=$(mount | grep " $mntpt " | awk -F@ '{print $1}')
3818 mgshost=$(echo $mgshost | awk -F: '{print $1}')
3820 # if [ "$mgshost" != "$myMGS_host" ]; then
3821 # log "Bad config file: lustre is mounted with mgs $mgshost, but mgs_HOST=$mgs_HOST, NETTYPE=$NETTYPE
3822 # Please use correct config or set mds_HOST correctly!"
3827 check_config_clients () {
3828 local clients=${CLIENTS:-$HOSTNAME}
3831 nfs_client_mode && return
3833 do_rpc_nodes "$clients" check_config_client $mntpt
3835 sanity_mount_check || error "environments are insane!"
3839 local mdstimeout=$(do_facet $SINGLEMDS "lctl get_param -n timeout")
3840 local cltimeout=$(lctl get_param -n timeout)
3841 if [ $mdstimeout -ne $TIMEOUT ] || [ $mdstimeout -ne $cltimeout ]; then
3842 error "timeouts are wrong! mds: $mdstimeout, client: $cltimeout, TIMEOUT=$TIMEOUT"
3849 [ -z $mntpt ] && return 1
3850 local mounted=$(mounted_lustre_filesystems)
3852 echo $mounted' ' | grep -w -q $mntpt' '
3856 [ $(find $1 -maxdepth 1 -print | wc -l) = 1 ] && return 0
3860 # empty lustre filesystem may have empty directories lost+found and .lustre
3862 # exclude .lustre & lost+found
3863 [ $(find $1 -maxdepth 1 -name lost+found -o -name .lustre -prune -o \
3864 -print | wc -l) = 1 ] || return 1
3865 [ ! -d $1/lost+found ] || is_empty_dir $1/lost+found || return 1
3866 if [ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.4.0) ]; then
3867 # exclude .lustre/fid (LU-2780)
3868 [ $(find $1/.lustre -maxdepth 1 -name fid -prune -o \
3869 -print | wc -l) = 1 ] || return 1
3871 [ ! -d $1/.lustre ] || is_empty_dir $1/.lustre || return 1
3876 check_and_setup_lustre() {
3877 nfs_client_mode && return
3879 local MOUNTED=$(mounted_lustre_filesystems)
3883 # both MOUNT and MOUNT2 are not mounted
3884 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
3885 [ "$REFORMAT" ] && formatall
3886 # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
3888 is_mounted $MOUNT || error "NAME=$NAME not mounted"
3889 export I_MOUNTED=yes
3893 elif is_mounted $MOUNT2; then
3895 # MOUNT2 is mounted, while MOUNT_2 is not set
3896 if ! [ "$MOUNT_2" ]; then
3897 cleanup_mount $MOUNT2
3898 export I_UMOUNTED2=yes
3901 # MOUNT2 is mounted, MOUNT_2 is set
3903 # FIXME: what to do if check_config failed?
3905 # 1) remote client has mounted other Lustre fs ?
3906 # 2) it has insane env ?
3907 # let's try umount MOUNT2 on all clients and mount it again:
3908 if ! check_config_clients $MOUNT2; then
3909 cleanup_mount $MOUNT2
3910 restore_mount $MOUNT2
3911 export I_MOUNTED2=yes
3916 # MOUNT is mounted MOUNT2 is not mounted
3917 elif [ "$MOUNT_2" ]; then
3918 restore_mount $MOUNT2
3919 export I_MOUNTED2=yes
3923 # FIXME: what to do if check_config failed?
3925 # 1) remote client has mounted other Lustre fs?
3926 # 2) lustre is mounted on remote_clients atall ?
3927 check_config_clients $MOUNT
3931 set_default_debug_nodes $(comma_list $(nodes_list))
3934 if [ $(lower $OSD_TRACK_DECLARES_LBUG) == 'yes' ] ; then
3936 [ "$(facet_fstype ost1)" = "ldiskfs" ] &&
3937 facets="$(get_facets OST)"
3938 [ "$(facet_fstype mds1)" = "ldiskfs" ] &&
3939 facets="$facets,$(get_facets MDS)"
3940 [ "$(facet_fstype mgs)" = "ldiskfs" ] &&
3941 facets="$facets,mgs"
3942 local nodes="$(facets_hosts ${facets})"
3943 if [ -n "$nodes" ] ; then
3944 do_nodes $nodes "$LCTL set_param \
3945 osd-ldiskfs.track_declares_assert=1 || true"
3954 #Enable remote MDT create for testing
3955 for num in $(seq $MDSCOUNT); do
3957 lctl set_param -n mdt.${FSNAME}*.enable_remote_dir=1 \
3961 if [ "$ONLY" == "setup" ]; then
3967 local clients=${CLIENTS:-$HOSTNAME}
3970 zconf_mount_clients $clients $mntpt
3974 local clients=${CLIENTS:-$HOSTNAME}
3977 zconf_umount_clients $clients $mntpt
3980 cleanup_and_setup_lustre() {
3981 if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
3982 lctl set_param debug=0 || true
3984 if [ "$ONLY" == "cleanup" ]; then
3988 check_and_setup_lustre
3991 # Get all of the server target devices from a given server node and type.
3998 if [ "$type" == ost ]; then
3999 devs=$(get_osd_param $node "" mntdev)
4001 devs=$(do_node $node $LCTL get_param -n osd-*.$FSNAME-M*.mntdev)
4003 for dev in $devs; do
4005 *loop*) do_node $node "losetup $dev" | \
4006 sed -e "s/.*(//" -e "s/).*//" ;;
4012 # Get all of the server target devices.
4017 # Master MDS parameters used by lfsck
4018 MDTNODE=$(facet_active_host $SINGLEMDS)
4019 MDTDEV=$(echo $(get_mnt_devs $MDTNODE mdt) | awk '{print $1}')
4023 for node in $(mdts_nodes); do
4024 MDTDEVS[i]=$(get_mnt_devs $node mdt)
4030 for node in $(osts_nodes); do
4031 OSTDEVS[i]=$(get_mnt_devs $node ost)
4036 # Run e2fsck on MDT or OST device.
4041 local cmd="$E2FSCK -d -v -t -t -f $extra_opts $target_dev"
4042 local log=$TMP/e2fsck.log
4046 do_node $node $cmd 2>&1 | tee $log
4048 if [ -n "$(grep "DNE mode isn't supported" $log)" ]; then
4050 if [ $MDSCOUNT -gt 1 ]; then
4051 skip "DNE mode isn't supported!"
4055 error "It's not DNE mode."
4060 [ $rc -le $FSCK_MAX_ERR ] ||
4061 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4067 # Run resize2fs on MDT or OST device.
4076 do_facet $facet "$RESIZE2FS $opts $device $size"
4079 # verify a directory is shared among nodes.
4080 check_shared_dir() {
4082 local list=${2:-$(comma_list $(nodes_list))}
4084 [ -z "$dir" ] && return 1
4085 do_rpc_nodes "$list" check_logdir $dir
4086 check_write_access $dir "$list" || return 1
4090 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
4097 [[ $(lustre_version_code $SINGLEMDS) -ne $(version_code 2.2.0) ]] ||
4098 { skip "Lustre 2.2.0 lacks the patch for LU-1255"; exit 0; }
4100 check_shared_dir $SHARED_DIRECTORY ||
4101 error "$SHARED_DIRECTORY isn't a shared directory"
4103 export MDSDB=$SHARED_DIRECTORY/mdsdb
4104 export OSTDB=$SHARED_DIRECTORY/ostdb
4106 # DNE is not supported, so when running e2fsck on a DNE filesystem,
4107 # we only pass master MDS parameters.
4108 run_e2fsck $MDTNODE $MDTDEV "-n --mdsdb $MDSDB"
4113 for node in $(osts_nodes); do
4114 for dev in ${OSTDEVS[i]}; do
4115 run_e2fsck $node $dev "-n --mdsdb $MDSDB --ostdb $OSTDB-$ostidx"
4116 OSTDB_LIST="$OSTDB_LIST $OSTDB-$ostidx"
4117 ostidx=$((ostidx + 1))
4123 # Run lfsck on server node if lfsck can't be found on client (LU-2571)
4124 run_lfsck_remote() {
4125 local cmd="$LFSCK_BIN -c -l --mdsdb $MDSDB --ostdb $OSTDB_LIST $MOUNT"
4130 #Check if lustre is already mounted
4131 do_rpc_nodes $client is_mounted $MOUNT || mounted=false
4133 zconf_mount $client $MOUNT ||
4134 error "failed to mount Lustre on $client"
4138 do_node $client $cmd || rc=$?
4139 #Umount if necessary
4141 zconf_umount $client $MOUNT ||
4142 error "failed to unmount Lustre on $client"
4145 [ $rc -le $FSCK_MAX_ERR ] ||
4146 error "$cmd returned $rc, should be <= $FSCK_MAX_ERR"
4147 echo "lfsck finished with rc=$rc"
4153 local facets="client $SINGLEMDS"
4159 for facet in $facets; do
4160 node=$(facet_active_host $facet)
4161 if check_progs_installed $node $LFSCK_BIN; then
4166 ! $found && error "None of \"$facets\" supports lfsck"
4168 run_lfsck_remote $node || rc=$?
4170 rm -rvf $MDSDB* $OSTDB* || true
4174 dump_file_contents() {
4180 if [ -z "$nodes" -o -z "$dir" -o -z "$logname" ]; then
4181 error_noexit false \
4182 "Invalid parameters for dump_file_contents()"
4185 for node in ${nodes}; do
4186 do_node $node "for i in \\\$(find $dir -type f); do
4187 echo ====\\\${i}=======================;
4189 done" >> ${logname}.${node}.log
4193 dump_command_output() {
4199 if [ -z "$nodes" -o -z "$cmd" -o -z "$logname" ]; then
4200 error_noexit false \
4201 "Invalid parameters for dump_command_output()"
4205 for node in ${nodes}; do
4206 do_node $node "echo ====${cmd}=======================;
4207 $cmd" >> ${logname}.${node}.log
4214 # dump file contents from /proc/spl in case of zfs test
4215 if [ "$(facet_fstype ost1)" = "zfs" ]; then
4216 dump_file_contents "$(osts_nodes)" "/proc/spl" "${logname}"
4217 dump_command_output \
4218 "$(osts_nodes)" "zpool events -v" "${logname}"
4221 if [ "$(facet_fstype $SINGLEMDS)" = "zfs" ]; then
4222 dump_file_contents "$(mdts_nodes)" "/proc/spl" "${logname}"
4223 dump_command_output \
4224 "$(mdts_nodes)" "zpool events -v" "${logname}"
4228 check_and_cleanup_lustre() {
4229 if [ "$LFSCK_ALWAYS" = "yes" -a "$TESTSUITE" != "lfsck" ]; then
4235 if is_mounted $MOUNT; then
4236 [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
4237 error "remove sub-test dirs failed"
4238 [ "$ENABLE_QUOTA" ] && restore_quota || true
4241 if [ "$I_UMOUNTED2" = "yes" ]; then
4242 restore_mount $MOUNT2 || error "restore $MOUNT2 failed"
4245 if [ "$I_MOUNTED2" = "yes" ]; then
4246 cleanup_mount $MOUNT2
4249 if [ "$I_MOUNTED" = "yes" ]; then
4250 cleanupall -f || error "cleanup failed"
4258 wait_for_function () {
4261 # suppress fn both stderr and stdout
4262 if [ "$1" = "--quiet" ]; then
4264 quiet=" > /dev/null 2>&1"
4276 eval $fn $quiet && return 0
4278 wait=$((wait + sleep))
4279 [ $wait -lt $max ] || return 1
4280 echo waiting $fn, $((max - wait)) secs left ...
4290 echo `date +"%H:%M:%S (%s)"` waiting for $host network $max secs ...
4291 if ! wait_for_function --quiet "ping -c 1 -w 3 $host" $max $sleep ; then
4292 echo "Network not available!"
4296 echo `date +"%H:%M:%S (%s)"` network interface is UP
4304 # Convert a space-delimited list to a comma-delimited list. If the input is
4305 # only whitespace, ensure the output is empty (i.e. "") so [ -n $list ] works
4307 # echo is used to convert newlines to spaces, since it doesn't
4308 # introduce a trailing space as using "tr '\n' ' '" does
4309 echo $(tr -s " " "\n" <<< $* | sort -b -u) | tr ' ' ','
4315 echo $list | grep -qw $item
4318 # list, excluded are the comma separated lists
4319 exclude_items_from_list () {
4325 for item in ${excluded//,/ }; do
4326 list=$(echo " $list " | sed -re "s/\s+$item\s+/ /g")
4328 echo $(comma_list $list)
4331 # list, expand are the comma separated lists
4333 local list=${1//,/ }
4334 local expand=${2//,/ }
4337 expanded=$(for i in $list $expand; do echo $i; done | sort -u)
4338 echo $(comma_list $expanded)
4341 testslist_filter () {
4342 local script=$LUSTRE/tests/${TESTSUITE}.sh
4344 [ -f $script ] || return 0
4346 local start_at=$START_AT
4347 local stop_at=$STOP_AT
4349 local var=${TESTSUITE//-/_}_START_AT
4350 [ x"${!var}" != x ] && start_at=${!var}
4351 var=${TESTSUITE//-/_}_STOP_AT
4352 [ x"${!var}" != x ] && stop_at=${!var}
4354 sed -n 's/^test_\([^ (]*\).*/\1/p' $script | \
4355 awk ' BEGIN { if ("'${start_at:-0}'" != 0) flag = 1 }
4356 /^'${start_at}'$/ {flag = 0}
4357 {if (flag == 1) print $0}
4358 /^'${stop_at}'$/ { flag = 1 }'
4362 (cd `dirname $1`; echo $PWD/`basename $1`)
4366 local types=${1:-"OST MDS MGS"}
4370 for entry in $types; do
4371 local name=$(echo $entry | tr "[:upper:]" "[:lower:]")
4372 local type=$(echo $entry | tr "[:lower:]" "[:upper:]")
4375 MGS ) list="$list $name";;
4376 MDS|OST|AGT ) local count=${type}COUNT
4377 for ((i=1; i<=${!count}; i++)) do
4378 list="$list ${name}$i"
4380 * ) error "Invalid facet type"
4384 echo $(comma_list $list)
4387 ##################################
4388 # Adaptive Timeouts funcs
4391 # only check mds, we assume at_max is the same on all nodes
4392 local at_max=$(do_facet $SINGLEMDS "lctl get_param -n at_max")
4393 if [ $at_max -eq 0 ]; then
4404 # suppose that all ost-s have the same $at value set
4405 [ $facet != "ost" ] || facet=ost1
4407 do_facet $facet "lctl get_param -n $at"
4425 if [ $facet == "ost" ]; then
4426 facet=$(get_facets OST)
4427 elif [ $facet == "mds" ]; then
4428 facet=$(get_facets MDS)
4430 hosts=$(expand_list $hosts $(facets_hosts $facet))
4433 do_nodes $hosts lctl set_param at_max=$at_max
4436 ##################################
4440 # OBD_FAIL_MDS_ALL_REQUEST_NET
4442 do_facet $SINGLEMDS lctl set_param fail_loc=0x123
4443 do_facet client "$1" || RC=$?
4444 do_facet $SINGLEMDS lctl set_param fail_loc=0
4449 # OBD_FAIL_MDS_ALL_REPLY_NET
4451 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x122
4453 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4457 drop_reint_reply() {
4458 # OBD_FAIL_MDS_REINT_NET_REP
4460 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x119
4462 do_facet $SINGLEMDS $LCTL set_param fail_loc=0
4466 drop_update_reply() {
4467 # OBD_FAIL_UPDATE_OBJ_NET_REP
4471 do_facet mds${index} lctl set_param fail_loc=0x1701
4472 do_facet client "$@" || RC=$?
4473 do_facet mds${index} lctl set_param fail_loc=0
4478 #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
4481 local timeout=${2:-0}
4482 # default is (obd_timeout / 4) if unspecified
4483 echo "timeout is $timeout/$2"
4484 do_facet ost1 lctl set_param fail_val=$timeout fail_loc=0x80000214
4485 do_facet client "$1" || RC=$?
4486 do_facet client "sync"
4487 do_facet ost1 lctl set_param fail_loc=0
4491 drop_ldlm_cancel() {
4492 #define OBD_FAIL_LDLM_CANCEL_NET 0x304
4494 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4495 do_nodes $list lctl set_param fail_loc=0x304
4497 do_facet client "$@" || RC=$?
4499 do_nodes $list lctl set_param fail_loc=0
4503 drop_bl_callback_once() {
4505 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
4506 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
4507 do_facet client lctl set_param fail_loc=0x80000305
4508 do_facet client "$@" || rc=$?
4509 do_facet client lctl set_param fail_loc=0
4510 do_facet client lctl set_param fail_val=0
4511 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
4515 drop_bl_callback() {
4517 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=0
4518 #define OBD_FAIL_LDLM_BL_CALLBACK_NET 0x305
4519 do_facet client lctl set_param fail_loc=0x305
4520 do_facet client "$@" || rc=$?
4521 do_facet client lctl set_param fail_loc=0
4522 do_facet client lctl set_param fail_val=0
4523 do_facet client lctl set_param ldlm.namespaces.*.early_lock_cancel=1
4528 #define OBD_FAIL_LDLM_REPLY 0x30c
4530 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4531 do_nodes $list lctl set_param fail_loc=0x30c
4533 do_facet client "$@" || RC=$?
4535 do_nodes $list lctl set_param fail_loc=0
4539 drop_ldlm_reply_once() {
4540 #define OBD_FAIL_LDLM_REPLY 0x30c
4542 local list=$(comma_list $(mdts_nodes) $(osts_nodes))
4543 do_nodes $list lctl set_param fail_loc=0x8000030c
4545 do_facet client "$@" || RC=$?
4547 do_nodes $list lctl set_param fail_loc=0
4555 echo "clearing fail_loc on $facet"
4556 do_facet $facet "lctl set_param fail_loc=0 2>/dev/null || true"
4559 set_nodes_failloc () {
4560 do_nodes $(comma_list $1) lctl set_param fail_val=0 fail_loc=$2
4563 cancel_lru_locks() {
4564 $LCTL mark "cancel_lru_locks $1 start"
4566 if [ $1 != "MGC" ]; then
4567 for d in $(lctl get_param -N ldlm.namespaces.*.lru_size |
4569 $LCTL set_param -n $d=clear
4571 $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 |
4575 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lru_size \
4581 /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lock_unused_count \
4583 if [ $(cat $d) != 0 ]; then
4584 echo "ldlm.namespaces.$(echo "$d" |
4585 cut -f 7 -d'/').lock_unused_count=$(cat $d)"
4590 $LCTL mark "cancel_lru_locks $1 stop"
4595 NR_CPU=$(grep -c "processor" /proc/cpuinfo)
4596 DEFAULT_LRU_SIZE=$((100 * NR_CPU))
4597 echo "$DEFAULT_LRU_SIZE"
4602 lctl set_param ldlm.namespaces.*$1*.lru_size=0
4605 lru_resize_disable()
4607 lctl set_param ldlm.namespaces.*$1*.lru_size $(default_lru_size)
4613 [ -z "$(mount | grep "$MOUNT.*flock" | grep -v noflock)" ] && RC=1
4619 for FILE in `lctl get_param -N "llite.*.dump_page_cache"`; do
4620 if [ `lctl get_param -n $FILE | wc -l` -gt 1 ]; then
4621 echo there is still data in page cache $FILE ?
4622 lctl get_param -n $FILE
4630 DEBUGSAVE="$(lctl get_param -n debug)"
4634 [ -n "$DEBUGSAVE" ] && \
4635 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=\\\"${DEBUGSAVE}\\\";"
4640 DEBUG_SIZE_SAVED="$(lctl get_param -n debug_mb)"
4643 debug_size_restore() {
4644 [ -n "$DEBUG_SIZE_SAVED" ] && \
4645 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE_SAVED"
4649 start_full_debug_logging() {
4654 local DEBUG_SIZE=150
4656 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug_mb=$DEBUG_SIZE"
4657 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$FULLDEBUG;"
4660 stop_full_debug_logging() {
4665 # prints bash call stack
4666 print_stack_trace() {
4668 for (( i=1; i < ${#BASH_LINENO[*]} ; i++ )) ; do
4669 local s=${BASH_SOURCE[$i]}
4670 local l=${BASH_LINENO[$i-1]}
4671 local f=${FUNCNAME[$i]}
4672 echo " = $s:$l:$f()"
4676 ##################################
4678 ##################################
4681 local TYPE=${TYPE:-"FAIL"}
4684 # do not dump logs if $1=false
4685 if [ "x$1" = "xfalse" ]; then
4691 log " ${TESTSUITE} ${TESTNAME}: @@@@@@ ${TYPE}: $@ "
4692 print_stack_trace >&2
4695 # We need to dump the logs on all nodes
4697 gather_logs $(comma_list $(nodes_list))
4701 [ "$TESTSUITELOG" ] &&
4702 echo "$TESTSUITE: $TYPE: $TESTNAME $@" >> $TESTSUITELOG
4703 if [ -z "$*" ]; then
4704 echo "error() without useful message, please fix" > $LOGDIR/err
4706 if [[ `echo $TYPE | grep ^IGNORE` ]]; then
4707 echo "$@" > $LOGDIR/ignore
4709 echo "$@" > $LOGDIR/err
4716 local log=$TESTSUITELOG
4718 [ -f "$log" ] && grep -q FAIL $log && status=1
4731 # use only if we are ignoring failures for this test, bugno required.
4732 # (like ALWAYS_EXCEPT, but run the test and ignore the results.)
4733 # e.g. error_ignore bz5494 "your message" or
4734 # error_ignore LU-5494 "your message"
4736 local TYPE="IGNORE ($1)"
4741 error_and_remount() {
4743 remount_client $MOUNT
4748 $FAIL_ON_SKIP_ENV && error false $@ || skip $@
4753 log " SKIP: $TESTSUITE $TESTNAME $@"
4755 if [[ -n "$ALWAYS_SKIPPED" ]]; then
4756 skip_logged $TESTNAME "$@"
4759 echo "$@" > $LOGDIR/skip
4762 [[ -n "$TESTSUITELOG" ]] &&
4763 echo "$TESTSUITE: SKIP: $TESTNAME $@" >> $TESTSUITELOG || true
4766 build_test_filter() {
4767 EXCEPT="$EXCEPT $(testslist_filter)"
4770 if [[ $O = [0-9]*-[0-9]* ]]; then
4771 for num in $(seq $(echo $O | tr '-' ' ')); do
4779 [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
4780 log "excepting tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
4781 [ "$EXCEPT_SLOW" ] && \
4782 log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
4783 for E in $EXCEPT; do
4784 eval EXCEPT_${E}=true
4786 for E in $ALWAYS_EXCEPT; do
4787 eval EXCEPT_ALWAYS_${E}=true
4789 for E in $EXCEPT_SLOW; do
4790 eval EXCEPT_SLOW_${E}=true
4792 for G in $GRANT_CHECK_LIST; do
4793 eval GCHECK_ONLY_${G}=true
4798 if [[ $1 = [a-z]* ]]; then
4805 # print a newline if the last test was skipped
4806 export LAST_SKIPPED=
4807 export ALWAYS_SKIPPED=
4809 # Main entry into test-framework. This is called with the name and
4810 # description of a test. The name is used to find the function to run
4811 # the test using "test_$name".
4813 # This supports a variety of methods of specifying specific test to
4814 # run or not run. These need to be documented...
4819 export base=$(basetest $1)
4820 if [ -n "$ONLY" ]; then
4822 if [ ${!testname}x != x ]; then
4823 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4824 run_one_logged $1 "$2"
4828 if [ ${!testname}x != x ]; then
4829 [ -n "$LAST_SKIPPED" ] && echo "" && LAST_SKIPPED=
4830 run_one_logged $1 "$2"
4840 if [ ${!testname}x != x ]; then
4841 TESTNAME=test_$1 skip "skipping excluded test $1"
4844 testname=EXCEPT_$base
4845 if [ ${!testname}x != x ]; then
4846 TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
4849 testname=EXCEPT_ALWAYS_$1
4850 if [ ${!testname}x != x ]; then
4851 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1"
4854 testname=EXCEPT_ALWAYS_$base
4855 if [ ${!testname}x != x ]; then
4856 TESTNAME=test_$1 skip "skipping ALWAYS excluded test $1 (base $base)"
4859 testname=EXCEPT_SLOW_$1
4860 if [ ${!testname}x != x ]; then
4861 TESTNAME=test_$1 skip "skipping SLOW test $1"
4864 testname=EXCEPT_SLOW_$base
4865 if [ ${!testname}x != x ]; then
4866 TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
4872 run_one_logged $1 "$2"
4879 module_loaded lnet || load_modules
4891 do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
4896 strace -o $TMP/$1.strace -ttt $*
4898 log "FINISHED: $*: rc $RC"
4905 banner test complete, duration $duration sec
4906 [ -f "$TESTSUITELOG" ] && egrep .FAIL $TESTSUITELOG || true
4907 echo duration $duration >>$TESTSUITELOG
4911 # Set TEST_STATUS here. It will be used for logging the result.
4914 if [[ -f $LOGDIR/err ]]; then
4916 elif [[ -f $LOGDIR/skip ]]; then
4919 echo "$TEST_STATUS $@" 2>&1 | tee -a $TESTSUITELOG
4923 local FFREE=$(do_node $SINGLEMDS \
4924 lctl get_param -n osd*.*MDT*.filesfree | calc_sum)
4925 local FTOTAL=$(do_node $SINGLEMDS \
4926 lctl get_param -n osd*.*MDT*.filestotal | calc_sum)
4928 [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
4932 echo -n "Resetting fail_loc on all nodes..."
4933 do_nodes $(comma_list $(nodes_list)) "lctl set_param -n fail_loc=0 \
4934 fail_val=0 2>/dev/null || true"
4940 # Log a message (on all nodes) padded with "=" before and after.
4941 # Also appends a timestamp and prepends the testsuite name.
4944 EQUALS="===================================================================================================="
4946 msg="== ${TESTSUITE} $*"
4948 [[ $last != "=" && $last != " " ]] && msg="$msg "
4949 msg=$(printf '%s%.*s' "$msg" $((${#EQUALS} - ${#msg})) $EQUALS )
4950 # always include at least == after the message
4951 log "$msg== $(date +"%H:%M:%S (%s)")"
4955 # Run a single test function and cleanup after it.
4957 # This function should be run in a subshell so the test func can
4958 # exit() without stopping the whole script.
4963 export tfile=f${testnum}.${TESTSUITE}
4964 export tdir=d${testnum}.${TESTSUITE}
4965 export TESTNAME=test_$testnum
4966 local SAVE_UMASK=`umask`
4969 banner "test $testnum: $message"
4970 test_${testnum} || error "test_$testnum failed with $?"
4973 check_grant ${testnum} || error "check_grant $testnum failed with $?"
4974 check_catastrophe || error "LBUG/LASSERT detected"
4975 if [ "$PARALLEL" != "yes" ]; then
4976 ps auxww | grep -v grep | grep -q multiop &&
4977 error "multiop still running"
4987 # Wrapper around run_one to ensure:
4988 # - test runs in subshell
4989 # - output of test is saved to separate log file for error reporting
4990 # - test result is saved to data file
4993 local BEFORE=$(date +%s)
4995 local name=${TESTSUITE}.test_${1}.test_log.$(hostname -s).log
4996 local test_log=$LOGDIR/$name
4997 local zfs_log_name=${TESTSUITE}.test_${1}.zfs_log
4998 local zfs_debug_log=$LOGDIR/$zfs_log_name
5000 rm -rf $LOGDIR/ignore
5002 local SAVE_UMASK=$(umask)
5006 log_sub_test_begin test_${1}
5007 (run_one $1 "$2") 2>&1 | tee -i $test_log
5008 local RC=${PIPESTATUS[0]}
5010 [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] &&
5011 echo "test_$1 returned $RC" | tee $LOGDIR/err
5013 duration=$(($(date +%s) - $BEFORE))
5014 pass "$1" "(${duration}s)"
5016 if [[ -f $LOGDIR/err ]]; then
5017 TEST_ERROR=$(cat $LOGDIR/err)
5018 elif [[ -f $LOGDIR/ignore ]]; then
5019 TEST_ERROR=$(cat $LOGDIR/ignore)
5020 elif [[ -f $LOGDIR/skip ]]; then
5021 TEST_ERROR=$(cat $LOGDIR/skip)
5023 log_sub_test_end $TEST_STATUS $duration "$RC" "$TEST_ERROR"
5025 if [[ "$TEST_STATUS" != "SKIP" ]] && [[ -f $TF_SKIP ]]; then
5029 if [ -f $LOGDIR/err ]; then
5030 log_zfs_info "$zfs_debug_log"
5031 $FAIL_ON_ERROR && exit $RC
5040 # Print information of skipped tests to result.yml
5043 log_sub_test_begin $1
5045 log_sub_test_end "SKIP" "0" "0" "$@"
5049 (cd $(dirname $1); echo $PWD/$(basename $1))
5054 export base=$(basetest $1)
5055 [ "$CHECK_GRANT" == "no" ] && return 0
5057 testname=GCHECK_ONLY_${base}
5058 [ ${!testname}x == x ] && return 0
5060 echo -n "checking grant......"
5062 local clients=$CLIENTS
5063 [ -z "$clients" ] && clients=$(hostname)
5065 # sync all the data and make sure no pending data on server
5066 do_nodes $clients sync
5069 client_grant=$(do_nodes $clients \
5070 "$LCTL get_param -n osc.${FSNAME}-*.cur_*grant_bytes" |
5071 awk '{ total += $1 } END { printf("%0.0f", total) }')
5074 server_grant=$(do_nodes $(comma_list $(osts_nodes)) \
5075 "$LCTL get_param -n obdfilter.${FSNAME}-OST*.tot_granted" |
5076 awk '{ total += $1 } END { printf("%0.0f", total) }')
5078 # check whether client grant == server grant
5079 if [[ $client_grant -ne $server_grant ]]; then
5080 echo "failed: client:${client_grant} server: ${server_grant}."
5081 do_nodes $(comma_list $(osts_nodes)) \
5082 "$LCTL get_param obdfilter.${FSNAME}-OST*.tot*"
5083 do_nodes $clients "$LCTL get_param osc.${FSNAME}-*.cur_*_bytes"
5086 echo "pass: client:${client_grant} server: ${server_grant}"
5090 ########################
5096 ost=`echo $1 | awk -F_ '{print $3}'`
5097 if [ -z $ost ]; then
5098 ost=`echo $1 | sed 's/-osc.*//'`
5103 ostuuid_from_index()
5105 $LFS osts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5108 ostname_from_index() {
5109 local uuid=$(ostuuid_from_index $1)
5113 index_from_ostuuid()
5115 $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
5118 mdtuuid_from_index()
5120 $LFS mdts $2 | sed -ne "/^$1: /s/.* \(.*\) .*$/\1/p"
5124 # Return unique identifier for given hostname
5127 echo $host_name | md5sum | cut -d' ' -f1
5131 # Returns list of ip addresses for each interface
5133 ip addr | awk '/inet\ / {print $2}' | awk -F\/ '{print $1}'
5138 # Cache address list to avoid mutiple execution of local_addr_list
5139 LOCAL_ADDR_LIST=${LOCAL_ADDR_LIST:-$(local_addr_list)}
5141 for i in $LOCAL_ADDR_LIST ; do
5142 [[ "$i" == "$addr" ]] && return 0
5149 local is_local="IS_LOCAL_$(host_id $host_name)"
5150 if [ -z "${!is_local-}" ] ; then
5152 local host_ip=$($LUSTRE/tests/resolveip $host_name)
5153 is_local_addr "$host_ip" && eval $is_local=1
5155 [[ "${!is_local}" == "1" ]]
5160 local_node $node && return 1
5167 for node in $(mdts_nodes); do
5168 remote_node $node && return 0
5175 [ "$CLIENTONLY" ] && return 0 || true
5176 remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
5181 remote_mds_nodsh && echo "SKIP: $TESTSUITE: remote MDS with nodsh" && \
5182 MSKIPPED=1 && return 1
5189 for node in $(osts_nodes) ; do
5190 remote_node $node && return 0
5197 [ "$CLIENTONLY" ] && return 0 || true
5198 remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5203 remote_ost_nodsh && echo "SKIP: $TESTSUITE: remote OST with nodsh" && \
5204 OSKIPPED=1 && return 1
5211 MGS=$(facet_host mgs)
5212 remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
5217 remote_mds_nodsh || remote_ost_nodsh || \
5218 $(single_local_node $(comma_list $(nodes_list)))
5222 remote_ost && remote_mds
5225 # Get the active nodes for facets.
5233 for facet in ${facets//,/ }; do
5234 nodes="$nodes $(facet_active_host $facet)"
5237 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5241 # Get all of the active MDS nodes.
5243 echo -n $(facets_nodes $(get_facets MDS))
5246 # Get all of the active OSS nodes.
5248 echo -n $(facets_nodes $(get_facets OST))
5251 # Get all of the active AGT (HSM agent) nodes.
5253 echo -n $(facets_nodes $(get_facets AGT))
5256 # Get all of the client nodes and active server nodes.
5258 local nodes=$HOSTNAME
5262 # CLIENTS (if specified) contains the local client
5263 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5265 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5266 nodes="$nodes $(facets_nodes $(get_facets))"
5269 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5273 # Get all of the remote client nodes and remote active server nodes.
5274 remote_nodes_list () {
5275 echo -n $(nodes_list) | sed -re "s/\<$HOSTNAME\>//g"
5278 # Get all of the MDS nodes, including active and passive nodes.
5286 for i in $(seq $MDSCOUNT); do
5288 failover_host=mds${i}failover_HOST
5289 nodes="$nodes ${!host} ${!failover_host}"
5292 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5296 # Get all of the OSS nodes, including active and passive nodes.
5304 for i in $(seq $OSTCOUNT); do
5306 failover_host=ost${i}failover_HOST
5307 nodes="$nodes ${!host} ${!failover_host}"
5310 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5314 # Get all of the server nodes, including active and passive nodes.
5315 all_server_nodes () {
5320 nodes="$mgs_HOST $mgsfailover_HOST $(all_mdts_nodes) $(all_osts_nodes)"
5322 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5326 # Get all of the client and server nodes, including active and passive nodes.
5328 local nodes=$HOSTNAME
5332 # CLIENTS (if specified) contains the local client
5333 [ -n "$CLIENTS" ] && nodes=${CLIENTS//,/ }
5335 if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
5336 nodes="$nodes $(all_server_nodes)"
5339 nodes_sort=$(for i in $nodes; do echo $i; done | sort -u)
5343 init_clients_lists () {
5344 # Sanity check: exclude the local client from RCLIENTS
5345 local clients=$(hostlist_expand "$RCLIENTS")
5346 local rclients=$(exclude_items_from_list "$clients" $HOSTNAME)
5348 # Sanity check: exclude the dup entries
5349 RCLIENTS=$(for i in ${rclients//,/ }; do echo $i; done | sort -u)
5351 clients="$SINGLECLIENT $HOSTNAME $RCLIENTS"
5353 # Sanity check: exclude the dup entries from CLIENTS
5354 # for those configs which has SINGLCLIENT set to local client
5355 clients=$(for i in $clients; do echo $i; done | sort -u)
5357 CLIENTS=$(comma_list $clients)
5358 local -a remoteclients=($RCLIENTS)
5359 for ((i=0; $i<${#remoteclients[@]}; i++)); do
5360 varname=CLIENT$((i + 2))
5361 eval $varname=${remoteclients[i]}
5364 CLIENTCOUNT=$((${#remoteclients[@]} + 1))
5367 get_random_entry () {
5370 rnodes=${rnodes//,/ }
5372 local -a nodes=($rnodes)
5373 local num=${#nodes[@]}
5374 local i=$((RANDOM * num * 2 / 65536))
5380 [ "$CLIENTONLY" ] || [ "$CLIENTMODSONLY" = yes ]
5385 lctl get_param version | grep -q patchless
5389 [ "$(lustre_version_code client)" = "$(lustre_version_code $SINGLEMDS)" -a \
5390 "$(lustre_version_code client)" = "$(lustre_version_code ost1)" ]
5395 echo $nodes | wc -w || true
5399 local nodes=$(osts_nodes)
5400 local osscount=$(get_node_count "$nodes")
5401 [ ! "$OSTCOUNT" = "$osscount" ]
5405 local nodes=$(mdts_nodes)
5406 local mdtcount=$(get_node_count "$nodes")
5407 [ ! "$MDSCOUNT" = "$mdtcount" ]
5410 generate_machine_file() {
5411 local nodes=${1//,/ }
5412 local machinefile=$2
5414 for node in $nodes; do
5415 echo $node >>$machinefile || \
5416 { echo "can not generate machinefile $machinefile" && return 1; }
5421 local file=$1/stripe
5424 $LFS getstripe -v $file || error "getstripe $file failed"
5428 setstripe_nfsserver () {
5431 local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
5432 { print $1 }' /proc/mounts | cut -f 1 -d : | head -n1)
5434 [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
5436 do_nodev $nfsserver lfs setstripe "$@"
5439 # Check and add a test group.
5445 local gid=$(getent group $group_name | cut -d: -f3)
5446 if [[ -n "$gid" ]]; then
5447 [[ "$gid" -eq "$group_id" ]] || {
5448 error_noexit "inconsistent group ID:" \
5449 "new: $group_id, old: $gid"
5453 groupadd -g $group_id $group_name
5460 # Check and add a test user.
5473 local uid=$(getent passwd $user_name | cut -d: -f3)
5474 if [[ -n "$uid" ]]; then
5475 if [[ "$uid" -eq "$user_id" ]]; then
5476 local dir=$(getent passwd $user_name | cut -d: -f6)
5477 if [[ "$dir" != "$home" ]]; then
5479 usermod -d $home $user_name
5483 error_noexit "inconsistent user ID:" \
5484 "new: $user_id, old: $uid"
5489 useradd -M -u $user_id -d $home -g $group_name $opts $user_name
5496 check_runas_id_ret() {
5498 local myRUNAS_UID=$1
5499 local myRUNAS_GID=$2
5502 if [ -z "$myRUNAS" ]; then
5503 error_exit "myRUNAS command must be specified for check_runas_id"
5506 $myRUNAS krb5_login.sh || \
5507 error "Failed to refresh Kerberos V5 TGT for UID $myRUNAS_ID."
5509 mkdir $DIR/d0_runas_test
5511 chown $myRUNAS_UID:$myRUNAS_GID $DIR/d0_runas_test
5512 $myRUNAS touch $DIR/d0_runas_test/f$$ || myRC=$?
5513 rm -rf $DIR/d0_runas_test
5518 local myRUNAS_UID=$1
5519 local myRUNAS_GID=$2
5522 check_runas_id_ret $myRUNAS_UID $myRUNAS_GID $myRUNAS || \
5523 error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_UID.
5524 Please set RUNAS_ID to some UID which exists on MDS and client or
5525 add user $myRUNAS_UID:$myRUNAS_GID on these nodes."
5528 # obtain the UID/GID for MPI_USER
5532 MPI_USER_UID=$(do_facet client "getent passwd $mpi_user | cut -d: -f3;
5533 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the UID for $mpi_user"
5535 MPI_USER_GID=$(do_facet client "getent passwd $mpi_user | cut -d: -f4;
5536 exit \\\${PIPESTATUS[0]}") || error_exit "failed to get the GID for $mpi_user"
5539 # obtain and cache Kerberos ticket-granting ticket
5540 refresh_krb5_tgt() {
5541 local myRUNAS_UID=$1
5542 local myRUNAS_GID=$2
5545 if [ -z "$myRUNAS" ]; then
5546 error_exit "myRUNAS command must be specified for refresh_krb5_tgt"
5549 CLIENTS=${CLIENTS:-$HOSTNAME}
5550 do_nodes $CLIENTS "set -x
5551 if ! $myRUNAS krb5_login.sh; then
5552 echo "Failed to refresh Krb5 TGT for UID/GID $myRUNAS_UID/$myRUNAS_GID."
5557 # Run multiop in the background, but wait for it to print
5558 # "PAUSING" to its stdout before returning from this function.
5559 multiop_bg_pause() {
5560 MULTIOP_PROG=${MULTIOP_PROG:-$MULTIOP}
5564 TMPPIPE=/tmp/multiop_open_wait_pipe.$$
5567 echo "$MULTIOP_PROG $FILE v$ARGS"
5568 $MULTIOP_PROG $FILE v$ARGS > $TMPPIPE &
5570 echo "TMPPIPE=${TMPPIPE}"
5571 read -t 60 multiop_output < $TMPPIPE
5572 if [ $? -ne 0 ]; then
5577 if [ "$multiop_output" != "PAUSING" ]; then
5578 echo "Incorrect multiop output: $multiop_output"
5593 [ ${PIPESTATUS[0]} -eq 0 ] || rc=1
5599 inodes_available () {
5600 local IFree=$($LFS df -i $MOUNT | grep ^$FSNAME | awk '{ print $4 }' |
5601 sort -un | head -n1) || return 1
5605 mdsrate_inodes_available () {
5606 local min_inodes=$(inodes_available)
5607 echo $((min_inodes * 99 / 100))
5610 # reset llite stat counters
5611 clear_llite_stats(){
5612 lctl set_param -n llite.*.stats 0
5615 # sum llite stat items
5616 calc_llite_stats() {
5617 local res=$(lctl get_param -n llite.*.stats |
5618 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5622 # reset osc stat counters
5624 lctl set_param -n osc.*.osc_stats 0
5627 # sum osc stat items
5629 local res=$(lctl get_param -n osc.*.osc_stats |
5630 awk '/^'"$1"'/ {sum += $2} END { printf("%0.0f", sum) }')
5635 awk '{sum += $1} END { printf("%0.0f", sum) }'
5638 calc_osc_kbytes () {
5639 df $MOUNT > /dev/null
5640 $LCTL get_param -n osc.*[oO][sS][cC][-_][0-9a-f]*.$1 | calc_sum
5643 # save_lustre_params(comma separated facet list, parameter_mask)
5644 # generate a stream of formatted strings (<facet> <param name>=<param value>)
5645 save_lustre_params() {
5651 for facet in ${facets//,/ }; do
5652 node=$(facet_active_host $facet)
5653 [[ *\ $node\ * = " $nodes " ]] && continue
5654 nodes="$nodes $node"
5656 do_node $node "$LCTL get_param $2 |
5657 while read s; do echo $facet \\\$s; done"
5661 # restore lustre parameters from input stream, produces by save_lustre_params
5662 restore_lustre_params() {
5667 while IFS=" =" read facet name val; do
5668 do_facet $facet "$LCTL set_param -n $name $val"
5672 check_catastrophe() {
5673 local nodes=${1:-$(comma_list $(nodes_list))}
5675 do_nodes $nodes "rc=0;
5676 val=\\\$($LCTL get_param -n catastrophe 2>&1);
5677 if [[ \\\$? -eq 0 && \\\$val -ne 0 ]]; then
5678 echo \\\$(hostname -s): \\\$val;
5684 mdsrate_cleanup () {
5686 mpi_run ${MACHINEFILE_OPTION} $2 -np $1 ${MDSRATE} --unlink \
5687 --nfiles $3 --dir $4 --filefmt $5 $6
5692 delayed_recovery_enabled () {
5693 local var=${SINGLEMDS}_svc
5694 do_facet $SINGLEMDS lctl get_param -n mdd.${!var}.stale_export_age > /dev/null 2>&1
5697 ########################
5699 convert_facet2label() {
5702 if [ x$facet = xost ]; then
5706 local varsvc=${facet}_svc
5708 if [ -n ${!varsvc} ]; then
5711 error "No lablel for $facet!"
5715 get_clientosc_proc_path() {
5719 get_lustre_version () {
5720 local facet=${1:-"$SINGLEMDS"}
5721 do_facet $facet $LCTL get_param -n version | awk '/^lustre:/ {print $2}'
5724 lustre_version_code() {
5725 local facet=${1:-"$SINGLEMDS"}
5726 version_code $(get_lustre_version $1)
5729 # If the 2.0 MDS was mounted on 1.8 device, then the OSC and LOV names
5730 # used by MDT would not be changed.
5731 # mdt lov: fsname-mdtlov
5732 # mdt osc: fsname-OSTXXXX-osc
5733 mds_on_old_device() {
5734 local mds=${1:-"$SINGLEMDS"}
5736 if [ $(lustre_version_code $mds) -gt $(version_code 1.9.0) ]; then
5737 do_facet $mds "lctl list_param osc.$FSNAME-OST*-osc \
5738 > /dev/null 2>&1" && return 0
5743 get_mdtosc_proc_path() {
5745 local ost_label=${2:-"*OST*"}
5747 [ "$mds_facet" = "mds" ] && mds_facet=$SINGLEMDS
5748 local mdt_label=$(convert_facet2label $mds_facet)
5749 local mdt_index=$(echo $mdt_label | sed -e 's/^.*-//')
5751 if [ $(lustre_version_code $mds_facet) -le $(version_code 1.8.0) ] ||
5752 mds_on_old_device $mds_facet; then
5753 echo "${ost_label}-osc"
5755 echo "${ost_label}-osc-${mdt_index}"
5759 get_osc_import_name() {
5762 local label=$(convert_facet2label $ost)
5764 if [ "${facet:0:3}" = "mds" ]; then
5765 get_mdtosc_proc_path $facet $label
5769 get_clientosc_proc_path $label
5773 _wait_import_state () {
5776 local maxtime=${3:-$(max_recovery_time)}
5780 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5781 while [ "${CONN_STATE}" != "${expected}" ]; do
5782 if [ "${expected}" == "DISCONN" ]; then
5783 # for disconn we can check after proc entry is removed
5784 [ "x${CONN_STATE}" == "x" ] && return 0
5785 # with AT enabled, we can have connect request timeout near of
5786 # reconnect timeout and test can't see real disconnect
5787 [ "${CONN_STATE}" == "CONNECTING" ] && return 0
5789 [ $i -ge $maxtime ] && \
5790 error "can't put import for $CONN_PROC into ${expected} state after $i sec, have ${CONN_STATE}" && \
5793 # Add uniq for multi-mount case
5794 CONN_STATE=$($LCTL get_param -n $CONN_PROC 2>/dev/null | cut -f2 | uniq)
5798 log "$CONN_PROC in ${CONN_STATE} state after $i sec"
5802 wait_import_state() {
5805 local maxtime=${3:-$(max_recovery_time)}
5808 for param in ${params//,/ }; do
5809 _wait_import_state $state $param $maxtime || return
5813 wait_import_state_mount() {
5814 if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
5818 wait_import_state $*
5821 # One client request could be timed out because server was not ready
5822 # when request was sent by client.
5823 # The request timeout calculation details :
5825 # /* We give the server rq_timeout secs to process the req, and
5826 # add the network latency for our local timeout. */
5827 # request->rq_deadline = request->rq_sent + request->rq_timeout +
5828 # ptlrpc_at_get_net_latency(request) ;
5830 # ptlrpc_connect_import ()
5831 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5834 # -> at_init(&at->iat_net_latency, 0, 0) -> iat_net_latency=0
5835 # ptlrpc_at_get_net_latency(request) ->
5836 # at_get (max (iat_net_latency=0, at_min)) = at_min
5839 # request->rq_timeout + ptlrpc_at_get_net_latency(request) =
5840 # INITIAL_CONNECT_TIMEOUT + at_min
5842 # We will use obd_timeout instead of INITIAL_CONNECT_TIMEOUT
5843 # because we can not get this value in runtime,
5844 # the value depends on configure options, and it is not stored in /proc.
5846 # #define CONNECTION_SWITCH_MIN 5U
5847 # #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN,obd_timeout/20)
5849 request_timeout () {
5852 # request->rq_timeout = INITIAL_CONNECT_TIMEOUT
5853 local init_connect_timeout=$TIMEOUT
5854 [[ $init_connect_timeout -ge 5 ]] || init_connect_timeout=5
5856 local at_min=$(at_get $facet at_min)
5858 echo $(( init_connect_timeout + at_min ))
5861 _wait_osc_import_state() {
5865 local ost=$(get_osc_import_name $facet $ost_facet)
5866 local param="osc.${ost}.ost_server_uuid"
5870 # 1. wait the deadline of client 1st request (it could be skipped)
5871 # 2. wait the deadline of client 2nd request
5872 local maxtime=$(( 2 * $(request_timeout $facet)))
5874 if [[ $facet == client* ]]; then
5875 # During setup time, the osc might not be setup, it need wait
5876 # until list_param can return valid value. And also if there
5877 # are mulitple osc entries we should list all of them before
5879 params=$($LCTL list_param $param 2>/dev/null || true)
5880 while [ -z "$params" ]; do
5881 if [ $i -ge $maxtime ]; then
5882 echo "can't get $param in $maxtime secs"
5887 params=$($LCTL list_param $param 2>/dev/null || true)
5890 if ! do_rpc_nodes "$(facet_active_host $facet)" \
5891 wait_import_state $expected "$params" $maxtime; then
5892 error "import is not in ${expected} state"
5899 wait_osc_import_state() {
5905 if [[ $facet = mds ]]; then
5906 for num in $(seq $MDSCOUNT); do
5907 _wait_osc_import_state mds$num "$ost_facet" "$expected"
5910 _wait_osc_import_state "$facet" "$ost_facet" "$expected"
5914 get_clientmdc_proc_path() {
5922 [ -z "$list" ] && return 0
5924 # Add paths to lustre tests for 32 and 64 bit systems.
5925 local LIBPATH="/usr/lib/lustre/tests:/usr/lib64/lustre/tests:"
5926 local TESTPATH="$RLUSTRE/tests:"
5927 local RPATH="PATH=${TESTPATH}${LIBPATH}${PATH}:/sbin:/bin:/usr/sbin:"
5928 do_nodesv $list "${RPATH} NAME=${NAME} sh rpc.sh $@ "
5931 wait_clients_import_state () {
5938 if [ "$FAILURE_MODE" = HARD ]; then
5939 facets=$(facets_on_host $(facet_active_host $facet))
5942 for facet in ${facets//,/ }; do
5943 local label=$(convert_facet2label $facet)
5946 ost* ) proc_path="osc.$(get_clientosc_proc_path $label).ost_server_uuid" ;;
5947 mds* ) proc_path="mdc.$(get_clientmdc_proc_path $label).mds_server_uuid" ;;
5948 *) error "unknown facet!" ;;
5950 local params=$(expand_list $params $proc_path)
5953 if ! do_rpc_nodes "$list" wait_import_state_mount $expected $params; then
5954 error "import is not in ${expected} state"
5964 AVAILA=($(do_nodes $(comma_list $(osts_nodes)) \
5965 $LCTL get_param obdfilter.*.kbytesavail))
5966 GRANTA=($(do_nodes $(comma_list $(osts_nodes)) \
5967 $LCTL get_param -n obdfilter.*.tot_granted))
5968 TOTALA=($(do_nodes $(comma_list $(osts_nodes)) \
5969 $LCTL get_param -n obdfilter.*.kbytestotal))
5970 for ((i=0; i<${#AVAILA[@]}; i++)); do
5971 local -a AVAIL1=(${AVAILA[$i]//=/ })
5972 local -a TOTAL=(${TOTALA[$i]//=/ })
5973 GRANT=$((${GRANTA[$i]}/1024))
5974 # allow 1% of total space in bavail because of delayed
5975 # allocation with ZFS which might release some free space after
5976 # txg commit. For small devices, we set a mininum of 8MB
5977 local LIMIT=$((${TOTAL} / 100 + 8000))
5978 echo -n $(echo ${AVAIL1[0]} | cut -d"." -f2) avl=${AVAIL1[1]} \
5979 grnt=$GRANT diff=$((AVAIL1[1] - GRANT)) limit=${LIMIT}
5980 [ $((AVAIL1[1] - GRANT)) -lt $LIMIT ] && OSCFULL=0 && \
5981 echo " FULL" || echo
5987 do_facet mgs lctl pool_list $1
5991 local fsname=${1%%.*}
5992 local poolname=${1##$fsname.}
5994 do_facet mgs lctl pool_new $1
5996 # get param should return err unless pool is created
5997 [[ $RC -ne 0 ]] && return $RC
5999 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
6000 2>/dev/null || echo foo" "" || RC=1
6001 if [[ $RC -eq 0 ]]; then
6004 error "pool_new failed $1"
6009 add_pool_to_list () {
6010 local fsname=${1%%.*}
6011 local poolname=${1##$fsname.}
6013 local listvar=${fsname}_CREATED_POOLS
6014 eval export ${listvar}=$(expand_list ${!listvar} $poolname)
6017 remove_pool_from_list () {
6018 local fsname=${1%%.*}
6019 local poolname=${1##$fsname.}
6021 local listvar=${fsname}_CREATED_POOLS
6022 eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
6025 destroy_pool_int() {
6027 local OSTS=$(do_facet $SINGLEMDS lctl pool_list $1 | \
6028 awk '$1 !~ /^Pool:/ {print $1}')
6029 for ost in $OSTS; do
6030 do_facet mgs lctl pool_remove $1 $ost
6032 do_facet mgs lctl pool_destroy $1
6035 # <fsname>.<poolname> or <poolname>
6037 local fsname=${1%%.*}
6038 local poolname=${1##$fsname.}
6040 [[ x$fsname = x$poolname ]] && fsname=$FSNAME
6044 pool_list $fsname.$poolname || return $?
6046 destroy_pool_int $fsname.$poolname
6048 [[ $RC -ne 0 ]] && return $RC
6050 wait_update $HOSTNAME "lctl get_param -n lov.$fsname-*.pools.$poolname \
6051 2>/dev/null || echo foo" "foo" || RC=1
6053 if [[ $RC -eq 0 ]]; then
6054 remove_pool_from_list $fsname.$poolname
6056 error "destroy pool failed $1"
6062 local fsname=${1:-$FSNAME}
6064 local listvar=${fsname}_CREATED_POOLS
6068 [ x${!listvar} = x ] && return 0
6070 echo destroy the created pools: ${!listvar}
6071 for poolname in ${!listvar//,/ }; do
6072 destroy_pool $fsname.$poolname
6077 local fsname=${1:-$FSNAME}
6079 destroy_pools $fsname
6085 local ts=$(date +%s)
6088 if [[ ! -f "$YAML_LOG" ]]; then
6089 # init_logging is not performed before gather_logs,
6090 # so the $LOGDIR needs to be checked here
6091 check_shared_dir $LOGDIR && touch $LOGDIR/shared
6094 [ -f $LOGDIR/shared ] && docp=false
6096 # dump lustre logs, dmesg
6098 prefix="$TESTLOG_PREFIX.$TESTNAME"
6100 echo "Dumping lctl log to ${prefix}.*.${suffix}"
6102 if [ "$CLIENTONLY" -o "$PDSH" == "no_dsh" ]; then
6103 echo "Dumping logs only on local client."
6104 $LCTL dk > ${prefix}.debug_log.$(hostname -s).${suffix}
6105 dmesg > ${prefix}.dmesg.$(hostname -s).${suffix}
6110 "$LCTL dk > ${prefix}.debug_log.\\\$(hostname -s).${suffix};
6111 dmesg > ${prefix}.dmesg.\\\$(hostname -s).${suffix}"
6112 if [ ! -f $LOGDIR/shared ]; then
6113 do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
6126 for i in $(seq 0 $num_mntpts); do
6127 cmd="ls -laf ${mntpt_root}$i/$dir"
6133 for pid in $pids; do
6140 # check_and_start_recovery_timer()
6141 # service_time = at_est2timeout(service_time);
6142 # service_time += 2 * INITIAL_CONNECT_TIMEOUT;
6143 # service_time += 2 * (CONNECTION_SWITCH_MAX + CONNECTION_SWITCH_INC);
6145 #define INITIAL_CONNECT_TIMEOUT max(CONNECTION_SWITCH_MIN, obd_timeout/20)
6146 #define CONNECTION_SWITCH_MAX min(50, max(CONNECTION_SWITCH_MIN, obd_timeout))
6147 #define CONNECTION_SWITCH_MIN 5
6148 #define CONNECTION_SWITCH_INC 5
6149 max_recovery_time() {
6150 local init_connect_timeout=$((TIMEOUT / 20))
6151 ((init_connect_timeout >= 5)) || init_connect_timeout=5
6153 local service_time=$(($(at_max_get client) * 9 / 4 + 5))
6154 service_time=$((service_time + 2 * (init_connect_timeout + 50 + 5)))
6156 echo -n $service_time
6159 get_clients_mount_count () {
6160 local clients=${CLIENTS:-`hostname`}
6162 # we need to take into account the clients mounts and
6163 # exclude mds/ost mounts if any;
6164 do_nodes $clients cat /proc/mounts | grep lustre | grep $MOUNT | wc -l
6168 PROC_CLI="srpc_info"
6176 if [ $M -lt $N ]; then
6180 while [ $N -lt $M ]; do
6190 calc_connection_cnt() {
6193 # MDT->MDT = 2 * C(M, 2)
6197 comb_m2=$(combination $MDSCOUNT 2)
6199 local num_clients=$(get_clients_mount_count)
6201 local cnt_mdt2mdt=$((comb_m2 * 2))
6202 local cnt_mdt2ost=$((MDSCOUNT * OSTCOUNT))
6203 local cnt_cli2ost=$((num_clients * OSTCOUNT))
6204 local cnt_cli2mdt=$((num_clients * MDSCOUNT))
6205 local cnt_all2ost=$((cnt_mdt2ost + cnt_cli2ost))
6206 local cnt_all2mdt=$((cnt_mdt2mdt + cnt_cli2mdt))
6207 local cnt_all2all=$((cnt_mdt2ost + cnt_mdt2mdt + cnt_cli2ost + cnt_cli2mdt))
6221 local cmd="$tgt.srpc.flavor"
6223 if [ $net == "any" ]; then
6228 if [ $dir != "any" ]; then
6233 log "Setting sptlrpc rule: $cmd"
6234 do_facet mgs "$LCTL conf_param $cmd"
6243 rpc_flvr=`echo $flavor | awk -F - '{ print $1 }'`
6244 bulkspec=`echo $flavor | awk -F - '{ print $2 }'`
6246 count=`echo "$output" | grep "rpc flavor" | grep $rpc_flvr | wc -l`
6248 if [ "x$bulkspec" != "x" ]; then
6249 algs=`echo $bulkspec | awk -F : '{ print $2 }'`
6251 if [ "x$algs" != "x" ]; then
6252 bulk_count=`echo "$output" | grep "bulk flavor" | grep $algs | wc -l`
6254 bulk=`echo $bulkspec | awk -F : '{ print $1 }'`
6255 if [ $bulk == "bulkn" ]; then
6256 bulk_count=`echo "$output" | grep "bulk flavor" \
6257 | grep "null/null" | wc -l`
6258 elif [ $bulk == "bulki" ]; then
6259 bulk_count=`echo "$output" | grep "bulk flavor" \
6260 | grep "/null" | grep -v "null/" | wc -l`
6262 bulk_count=`echo "$output" | grep "bulk flavor" \
6263 | grep -v "/null" | grep -v "null/" | wc -l`
6267 [ $bulk_count -lt $count ] && count=$bulk_count
6278 local clients=${CLIENTS:-`hostname`}
6280 for c in ${clients//,/ }; do
6281 output=`do_node $c lctl get_param -n mdc.*-MDT*-mdc-*.$PROC_CLI 2>/dev/null`
6282 tmpcnt=`count_flvr "$output" $flavor`
6283 cnt=$((cnt + tmpcnt))
6293 local clients=${CLIENTS:-`hostname`}
6295 for c in ${clients//,/ }; do
6296 output=`do_node $c lctl get_param -n osc.*OST*-osc-[^M][^D][^T]*.$PROC_CLI 2>/dev/null`
6297 tmpcnt=`count_flvr "$output" $flavor`
6298 cnt=$((cnt + tmpcnt))
6308 if [ $MDSCOUNT -le 1 ]; then
6313 for num in `seq $MDSCOUNT`; do
6314 output=`do_facet mds$num lctl get_param -n mdc.*-MDT*-mdc[0-9]*.$PROC_CLI 2>/dev/null`
6315 tmpcnt=`count_flvr "$output" $flavor`
6316 cnt=$((cnt + tmpcnt))
6327 for num in `seq $MDSCOUNT`; do
6328 mdtosc=$(get_mdtosc_proc_path mds$num)
6329 mdtosc=${mdtosc/-MDT*/-MDT\*}
6330 output=$(do_facet mds$num lctl get_param -n \
6331 osc.$mdtosc.$PROC_CLI 2>/dev/null)
6332 tmpcnt=`count_flvr "$output" $flavor`
6333 cnt=$((cnt + tmpcnt))
6342 output=`do_facet client lctl get_param -n mgc.*.$PROC_CLI 2>/dev/null`
6343 count_flvr "$output" $flavor
6348 local dir=$1 # from to
6349 local flavor=$2 # flavor expected
6352 if [ $dir == "cli2mdt" ]; then
6353 res=`flvr_cnt_cli2mdt $flavor`
6354 elif [ $dir == "cli2ost" ]; then
6355 res=`flvr_cnt_cli2ost $flavor`
6356 elif [ $dir == "mdt2mdt" ]; then
6357 res=`flvr_cnt_mdt2mdt $flavor`
6358 elif [ $dir == "mdt2ost" ]; then
6359 res=`flvr_cnt_mdt2ost $flavor`
6360 elif [ $dir == "all2ost" ]; then
6361 res1=`flvr_cnt_mdt2ost $flavor`
6362 res2=`flvr_cnt_cli2ost $flavor`
6363 res=$((res1 + res2))
6364 elif [ $dir == "all2mdt" ]; then
6365 res1=`flvr_cnt_mdt2mdt $flavor`
6366 res2=`flvr_cnt_cli2mdt $flavor`
6367 res=$((res1 + res2))
6368 elif [ $dir == "all2all" ]; then
6369 res1=`flvr_cnt_mdt2ost $flavor`
6370 res2=`flvr_cnt_cli2ost $flavor`
6371 res3=`flvr_cnt_mdt2mdt $flavor`
6372 res4=`flvr_cnt_cli2mdt $flavor`
6373 res=$((res1 + res2 + res3 + res4))
6381 local dir=$1 # from to
6382 local flavor=$2 # flavor expected
6383 local expect=${3:-$(calc_connection_cnt $dir)} # number expected
6387 for ((i=0;i<20;i++)); do
6388 echo -n "checking $dir..."
6389 res=$(do_check_flavor $dir $flavor)
6390 echo "found $res/$expect $flavor connections"
6391 [ $res -ge $expect ] && return 0
6395 echo "Error checking $flavor of $dir: expect $expect, actual $res"
6399 restore_to_default_flavor()
6401 local proc="mgs.MGS.live.$FSNAME"
6403 echo "restoring to default flavor..."
6405 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6407 # remove all existing rules if any
6408 if [ $nrule -ne 0 ]; then
6409 echo "$nrule existing rules"
6410 for rule in `do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor."`; do
6411 echo "remove rule: $rule"
6412 spec=`echo $rule | awk -F = '{print $1}'`
6413 do_facet mgs "$LCTL conf_param -d $spec"
6417 # verify no rules left
6418 nrule=`do_facet mgs lctl get_param -n $proc 2>/dev/null | grep ".srpc.flavor." | wc -l`
6419 [ $nrule -ne 0 ] && error "still $nrule rules left"
6421 # wait for default flavor to be applied
6422 # currently default flavor for all connections are 'null'
6423 wait_flavor all2all null
6424 echo "now at default flavor settings"
6429 local flavor=${1:-null}
6431 echo "setting all flavor to $flavor"
6433 # FIXME need parameter to this fn
6434 # and remove global vars
6435 local cnt_all2all=$(calc_connection_cnt all2all)
6437 local res=$(do_check_flavor all2all $flavor)
6438 if [ $res -eq $cnt_all2all ]; then
6439 echo "already have total $res $flavor connections"
6443 echo "found $res $flavor out of total $cnt_all2all connections"
6444 restore_to_default_flavor
6446 [[ $flavor = null ]] && return 0
6448 set_rule $FSNAME any any $flavor
6449 wait_flavor all2all $flavor
6455 # Checking for shared logdir
6456 if [ ! -d $dir ]; then
6457 # Not found. Create local logdir
6460 touch $dir/check_file.$(hostname -s)
6465 check_write_access() {
6467 local list=${2:-$(comma_list $(nodes_list))}
6471 for node in ${list//,/ }; do
6472 file=$dir/check_file.$(short_nodename $node)
6473 if [[ ! -f "$file" ]]; then
6474 # Logdir not accessible/writable from this node.
6477 rm -f $file || return 1
6483 if [[ -n $YAML_LOG ]]; then
6486 local SAVE_UMASK=`umask`
6489 export YAML_LOG=${LOGDIR}/results.yml
6493 if [ ! -f $YAML_LOG ]; then # If the yaml log already exists then we will just append to it
6494 if check_shared_dir $LOGDIR; then
6495 touch $LOGDIR/shared
6496 echo "Logging to shared log directory: $LOGDIR"
6498 echo "Logging to local directory: $LOGDIR"
6501 yml_nodes_file $LOGDIR >> $YAML_LOG
6502 yml_results_file >> $YAML_LOG
6509 yml_log_test $1 >> $YAML_LOG
6513 yml_log_test_status $@ >> $YAML_LOG
6516 log_sub_test_begin() {
6517 yml_log_sub_test_begin "$@" >> $YAML_LOG
6520 log_sub_test_end() {
6521 yml_log_sub_test_end "$@" >> $YAML_LOG
6527 local llverdev_opts=$2
6528 local devname=$(basename $1)
6529 local size=$(grep "$devname"$ /proc/partitions | awk '{print $3}')
6530 # loop devices aren't in /proc/partitions
6531 [ "x$size" == "x" ] && local size=$(ls -l $dev | awk '{print $5}')
6533 size=$(($size / 1024 / 1024)) # Gb
6535 local partial_arg=""
6536 # Run in partial (fast) mode if the size
6537 # of a partition > 1 GB
6538 [ $size -gt 1 ] && partial_arg="-p"
6540 llverdev --force $partial_arg $llverdev_opts $dev
6546 local llverfs_opts=$2
6547 local use_partial_arg=$3
6548 local partial_arg=""
6549 local size=$(df -B G $dir |tail -n 1 |awk '{print $2}' |sed 's/G//') #GB
6551 # Run in partial (fast) mode if the size
6552 # of a partition > 1 GB
6553 [ "x$use_partial_arg" != "xno" ] && [ $size -gt 1 ] && partial_arg="-p"
6555 llverfs $partial_arg $llverfs_opts $dir
6558 #Remove objects from OST
6559 remove_ost_objects() {
6565 local mntpt=$(facet_mntpt $facet)
6566 local opts=$OST_MOUNT_OPTS
6570 echo "removing objects from $ostdev on $facet: $objids"
6571 if ! test -b $ostdev; then
6572 opts=$(csa_add "$opts" -o loop)
6574 mount -t $(facet_fstype $facet) $opts $ostdev $mntpt ||
6577 for i in $objids; do
6578 rm $mntpt/O/$group/d$((i % 32))/$i || { rc=$?; break; }
6580 umount -f $mntpt || return $?
6584 #Remove files from MDT
6585 remove_mdt_files() {
6590 local mntpt=$(facet_mntpt $facet)
6591 local opts=$MDS_MOUNT_OPTS
6593 echo "removing files from $mdtdev on $facet: $files"
6594 if [ $(facet_fstype $facet) == ldiskfs ] &&
6595 ! do_facet $facet test -b $mdtdev; then
6596 opts=$(csa_add "$opts" -o loop)
6598 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6602 rm $mntpt/ROOT/$f || { rc=$?; break; }
6604 umount -f $mntpt || return $?
6608 duplicate_mdt_files() {
6613 local mntpt=$(facet_mntpt $facet)
6614 local opts=$MDS_MOUNT_OPTS
6616 echo "duplicating files on $mdtdev on $facet: $files"
6617 mkdir -p $mntpt || return $?
6618 if [ $(facet_fstype $facet) == ldiskfs ] &&
6619 ! do_facet $facet test -b $mdtdev; then
6620 opts=$(csa_add "$opts" -o loop)
6622 mount -t $(facet_fstype $facet) $opts $mdtdev $mntpt ||
6633 tmp=$(mktemp $TMP/setfattr.XXXXXXXXXX)
6634 pushd $mntpt/ROOT > /dev/null || return $?
6637 touch $f.bad || return $?
6638 getfattr -n trusted.lov $f | sed "s#$f#&.bad#" > $tmp
6640 [ $rc -eq 0 ] || return $rc
6641 setfattr --restore $tmp || return $?
6647 local devs=${1//,/ }
6650 local rslt=$TMP/sgpdd_survey
6652 # sgpdd-survey cleanups ${rslt}.* files
6654 local cmd="rslt=$rslt $params scsidevs=\"$devs\" $SGPDDSURVEY"
6660 # returns the canonical name for an ldiskfs device
6665 do_facet $facet "dv=\\\$(lctl get_param -n $dev);
6666 if foo=\\\$(lvdisplay -c \\\$dv 2>/dev/null); then
6667 echo dm-\\\${foo##*:};
6669 echo \\\$(basename \\\$dv);
6673 is_sanity_benchmark() {
6674 local benchmarks="dbench bonnie iozone fsx"
6676 for b in $benchmarks; do
6677 if [ "$b" == "$suite" ]; then
6685 $LCTL get_param -n osc.*.kbytesavail | sort -n | head -n1
6689 # Get the available size (KB) of a given obd target.
6696 [[ $facet != client ]] || return 0
6698 size=$(do_facet $facet $LCTL get_param -n *.$obd.kbytesavail | head -n1)
6703 # Get the page size (bytes) on a given facet node.
6709 size=$(do_facet $facet getconf PAGE_SIZE)
6710 [[ ${PIPESTATUS[0]} = 0 && -n "$size" ]] || size=4096
6715 # Get the block count of the filesystem.
6722 count=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6723 awk '/^Block count:/ {print $3}')
6727 # Get the block size of the filesystem.
6733 size=$(do_facet $facet "$DUMPE2FS -h $device 2>&1" |
6734 awk '/^Block size:/ {print $3}')
6738 # Check whether the "large_xattr" feature is enabled or not.
6739 large_xattr_enabled() {
6740 [[ $(facet_fstype $SINGLEMDS) == zfs ]] && return 0
6742 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6744 do_facet $SINGLEMDS "$DUMPE2FS -h $mds_dev 2>&1 |
6745 grep -E -q '(ea_inode|large_xattr)'"
6746 return ${PIPESTATUS[0]}
6749 # Get the maximum xattr size supported by the filesystem.
6753 if large_xattr_enabled; then
6754 # include/linux/limits.h: #define XATTR_SIZE_MAX 65536
6757 local mds_dev=$(mdsdevname ${SINGLEMDS//mds/})
6758 local block_size=$(get_block_size $SINGLEMDS $mds_dev)
6760 # maximum xattr size = size of block - size of header -
6761 # size of 1 entry - 4 null bytes
6762 size=$((block_size - 32 - 32 - 4))
6768 # Dump the value of the named xattr from a file.
6773 echo "$(getfattr -n $xattr_name --absolute-names --only-values $file)"
6776 # Generate a string with size of $size bytes.
6778 local size=${1:-1024} # in bytes
6780 echo "$(head -c $size < /dev/zero | tr '\0' y)"
6783 reformat_external_journal() {
6786 if [ ! -z ${EJOURNAL} ]; then
6787 local rcmd="do_facet $facet"
6789 echo "reformat external journal on $facet:${EJOURNAL}"
6790 ${rcmd} mke2fs -O journal_dev ${EJOURNAL} || return 1
6794 # MDT file-level backup/restore
6795 mds_backup_restore() {
6798 local devname=$(mdsdevname $(facet_number $facet))
6799 local mntpt=$(facet_mntpt brpt)
6800 local rcmd="do_facet $facet"
6801 local metaea=${TMP}/backup_restore.ea
6802 local metadata=${TMP}/backup_restore.tgz
6803 local opts=${MDS_MOUNT_OPTS}
6804 local svc=${facet}_svc
6806 if ! ${rcmd} test -b ${devname}; then
6807 opts=$(csa_add "$opts" -o loop)
6810 echo "file-level backup/restore on $facet:${devname}"
6812 # step 1: build mount point
6813 ${rcmd} mkdir -p $mntpt
6814 # step 2: cleanup old backup
6815 ${rcmd} rm -f $metaea $metadata
6817 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6818 if [ ! -z $igif ]; then
6819 # step 3.5: rm .lustre
6820 ${rcmd} rm -rf $mntpt/ROOT/.lustre || return 1
6822 # step 4: backup metaea
6824 ${rcmd} "cd $mntpt && getfattr -R -d -m '.*' -P . > $metaea && cd -" ||
6826 # step 5: backup metadata
6828 ${rcmd} tar zcf $metadata -C $mntpt/ . > /dev/null 2>&1 || return 3
6830 ${rcmd} umount -d $mntpt || return 4
6831 # step 7: reformat external journal if needed
6832 reformat_external_journal $facet || return 5
6833 # step 8: reformat dev
6834 echo "reformat new device"
6835 add $facet $(mkfs_opts $facet ${devname}) --backfstype ldiskfs \
6836 --reformat ${devname} $(mdsvdevname $(facet_number $facet)) \
6837 > /dev/null || exit 6
6839 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 7
6840 # step 10: restore metadata
6842 ${rcmd} tar zxfp $metadata -C $mntpt > /dev/null 2>&1 || return 8
6843 # step 11: restore metaea
6845 ${rcmd} "cd $mntpt && setfattr --restore=$metaea && cd - " || return 9
6846 # step 12: remove recovery logs
6847 echo "remove recovery logs"
6848 ${rcmd} rm -fv $mntpt/OBJECTS/* $mntpt/CATALOGS
6849 # step 13: umount dev
6850 ${rcmd} umount -d $mntpt || return 10
6851 # step 14: cleanup tmp backup
6852 ${rcmd} rm -f $metaea $metadata
6853 # step 15: reset device label - it's not virgin on
6854 ${rcmd} e2label $devname ${!svc}
6861 local devname=$(mdsdevname $(facet_number $facet))
6862 local mntpt=$(facet_mntpt brpt)
6863 local rcmd="do_facet $facet"
6864 local opts=${MDS_MOUNT_OPTS}
6866 if ! ${rcmd} test -b ${devname}; then
6867 opts=$(csa_add "$opts" -o loop)
6870 echo "removing OI files on $facet: idx=${idx}"
6872 # step 1: build mount point
6873 ${rcmd} mkdir -p $mntpt
6875 ${rcmd} mount -t ldiskfs $opts $devname $mntpt || return 1
6876 if [ -z $idx ]; then
6877 # step 3: remove all OI files
6878 ${rcmd} rm -fv $mntpt/oi.16*
6879 elif [ $idx -lt 2 ]; then
6880 ${rcmd} rm -fv $mntpt/oi.16.${idx}
6884 # others, rm oi.16.[idx, idx * idx, idx ** ...]
6885 for ((i=${idx}; i<64; i=$((i * idx)))); do
6886 ${rcmd} rm -fv $mntpt/oi.16.${i}
6890 ${rcmd} umount -d $mntpt || return 2
6891 # OI files will be recreated when mounted as lustre next time.
6894 # generate maloo upload-able log file name
6895 # \param logname specify unique part of file name
6896 generate_logname() {
6897 local logname=${1:-"default_logname"}
6899 echo "$TESTLOG_PREFIX.$TESTNAME.$logname.$(hostname -s).log"
6902 # make directory on different MDTs
6906 local stripe_count=2
6907 local stripe_index=-1
6910 while getopts "c:i:p" opt; do
6912 c) stripe_count=$OPTARG;;
6913 i) stripe_index=$OPTARG;;
6915 \?) error "only support -i -c -p";;
6919 shift $((OPTIND - 1))
6920 [ $# -eq 1 ] || error "Only creating single directory is supported"
6923 if [ "$p_option" == "-p" ]; then
6924 local parent=$(dirname $path)
6926 [ -d $path ] && return 0
6927 [ ! -d ${parent} ] && mkdir -p ${parent}
6930 if [ $MDSCOUNT -le 1 ]; then
6933 local test_num=$(echo $testnum | sed -e 's/[^0-9]*//g')
6936 if [ $stripe_index -eq -1 ]; then
6937 mdt_index=$((test_num % MDSCOUNT))
6939 mdt_index=$stripe_index
6941 echo "striped dir -i$mdt_index -c$stripe_count $path"
6942 $LFS setdirstripe -i$mdt_index -c$stripe_count $path
6946 # find the smallest and not in use file descriptor
6949 local max_fd=$(ulimit -n)
6951 while [[ $fd -le $max_fd && -e /proc/self/fd/$fd ]]; do
6954 [ $fd -lt $max_fd ] || error "finding free file descriptor failed"
6958 check_mount_and_prep()
6960 is_mounted $MOUNT || setupall
6962 rm -rf $DIR/[df][0-9]* || error "Fail to cleanup the env!"
6963 mkdir $DIR/$tdir || error "Fail to mkdir $DIR/$tdir."
6964 for idx in $(seq $MDSCOUNT); do
6965 local name="MDT$(printf '%04x' $((idx - 1)))"
6966 rm -rf $MOUNT/.lustre/lost+found/$name/*
6970 # calcule how many ost-objects to be created.
6971 precreated_ost_obj_count()
6975 local mdt_name="MDT$(printf '%04x' $mdt_idx)"
6976 local ost_name="OST$(printf '%04x' $ost_idx)"
6977 local proc_path="${FSNAME}-${ost_name}-osc-${mdt_name}"
6978 local last_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
6979 osp.$proc_path.prealloc_last_id)
6980 local next_id=$(do_facet mds$((mdt_idx + 1)) lctl get_param -n \
6981 osp.$proc_path.prealloc_next_id)
6982 echo $((last_id - next_id + 1))
6985 check_file_in_pool()
6990 local res=$($GETSTRIPE $file | grep 0x | cut -f2)
6993 for t in $tlist ; do
6994 [ "$i" -eq "$t" ] && continue 2
6997 echo "pool list: $tlist"
6998 echo "striping: $res"
6999 error_noexit "$file not allocated in $pool"
7006 echo "Creating new pool"
7009 create_pool $FSNAME.$pool ||
7010 { error_noexit "No pool created, result code $?"; return 1; }
7011 [ $($LFS pool_list $FSNAME | grep -c $pool) -eq 1 ] ||
7012 { error_noexit "$pool not in lfs pool_list"; return 2; }
7015 pool_add_targets() {
7016 echo "Adding targets to pool"
7022 local list=$(seq $first $step $last)
7024 local t=$(for i in $list; do printf "$FSNAME-OST%04x_UUID " $i; done)
7025 do_facet mgs $LCTL pool_add \
7026 $FSNAME.$pool $FSNAME-OST[$first-$last/$step]
7027 wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$pool \
7028 | sort -u | tr '\n' ' ' " "$t" || {
7029 error_noexit "Add to pool failed"
7032 local lfscount=$($LFS pool_list $FSNAME.$pool | grep -c "\-OST")
7033 local addcount=$(((last - first) / step + 1))
7034 [ $lfscount -eq $addcount ] || {
7035 error_noexit "lfs pool_list bad ost count" \
7036 "$lfscount != $addcount"
7044 echo "Setting pool on directory $tdir"
7046 $SETSTRIPE -c 2 -p $pool $tdir && return 0
7048 error_noexit "Cannot set pool $pool to $tdir"
7055 echo "Checking pool on directory $tdir"
7057 local res=$($GETSTRIPE --pool $tdir | sed "s/\s*$//")
7058 [ "$res" = "$pool" ] && return 0
7060 error_noexit "Pool on '$tdir' is '$res', not '$pool'"
7064 pool_dir_rel_path() {
7065 echo "Testing relative path works well"
7070 mkdir -p $root/$tdir/$tdir
7072 pool_set_dir $pool $tdir || return 1
7073 pool_set_dir $pool ./$tdir || return 2
7074 pool_set_dir $pool ../$tdir || return 3
7075 pool_set_dir $pool ../$tdir/$tdir || return 4
7076 rm -rf $tdir; cd - > /dev/null
7079 pool_alloc_files() {
7080 echo "Checking files allocation from directory pool"
7087 for i in $(seq -w 1 $count)
7089 local file=$tdir/file-$i
7091 check_file_in_pool $file $pool "$tlist" || \
7092 failed=$((failed + 1))
7094 [ "$failed" = 0 ] && return 0
7096 error_noexit "$failed files not allocated in $pool"
7100 pool_create_files() {
7101 echo "Creating files in pool"
7109 for i in $(seq -w 1 $count)
7111 local file=$tdir/spoo-$i
7112 $SETSTRIPE -p $pool $file
7113 check_file_in_pool $file $pool "$tlist" || \
7114 failed=$((failed + 1))
7116 [ "$failed" = 0 ] && return 0
7118 error_noexit "$failed files not allocated in $pool"
7123 echo "Checking 'lfs df' output"
7126 local t=$($LCTL get_param -n lov.$FSNAME-clilov-*.pools.$pool |
7128 local res=$($LFS df --pool $FSNAME.$pool |
7130 grep "$FSNAME-OST" |
7132 [ "$res" = "$t" ] && return 0
7134 error_noexit "Pools OSTs '$t' is not '$res' that lfs df reports"
7138 pool_file_rel_path() {
7139 echo "Creating files in a pool with relative pathname"
7144 { error_noexit "unable to create $tdir"; return 1 ; }
7145 local file="/..$tdir/$tfile-1"
7146 $SETSTRIPE -p $pool $file ||
7147 { error_noexit "unable to create $file" ; return 2 ; }
7150 $SETSTRIPE -p $pool $tfile-2 || {
7151 error_noexit "unable to create $tfile-2 in $tdir"
7156 pool_remove_first_target() {
7157 echo "Removing first target from a pool"
7160 local pname="lov.$FSNAME-*.pools.$pool"
7161 local t=$($LCTL get_param -n $pname | head -1)
7162 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7163 wait_update $HOSTNAME "lctl get_param -n $pname | grep $t" "" || {
7164 error_noexit "$t not removed from $FSNAME.$pool"
7169 pool_remove_all_targets() {
7170 echo "Removing all targets from pool"
7173 local pname="lov.$FSNAME-*.pools.$pool"
7174 for t in $($LCTL get_param -n $pname | sort -u)
7176 do_facet mgs $LCTL pool_remove $FSNAME.$pool $t
7178 wait_update $HOSTNAME "lctl get_param -n $pname" "" || {
7179 error_noexit "Pool $FSNAME.$pool cannot be drained"
7182 # striping on an empty/nonexistant pool should fall back
7183 # to "pool of everything"
7185 error_noexit "failed to use fallback striping for empty pool"
7188 # setstripe on an empty pool should fail
7189 $SETSTRIPE -p $pool $file 2>/dev/null && {
7190 error_noexit "expected failure when creating file" \
7198 echo "Destroying pool"
7202 do_facet mgs $LCTL pool_destroy $FSNAME.$pool
7205 # striping on an empty/nonexistant pool should fall back
7206 # to "pool of everything"
7208 error_noexit "failed to use fallback striping for missing pool"
7211 # setstripe on an empty pool should fail
7212 $SETSTRIPE -p $pool $file 2>/dev/null && {
7213 error_noexit "expected failure when creating file" \
7218 # get param should return err once pool is gone
7219 if wait_update $HOSTNAME "lctl get_param -n \
7220 lov.$FSNAME-*.pools.$pool 2>/dev/null || echo foo" "foo"
7222 remove_pool_from_list $FSNAME.$pool
7225 error_noexit "Pool $FSNAME.$pool is not destroyed"
7229 # Get and check the actual stripe count of one file.
7230 # Usage: check_stripe_count <file> <expected_stripe_count>
7231 check_stripe_count() {
7236 [[ -z "$file" || -z "$expected" ]] &&
7237 error "check_stripe_count: invalid argument"
7239 local cmd="$GETSTRIPE -c $file"
7240 actual=$($cmd) || error "$cmd failed"
7241 actual=${actual%% *}
7243 if [[ $actual -ne $expected ]]; then
7244 [[ $expected -eq -1 ]] ||
7245 error "$cmd wrong: found $actual, expected $expected"
7246 [[ $actual -eq $OSTCOUNT ]] ||
7247 error "$cmd wrong: found $actual, expected $OSTCOUNT"
7251 # Get and check the actual list of OST indices on one file.
7252 # Usage: check_obdidx <file> <expected_comma_separated_list_of_ost_indices>
7258 [[ -z "$file" || -z "$expected" ]] &&
7259 error "check_obdidx: invalid argument!"
7261 obdidx=$(comma_list $($GETSTRIPE $file | grep -A $OSTCOUNT obdidx |
7262 grep -v obdidx | awk '{print $1}' | xargs))
7264 [[ $obdidx = $expected ]] ||
7265 error "list of OST indices on $file is $obdidx," \
7266 "should be $expected"
7269 # Get and check the actual OST index of the first stripe on one file.
7270 # Usage: check_start_ost_idx <file> <expected_start_ost_idx>
7271 check_start_ost_idx() {
7276 [[ -z "$file" || -z "$expected" ]] &&
7277 error "check_start_ost_idx: invalid argument!"
7279 start_ost_idx=$($GETSTRIPE $file | grep -A 1 obdidx | grep -v obdidx |
7282 [[ $start_ost_idx = $expected ]] ||
7283 error "OST index of the first stripe on $file is" \
7284 "$start_ost_idx, should be $expected"