summaryrefslogtreecommitdiffstats
path: root/tests/09imsm-assemble
blob: 2a42369e349f602bcc1a770e2f0aff6e84d99d33 (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
# validate the prodigal member disk scenario i.e. a former container
# member is returned after having been rebuilt on another system


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
}

export IMSM_DEVNAME_AS_SERIAL=1
export IMSM_TEST_OROM=1
export IMSM_NO_PLATFORM=1
container=/dev/md/container
member=/dev/md/vol0


num_disks=4
size=$((10*1024))
mdadm -CR $container -e imsm -n $num_disks $dev0 $dev1 $dev2 $dev3
mdadm -CR $member $dev0 $dev2 -n 2 -l 1 -z $size
mdadm --wait $member
mdadm -Ss

# make dev0 and dev1 a new rebuild family
mdadm -A $container $dev0 $dev1
mdadm -IR $container
mdadm --wait ${member}_0
mdadm -Ss

# make dev2 and dev3 a new rebuild family
mdadm -A $container $dev2 $dev3
mdadm -IR $container
mdadm --wait ${member}_0
mdadm -Ss

# reassemble and make sure one of the families falls out
mdadm -A $container $dev0 $dev1 $dev2 $dev3
mdadm -IR $container
testdev ${member}_0 1 $size 64
if mdadm --remove $container $dev0 ; then
    # the dev[23] family won
    imsm_check_removal $container $dev1
    imsm_check_hold $container $dev2
    imsm_check_hold $container $dev3
else
    # the dev[01] family won
    imsm_check_hold $container $dev1
    imsm_check_removal $container $dev2
    imsm_check_removal $container $dev3
fi
mdadm -Ss

# reassemble with a new id for the dev[23] family
mdadm -A $container $dev0 $dev1
mdadm -IR $container
mdadm -A ${container}2 $dev2 $dev3 --update=uuid
mdadm -IR ${container}2

testdev ${member}_0 1 $size 64
testdev ${member}_1 1 $size 64