1#!/bin/sh 2 3# Test handling of write errors. 4 5. $(dirname $0)/conf.sh 6 7echo 1..3 8 9set -e 10 11ddbs=2048 12regwritefp="debug.fail_point.g_mirror_regular_request_write" 13m1=$(mktemp $base.XXXXXX) 14m2=$(mktemp $base.XXXXXX) 15 16dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 17dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 18 19attach_md us0 -t vnode -f $m1 20attach_md us1 -t vnode -f $m2 21 22gmirror label $name /dev/$us0 /dev/$us1 23devwait 24 25tmp1=$(mktemp $base.XXXXXX) 26tmp2=$(mktemp $base.XXXXXX) 27dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 28 29EIO=5 30# gmirror should kick one of the mirrors out after hitting EIO. 31sysctl ${regwritefp}="1*return(${EIO})[pid $(gmirror_worker_pid)]" 32dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 33dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 34sysctl ${regwritefp}='off' 35 36if cmp -s $tmp1 $tmp2; then 37 echo "ok 1" 38else 39 echo "not ok 1" 40fi 41 42# 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)) ]; then 46 echo "ok 2" 47else 48 echo "not ok 2" 49fi 50 51# Force a retaste of the disconnected component. 52if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then 53 detach_md $us1 54 attach_md us1 -t vnode -f $m2 55else 56 detach_md $us0 57 attach_md us0 -t vnode -f $m1 58fi 59 60# Make sure that the component wasn't re-added to the gmirror. 61if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then 62 echo "ok 3" 63else 64 echo "not ok 3" 65fi 66 67rm -f $m1 $m2 $tmp1 $tmp2 68