]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/zfs/zpool/replace/raidz2.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / zfs / zpool / replace / raidz2.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 dir=`dirname $0`
5 . ${dir}/../../misc.sh
6
7 echo "1..115"
8
9 disks_create 6
10 names_create 1
11
12 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
13 expect_ok ${ZPOOL} export ${name0}
14 dname0=${disk0}
15 fdname0=${fdisk0}
16 guid0=`get_guid ${fdisk0}`
17 disk_destroy 0
18 disk_create 0 ${dname0}
19 expect_ok ${ZPOOL} import ${import_flags} ${name0}
20 exp=`(
21   echo "  pool: ${name0}"
22   echo " state: DEGRADED"
23   echo "status: One or more devices could not be used because the label is missing or"
24   echo "      invalid.  Sufficient replicas exist for the pool to continue"
25   echo "      functioning in a degraded state."
26   echo "action: Replace the device using 'zpool replace'."
27   echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
28   echo " scrub: none requested"
29   echo "config:"
30   echo "        NAME          STATE     READ WRITE CKSUM"
31   echo "        ${name0}      DEGRADED     0     0     0"
32   echo "          raidz2      DEGRADED     0     0     0"
33   echo "            ${guid0}  UNAVAIL      0     0     0  was ${fdname0}"
34   echo "            ${disk1}  ONLINE       0     0     0"
35   echo "            ${disk2}  ONLINE       0     0     0"
36   echo "            ${disk3}  ONLINE       0     0     0"
37   echo "errors: No known data errors"
38 )`
39 expect "${exp}" ${ZPOOL} status ${name0}
40 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
41 wait_for_resilver ${name0}
42 exp=`(
43   echo "  pool: ${name0}"
44   echo " state: ONLINE"
45   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
46   echo "config:"
47   echo "        NAME          STATE   READ WRITE CKSUM"
48   echo "        ${name0}      ONLINE     0     0     0"
49   echo "          raidz2      ONLINE     0     0     0"
50   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
51   echo "            ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
52   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
53   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
54   echo "errors: No known data errors"
55 )`
56 expect "${exp}" ${ZPOOL} status ${name0}
57 expect_ok ${ZPOOL} destroy ${name0}
58 expect_fl ${ZPOOL} status -x ${name0}
59
60 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
61 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
62 wait_for_resilver ${name0}
63 exp=`(
64   echo "  pool: ${name0}"
65   echo " state: ONLINE"
66   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
67   echo "config:"
68   echo "        NAME          STATE   READ WRITE CKSUM"
69   echo "        ${name0}      ONLINE     0     0     0"
70   echo "          raidz2      ONLINE     0     0     0"
71   echo "            ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
72   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
73   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
74   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
75   echo "errors: No known data errors"
76 )`
77 expect "${exp}" ${ZPOOL} status ${name0}
78 expect_ok ${ZPOOL} destroy ${name0}
79 expect_fl ${ZPOOL} status -x ${name0}
80
81 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
82 expect_ok ${ZPOOL} export ${name0}
83 dname0=${disk0}
84 fdname0=${fdisk0}
85 guid0=`get_guid ${fdisk0}`
86 disk_destroy 0
87 expect_ok ${ZPOOL} import ${import_flags} ${name0}
88 exp=`(
89   echo "  pool: ${name0}"
90   echo " state: DEGRADED"
91   echo " scrub: none requested"
92   echo "config:"
93   echo "        NAME           STATE     READ WRITE CKSUM"
94   echo "        ${name0}       DEGRADED     0     0     0"
95   echo "          raidz2       DEGRADED     0     0     0"
96   echo "            ${guid0}   REMOVED      0     0     0  was ${fdname0}"
97   echo "            ${disk1}   ONLINE       0     0     0"
98   echo "            ${disk2}   ONLINE       0     0     0"
99   echo "            ${disk3}   ONLINE       0     0     0"
100   echo "errors: No known data errors"
101 )`
102 expect "${exp}" ${ZPOOL} status ${name0}
103 expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
104 wait_for_resilver ${name0}
105 exp=`(
106   echo "  pool: ${name0}"
107   echo " state: ONLINE"
108   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
109   echo "config:"
110   echo "        NAME          STATE   READ WRITE CKSUM"
111   echo "        ${name0}      ONLINE     0     0     0"
112   echo "          raidz2      ONLINE     0     0     0"
113   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
114   echo "            ${disk1}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
115   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
116   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
117   echo "errors: No known data errors"
118 )`
119 expect "${exp}" ${ZPOOL} status ${name0}
120 expect_ok ${ZPOOL} destroy ${name0}
121 expect_fl ${ZPOOL} status -x ${name0}
122 disk_create 0 ${dname0}
123
124 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
125 expect_ok ${ZPOOL} offline ${name0} ${disk1}
126 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
127 wait_for_resilver ${name0}
128 exp=`(
129   echo "  pool: ${name0}"
130   echo " state: ONLINE"
131   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
132   echo "config:"
133   echo "        NAME          STATE   READ WRITE CKSUM"
134   echo "        ${name0}      ONLINE     0     0     0"
135   echo "          raidz2      ONLINE     0     0     0"
136   echo "            ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
137   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
138   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
139   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
140   echo "errors: No known data errors"
141 )`
142 expect "${exp}" ${ZPOOL} status ${name0}
143 expect_ok ${ZPOOL} destroy ${name0}
144 expect_fl ${ZPOOL} status -x ${name0}
145
146 expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
147 expect_ok ${ZPOOL} export ${name0}
148 dname0=${disk0}
149 fdname0=${fdisk0}
150 guid0=`get_guid ${fdisk0}`
151 disk_destroy 0
152 disk_create 0 ${dname0}
153 dname1=${disk1}
154 fdname1=${fdisk1}
155 guid1=`get_guid ${fdisk1}`
156 disk_destroy 1
157 disk_create 1 ${dname1}
158 expect_ok ${ZPOOL} import ${import_flags} ${name0}
159 exp=`(
160   echo "  pool: ${name0}"
161   echo " state: DEGRADED"
162   echo "status: One or more devices could not be used because the label is missing or"
163   echo "      invalid.  Sufficient replicas exist for the pool to continue"
164   echo "      functioning in a degraded state."
165   echo "action: Replace the device using 'zpool replace'."
166   echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
167   echo " scrub: none requested"
168   echo "config:"
169   echo "        NAME          STATE     READ WRITE CKSUM"
170   echo "        ${name0}      DEGRADED     0     0     0"
171   echo "          raidz2      DEGRADED     0     0     0"
172   echo "            ${guid0}  UNAVAIL      0     0     0  was ${fdname0}"
173   echo "            ${guid1}  UNAVAIL      0     0     0  was ${fdname1}"
174   echo "            ${disk2}  ONLINE       0     0     0"
175   echo "            ${disk3}  ONLINE       0     0     0"
176   echo "errors: No known data errors"
177 )`
178 expect "${exp}" ${ZPOOL} status ${name0}
179 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
180 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
181 wait_for_resilver ${name0}
182 exp=`(
183   echo "  pool: ${name0}"
184   echo " state: ONLINE"
185   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
186   echo "config:"
187   echo "        NAME          STATE   READ WRITE CKSUM"
188   echo "        ${name0}      ONLINE     0     0     0"
189   echo "          raidz2      ONLINE     0     0     0"
190   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
191   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
192   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
193   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
194   echo "errors: No known data errors"
195 )`
196 expect "${exp}" ${ZPOOL} status ${name0}
197 expect_ok ${ZPOOL} destroy ${name0}
198 expect_fl ${ZPOOL} status -x ${name0}
199
200 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
201 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
202 expect_ok ${ZPOOL} replace ${name0} ${disk2} ${disk5}
203 wait_for_resilver ${name0}
204 exp=`(
205   echo "  pool: ${name0}"
206   echo " state: ONLINE"
207   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
208   echo "config:"
209   echo "        NAME          STATE   READ WRITE CKSUM"
210   echo "        ${name0}      ONLINE     0     0     0"
211   echo "          raidz2      ONLINE     0     0     0"
212   echo "            ${disk0}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
213   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
214   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
215   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
216   echo "errors: No known data errors"
217 )`
218 expect "${exp}" ${ZPOOL} status ${name0}
219 expect_ok ${ZPOOL} destroy ${name0}
220 expect_fl ${ZPOOL} status -x ${name0}
221
222 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
223 expect_ok ${ZPOOL} export ${name0}
224 dname0=${disk0}
225 fdname0=${fdisk0}
226 guid0=`get_guid ${fdisk0}`
227 disk_destroy 0
228 dname1=${disk1}
229 fdname1=${fdisk1}
230 guid1=`get_guid ${fdisk1}`
231 disk_destroy 1
232 expect_ok ${ZPOOL} import ${import_flags} ${name0}
233 exp=`(
234   echo "  pool: ${name0}"
235   echo " state: DEGRADED"
236   echo " scrub: none requested"
237   echo "config:"
238   echo "        NAME           STATE     READ WRITE CKSUM"
239   echo "        ${name0}       DEGRADED     0     0     0"
240   echo "          raidz2       DEGRADED     0     0     0"
241   echo "            ${guid0}   REMOVED      0     0     0  was ${fdname0}"
242   echo "            ${guid1}   REMOVED      0     0     0  was ${fdname1}"
243   echo "            ${disk2}   ONLINE       0     0     0"
244   echo "            ${disk3}   ONLINE       0     0     0"
245   echo "errors: No known data errors"
246 )`
247 expect "${exp}" ${ZPOOL} status ${name0}
248 expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
249 expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
250 wait_for_resilver ${name0}
251 exp=`(
252   echo "  pool: ${name0}"
253   echo " state: ONLINE"
254   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
255   echo "config:"
256   echo "        NAME          STATE   READ WRITE CKSUM"
257   echo "        ${name0}      ONLINE     0     0     0"
258   echo "          raidz2      ONLINE     0     0     0"
259   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
260   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
261   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
262   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
263   echo "errors: No known data errors"
264 )`
265 expect "${exp}" ${ZPOOL} status ${name0}
266 expect_ok ${ZPOOL} destroy ${name0}
267 expect_fl ${ZPOOL} status -x ${name0}
268 disk_create 0 ${dname0}
269 disk_create 1 ${dname1}
270
271 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
272 expect_ok ${ZPOOL} offline ${name0} ${disk0}
273 add_msg="# TODO Sun CR 6328632, Lustre bug 16878"
274 expect_ok ${ZPOOL} offline ${name0} ${disk1}
275 exp=`(
276   echo "  pool: ${name0}"
277   echo " state: DEGRADED"
278   echo "status: One or more devices has been taken offline by the administrator."
279   echo "      Sufficient replicas exist for the pool to continue functioning in a"
280   echo "      degraded state."
281   echo "action: Online the device using 'zpool online' or replace the device with"
282   echo "      'zpool replace'."
283   echo " scrub: none requested"
284   echo "config:"
285   echo "        NAME          STATE     READ WRITE CKSUM"
286   echo "        ${name0}      DEGRADED     0     0     0"
287   echo "          raidz2      DEGRADED     0     0     0"
288   echo "            ${disk0}  OFFLINE      0     0     0"
289   echo "            ${disk1}  OFFLINE      0     0     0"
290   echo "            ${disk2}  ONLINE       0     0     0"
291   echo "            ${disk3}  ONLINE       0     0     0"
292   echo "errors: No known data errors"
293 )`
294 expect "${exp}" ${ZPOOL} status ${name0}
295 add_msg=""
296 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
297 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
298 wait_for_resilver ${name0}
299 exp=`(
300   echo "  pool: ${name0}"
301   echo " state: ONLINE"
302   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
303   echo "config:"
304   echo "        NAME          STATE   READ WRITE CKSUM"
305   echo "        ${name0}      ONLINE     0     0     0"
306   echo "          raidz2      ONLINE     0     0     0"
307   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
308   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
309   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
310   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
311   echo "errors: No known data errors"
312 )`
313 expect "${exp}" ${ZPOOL} status ${name0}
314 expect_ok ${ZPOOL} destroy ${name0}
315 expect_fl ${ZPOOL} status -x ${name0}
316
317 expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
318 expect_ok ${ZPOOL} export ${name0}
319 dname0=${disk0}
320 fdname0=${fdisk0}
321 guid0=`get_guid ${fdisk0}`
322 disk_destroy 0
323 disk_create 0 ${dname0}
324 expect_ok ${ZPOOL} import ${import_flags} ${name0}
325 exp=`(
326   echo "  pool: ${name0}"
327   echo " state: DEGRADED"
328   echo "status: One or more devices could not be used because the label is missing or"
329   echo "      invalid.  Sufficient replicas exist for the pool to continue"
330   echo "      functioning in a degraded state."
331   echo "action: Replace the device using 'zpool replace'."
332   echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
333   echo " scrub: none requested"
334   echo "config:"
335   echo "        NAME          STATE     READ WRITE CKSUM"
336   echo "        ${name0}      DEGRADED     0     0     0"
337   echo "          raidz2      DEGRADED     0     0     0"
338   echo "            ${guid0}  UNAVAIL      0     0     0  was ${fdname0}"
339   echo "            ${disk1}  ONLINE       0     0     0"
340   echo "            ${disk2}  ONLINE       0     0     0"
341   echo "            ${disk3}  ONLINE       0     0     0"
342   echo "errors: No known data errors"
343 )`
344 expect "${exp}" ${ZPOOL} status ${name0}
345 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
346 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
347 wait_for_resilver ${name0}
348 exp=`(
349   echo "  pool: ${name0}"
350   echo " state: ONLINE"
351   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
352   echo "config:"
353   echo "        NAME          STATE   READ WRITE CKSUM"
354   echo "        ${name0}      ONLINE     0     0     0"
355   echo "          raidz2      ONLINE     0     0     0"
356   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
357   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
358   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
359   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
360   echo "errors: No known data errors"
361 )`
362 expect "${exp}" ${ZPOOL} status ${name0}
363 expect_ok ${ZPOOL} destroy ${name0}
364 expect_fl ${ZPOOL} status -x ${name0}
365
366 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
367 expect_ok ${ZPOOL} export ${name0}
368 dname0=${disk0}
369 fdname0=${fdisk0}
370 guid0=`get_guid ${fdisk0}`
371 disk_destroy 0
372 disk_create 0 ${dname0}
373 dname1=${disk1}
374 fdname1=${fdisk1}
375 guid1=`get_guid ${fdisk1}`
376 disk_destroy 1
377 expect_ok ${ZPOOL} import ${import_flags} ${name0}
378 exp=`(
379   echo "  pool: ${name0}"
380   echo " state: DEGRADED"
381   echo "status: One or more devices could not be used because the label is missing or"
382   echo "      invalid.  Sufficient replicas exist for the pool to continue"
383   echo "      functioning in a degraded state."
384   echo "action: Replace the device using 'zpool replace'."
385   echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
386   echo " scrub: none requested"
387   echo "config:"
388   echo "        NAME           STATE     READ WRITE CKSUM"
389   echo "        ${name0}       DEGRADED     0     0     0"
390   echo "          raidz2       DEGRADED     0     0     0"
391   echo "            ${guid0}   UNAVAIL      0     0     0  was ${fdname0}"
392   echo "            ${guid1}   REMOVED      0     0     0  was ${fdname1}"
393   echo "            ${disk2}   ONLINE       0     0     0"
394   echo "            ${disk3}   ONLINE       0     0     0"
395   echo "errors: No known data errors"
396 )`
397 expect "${exp}" ${ZPOOL} status ${name0}
398 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
399 expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
400 wait_for_resilver ${name0}
401 exp=`(
402   echo "  pool: ${name0}"
403   echo " state: ONLINE"
404   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
405   echo "config:"
406   echo "        NAME          STATE   READ WRITE CKSUM"
407   echo "        ${name0}      ONLINE     0     0     0"
408   echo "          raidz2      ONLINE     0     0     0"
409   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
410   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
411   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
412   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
413   echo "errors: No known data errors"
414 )`
415 expect "${exp}" ${ZPOOL} status ${name0}
416 expect_ok ${ZPOOL} destroy ${name0}
417 expect_fl ${ZPOOL} status -x ${name0}
418 disk_create 1 ${dname1}
419
420 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
421 expect_ok ${ZPOOL} export ${name0}
422 dname0=${disk0}
423 fdname0=${fdisk0}
424 guid0=`get_guid ${fdisk0}`
425 disk_destroy 0
426 expect_ok ${ZPOOL} import ${import_flags} ${name0}
427 exp=`(
428   echo "  pool: ${name0}"
429   echo " state: DEGRADED"
430   echo " scrub: none requested"
431   echo "config:"
432   echo "        NAME           STATE     READ WRITE CKSUM"
433   echo "        ${name0}       DEGRADED     0     0     0"
434   echo "          raidz2       DEGRADED     0     0     0"
435   echo "            ${guid0}   REMOVED      0     0     0  was ${fdname0}"
436   echo "            ${disk1}   ONLINE       0     0     0"
437   echo "            ${disk2}   ONLINE       0     0     0"
438   echo "            ${disk3}   ONLINE       0     0     0"
439   echo "errors: No known data errors"
440 )`
441 expect "${exp}" ${ZPOOL} status ${name0}
442 expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
443 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
444 wait_for_resilver ${name0}
445 exp=`(
446   echo "  pool: ${name0}"
447   echo " state: ONLINE"
448   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
449   echo "config:"
450   echo "        NAME          STATE   READ WRITE CKSUM"
451   echo "        ${name0}      ONLINE     0     0     0"
452   echo "          raidz2      ONLINE     0     0     0"
453   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
454   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
455   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
456   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
457   echo "errors: No known data errors"
458 )`
459 expect "${exp}" ${ZPOOL} status ${name0}
460 expect_ok ${ZPOOL} destroy ${name0}
461 expect_fl ${ZPOOL} status -x ${name0}
462 disk_create 0 ${dname0}
463
464 expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
465 expect_ok ${ZPOOL} offline ${name0} ${disk0}
466 exp=`(
467   echo "  pool: ${name0}"
468   echo " state: DEGRADED"
469   echo "status: One or more devices has been taken offline by the administrator."
470   echo "      Sufficient replicas exist for the pool to continue functioning in a"
471   echo "      degraded state."
472   echo "action: Online the device using 'zpool online' or replace the device with"
473   echo "      'zpool replace'."
474   echo " scrub: none requested"
475   echo "config:"
476   echo "        NAME          STATE     READ WRITE CKSUM"
477   echo "        ${name0}      DEGRADED     0     0     0"
478   echo "          raidz2      DEGRADED     0     0     0"
479   echo "            ${disk0}  OFFLINE      0     0     0"
480   echo "            ${disk1}  ONLINE       0     0     0"
481   echo "            ${disk2}  ONLINE       0     0     0"
482   echo "            ${disk3}  ONLINE       0     0     0"
483   echo "errors: No known data errors"
484 )`
485 expect "${exp}" ${ZPOOL} status ${name0}
486 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
487 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
488 wait_for_resilver ${name0}
489 exp=`(
490   echo "  pool: ${name0}"
491   echo " state: ONLINE"
492   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
493   echo "config:"
494   echo "        NAME          STATE   READ WRITE CKSUM"
495   echo "        ${name0}      ONLINE     0     0     0"
496   echo "          raidz2      ONLINE     0     0     0"
497   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
498   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
499   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
500   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
501   echo "errors: No known data errors"
502 )`
503 expect "${exp}" ${ZPOOL} status ${name0}
504 expect_ok ${ZPOOL} destroy ${name0}
505 expect_fl ${ZPOOL} status -x ${name0}
506
507 expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
508 expect_ok ${ZPOOL} offline ${name0} ${disk0}
509 expect_ok ${ZPOOL} export ${name0}
510 dname1=${disk1}
511 fdname1=${fdisk1}
512 guid1=`get_guid ${fdisk1}`
513 disk_destroy 1
514 disk_create 1 ${dname1}
515 expect_ok ${ZPOOL} import ${import_flags} ${name0}
516 exp=`(
517   echo "  pool: ${name0}"
518   echo " state: DEGRADED"
519   echo "status: One or more devices could not be used because the label is missing or"
520   echo "      invalid.  Sufficient replicas exist for the pool to continue"
521   echo "      functioning in a degraded state."
522   echo "action: Replace the device using 'zpool replace'."
523   echo "   see: http://www.sun.com/msg/ZFS-8000-4J"
524   echo " scrub: none requested"
525   echo "config:"
526   echo "        NAME          STATE     READ WRITE CKSUM"
527   echo "        ${name0}      DEGRADED     0     0     0"
528   echo "          raidz2      DEGRADED     0     0     0"
529   echo "            ${disk0}  OFFLINE      0     0     0"
530   echo "            ${guid1}  UNAVAIL      0     0     0  was ${fdname1}"
531   echo "            ${disk2}  ONLINE       0     0     0"
532   echo "            ${disk3}  ONLINE       0     0     0"
533   echo "errors: No known data errors"
534 )`
535 expect "${exp}" ${ZPOOL} status ${name0}
536 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
537 expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
538 wait_for_resilver ${name0}
539 exp=`(
540   echo "  pool: ${name0}"
541   echo " state: ONLINE"
542   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
543   echo "config:"
544   echo "        NAME          STATE   READ WRITE CKSUM"
545   echo "        ${name0}      ONLINE     0     0     0"
546   echo "          raidz2      ONLINE     0     0     0"
547   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
548   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
549   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
550   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
551   echo "errors: No known data errors"
552 )`
553 expect "${exp}" ${ZPOOL} status ${name0}
554 expect_ok ${ZPOOL} destroy ${name0}
555 expect_fl ${ZPOOL} status -x ${name0}
556
557 expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
558 expect_ok ${ZPOOL} offline ${name0} ${disk0}
559 expect_ok ${ZPOOL} export ${name0}
560 dname1=${disk1}
561 fdname1=${fdisk1}
562 guid1=`get_guid ${fdisk1}`
563 disk_destroy 1
564 expect_ok ${ZPOOL} import ${import_flags} ${name0}
565 exp=`(
566   echo "  pool: ${name0}"
567   echo " state: DEGRADED"
568   echo "status: One or more devices has been taken offline by the administrator."
569   echo "      Sufficient replicas exist for the pool to continue functioning in a"
570   echo "      degraded state."
571   echo "action: Online the device using 'zpool online' or replace the device with"
572   echo "      'zpool replace'."
573   echo " scrub: none requested"
574   echo "config:"
575   echo "        NAME           STATE     READ WRITE CKSUM"
576   echo "        ${name0}       DEGRADED     0     0     0"
577   echo "          raidz2       DEGRADED     0     0     0"
578   echo "            ${disk0}   OFFLINE      0     0     0"
579   echo "            ${guid1}   REMOVED      0     0     0  was ${fdname1}"
580   echo "            ${disk2}   ONLINE       0     0     0"
581   echo "            ${disk3}   ONLINE       0     0     0"
582   echo "errors: No known data errors"
583 )`
584 expect "${exp}" ${ZPOOL} status ${name0}
585 expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
586 expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
587 wait_for_resilver ${name0}
588 exp=`(
589   echo "  pool: ${name0}"
590   echo " state: ONLINE"
591   echo " scrub: (scrub|resilver) completed after [0-9]+h[0-9]+m with 0 errors on .*"
592   echo "config:"
593   echo "        NAME          STATE   READ WRITE CKSUM"
594   echo "        ${name0}      ONLINE     0     0     0"
595   echo "          raidz2      ONLINE     0     0     0"
596   echo "            ${disk4}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
597   echo "            ${disk5}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
598   echo "            ${disk2}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
599   echo "            ${disk3}  ONLINE     0     0     0(  [0-9.]+[A-Z] resilvered)?"
600   echo "errors: No known data errors"
601 )`
602 expect "${exp}" ${ZPOOL} status ${name0}
603 expect_ok ${ZPOOL} destroy ${name0}
604 expect_fl ${ZPOOL} status -x ${name0}
605 disk_create 1 ${dname1}
606
607 disks_destroy