2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2017-02-24 07:16:21 +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, MA2110-1301 USA
2018-05-24 17:49:48 +03:00
2017-02-24 07:16:21 +03:00
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
2018-05-30 13:50:34 +03:00
aux lvmconf 'activation/raid_region_size = 512'
2017-02-24 07:16:21 +03:00
which mkfs.ext4 || skip
2018-09-11 16:39:31 +03:00
aux have_raid 1 14 0 || skip
2017-02-24 07:16:21 +03:00
2017-12-01 20:42:37 +03:00
aux prepare_vg 5 20
2017-02-24 07:16:21 +03:00
#
# Test single step linear -> striped conversion
#
# Create 4-way striped LV
lvcreate -aey -i 4 -I 32k -L 16M -n $lv1 $vg
check lv_field $vg /$lv1 segtype "striped"
2017-03-01 20:50:35 +03:00
check lv_field $vg /$lv1 data_stripes 4
2017-02-24 07:16:21 +03:00
check lv_field $vg /$lv1 stripes 4
check lv_field $vg /$lv1 stripesize "32.00k"
2017-03-16 23:17:58 +03:00
check lv_field $vg /$lv1 reshape_len_le ""
2020-09-10 17:47:52 +03:00
wipefs -a " $DM_DEV_DIR / $vg / $lv1 "
mkfs -t ext4 " $DM_DEV_DIR / $vg / $lv1 "
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
# Convert striped -> raid5(_n)
lvconvert -y --ty raid5 -R 128k $vg /$lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
check lv_field $vg /$lv1 segtype "raid5_n"
2017-03-01 20:50:35 +03:00
check lv_field $vg /$lv1 data_stripes 4
2017-02-24 07:16:21 +03:00
check lv_field $vg /$lv1 stripes 5
check lv_field $vg /$lv1 stripesize "32.00k"
check lv_field $vg /$lv1 regionsize "128.00k"
2017-03-16 23:17:58 +03:00
check lv_field $vg /$lv1 reshape_len_le 0
2017-02-24 07:16:21 +03:00
aux wait_for_sync $vg $lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
# Extend raid5_n LV by factor 4 to keep size once linear
2018-05-30 13:50:34 +03:00
lvresize -y -L 64M $vg /$lv1
aux wait_for_sync $vg $lv1
2017-03-01 20:50:35 +03:00
check lv_field $vg /$lv1 segtype "raid5_n"
check lv_field $vg /$lv1 data_stripes 4
check lv_field $vg /$lv1 stripes 5
check lv_field $vg /$lv1 stripesize "32.00k"
check lv_field $vg /$lv1 regionsize "128.00k"
2017-03-16 23:17:58 +03:00
check lv_field $vg /$lv1 reshape_len_le "0"
2017-02-24 07:16:21 +03:00
aux wait_for_sync $vg $lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
# Convert raid5_n LV to 1 stripe (2 legs total),
# 64k stripesize and 1024k regionsize
# FIXME: "--type" superfluous (cli fix needed)
lvconvert -y -f --ty raid5_n --stripes 1 -I 64k -R 1024k $vg /$lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 segtype "raid5_n"
2017-03-01 20:50:35 +03:00
check lv_first_seg_field $vg /$lv1 data_stripes 1
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 stripes 5
2017-12-01 20:42:37 +03:00
check lv_first_seg_field $vg /$lv1 stripesize "32.00k"
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 regionsize "1.00m"
2017-03-16 23:17:58 +03:00
check lv_first_seg_field $vg /$lv1 reshape_len_le 10
2017-03-01 20:50:35 +03:00
# for slv in {0..4}
# do
2017-03-16 23:17:58 +03:00
# check lv_first_seg_field $vg/${lv1}_rimage_${slv} reshape_len_le 2
2017-03-01 20:50:35 +03:00
# done
2017-02-24 07:16:21 +03:00
aux wait_for_sync $vg $lv1 1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
# Remove the now freed legs
2017-05-16 18:51:58 +03:00
lvconvert -y --stripes 1 $vg /$lv1
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 segtype "raid5_n"
2017-03-01 20:50:35 +03:00
check lv_first_seg_field $vg /$lv1 data_stripes 1
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 stripes 2
2017-12-01 20:42:37 +03:00
check lv_first_seg_field $vg /$lv1 stripesize "32.00k"
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 regionsize "1.00m"
2017-03-16 23:17:58 +03:00
check lv_first_seg_field $vg /$lv1 reshape_len_le 4
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
# Convert raid5_n to raid1
lvconvert -y --type raid1 $vg /$lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 segtype "raid1"
2017-03-01 20:50:35 +03:00
check lv_first_seg_field $vg /$lv1 data_stripes 2
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 stripes 2
check lv_first_seg_field $vg /$lv1 stripesize "0"
check lv_first_seg_field $vg /$lv1 regionsize "1.00m"
2017-03-16 23:17:58 +03:00
check lv_first_seg_field $vg /$lv1 reshape_len_le ""
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
2017-12-01 20:42:37 +03:00
# Convert raid1 -> linear
2017-02-24 07:16:21 +03:00
lvconvert -y --type linear $vg /$lv1
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 segtype "linear"
2017-03-01 20:50:35 +03:00
check lv_first_seg_field $vg /$lv1 data_stripes 1
2017-02-24 07:16:21 +03:00
check lv_first_seg_field $vg /$lv1 stripes 1
check lv_first_seg_field $vg /$lv1 stripesize "0"
check lv_first_seg_field $vg /$lv1 regionsize "0"
2017-03-16 23:17:58 +03:00
check lv_first_seg_field $vg /$lv1 reshape_len_le ""
2020-09-10 17:47:52 +03:00
fsck -fn " $DM_DEV_DIR / $vg / $lv1 "
2017-02-24 07:16:21 +03:00
vgremove -ff $vg