Path: blob/main/tests/sys/geom/class/mirror/12_test.sh
39635 views
#!/bin/sh12# Test handling of write errors.34. $(dirname $0)/conf.sh56echo 1..378set -e910ddbs=204811regwritefp="debug.fail_point.g_mirror_regular_request_write"12m1=$(mktemp $base.XXXXXX)13m2=$(mktemp $base.XXXXXX)1415dd if=/dev/zero 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/$us0 /dev/$us122devwait2324tmp1=$(mktemp $base.XXXXXX)25tmp2=$(mktemp $base.XXXXXX)26dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&12728EIO=529# gmirror should kick one of the mirrors out after hitting EIO.30sysctl ${regwritefp}="1*return(${EIO})[pid $(gmirror_worker_pid)]"31dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&132dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&133sysctl ${regwritefp}='off'3435if cmp -s $tmp1 $tmp2; then36echo "ok 1"37else38echo "not ok 1"39fi4041# Make sure that one of the mirrors was marked broken.42genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}')43genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}')44if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then45echo "ok 2"46else47echo "not ok 2"48fi4950# Force a retaste of the disconnected component.51if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then52detach_md $us153attach_md us1 -t vnode -f $m254else55detach_md $us056attach_md us0 -t vnode -f $m157fi5859# Make sure that the component wasn't re-added to the gmirror.60if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then61echo "ok 3"62else63echo "not ok 3"64fi6566rm -f $m1 $m2 $tmp1 $tmp2676869