Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/11_test.sh
39635 views
1
#!/bin/sh
2
3
# Test handling of read errors.
4
5
. $(dirname $0)/conf.sh
6
7
echo 1..4
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
ENXIO=6
31
# gmirror has special handling for ENXIO. It does not mark the failed component
32
# as broken, allowing it to rejoin the mirror automatically when it appears.
33
sysctl ${regreadfp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]"
34
dd if=/dev/mirror/$name of=$tmp1 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1
35
dd if=/dev/$us1 of=$tmp2 iseek=512 bs=$ddbs count=1 >/dev/null 2>&1
36
sysctl ${regreadfp}='off'
37
38
if cmp -s $tmp1 $tmp2; then
39
echo "ok 1"
40
else
41
echo "not ok 1"
42
fi
43
44
# Verify that the genids still match after ENXIO.
45
genid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*genid: /{print $2}')
46
genid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*genid: /{print $2}')
47
if [ $genid1 -eq $genid2 ]; then
48
echo "ok 2"
49
else
50
echo "not ok 2"
51
fi
52
53
# Trigger a syncid bump.
54
dd if=/dev/zero of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
55
56
# The ENXIO+write should have caused a syncid bump.
57
syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}')
58
syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}')
59
if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then
60
echo "ok 3"
61
else
62
echo "not ok 3"
63
fi
64
65
# Force a retaste of the disconnected component.
66
if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
67
detach_md $us1
68
attach_md us1 -t vnode -f $m2
69
else
70
detach_md $us0
71
attach_md us0 -t vnode -f $m1
72
fi
73
74
# Make sure that the retaste caused the mirror to automatically be re-added.
75
if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then
76
echo "ok 4"
77
else
78
echo "not ok 4"
79
fi
80
81
syncwait
82
83
rm -f $m1 $m2 $tmp1 $tmp2
84
85