2019-10-02 15:54:00 +03:00
#!/usr/bin/env bash
# Copyright (C) 2019 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
SKIP_WITH_LVMPOLLD = 1
. lib/inittest
2019-10-16 22:58:39 +03:00
aux have_raid 1 3 0 || skip
2020-09-16 14:21:16 +03:00
PROGRESS = 0
2021-03-17 00:59:01 +03:00
aux have_raid 1 15 0 && PROGRESS = 1
2019-10-02 15:54:00 +03:00
# Use smallest regionsize to save VG space
2020-09-04 19:05:01 +03:00
regionsize = $( getconf PAGESIZE) # in bytes
2023-02-09 18:05:40 +03:00
pageregions = $(( regionsize * 8 )) # number of regions per MD bitmap page
2019-10-02 15:54:00 +03:00
# in KiB
2023-02-09 18:05:40 +03:00
regionsize = $(( regionsize / 1024 ))
2019-10-02 15:54:00 +03:00
# in MiB
2023-02-09 18:05:40 +03:00
lvsz = $(( pageregions * regionsize / 1024 ))
lvext = $(( lvsz / 8 ))
2019-10-02 15:54:00 +03:00
2023-02-09 18:05:40 +03:00
aux prepare_pvs 2 $(( lvsz + 3 * lvext ))
2019-10-02 15:54:00 +03:00
get_devs
vgcreate -s 4k $vg ${ DEVICES [@] }
2020-09-04 19:05:01 +03:00
# Keep $dev1 & $dev2 always open via small active LVs.
# This trick avoids race on system with scanning udev service
# when device is 'in-use' and we cleared _rimage & _rmeta.
lvcreate -l1 $vg " $dev1 "
lvcreate -l1 $vg " $dev2 "
sector = $(( $( get first_extent_sector " $dev2 " ) + 2048 ))
2020-09-08 01:22:16 +03:00
aux zero_dev " $dev1 " " ${ sector } : "
2020-09-16 14:21:16 +03:00
aux delayzero_dev " $dev2 " 0 10 " ${ sector } : "
2019-10-02 15:54:00 +03:00
# Create raid1 LV consuming 1 MD bitmap page
2023-02-09 18:05:40 +03:00
lvcreate --yes --type raid1 --regionsize ${ regionsize } K -L$(( lvsz - lvext )) M -n $lv1 $vg
2020-09-08 01:22:16 +03:00
lvs -a $vg
2019-10-02 15:54:00 +03:00
not check lv_field $vg /$lv1 sync_percent "100.00"
2023-02-09 18:05:40 +03:00
check lv_field $vg /$lv1 size " $(( lvsz - lvext )) .00m " $vg /$lv1
2019-10-02 15:54:00 +03:00
aux wait_for_sync $vg $lv1
check lv_field $vg /$lv1 sync_percent "100.00"
check lv_field $vg /$lv1 region_size "4.00k"
2020-09-04 19:05:01 +03:00
# to slow down extension - slowdown readings
2020-09-16 14:21:16 +03:00
aux delayzero_dev " $dev1 " 50 0 " ${ sector } : "
aux delayzero_dev " $dev2 " 0 50 " ${ sector } : "
2020-09-04 19:05:01 +03:00
2019-10-02 15:54:00 +03:00
# Extend so that full MD bitmap page is consumed
2020-09-08 01:22:16 +03:00
lvextend -y -L+${ lvext } M $vg /$lv1
2020-09-16 14:21:16 +03:00
if [ $PROGRESS -eq 1 ]
2020-09-08 01:22:16 +03:00
then
2021-03-23 23:32:51 +03:00
# Even with delayed devices wre are catching races here.
should not check lv_field $vg /$lv1 sync_percent "100.00"
2023-02-09 18:05:40 +03:00
check lv_field $vg /$lv1 size " $lvsz .00m " $vg /$lv1
2020-09-08 01:22:16 +03:00
fi
2019-10-02 15:54:00 +03:00
aux wait_for_sync $vg $lv1
check lv_field $vg /$lv1 sync_percent "100.00"
# Extend so that another MD bitmap page is allocated
lvextend -y -L+${ lvext } M $vg /$lv1
2020-09-16 14:21:16 +03:00
if [ $PROGRESS -eq 1 ]
2019-10-02 15:54:00 +03:00
then
2021-03-26 02:43:44 +03:00
# Even with delayed devices wre are catching races here.
should not check lv_field $vg /$lv1 sync_percent "100.00"
2019-10-02 15:54:00 +03:00
else
check lv_field $vg /$lv1 sync_percent "100.00"
fi
2023-07-15 11:39:56 +03:00
aux enable_dev " $dev1 " " $dev2 "
2020-09-04 19:05:01 +03:00
2020-09-08 01:22:16 +03:00
aux wait_for_sync $vg $lv1
check lv_field $vg /$lv1 sync_percent "100.00"
2023-02-09 18:05:40 +03:00
check lv_field $vg /$lv1 size " $(( lvsz + lvext )) .00m " $vg /$lv1
2020-09-08 01:22:16 +03:00
2019-10-02 15:54:00 +03:00
vgremove -ff $vg