2016-03-25 22:40:58 +03:00
|
|
|
#!/bin/bash
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# CDDL HEADER START
|
|
|
|
#
|
|
|
|
# This file and its contents are supplied under the terms of the
|
|
|
|
# Common Development and Distribution License ("CDDL"), version 1.0.
|
|
|
|
# You may only use this file in accordance with the terms of version
|
|
|
|
# 1.0 of the CDDL.
|
|
|
|
#
|
|
|
|
# A full copy of the text of the CDDL should have accompanied this
|
|
|
|
# source. A copy of the CDDL is also available via the Internet at
|
|
|
|
# http://www.illumos.org/license/CDDL.
|
|
|
|
#
|
|
|
|
# CDDL HEADER END
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
# Copyright (c) 2015 by Delphix. All rights reserved.
|
|
|
|
# Copyright (C) 2016 Lawrence Livermore National Security, LLC.
|
|
|
|
#
|
|
|
|
|
Retire legacy test infrastructure
* Removed zpios kmod, utility, headers and man page.
* Removed unused scripts zpios-profile/*, zpios-test/*,
zpool-config/*, smb.sh, zpios-sanity.sh, zpios-survey.sh,
zpios.sh, and zpool-create.sh.
* Removed zfs-script-config.sh.in. When building 'make' generates
a common.sh with in-tree path information from the common.sh.in
template. This file and sourced by the test scripts and used
for in-tree testing, it is not included in the packages. When
building packages 'make install' uses the same template to
create a new common.sh which is appropriate for the packaging.
* Removed unused functions/variables from scripts/common.sh.in.
Only minimal path information and configuration environment
variables remain.
* Removed unused scripts from scripts/ directory.
* Remaining shell scripts in the scripts directory updated to
cleanly pass shellcheck and added to checked scripts.
* Renamed tests/test-runner/cmd/ to tests/test-runner/bin/ to
match install location name.
* Removed last traces of the --enable-debug-dmu-tx configure
options which was retired some time ago.
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6509
2017-08-16 03:26:38 +03:00
|
|
|
BASE_DIR=$(dirname "$0")
|
2016-03-23 04:08:59 +03:00
|
|
|
SCRIPT_COMMON=common.sh
|
Retire legacy test infrastructure
* Removed zpios kmod, utility, headers and man page.
* Removed unused scripts zpios-profile/*, zpios-test/*,
zpool-config/*, smb.sh, zpios-sanity.sh, zpios-survey.sh,
zpios.sh, and zpool-create.sh.
* Removed zfs-script-config.sh.in. When building 'make' generates
a common.sh with in-tree path information from the common.sh.in
template. This file and sourced by the test scripts and used
for in-tree testing, it is not included in the packages. When
building packages 'make install' uses the same template to
create a new common.sh which is appropriate for the packaging.
* Removed unused functions/variables from scripts/common.sh.in.
Only minimal path information and configuration environment
variables remain.
* Removed unused scripts from scripts/ directory.
* Remaining shell scripts in the scripts directory updated to
cleanly pass shellcheck and added to checked scripts.
* Renamed tests/test-runner/cmd/ to tests/test-runner/bin/ to
match install location name.
* Removed last traces of the --enable-debug-dmu-tx configure
options which was retired some time ago.
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6509
2017-08-16 03:26:38 +03:00
|
|
|
if [ -f "${BASE_DIR}/${SCRIPT_COMMON}" ]; then
|
|
|
|
. "${BASE_DIR}/${SCRIPT_COMMON}"
|
2016-03-23 04:08:59 +03:00
|
|
|
else
|
|
|
|
echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
|
|
|
|
fi
|
|
|
|
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2034
|
2016-03-23 04:08:59 +03:00
|
|
|
PROG=zloop.sh
|
|
|
|
|
|
|
|
DEFAULTWORKDIR=/var/tmp
|
|
|
|
DEFAULTCOREDIR=/var/tmp/zloop
|
|
|
|
|
|
|
|
function usage
|
|
|
|
{
|
2017-10-13 22:39:39 +03:00
|
|
|
echo -e "\n$0 [-t <timeout>] [ -s <vdev size> ] [-c <dump directory>]" \
|
2016-03-23 04:08:59 +03:00
|
|
|
"[ -- [extra ztest parameters]]\n" \
|
|
|
|
"\n" \
|
|
|
|
" This script runs ztest repeatedly with randomized arguments.\n" \
|
|
|
|
" If a crash is encountered, the ztest logs, any associated\n" \
|
|
|
|
" vdev files, and core file (if one exists) are moved to the\n" \
|
|
|
|
" output directory ($DEFAULTCOREDIR by default). Any options\n" \
|
|
|
|
" after the -- end-of-options marker will be passed to ztest.\n" \
|
|
|
|
"\n" \
|
|
|
|
" Options:\n" \
|
|
|
|
" -t Total time to loop for, in seconds. If not provided,\n" \
|
|
|
|
" zloop runs forever.\n" \
|
2017-10-13 22:39:39 +03:00
|
|
|
" -s Size of vdev devices.\n" \
|
2016-03-23 04:08:59 +03:00
|
|
|
" -f Specify working directory for ztest vdev files.\n" \
|
|
|
|
" -c Specify a core dump directory to use.\n" \
|
|
|
|
" -h Print this help message.\n" \
|
|
|
|
"" >&2
|
|
|
|
}
|
|
|
|
|
|
|
|
function or_die
|
|
|
|
{
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2068
|
2016-03-23 04:08:59 +03:00
|
|
|
$@
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2181
|
2016-03-23 04:08:59 +03:00
|
|
|
if [[ $? -ne 0 ]]; then
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2145
|
2016-03-23 04:08:59 +03:00
|
|
|
echo "Command failed: $@"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-07-24 22:55:48 +03:00
|
|
|
# core file helpers
|
|
|
|
origcorepattern="$(cat /proc/sys/kernel/core_pattern)"
|
|
|
|
coreglob="$(egrep -o '^([^|%[:space:]]*)' /proc/sys/kernel/core_pattern)*"
|
|
|
|
|
|
|
|
if [[ $coreglob = "*" ]]; then
|
|
|
|
echo "Setting core file pattern..."
|
|
|
|
echo "core" > /proc/sys/kernel/core_pattern
|
2016-10-04 01:42:13 +03:00
|
|
|
coreglob="$(egrep -o '^([^|%[:space:]]*)' \
|
|
|
|
/proc/sys/kernel/core_pattern)*"
|
2016-07-24 22:55:48 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
function core_file
|
|
|
|
{
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2012 disable=2086
|
2016-07-24 22:55:48 +03:00
|
|
|
printf "%s" "$(ls -tr1 $coreglob 2> /dev/null | head -1)"
|
|
|
|
}
|
|
|
|
|
2016-10-04 01:42:13 +03:00
|
|
|
function core_prog
|
|
|
|
{
|
|
|
|
prog=$ZTEST
|
2017-03-09 21:20:15 +03:00
|
|
|
core_id=$($GDB --batch -c "$1" | grep "Core was generated by" | \
|
2016-10-04 01:42:13 +03:00
|
|
|
tr \' ' ')
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2076
|
2016-10-04 01:42:13 +03:00
|
|
|
if [[ "$core_id" =~ "zdb " ]]; then
|
|
|
|
prog=$ZDB
|
|
|
|
fi
|
|
|
|
printf "%s" "$prog"
|
|
|
|
}
|
|
|
|
|
2016-03-23 04:08:59 +03:00
|
|
|
function store_core
|
|
|
|
{
|
2016-07-24 22:55:48 +03:00
|
|
|
core="$(core_file)"
|
|
|
|
if [[ $ztrc -ne 0 ]] || [[ -f "$core" ]]; then
|
2017-09-21 20:17:56 +03:00
|
|
|
df -h "$workdir" >>ztest.out
|
2016-03-23 04:08:59 +03:00
|
|
|
coreid=$(date "+zloop-%y%m%d-%H%M%S")
|
2017-03-09 21:20:15 +03:00
|
|
|
foundcrashes=$((foundcrashes + 1))
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
dest=$coredir/$coreid
|
2017-03-09 21:20:15 +03:00
|
|
|
or_die mkdir -p "$dest"
|
|
|
|
or_die mkdir -p "$dest/vdev"
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
echo "*** ztest crash found - moving logs to $dest"
|
|
|
|
|
2017-03-09 21:20:15 +03:00
|
|
|
or_die mv ztest.history "$dest/"
|
|
|
|
or_die mv ztest.ddt "$dest/"
|
|
|
|
or_die mv ztest.out "$dest/"
|
|
|
|
or_die mv "$workdir/ztest*" "$dest/vdev/"
|
|
|
|
or_die mv "$workdir/zpool.cache" "$dest/vdev/"
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
# check for core
|
2016-07-24 22:55:48 +03:00
|
|
|
if [[ -f "$core" ]]; then
|
2017-03-09 21:20:15 +03:00
|
|
|
coreprog=$(core_prog "$core")
|
2016-03-23 04:08:59 +03:00
|
|
|
corestatus=$($GDB --batch --quiet \
|
|
|
|
-ex "set print thread-events off" \
|
|
|
|
-ex "printf \"*\n* Backtrace \n*\n\"" \
|
|
|
|
-ex "bt" \
|
|
|
|
-ex "printf \"*\n* Libraries \n*\n\"" \
|
|
|
|
-ex "info sharedlib" \
|
|
|
|
-ex "printf \"*\n* Threads (full) \n*\n\"" \
|
|
|
|
-ex "info threads" \
|
|
|
|
-ex "printf \"*\n* Backtraces \n*\n\"" \
|
|
|
|
-ex "thread apply all bt" \
|
|
|
|
-ex "printf \"*\n* Backtraces (full) \n*\n\"" \
|
|
|
|
-ex "thread apply all bt full" \
|
2017-03-09 21:20:15 +03:00
|
|
|
-ex "quit" "$coreprog" "$core" | grep -v "New LWP")
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
# Dump core + logs to stored directory
|
2017-03-09 21:20:15 +03:00
|
|
|
echo "$corestatus" >>"$dest/status"
|
|
|
|
or_die mv "$core" "$dest/"
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
# Record info in cores logfile
|
2016-07-24 22:55:48 +03:00
|
|
|
echo "*** core @ $coredir/$coreid/$core:" | \
|
2016-03-23 04:08:59 +03:00
|
|
|
tee -a ztest.cores
|
|
|
|
echo "$corestatus" | tee -a ztest.cores
|
|
|
|
echo "" | tee -a ztest.cores
|
|
|
|
fi
|
|
|
|
echo "continuing..."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2017-09-12 23:15:11 +03:00
|
|
|
rngdpid=""
|
|
|
|
function on_exit
|
|
|
|
{
|
|
|
|
if [ -n "$rngdpid" ]; then
|
|
|
|
kill -9 "$rngdpid"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
trap on_exit EXIT
|
|
|
|
|
2016-03-23 04:08:59 +03:00
|
|
|
# parse arguments
|
|
|
|
# expected format: zloop [-t timeout] [-c coredir] [-- extra ztest args]
|
|
|
|
coredir=$DEFAULTCOREDIR
|
2017-09-21 20:17:56 +03:00
|
|
|
basedir=$DEFAULTWORKDIR
|
|
|
|
rundir="zloop-run"
|
2016-03-23 04:08:59 +03:00
|
|
|
timeout=0
|
2017-10-13 22:39:39 +03:00
|
|
|
size="512m"
|
|
|
|
while getopts ":ht:s:c:f:" opt; do
|
2016-03-23 04:08:59 +03:00
|
|
|
case $opt in
|
|
|
|
t ) [[ $OPTARG -gt 0 ]] && timeout=$OPTARG ;;
|
2017-10-13 22:39:39 +03:00
|
|
|
s ) [[ $OPTARG ]] && size=$OPTARG ;;
|
2016-03-23 04:08:59 +03:00
|
|
|
c ) [[ $OPTARG ]] && coredir=$OPTARG ;;
|
2017-09-21 20:17:56 +03:00
|
|
|
f ) [[ $OPTARG ]] && basedir=$(readlink -f "$OPTARG") ;;
|
2016-03-23 04:08:59 +03:00
|
|
|
h ) usage
|
|
|
|
exit 2
|
|
|
|
;;
|
|
|
|
* ) echo "Invalid argument: -$OPTARG";
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
# pass remaining arguments on to ztest
|
|
|
|
shift $((OPTIND - 1))
|
|
|
|
|
|
|
|
# enable core dumps
|
|
|
|
ulimit -c unlimited
|
|
|
|
|
2016-07-24 22:55:48 +03:00
|
|
|
if [[ -f "$(core_file)" ]]; then
|
|
|
|
echo -n "There's a core dump here you might want to look at first... "
|
2017-03-09 21:20:15 +03:00
|
|
|
core_file
|
2016-03-23 04:08:59 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d $coredir ]]; then
|
|
|
|
echo "core dump directory ($coredir) does not exist, creating it."
|
2017-03-09 21:20:15 +03:00
|
|
|
or_die mkdir -p "$coredir"
|
2016-03-23 04:08:59 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -w $coredir ]]; then
|
|
|
|
echo "core dump directory ($coredir) is not writable."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
or_die rm -f ztest.history
|
|
|
|
or_die rm -f ztest.ddt
|
|
|
|
or_die rm -f ztest.cores
|
|
|
|
|
2017-09-12 23:15:11 +03:00
|
|
|
# start rngd in the background so we don't run out of entropy
|
|
|
|
or_die read -r rngdpid < <(rngd -f -r /dev/urandom & echo $!)
|
|
|
|
|
2016-03-23 04:08:59 +03:00
|
|
|
ztrc=0 # ztest return value
|
|
|
|
foundcrashes=0 # number of crashes found so far
|
|
|
|
starttime=$(date +%s)
|
|
|
|
curtime=$starttime
|
|
|
|
|
|
|
|
# if no timeout was specified, loop forever.
|
2017-03-09 21:20:15 +03:00
|
|
|
while [[ $timeout -eq 0 ]] || [[ $curtime -le $((starttime + timeout)) ]]; do
|
2016-03-23 04:08:59 +03:00
|
|
|
zopt="-VVVVV"
|
|
|
|
|
2017-09-21 20:17:56 +03:00
|
|
|
# start each run with an empty directory
|
|
|
|
workdir="$basedir/$rundir"
|
|
|
|
or_die rm -rf "$workdir"
|
|
|
|
or_die mkdir "$workdir"
|
|
|
|
|
2016-03-23 04:08:59 +03:00
|
|
|
# switch between common arrangements & fully randomized
|
|
|
|
if [[ $((RANDOM % 2)) -eq 0 ]]; then
|
|
|
|
mirrors=2
|
|
|
|
raidz=0
|
|
|
|
parity=1
|
|
|
|
vdevs=2
|
|
|
|
else
|
|
|
|
mirrors=$(((RANDOM % 3) * 1))
|
|
|
|
parity=$(((RANDOM % 3) + 1))
|
|
|
|
raidz=$((((RANDOM % 9) + parity + 1) * (RANDOM % 2)))
|
|
|
|
vdevs=$(((RANDOM % 3) + 3))
|
|
|
|
fi
|
|
|
|
align=$(((RANDOM % 2) * 3 + 9))
|
|
|
|
runtime=$((RANDOM % 100))
|
|
|
|
passtime=$((RANDOM % (runtime / 3 + 1) + 10))
|
|
|
|
|
|
|
|
zopt="$zopt -m $mirrors"
|
|
|
|
zopt="$zopt -r $raidz"
|
|
|
|
zopt="$zopt -R $parity"
|
|
|
|
zopt="$zopt -v $vdevs"
|
|
|
|
zopt="$zopt -a $align"
|
|
|
|
zopt="$zopt -T $runtime"
|
|
|
|
zopt="$zopt -P $passtime"
|
|
|
|
zopt="$zopt -s $size"
|
|
|
|
zopt="$zopt -f $workdir"
|
|
|
|
|
2017-03-09 21:20:15 +03:00
|
|
|
# shellcheck disable=SC2124
|
2016-03-23 04:08:59 +03:00
|
|
|
cmd="$ZTEST $zopt $@"
|
|
|
|
desc="$(date '+%m/%d %T') $cmd"
|
|
|
|
echo "$desc" | tee -a ztest.history
|
|
|
|
echo "$desc" >>ztest.out
|
|
|
|
$cmd >>ztest.out 2>&1
|
|
|
|
ztrc=$?
|
|
|
|
egrep '===|WARNING' ztest.out >>ztest.history
|
OpenZFS 8585 - improve batching done in zil_commit()
Authored by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Brad Lewis <brad.lewis@delphix.com>
Reviewed by: Matt Ahrens <mahrens@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Approved by: Dan McDonald <danmcd@joyent.com>
Ported-by: Prakash Surya <prakash.surya@delphix.com>
Problem
=======
The current implementation of zil_commit() can introduce significant
latency, beyond what is inherent due to the latency of the underlying
storage. The additional latency comes from two main problems:
1. When there's outstanding ZIL blocks being written (i.e. there's
already a "writer thread" in progress), then any new calls to
zil_commit() will block waiting for the currently oustanding ZIL
blocks to complete. The blocks written for each "writer thread" is
coined a "batch", and there can only ever be a single "batch" being
written at a time. When a batch is being written, any new ZIL
transactions will have to wait for the next batch to be written,
which won't occur until the current batch finishes.
As a result, the underlying storage may not be used as efficiently
as possible. While "new" threads enter zil_commit() and are blocked
waiting for the next batch, it's possible that the underlying
storage isn't fully utilized by the current batch of ZIL blocks. In
that case, it'd be better to allow these new threads to generate
(and issue) a new ZIL block, such that it could be serviced by the
underlying storage concurrently with the other ZIL blocks that are
being serviced.
2. Any call to zil_commit() must wait for all ZIL blocks in its "batch"
to complete, prior to zil_commit() returning. The size of any given
batch is proportional to the number of ZIL transaction in the queue
at the time that the batch starts processing the queue; which
doesn't occur until the previous batch completes. Thus, if there's a
lot of transactions in the queue, the batch could be composed of
many ZIL blocks, and each call to zil_commit() will have to wait for
all of these writes to complete (even if the thread calling
zil_commit() only cared about one of the transactions in the batch).
To further complicate the situation, these two issues result in the
following side effect:
3. If a given batch takes longer to complete than normal, this results
in larger batch sizes, which then take longer to complete and
further drive up the latency of zil_commit(). This can occur for a
number of reasons, including (but not limited to): transient changes
in the workload, and storage latency irregularites.
Solution
========
The solution attempted by this change has the following goals:
1. no on-disk changes; maintain current on-disk format.
2. modify the "batch size" to be equal to the "ZIL block size".
3. allow new batches to be generated and issued to disk, while there's
already batches being serviced by the disk.
4. allow zil_commit() to wait for as few ZIL blocks as possible.
5. use as few ZIL blocks as possible, for the same amount of ZIL
transactions, without introducing significant latency to any
individual ZIL transaction. i.e. use fewer, but larger, ZIL blocks.
In theory, with these goals met, the new allgorithm will allow the
following improvements:
1. new ZIL blocks can be generated and issued, while there's already
oustanding ZIL blocks being serviced by the storage.
2. the latency of zil_commit() should be proportional to the underlying
storage latency, rather than the incoming synchronous workload.
Porting Notes
=============
Due to the changes made in commit 119a394ab0, the lifetime of an itx
structure differs than in OpenZFS. Specifically, the itx structure is
kept around until the data associated with the itx is considered to be
safe on disk; this is so that the itx's callback can be called after the
data is committed to stable storage. Since OpenZFS doesn't have this itx
callback mechanism, it's able to destroy the itx structure immediately
after the itx is committed to an lwb (before the lwb is written to
disk).
To support this difference, and to ensure the itx's callbacks can still
be called after the itx's data is on disk, a few changes had to be made:
* A list of itxs was added to the lwb structure. This list contains
all of the itxs that have been committed to the lwb, such that the
callbacks for these itxs can be called from zil_lwb_flush_vdevs_done(),
after the data for the itxs is committed to disk.
* A list of itxs was added on the stack of the zil_process_commit_list()
function; the "nolwb_itxs" list. In some circumstances, an itx may
not be committed to an lwb (e.g. if allocating the "next" ZIL block
on disk fails), so this list is used to keep track of which itxs
fall into this state, such that their callbacks can be called after
the ZIL's writer pipeline is "stalled".
* The logic to actually call the itx's callback was moved into the
zil_itx_destroy() function. Since all consumers of zil_itx_destroy()
were effectively performing the same logic (i.e. if callback is
non-null, call the callback), it seemed like useful code cleanup to
consolidate this logic into a single function.
Additionally, the existing Linux tracepoint infrastructure dealing with
the ZIL's probes and structures had to be updated to reflect these code
changes. Specifically:
* The "zil__cw1" and "zil__cw2" probes were removed, so they had to be
removed from "trace_zil.h" as well.
* Some of the zilog structure's fields were removed, which affected
the tracepoint definitions of the structure.
* New tracepoints had to be added for the following 3 new probes:
* zil__process__commit__itx
* zil__process__normal__itx
* zil__commit__io__error
OpenZFS-issue: https://www.illumos.org/issues/8585
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/5d95a3a
Closes #6566
2017-12-05 20:39:16 +03:00
|
|
|
$ZDB -U "$workdir/zpool.cache" -DD ztest >>ztest.ddt 2>&1
|
2016-03-23 04:08:59 +03:00
|
|
|
|
|
|
|
store_core
|
|
|
|
|
|
|
|
curtime=$(date +%s)
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "zloop finished, $foundcrashes crashes found"
|
|
|
|
|
2016-07-24 22:55:48 +03:00
|
|
|
#restore core pattern
|
|
|
|
echo "$origcorepattern" > /proc/sys/kernel/core_pattern
|
|
|
|
|
2016-03-23 04:08:59 +03:00
|
|
|
uptime >>ztest.out
|
|
|
|
|
|
|
|
if [[ $foundcrashes -gt 0 ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|