Path: blob/main/tests/sys/geom/class/mirror/8_test.sh
39635 views
#!/bin/sh12# Regression test for r317712.34. `dirname $0`/conf.sh56if ! [ -c /dev/mdctl ]; then7echo "1..0 # SKIP no /dev/mdctl to create md devices"8exit 09fi1011echo 1..11213ddbs=204814m1=`mktemp $base.XXXXXX` || exit 115m2=`mktemp $base.XXXXXX` || exit 11617dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&118dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&11920us0=$(mdconfig -t vnode -f $m1) || exit 121us1=$(mdconfig -t vnode -f $m2) || exit 12223gmirror label $name /dev/$us0 /dev/$us1 || exit 124devwait2526# Ensure that the mirrors are marked dirty, and then disconnect them.27# We need to have the gmirror provider open when destroying the MDs since28# gmirror will automatically mark the mirrors clean when the provider is closed.29exec 9>/dev/mirror/$name30dd if=/dev/zero bs=$ddbs count=1 >&9 2>/dev/null31mdconfig -d -u ${us0#md} -o force || exit 132mdconfig -d -u ${us1#md} -o force || exit 133exec 9>&-3435dd if=/dev/random of=$m1 bs=$ddbs count=1 conv=notrunc >/dev/null 2>&136attach_md us0 -t vnode -f $m1 || exit 137devwait # This will take kern.geom.mirror.timeout seconds.3839# Re-attach the second mirror and wait for it to synchronize.40attach_md us1 -t vnode -f $m2 || exit 141syncwait4243# Verify the two mirrors are identical. Destroy the gmirror first so that44# the mirror metadata is wiped; otherwise the metadata blocks will fail45# the comparison. It would be nice to do this with a "gmirror verify"46# command instead.47gmirror destroy $name48if cmp -s ${m1} ${m2}; then49echo "ok 1"50else51echo "not ok 1"52fi5354rm -f $m1 $m2555657