Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/8_test.sh
39635 views
1
#!/bin/sh
2
3
# Regression test for r317712.
4
5
. `dirname $0`/conf.sh
6
7
if ! [ -c /dev/mdctl ]; then
8
echo "1..0 # SKIP no /dev/mdctl to create md devices"
9
exit 0
10
fi
11
12
echo 1..1
13
14
ddbs=2048
15
m1=`mktemp $base.XXXXXX` || exit 1
16
m2=`mktemp $base.XXXXXX` || exit 1
17
18
dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
19
dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
20
21
us0=$(mdconfig -t vnode -f $m1) || exit 1
22
us1=$(mdconfig -t vnode -f $m2) || exit 1
23
24
gmirror label $name /dev/$us0 /dev/$us1 || exit 1
25
devwait
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.
30
exec 9>/dev/mirror/$name
31
dd if=/dev/zero bs=$ddbs count=1 >&9 2>/dev/null
32
mdconfig -d -u ${us0#md} -o force || exit 1
33
mdconfig -d -u ${us1#md} -o force || exit 1
34
exec 9>&-
35
36
dd if=/dev/random of=$m1 bs=$ddbs count=1 conv=notrunc >/dev/null 2>&1
37
attach_md us0 -t vnode -f $m1 || exit 1
38
devwait # This will take kern.geom.mirror.timeout seconds.
39
40
# Re-attach the second mirror and wait for it to synchronize.
41
attach_md us1 -t vnode -f $m2 || exit 1
42
syncwait
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.
48
gmirror destroy $name
49
if cmp -s ${m1} ${m2}; then
50
echo "ok 1"
51
else
52
echo "not ok 1"
53
fi
54
55
rm -f $m1 $m2
56
57