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