2
# Copyright (C) 2007 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 vgsplit operation, including different LV types
21
# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run
22
# fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1
26
# vgsplit can be done into a new or existing VG
31
# We can have PVs or LVs on the cmdline
35
COMM "vgsplit correctly splits single linear LV into $i VG ($j args)"
36
vgcreate $vg1 $dev1 $dev2
37
if [ $i = existing ]; then
38
vgcreate $vg2 $dev3 $dev4
40
lvcreate -l 4 -n $lv1 $vg1 $dev1
43
vgsplit $vg1 $vg2 $dev1
45
vgsplit -n $lv1 $vg1 $vg2
47
check pvlv_counts $vg1 1 0 0
48
if [ $i = existing ]; then
49
check pvlv_counts $vg2 3 1 0
51
check pvlv_counts $vg2 1 1 0
57
COMM "vgsplit correctly splits single striped LV into $i VG ($j args)"
58
vgcreate $vg1 $dev1 $dev2
59
if [ $i = existing ]; then
60
vgcreate $vg2 $dev3 $dev4
62
lvcreate -l 4 -i 2 -n $lv1 $vg1 $dev1 $dev2
65
vgsplit $vg1 $vg2 $dev1 $dev2
67
vgsplit -n $lv1 $vg1 $vg2
69
if [ $i = existing ]; then
70
check pvlv_counts $vg2 4 1 0
72
check pvlv_counts $vg2 2 1 0
77
COMM "vgsplit correctly splits mirror LV into $i VG ($j args)"
78
vgcreate -c n $vg1 $dev1 $dev2 $dev3
79
if [ $i = existing ]; then
80
vgcreate -c n $vg2 $dev4
82
lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3
85
vgsplit $vg1 $vg2 $dev1 $dev2 $dev3
87
vgsplit -n $lv1 $vg1 $vg2
89
if [ $i = existing ]; then
90
check pvlv_counts $vg2 4 1 0
92
check pvlv_counts $vg2 3 1 0
97
COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)"
98
vgcreate -c n $vg1 $dev1 $dev2
99
if [ $i = existing ]; then
100
vgcreate -c n $vg2 $dev3 $dev4
102
lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2
103
lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1
106
vgsplit $vg1 $vg2 $dev1 $dev2
108
vgsplit -n $lv1 $vg1 $vg2
110
if [ $i = existing ]; then
111
check pvlv_counts $vg2 4 2 1
113
check pvlv_counts $vg2 2 2 1
115
lvremove -f $vg2/$lv2
116
lvremove -f $vg2/$lv1
119
COMM "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)"
120
vgcreate -c n $vg1 $dev1 $dev2
121
if [ $i = existing ]; then
122
vgcreate -c n $vg2 $dev3
124
lvcreate -l 64 -i 2 -n $lv1 $vg1
125
lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1
127
lvcreate -l 64 -n $lv3 $vg1 $dev4
130
vgsplit $vg1 $vg2 $dev4
132
vgsplit -n $lv3 $vg1 $vg2
134
if [ $i = existing ]; then
135
check pvlv_counts $vg2 2 1 0
136
check pvlv_counts $vg1 2 2 1
138
check pvlv_counts $vg2 1 1 0
139
check pvlv_counts $vg1 2 2 1
141
lvremove -f $vg1/$lv2
142
lvremove -f $vg1/$lv1
143
lvremove -f $vg2/$lv3
147
COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)"
148
vgcreate -c n $vg1 $dev1 $dev2 $dev3
149
if [ $i = existing ]; then
150
vgcreate -c n $vg2 $dev5
152
lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3
154
lvcreate -l 64 -n $lv2 $vg1 $dev4
160
vgsplit $vg1 $vg2 $dev4
162
vgsplit -n $lv2 $vg1 $vg2
164
if [ $i = existing ]; then
165
check pvlv_counts $vg1 3 1 0
166
check pvlv_counts $vg2 2 1 0
171
check pvlv_counts $vg1 3 1 0
172
check pvlv_counts $vg2 1 1 0
174
lvremove -f $vg1/$lv1
175
lvremove -f $vg2/$lv2
183
# Test more complex setups where the code has to find associated PVs and
184
# LVs to split the VG correctly
186
COMM "vgsplit fails splitting 3 striped LVs into VG when only 1 LV specified"
187
vgcreate $vg1 $dev1 $dev2 $dev3 $dev4
188
lvcreate -l 4 -n $lv1 -i 2 $vg1 $dev1 $dev2
189
lvcreate -l 4 -n $lv2 -i 2 $vg1 $dev2 $dev3
190
lvcreate -l 4 -n $lv3 -i 2 $vg1 $dev3 $dev4
192
not vgsplit -n $lv1 $vg1 $vg2
195
COMM "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified"
196
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
197
lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2
198
lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3
199
lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4
200
check pvlv_counts $vg1 4 3 2
202
not vgsplit -n $lv1 $vg1 $vg2;
203
lvremove -f $vg1/$lv2
204
lvremove -f $vg1/$lv3
205
lvremove -f $vg1/$lv1
208
COMM "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified"
209
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
210
lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2
211
lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3
212
lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4
213
check pvlv_counts $vg1 4 3 2
215
not vgsplit -n $lv2 $vg1 $vg2
216
lvremove -f $vg1/$lv2
217
lvremove -f $vg1/$lv3
218
lvremove -f $vg1/$lv1
221
COMM "vgsplit fails splitting one mirror LV, only one PV specified"
222
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
223
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3
224
check pvlv_counts $vg1 4 1 0
226
not vgsplit $vg1 $vg2 $dev2
229
COMM "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified"
230
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
231
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3
232
lvcreate -l 16 -n $lv2 -i 2 $vg1 $dev3 $dev4
233
check pvlv_counts $vg1 4 2 0
235
not vgsplit -n $lv2 $vg1 $vg2 2>err
239
# Verify vgsplit rejects active LVs only when active LVs involved in split
241
COMM "vgsplit fails, active mirror involved in split"
242
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
243
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3
244
lvcreate -l 16 -n $lv2 $vg1 $dev4
245
lvchange -an $vg1/$lv2
246
check pvlv_counts $vg1 4 2 0
247
not vgsplit -n $lv1 $vg1 $vg2;
248
check pvlv_counts $vg1 4 2 0
251
COMM "vgsplit succeeds, active mirror not involved in split"
252
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
253
lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3
254
lvcreate -l 16 -n $lv2 $vg1 $dev4
255
lvchange -an $vg1/$lv2
256
check pvlv_counts $vg1 4 2 0
257
vgsplit -n $lv2 $vg1 $vg2
258
check pvlv_counts $vg1 3 1 0
259
check pvlv_counts $vg2 1 1 0
263
COMM "vgsplit fails, active snapshot involved in split"
264
vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4
265
lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2
266
lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1
267
lvcreate -l 64 -i 2 -n $lv3 $vg1 $dev3 $dev4
268
lvchange -an $vg1/$lv3
269
check pvlv_counts $vg1 4 3 1
270
not vgsplit -n $lv2 $vg1 $vg2;
271
check pvlv_counts $vg1 4 3 1
272
lvremove -f $vg1/$lv2
275
COMM "vgsplit succeeds, active snapshot not involved in split"
276
vgcreate -c n $vg1 $dev1 $dev2 $dev3
277
lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2
278
lvcreate -l 4 -s -n $lv2 $vg1/$lv1
280
lvcreate -l 64 -n $lv3 $vg1 $dev4
281
lvchange -an $vg1/$lv3
282
check pvlv_counts $vg1 4 3 1
283
vgsplit -n $lv3 $vg1 $vg2
284
check pvlv_counts $vg1 3 2 1
285
check pvlv_counts $vg2 1 1 0
287
lvremove -f $vg1/$lv2