1
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
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.
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
15
echo Make sure we can ignore / un-ignore mdas on a per-PV basis
16
for pv_in_vg in 1 0; do
18
pvcreate --metadatacopies $mdacp $dev1 $dev2
19
pvcreate --metadatacopies 0 $dev3
20
if [ $pv_in_vg = 1 ]; then
21
vgcreate -c n "$vg" $dev1 $dev2 $dev3
23
pvchange --metadataignore y $dev1
24
check pv_field $dev1 pv_mda_count $mdacp
25
check pv_field $dev1 pv_mda_used_count 0
26
check pv_field $dev2 pv_mda_count $mdacp
27
check pv_field $dev2 pv_mda_used_count $mdacp
28
if [ $pv_in_vg = 1 ]; then
29
check vg_field $vg vg_mda_count $(($mdacp * 2))
30
check vg_field $vg vg_mda_used_count $mdacp
31
check vg_field $vg vg_mda_copies unmanaged
33
pvchange --metadataignore n $dev1
34
check pv_field $dev1 pv_mda_count $mdacp
35
check pv_field $dev1 pv_mda_used_count $mdacp
36
if [ $pv_in_vg = 1 ]; then
37
check vg_field $vg vg_mda_count $(($mdacp * 2))
38
check vg_field $vg vg_mda_used_count $(($mdacp * 2))
39
check vg_field $vg vg_mda_copies unmanaged
45
# Check if a PV has unignored (used) mdas, and if so, ignore
47
pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count)
48
if [ $pv_mda_used_count -ne 0 ]; then
49
pvchange --metadataignore y $1
53
# Check if a PV has ignored mdas, and if so, unignore (make used)
55
pv_mda_count=$(get pv_field "$1" pv_mda_count)
56
pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count)
57
if [ $pv_mda_count -gt $pv_mda_used_count ]; then
58
pvchange --metadataignore n $1
62
echo Test of vgmetadatacopies with vgcreate and vgchange
64
pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5
65
check pv_field $dev1 pv_mda_used_count $mdacp
66
check pv_field $dev2 pv_mda_used_count $mdacp
67
check pv_field $dev4 pv_mda_used_count $mdacp
68
check pv_field $dev5 pv_mda_used_count $mdacp
69
pvcreate --metadatacopies 0 $dev3
70
vgcreate -c n "$vg" $dev1 $dev2 $dev3
71
check vg_field $vg vg_mda_copies unmanaged
72
echo ensure both --vgmetadatacopies and --metadatacopies accepted
73
vgchange --metadatacopies $(($mdacp * 1)) $vg
74
echo --vgmetadatacopies is persistent on disk
75
echo --vgmetadatacopies affects underlying pv mda ignore
76
check vg_field $vg vg_mda_copies $(($mdacp * 1))
77
check vg_field $vg vg_mda_used_count $(($mdacp * 1))
78
vgchange --vgmetadatacopies $(($mdacp * 2)) $vg
79
check vg_field $vg vg_mda_copies $(($mdacp * 2))
80
check vg_field $vg vg_mda_used_count $(($mdacp * 2))
81
echo allow setting metadatacopies larger than number of PVs
82
vgchange --vgmetadatacopies $(($mdacp * 5)) $vg
83
check vg_field $vg vg_mda_copies $(($mdacp * 5))
84
check vg_field $vg vg_mda_used_count $(($mdacp * 2))
85
echo setting to 0 disables automatic balancing
86
vgchange --vgmetadatacopies unmanaged $vg
87
check vg_field $vg vg_mda_copies unmanaged
89
echo vgcreate succeeds even when creating a VG w/all ignored mdas
90
pvchange --metadataignore y $dev1 $dev2
91
check pv_field $dev1 pv_mda_count $mdacp
92
check pv_field $dev2 pv_mda_used_count 0
93
vgcreate -c n "$vg" $dev1 $dev2
94
check vg_field $vg vg_mda_copies unmanaged
96
echo vgcreate succeeds with a specific number of metadata copies
97
vgcreate -c n --vgmetadatacopies $(($mdacp * 2)) "$vg" $dev1 $dev2
98
check vg_field $vg vg_mda_copies $(($mdacp * 2))
100
vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2
101
check vg_field $vg vg_mda_copies $(($mdacp * 1))
103
echo vgcreate succeeds with a larger value than total metadatacopies
104
vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2
105
check vg_field $vg vg_mda_copies $(($mdacp * 5))
107
echo vgcreate succeeds with --vgmetadatacopies unmanaged
108
vgcreate -c n --vgmetadatacopies unmanaged "$vg" $dev1 $dev2
109
check vg_field $vg vg_mda_copies unmanaged
115
echo vgcreate succeds with small value of --metadatacopies, ignores mdas
116
vgcreate -c n --vgmetadatacopies 1 "$vg" $dev1 $dev2 $dev4 $dev5
117
check vg_field $vg vg_mda_copies 1
118
check vg_field $vg vg_mda_count $(($mdacp * 4))
119
check vg_field $vg vg_mda_used_count 1
120
echo Setting a larger value should trigger non-ignore of mdas
121
vgchange --metadatacopies 3 $vg
122
check vg_field $vg vg_mda_copies 3
123
check vg_field $vg vg_mda_used_count 3
124
echo Setting all should trigger unignore of all mdas
125
vgchange --vgmetadatacopies all $vg
126
check vg_field $vg vg_mda_count $(($mdacp * 4))
127
check vg_field $vg vg_mda_copies unmanaged
128
check vg_field $vg vg_mda_used_count $(($mdacp * 4))
129
echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate
130
vgchange --vgmetadatacopies 0 $vg
131
check vg_field $vg vg_mda_copies unmanaged
133
vgcreate -c n --vgmetadatacopies 0 "$vg" $dev1 $dev2 $dev4 $dev5
134
check vg_field $vg vg_mda_copies unmanaged
138
echo Test vgextend / vgreduce with vgmetadatacopies
140
pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5
141
pvcreate --metadatacopies 0 $dev3
142
echo Set a large value of vgmetadatacopies
143
vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2 $dev3
144
check vg_field $vg vg_mda_copies $(($mdacp * 5))
145
echo Ignore mdas on devices to be used for vgextend
146
echo Large value of vgetadatacopies should automatically un-ignore mdas
147
pvchange --metadataignore y $dev4 $dev5
148
check pv_field $dev4 pv_mda_used_count 0
149
vgextend $vg $dev4 $dev5
150
check pv_field $dev4 pv_mda_used_count $mdacp
151
check pv_field $dev5 pv_mda_used_count $mdacp
153
echo Set a small value of vgmetadatacopies
154
vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2 $dev3
155
check vg_field $vg vg_mda_copies $(($mdacp * 1))
156
echo Ignore mdas on devices to be used for vgextend
157
echo Small value of vgetadatacopies should leave mdas as ignored
158
pvchange --metadataignore y $dev4 $dev5
159
check pv_field $dev4 pv_mda_used_count 0
160
vgextend $vg $dev4 $dev5
161
check pv_field $dev4 pv_mda_used_count 0
162
check pv_field $dev5 pv_mda_used_count 0
163
echo vgreduce of ignored pv w/mda should not trigger any change to ignore bits
165
check pv_field $dev4 pv_mda_used_count 0
166
check pv_field $dev5 pv_mda_used_count 0
167
echo vgreduce of un-ignored pv w/mda should trigger un-ignore on an mda
168
vgreduce $vg $dev1 $dev2 $dev3
169
check pv_field $dev5 pv_mda_used_count $mdacp
170
check vg_field $vg vg_mda_copies $(($mdacp * 1))
173
echo setting vgmetadatacopies to unmanaged should allow vgextend to add w/out balancing
174
vgchange --vgmetadatacopies unmanaged $vg
175
vgextend $vg $dev1 $dev2
176
check vg_field $vg vg_mda_copies unmanaged
177
check vg_field $vg vg_mda_count $(($mdacp * 3))
178
check vg_field $vg vg_mda_used_count $((mdacp * 3))
179
check pv_field $dev1 pv_mda_used_count $mdacp
180
check pv_field $dev2 pv_mda_used_count $mdacp
184
echo Test special situations, vgsplit, vgmerge, etc
186
pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5
187
vgcreate -c n --vgmetadatacopies 2 $vg1 $dev1 $dev2 $dev3
188
vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg2 $dev4 $dev5
189
echo vgsplit/vgmerge preserves value of metadata copies
190
check vg_field $vg1 vg_mda_copies 2
191
check vg_field $vg2 vg_mda_copies $(($mdacp * 1))
192
vgsplit $vg1 $vg2 $dev1
193
check vg_field $vg2 vg_mda_copies $(($mdacp * 1))
195
check vg_field $vg1 vg_mda_copies 2
196
check vg_field $vg1 vg_mda_count $(($mdacp * 5))
197
echo vgsplit into new vg sets proper value of vgmetadatacopies
198
vgsplit --vgmetadatacopies $(($mdacp * 2)) $vg1 $vg2 $dev1 $dev2
199
check vg_field $vg2 vg_mda_copies $(($mdacp * 2))
200
echo vgchange fails if given both vgmetadatacopies and metadatacopies
201
not vgchange --vgmetadatacopies 5 --metadatacopies 7 $vg2
206
echo Test combination of --vgmetadatacopies and pvchange --metadataignore
208
pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5
209
vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg1 $dev1 $dev2
210
check vg_field $vg1 vg_mda_copies $(($mdacp * 1))
211
check vg_field $vg1 vg_mda_used_count $(($mdacp * 1))
213
echo Ensure vgextend of PVs with ignored MDAs does not add to vg_mda_used_count
215
check vg_field $vg1 vg_mda_used_count $(($mdacp * 1))
216
echo Using pvchange to unignore should update vg_mda_used_count
217
pvchange -f --metadataignore n $dev3
218
check pv_field $dev3 pv_mda_used_count $mdacp
219
check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))
220
echo Set unmanaged on the vg should keep ignore bits the same during vgextend
221
vgchange --vgmetadatacopies unmanaged $vg1
222
check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))
225
check pv_field $dev4 pv_mda_used_count $mdacp
226
check vg_field $vg1 vg_mda_used_count $(($mdacp * 3))
227
echo Using pvchange to ignore should update vg_mda_used_count
228
pvchange -f --metadataignore y $dev4
229
check pv_field $dev4 pv_mda_used_count 0
230
check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))