Print this page
7290 ZFS test suite needs to control what utilities it can run
Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/test/zfs-tests/tests/functional/snapused/snapused.kshlib
+++ new/usr/src/test/zfs-tests/tests/functional/snapused/snapused.kshlib
1 1 #
2 2 # CDDL HEADER START
3 3 #
4 4 # The contents of this file are subject to the terms of the
5 5 # Common Development and Distribution License (the "License").
6 6 # You may not use this file except in compliance with the License.
7 7 #
8 8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 # or http://www.opensolaris.org/os/licensing.
10 10 # See the License for the specific language governing permissions
11 11 # and limitations under the License.
12 12 #
13 13 # When distributing Covered Code, include this CDDL HEADER in each
14 14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 # If applicable, add the following below this CDDL HEADER, with the
16 16 # fields enclosed by brackets "[]" replaced with your own identifying
17 17 # information: Portions Copyright [yyyy] [name of copyright owner]
|
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 #
19 19 # CDDL HEADER END
20 20 #
21 21
22 22 #
23 23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 # Use is subject to license terms.
25 25 #
26 26
27 27 #
28 -# Copyright (c) 2013 by Delphix. All rights reserved.
28 +# Copyright (c) 2013, 2016 by Delphix. All rights reserved.
29 29 #
30 30
31 31 . $STF_SUITE/include/libtest.shlib
32 32
33 33 export USEDTEST=$TESTPOOL/$TESTFS/usedtest-snapused
34 34
35 35 function _check_used # dataset
36 36 {
37 37 typeset dataset=$1
38 38
39 39 if [[ "$(get_prop type $dataset)" == "snapshot" ]]; then
40 40 return
41 41 fi
42 42
43 43 used=$(get_prop used $dataset)
44 44 usedbychildren=$(get_prop usedbychildren $dataset)
45 45 usedbydataset=$(get_prop usedbydataset $dataset)
46 46 usedbyrefreservation=$(get_prop usedbyrefreservation $dataset)
47 47 usedbysnapshots=$(get_prop usedbysnapshots $dataset)
|
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
48 48 ((used_sum = usedbychildren + usedbydataset + \
49 49 usedbyrefreservation + usedbysnapshots))
50 50 if ((used != used_sum)); then
51 51 log_fail "$dataset: used($used) is not the sum($used_sum) of usedby*"
52 52 fi
53 53 }
54 54
55 55 function check_used # dataset
56 56 {
57 57 typeset dataset=$1
58 - for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
58 + for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
59 59 do
60 60 _check_used $child
61 61 done
62 62 }
63 63
64 64 function check_usedbychildren # dataset
65 65 {
66 66 typeset dataset=$1
67 67 typeset -i usedbychildren_sum=0
68 68 typeset -i parent_usedbychildren=0
69 - for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
69 + for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
70 70 do
71 71 if [[ "$(get_prop type $child)" == "snapshot" ]]; then
72 72 continue
73 73 fi
74 74
75 75 # parent
76 76 if [[ "$child" == "$dataset" ]]; then
77 77 parent_usedbychildren=$(get_prop usedbychildren $child)
78 78 else #child
79 79 reservation=$(get_prop reservation $child)
80 80 used=$(get_prop used $child)
81 81 if ((reservation > used)); then
82 82 ((usedbychildren_sum += reservation))
83 83 else
84 84 ((usedbychildren_sum += used))
85 85 fi
86 86 fi
87 87 done
88 88
89 89 if ((parent_usedbychildren != usedbychildren_sum)); then
90 90 log_fail "$dataset: usedbychildren($parent_usedbychildren) is not the sum($usedbychildren_sum) of used by children"
91 91 fi
92 92 }
93 93
94 94 function _check_usedbydataset # dataset
95 95 {
96 96 typeset dataset=$1
97 97 if [[ "$(get_prop type $dataset)" == "snapshot" ]]; then
98 98 return
99 99 fi
100 100
101 101 usedbydataset=$(get_prop usedbydataset $dataset)
102 102 referenced=$(get_prop referenced $dataset)
103 103
104 104 is_cloned=$(get_prop is:cloned $dataset)
105 105
106 106 if [[ "$is_cloned" == "yes" ]]; then
107 107 if ((usedbydataset > referenced)); then
108 108 log_fail "$dataset(cloned): usedbydataset($usedbydataset) is more than referenced($referenced)"
109 109 fi
110 110 else
111 111 #
112 112 # if non-clones, should usedbydataset == referenced
|
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
113 113 #
114 114 if ((usedbydataset != referenced)); then
115 115 log_fail "$dataset: usedbydataset($usedbydataset) is not equal to referenced($referenced)"
116 116 fi
117 117 fi
118 118 }
119 119
120 120 function check_usedbydataset # dataset
121 121 {
122 122 typeset dataset=$1
123 - for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
123 + for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
124 124 do
125 125 _check_usedbydataset $child
126 126 done
127 127 }
128 128
129 129 function _check_usedbyrefreservation # dataset
130 130 {
131 131 typeset dataset=$1
132 132 if [[ "$(get_prop type $dataset)" == "snapshot" ]]; then
133 133 return
134 134 fi
135 135
136 136 usedbyrefreservation=$(get_prop usedbyrefreservation $dataset)
137 137 referenced=$(get_prop referenced $dataset)
138 138 refreservation=$(get_prop refreservation $dataset)
|
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
139 139 ((diff_ref = refreservation - referenced))
140 140 if ((usedbyrefreservation > refreservation || \
141 141 usedbyrefreservation < diff_ref)); then
142 142 log_fail "$dataset: usedbyrefreservation($usedbyrefreservation) checking is not ok"
143 143 fi
144 144 }
145 145
146 146 function check_usedbyrefreservation # dataset
147 147 {
148 148 typeset dataset=$1
149 - for child in $($ZFS list -rH -t filesystem,volume -o name $dataset)
149 + for child in $(zfs list -rH -t filesystem,volume -o name $dataset)
150 150 do
151 151 _check_usedbyrefreservation $child
152 152 done
153 153 }
154 154
155 155 function check_usedbysnapshots # dataset
156 156 {
157 157 typeset dataset=$1
158 158 typeset -i usedbysnapshots_sum=0
159 159 typeset -i parent_usedbysnapshots=0
160 - for child in $($ZFS list -rH -t filesystem,volume,snapshot -o name $dataset)
160 + for child in $(zfs list -rH -t filesystem,volume,snapshot -o name $dataset)
161 161 do
162 162 # parent
163 163 if [[ "$child" == "$dataset" ]]; then
164 164 parent_usedbysnapshots=$(get_prop usedbysnapshots $child)
165 165 continue
166 166 fi
167 167
168 168 if [[ "$(get_prop type $child)" != "snapshot" ]]; then
169 169 continue
170 170 fi
171 171
172 172 if [[ "$child" != "$dataset@"* ]]; then
173 173 continue
174 174 fi
175 175
176 176 # snapshot
177 177 used=$(get_prop used $child)
178 178 ((usedbysnapshots_sum += used))
179 179 done
180 180
181 181 if ((parent_usedbysnapshots < usedbysnapshots_sum)); then
182 182 log_fail "$dataset: usedbysnapshots($parent_usedbysnapshots) is not more than or equal to" \
183 183 "the sum($usedbysnapshots_sum) of used of snapshots"
184 184 fi
185 185 }
|
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX