1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: extend the usability for older systems

Extend the test a bit futher so we can keep logic of resize
working similarly well for older and newer systems.

Test uses new 'aux have_fsinfo'function to regnize compiled
version of lvm.
This commit is contained in:
Zdenek Kabelac 2023-10-14 21:26:39 +02:00
parent 26766dcf73
commit 1a67bfe396
3 changed files with 35 additions and 8 deletions

View File

@ -15,10 +15,12 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest . lib/inittest
aux prepare_vg 3 256
which mkfs.xfs || skip which mkfs.xfs || skip
aux have_fsinfo || skip "Test needs --fs checksize support"
aux prepare_vg 3 256
# Tests require a libblkid version that shows FSLASTBLOCK # Tests require a libblkid version that shows FSLASTBLOCK
lvcreate -n $lv1 -L 300 $vg lvcreate -n $lv1 -L 300 $vg
mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1" mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"

View File

@ -21,14 +21,18 @@ which mkfs.ext4 || skip
which resize2fs || skip which resize2fs || skip
# #
# Workaroudn for kernel bug fixed with: # Blkid is not able to detected 'running' filesystem after resize
# freeeing and unfreezing stores fs metadata on disk
#
# Workaround for kernel bug fixed with:
# a408f33e895e455f16cf964cb5cd4979b658db7b # a408f33e895e455f16cf964cb5cd4979b658db7b
# refreshing DM device - using fsfreeze with suspend # refreshing DM device - using fsfreeze with suspend
# #
workaround_() { workaround_() {
blkid -p "$DM_DEV_DIR/$vg/$lv" >/dev/null || { local vol=${1-$lv}
dmsetup suspend $vg-$lv blkid -p "$DM_DEV_DIR/$vg/$vol" >/dev/null || {
dmsetup resume $vg-$lv dmsetup suspend $vg-$vol
dmsetup resume $vg-$vol
} }
} }
@ -90,6 +94,11 @@ lvreduce -L-10M $vg/$lv
check lv_field $vg/$lv lv_size "40.00m" check lv_field $vg/$lv lv_size "40.00m"
lvchange -an $vg/$lv lvchange -an $vg/$lv
HAVE_FSINFO=1
aux have_fsinfo || HAVE_FSINFO=
if [ -n "$HAVE_FSINFO" ]; then
# lvreduce, no fs, inactive, no --fs setting is same as --fs checksize # lvreduce, no fs, inactive, no --fs setting is same as --fs checksize
not lvreduce -L-10M $vg/$lv not lvreduce -L-10M $vg/$lv
lvreduce --fs checksize -L-10M $vg/$lv lvreduce --fs checksize -L-10M $vg/$lv
@ -104,6 +113,8 @@ lvchange -ay $vg/$lv
not lvreduce -L-10M --fs resize $vg/$lv not lvreduce -L-10M --fs resize $vg/$lv
check lv_field $vg/$lv lv_size "20.00m" check lv_field $vg/$lv lv_size "20.00m"
fi # HAVE_FSINFO
lvremove -f $vg/$lv lvremove -f $vg/$lv
@ -146,6 +157,8 @@ diff df1 df2
# keep mounted fs # keep mounted fs
# lvextend, ext4, active, mounted, --fs resize # lvextend, ext4, active, mounted, --fs resize
workaround_
lvextend --fs resize -L+10M $vg/$lv lvextend --fs resize -L+10M $vg/$lv
check lv_field $vg/$lv lv_size "50.00m" check lv_field $vg/$lv lv_size "50.00m"
df --output=size "$mount_dir" |tee df2 df --output=size "$mount_dir" |tee df2
@ -162,6 +175,8 @@ df --output=size "$mount_dir" |tee df2
not diff df1 df2 not diff df1 df2
# keep mounted fs # keep mounted fs
if [ -n "$HAVE_FSINFO" ]; then
workaround_ workaround_
# lvextend, ext4, active, mounted, --fs resize --fsmode manage (same as --fs resize) # lvextend, ext4, active, mounted, --fs resize --fsmode manage (same as --fs resize)
@ -193,6 +208,8 @@ df --output=size "$mount_dir" |tee df2
not diff df1 df2 not diff df1 df2
# keep mounted fs # keep mounted fs
fi # HAVE_FSINFO
# lvextend|lvreduce, ext4, active, mounted, --fs resize, renamed LV # lvextend|lvreduce, ext4, active, mounted, --fs resize, renamed LV
lvrename $vg/$lv $vg/$lv2 lvrename $vg/$lv $vg/$lv2
not lvextend --fs resize -L+32M $vg/$lv2 not lvextend --fs resize -L+32M $vg/$lv2
@ -245,11 +262,17 @@ umount "$mount_dir"
umount "$mount_dir_2" umount "$mount_dir_2"
mount "$DM_DEV_DIR/$vg/$lv3" "$mount_dir" mount "$DM_DEV_DIR/$vg/$lv3" "$mount_dir"
lvextend -r -L+8M $vg/$lv3 lvextend -r -L+8M $vg/$lv3
workaround_ $lv3
lvreduce -r -y -L-8M $vg/$lv3 lvreduce -r -y -L-8M $vg/$lv3
umount "$mount_dir" umount "$mount_dir"
lvremove -f $vg/$lv3 lvremove -f $vg/$lv3
# Following test require --fs checksize being compiled in
test -z "$HAVE_FSINFO" && exit 0
##################################### #####################################
# #
# Now let do some unmounted tests # Now let do some unmounted tests

View File

@ -15,11 +15,13 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest . lib/inittest
aux prepare_vg 1 500
which mkfs.xfs || skip which mkfs.xfs || skip
which xfs_growfs || skip which xfs_growfs || skip
aux have_fsinfo || skip "Test needs --fs checksize support"
aux prepare_vg 1 500
mount_dir="mnt_lvresize_fs" mount_dir="mnt_lvresize_fs"
mkdir -p "$mount_dir" mkdir -p "$mount_dir"