]> git.ipfire.org Git - thirdparty/mdadm.git/blob - tests/10ddf-fail-create-race
tests: add test that DDF marks missing devices as failed on assembly.
[thirdparty/mdadm.git] / tests / 10ddf-fail-create-race
1 # This test creates a RAID1, fails a disk, and immediately
2 # (simultaneously) creates a new array. This tests for a possible
3 # race where the meta data reflecting the disk failure may not
4 # be written when the 2nd array is created.
5 . tests/env-ddf-template
6
7 mdadm --zero-superblock $dev8 $dev9 $dev10 $dev11 $dev12 $dev13
8
9 mdadm -CR $container -e ddf -l container -n 2 $dev11 $dev12
10 #$dir/mdadm -CR $member0 -l raid1 -n 2 $container -z 10000 >/tmp/mdmon.txt 2>&1
11 mdadm -CR $member0 -l raid1 -n 2 $container -z 10000
12 check wait
13 fail0=$dev11
14 mdadm --fail $member0 $fail0 &
15
16 # The test can succeed two ways:
17 # 1) mdadm -C member1 fails - in this case the meta data
18 # was already on disk when the create attempt was made
19 # 2) mdadm -C succeeds in the first place (meta data not on disk yet),
20 # but mdmon detects the problem and sets the disk faulty.
21
22 if mdadm -CR $member1 -l raid1 -n 2 $container; then
23
24 echo create should have failed / race condition?
25
26 check wait
27 set -- $(get_raiddisks $member0)
28 d0=$1
29 ret=0
30 if [ $1 = $fail0 -o $2 = $fail0 ]; then
31 ret=1
32 else
33 set -- $(get_raiddisks $member1)
34 if [ $1 = $fail0 -o $2 = $fail0 ]; then
35 ret=1
36 fi
37 fi
38 if [ $ret -eq 1 ]; then
39 echo ERROR: failed disk $fail0 is still a RAID member
40 echo $member0: $(get_raiddisks $member0)
41 echo $member1: $(get_raiddisks $member1)
42 fi
43 tmp=$(mktemp /tmp/mdest-XXXXXX)
44 mdadm -E $d0 >$tmp
45 if [ x$(grep -c 'state\[[01]\] : Degraded' $tmp) != x2 ]; then
46 echo ERROR: non-degraded array found
47 mdadm -E $d0
48 ret=1
49 fi
50 if ! grep -q '^ *0 *[0-9a-f]\{8\} .*Offline, Failed' $tmp; then
51 echo ERROR: disk 0 not marked as failed in meta data
52 mdadm -E $d0
53 ret=1
54 fi
55 rm -f $tmp
56 else
57 ret=0
58 fi
59
60 [ -f /tmp/mdmon.txt ] && {
61 cat /tmp/mdmon.txt
62 rm -f /tmp/mdmon.txt
63 }
64
65 [ $ret -eq 0 ]
66