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