2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2012-10-09 14:17:33 +04:00
# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2012-10-09 14:17:33 +04:00
2016-02-23 01:13:42 +03:00
SKIP_WITH_LVMLOCKD = 1
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2012-10-09 14:17:33 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2012-10-09 14:17:33 +04:00
get_image_pvs( ) {
local d
local images
2017-07-10 11:38:55 +03:00
images = $( dmsetup ls | grep " ${ 1 } - ${ 2 } _.image_.* " | cut -f1 | sed -e s:-:/:)
2012-10-09 14:17:33 +04:00
lvs --noheadings -a -o devices $images | sed s/\( .\) //
}
########################################################
# MAIN
########################################################
# RAID10: Can replace 'copies - 1' devices from each stripe
# Tests are run on 2-way mirror, 3-way stripe RAID10
2014-05-20 21:54:48 +04:00
aux have_raid 1 3 1 || skip
2012-10-09 14:17:33 +04:00
# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs)
aux prepare_pvs 9 80
2017-07-06 20:41:25 +03:00
get_devs
vgcreate -s 256k " $vg " " ${ DEVICES [@] } "
2012-10-09 14:17:33 +04:00
lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv1 $vg
aux wait_for_sync $vg $lv1
# Can replace any single device
for i in $( get_image_pvs $vg $lv1 ) ; do
lvconvert --replace $i $vg /$lv1
aux wait_for_sync $vg $lv1
done
# Can't replace adjacent devices
devices = ( $( get_image_pvs $vg $lv1 ) )
2017-07-10 11:40:09 +03:00
not lvconvert --replace " ${ devices [0] } " --replace " ${ devices [1] } " $vg /$lv1
not lvconvert --replace " ${ devices [2] } " --replace " ${ devices [3] } " $vg /$lv1
not lvconvert --replace " ${ devices [4] } " --replace " ${ devices [5] } " $vg /$lv1
2012-10-09 14:17:33 +04:00
# Can replace non-adjacent devices
for i in 0 1; do
lvconvert \
2017-07-10 11:40:09 +03:00
--replace " ${ devices [ $i ] } " \
--replace " ${ devices [ $(( i + 2 )) ] } " \
--replace " ${ devices [ $(( i + 4 )) ] } " \
2012-10-09 14:17:33 +04:00
$vg /$lv1
aux wait_for_sync $vg $lv1
done
2013-09-11 01:33:22 +04:00
2014-02-27 02:25:30 +04:00
vgremove -ff $vg