Path: blob/main/tests/sys/geom/class/mirror/11_test.sh
39635 views
#!/bin/sh12# Test handling of read errors.34. $(dirname $0)/conf.sh56echo 1..478set -e910ddbs=204811regreadfp="debug.fail_point.g_mirror_regular_request_read"12m1=$(mktemp $base.XXXXXX)13m2=$(mktemp $base.XXXXXX)1415dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&116dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&11718attach_md us0 -t vnode -f $m119attach_md us1 -t vnode -f $m22021gmirror label $name /dev/$us022gmirror insert $name /dev/$us123devwait24syncwait2526tmp1=$(mktemp $base.XXXXXX)27tmp2=$(mktemp $base.XXXXXX)2829ENXIO=630# gmirror has special handling for ENXIO. It does not mark the failed component31# as broken, allowing it to rejoin the mirror automatically when it appears.32sysctl ${regreadfp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]"33dd if=/dev/mirror/$name of=$tmp1 iseek=512 bs=$ddbs count=1 >/dev/null 2>&134dd if=/dev/$us1 of=$tmp2 iseek=512 bs=$ddbs count=1 >/dev/null 2>&135sysctl ${regreadfp}='off'3637if cmp -s $tmp1 $tmp2; then38echo "ok 1"39else40echo "not ok 1"41fi4243# Verify that the genids still match after ENXIO.44genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}')45genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}')46if [ $genid1 -eq $genid2 ]; then47echo "ok 2"48else49echo "not ok 2"50fi5152# Trigger a syncid bump.53dd if=/dev/zero of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&15455# The ENXIO+write should have caused a syncid bump.56syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}')57syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}')58if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then59echo "ok 3"60else61echo "not ok 3"62fi6364# Force a retaste of the disconnected component.65if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then66detach_md $us167attach_md us1 -t vnode -f $m268else69detach_md $us070attach_md us0 -t vnode -f $m171fi7273# Make sure that the retaste caused the mirror to automatically be re-added.74if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then75echo "ok 4"76else77echo "not ok 4"78fi7980syncwait8182rm -f $m1 $m2 $tmp1 $tmp2838485