xref: /freebsd/tools/regression/zfs/zpool/create/option-f_inuse.t (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
1#!/bin/sh
2# $FreeBSD$
3
4dir=`dirname $0`
5. ${dir}/../../misc.sh
6
7echo "1..146"
8
9disks_create 7
10names_create 2
11
12expect_ok ${ZPOOL} create ${name0} ${disk0}
13expect_ok ${ZPOOL} export ${name0}
14exp=`(
15  echo "invalid vdev specification"
16  echo "use '-f' to override the following errors:"
17  echo "${fdisk0} is part of exported pool '${name0}'"
18)`
19expect "${exp}" ${ZPOOL} create ${name1} ${disk0}
20expect_fl ${ZPOOL} status -x ${name1}
21expect_ok ${ZPOOL} create -f ${name1} ${disk0}
22expect_ok ${ZPOOL} status -x ${name1}
23expect_ok ${ZPOOL} destroy ${name1}
24
25expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
26expect_ok ${ZPOOL} export ${name0}
27exp=`(
28  echo "invalid vdev specification"
29  echo "use '-f' to override the following errors:"
30  echo "${fdisk0} is part of exported pool '${name0}'"
31)`
32expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk0} ${disk1}
33expect_fl ${ZPOOL} status -x ${name1}
34expect_ok ${ZPOOL} create -f ${name1} mirror ${disk0} ${disk1}
35expect_ok ${ZPOOL} status -x ${name1}
36expect_ok ${ZPOOL} destroy ${name1}
37
38expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
39expect_ok ${ZPOOL} export ${name0}
40exp=`(
41  echo "invalid vdev specification"
42  echo "use '-f' to override the following errors:"
43  echo "${fdisk0} is part of exported pool '${name0}'"
44)`
45expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk0} ${disk1} ${disk2}
46expect_fl ${ZPOOL} status -x ${name1}
47expect_ok ${ZPOOL} create -f ${name1} raidz1 ${disk0} ${disk1} ${disk2}
48expect_ok ${ZPOOL} status -x ${name1}
49expect_ok ${ZPOOL} destroy ${name1}
50
51expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
52expect_ok ${ZPOOL} export ${name0}
53exp=`(
54  echo "invalid vdev specification"
55  echo "use '-f' to override the following errors:"
56  echo "${fdisk0} is part of exported pool '${name0}'"
57)`
58expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
59expect_fl ${ZPOOL} status -x ${name1}
60expect_ok ${ZPOOL} create -f ${name1} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
61expect_ok ${ZPOOL} status -x ${name1}
62expect_ok ${ZPOOL} destroy ${name1}
63
64expect_ok ${ZPOOL} create ${name0} ${disk0} log ${disk1}
65expect_ok ${ZPOOL} export ${name0}
66exp=`(
67  echo "invalid vdev specification"
68  echo "use '-f' to override the following errors:"
69  echo "${fdisk0} is part of exported pool '${name0}'"
70)`
71expect "${exp}" ${ZPOOL} create ${name1} ${disk0} log ${disk1}
72expect_fl ${ZPOOL} status -x ${name1}
73expect_ok ${ZPOOL} create -f ${name1} ${disk0} log ${disk1}
74expect_ok ${ZPOOL} status -x ${name1}
75expect_ok ${ZPOOL} destroy ${name1}
76
77expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
78expect_ok ${ZPOOL} export ${name0}
79exp=`(
80  echo "invalid vdev specification"
81  echo "use '-f' to override the following errors:"
82  echo "${fdisk0} is part of exported pool '${name0}'"
83)`
84expect "${exp}" ${ZPOOL} create ${name1} ${disk0} log mirror ${disk1} ${disk2}
85expect_fl ${ZPOOL} status -x ${name1}
86expect_ok ${ZPOOL} create -f ${name1} ${disk0} log mirror ${disk1} ${disk2}
87expect_ok ${ZPOOL} status -x ${name1}
88expect_ok ${ZPOOL} destroy ${name1}
89
90expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
91expect_ok ${ZPOOL} export ${name0}
92exp=`(
93  echo "invalid vdev specification"
94  echo "use '-f' to override the following errors:"
95  echo "${fdisk0} is part of exported pool '${name0}'"
96)`
97expect "${exp}" ${ZPOOL} create ${name1} ${disk0} cache ${disk1}
98expect_fl ${ZPOOL} status -x ${name1}
99expect_ok ${ZPOOL} create -f ${name1} ${disk0} cache ${disk1}
100expect_ok ${ZPOOL} status -x ${name1}
101expect_ok ${ZPOOL} destroy ${name1}
102
103expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
104expect_ok ${ZPOOL} offline ${name0} ${disk1}
105expect_ok ${ZPOOL} export ${name0}
106exp=`(
107  echo "invalid vdev specification"
108  echo "use '-f' to override the following errors:"
109  echo "${fdisk1} is part of potentially active pool '${name0}'"
110)`
111expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk1} ${disk2}
112expect_fl ${ZPOOL} status -x ${name1}
113expect_ok ${ZPOOL} create -f ${name1} mirror ${disk1} ${disk2}
114expect_ok ${ZPOOL} status -x ${name1}
115expect_ok ${ZPOOL} destroy ${name1}
116expect_ok ${ZPOOL} import ${name0}
117expect_ok ${ZPOOL} destroy ${name0}
118
119expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
120expect_ok ${ZPOOL} offline ${name0} ${disk2}
121expect_ok ${ZPOOL} export ${name0}
122exp=`(
123  echo "invalid vdev specification"
124  echo "use '-f' to override the following errors:"
125  echo "${fdisk2} is part of potentially active pool '${name0}'"
126)`
127expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk2} ${disk3} ${disk4}
128expect_fl ${ZPOOL} status -x ${name1}
129expect_ok ${ZPOOL} create -f ${name1} raidz1 ${disk2} ${disk3} ${disk4}
130expect_ok ${ZPOOL} status -x ${name1}
131expect_ok ${ZPOOL} destroy ${name1}
132expect_ok ${ZPOOL} import ${name0}
133expect_ok ${ZPOOL} destroy ${name0}
134
135expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
136expect_ok ${ZPOOL} offline ${name0} ${disk3}
137expect_ok ${ZPOOL} export ${name0}
138exp=`(
139  echo "invalid vdev specification"
140  echo "use '-f' to override the following errors:"
141  echo "${fdisk3} is part of potentially active pool '${name0}'"
142)`
143expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
144expect_fl ${ZPOOL} status -x ${name1}
145expect_ok ${ZPOOL} create -f ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
146expect_ok ${ZPOOL} status -x ${name1}
147expect_ok ${ZPOOL} destroy ${name1}
148expect_ok ${ZPOOL} import ${name0}
149expect_ok ${ZPOOL} destroy ${name0}
150
151expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
152expect_ok ${ZPOOL} offline ${name0} ${disk2}
153expect_ok ${ZPOOL} export ${name0}
154exp=`(
155  echo "invalid vdev specification"
156  echo "use '-f' to override the following errors:"
157  echo "${fdisk2} is part of potentially active pool '${name0}'"
158)`
159expect "${exp}" ${ZPOOL} create ${name1} ${disk3} log mirror ${disk2} ${disk4}
160expect_fl ${ZPOOL} status -x ${name1}
161expect_ok ${ZPOOL} create -f ${name1} ${disk3} log mirror ${disk2} ${disk4}
162expect_ok ${ZPOOL} status -x ${name1}
163expect_ok ${ZPOOL} destroy ${name1}
164expect_ok ${ZPOOL} import ${name0}
165expect_ok ${ZPOOL} destroy ${name0}
166
167expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
168expect_ok ${ZPOOL} offline ${name0} ${disk1}
169expect_ok ${ZPOOL} export ${name0}
170exp=`(
171  echo "invalid vdev specification"
172  echo "use '-f' to override the following errors:"
173  echo "${fdisk1} is part of potentially active pool '${name0}'"
174)`
175add_msg="# TODO It shouldn't be possible to use offlined cache vdev."
176expect "${exp}" ${ZPOOL} create ${name1} ${disk2} cache ${disk1}
177expect_fl ${ZPOOL} status -x ${name1}
178expect_ok ${ZPOOL} create -f ${name1} ${disk2} cache ${disk1}
179add_msg=""
180expect_ok ${ZPOOL} status -x ${name1}
181expect_ok ${ZPOOL} destroy ${name1}
182expect_ok ${ZPOOL} import ${name0}
183expect_ok ${ZPOOL} destroy ${name0}
184
185expect_ok ${ZPOOL} create ${name0} mirror ${disk0} ${disk1}
186expect_ok ${ZPOOL} offline ${name0} ${disk1}
187exp=`(
188  echo "invalid vdev specification"
189  echo "use '-f' to override the following errors:"
190  echo "${fdisk1} is part of active pool '${name0}'"
191)`
192expect "${exp}" ${ZPOOL} create ${name1} mirror ${disk1} ${disk2}
193expect_fl ${ZPOOL} status -x ${name1}
194exp=`(
195  echo "invalid vdev specification"
196  echo "the following errors must be manually repaired:"
197  echo "${fdisk1} is part of active pool '${name0}'"
198)`
199expect "${exp}" ${ZPOOL} create -f ${name1} mirror ${disk1} ${disk2}
200expect_fl ${ZPOOL} status -x ${name1}
201expect_ok ${ZPOOL} online ${name0} ${disk1}
202expect_ok ${ZPOOL} destroy ${name0}
203
204expect_ok ${ZPOOL} create ${name0} raidz1 ${disk0} ${disk1} ${disk2}
205expect_ok ${ZPOOL} offline ${name0} ${disk2}
206exp=`(
207  echo "invalid vdev specification"
208  echo "use '-f' to override the following errors:"
209  echo "${fdisk2} is part of active pool '${name0}'"
210)`
211expect "${exp}" ${ZPOOL} create ${name1} raidz1 ${disk2} ${disk3} ${disk4}
212expect_fl ${ZPOOL} status -x ${name1}
213exp=`(
214  echo "invalid vdev specification"
215  echo "the following errors must be manually repaired:"
216  echo "${fdisk2} is part of active pool '${name0}'"
217)`
218expect "${exp}" ${ZPOOL} create -f ${name1} raidz1 ${disk2} ${disk3} ${disk4}
219expect_fl ${ZPOOL} status -x ${name1}
220expect_ok ${ZPOOL} online ${name0} ${disk2}
221expect_ok ${ZPOOL} destroy ${name0}
222
223expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
224expect_ok ${ZPOOL} offline ${name0} ${disk3}
225exp=`(
226  echo "invalid vdev specification"
227  echo "use '-f' to override the following errors:"
228  echo "${fdisk3} is part of active pool '${name0}'"
229)`
230expect "${exp}" ${ZPOOL} create ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
231expect_fl ${ZPOOL} status -x ${name1}
232exp=`(
233  echo "invalid vdev specification"
234  echo "the following errors must be manually repaired:"
235  echo "${fdisk3} is part of active pool '${name0}'"
236)`
237expect "${exp}" ${ZPOOL} create -f ${name1} raidz2 ${disk3} ${disk4} ${disk5} ${disk6}
238expect_fl ${ZPOOL} status -x ${name1}
239expect_ok ${ZPOOL} online ${name0} ${disk3}
240expect_ok ${ZPOOL} destroy ${name0}
241
242expect_ok ${ZPOOL} create ${name0} ${disk0} log mirror ${disk1} ${disk2}
243expect_ok ${ZPOOL} offline ${name0} ${disk2}
244exp=`(
245  echo "invalid vdev specification"
246  echo "use '-f' to override the following errors:"
247  echo "${fdisk2} is part of active pool '${name0}'"
248)`
249expect "${exp}" ${ZPOOL} create ${name1} ${disk3} log mirror ${disk2} ${disk4}
250expect_fl ${ZPOOL} status -x ${name1}
251exp=`(
252  echo "invalid vdev specification"
253  echo "the following errors must be manually repaired:"
254  echo "${fdisk2} is part of active pool '${name0}'"
255)`
256expect "${exp}" ${ZPOOL} create -f ${name1} ${disk3} log mirror ${disk2} ${disk4}
257expect_fl ${ZPOOL} status -x ${name1}
258expect_ok ${ZPOOL} online ${name0} ${disk2}
259expect_ok ${ZPOOL} destroy ${name0}
260
261expect_ok ${ZPOOL} create ${name0} ${disk0} cache ${disk1}
262expect_ok ${ZPOOL} offline ${name0} ${disk1}
263exp=`(
264  echo "invalid vdev specification"
265  echo "use '-f' to override the following errors:"
266  echo "${fdisk1} is part of active pool '${name0}'"
267)`
268add_msg="# TODO It reports that ${fdisk1} is part of unknown pool."
269expect "${exp}" ${ZPOOL} create ${name1} ${disk2} cache ${disk1}
270add_msg=""
271expect_fl ${ZPOOL} status -x ${name1}
272exp=`(
273  echo "invalid vdev specification"
274  echo "the following errors must be manually repaired:"
275  echo "${fdisk1} is part of active pool '${name0}'"
276)`
277add_msg="# TODO It reports that ${fdisk1} is used twice."
278expect "${exp}" ${ZPOOL} create -f ${name1} ${disk2} cache ${disk1}
279add_msg=""
280expect_fl ${ZPOOL} status -x ${name1}
281expect_ok ${ZPOOL} online ${name0} ${disk1}
282expect_ok ${ZPOOL} destroy ${name0}
283
284expect_ok ${ZPOOL} create ${name0} ${disk0}
285expect_ok ${ZPOOL} export ${name0}
286exp=`(
287  echo "invalid vdev specification"
288  echo "use '-f' to override the following errors:"
289  echo "${fdisk0} is part of exported pool '${name0}'"
290)`
291expect "${exp}" ${ZPOOL} create ${name0} ${disk0}
292expect_fl ${ZPOOL} status -x ${name0}
293expect_ok ${ZPOOL} create -f ${name0} ${disk0}
294expect_ok ${ZPOOL} status -x ${name0}
295expect_ok ${ZPOOL} destroy ${name0}
296
297disks_destroy
298