2017-07-02 21:38:32 +02:00
#!/usr/bin/env bash
2017-02-06 22:09:26 +01:00
# Copyright (C) 2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2018-05-24 09:49:48 -05:00
2017-02-06 22:09:26 +01:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
2017-02-12 22:28:40 +01:00
which mkfs.ext4 || skip
2017-05-16 10:47:53 +02:00
aux have_raid 1 9 0 || skip
2017-02-06 22:09:26 +01:00
aux prepare_vg 6
function _test_regionsize
{
local type = $1
local regionsize = $2
local regionsize_str = $3
local vg = $4
local lv = $5
2017-07-11 11:23:14 +02:00
lvconvert --type " $type " --yes -R " $regionsize " " $vg / $lv "
2017-02-06 22:09:26 +01:00
check lv_field $vg /$lv regionsize " $regionsize_str "
2017-04-12 15:01:12 +02:00
2017-07-11 11:23:14 +02:00
not lvconvert --regionsize " $regionsize " " $vg / $lv " 2>err
2017-04-12 15:01:12 +02:00
grep "is already" err
2017-02-12 22:28:40 +01:00
fsck -fn " $DM_DEV_DIR / $vg / $lv "
2017-02-06 22:09:26 +01:00
}
function _test_regionsizes
{
# FIXME: have to provide raid type or region size ain't set until cli validation merged
local type = $1
# Test RAID regionsize changes
2017-07-11 11:23:14 +02:00
_test_regionsize " $type " 128K "128.00k" $vg $lv1
_test_regionsize " $type " 256K "256.00k" $vg $lv1
not _test_regionsize " $type " 1K "1.00k" $vg $lv1
_test_regionsize " $type " 1m "1.00m" $vg $lv1
not _test_regionsize " $type " 1G "1.00g" $vg $lv1
not _test_regionsize " $type " 16K "16.00k" $vg $lv1
2017-02-06 22:09:26 +01:00
}
# Create 3-way raid1
2017-02-12 22:28:40 +01:00
lvcreate --yes -aey --type raid1 -m 2 -R64K -L8M -n $lv1 $vg
2017-02-06 22:09:26 +01:00
check lv_field $vg /$lv1 segtype "raid1"
check lv_field $vg /$lv1 stripes 3
check lv_field $vg /$lv1 regionsize "64.00k"
2017-02-12 22:28:40 +01:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
aux wait_for_sync $vg $lv1
2017-02-12 22:28:40 +01:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
_test_regionsizes raid1
# Clean up
lvremove --yes $vg
2017-05-31 12:59:53 +02:00
if aux have_raid 1 10 1; then
2017-02-06 22:09:26 +01:00
# Create 5-way raid6
2017-02-12 22:28:40 +01:00
lvcreate --yes -aey --type raid6 -i 3 --stripesize 128K -R 256K -L8M -n $lv1 $vg
2017-02-06 22:09:26 +01:00
check lv_field $vg /$lv1 segtype "raid6"
check lv_field $vg /$lv1 stripes 5
check lv_field $vg /$lv1 stripesize "128.00k"
check lv_field $vg /$lv1 regionsize "256.00k"
2017-02-12 22:28:40 +01:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
aux wait_for_sync $vg $lv1
2017-02-12 22:28:40 +01:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
_test_regionsizes raid6
# Clean up
lvremove --yes $vg
2017-05-16 10:47:53 +02:00
else
echo "Skipping RAID6 tests"
fi
2017-02-06 22:09:26 +01:00
2017-05-31 12:59:53 +02:00
if aux have_raid 1 10 1; then
2017-02-06 22:09:26 +01:00
# Create 6-way raid01
2017-02-12 22:28:40 +01:00
lvcreate --yes -aey --type raid10 -i 3 -m 1 --stripesize 128K -R 256K -L8M -n $lv1 $vg
2017-02-06 22:09:26 +01:00
check lv_field $vg /$lv1 segtype "raid10"
check lv_field $vg /$lv1 stripes 6
check lv_field $vg /$lv1 stripesize "128.00k"
check lv_field $vg /$lv1 regionsize "256.00k"
2017-02-12 22:28:40 +01:00
mkfs.ext4 -t ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
aux wait_for_sync $vg $lv1
2017-02-12 22:28:40 +01:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-06 22:09:26 +01:00
_test_regionsizes raid10
2017-05-31 12:59:53 +02:00
else
echo "Skipping RAID10 tests"
fi
2017-02-06 22:09:26 +01:00
vgremove -ff $vg