Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/tests/sys/geom/class/concat/append2.sh
39638 views
1
#!/bin/sh
2
3
# A basic regression test for gconcat append using "gconcat label",
4
# i.e., automatic mode.
5
6
gconcat_check_size()
7
{
8
local actual expected name
9
10
name=$1
11
expected=$2
12
13
actual=$(diskinfo /dev/concat/${name} | awk '{print $3}')
14
if [ $actual -eq $expected ]; then
15
echo "ok - Size is ${actual}"
16
else
17
echo "not ok - Size is ${actual}"
18
fi
19
}
20
21
. `dirname $0`/conf.sh
22
23
echo '1..4'
24
25
ss=512
26
27
f1=$(mktemp) || exit 1
28
truncate -s $((1024 * 1024 + $ss)) $f1
29
f2=$(mktemp) || exit 1
30
truncate -s $((1024 * 1024 + $ss)) $f2
31
f3=$(mktemp) || exit 1
32
truncate -s $((1024 * 1024 + $ss)) $f3
33
34
attach_md us0 -f $f1 -S $ss || exit 1
35
attach_md us1 -f $f2 -S $ss || exit 1
36
attach_md us2 -f $f3 -S $ss || exit 1
37
38
gconcat label $name /dev/$us0 /dev/$us1 || exit 1
39
devwait
40
41
# We should have a 2MB device. Add another disk and verify that the
42
# reported size of the concat device grows accordingly. A sector from
43
# each disk is reserved for the metadata sector.
44
gconcat_check_size "${name}" $((2 * 1024 * 1024))
45
gconcat append $name /dev/$us2 || exit 1
46
gconcat_check_size "${name}" $((3 * 1024 * 1024))
47
48
copy=$(mktemp) || exit 1
49
dd if=/dev/random of=$copy bs=1M count=3 || exit 1
50
dd if=$copy of=/dev/concat/${name} || exit 1
51
52
# Stop the concat device and destroy the backing providers.
53
gconcat stop ${name} || exit 1
54
detach_md $us0
55
detach_md $us1
56
detach_md $us2
57
58
# Re-create the providers and verify that the concat device comes
59
# back and that the data is still there.
60
attach_md us0 -f $f1 -S $ss || exit 1
61
attach_md us1 -f $f2 -S $ss || exit 1
62
attach_md us2 -f $f3 -S $ss || exit 1
63
64
devwait
65
66
# Make sure that the
67
if [ -c /dev/concat/${name} ]; then
68
echo "ok - concat device was instantiated"
69
else
70
echo "not ok - concat device was instantiated"
71
fi
72
73
if cmp -s $copy /dev/concat/${name}; then
74
echo "ok - Data was persisted across gconcat stop"
75
else
76
echo "not ok - Data was persisted across gconcat stop"
77
fi
78
79