blob: b44746c5a4122dbaefb03502eb5a626b6389defd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
imsm_check_hold() {
if mdadm --remove $1 $2; then
echo "$2 removal from $1 should have been blocked" >&2
cat /proc/mdstat >&2
mdadm -E $2
exit 1
fi
}
imsm_check_removal() {
if ! mdadm --remove $1 $2 ; then
echo "$2 removal from $1 should have succeeded" >&2
cat /proc/mdstat >&2
mdadm -E $2
exit 1
fi
}
imsm_check() {
udevadm settle
case $1 in
container )
grep -s "$(((418 * $2)/2)) blocks super external:imsm" /proc/mdstat > /dev/null || {
echo >&2 "ERROR correctly formed container not found"; cat /proc/mdstat; exit 1;}
;;
member )
member=$2
num_disks=$3
level=$4
size=$5
offset=$6
chunk=$7
err=0
if [ $level -ne 1 ]; then
size=$((size & ~(chunk - 1)))
else
chunk=64
fi
eval `stat -L -c "let major=0x%t; let minor=0x%T;" $member`
sysfs=/sys/dev/block/${major}:${minor}
if [ ! -f ${sysfs}/md/array_state ]; then
echo "member array $member not found" >&2
cat /proc/mdstat >&2
exit 1
fi
_chunk=`cat ${sysfs}/md/chunk_size`
if [ $chunk -ne $((_chunk/1024)) ]; then
echo "chunk mismatch expected $chunk got $_chunk" >&2
err=$((err+1))
fi
for i in `seq 0 $((num_disks-1))`
do
_offset=`cat ${sysfs}/md/rd${i}/offset`
if [ $offset -ne $((_offset/2)) ]; then
echo "offset mismatch expected $offset got $_offset" >&2
err=$((err+1))
fi
_size=`cat ${sysfs}/md/rd${i}/size`
if [ $size -ne $_size ]; then
echo "size mismatch expected $size got $_size" >&2
err=$((err+1))
fi
done
if [ $err -gt 0 ]; then
echo "$member failed check" >&2
cat /proc/mdstat >&2
mdadm -E /dev/loop0 >&2
exit 1
fi
;;
* ) echo >&2 ERROR unknown check $1 ; exit 1;
esac
}
setup_env() {
export IMSM_DEVNAME_AS_SERIAL=1
export IMSM_TEST_OROM=1
container=/dev/md/container
member0=/dev/md/vol0
member1=/dev/md/vol1
member2=/dev/md/vol2
member3=/dev/md/vol3
member4=/dev/md/vol4
}
reset_env() {
unset IMSM_DEVNAME_AS_SERIAL
unset IMSM_TEST_OROM
unset imsm_check
unset container
unset member0
unset member1
unset member2
unset member3
unset member4
}
|