1f55b9be8SMark Johnston#!/bin/sh 2f55b9be8SMark Johnston 3f55b9be8SMark Johnston# Regression test for r306743. 4f55b9be8SMark Johnston 5f55b9be8SMark Johnston. `dirname $0`/conf.sh 6f55b9be8SMark Johnston 7f55b9be8SMark Johnstonecho 1..1 8f55b9be8SMark Johnston 9f55b9be8SMark Johnstonddbs=2048 10f55b9be8SMark Johnstonm1=`mktemp $base.XXXXXX` || exit 1 11f55b9be8SMark Johnstonm2=`mktemp $base.XXXXXX` || exit 1 12f55b9be8SMark Johnstonm3=`mktemp $base.XXXXXX` || exit 1 13f55b9be8SMark Johnston 14f55b9be8SMark Johnstondd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 15f55b9be8SMark Johnstondd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 16f55b9be8SMark Johnstondd if=/dev/zero of=$m3 bs=$ddbs count=1024 >/dev/null 2>&1 17f55b9be8SMark Johnston 18*96950419SGleb Smirnoffattach_md us0 -t vnode -f $m1 || exit 1 19*96950419SGleb Smirnoffattach_md us1 -t vnode -f $m2 || exit 1 20*96950419SGleb Smirnoffattach_md us2 -t vnode -f $m3 || exit 1 21f55b9be8SMark Johnston 22f55b9be8SMark Johnstongmirror label $name /dev/$us0 /dev/$us1 || exit 1 23f55b9be8SMark Johnstondevwait 24f55b9be8SMark Johnston 25f55b9be8SMark Johnston# Break one of the mirrors by forcing a single metadata write error. 26f55b9be8SMark Johnston# When dd closes the mirror provider, gmirror will attempt to mark the mirrors 27f55b9be8SMark Johnston# clean, and will kick one of the mirrors out upon hitting the error. 283cee7cb2SBryan Drewerysysctl debug.fail_point.g_mirror_metadata_write="1*return(5)[pid $(gmirror_worker_pid)]" || exit 1 29f55b9be8SMark Johnstondd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 30f55b9be8SMark Johnstonsysctl debug.fail_point.g_mirror_metadata_write='off' || exit 1 31f55b9be8SMark Johnston 32f55b9be8SMark Johnston# Replace the broken mirror, and then stop the gmirror. 33f55b9be8SMark Johnstongmirror forget $name || exit 1 34f55b9be8SMark Johnstongmirror insert $name /dev/$us2 || exit 1 35504eda20SMark Johnstonsyncwait 36f55b9be8SMark Johnstongmirror stop $name || exit 1 37f55b9be8SMark Johnston 38f55b9be8SMark Johnston# Restart the gmirror on the original two mirrors. One of them is broken, 39f55b9be8SMark Johnston# so we should end up with a degraded gmirror. 40f55b9be8SMark Johnstongmirror activate $name /dev/$us0 /dev/$us1 || exit 1 41f55b9be8SMark Johnstondevwait 42f55b9be8SMark Johnstondd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1 43f55b9be8SMark Johnston 44f55b9be8SMark Johnston# Re-add the replacement mirror and verify the two mirrors are synchronized. 45f55b9be8SMark Johnston# Destroy the gmirror first so that the mirror metadata is wiped; otherwise 46f55b9be8SMark Johnston# the metadata blocks will fail the comparison. It would be nice to do this 47f55b9be8SMark Johnston# with a "gmirror verify" command instead. 48f55b9be8SMark Johnstongmirror activate $name /dev/$us2 || exit 1 49504eda20SMark Johnstonsyncwait 50f55b9be8SMark Johnstongmirror destroy $name || exit 1 51f55b9be8SMark Johnstonif cmp -s $m1 $m3; then 52f55b9be8SMark Johnston echo "ok 1" 53f55b9be8SMark Johnstonelse 54f55b9be8SMark Johnston echo "not ok 1" 55f55b9be8SMark Johnstonfi 56f55b9be8SMark Johnston 57f55b9be8SMark Johnstonrm -f $m1 $m2 $m3 58