2 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
4 # This copyrighted material is made available to anyone wishing to use,
5 # modify, copy, or redistribute it subject to the terms and conditions
6 # of the GNU General Public License v.2.
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software Foundation,
10 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12 test_description
='Test pvcreate option values'
13 PAGESIZE
=$
(getconf PAGESIZE
)
19 #COMM 'pvcreate rejects negative setphysicalvolumesize'
20 not pvcreate
--setphysicalvolumesize -1024 $dev1
22 #COMM 'pvcreate rejects negative metadatasize'
23 not pvcreate
--metadatasize -1024 $dev1
25 # x. metadatasize 0, defaults to 255
26 # FIXME: unable to check default value, not in reporting cmds
27 # should default to 255 according to code
28 # check_pv_field_ pv_mda_size 255
29 #COMM 'pvcreate accepts metadatasize 0'
30 pvcreate
--metadatasize 0 $dev1
33 #Verify vg_mda_size is smaller pv_mda_size
34 pvcreate
--metadatasize 512k
$dev1
35 pvcreate
--metadatasize 96k
$dev2
36 vgcreate
$vg $dev1 $dev2
37 compare_two_fields_ vgs
$vg vg_mda_size pvs
$dev2 pv_mda_size
40 # x. metadatasize too large
41 # For some reason we allow this, even though there's no room for data?
42 ##COMM 'pvcreate rejects metadatasize too large'
43 #not pvcreate --metadatasize 100000000000000 $dev1
45 #COMM 'pvcreate rejects metadatacopies < 0'
46 not pvcreate
--metadatacopies -1 $dev1
48 #COMM 'pvcreate accepts metadatacopies = 0, 1, 2'
49 for j
in metadatacopies pvmetadatacopies
54 check_pv_field_
$dev1 pv_mda_count
0
55 check_pv_field_
$dev2 pv_mda_count
1
56 check_pv_field_
$dev3 pv_mda_count
2
62 #COMM 'pvcreate rejects metadatacopies > 2'
63 not pvcreate
--metadatacopies 3 $dev1
65 #COMM 'pvcreate rejects invalid device'
66 not pvcreate
$dev1bogus
68 #COMM 'pvcreate rejects labelsector < 0'
69 not pvcreate
--labelsector -1 $dev1
71 #COMM 'pvcreate rejects labelsector > 1000000000000'
72 not pvcreate
--labelsector 1000000000000 $dev1
74 # other possibilites based on code inspection (not sure how hard)
75 # x. device too small (min of 512 * 1024 KB)
76 # x. device filtered out
77 # x. unable to open /dev/urandom RDONLY
78 # x. device too large (pe_count > UINT32_MAX)
80 # x. unable to open device readonly
81 # x. BLKGETSIZE64 fails
82 # x. set size to value inconsistent with device / PE size
84 #COMM 'pvcreate basic dataalignment sanity checks'
85 not pvcreate
--dataalignment -1 $dev1
86 not pvcreate
-M 1 --dataalignment 1 $dev1
87 not pvcreate
--dataalignment 1e
$dev1
89 #COMM 'pvcreate always rounded up to page size for start of device'
90 #pvcreate --metadatacopies 0 --dataalignment 1 $dev1
92 #check_pv_field_ $dev1 pe_start $(($(getconf PAGESIZE)/1024))".00k"
94 #COMM 'pvcreate sets data offset directly'
95 pvcreate
--dataalignment 512k
$dev1
96 check_pv_field_
$dev1 pe_start
512.00k
98 #COMM 'vgcreate/vgremove do not modify data offset of existing PV'
99 vgcreate
$vg $dev1 --config 'devices { data_alignment = 1024 }'
100 check_pv_field_
$dev1 pe_start
512.00k
101 vgremove
$vg --config 'devices { data_alignment = 1024 }'
102 check_pv_field_
$dev1 pe_start
512.00k
104 #COMM 'pvcreate sets data offset next to mda area'
105 pvcreate
--metadatasize 100k
--dataalignment 100k
$dev1
106 check_pv_field_
$dev1 pe_start
200.00k
108 # metadata area start is aligned according to pagesize
109 # pagesize should be 64k or 4k ...
110 if [ $PAGESIZE -eq 65536 ] ; then
116 pvcreate
--metadatasize 128k
--dataalignment 3.5k
$dev1
117 check_pv_field_
$dev1 pe_start
$pv_align
119 pvcreate
--metadatasize 128k
--metadatacopies 2 --dataalignment 3.5k
$dev1
120 check_pv_field_
$dev1 pe_start
$pv_align
122 # data area is aligned to 64k by default,
123 # data area start is shifted by the specified alignment_offset
125 pvcreate
--metadatasize 128k
--dataalignmentoffset 7s
$dev1
126 check_pv_field_
$dev1 pe_start
$pv_align
128 # 2nd metadata area is created without problems when
129 # data area start is shifted by the specified alignment_offset
130 pvcreate
--metadatasize 128k
--metadatacopies 2 --dataalignmentoffset 7s
$dev1
131 check_pv_field_
$dev1 pv_mda_count
2
132 # FIXME: compare start of 2nd mda with and without --dataalignmentoffset
134 #COMM 'pv with LVM1 compatible data alignment can be convereted'
135 #compatible == LVM1_PE_ALIGN == 64k
136 pvcreate
--dataalignment 256k
$dev1
137 vgcreate
-s 1m
$vg $dev1
140 check_pv_field_
$dev1 pe_start
256.00k
143 #COMM 'pv with LVM1 incompatible data alignment cannot be convereted'
144 pvcreate
--dataalignment 10k
$dev1
145 vgcreate
-s 1m
$vg $dev1
146 not vgconvert
-M1 $vg
149 #COMM 'vgcfgrestore allows pe_start=0'
150 #basically it produces nonsense, but it tests vgcfgrestore,
151 #not that final cfg is usable...
152 pvcreate
--metadatacopies 0 $dev1
154 vgcreate
$vg $dev1 $dev2
155 vgcfgbackup
-f "$(pwd)/backup.$$" $vg
156 sed 's/pe_start = [0-9]*/pe_start = 0/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1"
157 vgcfgrestore
-f "$(pwd)/backup.$$1" $vg
158 check_pv_field_
$dev1 pe_start
0
159 check_pv_field_
$dev2 pe_start
0