xref: /freebsd/tools/regression/zfs/zpool/replace/raidz2.t (revision 63a938566d524836885917d95bd491aa4400b181)
1#!/bin/sh
2# $FreeBSD$
3
4dir=`dirname $0`
5. ${dir}/../../misc.sh
6
7echo "1..115"
8
9disks_create 6
10names_create 1
11
12expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
13expect_ok ${ZPOOL} export ${name0}
14dname0=${disk0}
15fdname0=${fdisk0}
16guid0=`get_guid ${fdisk0}`
17disk_destroy 0
18disk_create 0 ${dname0}
19expect_ok ${ZPOOL} import ${import_flags} ${name0}
20exp=`(
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)`
39expect "${exp}" ${ZPOOL} status ${name0}
40expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
41wait_for_resilver ${name0}
42exp=`(
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)`
56expect "${exp}" ${ZPOOL} status ${name0}
57expect_ok ${ZPOOL} destroy ${name0}
58expect_fl ${ZPOOL} status -x ${name0}
59
60expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
61expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
62wait_for_resilver ${name0}
63exp=`(
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)`
77expect "${exp}" ${ZPOOL} status ${name0}
78expect_ok ${ZPOOL} destroy ${name0}
79expect_fl ${ZPOOL} status -x ${name0}
80
81expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
82expect_ok ${ZPOOL} export ${name0}
83dname0=${disk0}
84fdname0=${fdisk0}
85guid0=`get_guid ${fdisk0}`
86disk_destroy 0
87expect_ok ${ZPOOL} import ${import_flags} ${name0}
88exp=`(
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)`
102expect "${exp}" ${ZPOOL} status ${name0}
103expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
104wait_for_resilver ${name0}
105exp=`(
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)`
119expect "${exp}" ${ZPOOL} status ${name0}
120expect_ok ${ZPOOL} destroy ${name0}
121expect_fl ${ZPOOL} status -x ${name0}
122disk_create 0 ${dname0}
123
124expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
125expect_ok ${ZPOOL} offline ${name0} ${disk1}
126expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
127wait_for_resilver ${name0}
128exp=`(
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)`
142expect "${exp}" ${ZPOOL} status ${name0}
143expect_ok ${ZPOOL} destroy ${name0}
144expect_fl ${ZPOOL} status -x ${name0}
145
146expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
147expect_ok ${ZPOOL} export ${name0}
148dname0=${disk0}
149fdname0=${fdisk0}
150guid0=`get_guid ${fdisk0}`
151disk_destroy 0
152disk_create 0 ${dname0}
153dname1=${disk1}
154fdname1=${fdisk1}
155guid1=`get_guid ${fdisk1}`
156disk_destroy 1
157disk_create 1 ${dname1}
158expect_ok ${ZPOOL} import ${import_flags} ${name0}
159exp=`(
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)`
178expect "${exp}" ${ZPOOL} status ${name0}
179expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
180expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
181wait_for_resilver ${name0}
182exp=`(
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)`
196expect "${exp}" ${ZPOOL} status ${name0}
197expect_ok ${ZPOOL} destroy ${name0}
198expect_fl ${ZPOOL} status -x ${name0}
199
200expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
201expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk4}
202expect_ok ${ZPOOL} replace ${name0} ${disk2} ${disk5}
203wait_for_resilver ${name0}
204exp=`(
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)`
218expect "${exp}" ${ZPOOL} status ${name0}
219expect_ok ${ZPOOL} destroy ${name0}
220expect_fl ${ZPOOL} status -x ${name0}
221
222expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
223expect_ok ${ZPOOL} export ${name0}
224dname0=${disk0}
225fdname0=${fdisk0}
226guid0=`get_guid ${fdisk0}`
227disk_destroy 0
228dname1=${disk1}
229fdname1=${fdisk1}
230guid1=`get_guid ${fdisk1}`
231disk_destroy 1
232expect_ok ${ZPOOL} import ${import_flags} ${name0}
233exp=`(
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)`
247expect "${exp}" ${ZPOOL} status ${name0}
248expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
249expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
250wait_for_resilver ${name0}
251exp=`(
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)`
265expect "${exp}" ${ZPOOL} status ${name0}
266expect_ok ${ZPOOL} destroy ${name0}
267expect_fl ${ZPOOL} status -x ${name0}
268disk_create 0 ${dname0}
269disk_create 1 ${dname1}
270
271expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
272expect_ok ${ZPOOL} offline ${name0} ${disk0}
273add_msg="# TODO Sun CR 6328632, Lustre bug 16878"
274expect_ok ${ZPOOL} offline ${name0} ${disk1}
275exp=`(
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)`
294expect "${exp}" ${ZPOOL} status ${name0}
295add_msg=""
296expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
297expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
298wait_for_resilver ${name0}
299exp=`(
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)`
313expect "${exp}" ${ZPOOL} status ${name0}
314expect_ok ${ZPOOL} destroy ${name0}
315expect_fl ${ZPOOL} status -x ${name0}
316
317expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
318expect_ok ${ZPOOL} export ${name0}
319dname0=${disk0}
320fdname0=${fdisk0}
321guid0=`get_guid ${fdisk0}`
322disk_destroy 0
323disk_create 0 ${dname0}
324expect_ok ${ZPOOL} import ${import_flags} ${name0}
325exp=`(
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)`
344expect "${exp}" ${ZPOOL} status ${name0}
345expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
346expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
347wait_for_resilver ${name0}
348exp=`(
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)`
362expect "${exp}" ${ZPOOL} status ${name0}
363expect_ok ${ZPOOL} destroy ${name0}
364expect_fl ${ZPOOL} status -x ${name0}
365
366expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
367expect_ok ${ZPOOL} export ${name0}
368dname0=${disk0}
369fdname0=${fdisk0}
370guid0=`get_guid ${fdisk0}`
371disk_destroy 0
372disk_create 0 ${dname0}
373dname1=${disk1}
374fdname1=${fdisk1}
375guid1=`get_guid ${fdisk1}`
376disk_destroy 1
377expect_ok ${ZPOOL} import ${import_flags} ${name0}
378exp=`(
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)`
397expect "${exp}" ${ZPOOL} status ${name0}
398expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
399expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
400wait_for_resilver ${name0}
401exp=`(
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)`
415expect "${exp}" ${ZPOOL} status ${name0}
416expect_ok ${ZPOOL} destroy ${name0}
417expect_fl ${ZPOOL} status -x ${name0}
418disk_create 1 ${dname1}
419
420expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
421expect_ok ${ZPOOL} export ${name0}
422dname0=${disk0}
423fdname0=${fdisk0}
424guid0=`get_guid ${fdisk0}`
425disk_destroy 0
426expect_ok ${ZPOOL} import ${import_flags} ${name0}
427exp=`(
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)`
441expect "${exp}" ${ZPOOL} status ${name0}
442expect_ok ${ZPOOL} replace ${name0} ${dname0} ${disk4}
443expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
444wait_for_resilver ${name0}
445exp=`(
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)`
459expect "${exp}" ${ZPOOL} status ${name0}
460expect_ok ${ZPOOL} destroy ${name0}
461expect_fl ${ZPOOL} status -x ${name0}
462disk_create 0 ${dname0}
463
464expect_ok ${ZPOOL} create ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
465expect_ok ${ZPOOL} offline ${name0} ${disk0}
466exp=`(
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)`
485expect "${exp}" ${ZPOOL} status ${name0}
486expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
487expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
488wait_for_resilver ${name0}
489exp=`(
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)`
503expect "${exp}" ${ZPOOL} status ${name0}
504expect_ok ${ZPOOL} destroy ${name0}
505expect_fl ${ZPOOL} status -x ${name0}
506
507expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
508expect_ok ${ZPOOL} offline ${name0} ${disk0}
509expect_ok ${ZPOOL} export ${name0}
510dname1=${disk1}
511fdname1=${fdisk1}
512guid1=`get_guid ${fdisk1}`
513disk_destroy 1
514disk_create 1 ${dname1}
515expect_ok ${ZPOOL} import ${import_flags} ${name0}
516exp=`(
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)`
535expect "${exp}" ${ZPOOL} status ${name0}
536expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
537expect_ok ${ZPOOL} replace ${name0} ${disk1} ${disk5}
538wait_for_resilver ${name0}
539exp=`(
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)`
553expect "${exp}" ${ZPOOL} status ${name0}
554expect_ok ${ZPOOL} destroy ${name0}
555expect_fl ${ZPOOL} status -x ${name0}
556
557expect_ok ${ZPOOL} create ${zpool_f_flag} ${name0} raidz2 ${disk0} ${disk1} ${disk2} ${disk3}
558expect_ok ${ZPOOL} offline ${name0} ${disk0}
559expect_ok ${ZPOOL} export ${name0}
560dname1=${disk1}
561fdname1=${fdisk1}
562guid1=`get_guid ${fdisk1}`
563disk_destroy 1
564expect_ok ${ZPOOL} import ${import_flags} ${name0}
565exp=`(
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)`
584expect "${exp}" ${ZPOOL} status ${name0}
585expect_ok ${ZPOOL} replace ${name0} ${disk0} ${disk4}
586expect_ok ${ZPOOL} replace ${name0} ${dname1} ${disk5}
587wait_for_resilver ${name0}
588exp=`(
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)`
602expect "${exp}" ${ZPOOL} status ${name0}
603expect_ok ${ZPOOL} destroy ${name0}
604expect_fl ${ZPOOL} status -x ${name0}
605disk_create 1 ${dname1}
606
607disks_destroy
608