Expand PMF_FN_* macros.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / t-vgsplit-operation.sh
bloba801f93a71bb6fd2a9b986d5e1d59feed35ede76
1 #!/bin/sh
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
14 . ./test-utils.sh
16 COMM() {
17 LAST_TEST="$@"
20 prepare_pvs 5 257
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
23 # metadata
26 # vgsplit can be done into a new or existing VG
28 for i in new existing
31 # We can have PVs or LVs on the cmdline
33 for j in PV LV
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
39 fi
40 lvcreate -l 4 -n $lv1 $vg1 $dev1
41 vgchange -an $vg1
42 if [ $j = PV ]; then
43 vgsplit $vg1 $vg2 $dev1
44 else
45 vgsplit -n $lv1 $vg1 $vg2
46 fi
47 vg_validate_pvlv_counts_ $vg1 1 0 0
48 if [ $i = existing ]; then
49 aux vg_validate_pvlv_counts_ $vg2 3 1 0
50 else
51 aux vg_validate_pvlv_counts_ $vg2 1 1 0
52 fi
53 lvremove -f $vg2/$lv1
54 vgremove -f $vg2
55 vgremove -f $vg1
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
61 fi
62 lvcreate -l 4 -i 2 -n $lv1 $vg1 $dev1 $dev2
63 vgchange -an $vg1
64 if [ $j = PV ]; then
65 vgsplit $vg1 $vg2 $dev1 $dev2
66 else
67 vgsplit -n $lv1 $vg1 $vg2
68 fi
69 if [ $i = existing ]; then
70 aux vg_validate_pvlv_counts_ $vg2 4 1 0
71 else
72 aux vg_validate_pvlv_counts_ $vg2 2 1 0
73 fi
74 lvremove -f $vg2/$lv1
75 vgremove -f $vg2
77 COMM "vgsplit correctly splits mirror LV into $i VG ($j args)"
78 vgcreate $vg1 $dev1 $dev2 $dev3
79 if [ $i = existing ]; then
80 vgcreate $vg2 $dev4
81 fi
82 lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3
83 vgchange -an $vg1
84 if [ $j = PV ]; then
85 vgsplit $vg1 $vg2 $dev1 $dev2 $dev3
86 else
87 vgsplit -n $lv1 $vg1 $vg2
88 fi
89 if [ $i = existing ]; then
90 aux vg_validate_pvlv_counts_ $vg2 4 1 0
91 else
92 aux vg_validate_pvlv_counts_ $vg2 3 1 0
93 fi
94 lvremove -f $vg2/$lv1
95 vgremove -f $vg2
97 COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)"
98 vgcreate $vg1 $dev1 $dev2
99 if [ $i = existing ]; then
100 vgcreate $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
104 vgchange -an $vg1
105 if [ $j = PV ]; then
106 vgsplit $vg1 $vg2 $dev1 $dev2
107 else
108 vgsplit -n $lv1 $vg1 $vg2
110 if [ $i = existing ]; then
111 aux vg_validate_pvlv_counts_ $vg2 4 2 1
112 else
113 aux vg_validate_pvlv_counts_ $vg2 2 2 1
115 lvremove -f $vg2/$lv2
116 lvremove -f $vg2/$lv1
117 vgremove -f $vg2
119 COMM "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)"
120 vgcreate $vg1 $dev1 $dev2
121 if [ $i = existing ]; then
122 vgcreate $vg2 $dev3
124 lvcreate -l 64 -i 2 -n $lv1 $vg1
125 lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1
126 vgextend $vg1 $dev4
127 lvcreate -l 64 -n $lv3 $vg1 $dev4
128 vgchange -an $vg1
129 if [ $j = PV ]; then
130 vgsplit $vg1 $vg2 $dev4
131 else
132 vgsplit -n $lv3 $vg1 $vg2
134 if [ $i = existing ]; then
135 aux vg_validate_pvlv_counts_ $vg2 2 1 0
136 aux vg_validate_pvlv_counts_ $vg1 2 2 1
137 else
138 aux vg_validate_pvlv_counts_ $vg2 1 1 0
139 aux vg_validate_pvlv_counts_ $vg1 2 2 1
141 lvremove -f $vg1/$lv2
142 lvremove -f $vg1/$lv1
143 lvremove -f $vg2/$lv3
144 vgremove -f $vg1
145 vgremove -f $vg2
147 COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)"
148 vgcreate $vg1 $dev1 $dev2 $dev3
149 if [ $i = existing ]; then
150 vgcreate $vg2 $dev5
152 lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3
153 vgextend $vg1 $dev4
154 lvcreate -l 64 -n $lv2 $vg1 $dev4
155 vgchange -an $vg1
157 lvs
159 if [ $j = PV ]; then
160 vgsplit $vg1 $vg2 $dev4
161 else
162 vgsplit -n $lv2 $vg1 $vg2
164 if [ $i = existing ]; then
165 aux vg_validate_pvlv_counts_ $vg1 3 1 0
166 aux vg_validate_pvlv_counts_ $vg2 2 1 0
167 else
169 lvs
171 aux vg_validate_pvlv_counts_ $vg1 3 1 0
172 aux vg_validate_pvlv_counts_ $vg2 1 1 0
174 lvremove -f $vg1/$lv1
175 lvremove -f $vg2/$lv2
176 vgremove -f $vg1
177 vgremove -f $vg2
179 done
180 done
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
191 vgchange -an $vg1
192 not vgsplit -n $lv1 $vg1 $vg2
193 vgremove -ff $vg1
195 COMM "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified"
196 vgcreate $vg1 $dev1 $dev2 $dev3 $dev4
197 lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2
198 lvcreate -l 4 -n $lv2 -s $vg1/$lv1
199 lvcreate -l 4 -n $lv3 -s $vg1/$lv1
200 vg_validate_pvlv_counts_ $vg1 4 3 2
201 vgchange -an $vg1
202 not vgsplit -n $lv1 $vg1 $vg2;
203 lvremove -f $vg1/$lv2
204 lvremove -f $vg1/$lv3
205 lvremove -f $vg1/$lv1
206 vgremove -ff $vg1
208 COMM "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified"
209 vgcreate $vg1 $dev1 $dev2 $dev3 $dev4
210 lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2
211 lvcreate -l 4 -n $lv2 -s $vg1/$lv1
212 lvcreate -l 4 -n $lv3 -s $vg1/$lv1
213 vg_validate_pvlv_counts_ $vg1 4 3 2
214 vgchange -an $vg1
215 not vgsplit -n $lv2 $vg1 $vg2
216 lvremove -f $vg1/$lv2
217 lvremove -f $vg1/$lv3
218 lvremove -f $vg1/$lv1
219 vgremove -ff $vg1
221 COMM "vgsplit fails splitting one mirror LV, only one PV specified"
222 vgcreate $vg1 $dev1 $dev2 $dev3 $dev4
223 lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3
224 vg_validate_pvlv_counts_ $vg1 4 1 0
225 vgchange -an $vg1
226 not vgsplit $vg1 $vg2 $dev2
227 vgremove -ff $vg1
229 COMM "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified"
230 vgcreate $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 vg_validate_pvlv_counts_ $vg1 4 2 0
234 vgchange -an $vg1
235 not vgsplit -n $lv2 $vg1 $vg2 2>err
236 vgremove -ff $vg1
239 # Verify vgsplit rejects active LVs only when active LVs involved in split
241 COMM "vgsplit fails, active mirror involved in split"
242 vgcreate $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 vg_validate_pvlv_counts_ $vg1 4 2 0
247 not vgsplit -n $lv1 $vg1 $vg2;
248 vg_validate_pvlv_counts_ $vg1 4 2 0
249 vgremove -ff $vg1
251 COMM "vgsplit succeeds, active mirror not involved in split"
252 vgcreate $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 vg_validate_pvlv_counts_ $vg1 4 2 0
257 vgsplit -n $lv2 $vg1 $vg2
258 vg_validate_pvlv_counts_ $vg1 3 1 0
259 vg_validate_pvlv_counts_ $vg2 1 1 0
260 vgremove -ff $vg1
261 vgremove -ff $vg2
263 COMM "vgsplit fails, active snapshot involved in split"
264 vgcreate $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 vg_validate_pvlv_counts_ $vg1 4 3 1
270 not vgsplit -n $lv2 $vg1 $vg2;
271 vg_validate_pvlv_counts_ $vg1 4 3 1
272 lvremove -f $vg1/$lv2
273 vgremove -ff $vg1
275 COMM "vgsplit succeeds, active snapshot not involved in split"
276 vgcreate $vg1 $dev1 $dev2 $dev3
277 lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2
278 lvcreate -l 4 -s -n $lv2 $vg1/$lv1
279 vgextend $vg1 $dev4
280 lvcreate -l 64 -n $lv3 $vg1 $dev4
281 lvchange -an $vg1/$lv3
282 vg_validate_pvlv_counts_ $vg1 4 3 1
283 vgsplit -n $lv3 $vg1 $vg2
284 vg_validate_pvlv_counts_ $vg1 3 2 1
285 vg_validate_pvlv_counts_ $vg2 1 1 0
286 vgchange -an $vg1
287 lvremove -f $vg1/$lv2
288 vgremove -ff $vg1
289 vgremove -ff $vg2