Path: blob/main/tests/sys/geom/class/mirror/13_test.sh
39635 views
#!/bin/sh12# Test handling of write errors.34. $(dirname $0)/conf.sh56echo 1..478set -e910ddbs=204811regwritefp="debug.fail_point.g_mirror_regular_request_write"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/$us0 /dev/$us122devwait2324tmp1=$(mktemp $base.XXXXXX)25tmp2=$(mktemp $base.XXXXXX)2627dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&12829ENXIO=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 ${regwritefp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]"33dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&134dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&135sysctl ${regwritefp}='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# The ENXIO should have caused a syncid bump.53syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}')54syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}')55if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then56echo "ok 3"57else58echo "not ok 3"59fi6061# Force a retaste of the disconnected component.62if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then63detach_md $us164attach_md us1 -t vnode -f $m265else66detach_md $us067attach_md us0 -t vnode -f $m168fi6970# Make sure that the retaste caused the mirror to automatically be re-added.71if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then72echo "ok 4"73else74echo "not ok 4"75fi7677syncwait7879rm -f $m1 $m2 $tmp1 $tmp2808182