2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2014-06-26 06:20:41 +04:00
# Copyright (C) 2011-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
2014-06-26 06:20:41 +04:00
2018-06-01 00:18:53 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2014-06-26 06:20:41 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-06-26 06:20:41 +04:00
aux have_raid 1 3 0 || skip
aux prepare_pvs 5
2017-07-06 20:41:25 +03:00
get_devs
2018-06-01 00:18:53 +03:00
vgcreate $SHARED -s 256k " $vg " " ${ DEVICES [@] } "
2014-06-26 06:20:41 +04:00
# Start with linear on 2 PV and ensure that converting to
# RAID is not allowed to reuse PVs for different images. (Bug 1113180)
2014-07-23 01:43:26 +04:00
lvcreate -aey -l 4 -n $lv1 $vg " $dev1 :0-1 " " $dev2 :0-1 "
2017-04-27 16:56:58 +03:00
not lvconvert -y --type raid1 -m 1 $vg /$lv1 " $dev1 " " $dev2 "
not lvconvert -y --type raid1 -m 1 $vg /$lv1 " $dev1 " " $dev3 :0-2 "
2017-04-06 19:47:41 +03:00
lvconvert -y --type raid1 -m 1 $vg /$lv1 " $dev3 "
2017-03-09 15:16:08 +03:00
not lvconvert -m 0 $vg /$lv1
lvconvert -y -m 0 $vg /$lv1
2014-06-26 06:20:41 +04:00
# RAID conversions are not honoring allocation policy!
2017-04-06 19:47:41 +03:00
# lvconvert -y --type raid1 -m 1 --alloc anywhere $vg/$lv1 "$dev1" "$dev2"
2014-06-26 06:20:41 +04:00
lvremove -ff $vg
2014-06-26 07:26:06 +04:00
# Setup 2-way RAID1 LV, spread across 4 devices.
2014-06-26 06:20:41 +04:00
# For each image:
# - metadata LV + 1 image extent (2 total extents) on one PV
# - 2 image extents on the other PV
# Then attempt allocation of another image from 2 extents on
# a 5th PV and the remainder of the rest of already used PVs.
#
# This should fail because there is insufficient space on the
# non-parallel PV (i.e. there is not enough space for the image
# if it doesn't share a PV with another image).
lvcreate --type raid1 -m 1 -l 3 -n $lv1 $vg \
" $dev1 :0-1 " " $dev2 :0-1 " " $dev3 :0-1 " " $dev4 :0-1 "
aux wait_for_sync $vg $lv1
# Should not be enough non-overlapping space.
not lvconvert -m +1 $vg /$lv1 \
" $dev5 :0-1 " " $dev1 " " $dev2 " " $dev3 " " $dev4 "
2017-04-06 19:47:41 +03:00
lvconvert -y -m +1 $vg /$lv1 " $dev5 "
2017-03-09 15:16:08 +03:00
not lvconvert -m 0 $vg /$lv1
lvconvert -y -m 0 $vg /$lv1
2014-06-26 06:20:41 +04:00
# Should work due to '--alloc anywhere'
# RAID conversion not honoring allocation policy!
2017-04-06 19:47:41 +03:00
#lvconvert -y -m +1 --alloc anywhere $vg/$lv1 \
2014-06-26 06:20:41 +04:00
# "$dev5:0-1" "$dev1" "$dev2" "$dev3" "$dev4"
lvremove -ff $vg
2014-06-26 07:26:06 +04:00
# Setup 2-way RAID1 LV, spread across 4 devices
# - metadata LV + 1 image extent (2 total extents) on one PV
# - 2 image extents on the other PV
# Kill one PV. There should be enough space on the remaining
# PV for that image to reallocate the entire image there and
# still maintain redundancy.
lvcreate --type raid1 -m 1 -l 3 -n $lv1 $vg \
" $dev1 :0-1 " " $dev2 :0-1 " " $dev3 :0-1 " " $dev4 :0-1 "
aux wait_for_sync $vg $lv1
aux disable_dev " $dev1 "
2017-04-06 19:47:41 +03:00
lvconvert -y --repair $vg /$lv1 " $dev2 " " $dev3 " " $dev4 "
2014-06-26 07:26:06 +04:00
#FIXME: ensure non-overlapping images (they should not share PVs)
aux enable_dev " $dev1 "
lvremove -ff $vg
2014-06-26 06:20:41 +04:00
vgremove -ff $vg