#
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-# Copyright (c) 2012, 2016 by Delphix. All rights reserved.
-# Copyright 2016 Nexenta Systems, Inc.
+# Copyright (c) 2012, 2017 by Delphix. All rights reserved.
+# Copyright (c) 2017 by Tim Chase. All rights reserved.
+# Copyright (c) 2017 by Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2017 Lawrence Livermore National Security, LLC.
# Copyright (c) 2017 Datto Inc.
# Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
+# Use is subject to license terms.
#
. ${STF_TOOLS}/include/logapi.shlib
PATH="$STF_PATH"
fi
+#
+# Generic dot version comparison function
+#
+# Returns success when version $1 is greater than or equal to $2.
+#
+function compare_version_gte
+{
+ if [[ "$(printf "$1\n$2" | sort -V | tail -n1)" == "$1" ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
# Linux kernel version comparison function
#
# $1 Linux version ("4.10", "2.6.32") or blank for installed Linux version
typeset snap=${1:-$TESTPOOL/$TESTFS@$TESTSNAP}
if ! snapexists $snap; then
- log_fail "'$snap' does not existed."
+ log_fail "'$snap' does not exist."
fi
#
((endcyl = (endcyl + 1) / ratio))
fi
-
+
echo $endcyl
}
typeset -i filenum=${3:-50}
typeset -i bytes=${4:-8192}
typeset -i num_writes=${5:-10240}
- typeset -i data=${6:-0}
+ typeset data=${6:-0}
typeset -i odirnum=1
typeset -i idirnum=0
typeset -i fn=0
typeset -i retval=0
- log_must mkdir -p $destdir/$idirnum
+ mkdir -p $destdir/$idirnum
while (($odirnum > 0)); do
if ((dirnum >= 0 && idirnum >= dirnum)); then
odirnum=0
if (($fn >= $filenum)); then
fn=0
((idirnum = idirnum + 1))
- log_must mkdir -p $destdir/$idirnum
+ mkdir -p $destdir/$idirnum
else
((fn = fn + 1))
fi
return 0
}
-#
-# Given a mountpoint, or a dataset name, determine if it is shared via NFS.
-#
-# Returns 0 if shared, 1 otherwise.
-#
-function is_shared
+function is_shared_impl
{
typeset fs=$1
typeset mtpt
- if [[ $fs != "/"* ]] ; then
- if datasetnonexists "$fs" ; then
- return 1
- else
- mtpt=$(get_prop mountpoint "$fs")
- case $mtpt in
- none|legacy|-) return 1
- ;;
- *) fs=$mtpt
- ;;
- esac
- fi
- fi
-
if is_linux; then
for mtpt in `share | awk '{print $1}'` ; do
if [[ $mtpt == $fs ]] ; then
return 1
}
+#
+# Given a mountpoint, or a dataset name, determine if it is shared via NFS.
+#
+# Returns 0 if shared, 1 otherwise.
+#
+function is_shared
+{
+ typeset fs=$1
+ typeset mtpt
+
+ if [[ $fs != "/"* ]] ; then
+ if datasetnonexists "$fs" ; then
+ return 1
+ else
+ mtpt=$(get_prop mountpoint "$fs")
+ case $mtpt in
+ none|legacy|-) return 1
+ ;;
+ *) fs=$mtpt
+ ;;
+ esac
+ fi
+ fi
+
+ is_shared_impl "$fs"
+}
+
#
# Given a dataset name determine if it is shared via SMB.
#
log_must rm -rf $zdbout
}
+#
+# Given a pool issue a scrub and verify that no checksum errors are reported.
+#
+function verify_pool
+{
+ typeset pool=${1:-$TESTPOOL}
+
+ log_must zpool scrub $pool
+ log_must wait_scrubbed $pool
+
+ cksum=$(zpool status $pool | awk 'L{print $NF;L=0} /CKSUM$/{L=1}')
+ if [[ $cksum != 0 ]]; then
+ log_must zpool status -v
+ log_fail "Unexpected CKSUM errors found on $pool ($cksum)"
+ fi
+}
+
#
# Given a pool, and this function list all disks in the pool
#
disklist=$(zpool iostat -v $1 | nawk '(NR >4) {print $1}' | \
grep -v "\-\-\-\-\-" | \
- egrep -v -e "^(mirror|raidz1|raidz2|spare|log|cache)$")
+ egrep -v -e "^(mirror|raidz[1-3]|spare|log|cache|special|dedup)$")
echo $disklist
}
function wait_hotspare_state # pool disk state timeout
{
typeset pool=$1
- typeset disk=${2#$/DEV_DSKDIR/}
+ typeset disk=${2#*$DEV_DSKDIR/}
typeset state=$3
typeset timeout=${4:-60}
typeset -i i=0
function check_vdev_state # pool disk state{online,offline,unavail}
{
typeset pool=$1
- typeset disk=${2#$/DEV_DSKDIR/}
+ typeset disk=${2#*$DEV_DSKDIR/}
typeset state=$3
cur_state=$(get_device_state $pool $disk)
function wait_vdev_state # pool disk state timeout
{
typeset pool=$1
- typeset disk=${2#$/DEV_DSKDIR/}
+ typeset disk=${2#*$DEV_DSKDIR/}
typeset state=$3
typeset timeout=${4:-60}
typeset -i i=0
"when ops is $ops."
fi
log_must datasetexists $dataset
- log_mustnot snapexists $dataset
;;
*)
log_fail "$ops is not supported."
shift
+ # We could use 'zpool list' to only get the vdevs of the pool but we
+ # can't reference a mirror/raidz vdev using its ID (i.e mirror-0),
+ # therefore we use the 'zpool status' output.
typeset tmpfile=$(mktemp)
- zpool list -Hv "$pool" >$tmpfile
+ zpool status -v "$pool" | grep -A 1000 "config:" >$tmpfile
for vdev in $@; do
grep -w ${vdev##*/} $tmpfile >/dev/null 2>&1
[[ $? -ne 0 ]] && return 1
function wait_scrubbed
{
typeset pool=${1:-$TESTPOOL}
- typeset iter=${2:-10}
- for i in {1..$iter} ; do
- if is_pool_scrubbed $pool ; then
- return 0
- fi
- sleep 1
+ while true ; do
+ is_pool_scrubbed $pool && break
+ log_must sleep 1
done
- return 1
}
# Backup the zed.rc in our test directory so that we can edit it for our test.
log_note "Stopping ZED"
if [[ -f ${ZEDLET_DIR}/zed.pid ]]; then
- zedpid=$(cat ${ZEDLET_DIR}/zed.pid)
+ zedpid=$(<${ZEDLET_DIR}/zed.pid)
kill $zedpid
while ps -p $zedpid > /dev/null; do
sleep 1
return 0
}
+
+#
+# Set global scalar integer variable to a hex value using mdb.
+# Note: Target should have CTF data loaded.
+#
+function mdb_ctf_set_int
+{
+ typeset variable=$1
+ typeset value=$2
+
+ mdb -kw -e "$variable/z $value" > /dev/null
+ if [[ $? -ne 0 ]]; then
+ echo "Failed to set '$variable' to '$value' in mdb."
+ return 1
+ fi
+
+ return 0
+}