3 trap 'print_summary && print_stack_trace | tee $TF_FAIL && \
4 echo "$TESTSUITE: FAIL: test-framework exiting on error"' ERR
8 export REFORMAT=${REFORMAT:-""}
9 export WRITECONF=${WRITECONF:-""}
10 export VERBOSE=${VERBOSE:-false}
11 export GSS=${GSS:-false}
12 export GSS_SK=${GSS_SK:-false}
14 export GSS_PIPEFS=false
15 export SHARED_KEY=${SHARED_KEY:-false}
16 export SK_PATH=${SK_PATH:-/tmp/test-framework-keys}
17 export SK_OM_PATH=$SK_PATH'/tmp-request-mount'
18 export SK_MOUNTED=${SK_MOUNTED:-false}
19 export SK_FLAVOR=${SK_FLAVOR:-ski}
20 export SK_NO_KEY=${SK_NO_KEY:-true}
21 export SK_UNIQUE_NM=${SK_UNIQUE_NM:-false}
22 export SK_S2S=${SK_S2S:-false}
23 export SK_S2SNM=${SK_S2SNM:-TestFrameNM}
24 export SK_S2SNMCLI=${SK_S2SNMCLI:-TestFrameNMCli}
25 export SK_SKIPFIRST=${SK_SKIPFIRST:-true}
26 export IDENTITY_UPCALL=default
28 export FLAKEY=${FLAKEY:-true}
29 # specify environment variable containing batch job name for server statistics
30 export JOBID_VAR=${JOBID_VAR:-"procname_uid"} # or "existing" or "disable"
32 #export PDSH="pdsh -S -Rssh -w"
33 export MOUNT_CMD=${MOUNT_CMD:-"mount -t lustre"}
34 export UMOUNT=${UMOUNT:-"umount -d"}
36 export LSNAPSHOT_CONF="/etc/ldev.conf"
37 export LSNAPSHOT_LOG="/var/log/lsnapshot.log"
39 # sles12 umount has a issue with -d option
40 [ -e /etc/SuSE-release ] && grep -w VERSION /etc/SuSE-release | grep -wq 12 && {
41 export UMOUNT="umount"
44 # function used by scripts run on remote nodes
45 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
46 . $LUSTRE/tests/functions.sh
47 . $LUSTRE/tests/yaml.sh
49 export LD_LIBRARY_PATH=${LUSTRE}/utils/.libs:${LUSTRE}/utils:${LD_LIBRARY_PATH}
51 LUSTRE_TESTS_CFG_DIR=${LUSTRE_TESTS_CFG_DIR:-${LUSTRE}/tests/cfg}
53 EXCEPT_LIST_FILE=${EXCEPT_LIST_FILE:-${LUSTRE_TESTS_CFG_DIR}/tests-to-skip.sh}
55 if [ -f "$EXCEPT_LIST_FILE" ]; then
56 echo "Reading test skip list from $EXCEPT_LIST_FILE"
61 # check config files for options in decreasing order of preference
62 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/lustre.conf ] &&
63 MODPROBECONF=/etc/modprobe.d/lustre.conf
64 [ -z "$MODPROBECONF" -a -f /etc/modprobe.d/Lustre ] &&
65 MODPROBECONF=/etc/modprobe.d/Lustre
66 [ -z "$MODPROBECONF" -a -f /etc/modprobe.conf ] &&
67 MODPROBECONF=/etc/modprobe.conf
69 sanitize_parameters() {
70 for i in DIR DIR1 DIR2 MOUNT MOUNT1 MOUNT2
73 if [ -d "$path" ]; then
74 eval export $i=$(echo $path | sed -r 's/\/+$//g')
80 [[ $DIR/ = $MOUNT/* ]] ||
81 { failed=1 && echo "DIR=$DIR not in $MOUNT. Aborting."; }
82 [[ $DIR1/ = $MOUNT1/* ]] ||
83 { failed=1 && echo "DIR1=$DIR1 not in $MOUNT1. Aborting."; }
84 [[ $DIR2/ = $MOUNT2/* ]] ||
85 { failed=1 && echo "DIR2=$DIR2 not in $MOUNT2. Aborting"; }
87 [ -n "$failed" ] && exit 99 || true
91 echo "usage: $0 [-r] [-f cfgfile]"
99 [ -z "$DEFAULT_SUITES" ] && return 0
100 [ -n "$ONLY" ] && echo "WARNING: ONLY is set to $(echo $ONLY)"
102 local form="%-13s %-17s %-9s %s %s\n"
104 printf "$form" "status" "script" "Total(sec)" "E(xcluded) S(low)"
105 echo "---------------------------------------------------------------"
106 for O in $DEFAULT_SUITES; do
107 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
108 [ "${!O}" = "no" ] && continue || true
109 local o=$(echo $O | tr "[:upper:]_" "[:lower:]-")
110 local log=${TMP}/${o}.log
111 if is_sanity_benchmark $o; then
112 log=${TMP}/sanity-benchmark.log
117 local status=Unfinished
119 skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' |
121 slow=$(egrep "^PASS|^FAIL" $log | tr -d "("| sed s/s\)$//g |
122 sort -nr -k 3 | head -n5 | awk '{ print $2":"$3"s" }')
123 total=$(grep duration $log | awk '{ print $2 }')
124 if [ "${!O}" = "done" ]; then
128 local durations=$(egrep "^PASS|^FAIL" $log |
129 tr -d "("| sed s/s\)$//g |
130 awk '{ print $2":"$3"|" }')
131 details=$(printf "%s\n%s %s %s\n" "$details" \
132 "DDETAILS" "$O" "$(echo $durations)")
135 printf "$form" $status "$O" "${total}" "E=$skipped"
136 printf "$form" "-" "-" "-" "S=$(echo $slow)"
139 for O in $DEFAULT_SUITES; do
140 O=$(echo $O | tr "-" "_" | tr "[:lower:]" "[:upper:]")
141 if [ "${!O}" = "no" ]; then
142 printf "$form" "Skipped" "$O" ""
146 # print the detailed tests durations if DDETAILS=true
152 # Get information about the Lustre environment. The information collected
153 # will be used in Lustre tests.
154 # usage: get_lustre_env
155 # input: No required or optional arguments
156 # output: No return values, environment variables are exported
160 export mds1_FSTYPE=${mds1_FSTYPE:-$(facet_fstype mds1)}
161 export ost1_FSTYPE=${ost1_FSTYPE:-$(facet_fstype ost1)}
163 export MGS_VERSION=$(lustre_version_code mgs)
164 export MDS1_VERSION=$(lustre_version_code mds1)
165 export OST1_VERSION=$(lustre_version_code ost1)
166 export CLIENT_VERSION=$(lustre_version_code client)
168 # Prefer using "mds1" directly instead of SINGLEMDS.
169 # Keep this for compat until it is removed from scripts.
170 export SINGLEMDS=${SINGLEMDS:-mds1}
174 export LUSTRE=$(absolute_path $LUSTRE)
175 export TESTSUITE=$(basename $0 .sh)
176 export TEST_FAILED=false
177 export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
178 export RPC_MODE=${RPC_MODE:-false}
179 export DO_CLEANUP=${DO_CLEANUP:-true}
180 export KEEP_ZPOOL=${KEEP_ZPOOL:-false}
181 export CLEANUP_DM_DEV=false
182 export PAGE_SIZE=$(get_page_size client)
184 export MKE2FS=$MKE2FS
185 if [ -z "$MKE2FS" ]; then
186 if which mkfs.ldiskfs >/dev/null 2>&1; then
187 export MKE2FS=mkfs.ldiskfs
193 export DEBUGFS=$DEBUGFS
194 if [ -z "$DEBUGFS" ]; then
195 if which debugfs.ldiskfs >/dev/null 2>&1; then
196 export DEBUGFS=debugfs.ldiskfs
198 export DEBUGFS=debugfs
202 export TUNE2FS=$TUNE2FS
203 if [ -z "$TUNE2FS" ]; then
204 if which tunefs.ldiskfs >/dev/null 2>&1; then
205 export TUNE2FS=tunefs.ldiskfs
207 export TUNE2FS=tune2fs
211 export E2LABEL=$E2LABEL
212 if [ -z "$E2LABEL" ]; then
213 if which label.ldiskfs >/dev/null 2>&1; then
214 export E2LABEL=label.ldiskfs
216 export E2LABEL=e2label
220 export DUMPE2FS=$DUMPE2FS
221 if [ -z "$DUMPE2FS" ]; then
222 if which dumpfs.ldiskfs >/dev/null 2>&1; then
223 export DUMPE2FS=dumpfs.ldiskfs
225 export DUMPE2FS=dumpe2fs
229 export E2FSCK=$E2FSCK
230 if [ -z "$E2FSCK" ]; then
231 if which fsck.ldiskfs >/dev/null 2>&1; then
232 export E2FSCK=fsck.ldiskfs
238 export RESIZE2FS=$RESIZE2FS
239 if [ -z "$RESIZE2FS" ]; then
240 if which resizefs.ldiskfs >/dev/null 2>&1; then
241 export RESIZE2FS=resizefs.ldiskfs
243 export RESIZE2FS=resize2fs
247 export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after test suite
248 export FSCK_MAX_ERR=4 # File system errors left uncorrected
250 export ZFS=${ZFS:-zfs}
251 export ZPOOL=${ZPOOL:-zpool}
252 export ZDB=${ZDB:-zdb}
253 export PARTPROBE=${PARTPROBE:-partprobe}
255 #[ -d /r ] && export ROOT=${ROOT:-/r}
256 export TMP=${TMP:-$ROOT/tmp}
257 export TESTSUITELOG=${TMP}/${TESTSUITE}.log
258 export LOGDIR=${LOGDIR:-${TMP}/test_logs/$(date +%s)}
259 export TESTLOG_PREFIX=$LOGDIR/$TESTSUITE
261 export HOSTNAME=${HOSTNAME:-$(hostname -s)}
262 if ! echo $PATH | grep -q $LUSTRE/utils; then
263 export PATH=$LUSTRE/utils:$PATH
265 if ! echo $PATH | grep -q $LUSTRE/utils/gss; then
266 export PATH=$LUSTRE/utils/gss:$PATH
268 if ! echo $PATH | grep -q $LUSTRE/tests; then
269 export PATH=$LUSTRE/tests:$PATH
271 if ! echo $PATH | grep -q $LUSTRE/../lustre-iokit/sgpdd-survey; then
272 export PATH=$LUSTRE/../lustre-iokit/sgpdd-survey:$PATH
274 export LST=${LST:-"$LUSTRE/../lnet/utils/lst"}
275 [ ! -f "$LST" ] && export LST=$(which lst)
276 export SGPDDSURVEY=${SGPDDSURVEY:-"$LUSTRE/../lustre-iokit/sgpdd-survey/sgpdd-survey")}
277 [ ! -f "$SGPDDSURVEY" ] && export SGPDDSURVEY=$(which sgpdd-survey)
278 export MCREATE=${MCREATE:-mcreate}
279 export MULTIOP=${MULTIOP:-multiop}
280 export MMAP_CAT=${MMAP_CAT:-mmap_cat}
281 export STATX=${STATX:-statx}
282 # Ubuntu, at least, has a truncate command in /usr/bin
283 # so fully path our truncate command.
284 export TRUNCATE=${TRUNCATE:-$LUSTRE/tests/truncate}
285 export FSX=${FSX:-$LUSTRE/tests/fsx}
286 export MDSRATE=${MDSRATE:-"$LUSTRE/tests/mpi/mdsrate"}
287 [ ! -f "$MDSRATE" ] && export MDSRATE=$(which mdsrate 2> /dev/null)
288 if ! echo $PATH | grep -q $LUSTRE/tests/racer; then
289 export PATH=$LUSTRE/tests/racer:$PATH:
291 if ! echo $PATH | grep -q $LUSTRE/tests/mpi; then
292 export PATH=$LUSTRE/tests/mpi:$PATH
294 export RSYNC_RSH=${RSYNC_RSH:-rsh}
296 export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
297 [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
298 export LFS=${LFS:-"$LUSTRE/utils/lfs"}
299 [ ! -f "$LFS" ] && export LFS=$(which lfs)
301 export PERM_CMD=${PERM_CMD:-"$LCTL conf_param"}
303 export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
304 if [ ! -f "$L_GETIDENTITY" ]; then
305 if `which l_getidentity > /dev/null 2>&1`; then
306 export L_GETIDENTITY=$(which l_getidentity)
308 export L_GETIDENTITY=NONE
311 export LL_DECODE_FILTER_FID=${LL_DECODE_FILTER_FID:-"$LUSTRE/utils/ll_decode_filter_fid"}
312 [ ! -f "$LL_DECODE_FILTER_FID" ] && export LL_DECODE_FILTER_FID="ll_decode_filter_fid"
313 export LL_DECODE_LINKEA=${LL_DECODE_LINKEA:-"$LUSTRE/utils/ll_decode_linkea"}
314 [ ! -f "$LL_DECODE_LINKEA" ] && export LL_DECODE_LINKEA="ll_decode_linkea"
315 export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
316 [ ! -f "$MKFS" ] && export MKFS="mkfs.lustre"
317 export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
318 [ ! -f "$TUNEFS" ] && export TUNEFS="tunefs.lustre"
319 export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
320 export LUSTRE_RMMOD=${LUSTRE_RMMOD:-$LUSTRE/scripts/lustre_rmmod}
321 [ ! -f "$LUSTRE_RMMOD" ] &&
322 export LUSTRE_RMMOD=$(which lustre_rmmod 2> /dev/null)
323 export LUSTRE_ROUTES_CONVERSION=${LUSTRE_ROUTES_CONVERSION:-$LUSTRE/scripts/lustre_routes_conversion}
324 [ ! -f "$LUSTRE_ROUTES_CONVERSION" ] &&
325 export LUSTRE_ROUTES_CONVERSION=$(which lustre_routes_conversion 2> /dev/null)
326 export LFS_MIGRATE=${LFS_MIGRATE:-$LUSTRE/scripts/lfs_migrate}
327 [ ! -f "$LFS_MIGRATE" ] &&
328 export LFS_MIGRATE=$(which lfs_migrate 2> /dev/null)
329 export LR_READER=${LR_READER:-"$LUSTRE/utils/lr_reader"}
330 [ ! -f "$LR_READER" ] &&
331 export LR_READER=$(which lr_reader 2> /dev/null)
332 [ -z "$LR_READER" ] && export LR_READER="/usr/sbin/lr_reader"
333 export LSOM_SYNC=${LSOM_SYNC:-"$LUSTRE/utils/llsom_sync"}
334 [ ! -f "$LSOM_SYNC" ] &&
335 export LSOM_SYNC=$(which llsom_sync 2> /dev/null)
336 [ -z "$LSOM_SYNC" ] && export LSOM_SYNC="/usr/sbin/llsom_sync"
337 export NAME=${NAME:-local}
338 export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
339 [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] &&
340 export LGSSD=$(which lgssd)
341 export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
342 [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd 2> /dev/null)
343 export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
345 export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
347 export LDEV=${LDEV:-"$LUSTRE/scripts/ldev"}
348 [ ! -f "$LDEV" ] && export LDEV=$(which ldev 2> /dev/null)
350 export DMSETUP=${DMSETUP:-dmsetup}
351 export DM_DEV_PATH=${DM_DEV_PATH:-/dev/mapper}
352 export LOSETUP=${LOSETUP:-losetup}
354 if [ "$ACCEPTOR_PORT" ]; then
355 export PORT_OPT="--port $ACCEPTOR_PORT"
359 $RPC_MODE || echo "Using GSS shared-key feature"
360 which lgss_sk > /dev/null 2>&1 ||
361 error_exit "built with lgss_sk disabled! SEC=$SEC"
369 $RPC_MODE || echo "Using GSS/krb5 ptlrpc security flavor"
370 which lgss_keyring > /dev/null 2>&1 ||
371 error_exit "built with gss disabled! SEC=$SEC"
382 IDENTITY_UPCALL=false
386 export LOAD_MODULES_REMOTE=${LOAD_MODULES_REMOTE:-false}
388 # Paths on remote nodes, if different
389 export RLUSTRE=${RLUSTRE:-$LUSTRE}
390 export RPWD=${RPWD:-$PWD}
391 export I_MOUNTED=${I_MOUNTED:-"no"}
392 export AUSTER_CLEANUP=${AUSTER_CLEANUP:-false}
393 if [ ! -f /lib/modules/$(uname -r)/kernel/fs/lustre/mdt.ko -a \
394 ! -f /lib/modules/$(uname -r)/updates/kernel/fs/lustre/mdt.ko -a \
395 ! -f /lib/modules/$(uname -r)/extra/kernel/fs/lustre/mdt.ko -a \
396 ! -f $LUSTRE/mdt/mdt.ko ]; then
397 export CLIENTMODSONLY=yes
400 export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
401 export OSD_TRACK_DECLARES_LBUG=${OSD_TRACK_DECLARES_LBUG:-"yes"}
405 while getopts "rvwf:" opt $*; do
410 w) WRITECONF=writeconf;;
415 shift $((OPTIND - 1))
418 # print the durations of each test if "true"
419 DDETAILS=${DDETAILS:-false}
420 [ "$TESTSUITELOG" ] && rm -f $TESTSUITELOG || true
425 export TF_FAIL=${TF_FAIL:-$TMP/tf.fail}
427 # Constants used in more than one test script
428 export LOV_MAX_STRIPE_COUNT=2000
430 export MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh).machines}
431 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
434 # use localrecov to enable recovery for local clients, LU-12722
435 [[ $MDS1_VERSION -lt $(version_code 2.13.52) ]] ||
436 export MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-"-o localrecov"}
437 [[ $OST1_VERSION -lt $(version_code 2.13.52) ]] ||
438 export OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-"-o localrecov"}
445 ncpts=$(do_facet $facet "lctl get_param -n " \
446 "cpu_partition_table 2>/dev/null| wc -l" || echo 1)
448 if [ $ncpts -eq 0 ]; then
455 # Return a numeric version code based on a version string. The version
456 # code is useful for comparison two version strings to see which is newer.
458 # split arguments like "1.8.6-wc3" into "1", "8", "6", "wc3"
459 eval set -- $(tr "[:punct:]" " " <<< $*)
461 echo -n $(((${1:-0} << 16) | (${2:-0} << 8) | ${3:-0}))
464 export LINUX_VERSION=$(uname -r | sed -e "s/\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/")
465 export LINUX_VERSION_CODE=$(version_code ${LINUX_VERSION//\./ })
467 # Report the Lustre build version string (e.g. 1.8.7.3 or 2.4.1).
469 # usage: lustre_build_version
471 # All Lustre versions support "lctl get_param" to report the version of the
472 # code running in the kernel (what our tests are interested in), but it
473 # doesn't work without modules loaded. After 2.9.53 and in upstream kernels
474 # the "version" parameter doesn't include "lustre: " at the beginning.
475 # If that fails, call "lctl lustre_build_version" which prints either (or both)
476 # the userspace and kernel build versions, but until 2.8.55 required root
477 # access to get the Lustre kernel version. If that also fails, fall back to
478 # using "lctl --version", which is easy to parse and works without the kernel
479 # modules, but was only added in 2.6.50 and only prints the lctl tool version,
480 # not the module version, though they are usually the same.
482 # Various commands and their output format for different Lustre versions:
483 # lctl get_param version: 2.9.55
484 # lctl get_param version: lustre: 2.8.53
485 # lctl get_param version: lustre: 2.6.52
486 # kernel: patchless_client
487 # build: v2_6_92_0-2.6.32-431.el6_lustre.x86_64
488 # lctl lustre_build_version: Lustre version: 2.8.53_27_gae67fc01
489 # lctl lustre_build_version: error: lustre_build_version: Permission denied
490 # (as non-root user) lctl version: v2_6_92_0-2.6.32-431.el6.x86_64
491 # lctl lustre_build_version: Lustre version: 2.5.3-2.6.32.26-175.fc12.x86_64
492 # lctl version: 2.5.3-2.6.32..26-175fc12.x86_64
493 # lctl --version: lctl 2.6.50
495 # output: prints version string to stdout in (up to 4) dotted-decimal values
496 lustre_build_version() {
497 local facet=${1:-client}
498 local facet_version=${facet}_VERSION
500 # if the global variable is already set, then use that
501 [ -n "${!facet_version}" ] && echo ${!facet_version} && return
503 # this is the currently-running version of the kernel modules
504 local ver=$(do_facet $facet "$LCTL get_param -n version 2>/dev/null")
505 # we mostly test 2.10+ systems, only try others if the above fails
506 if [ -z "$ver" ]; then
507 ver=$(do_facet $facet "$LCTL lustre_build_version 2>/dev/null")
509 if [ -z "$ver" ]; then
510 ver=$(do_facet $facet "$LCTL --version 2>/dev/null" |
513 local lver=$(egrep -i "lustre: |version: " <<<"$ver" | head -n 1)
514 [ -n "$lver" ] && ver="$lver"
516 lver=$(sed -e 's/[^:]*: //' -e 's/^v//' -e 's/[ -].*//' <<<$ver |
517 tr _ . | cut -d. -f1-4)
519 # save in global variable for the future
520 export $facet_version=$lver
525 # Report the Lustre numeric build version code for the supplied facet.
526 lustre_version_code() {
527 version_code $(lustre_build_version $1)
531 /sbin/lsmod | grep -q "^\<$1\>"
543 msg="$(insmod $module $args 2>&1)" && return 0 || rc=$?
546 # parallels can't load modules directly from prlfs, use /tmp instead
547 if $PRLFS || [[ "$(stat -f -c%t $module)" == "7c7c6673" ]]; then
548 local target="$(mktemp)"
550 cp "$module" "$target"
553 [[ $rc == 0 ]] && PRLFS=true
561 # Load a module on the system where this is running.
563 # usage: load_module module_name [module arguments for insmod/modprobe]
565 # If module arguments are not given but MODOPTS_<MODULE> is set, then its value
566 # will be used as the arguments. Otherwise arguments will be obtained from
567 # /etc/modprobe.conf, from /etc/modprobe.d/Lustre, or else none will be used.
570 local module=$1 # '../libcfs/libcfs/libcfs', 'obdclass/obdclass', ...
573 local base=$(basename $module $ext)
575 local -A module_is_loaded_aa
579 for mod in $(lsmod | awk '{ print $1; }'); do
580 module_is_loaded_aa[${mod//-/_}]=true
584 ${module_is_loaded_aa[${1//-/_}]:-false}
587 if module_is_loaded $base; then
591 if [[ -f $LUSTRE/$module$ext ]]; then
592 path=$LUSTRE/$module$ext
593 elif [[ "$base" == lnet_selftest ]] &&
594 [[ -f $LUSTRE/../lnet/selftest/$base$ext ]]; then
595 path=$LUSTRE/../lnet/selftest/$base$ext
600 if [[ -n "$path" ]]; then
601 # Try to load any non-Lustre modules that $module depends on.
602 for mod in $(modinfo --field=depends $path | tr ',' ' '); do
603 if ! module_is_loaded $mod; then
609 # If no module arguments were passed then get them from
610 # $MODOPTS_<MODULE>, otherwise from modprobe.conf.
611 if [ $# -eq 0 ]; then
612 # $MODOPTS_<MODULE>; we could use associative arrays, but that's
613 # not in Bash until 4.x, so we resort to eval.
614 optvar="MODOPTS_$(basename $module | tr a-z A-Z)"
615 eval set -- \$$optvar
616 if [ $# -eq 0 -a -n "$MODPROBECONF" ]; then
617 # Nothing in $MODOPTS_<MODULE>; try modprobe.conf
619 opt=$(awk -v var="^options $base" '$0 ~ var \
620 {gsub("'"options $base"'",""); print}' \
622 set -- $(echo -n $opt)
624 # Ensure we have accept=all for lnet
625 if [[ "$base" == lnet ]]; then
626 # OK, this is a bit wordy...
627 local arg accept_all_present=false
630 [[ "$arg" == accept=all ]] &&
631 accept_all_present=true
634 $accept_all_present || set -- "$@" accept=all
641 [ $# -gt 0 ] && echo "${module} options: '$*'"
643 # Note that insmod will ignore anything in modprobe.conf, which is why
644 # we're passing options on the command-line. If $path does not exist
645 # then we must be testing a "make install" or"rpm" installation. Also
646 # note that failing to load ptlrpc_gss is not considered fatal.
647 if [[ -n "$path" ]]; then
648 lustre_insmod $path "$@"
649 elif [[ "$base" == ptlrpc_gss ]]; then
650 if ! modprobe $base "$@" 2>/dev/null; then
651 echo "gss/krb5 is not supported"
658 load_modules_local() {
659 if [ -n "$MODPROBE" ]; then
661 echo "Using modprobe to load modules"
665 # Create special udev test rules on every node
666 if [ -f $LUSTRE/lustre/conf/99-lustre.rules ]; then {
667 sed -e 's|/usr/sbin/lctl|$LCTL|g' $LUSTRE/lustre/conf/99-lustre.rules > /etc/udev/rules.d/99-lustre-test.rules
669 echo "SUBSYSTEM==\"lustre\", ACTION==\"change\", ENV{PARAM}==\"?*\", RUN+=\"$LCTL set_param '\$env{PARAM}=\$env{SETTING}'\"" > /etc/udev/rules.d/99-lustre-test.rules
671 udevadm control --reload-rules
674 # For kmemleak-enabled kernels we need clear all past state
675 # that obviously has nothing to do with this Lustre run
676 # Disable automatic memory scanning to avoid perf hit.
677 if [ -f /sys/kernel/debug/kmemleak ] ; then
678 echo scan=off > /sys/kernel/debug/kmemleak
679 echo scan > /sys/kernel/debug/kmemleak
680 echo clear > /sys/kernel/debug/kmemleak
683 echo Loading modules from $LUSTRE
687 if [ -f /sys/devices/system/cpu/online ]; then
688 ncpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/online) + 1))
689 echo "detected $ncpus online CPUs by sysfs"
691 ncpus=$(getconf _NPROCESSORS_CONF 2>/dev/null)
693 if [ $rc -eq 0 ]; then
694 echo "detected $ncpus online CPUs by getconf"
696 echo "Can't detect number of CPUs"
701 # if there is only one CPU core, libcfs can only create one partition
702 # if there is more than 4 CPU cores, libcfs should create multiple CPU
703 # partitions. So we just force libcfs to create 2 partitions for
704 # system with 2 or 4 cores
705 local saved_opts="$MODOPTS_LIBCFS"
706 if [ $ncpus -le 4 ] && [ $ncpus -gt 1 ]; then
707 # force to enable multiple CPU partitions
708 echo "Force libcfs to create 2 CPU partitions"
709 MODOPTS_LIBCFS="cpu_npartitions=2 $MODOPTS_LIBCFS"
711 echo "libcfs will create CPU partition based on online CPUs"
714 load_module ../libcfs/libcfs/libcfs
715 # Prevent local MODOPTS_LIBCFS being passed as part of environment
716 # variable to remote nodes
717 MODOPTS_LIBCFS=$saved_opts
720 load_module ../lnet/lnet/lnet
722 LNDPATH=${LNDPATH:-"../lnet/klnds"}
723 if [ -z "$LNETLND" ]; then
725 o2ib*) LNETLND="o2iblnd/ko2iblnd" ;;
726 tcp*) LNETLND="socklnd/ksocklnd" ;;
727 *) local lnd="${NETTYPE%%[0-9]}lnd"
728 [ -f "$LNDPATH/$lnd/k$lnd.ko" ] &&
729 LNETLND="$lnd/k$lnd" ||
730 LNETLND="socklnd/ksocklnd"
733 load_module ../lnet/klnds/$LNETLND
734 load_module obdclass/obdclass
735 load_module ptlrpc/ptlrpc
736 load_module ptlrpc/gss/ptlrpc_gss
744 load_module obdecho/obdecho
745 if ! client_only; then
746 load_module lfsck/lfsck
747 [ "$LQUOTA" != "no" ] &&
748 load_module quota/lquota $LQUOTAOPTS
749 if [[ $(node_fstypes $HOSTNAME) == *zfs* ]]; then
750 load_module osd-zfs/osd_zfs
751 elif [[ $(node_fstypes $HOSTNAME) == *ldiskfs* ]]; then
752 load_module ../ldiskfs/ldiskfs
753 load_module osd-ldiskfs/osd_ldiskfs
765 load_module llite/lustre
766 [ -d /r ] && OGDB=${OGDB:-"/r/tmp"}
768 rm -f $OGDB/ogdb-$HOSTNAME
769 $LCTL modules > $OGDB/ogdb-$HOSTNAME
771 # 'mount' doesn't look in $PATH, just sbin
772 local mount_lustre=$LUSTRE/utils/mount.lustre
773 if [ -f $mount_lustre ]; then
774 local sbin_mount=$(readlink -f /sbin)/mount.lustre
775 if grep -qw "$sbin_mount" /proc/mounts; then
776 cmp -s $mount_lustre $sbin_mount || umount $sbin_mount
778 if ! grep -qw "$sbin_mount" /proc/mounts; then
779 [ ! -f "$sbin_mount" ] && touch "$sbin_mount"
780 if [ ! -s "$sbin_mount" -a -w "$sbin_mount" ]; then
781 cat <<- EOF > "$sbin_mount"
784 echo "This $sbin_mount just a mountpoint." 1>&2
785 echo "It is never supposed to be run." 1>&2
786 logger -p emerg -- "using stub $sbin_mount $@"
789 chmod a+x $sbin_mount
791 mount --bind $mount_lustre $sbin_mount ||
792 error "can't bind $mount_lustre to $sbin_mount"
800 # load modules on remote nodes optionally
801 # lustre-tests have to be installed on these nodes
802 if $LOAD_MODULES_REMOTE; then
803 local list=$(comma_list $(remote_nodes_list))
804 if [ -n "$list" ]; then
805 echo "loading modules on: '$list'"
806 do_rpc_nodes "$list" load_modules_local
812 LEAK_LUSTRE=$(dmesg | tail -n 30 | grep "obd_memory.*leaked" || true)
813 LEAK_PORTALS=$(dmesg | tail -n 20 | egrep -i "libcfs.*memory leaked" || true)
814 if [ "$LEAK_LUSTRE" -o "$LEAK_PORTALS" ]; then
815 echo "$LEAK_LUSTRE" 1>&2
816 echo "$LEAK_PORTALS" 1>&2
817 mv $TMP/debug $TMP/debug-leak.`date +%s` || true
818 echo "Memory leaks detected"
819 [ -n "$IGNORE_LEAK" ] && { echo "ignoring leaks" && return 0; } || true
825 wait_exit_ST client # bug 12845
827 $LUSTRE_RMMOD ldiskfs || return 2
829 [ -f /etc/udev/rules.d/99-lustre-test.rules ] &&
830 rm /etc/udev/rules.d/99-lustre-test.rules
831 udevadm control --reload-rules
834 if $LOAD_MODULES_REMOTE; then
835 local list=$(comma_list $(remote_nodes_list))
836 if [ -n "$list" ]; then
837 echo "unloading modules on: '$list'"
838 do_rpc_nodes "$list" $LUSTRE_RMMOD ldiskfs
839 do_rpc_nodes "$list" check_mem_leak
840 do_rpc_nodes "$list" "rm -f /etc/udev/rules.d/99-lustre-test.rules"
841 do_rpc_nodes "$list" "udevadm control --reload-rules"
842 do_rpc_nodes "$list" "udevadm trigger"
846 local sbin_mount=$(readlink -f /sbin)/mount.lustre
847 if grep -qe "$sbin_mount " /proc/mounts; then
848 umount $sbin_mount || true
849 [ -s $sbin_mount ] && ! grep -q "STUB MARK" $sbin_mount ||
853 check_mem_leak || return 254
855 echo "modules unloaded."
860 local facet=${1:-$SINGLEMDS}
863 case $(facet_fstype $facet) in
864 ldiskfs) size=50;; # largest seen is 44, leave some headroom
865 # grant_block_size is in bytes, allow at least 2x max blocksize
866 zfs) size=$(lctl get_param osc.$FSNAME*.import |
867 awk '/grant_block_size:/ {print $2/512; exit;}')
871 echo -n $((size * MDSCOUNT))
875 local facet=${1:-$SINGLEMDS}
876 local fstype=$(facet_fstype $facet)
879 ldiskfs) size=4;; # ~4KB per inode
880 zfs) size=11;; # 10 to 11KB per inode
886 check_gss_daemon_nodes() {
890 do_nodesv $list "num=\\\$(ps -o cmd -C $dname | grep $dname | wc -l);
891 if [ \\\"\\\$num\\\" -ne 1 ]; then
892 echo \\\$num instance of $dname;
897 check_gss_daemon_facet() {
901 num=`do_facet $facet ps -o cmd -C $dname | grep $dname | wc -l`
902 if [ $num -ne 1 ]; then
903 echo "$num instance of $dname on $facet"
912 echo Stopping $@ on $list
913 do_nodes $list "killall -2 $@ 2>/dev/null || true"
916 # start gss daemons on all nodes, or "daemon" on "nodes" if set
917 start_gss_daemons() {
921 if [ "$nodes" ] && [ "$daemon" ] ; then
922 echo "Starting gss daemon on nodes: $nodes"
923 do_nodes $nodes "$daemon" || return 8
927 nodes=$(comma_list $(mdts_nodes))
928 echo "Starting gss daemon on mds: $nodes"
930 # Start all versions, in case of switching
931 do_nodes $nodes "$LSVCGSSD -vvv -s -m -o -z" || return 1
933 do_nodes $nodes "$LSVCGSSD -v" || return 1
936 do_nodes $nodes "$LGSSD -v" || return 2
939 nodes=$(comma_list $(osts_nodes))
940 echo "Starting gss daemon on ost: $nodes"
942 # Start all versions, in case of switching
943 do_nodes $nodes "$LSVCGSSD -vvv -s -m -o -z" || return 3
945 do_nodes $nodes "$LSVCGSSD -v" || return 3
947 # starting on clients
949 local clients=${CLIENTS:-$HOSTNAME}
951 echo "Starting $LGSSD on clients $clients "
952 do_nodes $clients "$LGSSD -v" || return 4
955 # wait daemons entering "stable" status
959 # check daemons are running
961 nodes=$(comma_list $(mdts_nodes) $(osts_nodes))
962 check_gss_daemon_nodes $nodes lsvcgssd || return 5
964 nodes=$(comma_list $(mdts_nodes))
965 check_gss_daemon_nodes $nodes lgssd || return 6
968 check_gss_daemon_nodes $clients lgssd || return 7
973 local nodes=$(comma_list $(mdts_nodes))
975 send_sigint $nodes lsvcgssd lgssd
977 nodes=$(comma_list $(osts_nodes))
978 send_sigint $nodes lsvcgssd
980 nodes=${CLIENTS:-$HOSTNAME}
981 send_sigint $nodes lgssd
985 # Add mount flags for shared key
987 if grep -q skpath <<< "$mt_opts" ; then
988 mt_opts=$(echo $mt_opts |
989 sed -e "s#skpath=[^ ,]*#skpath=$SK_PATH#")
991 if [ -z "$mt_opts" ]; then
992 mt_opts="-o skpath=$SK_PATH"
994 mt_opts="$mt_opts,skpath=$SK_PATH"
1004 /usr/lib/lustre/* | /usr/lib64/lustre/* | /usr/lib/lustre | \
1013 [ $from_tree = true ]
1017 if $SHARED_KEY; then
1026 if ! module_loaded ptlrpc_gss; then
1027 load_module ptlrpc/gss/ptlrpc_gss
1028 module_loaded ptlrpc_gss ||
1029 error_exit "init_gss: GSS=$GSS, but gss/krb5 missing"
1032 if $GSS_KRB5 || $GSS_SK; then
1033 start_gss_daemons || error_exit "start gss daemon failed! rc=$?"
1036 if $GSS_SK && ! $SK_NO_KEY; then
1037 echo "Loading basic SSK keys on all servers"
1038 do_nodes $(comma_list $(all_server_nodes)) \
1039 "lgss_sk -t server -l $SK_PATH/$FSNAME.key || true"
1040 do_nodes $(comma_list $(all_server_nodes)) \
1041 "keyctl show | grep lustre | cut -c1-11 |
1043 xargs -IX keyctl setperm X 0x3f3f3f3f"
1046 if $GSS_SK && $SK_NO_KEY; then
1047 local numclients=${1:-$CLIENTCOUNT}
1048 local clients=${CLIENTS:-$HOSTNAME}
1050 # security ctx config for keyring
1052 local lgssc_conf_file="/etc/request-key.d/lgssc.conf"
1054 if from_build_tree; then
1055 mkdir -p $SK_OM_PATH
1056 if grep -q request-key /proc/mounts > /dev/null; then
1057 echo "SSK: Request key already mounted."
1059 mount -o bind $SK_OM_PATH /etc/request-key.d/
1061 local lgssc_conf_line='create lgssc * * '
1062 lgssc_conf_line+=$(which lgss_keyring)
1063 lgssc_conf_line+=' %o %k %t %d %c %u %g %T %P %S'
1064 echo "$lgssc_conf_line" > $lgssc_conf_file
1067 [ -e $lgssc_conf_file ] ||
1068 error_exit "Could not find key options in $lgssc_conf_file"
1069 echo "$lgssc_conf_file content is:"
1070 cat $lgssc_conf_file
1072 if ! local_mode; then
1073 if from_build_tree; then
1074 do_nodes $(comma_list $(all_nodes)) "mkdir -p \
1076 do_nodes $(comma_list $(all_nodes)) "mount \
1077 -o bind $SK_OM_PATH \
1078 /etc/request-key.d/"
1079 do_nodes $(comma_list $(all_nodes)) "rsync \
1080 -aqv $HOSTNAME:$lgssc_conf_file \
1081 $lgssc_conf_file >/dev/null 2>&1"
1083 do_nodes $(comma_list $(all_nodes)) \
1084 "echo $lgssc_conf_file: ; \
1085 cat $lgssc_conf_file"
1089 # create shared key on all nodes
1090 mkdir -p $SK_PATH/nodemap
1091 rm -f $SK_PATH/$FSNAME.key $SK_PATH/nodemap/c*.key \
1092 $SK_PATH/$FSNAME-*.key
1093 # for nodemap testing each client may need own key,
1094 # and S2S now requires keys as well, both for "client"
1097 lgss_sk -t server -f$FSNAME -n $SK_S2SNMCLI \
1098 -w $SK_PATH/$FSNAME-nmclient.key \
1099 -d /dev/urandom >/dev/null 2>&1
1100 lgss_sk -t mgs,server -f$FSNAME -n $SK_S2SNM \
1101 -w $SK_PATH/$FSNAME-s2s-server.key \
1102 -d /dev/urandom >/dev/null 2>&1
1105 lgss_sk -t server -f$FSNAME -w $SK_PATH/$FSNAME.key \
1106 -d /dev/urandom >/dev/null 2>&1
1108 for i in $(seq 0 $((numclients - 1))); do
1109 lgss_sk -t server -f$FSNAME -n c$i \
1110 -w $SK_PATH/nodemap/c$i.key -d /dev/urandom \
1114 if ! local_mode; then
1115 for lnode in $(all_nodes); do
1116 scp -r $SK_PATH ${lnode}:$(dirname $SK_PATH)/
1119 # Set client keys to client type to generate prime P
1121 do_nodes $(all_nodes) "lgss_sk -t client,server -m \
1122 $SK_PATH/$FSNAME.key >/dev/null 2>&1"
1124 do_nodes $clients "lgss_sk -t client -m \
1125 $SK_PATH/$FSNAME.key >/dev/null 2>&1"
1126 do_nodes $clients "find $SK_PATH/nodemap -name \*.key | \
1127 xargs -IX lgss_sk -t client -m X >/dev/null 2>&1"
1129 # This is required for servers as well, if S2S in use
1131 do_nodes $(comma_list $(mdts_nodes)) \
1132 "cp $SK_PATH/$FSNAME-s2s-server.key \
1133 $SK_PATH/$FSNAME-s2s-client.key; lgss_sk \
1134 -t client -m $SK_PATH/$FSNAME-s2s-client.key \
1136 do_nodes $(comma_list $(osts_nodes)) \
1137 "cp $SK_PATH/$FSNAME-s2s-server.key \
1138 $SK_PATH/$FSNAME-s2s-client.key; lgss_sk \
1139 -t client -m $SK_PATH/$FSNAME-s2s-client.key \
1141 do_nodes $clients "lgss_sk -t client \
1142 -m $SK_PATH/$FSNAME-nmclient.key \
1147 # mount options for servers and clients
1148 MGS_MOUNT_OPTS=$(add_sk_mntflag $MGS_MOUNT_OPTS)
1149 MDS_MOUNT_OPTS=$(add_sk_mntflag $MDS_MOUNT_OPTS)
1150 OST_MOUNT_OPTS=$(add_sk_mntflag $OST_MOUNT_OPTS)
1151 MOUNT_OPTS=$(add_sk_mntflag $MOUNT_OPTS)
1153 if [ -z "$LGSS_KEYRING_DEBUG" ]; then
1154 LGSS_KEYRING_DEBUG=4
1158 if [ -n "$LGSS_KEYRING_DEBUG" ] && \
1159 ( local_mode || from_build_tree ); then
1161 sptlrpc.gss.lgss_keyring.debug_level=$LGSS_KEYRING_DEBUG
1162 elif [ -n "$LGSS_KEYRING_DEBUG" ]; then
1163 do_nodes $(comma_list $(all_nodes)) "modprobe ptlrpc_gss && \
1165 sptlrpc.gss.lgss_keyring.debug_level=$LGSS_KEYRING_DEBUG"
1172 # maybe cleanup credential cache?
1179 do_node $(mgs_node) "$LCTL nodemap_del $SK_S2SNM"
1180 do_node $(mgs_node) "$LCTL nodemap_del $SK_S2SNMCLI"
1181 $RPC_MODE || echo "Sleeping for 10 sec for Nodemap.."
1185 $RPC_MODE || echo "Cleaning up Shared Key.."
1186 do_nodes $(comma_list $(all_nodes)) "rm -f \
1187 $SK_PATH/$FSNAME*.key $SK_PATH/nodemap/$FSNAME*.key"
1188 do_nodes $(comma_list $(all_nodes)) "keyctl show | \
1189 awk '/lustre/ { print \\\$1 }' | xargs -IX keyctl unlink X"
1190 if from_build_tree; then
1191 # Remove the mount and clean up the files we added to
1193 do_nodes $(comma_list $(all_nodes)) "while grep -q \
1194 request-key.d /proc/mounts; do umount \
1195 /etc/request-key.d/; done"
1196 do_nodes $(comma_list $(all_nodes)) "rm -f \
1197 $SK_OM_PATH/lgssc.conf"
1198 do_nodes $(comma_list $(all_nodes)) "rmdir $SK_OM_PATH"
1206 local var=${facet}_svc
1214 echo -n $facet | sed -e 's/^fs[0-9]\+//' -e 's/[0-9_]\+//' |
1215 tr '[:lower:]' '[:upper:]'
1221 if [ $facet == mgs ] || [ $facet == client ]; then
1225 echo -n $facet | sed -e 's/^fs[0-9]\+//' | sed -e 's/^[a-z]\+//'
1233 if [ -n "${!var}" ]; then
1238 var=$(facet_type $facet)FSTYPE
1239 if [ -n "${!var}" ]; then
1244 if [ -n "$FSTYPE" ]; then
1249 if [[ $facet == mgs ]] && combined_mgs_mds; then
1261 local facets=$(get_facets)
1264 for facet in ${facets//,/ }; do
1265 if [ $node == $(facet_host $facet) ] ||
1266 [ $node == "$(facet_failover_host $facet)" ]; then
1267 fstype=$(facet_fstype $facet)
1268 if [[ $fstypes != *$fstype* ]]; then
1269 fstypes+="${fstypes:+,}$fstype"
1278 local num=$(facet_number $facet)
1281 if [[ $(facet_type $facet) = OST ]]; then
1282 index=OSTINDEX${num}
1283 if [[ -n "${!index}" ]]; then
1288 index=${OST_INDICES[num - 1]}
1291 [[ -n "$index" ]] || index=$((num - 1))
1299 local fstype=$(facet_fstype $facet)
1303 label=$(do_facet ${facet} "$E2LABEL ${dev} 2>/dev/null");;
1305 label=$(do_facet ${facet} "$ZFS get -H -o value lustre:svname \
1306 ${dev} 2>/dev/null");;
1308 error "unknown fstype!";;
1316 local device=$(mdsdevname $num)
1317 local label=$(devicelabel mds$num ${device} | grep -v "CMD: ")
1323 local device=$(ostdevname $num)
1324 local label=$(devicelabel ost$num ${device} | grep -v "CMD: ")
1329 # Get the device of a facet.
1336 mgs) device=$(mgsdevname) ;;
1337 mds*) device=$(mdsdevname $(facet_number $facet)) ;;
1338 ost*) device=$(ostdevname $(facet_number $facet)) ;;
1339 fs2mds) device=$(mdsdevname 1_2) ;;
1340 fs2ost) device=$(ostdevname 1_2) ;;
1341 fs3ost) device=$(ostdevname 2_2) ;;
1349 # Get the virtual device of a facet.
1356 mgs) device=$(mgsvdevname) ;;
1357 mds*) device=$(mdsvdevname $(facet_number $facet)) ;;
1358 ost*) device=$(ostvdevname $(facet_number $facet)) ;;
1359 fs2mds) device=$(mdsvdevname 1_2) ;;
1360 fs2ost) device=$(ostvdevname 1_2) ;;
1361 fs3ost) device=$(ostvdevname 2_2) ;;
1369 local virt=$(virt-what 2> /dev/null)
1371 [ $? -eq 0 ] && [ -n "$virt" ] && { echo $virt; return; }
1373 virt=$(dmidecode -s system-product-name | awk '{print $1}')
1376 VMware|KVM|VirtualBox|Parallels|Bochs)
1377 echo $virt | tr '[A-Z]' '[a-z]' ;;
1383 # Re-read the partition table on failover partner host.
1384 # After a ZFS storage pool is created on a shared device, the partition table
1385 # on the device may change. However, the operating system on the failover
1386 # host may not notice the change automatically. Without the up-to-date partition
1387 # block devices, 'zpool import ..' cannot find the labels, whose positions are
1388 # relative to partition rather than disk beginnings.
1390 # This function performs partprobe on the failover host to make it re-read the
1393 refresh_partition_table() {
1398 host=$(facet_passive_host $facet)
1399 if [[ -n "$host" ]]; then
1400 do_node $host "$PARTPROBE $device"
1405 # Get ZFS storage pool name.
1412 device=$(facet_device $facet)
1413 # poolname is string before "/"
1414 poolname="${device%%/*}"
1421 # Get ZFS local fsname.
1423 zfs_local_fsname() {
1425 local lfsname=$(basename $(facet_device $facet))
1431 # Create ZFS storage pool.
1438 local opts=${@:-"-o cachefile=none"}
1440 do_facet $facet "lsmod | grep zfs >&/dev/null || modprobe zfs;
1441 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1442 $ZPOOL create -f $opts $poolname $vdev"
1446 # Create ZFS file system.
1452 local opts=${@:-"-o mountpoint=legacy"}
1454 do_facet $facet "$ZFS list -H $dataset >/dev/null 2>&1 ||
1455 $ZFS create $opts $dataset"
1459 # Export ZFS storage pool.
1460 # Before exporting the pool, all datasets within the pool should be unmounted.
1468 poolname=$(zpool_name $facet)
1470 if [[ -n "$poolname" ]]; then
1471 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1472 grep -q ^$poolname/ /proc/mounts ||
1473 $ZPOOL export $opts $poolname"
1478 # Destroy ZFS storage pool.
1479 # Destroy the given pool and free up any devices for other use. This command
1480 # tries to unmount any active datasets before destroying the pool.
1481 # -f Force any active datasets contained within the pool to be unmounted.
1485 local poolname=${2:-$(zpool_name $facet)}
1487 if [[ -n "$poolname" ]]; then
1488 do_facet $facet "! $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1489 $ZPOOL destroy -f $poolname"
1494 # Import ZFS storage pool.
1495 # Force importing, even if the pool appears to be potentially active.
1500 local opts=${@:-"-o cachefile=none -o failmode=panic"}
1503 poolname=$(zpool_name $facet)
1505 if [[ -n "$poolname" ]]; then
1506 opts+=" -d $(dirname $(facet_vdevice $facet))"
1507 do_facet $facet "lsmod | grep zfs >&/dev/null || modprobe zfs;
1508 $ZPOOL list -H $poolname >/dev/null 2>&1 ||
1509 $ZPOOL import -f $opts $poolname"
1514 # Reimport ZFS storage pool with new name
1519 local opts="-o cachefile=none"
1520 local poolname=$(zpool_name $facet)
1522 opts+=" -d $(dirname $(facet_vdevice $facet))"
1523 do_facet $facet "$ZPOOL export $poolname;
1524 $ZPOOL import $opts $poolname $newpool"
1528 # Set the "cachefile=none" property on ZFS storage pool so that the pool
1529 # is not automatically imported on system startup.
1531 # In a failover environment, this will provide resource level fencing which
1532 # will ensure that the same ZFS storage pool will not be imported concurrently
1533 # on different nodes.
1535 disable_zpool_cache() {
1539 poolname=$(zpool_name $facet)
1541 if [[ -n "$poolname" ]]; then
1542 do_facet $facet "$ZPOOL set cachefile=none $poolname"
1547 # This and set_osd_param() shall be used to access OSD parameters
1548 # once existed under "obdfilter":
1553 # writethrough_cache_enable
1557 local device=${2:-$FSNAME-OST*}
1560 do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
1561 osd-*.$device.$name 2>&1" | grep -v 'error:'
1566 local device=${2:-$FSNAME-OST*}
1570 do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
1571 osd-*.$device.$name=$value 2>&1" | grep -v 'error:'
1575 local dz=${1:-$DEBUG_SIZE}
1577 if [ -f /sys/devices/system/cpu/possible ]; then
1578 local cpus=$(($(cut -d "-" -f 2 /sys/devices/system/cpu/possible)+1))
1580 local cpus=$(getconf _NPROCESSORS_CONF 2>/dev/null)
1583 # bug 19944, adjust size to be -gt num_possible_cpus()
1584 # promise 2MB for every cpu at least
1585 if [ -n "$cpus" ] && [ $((cpus * 2)) -gt $dz ]; then
1588 lctl set_param debug_mb=$dz
1591 set_default_debug () {
1592 local debug=${1:-"$PTLDEBUG"}
1593 local subsys=${2:-"$SUBSYSTEM"}
1594 local debug_size=${3:-$DEBUG_SIZE}
1596 [ -n "$debug" ] && lctl set_param debug="$debug" >/dev/null
1597 [ -n "$subsys" ] && lctl set_param subsystem_debug="${subsys# }" >/dev/null
1599 [ -n "$debug_size" ] && set_debug_size $debug_size > /dev/null
1602 set_default_debug_nodes () {
1604 local debug="${2:-"$PTLDEBUG"}"
1605 local subsys="${3:-"$SUBSYSTEM"}"
1606 local debug_size="${4:-$DEBUG_SIZE}"
1608 if [[ ,$nodes, = *,$HOSTNAME,* ]]; then
1609 nodes=$(exclude_items_from_list "$nodes" "$HOSTNAME")
1613 [[ -z "$nodes" ]] ||
1614 do_rpc_nodes "$nodes" set_default_debug \
1615 \\\"$debug\\\" \\\"$subsys\\\" $debug_size || true
1618 set_default_debug_facet () {
1620 local debug="${2:-"$PTLDEBUG"}"
1621 local subsys="${3:-"$SUBSYSTEM"}"
1622 local debug_size="${4:-$DEBUG_SIZE}"
1623 local node=$(facet_active_host $facet)
1625 [ -n "$node" ] || error "No host defined for facet $facet"
1627 set_default_debug_nodes $node "$debug" "$subsys" $debug_size
1630 set_params_nodes () {
1631 [[ $# -ge 2 ]] || return 0
1635 do_nodes $nodes $LCTL set_param $@
1638 set_params_clients () {
1639 local clients=${1:-$CLIENTS}
1640 local params=${2:-$CLIENT_LCTL_SETPARAM_PARAM}
1642 [[ -n $params ]] || return 0
1643 set_params_nodes $clients $params
1647 local hostid=${1:-$(hostid)}
1649 if [ ! -s /etc/hostid ]; then
1650 printf $(echo -n $hostid |
1651 sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/') >/etc/hostid
1657 local facets=${1:-$(get_facets)}
1660 for facet in ${facets//,/ }; do
1663 [ $RC -eq 0 ] && continue
1665 if [ "$TESTSUITE.$TESTNAME" = "replay-dual.test_0a" ]; then
1666 skip_noexit "Restart of $facet failed!." &&
1669 error "Restart of $facet failed!"
1676 # Add argument "arg" (e.g., "loop") to the comma-separated list
1677 # of arguments for option "opt" (e.g., "-o") on command
1678 # line "opts" (e.g., "-o flock").
1684 local opt_pattern="\([[:space:]]\+\|^\)$opt"
1686 if echo "$opts" | grep -q $opt_pattern; then
1687 opts=$(echo "$opts" | sed -e \
1688 "s/$opt_pattern[[:space:]]*[^[:space:]]\+/&,$arg/")
1690 opts+="${opts:+ }$opt $arg"
1696 # Associate loop device with a given regular file.
1697 # Return the loop device.
1699 setup_loop_device() {
1703 do_facet $facet "loop_dev=\\\$($LOSETUP -j $file | cut -d : -f 1);
1704 if [[ -z \\\$loop_dev ]]; then
1705 loop_dev=\\\$($LOSETUP -f);
1706 $LOSETUP \\\$loop_dev $file || loop_dev=;
1708 echo -n \\\$loop_dev"
1712 # Detach a loop device.
1714 cleanup_loop_device() {
1718 do_facet $facet "! $LOSETUP $loop_dev >/dev/null 2>&1 ||
1719 $LOSETUP -d $loop_dev"
1723 # Check if a given device is a block device.
1730 [[ -n "$dev" ]] || return 1
1731 do_facet $facet "test -b $dev" || return 1
1732 if [[ -n "$size" ]]; then
1733 local in=$(do_facet $facet "dd if=$dev of=/dev/null bs=1k \
1734 count=1 skip=$size 2>&1" |
1735 awk '($3 == "in") { print $1 }')
1736 [[ "$in" = "1+0" ]] || return 1
1741 # Check if a given device is a device-mapper device.
1747 [[ -n "$dev" ]] || return 1
1748 do_facet $facet "$DMSETUP status $dev >/dev/null 2>&1"
1752 # Check if a given device is a device-mapper flakey device.
1754 is_dm_flakey_dev() {
1759 [[ -n "$dev" ]] || return 1
1761 type=$(do_facet $facet "$DMSETUP status $dev 2>&1" |
1763 [[ $type = flakey ]] && return 0 || return 1
1767 # Check if device-mapper flakey device is supported by the kernel
1768 # of $facet node or not.
1770 dm_flakey_supported() {
1774 do_facet $facet "modprobe dm-flakey;
1775 $DMSETUP targets | grep -q flakey" &> /dev/null
1779 # Get the device-mapper flakey device name of a given facet.
1781 dm_facet_devname() {
1783 [[ $facet = mgs ]] && combined_mgs_mds && facet=mds1
1785 echo -n ${facet}_flakey
1789 # Get the device-mapper flakey device of a given facet.
1790 # A device created by dmsetup will appear as /dev/mapper/<device-name>.
1792 dm_facet_devpath() {
1795 echo -n $DM_DEV_PATH/$(dm_facet_devname $facet)
1799 # Set a device-mapper device with a new table.
1801 # The table has the following format:
1802 # <logical_start_sector> <num_sectors> <target_type> <target_args>
1804 # flakey <target_args> includes:
1805 # <destination_device> <offset> <up_interval> <down_interval> \
1806 # [<num_features> [<feature_arguments>]]
1808 # linear <target_args> includes:
1809 # <destination_device> <start_sector>
1811 dm_set_dev_table() {
1814 local target_type=$3
1820 read tmp num_sectors tmp real_dev tmp \
1821 <<< $(do_facet $facet "$DMSETUP table $dm_dev")
1823 case $target_type in
1825 table="0 $num_sectors flakey $real_dev 0 0 1800 1 drop_writes"
1828 table="0 $num_sectors linear $real_dev 0"
1830 *) error "invalid target type $target_type" ;;
1833 do_facet $facet "$DMSETUP suspend --nolockfs --noflush $dm_dev" ||
1834 error "failed to suspend $dm_dev"
1835 do_facet $facet "$DMSETUP load $dm_dev --table \\\"$table\\\"" ||
1836 error "failed to load $target_type table into $dm_dev"
1837 do_facet $facet "$DMSETUP resume $dm_dev" ||
1838 error "failed to resume $dm_dev"
1842 # Set a device-mapper flakey device as "read-only" by using the "drop_writes"
1843 # feature parameter.
1846 # All write I/O is silently ignored.
1847 # Read I/O is handled correctly.
1849 dm_set_dev_readonly() {
1851 local dm_dev=${2:-$(dm_facet_devpath $facet)}
1853 dm_set_dev_table $facet $dm_dev flakey
1857 # Set a device-mapper device to traditional linear mapping mode.
1859 dm_clear_dev_readonly() {
1861 local dm_dev=${2:-$(dm_facet_devpath $facet)}
1863 dm_set_dev_table $facet $dm_dev linear
1867 # Set the device of a given facet as "read-only".
1869 set_dev_readonly() {
1871 local svc=${facet}_svc
1873 if [[ $(facet_fstype $facet) = zfs ]] ||
1874 ! dm_flakey_supported $facet; then
1875 do_facet $facet $LCTL --device ${!svc} readonly
1877 dm_set_dev_readonly $facet
1882 # Get size in 512-byte sectors (BLKGETSIZE64 / 512) of a given device.
1889 num_sectors=$(do_facet $facet "blockdev --getsz $dev 2>/dev/null")
1890 [[ ${PIPESTATUS[0]} = 0 && -n "$num_sectors" ]] || num_sectors=0
1891 echo -n $num_sectors
1895 # Create a device-mapper device with a given block device or regular file (will
1896 # be associated with loop device).
1897 # Return the full path of the device-mapper device.
1901 local real_dev=$2 # destination device
1902 local dm_dev_name=${3:-$(dm_facet_devname $facet)} # device name
1903 local dm_dev=$DM_DEV_PATH/$dm_dev_name # device-mapper device
1905 # check if the device-mapper device to be created already exists
1906 if is_dm_dev $facet $dm_dev; then
1907 # if the existing device was set to "read-only", then clear it
1908 ! is_dm_flakey_dev $facet $dm_dev ||
1909 dm_clear_dev_readonly $facet $dm_dev
1915 # check if the destination device is a block device, and if not,
1916 # associate it with a loop device
1917 is_blkdev $facet $real_dev ||
1918 real_dev=$(setup_loop_device $facet $real_dev)
1919 [[ -n "$real_dev" ]] || { echo -n $real_dev; return 2; }
1921 # now create the device-mapper device
1922 local num_sectors=$(get_num_sectors $facet $real_dev)
1923 local table="0 $num_sectors linear $real_dev 0"
1926 do_facet $facet "$DMSETUP create $dm_dev_name --table \\\"$table\\\"" ||
1927 { rc=${PIPESTATUS[0]}; dm_dev=; }
1928 do_facet $facet "$DMSETUP mknodes >/dev/null 2>&1"
1935 # Map the facet name to its device variable name.
1937 facet_device_alias() {
1939 local dev_alias=$facet
1942 fs2mds) dev_alias=mds1_2 ;;
1943 fs2ost) dev_alias=ost1_2 ;;
1944 fs3ost) dev_alias=ost2_2 ;;
1952 # Save the original value of the facet device and export the new value.
1958 local active_facet=$(facet_active $facet)
1959 local dev_alias=$(facet_device_alias $active_facet)
1960 local dev_name=${dev_alias}_dev
1961 local dev=${!dev_name}
1963 if [[ $active_facet = $facet ]]; then
1964 local failover_dev=${dev_alias}failover_dev
1965 if [[ ${!failover_dev} = $dev ]]; then
1966 eval export ${failover_dev}_saved=$dev
1967 eval export ${failover_dev}=$dm_dev
1970 dev_alias=$(facet_device_alias $facet)
1971 local facet_dev=${dev_alias}_dev
1972 if [[ ${!facet_dev} = $dev ]]; then
1973 eval export ${facet_dev}_saved=$dev
1974 eval export ${facet_dev}=$dm_dev
1978 eval export ${dev_name}_saved=$dev
1979 eval export ${dev_name}=$dm_dev
1983 # Restore the saved value of the facet device.
1988 [[ $facet = mgs ]] && combined_mgs_mds && facet=mds1
1989 local dev_alias=$(facet_device_alias $facet)
1991 local saved_dev=${dev_alias}_dev_saved
1992 [[ -z ${!saved_dev} ]] ||
1993 eval export ${dev_alias}_dev=${!saved_dev}
1995 saved_dev=${dev_alias}failover_dev_saved
1996 [[ -z ${!saved_dev} ]] ||
1997 eval export ${dev_alias}failover_dev=${!saved_dev}
2001 # Remove a device-mapper device.
2002 # If the destination device is a loop device, then also detach it.
2006 local dm_dev=${2:-$(dm_facet_devpath $facet)}
2010 is_dm_dev $facet $dm_dev || return 0
2012 read major minor <<< $(do_facet $facet "$DMSETUP table $dm_dev" |
2013 awk '{ print $4 }' | awk -F: '{ print $1" "$2 }')
2015 do_facet $facet "$DMSETUP remove $dm_dev"
2016 do_facet $facet "$DMSETUP mknodes >/dev/null 2>&1"
2018 unexport_dm_dev $facet
2020 # detach a loop device
2021 [[ $major -ne 7 ]] || cleanup_loop_device $facet /dev/loop$minor
2023 # unload dm-flakey module
2024 do_facet $facet "modprobe -r dm-flakey" || true
2030 local active_facet=$(facet_active $facet)
2031 local dev_alias=$(facet_device_alias $active_facet)
2032 local dev=${dev_alias}_dev
2033 local opt=${facet}_opt
2034 local mntpt=$(facet_mntpt $facet)
2035 local opts="${!opt} $@"
2036 local fstype=$(facet_fstype $facet)
2038 local dm_dev=${!dev}
2040 module_loaded lustre || load_modules
2044 if dm_flakey_supported $facet; then
2045 dm_dev=$(dm_create_dev $facet ${!dev})
2046 [[ -n "$dm_dev" ]] || dm_dev=${!dev}
2049 is_blkdev $facet $dm_dev || opts=$(csa_add "$opts" -o loop)
2051 devicelabel=$(do_facet ${facet} "$E2LABEL $dm_dev");;
2053 # import ZFS storage pool
2054 import_zpool $facet || return ${PIPESTATUS[0]}
2056 devicelabel=$(do_facet ${facet} "$ZFS get -H -o value \
2057 lustre:svname $dm_dev");;
2059 error "unknown fstype!";;
2062 echo "Starting ${facet}: $opts $dm_dev $mntpt"
2063 # for testing LU-482 error handling in mount_facets() and test_0a()
2064 if [ -f $TMP/test-lu482-trigger ]; then
2068 "mkdir -p $mntpt; $MOUNT_CMD $opts $dm_dev $mntpt"
2072 if [ $RC -ne 0 ]; then
2073 echo "Start of $dm_dev on ${facet} failed ${RC}"
2077 health=$(do_facet ${facet} "$LCTL get_param -n health_check")
2078 if [[ "$health" != "healthy" ]]; then
2079 error "$facet is in a unhealthy state"
2082 set_default_debug_facet $facet
2084 if [[ $opts =~ .*nosvc.* ]]; then
2085 echo "Start $dm_dev without service"
2090 wait_update_facet ${facet} "$E2LABEL $dm_dev \
2091 2>/dev/null | grep -E ':[a-zA-Z]{3}[0-9]{4}'" \
2092 "" || error "$dm_dev failed to initialize!";;
2094 wait_update_facet ${facet} "$ZFS get -H -o value \
2095 lustre:svname $dm_dev 2>/dev/null | \
2096 grep -E ':[a-zA-Z]{3}[0-9]{4}'" "" ||
2097 error "$dm_dev failed to initialize!";;
2100 error "unknown fstype!";;
2104 # commit the device label change to disk
2105 if [[ $devicelabel =~ (:[a-zA-Z]{3}[0-9]{4}) ]]; then
2106 echo "Commit the device label on ${!dev}"
2107 do_facet $facet "sync; sleep 1; sync"
2111 label=$(devicelabel ${facet} $dm_dev)
2112 [ -z "$label" ] && echo no label for $dm_dev && exit 1
2113 eval export ${facet}_svc=${label}
2114 echo Started ${label}
2116 export_dm_dev $facet $dm_dev
2121 # start facet device options
2127 local dev_alias=$(facet_device_alias $facet)
2129 eval export ${dev_alias}_dev=${device}
2130 eval export ${facet}_opt=\"$@\"
2132 local varname=${dev_alias}failover_dev
2133 if [ -n "${!varname}" ] ; then
2134 eval export ${dev_alias}failover_dev=${!varname}
2136 eval export ${dev_alias}failover_dev=$device
2139 local mntpt=$(facet_mntpt $facet)
2140 do_facet ${facet} mkdir -p $mntpt
2141 eval export ${facet}_MOUNT=$mntpt
2142 mount_facet ${facet}
2152 local HOST=$(facet_active_host $facet)
2153 [[ -z $HOST ]] && echo stop: no host for $facet && return 0
2155 local mntpt=$(facet_mntpt $facet)
2156 running=$(do_facet ${facet} "grep -c $mntpt' ' /proc/mounts || true")
2157 if [ ${running} -ne 0 ]; then
2158 echo "Stopping $mntpt (opts:$@) on $HOST"
2159 do_facet ${facet} $UMOUNT $@ $mntpt
2162 # umount should block, but we should wait for unrelated obd's
2163 # like the MGS or MGC to also stop.
2164 wait_exit_ST ${facet} || return ${PIPESTATUS[0]}
2166 if [[ $(facet_fstype $facet) == zfs ]]; then
2167 # export ZFS storage pool
2168 [ "$KEEP_ZPOOL" = "true" ] || export_zpool $facet
2169 elif dm_flakey_supported $facet; then
2170 local host=${facet}_HOST
2171 local failover_host=${facet}failover_HOST
2172 if [[ -n ${!failover_host} && ${!failover_host} != ${!host} ]]||
2173 $CLEANUP_DM_DEV || [[ $facet = fs* ]]; then
2174 dm_cleanup_dev $facet
2179 # get mdt quota type
2181 local varsvc=${SINGLEMDS}_svc
2182 do_facet $SINGLEMDS $LCTL get_param -n \
2183 osd-$(facet_fstype $SINGLEMDS).${!varsvc}.quota_slave.enabled
2186 # get ost quota type
2188 # All OSTs should have same quota type
2189 local varsvc=ost1_svc
2190 do_facet ost1 $LCTL get_param -n \
2191 osd-$(facet_fstype ost1).${!varsvc}.quota_slave.enabled
2194 # restore old quota type settings
2196 if [ "$old_MDT_QUOTA_TYPE" ]; then
2197 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2198 do_facet mgs $PERM_CMD \
2199 osd-*.$FSNAME-MDT*.quota_slave.enable = \
2202 do_facet mgs $PERM_CMD \
2203 $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
2206 if [ "$old_OST_QUOTA_TYPE" ]; then
2207 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2208 do_facet mgs $PERM_CMD \
2209 osd-*.$FSNAME-OST*.quota_slave.enable = \
2212 do_facet mgs $LCTL conf_param \
2213 $FSNAME.quota.ost=$old_OST_QUOTA_TYPE
2218 # Handle the case when there is a space in the lfs df
2219 # "filesystem summary" line the same as when there is no space.
2220 # This will allow fixing the "lfs df" summary line in the future.
2222 $LFS df $* | sed -e 's/filesystem /filesystem_/'
2225 # Get free inodes on the MDT specified by mdt index, free indoes on
2226 # the whole filesystem will be returned when index == -1.
2232 if [ $index -eq -1 ]; then
2235 mdt_uuid=$(mdtuuid_from_index $index)
2238 free_inodes=$(lfs_df -i $MOUNT | grep $mdt_uuid | awk '{print $4}')
2243 # Get the OST device status from 'lfs df' with a given OST index.
2247 local mnt_pnt=${2:-$MOUNT}
2251 ost_uuid=$(ostuuid_from_index $ost_idx $mnt_pnt)
2252 lfs_df $opts $mnt_pnt | awk '/'$ost_uuid'/ { print $7 }'
2258 # save old quota type & set new quota type
2259 local mdt_qtype=$(mdt_quota_type)
2260 local ost_qtype=$(ost_quota_type)
2262 echo "[HOST:$HOSTNAME] [old_mdt_qtype:$mdt_qtype]" \
2263 "[old_ost_qtype:$ost_qtype] [new_qtype:$QUOTA_TYPE]"
2265 export old_MDT_QUOTA_TYPE=$mdt_qtype
2266 export old_OST_QUOTA_TYPE=$ost_qtype
2268 if [[ $PERM_CMD == *"set_param -P"* ]]; then
2269 do_facet mgs $PERM_CMD \
2270 osd-*.$FSNAME-MDT*.quota_slave.enable=$QUOTA_TYPE
2271 do_facet mgs $PERM_CMD \
2272 osd-*.$FSNAME-OST*.quota_slave.enable=$QUOTA_TYPE
2274 do_facet mgs $PERM_CMD $FSNAME.quota.mdt=$QUOTA_TYPE ||
2275 error "set mdt quota type failed"
2276 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$QUOTA_TYPE ||
2277 error "set ost quota type failed"
2280 local quota_usrs=$QUOTA_USERS
2282 # get_filesystem_size
2283 local disksz=$(lfs_df $mntpt | grep "summary" | awk '{print $2}')
2284 local blk_soft=$((disksz + 1024))
2285 local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
2287 local inodes=$(lfs_df -i $mntpt | grep "summary" | awk '{print $2}')
2288 local i_soft=$inodes
2289 local i_hard=$((i_soft + i_soft / 20))
2291 echo "Total disk size: $disksz block-softlimit: $blk_soft" \
2292 "block-hardlimit: $blk_hard inode-softlimit: $i_soft" \
2293 "inode-hardlimit: $i_hard"
2296 for usr in $quota_usrs; do
2297 echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
2299 cmd="$LFS setquota -$type $usr -b $blk_soft"
2300 cmd="$cmd -B $blk_hard -i $i_soft -I $i_hard $mntpt"
2302 eval $cmd || error "$cmd FAILED!"
2304 # display the quota status
2305 echo "Quota settings for $usr : "
2306 $LFS quota -v -u $usr $mntpt || true
2313 local opts=${3:-$MOUNT_OPTS}
2314 opts=${opts:+-o $opts}
2315 local flags=${4:-$MOUNT_FLAGS}
2317 local device=$MGSNID:/$FSNAME$FILESET
2318 if [ -z "$mnt" -o -z "$FSNAME" ]; then
2319 echo "Bad mount command: opt=$flags $opts dev=$device " \
2325 # update mount option with skpath
2326 opts=$(add_sk_mntflag $opts)
2329 echo "Starting client: $client: $flags $opts $device $mnt"
2330 do_node $client mkdir -p $mnt
2331 if [ -n "$FILESET" -a -z "$SKIP_FILESET" ];then
2332 do_node $client $MOUNT_CMD $flags $opts $MGSNID:/$FSNAME \
2334 #disable FILESET if not supported
2335 do_nodes $client lctl get_param -n \
2336 mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
2337 device=$MGSNID:/$FSNAME
2338 do_node $client mkdir -p $mnt/$FILESET
2339 do_node $client "! grep -q $mnt' ' /proc/mounts ||
2342 if $GSS_SK && ($SK_UNIQUE_NM || $SK_S2S); then
2343 # Mount using nodemap key
2344 local mountkey=$SK_PATH/$FSNAME-nmclient.key
2345 if $SK_UNIQUE_NM; then
2346 mountkey=$SK_PATH/nodemap/c0.key
2348 local prunedopts=$(echo $opts |
2349 sed -e "s#skpath=[^,^ ]*#skpath=$mountkey#g")
2350 do_node $client $MOUNT_CMD $flags $prunedopts $device $mnt ||
2353 do_node $client $MOUNT_CMD $flags $opts $device $mnt ||
2357 set_default_debug_nodes $client
2358 set_params_clients $client
2369 local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
2371 [ "$3" ] && force=-f
2372 [ $running -eq 0 ] && return 0
2374 echo "Stopping client $client $mnt (opts:$force)"
2375 do_node $client lsof -t $mnt || need_kill=no
2376 if [ "x$force" != "x" ] && [ "x$need_kill" != "xno" ]; then
2377 pids=$(do_node $client lsof -t $mnt | sort -u);
2378 if [ -n "$pids" ]; then
2379 do_node $client kill -9 $pids || true
2383 busy=$(do_node $client "umount $force $mnt 2>&1" | grep -c "busy") ||
2385 if [ $busy -ne 0 ] ; then
2386 echo "$mnt is still busy, wait one second" && sleep 1
2387 do_node $client umount $force $mnt
2391 # Mount the file system on the MDS
2392 mount_mds_client() {
2393 local mds_HOST=${SINGLEMDS}_HOST
2395 zconf_mount $mds1_HOST $MOUNT2 $MOUNT_OPTS ||
2396 error "unable to mount $MOUNT2 on MDS"
2399 # Unmount the file system on the MDS
2400 umount_mds_client() {
2401 local mds_HOST=${SINGLEMDS}_HOST
2402 zconf_umount $mds1_HOST $MOUNT2
2403 do_facet $SINGLEMDS "rmdir $MOUNT2"
2406 # nodes is comma list
2407 sanity_mount_check_nodes () {
2413 # FIXME: assume that all cluster nodes run the same os
2414 [ "$(uname)" = Linux ] || return 0
2417 for mnt in $mnts ; do
2418 do_nodes $nodes "running=\\\$(grep -c $mnt' ' /proc/mounts);
2419 mpts=\\\$(mount | grep -c $mnt' ');
2420 if [ \\\$running -ne \\\$mpts ]; then
2421 echo \\\$(hostname) env are INSANE!;
2424 [ $? -eq 0 ] || rc=1
2429 sanity_mount_check_servers () {
2430 [ -n "$CLIENTONLY" ] &&
2431 { echo "CLIENTONLY mode, skip mount_check_servers"; return 0; } || true
2432 echo Checking servers environments
2434 # FIXME: modify get_facets to display all facets wo params
2435 local facets="$(get_facets OST),$(get_facets MDS),mgs"
2439 for facet in ${facets//,/ }; do
2440 node=$(facet_host ${facet})
2441 mntpt=$(facet_mntpt $facet)
2442 sanity_mount_check_nodes $node $mntpt ||
2443 { error "server $node environments are insane!"; return 1; }
2447 sanity_mount_check_clients () {
2448 local clients=${1:-$CLIENTS}
2449 local mntpt=${2:-$MOUNT}
2450 local mntpt2=${3:-$MOUNT2}
2452 [ -z $clients ] && clients=$(hostname)
2453 echo Checking clients $clients environments
2455 sanity_mount_check_nodes $clients $mntpt $mntpt2 ||
2456 error "clients environments are insane!"
2459 sanity_mount_check () {
2460 sanity_mount_check_servers || return 1
2461 sanity_mount_check_clients || return 2
2464 # mount clients if not mouted
2465 zconf_mount_clients() {
2468 local opts=${3:-$MOUNT_OPTS}
2469 opts=${opts:+-o $opts}
2470 local flags=${4:-$MOUNT_FLAGS}
2471 local device=$MGSNID:/$FSNAME$FILESET
2472 if [ -z "$mnt" -o -z "$FSNAME" ]; then
2473 echo "Bad conf mount command: opt=$flags $opts dev=$device " \
2478 echo "Starting client $clients: $flags $opts $device $mnt"
2479 do_nodes $clients mkdir -p $mnt
2480 if [ -n "$FILESET" -a -z "$SKIP_FILESET" ]; then
2481 if $GSS_SK && ($SK_UNIQUE_NM || $SK_S2S); then
2482 # Mount with own nodemap key
2484 # Mount all server nodes first with per-NM keys
2485 for nmclient in ${clients//,/ }; do
2486 # do_nodes $(comma_list $(all_server_nodes)) "lgss_sk -t server -l $SK_PATH/nodemap/c$i.key -n c$i"
2487 do_nodes $(comma_list $(all_server_nodes)) "lgss_sk -t server -l $SK_PATH/nodemap/c$i.key"
2490 # set perms for per-nodemap keys else permission denied
2491 do_nodes $(comma_list $(all_nodes)) \
2492 "keyctl show | grep lustre | cut -c1-11 |
2494 xargs -IX keyctl setperm X 0x3f3f3f3f"
2495 local mountkey=$SK_PATH/$FSNAME-nmclient.key
2497 for nmclient in ${clients//,/ }; do
2498 if $SK_UNIQUE_NM; then
2499 mountkey=$SK_PATH/nodemap/c$i.key
2501 do_node $nmclient "! grep -q $mnt' ' \
2502 /proc/mounts || umount $mnt"
2503 local prunedopts=$(add_sk_mntflag $prunedopts);
2504 prunedopts=$(echo $prunedopts | sed -e \
2505 "s#skpath=[^ ^,]*#skpath=$mountkey#g")
2507 do_nodes $(comma_list $(all_server_nodes)) \
2510 do_node $nmclient $MOUNT_CMD $flags \
2511 $prunedopts $MGSNID:/$FSNAME $mnt ||
2516 do_nodes $clients "! grep -q $mnt' ' /proc/mounts ||
2518 do_nodes $clients $MOUNT_CMD $flags $opts \
2519 $MGSNID:/$FSNAME $mnt || return 1
2521 #disable FILESET if not supported
2522 do_nodes $clients lctl get_param -n \
2523 mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
2524 device=$MGSNID:/$FSNAME
2525 do_nodes $clients mkdir -p $mnt/$FILESET
2526 do_nodes $clients "! grep -q $mnt' ' /proc/mounts ||
2530 if $GSS_SK && ($SK_UNIQUE_NM || $SK_S2S); then
2531 # Mount with nodemap key
2533 local mountkey=$SK_PATH/$FSNAME-nmclient.key
2534 for nmclient in ${clients//,/ }; do
2535 if $SK_UNIQUE_NM; then
2536 mountkey=$SK_PATH/nodemap/c$i.key
2538 local prunedopts=$(echo $opts | sed -e \
2539 "s#skpath=[^ ^,]*#skpath=$mountkey#g");
2540 do_node $nmclient "! grep -q $mnt' ' /proc/mounts ||
2543 running=\\\$(mount | grep -c $mnt' ');
2545 if [ \\\$running -eq 0 ] ; then
2547 $MOUNT_CMD $flags $prunedopts $device $mnt;
2550 lustre_mnt_count=\\\$(mount | grep $mnt' ' | \
2551 grep 'type lustre' | wc -l);
2552 if [ \\\$running -ne \\\$lustre_mnt_count ] ; then
2553 echo zconf_mount_clients FAILED: \
2554 mount count \\\$running, not matching \
2555 with mount count of 'type lustre' \
2556 \\\$lustre_mnt_count;
2560 exit \\\$rc" || return ${PIPESTATUS[0]}
2567 if $SHARED_KEY; then
2568 tmpopts=$(add_sk_mntflag $opts)
2571 running=\\\$(mount | grep -c $mnt' ');
2573 if [ \\\$running -eq 0 ] ; then
2575 $MOUNT_CMD $flags $tmpopts $device $mnt;
2578 exit \\\$rc" || return ${PIPESTATUS[0]}
2581 echo "Started clients $clients: "
2582 do_nodes $clients "mount | grep $mnt' '"
2584 set_default_debug_nodes $clients
2585 set_params_clients $clients
2590 zconf_umount_clients() {
2595 [ "$3" ] && force=-f
2597 echo "Stopping clients: $clients $mnt (opts:$force)"
2598 do_nodes $clients "running=\\\$(grep -c $mnt' ' /proc/mounts);
2599 if [ \\\$running -ne 0 ] ; then
2600 echo Stopping client \\\$(hostname) $mnt opts:$force;
2601 lsof $mnt || need_kill=no;
2602 if [ "x$force" != "x" -a "x\\\$need_kill" != "xno" ]; then
2603 pids=\\\$(lsof -t $mnt | sort -u);
2604 if [ -n \\\"\\\$pids\\\" ]; then
2608 while umount $force $mnt 2>&1 | grep -q "busy"; do
2609 echo "$mnt is still busy, wait one second" && sleep 1;
2616 echo + $POWER_DOWN $node
2620 shutdown_node_hard () {
2622 local attempts=$SHUTDOWN_ATTEMPTS
2624 for i in $(seq $attempts) ; do
2627 wait_for_function --quiet "! ping -w 3 -c 1 $host" 5 1 && return 0
2628 echo "waiting for $host to fail attempts=$attempts"
2629 [ $i -lt $attempts ] || \
2630 { echo "$host still pingable after power down! attempts=$attempts" && return 1; }
2636 local mnt=${2:-$MOUNT}
2639 if [ "$FAILURE_MODE" = HARD ]; then
2640 shutdown_node_hard $client
2642 zconf_umount_clients $client $mnt -f
2648 local facets="$(get_facets OST),$(get_facets MDS)"
2651 combined_mgs_mds || facets="$facets,mgs"
2653 for facet in ${facets//,/ }; do
2654 if [ $(facet_active_host $facet) == $host ]; then
2655 affected="$affected $facet"
2659 echo $(comma_list $affected)
2664 local host=${2:-$(facet_host $facet)}
2666 local label=$(convert_facet2label $facet)
2667 do_node $host $LCTL dl | awk '{ print $4 }' | grep -q "^$label\$"
2670 facets_up_on_host () {
2672 local facets=$(facets_on_host $host)
2675 for facet in ${facets//,/ }; do
2676 if $(facet_up $facet $host); then
2677 affected_up="$affected_up $facet"
2681 echo $(comma_list $affected_up)
2686 local affected_facet
2687 local affected_facets
2689 if [[ "$FAILURE_MODE" = HARD ]]; then
2690 if [[ $(facet_fstype $facet) = ldiskfs ]] &&
2691 dm_flakey_supported $facet; then
2692 affected_facets=$(affected_facets $facet)
2693 for affected_facet in ${affected_facets//,/ }; do
2694 unexport_dm_dev $affected_facet
2698 shutdown_node_hard $(facet_active_host $facet)
2706 echo + $POWER_UP $node
2719 local node=$(facet_active_host $facet)
2721 if [ "$FAILURE_MODE" = HARD ]; then
2731 if [ "$FAILURE_MODE" = HARD ]; then
2734 if $LOAD_MODULES_REMOTE; then
2735 echo "loading modules on $node: $facet"
2736 do_rpc_nodes $node load_modules_local
2745 for facet in ${facets//,/ }; do
2746 hosts=$(expand_list $hosts $(facet_host $facet) )
2752 _check_progs_installed () {
2756 for prog in $progs; do
2757 if ! [ "$(which $prog)" -o "${!prog}" ]; then
2758 echo $prog missing on $(hostname)
2765 check_progs_installed () {
2769 do_rpc_nodes "$nodes" _check_progs_installed $@
2772 # recovery-scale functions
2774 echo __$(echo $1 | tr '-' '_' | tr '.' '_')
2777 start_client_load() {
2780 local var=$(node_var_name $client)_load
2781 eval export ${var}=$load
2783 do_node $client "PATH=$PATH MOUNT=$MOUNT ERRORS_OK=$ERRORS_OK \
2784 BREAK_ON_ERROR=$BREAK_ON_ERROR \
2785 END_RUN_FILE=$END_RUN_FILE \
2786 LOAD_PID_FILE=$LOAD_PID_FILE \
2787 TESTLOG_PREFIX=$TESTLOG_PREFIX \
2788 TESTNAME=$TESTNAME \
2789 DBENCH_LIB=$DBENCH_LIB \
2790 DBENCH_SRC=$DBENCH_SRC \
2791 CLIENT_COUNT=$((CLIENTCOUNT - 1)) \
2796 MPIRUN_OPTIONS=\\\"$MPIRUN_OPTIONS\\\" \
2797 MACHINEFILE_OPTION=\\\"$MACHINEFILE_OPTION\\\" \
2798 num_clients=$(get_node_count ${CLIENTS//,/ }) \
2799 ior_THREADS=$ior_THREADS ior_iteration=$ior_iteration \
2800 ior_blockSize=$ior_blockSize \
2801 ior_blockUnit=$ior_blockUnit \
2802 ior_xferSize=$ior_xferSize ior_type=$ior_type \
2803 ior_DURATION=$ior_DURATION \
2804 ior_stripe_params=\\\"$ior_stripe_params\\\" \
2805 ior_custom_params=\\\"$ior_custom_param\\\" \
2806 mpi_ior_custom_threads=$mpi_ior_custom_threads \
2809 log "Started client load: ${load} on $client"
2811 # get the children process IDs
2812 local pids=$(ps --ppid $ppid -o pid= | xargs)
2813 CLIENT_LOAD_PIDS="$CLIENT_LOAD_PIDS $ppid $pids"
2817 start_client_loads () {
2818 local -a clients=(${1//,/ })
2819 local numloads=${#CLIENT_LOADS[@]}
2821 for ((nodenum=0; nodenum < ${#clients[@]}; nodenum++ )); do
2822 local load=$((nodenum % numloads))
2823 start_client_load ${clients[nodenum]} ${CLIENT_LOADS[load]}
2825 # bug 22169: wait the background threads to start
2829 # only for remote client
2830 check_client_load () {
2832 local var=$(node_var_name $client)_load
2833 local testload=run_${!var}.sh
2835 ps auxww | grep -v grep | grep $client | grep -q $testload || return 1
2837 # bug 18914: try to connect several times not only when
2838 # check ps, but while check_node_health also
2842 while [ $RC = 254 -a $tries -gt 0 ]; do
2846 if ! check_node_health $client; then
2848 if [ $RC -eq 254 ]; then
2849 # FIXME: not sure how long we shuold sleep here
2853 echo "check node health failed: RC=$RC "
2857 # We can continue try to connect if RC=254
2858 # Just print the warning about this
2859 if [ $RC = 254 ]; then
2860 echo "got a return status of $RC from do_node while checking " \
2861 "node health on $client"
2864 # see if the load is still on the client
2867 while [ $RC = 254 -a $tries -gt 0 ]; do
2871 if ! do_node $client \
2872 "ps auxwww | grep -v grep | grep -q $testload"; then
2877 if [ $RC = 254 ]; then
2878 echo "got a return status of $RC from do_node while checking " \
2879 "(node health and 'ps') the client load on $client"
2880 # see if we can diagnose a bit why this is
2885 check_client_loads () {
2886 local clients=${1//,/ }
2890 for client in $clients; do
2891 check_client_load $client
2893 if [ "$rc" != 0 ]; then
2894 log "Client load failed on node $client, rc=$rc"
2900 restart_client_loads () {
2901 local clients=${1//,/ }
2902 local expectedfail=${2:-""}
2906 for client in $clients; do
2907 check_client_load $client
2909 if [ "$rc" != 0 -a "$expectedfail" ]; then
2910 local var=$(node_var_name $client)_load
2911 start_client_load $client ${!var}
2912 echo "Restarted client load ${!var}: on $client. Checking ..."
2913 check_client_load $client
2915 if [ "$rc" != 0 ]; then
2916 log "Client load failed to restart on node $client, rc=$rc"
2917 # failure one client load means test fail
2918 # we do not need to check other
2927 # Start vmstat and save its process ID in a file.
2932 [ -z "$nodes" -o -z "$pid_file" ] && return 0
2935 "vmstat 1 > $TESTLOG_PREFIX.$TESTNAME.vmstat.\\\$(hostname -s).log \
2936 2>/dev/null </dev/null & echo \\\$! > $pid_file"
2939 # Display the nodes on which client loads failed.
2940 print_end_run_file() {
2944 [ -s $file ] || return 0
2946 echo "Found the END_RUN_FILE file: $file"
2949 # A client load will stop if it finds the END_RUN_FILE file.
2950 # That does not mean the client load actually failed though.
2951 # The first node in END_RUN_FILE is the one we are interested in.
2954 if [ -n "$node" ]; then
2955 local var=$(node_var_name $node)_load
2957 local prefix=$TESTLOG_PREFIX
2958 [ -n "$TESTNAME" ] && prefix=$prefix.$TESTNAME
2959 local stdout_log=$prefix.run_${!var}_stdout.$node.log
2960 local debug_log=$(echo $stdout_log | sed 's/\(.*\)stdout/\1debug/')
2962 echo "Client load ${!var} failed on node $node:"
2968 # Stop the process which had its PID saved in a file.
2973 [ -z "$nodes" -o -z "$pid_file" ] && return 0
2975 do_nodes $nodes "test -f $pid_file &&
2976 { kill -s TERM \\\$(cat $pid_file); rm -f $pid_file; }" || true
2979 # Stop all client loads.
2980 stop_client_loads() {
2981 local nodes=${1:-$CLIENTS}
2984 # stop the client loads
2985 stop_process $nodes $pid_file
2987 # clean up the processes that started them
2988 [ -n "$CLIENT_LOAD_PIDS" ] && kill -9 $CLIENT_LOAD_PIDS 2>/dev/null || true
2990 # End recovery-scale functions
2992 # verify that lustre actually cleaned up properly
2994 VAR=$(lctl get_param -n catastrophe 2>&1)
2995 if [ $? = 0 ] ; then
2996 if [ $VAR != 0 ]; then
2997 error "LBUG/LASSERT detected"
3000 BUSY=$(dmesg | grep -i destruct || true)
3001 if [ -n "$BUSY" ]; then
3003 [ -e $TMP/debug ] && mv $TMP/debug $TMP/debug-busy.$(date +%s)
3007 check_mem_leak || exit 204
3009 [[ $($LCTL dl 2>/dev/null | wc -l) -gt 0 ]] && $LCTL dl &&
3010 echo "$TESTSUITE: lustre didn't clean up..." 1>&2 &&
3013 if module_loaded lnet || module_loaded libcfs; then
3014 echo "$TESTSUITE: modules still loaded..." 1>&2
3022 # wait for a command to return the expected result
3024 # This will run @check on @node repeatedly until the output matches @expect
3025 # based on the supplied condition, or until @max_wait seconds have elapsed,
3026 # whichever comes first. @cond may be one of the normal bash operators,
3027 # "-gt", "-ge", "-eq", "-le", "-lt", "==", "!=", or "=~", and must be quoted
3028 # in the caller to avoid unintentional evaluation by the shell in the caller.
3030 # If @max_wait is not specified, the condition will be checked for up to 90s.
3032 # If --verbose is passed as the first argument, the result is printed on each
3033 # value change, otherwise it is only printed after every 10s interval.
3035 # Using wait_update_cond() or related helper function is preferable to adding
3036 # a "long enough" wait for some state to change in the background, since
3037 # "long enough" may be too short due to tunables, system config, or running in
3038 # a VM, and must by necessity wait too long for most cases or risk failure.
3040 # usage: wait_update_cond [--verbose] node check cond expect [max_wait]
3041 wait_update_cond() {
3043 [[ "$1" == "--verbose" ]] && verbose=true && shift
3049 local max_wait=${5:-90}
3053 local begin=$SECONDS
3057 while (( $waited <= $max_wait )); do
3058 result=$(do_node $node "$check")
3060 eval [[ "'$result'" $cond "'$expect'" ]]
3061 if [[ $? == 0 ]]; then
3062 [[ -z "$result" || $waited -le $sleep ]] ||
3063 echo "Updated after ${waited}s: want '$expect' got '$result'"
3066 if $verbose && [[ "$result" != "$prev_result" ]]; then
3067 [[ -n "$prev_result" ]] &&
3068 echo "Changed after ${waited}s: from '$prev_result' to '$result'"
3069 prev_result="$result"
3071 (( $waited % $print == 0 )) &&
3072 echo "Waiting $((max_wait - waited))s for '$expect'"
3074 waited=$((SECONDS - begin))
3076 echo "Update not seen after ${max_wait}s: want '$expect' got '$result'"
3080 # usage: wait_update [--verbose] node check expect [max_wait]
3083 [ "$1" = "--verbose" ] && verbose="$1" && shift
3090 wait_update_cond $verbose $node "$check" "==" "$expect" $max_wait
3093 # usage: wait_update_facet_cond [--verbose] facet check cond expect [max_wait]
3094 wait_update_facet_cond() {
3096 [ "$1" = "--verbose" ] && verbose="$1" && shift
3098 local node=$(facet_active_host $1)
3104 wait_update_cond $verbose $node "$check" "$cond" "$expect" $max_wait
3107 # usage: wait_update_facet [--verbose] facet check expect [max_wait]
3108 wait_update_facet() {
3110 [ "$1" = "--verbose" ] && verbose="$1" && shift
3112 local node=$(facet_active_host $1)
3117 wait_update_cond $verbose $node "$check" "==" "$expect" $max_wait
3121 do_nodes $(comma_list $(mdts_nodes)) \
3122 "lctl set_param -n os[cd]*.*MDT*.force_sync=1"
3123 do_nodes $(comma_list $(osts_nodes)) \
3124 "lctl set_param -n osd*.*OS*.force_sync=1" 2>&1 |
3125 grep -v 'Found no match'
3129 local zfs_wait=${2:-5}
3131 # the occupied disk space will be released
3132 # only after TXGs are committed
3133 if [[ $(facet_fstype $1) == zfs ]]; then
3134 echo "sleep $zfs_wait for ZFS $(facet_fstype $1)"
3142 local lwm=$3 #low watermark
3143 local size_mb #how many MB should we write to pass watermark
3144 local ost_name=$(ostname_from_index $ost_idx)
3146 free_kb=$($LFS df $MOUNT | awk "/$ost_name/ { print \$4 }")
3148 if (( $free_kb / 1024 > lwm )); then
3149 size_mb=$((free_kb / 1024 - lwm))
3151 #If 10% of free space cross low watermark use it
3152 if (( $free_kb / 10240 > size_mb )); then
3153 size_mb=$((free_kb / 10240))
3155 #At least we need to store 1.1 of difference between
3156 #free space and low watermark
3157 size_mb=$((size_mb + size_mb / 10))
3159 if (( lwm <= $free_kb / 1024 )) ||
3160 [ ! -f $DIR/${filename}.fill_ost$ost_idx ]; then
3161 $LFS setstripe -i $ost_idx -c1 $DIR/${filename}.fill_ost$ost_idx
3162 dd if=/dev/zero of=$DIR/${filename}.fill_ost$ost_idx bs=1M \
3163 count=$size_mb oflag=append conv=notrunc
3168 free_kb=$($LFS df $MOUNT | awk "/$ost_name/ { print \$4 }")
3169 echo "OST still has $((free_kb / 1024)) MB free"
3172 # This checks only the primary MDS
3173 ost_watermarks_get() {
3175 local ost_name=$(ostname_from_index $ost_idx)
3176 local mdtosc_proc=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
3178 local hwm=$(do_facet $SINGLEMDS $LCTL get_param -n \
3179 osp.$mdtosc_proc.reserved_mb_high)
3180 local lwm=$(do_facet $SINGLEMDS $LCTL get_param -n \
3181 osp.$mdtosc_proc.reserved_mb_low)
3186 # Note that we set watermarks on all MDSes (necessary for striped dirs)
3187 ost_watermarks_set() {
3191 local ost_name=$(ostname_from_index $ost_idx)
3192 local facets=$(get_facets MDS)
3194 do_nodes $(comma_list $(mdts_nodes)) $LCTL set_param -n \
3195 osp.*$ost_name*.reserved_mb_low=$lwm \
3196 osp.*$ost_name*.reserved_mb_high=$hwm > /dev/null
3198 # sleep to ensure we see the change
3202 ost_watermarks_set_low_space() {
3204 local wms=$(ost_watermarks_get $ost_idx)
3205 local ost_name=$(ostname_from_index $ost_idx)
3207 local old_lwm=$(echo $wms | awk '{ print $1 }')
3208 local old_hwm=$(echo $wms | awk '{ print $2 }')
3210 local blocks=$($LFS df $MOUNT | awk "/$ost_name/ { print \$4 }")
3211 # minimal extension size is 64M
3213 if (( $blocks / 1024 > 50 )); then
3214 new_lwm=$((blocks / 1024 - 50))
3216 local new_hwm=$((new_lwm + 5))
3218 ost_watermarks_set $ost_idx $new_lwm $new_hwm
3219 echo "watermarks: $old_lwm $old_hwm $new_lwm $new_hwm"
3222 # Set watermarks to ~current available space & then write data to fill it
3223 # Note OST is not *actually* full after this, it just reports ENOSPC in the
3224 # internal statfs used by the stripe allocator
3226 # first parameter is the filename-prefix, which must get under t-f cleanup
3227 # requirements (rm -rf $DIR/[Rdfs][0-9]*), i.e. $tfile work fine
3228 ost_watermarks_set_enospc() {
3232 local ost_name=$(ostname_from_index $ost_idx)
3233 local facets=$(get_facets MDS)
3237 for MDS in ${facets//,/ }; do
3238 local mdtosc_proc=$(get_mdtosc_proc_path $MDS $ost_name)
3240 do_facet $MDS $LCTL get_param -n \
3241 osp.$mdtosc_proc.reserved_mb_high ||
3242 skip "remote MDS does not support reserved_mb_high"
3245 wms=$(ost_watermarks_set_low_space $ost_idx)
3246 local new_lwm=$(echo $wms | awk '{ print $4 }')
3247 fill_ost $filename $ost_idx $new_lwm
3248 #First enospc could execute orphan deletion so repeat
3249 fill_ost $filename $ost_idx $new_lwm
3253 ost_watermarks_enospc_delete_files() {
3257 rm -f $DIR/${filename}.fill_ost$ost_idx
3259 wait_delete_completed
3263 # clean up from "ost_watermarks_set_enospc"
3264 ost_watermarks_clear_enospc() {
3270 ost_watermarks_enospc_delete_files $filename $ost_idx
3271 ost_watermarks_set $ost_idx $old_lwm $old_hwm
3272 echo "set OST$ost_idx lwm back to $old_lwm, hwm back to $old_hwm"
3275 wait_delete_completed_mds() {
3276 local max_wait=${1:-20}