2012-10-09 15:51:30 +04:00
#!/bin/sh
# 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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2014-06-06 19:40:04 +04:00
. lib/inittest
2012-10-09 15:51:30 +04:00
2014-02-22 04:26:47 +04:00
lv_devices( ) {
2014-05-15 12:25:25 +04: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
aux prepare_pvs 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test
2013-05-31 23:11:51 +04:00
vgcreate -s 512k $vg $( cat DEVICES)
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)
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
lvremove -ff $vg
# Implicit count comes from total #PVs in VG (always 2 for mirror though)
2014-05-15 12:25:25 +04:00
lvcreate --type raid10 -l2 -an -Zn -n raid10 $vg
2014-02-22 04:26:47 +04:00
lv_devices $vg raid10 6
lvremove -ff $vg
2012-10-09 15:51:30 +04:00
#
# FIXME: Add tests that specify particular PVs to use for creation
#
2014-02-27 02:25:30 +04:00
vgremove -ff $vg