Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/10_test.sh
39635 views
1
#!/bin/sh
2
3
# Test handling of read errors.
4
5
. $(dirname $0)/conf.sh
6
7
echo 1..3
8
9
set -e
10
11
ddbs=2048
12
regreadfp="debug.fail_point.g_mirror_regular_request_read"
13
m1=$(mktemp $base.XXXXXX)
14
m2=$(mktemp $base.XXXXXX)
15
16
dd if=/dev/random of=$m1 bs=$ddbs count=1024 >/dev/null 2>&1
17
dd if=/dev/zero of=$m2 bs=$ddbs count=1024 >/dev/null 2>&1
18
19
attach_md us0 -t vnode -f $m1
20
attach_md us1 -t vnode -f $m2
21
22
gmirror label $name /dev/$us0
23
gmirror insert $name /dev/$us1
24
devwait
25
syncwait
26
27
tmp1=$(mktemp $base.XXXXXX)
28
tmp2=$(mktemp $base.XXXXXX)
29
30
EIO=5
31
# gmirror should retry a failed read from the other mirror.
32
sysctl ${regreadfp}="1*return(${EIO})[pid $(gmirror_worker_pid)]"
33
dd if=/dev/mirror/$name of=$tmp1 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1
34
dd if=/dev/$us1 of=$tmp2 iseek=256 bs=$ddbs count=1 >/dev/null 2>&1
35
sysctl ${regreadfp}='off'
36
37
if cmp -s $tmp1 $tmp2; then
38
echo "ok 1"
39
else
40
echo "not ok 1"
41
fi
42
43
# Make sure that one of the mirrors was marked broken.
44
genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}')
45
genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}')
46
if [ $genid1 -eq $(($genid2 + 1)) -o $genid2 -eq $(($genid1 + 1)) ]; then
47
echo "ok 2"
48
else
49
echo "not ok 2"
50
fi
51
52
# Force a retaste of the disconnected component.
53
if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
54
detach_md $us1
55
attach_md us1 -t vnode -f $m2
56
else
57
detach_md $us0
58
attach_md us0 -t vnode -f $m1
59
fi
60
61
# Make sure that the component wasn't re-added to the gmirror.
62
if [ $(gmirror status -s $name | wc -l) -eq 1 ]; then
63
echo "ok 3"
64
else
65
echo "not ok 3"
66
fi
67
68
rm -f $m1 $m2 $tmp1 $tmp2
69
70