2012-10-09 15:51:30 +04:00
#!/bin/sh
2016-07-28 17:37:20 +03:00
# Copyright (C) 2012-2016 Red Hat, Inc. All rights reserved.
2012-10-09 15:51:30 +04:00
#
# 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 15:51:30 +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 15:51:30 +04:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2014-02-22 04:26:47 +04:00
lv_devices( ) {
2017-07-10 11:40:09 +03:00
test " $3 " -eq " $( get lv_devices " $1 / $2 " | wc -w) "
2014-02-22 04:26:47 +04:00
}
2012-10-09 15:51:30 +04:00
########################################################
# MAIN
########################################################
2014-05-20 21:54:48 +04:00
aux have_raid 1 3 0 || skip
2012-10-09 15:51:30 +04:00
2016-12-12 13:22:41 +03:00
aux prepare_vg 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test
2012-10-09 15:51:30 +04:00
#
# Create RAID10:
#
# Should not allow more than 2-way mirror
not lvcreate --type raid10 -m 2 -i 2 -l 2 -n $lv1 $vg
# 2-way mirror, 2-stripes
lvcreate --type raid10 -m 1 -i 2 -l 2 -n $lv1 $vg
aux wait_for_sync $vg $lv1
2013-08-10 02:09:47 +04:00
lvremove -ff $vg /$lv1
# 2-way mirror, 2-stripes - Set min/max recovery rate
lvcreate --type raid10 -m 1 -i 2 -l 2 \
2014-05-15 12:25:25 +04:00
--minrecoveryrate 50 --maxrecoveryrate 1M \
2013-08-10 02:09:47 +04:00
-n $lv1 $vg
2013-09-16 13:15:38 +04:00
check lv_field $vg /$lv1 raid_min_recovery_rate 50
2014-05-15 12:25:25 +04:00
check lv_field $vg /$lv1 raid_max_recovery_rate 1024
2013-08-10 02:09:47 +04:00
aux wait_for_sync $vg $lv1
2012-10-09 15:51:30 +04:00
# 2-way mirror, 3-stripes
2013-06-15 13:21:03 +04:00
lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv2 $vg
aux wait_for_sync $vg $lv2
2012-10-09 15:51:30 +04:00
lvremove -ff $vg
2014-02-14 07:10:28 +04:00
# Test 100%FREE option
2014-09-14 13:46:13 +04:00
# 38 extents / device
# 1 image = 37 extents (1 for meta)
# 3 images = 111 extents = 55.50m
2014-05-15 12:25:25 +04:00
lvcreate --type raid10 -i 3 -l 100%FREE -an -Zn -n raid10 $vg
2014-09-14 13:46:13 +04:00
check lv_field $vg /raid10 size "55.50m"
2014-02-14 07:10:28 +04:00
lvremove -ff $vg
2014-02-22 04:26:47 +04:00
# Create RAID (implicit stripe count based on PV count)
#######################################################
# Not enough drives
2014-03-20 02:32:25 +04:00
not lvcreate --type raid10 -l2 $vg " $dev1 " " $dev2 " " $dev3 "
2014-02-22 04:26:47 +04:00
# Implicit count comes from #PVs given (always 2-way mirror)
2016-07-28 17:37:20 +03:00
# Defaults -i2, which works with 4 PVs listed
2014-05-15 12:25:25 +04:00
lvcreate --type raid10 -l2 -an -Zn -n raid10 $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 "
2014-02-22 04:26:47 +04:00
lv_devices $vg raid10 4
2016-07-28 17:37:20 +03:00
# Defaults -i2 even though more PVs listed
lvcreate --type raid10 -l2 -an -Zn -n raid10_6 $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 " " $dev5 " " $dev6 "
lv_devices $vg raid10_6 4
2014-02-22 04:26:47 +04:00
lvremove -ff $vg
2012-10-09 15:51:30 +04:00
#
# FIXME: Add tests that specify particular PVs to use for creation
#
2016-07-28 17:37:20 +03:00
########################################################
# Try again with backward compatible old logic applied #
########################################################
aux lvmconf 'allocation/raid_stripe_all_devices = 1'
# Implicit count comes from #PVs given (always 2-way mirror)
lvcreate --type raid10 -l2 -an -Zn -n raid10 $vg " $dev1 " " $dev2 " " $dev3 " " $dev4 "
lv_devices $vg raid10 4
# Implicit count comes from total #PVs in VG (always 2 for mirror though)
lvcreate --type raid10 -l2 -an -Zn -n raid10_vg $vg
lv_devices $vg raid10_vg 6
2014-02-27 02:25:30 +04:00
vgremove -ff $vg