1#!/bin/sh 2 3# Test handling of write errors. 4 5. $(dirname $0)/conf.sh 6 7echo 1..4 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/random 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 19us0=$(attach_md -t vnode -f $m1) 20us1=$(attach_md -t vnode -f $m2) 21 22gmirror label $name /dev/$us0 /dev/$us1 23devwait 24 25tmp1=$(mktemp $base.XXXXXX) 26tmp2=$(mktemp $base.XXXXXX) 27 28dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1 29 30ENXIO=6 31# gmirror has special handling for ENXIO. It does not mark the failed component 32# as broken, allowing it to rejoin the mirror automatically when it appears. 33sysctl ${regwritefp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]" 34dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 35dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1 36sysctl ${regwritefp}='off' 37 38if cmp -s $tmp1 $tmp2; then 39 echo "ok 1" 40else 41 echo "not ok 1" 42fi 43 44# Verify that the genids still match after ENXIO. 45genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}') 46genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}') 47if [ $genid1 -eq $genid2 ]; then 48 echo "ok 2" 49else 50 echo "not ok 2" 51fi 52 53# The ENXIO should have caused a syncid bump. 54syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}') 55syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}') 56if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then 57 echo "ok 3" 58else 59 echo "not ok 3" 60fi 61 62# Force a retaste of the disconnected component. 63if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then 64 detach_md $us1 65 us1=$(attach_md -t vnode -f $m2) 66else 67 detach_md $us0 68 us0=$(attach_md -t vnode -f $m1) 69fi 70 71# Make sure that the retaste caused the mirror to automatically be re-added. 72if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then 73 echo "ok 4" 74else 75 echo "not ok 4" 76fi 77 78syncwait 79 80rm -f $m1 $m2 $tmp1 $tmp2 81