2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2017-02-07 00:09:26 +03: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 17:49:48 +03:00
2017-02-07 00:09:26 +03:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
2017-02-13 00:28:40 +03:00
which mkfs.ext4 || skip
2017-05-16 11:47:53 +03:00
aux have_raid 1 9 0 || skip
2017-02-07 00:09:26 +03: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 12:23:14 +03:00
lvconvert --type " $type " --yes -R " $regionsize " " $vg / $lv "
2017-02-07 00:09:26 +03:00
check lv_field $vg /$lv regionsize " $regionsize_str "
2017-04-12 16:01:12 +03:00
2017-07-11 12:23:14 +03:00
not lvconvert --regionsize " $regionsize " " $vg / $lv " 2>err
2017-04-12 16:01:12 +03:00
grep "is already" err
2017-02-13 00:28:40 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv "
2017-02-07 00:09:26 +03: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 12:23:14 +03: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-07 00:09:26 +03:00
}
# Create 3-way raid1
2017-02-13 00:28:40 +03:00
lvcreate --yes -aey --type raid1 -m 2 -R64K -L8M -n $lv1 $vg
2017-02-07 00:09:26 +03: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-13 00:28:40 +03:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
aux wait_for_sync $vg $lv1
2017-02-13 00:28:40 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
_test_regionsizes raid1
# Clean up
lvremove --yes $vg
2017-05-31 13:59:53 +03:00
if aux have_raid 1 10 1; then
2017-02-07 00:09:26 +03:00
# Create 5-way raid6
2017-02-13 00:28:40 +03:00
lvcreate --yes -aey --type raid6 -i 3 --stripesize 128K -R 256K -L8M -n $lv1 $vg
2017-02-07 00:09:26 +03: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-13 00:28:40 +03:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
aux wait_for_sync $vg $lv1
2017-02-13 00:28:40 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
_test_regionsizes raid6
# Clean up
lvremove --yes $vg
2017-05-16 11:47:53 +03:00
else
echo "Skipping RAID6 tests"
fi
2017-02-07 00:09:26 +03:00
2017-05-31 13:59:53 +03:00
if aux have_raid 1 10 1; then
2017-02-07 00:09:26 +03:00
# Create 6-way raid01
2017-02-13 00:28:40 +03:00
lvcreate --yes -aey --type raid10 -i 3 -m 1 --stripesize 128K -R 256K -L8M -n $lv1 $vg
2017-02-07 00:09:26 +03: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-13 00:28:40 +03:00
mkfs.ext4 -t ext4 " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
aux wait_for_sync $vg $lv1
2017-02-13 00:28:40 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-07 00:09:26 +03:00
_test_regionsizes raid10
2017-05-31 13:59:53 +03:00
else
echo "Skipping RAID10 tests"
fi
2017-02-07 00:09:26 +03:00
vgremove -ff $vg