mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-26 07:33:16 +03:00
Compare commits
9 Commits
v2_03_36
...
dev-lvmguy
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be90a9866c | ||
|
|
624eedc7ae | ||
|
|
003bd55c44 | ||
|
|
e1d108086e | ||
|
|
02b2034c1a | ||
|
|
0e739a6d42 | ||
|
|
1a6d2b9194 | ||
|
|
ab60e1fba1 | ||
|
|
428cea96e9 |
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (C) 2024 Red Hat, Inc. All rights reserved.
|
||||
# Copyright (C) 2024,2025 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
|
||||
@@ -9,10 +9,21 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
#
|
||||
# Due to MD constraints, three issues must be considered when modifying stripe counts that alter the RAID-mapped device size:
|
||||
# - on a stripe adding reshape, the initial size remains until after the end when the device capacity is increased
|
||||
# - on a stripe removing reshape, the initial size is reduced before the reshape is allowed to start
|
||||
# - size changes are being reported asynchronously by the kernel, which requires polling for it for split seconds
|
||||
#
|
||||
|
||||
LVM_SKIP_LARGE_TESTS=1
|
||||
SKIP_FSCK=1
|
||||
SKIP_RESIZE=0
|
||||
|
||||
UDEVOPTS="--noudevsync"
|
||||
|
||||
. lib/inittest
|
||||
|
||||
which mkfs.ext4 || skip
|
||||
@@ -22,6 +33,9 @@ aux kernel_at_least 6 9 0 || skip
|
||||
|
||||
test "$(aux total_mem)" -gt 1048576 || skip "Not enough RAM for this test"
|
||||
|
||||
# Timeout in seconds to check for size updates happening during/after.
|
||||
CHECK_SIZE_TIMEOUT=5
|
||||
|
||||
# List of stripes to add or remove
|
||||
tst_stripes=""
|
||||
|
||||
@@ -33,22 +47,33 @@ ms=0
|
||||
npvs=0
|
||||
pvsz=0
|
||||
|
||||
function _get_pvs_stripes_and_delay
|
||||
function _get_pvs
|
||||
{
|
||||
case $LVM_SKIP_LARGE_TESTS in
|
||||
0)
|
||||
npvs=64
|
||||
pvsz=32
|
||||
;;
|
||||
*)
|
||||
npvs=20
|
||||
pvsz=16
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function _get_stripes_and_delay
|
||||
{
|
||||
local raid_type=$1
|
||||
|
||||
case $LVM_SKIP_LARGE_TESTS in
|
||||
0)
|
||||
npvs=64
|
||||
pvsz=32
|
||||
|
||||
case $raid_type in
|
||||
raid[45]*)
|
||||
ms=30
|
||||
ms=60
|
||||
tst_stripes="5 4 11 9 15 13 19 18 22 21 25 23 28 30 31 29 33 31 34 33 37 45 41 50 55 60 63 30 15 10 8 3"
|
||||
;;
|
||||
raid6*)
|
||||
ms=20
|
||||
ms=40
|
||||
tst_stripes="5 4 11 9 15 13 19 18 22 21 25 23 28 30 31 29 33 31 34 33 37 45 41 50 55 60 62 30 15 10 8 3"
|
||||
;;
|
||||
raid10*)
|
||||
@@ -58,20 +83,17 @@ function _get_pvs_stripes_and_delay
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
npvs=20
|
||||
pvsz=16
|
||||
|
||||
case $raid_type in
|
||||
raid[45]*)
|
||||
ms=40
|
||||
ms=60
|
||||
tst_stripes="5 4 8 7 11 9 15 19 18 10"
|
||||
;;
|
||||
raid6*)
|
||||
ms=25
|
||||
ms=40
|
||||
tst_stripes="5 4 8 7 11 9 15 18 10 5"
|
||||
;;
|
||||
raid10*)
|
||||
ms=40
|
||||
ms=50
|
||||
tst_stripes="5 6 7 8 9 10"
|
||||
;;
|
||||
esac
|
||||
@@ -86,9 +108,9 @@ function _get_size
|
||||
local reshape_len rimagesz
|
||||
|
||||
# Get any reshape size in sectors
|
||||
# avoid using pipes as exit codes may cause test failure
|
||||
# Avoid using pipes as exit codes may cause test failure
|
||||
reshape_len="$(lvs --noheadings --nosuffix -aoreshapelen --unit s $vg/${lv}_rimage_0)"
|
||||
# drop everything past 'S'
|
||||
# Drop everything past 'S'
|
||||
reshape_len="$(echo ${reshape_len/S*}|xargs)"
|
||||
|
||||
# Get rimage size - reshape length
|
||||
@@ -105,7 +127,24 @@ function _check_size
|
||||
local data_stripes=$3
|
||||
|
||||
# Compare size of LV with calculated one
|
||||
[ "$(blockdev --getsz /dev/$vg/$lv)" -eq "$(_get_size $vg $lv $data_stripes)" ] && echo 0 || echo 1
|
||||
test "$(blockdev --getsz /dev/$vg/$lv)" -eq "$(_get_size $vg $lv $data_stripes)"
|
||||
}
|
||||
|
||||
function _check_size_timeout
|
||||
{
|
||||
local count=$((CHECK_SIZE_TIMEOUT * 20))
|
||||
local r
|
||||
|
||||
while [ $count -gt 0 ]
|
||||
do
|
||||
_check_size $*
|
||||
r=$?
|
||||
[ $r -eq 0 ] && break
|
||||
((count--))
|
||||
sleep .05
|
||||
done
|
||||
|
||||
return $r
|
||||
}
|
||||
|
||||
function _total_stripes
|
||||
@@ -139,8 +178,8 @@ function _lvcreate
|
||||
check lv_first_seg_field $vg/$lv datastripes $data_stripes
|
||||
check lv_first_seg_field $vg/$lv stripes $stripes
|
||||
|
||||
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
echo y|mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv" || return 0
|
||||
}
|
||||
|
||||
function _reshape_layout
|
||||
@@ -157,13 +196,13 @@ function _reshape_layout
|
||||
|
||||
stripes=$(_total_stripes $raid_type $data_stripes)
|
||||
|
||||
lvconvert -y --ty $raid_type --stripes $data_stripes $opts $vg/$lv
|
||||
lvconvert -y --ty $raid_type --stripes $data_stripes $UDEVOPTS $opts $vg/$lv
|
||||
check lv_first_seg_field $vg/$lv1 segtype "$raid_type"
|
||||
|
||||
if [ $wait_for_reshape -eq 1 ]
|
||||
then
|
||||
aux wait_for_sync $vg $lv $ignore_a_chars
|
||||
fsck -fn "$DM_DEV_DIR/$vg/$lv"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fn "$DM_DEV_DIR/$vg/$lv" || return 0
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -178,34 +217,33 @@ function _add_stripes
|
||||
|
||||
stripes=$(_total_stripes $raid_type $data_stripes)
|
||||
|
||||
aux delay_dev "$dev1" $ms 0
|
||||
aux delay_dev "$dev1" $ms 0 "$(( $(get first_extent_sector "$dev1") + 2048 ))"
|
||||
_reshape_layout $raid_type $data_stripes $vg $lv 0 1 --stripesize $stripesize
|
||||
|
||||
# Size has to be inconsistent until reshape finishes
|
||||
[ $(_check_size $vg $lv $data_stripes) -ne 0 ] || die "LV size should be small"
|
||||
_check_size $vg $lv $data_stripes || die "LV size should be small"
|
||||
|
||||
aux delay_dev "$dev1" 0 0
|
||||
|
||||
check lv_first_seg_field $vg/$lv stripesize "$stripesize"
|
||||
check lv_first_seg_field $vg/$lv datastripes $data_stripes
|
||||
check lv_first_seg_field $vg/$lv stripes $stripes
|
||||
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
aux delay_dev "$dev1" 0 0
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
aux wait_for_sync $vg $lv 0
|
||||
sleep 1
|
||||
|
||||
# Now size consistency has to be fine
|
||||
[ $(_check_size $vg $lv $data_stripes) -eq 0 ] || die "LV size should be grown"
|
||||
_check_size_timeout $vg $lv $data_stripes && die "LV size should be grown"
|
||||
|
||||
# Check, use grown capacity for the filesystem and check again
|
||||
if [ $SKIP_RESIZE -eq 0 ]
|
||||
then
|
||||
# Mandatory fsck before resize2fs.
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
resize2fs "$DM_DEV_DIR/$vg/$lv"
|
||||
fi
|
||||
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
|
||||
udevadm settle
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv" || return 0
|
||||
}
|
||||
|
||||
function _remove_stripes
|
||||
@@ -224,26 +262,28 @@ function _remove_stripes
|
||||
# Check, shrink hilesystem to the resulting smaller size and check again
|
||||
if [ $SKIP_RESIZE -eq 0 ]
|
||||
then
|
||||
# Mandatory fsck before resize2fs.
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
resize2fs "$DM_DEV_DIR/$vg/$lv" $(_get_size $vg $lv $data_stripes)s
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
fi
|
||||
|
||||
aux delay_dev "$dev1" $ms 0
|
||||
aux delay_dev "$dev1" $ms 0 "$(( $(get first_extent_sector "$dev1") + 2048 ))"
|
||||
_reshape_layout $raid_type $data_stripes $vg $lv 0 1 --force --stripesize $stripesize
|
||||
|
||||
# Size has to be inconsistent, as to be removed legs still exist
|
||||
[ $(_check_size $vg $lv $cur_data_stripes) -ne 0 ] || die "LV size should be reduced but not rimage count"
|
||||
_check_size $vg $lv $cur_data_stripes && die "LV size should be reduced but not rimage count"
|
||||
|
||||
aux delay_dev "$dev1" 0 0
|
||||
|
||||
check lv_first_seg_field $vg/$lv stripesize "$stripesize"
|
||||
check lv_first_seg_field $vg/$lv datastripes $data_stripes
|
||||
check lv_first_seg_field $vg/$lv stripes $stripes
|
||||
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
|
||||
# Have to remove freed legs before another restriping conversion. Will fail while reshaping is ongoing as stripes are still in use
|
||||
not _reshape_layout $raid_type $(($data_stripes + 1)) 0 1 $vg $lv --force
|
||||
aux delay_dev "$dev1" 0 0
|
||||
aux wait_for_sync $vg $lv 1
|
||||
|
||||
# Remove freed legs as they are now idle has to succeed without --force
|
||||
@@ -251,14 +291,10 @@ function _remove_stripes
|
||||
check lv_first_seg_field $vg/$lv datastripes $data_stripes
|
||||
check lv_first_seg_field $vg/$lv stripes $(_total_stripes $raid_type $data_stripes)
|
||||
|
||||
sleep 1
|
||||
|
||||
# Now size consistency has to be fine
|
||||
[ $(_check_size $vg $lv $data_stripes) -eq 0 ] || die "LV size should be completely reduced"
|
||||
_check_size_timeout $vg $lv $data_stripes || die "LV size should be completely reduced"
|
||||
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
|
||||
udevadm settle
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv" || return 0
|
||||
}
|
||||
|
||||
function _test
|
||||
@@ -269,29 +305,24 @@ function _test
|
||||
local data_stripes=$4
|
||||
local cur_data_stripes
|
||||
|
||||
_get_pvs_stripes_and_delay $raid_type
|
||||
|
||||
aux prepare_pvs $npvs $pvsz
|
||||
get_devs
|
||||
|
||||
vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}"
|
||||
_get_stripes_and_delay $raid_type
|
||||
|
||||
# Calculate maximum rimage size in MiB and subtract 3 extents to leave room for rounding
|
||||
rimagesz=$(($(blockdev --getsz "$dev1") / 2048 - 3))
|
||||
|
||||
# Create (data_stripes+1)-way striped $raid_type
|
||||
_lvcreate $raid_type $data_stripes $(($data_stripes * ${rimagesz}))M $vg $lv --stripesize 128k
|
||||
[ $(_check_size $vg $lv $data_stripes) -eq 0 ] || die "LV size bogus"
|
||||
_check_size $vg $lv $data_stripes || die "LV size bogus"
|
||||
check lv_first_seg_field $vg/$lv stripesize "128.00k"
|
||||
aux wait_for_sync $vg $lv 0
|
||||
|
||||
# Delay its first 'PV' so that size can be evaluated before reshape finished too quick.
|
||||
aux delay_dev "$dev1" $ms 0
|
||||
aux delay_dev "$dev1" $ms 0 "$(( $(get first_extent_sector "$dev1") + 2048 ))"
|
||||
|
||||
# Reshape it to one more stripe and 256K stripe size
|
||||
_reshape_layout $raid_type $(($data_stripes + 1)) $vg $lv 0 0 --stripesize 256K
|
||||
[ $(_check_size $vg $lv $(($data_stripes + 1))) -ne 0 ] || die "LV size should still be small"
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
_check_size $vg $lv $data_stripes || die "LV size should still be small"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
|
||||
# Reset delay
|
||||
aux delay_dev "$dev1" 0 0
|
||||
@@ -299,9 +330,8 @@ function _test
|
||||
# Wait for sync to finish to check frow extended LV size
|
||||
aux wait_for_sync $vg $lv 0
|
||||
|
||||
[ $(_check_size $vg $lv $(($data_stripes + 1))) -eq 0 ] || die "LV size should be grown"
|
||||
fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
udevadm settle
|
||||
_check_size_timeout $vg $lv $(($data_stripes + 1)) || die "LV size should be grown"
|
||||
[ $SKIP_FSCK -eq 0 ] && fsck -fy "$DM_DEV_DIR/$vg/$lv"
|
||||
|
||||
# Loop adding stripes and check size consistency on each iteration
|
||||
for data_stripes in $tst_stripes
|
||||
@@ -311,12 +341,22 @@ function _test
|
||||
|| _remove_stripes $raid_type $vg $lv $data_stripes
|
||||
done
|
||||
|
||||
vgremove -ff $vg
|
||||
aux remove_dm_devs "${DEVICES[@]}"
|
||||
lvremove -ff $vg
|
||||
}
|
||||
|
||||
#
|
||||
# Main
|
||||
#
|
||||
_get_pvs
|
||||
aux prepare_pvs $npvs $pvsz
|
||||
get_devs
|
||||
vgcreate $SHARED -s 1M "$vg" "${DEVICES[@]}"
|
||||
|
||||
# Test all respective RAID levels
|
||||
_test $vg $lv1 raid4 2
|
||||
_test $vg $lv1 raid5_ra 2
|
||||
_test $vg $lv1 raid6_nc 3
|
||||
_test $vg $lv1 raid10 2
|
||||
|
||||
vgremove -ff $vg
|
||||
aux remove_dm_devs "${DEVICES[@]}"
|
||||
|
||||
Reference in New Issue
Block a user