Path: blob/main/tests/sys/geom/class/mirror/10_test.sh
39635 views
#!/bin/sh12# Test handling of read errors.34. $(dirname $0)/conf.sh56echo 1..378set -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)2829EIO=530# gmirror should retry a failed read from the other mirror.31sysctl ${regreadfp}="1*return(${EIO})[pid $(gmirror_worker_pid)]"32dd if=/dev/mirror/$name of=$tmp1 iseek=256 bs=$ddbs count=1 >/dev/null 2>&133dd if=/dev/$us1 of=$tmp2 iseek=256 bs=$ddbs count=1 >/dev/null 2>&134sysctl ${regreadfp}='off'3536if cmp -s $tmp1 $tmp2; then37echo "ok 1"38else39echo "not ok 1"40fi4142# Make sure that one of the mirrors was marked broken.43genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}')44genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}')45if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then46echo "ok 2"47else48echo "not ok 2"49fi5051# Force a retaste of the disconnected component.52if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then53detach_md $us154attach_md us1 -t vnode -f $m255else56detach_md $us057attach_md us0 -t vnode -f $m158fi5960# Make sure that the component wasn't re-added to the gmirror.61if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then62echo "ok 3"63else64echo "not ok 3"65fi6667rm -f $m1 $m2 $tmp1 $tmp2686970