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