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