4 . $(atf_get_srcdir)/conf.sh
6 REG_READ_FP=debug.fail_point.g_mirror_regular_request_read
8 atf_test_case sync_read_error_2_disks cleanup
9 sync_read_error_2_disks_head()
12 "Ensure that we properly handle read errors during synchronization."
13 atf_set "require.user" "root"
15 sync_read_error_2_disks_body()
19 f1=$(mktemp ${base}.XXXXXX)
20 f2=$(mktemp ${base}.XXXXXX)
22 atf_check dd if=/dev/zero bs=1M count=32 of=$f1 status=none
23 atf_check truncate -s 32M $f2
25 md1=$(attach_md -t vnode -f ${f1})
26 md2=$(attach_md -t vnode -f ${f2})
28 atf_check gmirror label $name $md1
31 atf_check -s ignore -e empty -o not-empty sysctl ${REG_READ_FP}='1*return(5)'
33 # If a read error occurs while synchronizing and the mirror contains
34 # a single active disk, gmirror has no choice but to fail the
35 # synchronization and kick the new disk out of the mirror.
36 atf_check gmirror insert $name $md2
39 atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ]
40 atf_check -s exit:0 -o match:"DEGRADED $md1 \(ACTIVE\)" \
41 gmirror status -s $name
43 sync_read_error_2_disks_cleanup()
45 atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'
49 atf_test_case sync_read_error_3_disks cleanup
50 sync_read_error_3_disks_head()
53 "Ensure that we properly handle read errors during synchronization."
54 atf_set "require.user" "root"
56 sync_read_error_3_disks_body()
60 f1=$(mktemp ${base}.XXXXXX)
61 f2=$(mktemp ${base}.XXXXXX)
62 f3=$(mktemp ${base}.XXXXXX)
64 atf_check dd if=/dev/random bs=1M count=32 of=$f1 status=none
65 atf_check truncate -s 32M $f2
66 atf_check truncate -s 32M $f3
68 md1=$(attach_md -t vnode -f ${f1})
69 md2=$(attach_md -t vnode -f ${f2})
70 md3=$(attach_md -t vnode -f ${f3})
72 atf_check gmirror label $name $md1
75 atf_check gmirror insert $name $md2
78 atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}='1*return(5)'
80 # If a read error occurs while synchronizing a new disk, and we have
81 # multiple active disks, we retry the read after an error. The disk
82 # which returned the read error is kicked out of the mirror.
83 atf_check gmirror insert $name $md3
85 atf_check [ $(gmirror status -s $name | wc -l) -eq 2 ]
86 atf_check -s exit:0 -o match:"DEGRADED $md3 \(ACTIVE\)" \
87 gmirror status -s $name
89 # Make sure that the two active disks are identical. Destroy the
90 # mirror first so that the metadata sectors are wiped.
91 if $(gmirror status -s $name | grep -q $md1); then
96 atf_check gmirror destroy $name
97 atf_check cmp /dev/$active /dev/$md3
99 sync_read_error_3_disks_cleanup()
101 atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'
105 atf_init_test_cases()
107 atf_add_test_case sync_read_error_2_disks
108 atf_add_test_case sync_read_error_3_disks