1f55b9be8SMark Johnston#!/bin/sh 2f55b9be8SMark Johnston 3f55b9be8SMark Johnston# Regression test for r317712. 4f55b9be8SMark Johnston 5f55b9be8SMark Johnston. `dirname $0`/conf.sh 6f55b9be8SMark Johnston 7ea823622SWarner Loshif ! [ -c /dev/mdctl ]; then 8ea823622SWarner Losh echo "1..0 # SKIP no /dev/mdctl to create md devices" 9ea823622SWarner Losh exit 0 10ea823622SWarner Loshfi 11ea823622SWarner Losh 12f55b9be8SMark Johnstonecho 1..1 13f55b9be8SMark Johnston 14f55b9be8SMark Johnstonddbs=2048 15f55b9be8SMark Johnstonm1=`mktemp $base.XXXXXX` || exit 1 16f55b9be8SMark Johnstonm2=`mktemp $base.XXXXXX` || exit 1 17f55b9be8SMark Johnston 18f55b9be8SMark Johnstondd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1 19f55b9be8SMark Johnstondd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1 20f55b9be8SMark Johnston 21f55b9be8SMark Johnstonus0=$(mdconfig -t vnode -f $m1) || exit 1 22f55b9be8SMark Johnstonus1=$(mdconfig -t vnode -f $m2) || exit 1 23f55b9be8SMark Johnston 24f55b9be8SMark Johnstongmirror label $name /dev/$us0 /dev/$us1 || exit 1 25f55b9be8SMark Johnstondevwait 26f55b9be8SMark Johnston 27f55b9be8SMark Johnston# Ensure that the mirrors are marked dirty, and then disconnect them. 28f55b9be8SMark Johnston# We need to have the gmirror provider open when destroying the MDs since 29f55b9be8SMark Johnston# gmirror will automatically mark the mirrors clean when the provider is closed. 30f55b9be8SMark Johnstonexec 9>/dev/mirror/$name 31f55b9be8SMark Johnstondd if=/dev/zero bs=$ddbs count=1 >&9 2>/dev/null 32f55b9be8SMark Johnstonmdconfig -d -u ${us0#md} -o force || exit 1 33f55b9be8SMark Johnstonmdconfig -d -u ${us1#md} -o force || exit 1 34f55b9be8SMark Johnstonexec 9>&- 35f55b9be8SMark Johnston 36f55b9be8SMark Johnstondd if=/dev/random of=$m1 bs=$ddbs count=1 conv=notrunc >/dev/null 2>&1 37*96950419SGleb Smirnoffattach_md us0 -t vnode -f $m1 || exit 1 38f55b9be8SMark Johnstondevwait # This will take kern.geom.mirror.timeout seconds. 39f55b9be8SMark Johnston 40f55b9be8SMark Johnston# Re-attach the second mirror and wait for it to synchronize. 41*96950419SGleb Smirnoffattach_md us1 -t vnode -f $m2 || exit 1 42504eda20SMark Johnstonsyncwait 43f55b9be8SMark Johnston 44f55b9be8SMark Johnston# Verify the two mirrors are identical. Destroy the gmirror first so that 45f55b9be8SMark Johnston# the mirror metadata is wiped; otherwise the metadata blocks will fail 46f55b9be8SMark Johnston# the comparison. It would be nice to do this with a "gmirror verify" 47f55b9be8SMark Johnston# command instead. 48f55b9be8SMark Johnstongmirror destroy $name 49f55b9be8SMark Johnstonif cmp -s ${m1} ${m2}; then 50f55b9be8SMark Johnston echo "ok 1" 51f55b9be8SMark Johnstonelse 52f55b9be8SMark Johnston echo "not ok 1" 53f55b9be8SMark Johnstonfi 54f55b9be8SMark Johnston 55f55b9be8SMark Johnstonrm -f $m1 $m2 56