Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/9_test.sh
39635 views
1
#!/bin/sh
2
3
# Regression test for r306743.
4
5
. `dirname $0`/conf.sh
6
7
echo 1..1
8
9
ddbs=2048
10
m1=`mktemp $base.XXXXXX` || exit 1
11
m2=`mktemp $base.XXXXXX` || exit 1
12
m3=`mktemp $base.XXXXXX` || exit 1
13
14
dd if=/dev/zero of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
15
dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
16
dd if=/dev/zero of=$m3 bs=$ddbs count=1024 >/dev/null 2>&1
17
18
attach_md us0 -t vnode -f $m1 || exit 1
19
attach_md us1 -t vnode -f $m2 || exit 1
20
attach_md us2 -t vnode -f $m3 || exit 1
21
22
gmirror label $name /dev/$us0 /dev/$us1 || exit 1
23
devwait
24
25
# Break one of the mirrors by forcing a single metadata write error.
26
# When dd closes the mirror provider, gmirror will attempt to mark the mirrors
27
# clean, and will kick one of the mirrors out upon hitting the error.
28
sysctl debug.fail_point.g_mirror_metadata_write="1*return(5)[pid $(gmirror_worker_pid)]" || exit 1
29
dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
30
sysctl debug.fail_point.g_mirror_metadata_write='off' || exit 1
31
32
# Replace the broken mirror, and then stop the gmirror.
33
gmirror forget $name || exit 1
34
gmirror insert $name /dev/$us2 || exit 1
35
syncwait
36
gmirror stop $name || exit 1
37
38
# Restart the gmirror on the original two mirrors. One of them is broken,
39
# so we should end up with a degraded gmirror.
40
gmirror activate $name /dev/$us0 /dev/$us1 || exit 1
41
devwait
42
dd if=/dev/random of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
43
44
# Re-add the replacement mirror and verify the two mirrors are synchronized.
45
# Destroy the gmirror first so that the mirror metadata is wiped; otherwise
46
# the metadata blocks will fail the comparison. It would be nice to do this
47
# with a "gmirror verify" command instead.
48
gmirror activate $name /dev/$us2 || exit 1
49
syncwait
50
gmirror destroy $name || exit 1
51
if cmp -s $m1 $m3; then
52
echo "ok 1"
53
else
54
echo "not ok 1"
55
fi
56
57
rm -f $m1 $m2 $m3
58
59