Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/mirror/13_test.sh
39635 views
1
#!/bin/sh
2
3
# Test handling of write errors.
4
5
. $(dirname $0)/conf.sh
6
7
echo 1..4
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/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 /dev/$us1
23
devwait
24
25
tmp1=$(mktemp $base.XXXXXX)
26
tmp2=$(mktemp $base.XXXXXX)
27
28
dd if=/dev/random of=$tmp1 bs=$ddbs count=1 >/dev/null 2>&1
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 ${regwritefp}="1*return(${ENXIO})[pid $(gmirror_worker_pid)]"
34
dd if=$tmp1 of=/dev/mirror/$name bs=$ddbs count=1 >/dev/null 2>&1
35
dd if=/dev/mirror/$name of=$tmp2 bs=$ddbs count=1 >/dev/null 2>&1
36
sysctl ${regwritefp}='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
# The ENXIO should have caused a syncid bump.
54
syncid1=$(gmirror dump /dev/$us0 | awk '/^[[:space:]]*syncid: /{print $2}')
55
syncid2=$(gmirror dump /dev/$us1 | awk '/^[[:space:]]*syncid: /{print $2}')
56
if [ $syncid1 -eq $(($syncid2 + 1)) -o $syncid2 -eq $(($syncid1 + 1)) ]; then
57
echo "ok 3"
58
else
59
echo "not ok 3"
60
fi
61
62
# Force a retaste of the disconnected component.
63
if [ $(gmirror status -s $name | awk '{print $3}') = $us0 ]; then
64
detach_md $us1
65
attach_md us1 -t vnode -f $m2
66
else
67
detach_md $us0
68
attach_md us0 -t vnode -f $m1
69
fi
70
71
# Make sure that the retaste caused the mirror to automatically be re-added.
72
if [ $(gmirror status -s $name | wc -l) -eq 2 ]; then
73
echo "ok 4"
74
else
75
echo "not ok 4"
76
fi
77
78
syncwait
79
80
rm -f $m1 $m2 $tmp1 $tmp2
81
82