1 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
2 # Copyright (C) 2007 NEC Corporation
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
="ensure that 'vgreduce --removemissing' works on mirrored LV"
16 dmsetup_has_dm_devdir_support_ ||
exit 200
24 echo "Check if $lv is exactly on PVs $pvs"
26 echo $pvs |
sed 's/ /\n/g' |
sort |
uniq > out1
28 lvs
-a -odevices --noheadings $lv | \
29 sed 's/([^)]*)//g; s/[ ,]/\n/g' |
sort |
uniq > out2
31 diff --ignore-blank-lines out1 out2
42 echo "Check if mirror images of $lv are on PVs $pvs"
44 echo $pvs |
sed 's/ /\n/g' |
sort |
uniq > out1
46 mimages
=$
(lvs
--noheadings -a -o lv_name
$vg |
grep "${lv}_mimage_" | \
47 sed 's/\[//g; s/\]//g')
49 echo "Checking $vg/$i"
50 lvs
-a -odevices --noheadings $vg/$i | \
51 sed 's/([^)]*)//g; s/ //g; s/,/ /g' |
sort |
uniq >> out2
54 diff --ignore-blank-lines out1 out2
66 echo "Check if $1 is linear LV (i.e. not a mirror)"
67 lvs
-o stripes
,attr
--noheadings $vg/$1 |
sed 's/ //g'
68 lvs
-o stripes
,attr
--noheadings $vg/$1 |
sed 's/ //g' |
grep -q '^1-'
78 for n
in $
(seq 1 $
(($index - 1))) $
(seq $
(($index + 1)) $num); do
79 eval local dev
=$\dev
$n
86 # ---------------------------------------------------------------------
87 # Initialize PVs and VGs
91 # ---------------------------------------------------------------------
92 # Common environment setup/cleanup for each sub testcases
97 if dmsetup table|
grep $vg; then
98 echo "ERROR: lvremove did leave some some mappings in DM behind!"
104 check_and_cleanup_lvs_
()
106 lvs
-a -o+devices
$vg
108 if dmsetup table|
grep $vg; then
109 echo "ERROR: lvremove did leave some some mappings in DM behind!"
119 check_and_cleanup_lvs_
122 #COMM "check environment setup/cleanup"
124 check_and_cleanup_lvs_
126 # ---------------------------------------------------------------------
127 # one of mirror images has failed
129 #COMM "basic: fail the 2nd mirror image of 2-way mirrored LV"
131 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1
132 lvchange
-an $vg/$lv1
133 aux mimages_are_on_
$lv1 $dev1 $dev2
134 mirrorlog_is_on_
$lv1 $dev3
136 vgreduce
--removemissing --force $vg
143 # ---------------------------------------------------------------------
144 # LV has 3 images in flat,
145 # 1 out of 3 images fails
147 #COMM test_3way_mirror_fail_1_ <PV# to fail>
148 test_3way_mirror_fail_1_
()
152 lvcreate
-l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev4:0-1
153 lvchange
-an $vg/$lv1
154 aux mimages_are_on_
$lv1 $dev1 $dev2 $dev3
155 mirrorlog_is_on_
$lv1 $dev4
156 eval disable_dev \
$dev$index
157 vgreduce
--removemissing --force $vg
158 lvs
-a -o+devices
$vg
159 mimages_are_on_
$lv1 $
(rest_pvs_
$index 3)
160 mirrorlog_is_on_
$lv1 $dev4
163 for n
in $
(seq 1 3); do
164 #COMM fail mirror image $(($n - 1)) of 3-way mirrored LV"
166 test_3way_mirror_fail_1_
$n
167 eval recover_vg_ \
$dev$n
170 # ---------------------------------------------------------------------
171 # LV has 3 images in flat,
172 # 2 out of 3 images fail
174 #COMM test_3way_mirror_fail_2_ <PV# NOT to fail>
175 test_3way_mirror_fail_2_
()
179 lvcreate
-l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev4:0-1
180 lvchange
-an $vg/$lv1
181 mimages_are_on_
$lv1 $dev1 $dev2 $dev3
182 mirrorlog_is_on_
$lv1 $dev4
184 disable_dev $
(rest_pvs_
$index 3)
185 vgreduce
--force --removemissing $vg
186 lvs
-a -o+devices
$vg
187 aux lv_is_linear_
$lv1
188 eval lv_is_on_
$lv1 \
$dev$n
191 for n
in $
(seq 1 3); do
192 #COMM fail mirror images other than mirror image $(($n - 1)) of 3-way mirrored LV
194 test_3way_mirror_fail_2_
$n
195 recover_vg_ $
(rest_pvs_
$n 3)
198 # ---------------------------------------------------------------------
199 # LV has 4 images, 1 of them is in the temporary mirror for syncing.
200 # 1 out of 4 images fails
202 #COMM test_3way_mirror_plus_1_fail_1_ <PV# to fail>
203 test_3way_mirror_plus_1_fail_1_
()
207 lvcreate
-l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev5:0-1
208 lvchange
-an $vg/$lv1
209 lvconvert
-m+1 $vg/$lv1 $dev4
210 mimages_are_on_
$lv1 $dev1 $dev2 $dev3 $dev4
211 mirrorlog_is_on_
$lv1 $dev5
212 eval disable_dev \
$dev$n
213 vgreduce
--removemissing --force $vg
214 lvs
-a -o+devices
$vg
215 mimages_are_on_
$lv1 $
(rest_pvs_
$index 4)
216 mirrorlog_is_on_
$lv1 $dev5
219 for n
in $
(seq 1 4); do
220 #COMM "fail mirror image $(($n - 1)) of 4-way (1 converting) mirrored LV"
222 test_3way_mirror_plus_1_fail_1_
$n
223 eval recover_vg_ \
$dev$n
226 # ---------------------------------------------------------------------
227 # LV has 4 images, 1 of them is in the temporary mirror for syncing.
228 # 3 out of 4 images fail
230 #COMM test_3way_mirror_plus_1_fail_3_ <PV# NOT to fail>
231 test_3way_mirror_plus_1_fail_3_
()
235 lvcreate
-l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev5:0-1
236 lvchange
-an $vg/$lv1
237 lvconvert
-m+1 $vg/$lv1 $dev4
238 mimages_are_on_
$lv1 $dev1 $dev2 $dev3 $dev4
239 mirrorlog_is_on_
$lv1 $dev5
240 disable_dev $
(rest_pvs_
$index 4)
241 vgreduce
--removemissing --force $vg
242 lvs
-a -o+devices
$vg
243 eval local dev
=\
$dev$n
244 mimages_are_on_
$lv1 $dev || lv_is_on_
$lv1 $dev
245 not mirrorlog_is_on_
$lv1 $dev5
248 for n
in $
(seq 1 4); do
249 #COMM "fail mirror images other than mirror image $(($n - 1)) of 4-way (1 converting) mirrored LV"
251 test_3way_mirror_plus_1_fail_3_
$n
252 recover_vg_ $
(rest_pvs_
$n 4)
255 # ---------------------------------------------------------------------
256 # LV has 4 images, 2 of them are in the temporary mirror for syncing.
257 # 1 out of 4 images fail
259 # test_2way_mirror_plus_2_fail_1_ <PV# to fail>
260 test_2way_mirror_plus_2_fail_1_
()
264 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
265 lvchange
-an $vg/$lv1
266 lvconvert
-m+2 $vg/$lv1 $dev3 $dev4
267 mimages_are_on_
$lv1 $dev1 $dev2 $dev3 $dev4
268 mirrorlog_is_on_
$lv1 $dev5
269 eval disable_dev \
$dev$n
270 vgreduce
--removemissing --force $vg
271 lvs
-a -o+devices
$vg
272 mimages_are_on_
$lv1 $
(rest_pvs_
$index 4)
273 mirrorlog_is_on_
$lv1 $dev5
276 for n
in $
(seq 1 4); do
277 #COMM "fail mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV"
279 test_2way_mirror_plus_2_fail_1_
$n
280 eval recover_vg_ \
$dev$n
283 # ---------------------------------------------------------------------
284 # LV has 4 images, 2 of them are in the temporary mirror for syncing.
285 # 3 out of 4 images fail
287 # test_2way_mirror_plus_2_fail_3_ <PV# NOT to fail>
288 test_2way_mirror_plus_2_fail_3_
()
292 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
293 lvchange
-an $vg/$lv1
294 lvconvert
-m+2 $vg/$lv1 $dev3 $dev4
295 mimages_are_on_
$lv1 $dev1 $dev2 $dev3 $dev4
296 mirrorlog_is_on_
$lv1 $dev5
297 disable_dev $
(rest_pvs_
$index 4)
298 vgreduce
--removemissing --force $vg
299 lvs
-a -o+devices
$vg
300 eval local dev
=\
$dev$n
301 mimages_are_on_
$lv1 $dev || lv_is_on_
$lv1 $dev
302 not mirrorlog_is_on_
$lv1 $dev5
305 for n
in $
(seq 1 4); do
306 #COMM "fail mirror images other than mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV"
308 test_2way_mirror_plus_2_fail_3_
$n
309 recover_vg_ $
(rest_pvs_
$n 4)
312 # ---------------------------------------------------------------------
313 # log device is gone (flat mirror and stacked mirror)
315 #COMM "fail mirror log of 2-way mirrored LV"
317 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
318 lvchange
-an $vg/$lv1
319 mimages_are_on_
$lv1 $dev1 $dev2
320 mirrorlog_is_on_
$lv1 $dev5
322 vgreduce
--removemissing --force $vg
323 mimages_are_on_
$lv1 $dev1 $dev2
324 not mirrorlog_is_on_
$lv1 $dev5
327 #COMM "fail mirror log of 3-way (1 converting) mirrored LV"
329 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
330 lvchange
-an $vg/$lv1
331 lvconvert
-m+1 $vg/$lv1 $dev3
332 mimages_are_on_
$lv1 $dev1 $dev2 $dev3
333 mirrorlog_is_on_
$lv1 $dev5
335 vgreduce
--removemissing --force $vg
336 mimages_are_on_
$lv1 $dev1 $dev2 $dev3
337 not mirrorlog_is_on_
$lv1 $dev5
340 # ---------------------------------------------------------------------
341 # all images are gone (flat mirror and stacked mirror)
343 #COMM "fail all mirror images of 2-way mirrored LV"
345 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
346 lvchange
-an $vg/$lv1
347 mimages_are_on_
$lv1 $dev1 $dev2
348 mirrorlog_is_on_
$lv1 $dev5
349 disable_dev
$dev1 $dev2
350 vgreduce
--removemissing --force $vg
352 recover_vg_
$dev1 $dev2
354 #COMM "fail all mirror images of 3-way (1 converting) mirrored LV"
356 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
357 lvchange
-an $vg/$lv1
358 lvconvert
-m+1 $vg/$lv1 $dev3
359 mimages_are_on_
$lv1 $dev1 $dev2 $dev3
360 mirrorlog_is_on_
$lv1 $dev5
361 disable_dev
$dev1 $dev2 $dev3
362 vgreduce
--removemissing --force $vg
364 recover_vg_
$dev1 $dev2 $dev3
366 # ---------------------------------------------------------------------
369 #COMM "fail a mirror image of one of mirrored LV"
371 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
372 lvchange
-an $vg/$lv1
373 lvcreate
-l2 -m1 -n $lv2 $vg $dev3 $dev4 $dev5:1-1
374 lvchange
-an $vg/$lv2
375 mimages_are_on_
$lv1 $dev1 $dev2
376 mimages_are_on_
$lv2 $dev3 $dev4
377 mirrorlog_is_on_
$lv1 $dev5
378 mirrorlog_is_on_
$lv2 $dev5
380 vgreduce
--removemissing --force $vg
381 mimages_are_on_
$lv2 $dev3 $dev4
382 mirrorlog_is_on_
$lv2 $dev5
387 #COMM "fail mirror images, one for each mirrored LV"
389 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
390 lvchange
-an $vg/$lv1
391 lvcreate
-l2 -m1 -n $lv2 $vg $dev3 $dev4 $dev5:1-1
392 lvchange
-an $vg/$lv2
393 mimages_are_on_
$lv1 $dev1 $dev2
394 mimages_are_on_
$lv2 $dev3 $dev4
395 mirrorlog_is_on_
$lv1 $dev5
396 mirrorlog_is_on_
$lv2 $dev5
399 vgreduce
--removemissing --force $vg
404 recover_vg_
$dev2 $dev4
406 # ---------------------------------------------------------------------
411 lvcreate
-l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0-1
412 lvchange
-an $vg/$lv1
413 mimages_are_on_
$lv1 $dev1 $dev2
414 mirrorlog_is_on_
$lv1 $dev5
415 vgreduce
--removemissing --force $vg
416 mimages_are_on_
$lv1 $dev1 $dev2
417 mirrorlog_is_on_
$lv1 $dev5
418 check_and_cleanup_lvs_
420 # ---------------------------------------------------------------------