summaryrefslogtreecommitdiffstats
path: root/tests/10ddf-incremental-wrong-order
blob: 9ecf6bc2ff665a660b43b555b97ce964ff879ba1 (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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# An array is assembled incompletely. Some disks will
# have later metadata than others.
# The array is then reassembled in the "wrong" order -
# older meta data first.
# This FAILS with mdadm 3.3
. tests/env-ddf-template
tmp=$(mktemp /tmp/mdtest-XXXXXX)
rm -f $tmp /var/tmp/mdmon.log
ret=0

mdadm -CR $container -e ddf -n 4 $dev8 $dev9 $dev10 $dev11
ddf_check container 4

mdadm -CR $member1 -n 4 -l 10 $dev8 $dev10 $dev9 $dev11 -z 10000
mdadm -CR $member0 -n 2 -l 1 $dev8 $dev9 -z 10000

mdadm --wait $member0 || true
mdadm --wait $member1 || true

mke2fs -F $member0
mke2fs -F $member1
sha_0a=$(sha1_sum $member0)
sha_1a=$(sha1_sum $member1)

mdadm -Ss
sleep 1

# Add all devices except those for $member0
mdadm -I $dev10
mdadm -I $dev11

# Start runnable members ($member1) and write
mdadm -IRs || true
e2fsck -fy $member1
sha_1b=$(sha1_sum $member1)

mdadm -Ss
sleep 1

# Seq number should be different now
seq8a=$(mdadm -E $dev8 | sed -n 's/^ *Seq : //p')
seq10a=$(mdadm -E $dev10 | sed -n 's/^ *Seq : //p')

if [ $seq8a -ge $seq10a ]; then
    ret=1
    echo ERROR: sequential number of $dev10 not bigger than $dev8
fi
if [ x$sha_1a = x$sha_1b ]; then
    ret=1
    echo ERROR: sha1sums equal after write
fi

#[ -f /var/tmp/mdmon.log ] && cat /var/tmp/mdmon.log

# Now reassemble
# Note that we add the previously missing disks first.
# $dev10 should have a higher seq number than $dev8
for d in $dev8 $dev9 $dev10 $dev11; do
    mdadm -I $d
done

mdadm -IRs || true
sha_0c=$(sha1_sum $member0)
sha_1c=$(sha1_sum $member1)

mdadm -Ss
sleep 1

seq8c=$(mdadm -E $dev8 | sed -n 's/^ *Seq : //p')
seq10c=$(mdadm -E $dev10 | sed -n 's/^ *Seq : //p')

if [ x$sha_0a != x$sha_0c ]; then
    ret=1
    echo ERROR: sha1sum of $member0 has changed
fi
if [ x$sha_1b != x$sha_1c ]; then
    ret=1
    echo ERROR: sha1sum of $member1 has changed
fi
if [ \( $seq10a -ge $seq10c \) -o \( $seq8c -ne $seq10c \) ]; then
    ret=1
    echo ERROR: sequential numbers are wrong
fi

# Expect consistent state
for d in $dev10 $dev8; do
    mdadm -E $d>$tmp
    for x in 0 1; do
	egrep 'state\['$x'\] : Optimal, Consistent' $tmp || {
	    ret=1
	    echo ERROR: $member0 has unexpected state on $d
	}
    done
    if [ x$(egrep -c 'active/Online$' $tmp) != x4 ]; then
	ret=1
	echo ERROR: unexpected number of online disks on $d
    fi
done

# Now try assembly
if mdadm -A $container $dev8 $dev9 $dev10 $dev11; then
    mdadm -IR $container
    sha_0d=$(sha1_sum $member0)
    sha_1d=$(sha1_sum $member1)
    mdadm -Ss
    sleep 1
    seq8d=$(mdadm -E $dev8 | sed -n 's/^ *Seq : //p')
    seq10d=$(mdadm -E $dev10 | sed -n 's/^ *Seq : //p')
    if [ x$sha_0a != x$sha_0d ]; then
	ret=1
	echo ERROR: sha1sum of $member0 has changed
    fi
    if [ x$sha_1b != x$sha_1d ]; then
	ret=1
	echo ERROR: sha1sum of $member1 has changed
    fi
    if [ \( $seq10a -ge $seq10d \) -o \( $seq8d -ne $seq10d \) ]; then
	ret=1
	echo ERROR: sequential numbers are wrong
    fi
else
    ret=1
    echo ERROR: assembly failed
fi

if [ $ret -ne 0 ]; then
    mdadm -E $dev10
    mdadm -E $dev8
fi
rm -f $tmp /var/tmp/mdmon.log
[ $ret -eq 0 ]