~ubuntu-branches/ubuntu/vivid/lvm2/vivid

« back to all changes in this revision

Viewing changes to test/t-pvcreate-operation-md.sh

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2012-05-01 20:27:50 UTC
  • mto: (3.1.23 sid)
  • mto: This revision was merged to the branch mainline in revision 72.
  • Revision ID: package-import@ubuntu.com-20120501202750-gljjjtblowwq9mw8
Tags: upstream-2.02.95
ImportĀ upstreamĀ versionĀ 2.02.95

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
2
 
#
3
 
# This copyrighted material is made available to anyone wishing to use,
4
 
# modify, copy, or redistribute it subject to the terms and conditions
5
 
# of the GNU General Public License v.2.
6
 
#
7
 
# You should have received a copy of the GNU General Public License
8
 
# along with this program; if not, write to the Free Software Foundation,
9
 
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
10
 
 
11
 
# skip this test if mdadm or sfdisk (or others) aren't available
12
 
which mdadm || exit 200
13
 
which sfdisk || exit 200
14
 
which perl || exit 200
15
 
which awk || exit 200
16
 
which cut || exit 200
17
 
 
18
 
test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \
19
 
modprobe raid0 || exit 200
20
 
 
21
 
. lib/test
22
 
 
23
 
aux lvmconf 'devices/filter = [ "a|/dev/md.*|", "a/dev\/mapper\/.*$/", "r/.*/" ]'
24
 
aux prepare_devs 2
25
 
 
26
 
# Have MD use a non-standard name to avoid colliding with an existing MD device
27
 
# - mdadm >= 3.0 requires that non-standard device names be in /dev/md/
28
 
# - newer mdadm _completely_ defers to udev to create the associated device node
29
 
mdadm_maj=$(mdadm --version 2>&1 | perl -pi -e 's|.* v(\d+).*|\1|')
30
 
[ $mdadm_maj -ge 3 ] && \
31
 
    mddev=/dev/md/md_lvm_test0 || \
32
 
    mddev=/dev/md_lvm_test0
33
 
 
34
 
cleanup_md() {
35
 
    # sleeps offer hack to defeat: 'md: md127 still in use'
36
 
    # see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25
37
 
    aux udev_wait
38
 
    mdadm --stop $mddev || true
39
 
    aux udev_wait
40
 
    if [ -b "$mddev" ]; then
41
 
        # mdadm doesn't always cleanup the device node
42
 
        sleep 2
43
 
        rm -f $mddev
44
 
    fi
45
 
}
46
 
 
47
 
cleanup_md_and_teardown() {
48
 
    cleanup_md
49
 
    aux teardown
50
 
}
51
 
 
52
 
# create 2 disk MD raid0 array (stripe_width=128K)
53
 
test -b "$mddev" && exit 200
54
 
mdadm --create --metadata=1.0 $mddev --auto=md --level 0 --raid-devices=2 --chunk 64 $dev1 $dev2
55
 
trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test
56
 
test -b "$mddev" || exit 200
57
 
 
58
 
# Test alignment of PV on MD without any MD-aware or topology-aware detection
59
 
# - should treat $mddev just like any other block device
60
 
pv_align="1.00m"
61
 
pvcreate --metadatasize 128k \
62
 
    --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \
63
 
    $mddev
64
 
check pv_field $mddev pe_start $pv_align
65
 
 
66
 
# Test md_chunk_alignment independent of topology-aware detection
67
 
pv_align="1.00m"
68
 
pvcreate --metadatasize 128k \
69
 
    --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \
70
 
    $mddev
71
 
check pv_field $mddev pe_start $pv_align
72
 
 
73
 
 
74
 
# Test newer topology-aware alignment detection
75
 
# - first added to 2.6.31 but not "reliable" until 2.6.33
76
 
if kernel_at_least 2 6 33 ; then
77
 
    pv_align="1.00m"
78
 
    # optimal_io_size=131072, minimum_io_size=65536
79
 
    pvcreate --metadatasize 128k \
80
 
        --config 'devices { md_chunk_alignment=0 }' $mddev
81
 
    check pv_field $mddev pe_start $pv_align
82
 
fi
83
 
 
84
 
# partition MD array directly, depends on blkext in Linux >= 2.6.28
85
 
if kernel_at_least 2 6 28 ; then
86
 
    # create one partition
87
 
    sfdisk $mddev <<EOF
88
 
,,83
89
 
EOF
90
 
    # make sure partition on MD is _not_ removed
91
 
    # - tests partition -> parent lookup via sysfs paths
92
 
    not pvcreate --metadatasize 128k $mddev
93
 
 
94
 
    # verify alignment_offset is accounted for in pe_start
95
 
    # - topology infrastructure is available in Linux >= 2.6.31
96
 
    # - also tests partition -> parent lookup via sysfs paths
97
 
 
98
 
    # Oh joy: need to lookup /sys/block/md127 rather than /sys/block/md_lvm_test0
99
 
    mddev_maj_min=$(ls -lL $mddev | awk '{ print $5 $6 }' | perl -pi -e 's|,|:|')
100
 
    mddev_p_sysfs_name=$(echo /sys/dev/block/${mddev_maj_min}/*p1)
101
 
    base_mddev_p=`basename $mddev_p_sysfs_name`
102
 
    mddev_p=/dev/${base_mddev_p}
103
 
 
104
 
    # in case the system is running without devtmpfs /dev
105
 
    # wait here for created device node on tmpfs
106
 
    aux udev_wait $mddev_p
107
 
    test -b $mddev_p || exit 200
108
 
 
109
 
    # Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31
110
 
    # but reliable alignment_offset support requires kernel.org Linux >= 2.6.33
111
 
    sysfs_alignment_offset=/sys/dev/block/${mddev_maj_min}/${base_mddev_p}/alignment_offset
112
 
    [ -f $sysfs_alignment_offset ] && kernel_at_least 2 6 33 && \
113
 
        alignment_offset=`cat $sysfs_alignment_offset` || \
114
 
        alignment_offset=0
115
 
 
116
 
    if [ $alignment_offset -gt 0 ]; then
117
 
        # default alignment is 1M, add alignment_offset
118
 
        pv_align=$((1048576+$alignment_offset))B
119
 
        pvcreate --metadatasize 128k $mddev_p
120
 
        check pv_field $mddev_p pe_start $pv_align "--units b"
121
 
        pvremove $mddev_p
122
 
    fi
123
 
fi
124
 
 
125
 
# Test newer topology-aware alignment detection w/ --dataalignment override
126
 
if kernel_at_least 2 6 33 ; then
127
 
    cleanup_md
128
 
    pvcreate -f $dev1
129
 
    pvcreate -f $dev2
130
 
 
131
 
    # create 2 disk MD raid0 array (stripe_width=2M)
132
 
    test -b "$mddev" && exit 200
133
 
    mdadm --create --metadata=1.0 $mddev --auto=md --level 0 --raid-devices=2 --chunk 1024 $dev1 $dev2
134
 
    test -b "$mddev" || exit 200
135
 
 
136
 
    # optimal_io_size=2097152, minimum_io_size=1048576
137
 
    pv_align="2.00m"
138
 
    pvcreate --metadatasize 128k \
139
 
        --config 'devices { md_chunk_alignment=0 }' $mddev
140
 
    check pv_field $mddev pe_start $pv_align
141
 
 
142
 
    # now verify pe_start alignment override using --dataalignment
143
 
    pv_align="192.00k"
144
 
    pvcreate --dataalignment 64k --metadatasize 128k \
145
 
        --config 'devices { md_chunk_alignment=0 }' $mddev
146
 
    check pv_field $mddev pe_start $pv_align
147
 
fi