Path: blob/main/tests/sys/geom/class/mirror/sync_error.sh
39635 views
1ATF_TEST=true2. $(atf_get_srcdir)/conf.sh34REG_READ_FP=debug.fail_point.g_mirror_regular_request_read56atf_test_case sync_read_error_2_disks cleanup7sync_read_error_2_disks_head()8{9atf_set "descr" \10"Ensure that we properly handle read errors during synchronization."11atf_set "require.user" "root"12}13sync_read_error_2_disks_body()14{15geom_atf_test_setup1617f1=$(mktemp ${base}.XXXXXX)18f2=$(mktemp ${base}.XXXXXX)1920atf_check dd if=/dev/zero bs=1M count=32 of=$f1 status=none21atf_check truncate -s 32M $f22223attach_md md1 -t vnode -f ${f1}24attach_md md2 -t vnode -f ${f2}2526atf_check gmirror label $name $md127devwait2829atf_check -s ignore -e empty -o not-empty sysctl ${REG_READ_FP}="1*return(5)[pid $(gmirror_worker_pid)]"3031# If a read error occurs while synchronizing and the mirror contains32# a single active disk, gmirror has no choice but to fail the33# synchronization and kick the new disk out of the mirror.34atf_check gmirror insert $name $md235sleep 0.136syncwait37atf_check [ $(gmirror status -s $name | wc -l) -eq 1 ]38atf_check -s exit:0 -o match:"DEGRADED $md1 \(ACTIVE\)" \39gmirror status -s $name40}41sync_read_error_2_disks_cleanup()42{43atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'44gmirror_test_cleanup45}4647atf_test_case sync_read_error_3_disks cleanup48sync_read_error_3_disks_head()49{50atf_set "descr" \51"Ensure that we properly handle read errors during synchronization."52atf_set "require.user" "root"53}54sync_read_error_3_disks_body()55{56geom_atf_test_setup5758f1=$(mktemp ${base}.XXXXXX)59f2=$(mktemp ${base}.XXXXXX)60f3=$(mktemp ${base}.XXXXXX)6162atf_check dd if=/dev/random bs=1M count=32 of=$f1 status=none63atf_check truncate -s 32M $f264atf_check truncate -s 32M $f36566attach_md md1 -t vnode -f ${f1}67attach_md md2 -t vnode -f ${f2}68attach_md md3 -t vnode -f ${f3}6970atf_check gmirror label $name $md171devwait7273atf_check gmirror insert $name $md274syncwait7576atf_check -s exit:0 -e empty -o not-empty sysctl ${REG_READ_FP}="1*return(5)[pid $(gmirror_worker_pid)]"7778# If a read error occurs while synchronizing a new disk, and we have79# multiple active disks, we retry the read after an error. The disk80# which returned the read error is kicked out of the mirror.81atf_check gmirror insert $name $md382syncwait83atf_check [ $(gmirror status -s $name | wc -l) -eq 2 ]84atf_check -s exit:0 -o match:"DEGRADED $md3 \(ACTIVE\)" \85gmirror status -s $name8687# Make sure that the two active disks are identical. Destroy the88# mirror first so that the metadata sectors are wiped.89if $(gmirror status -s $name | grep -q $md1); then90active=$md191else92active=$md293fi94atf_check gmirror destroy $name95atf_check cmp /dev/$active /dev/$md396}97sync_read_error_3_disks_cleanup()98{99atf_check -s ignore -e ignore -o ignore sysctl ${REG_READ_FP}='off'100gmirror_test_cleanup101}102103atf_init_test_cases()104{105atf_add_test_case sync_read_error_2_disks106atf_add_test_case sync_read_error_3_disks107}108109110