xref: /titanic_44/usr/src/test/zfs-tests/tests/functional/nopwrite/nopwrite.shlib (revision 56b2bdd1f04d465cfe4a95b88ae5cba5884154e4)
1#
2# This file and its contents are supplied under the terms of the
3# Common Development and Distribution License ("CDDL"), version 1.0.
4# You may only use this file in accordance with the terms of version
5# 1.0 of the CDDL.
6#
7# A full copy of the text of the CDDL should have accompanied this
8# source.  A copy of the CDDL is also available via the Internet at
9# http://www.illumos.org/license/CDDL.
10#
11
12#
13# Copyright (c) 2012 by Delphix. All rights reserved.
14#
15
16. $STF_SUITE/include/math.shlib
17
18export TESTVOL="testvol.nopwrite"
19export VOLSIZE="256M"
20export MEGS="64"
21
22function verify_nopwrite
23{
24	typeset origin=$1
25	typeset snap=$2
26	typeset clone=$3
27	typeset low=1
28	typeset high=99
29
30	$SYNC
31	for i in origin snap clone; do
32		for j in used refer usedbychildren written; do
33			typeset ${i}_$j=$(get_prop $j $(eval echo \$$i))
34		done
35	done
36
37	#
38	# If we are dealing with a volume, deduct the refreserv from the used
39	# value to prevent real failures from being masked by the unexpected
40	# extra space. Also, volumes use more space for metadata, so adjust the
41	# percentages to be more forgiving.
42	#
43	if [[ "$(get_prop type $origin)" = "volume" ]]; then
44		typeset rr=$(get_prop refreserv $origin)
45		((origin_used -= rr ))
46		low=2
47		high=98
48	fi
49
50	# These values should differ greatly with nopwrite.
51	within_percent $origin_used $clone_used $low && return 1
52	within_percent $origin_refer $origin_usedbychildren $low && return 1
53	within_percent $snap_written $clone_written $low && return 1
54
55	# These values should be nearly the same with nopwrite.
56	within_percent $origin_used $clone_refer $high || return 1
57	within_percent $origin_used $snap_refer $high || return 1
58
59	#
60	# The comparisons below should pass regardless of nopwrite. They're
61	# here for sanity.
62	#
63	typeset deadlist=$($ZDB -Pddd $clone | $AWK '/Deadlist:/ {print $2}')
64	within_percent $deadlist $clone_written $high || return 1
65	within_percent $snap_refer $snap_written $high || return 1
66
67	return 0
68}
69