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

tests: updates

Add some more complicated conversion tests.
This commit is contained in:
Zdenek Kabelac 2023-06-09 13:28:23 +02:00
parent 7f661a24c4
commit 9105890d43

View File

@ -18,10 +18,12 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest . lib/inittest
# Use local for this test vdo configuratoin # Use local for this test vdo configuratoin
VDOCONF="-f vdotestconf.yml" VDO_CONFIG="vdotestconf.yml"
VDOCONF="-f $VDO_CONFIG"
#VDOCONF="" #VDOCONF=""
export VDOCONF export VDOCONF VDO_CONFIG
VDONAME="${PREFIX}-TESTVDO" VDONAME="${PREFIX}-TESTVDO"
export DM_UUID_PREFIX=$PREFIX
# VDO automatically starts dmeventd # VDO automatically starts dmeventd
aux prepare_dmeventd aux prepare_dmeventd
@ -44,11 +46,11 @@ export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
aux have_vdo 6 2 0 || skip aux have_vdo 6 2 0 || skip
aux prepare_devs 2 10000 aux prepare_devs 2 20000
aux extend_filter_LVMTEST aux extend_filter_LVMTEST
export TMPDIR=$PWD
# Conversion can be made with this version of vdo driver # Conversion can be made with this version of vdo driver
@ -59,14 +61,16 @@ aux have_vdo 6 2 5 || skip
# #
# In this case we do not need to move any VDO headers. # In this case we do not need to move any VDO headers.
# #
if [ 1 -eq 0 ]; then
vgcreate $vg "$dev1" vgcreate $vg "$dev1"
lvcreate -L5G -n $lv1 $vg lvcreate -L5G -n $lv1 $vg
# use some not so 'well' aligned virtual|logical size
vdo create $VDOCONF --name "$VDONAME" --device "$DM_DEV_DIR/$vg/$lv1" --vdoSlabSize 128M --vdoLogicalSize 10G vdo create $VDOCONF --name "$VDONAME" --device "$DM_DEV_DIR/$vg/$lv1" --vdoSlabSize 128M --vdoLogicalSize 10G
mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME" mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
##XXXXX
# Different VG name fails # Different VG name fails
not lvm_import_vdo -y -v --name $vg1/$lv1 "$DM_DEV_DIR/$vg/$lv1" not lvm_import_vdo -y -v --name $vg1/$lv1 "$DM_DEV_DIR/$vg/$lv1"
@ -130,26 +134,25 @@ vdo create $VDOCONF --name "$VDONAME" --device "$dev1" --vdoSlabSize 128M --vdoL
mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME" mkfs -E nodiscard "$DM_DEV_DIR/mapper/$VDONAME"
lvm_import_vdo -y -v --name $vg1/$lv2 "$dev1" lvm_import_vdo --vdo-config "$VDO_CONFIG" -y -v --name $vg1/$lv2 "$dev1"
fsck -n "$DM_DEV_DIR/$vg1/$lv2" fsck -n "$DM_DEV_DIR/$vg1/$lv2"
vgremove -f $vg1 vgremove -f $vg1
fi
aux teardown_devs aux wipefs_a "$dev1"
# let's assume users with VDO target have 'new' enough version of stat too
# otherwise use more universal code from lvm_vdo_import
read major minor < <(stat -c '%Hr %Lr' $(readlink -e "$dev1"))
dmsetup create "$PREFIX-vdotest" --table "0 30280004 linear $major:$minor 32"
# Check with some real non-DM device from system TEST="$DM_DEV_DIR/mapper/$PREFIX-vdotest"
# this needs to dropping DM_DEV_DIR
aux prepare_loop 60000 || skip aux wipefs_a "$TEST"
aux extend_filter "a|$TEST|"
test -f LOOP aux extend_devices "$TEST"
LOOP=$(< LOOP)
LOOP="${DM_DEV_DIR}/${LOOP##/dev/}"
aux extend_filter "a|$LOOP|"
aux extend_devices "$LOOP"
# #
# Unfortunatelly generates this in syslog: # Unfortunatelly generates this in syslog:
@ -165,7 +168,9 @@ aux extend_devices "$LOOP"
# #
# automate... # automate...
# #
vdo create $VDOCONF --name "$VDONAME" --device "$LOOP" --vdoSlabSize 128M --vdoLogicalSize 23G\
# use slightly smaller size then 'rounded' 23G - to enforce vdo_logicalSize rounding
vdo create $VDOCONF --name "$VDONAME" --device "$TEST" --vdoSlabSize 128M --vdoLogicalSize 24117240K\
--blockMapCacheSize 192 \ --blockMapCacheSize 192 \
--blockMapPeriod 2048 \ --blockMapPeriod 2048 \
--emulate512 disabled \ --emulate512 disabled \
@ -179,19 +184,39 @@ vdo create $VDOCONF --name "$VDONAME" --device "$LOOP" --vdoSlabSize 128M --vdoL
--vdoHashZoneThreads 3 \ --vdoHashZoneThreads 3 \
--vdoLogicalThreads 3 \ --vdoLogicalThreads 3 \
--writePolicy async-unsafe --writePolicy async-unsafe
dmsetup table
# Get VDO table line # Get VDO table line
dmsetup table "$VDONAME" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee vdo-orig dmsetup table "$VDONAME" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee vdo-orig
# For conversion we
aux lvmconf 'global/vdo_disabled_features = [ "version4" ]' aux lvmconf 'global/vdo_disabled_features = [ "version4" ]'
lvm_import_vdo -y --name $vg/$lv "$LOOP" #
lvs -a $vg # Try to prepare 'broken' case where header was moved by older tool to 2M position
#
export LVM_VDO_PREPARE=oldvdoprepareforlvm2M
if which "$LVM_VDO_PREPARE" ; then
# Use old vdoprepareforlvm tool, that always moves header to 2M offset
cp "$VDO_CONFIG" "$VDO_CONFIG.backup"
lvm_import_vdo --abort-after-vdo-convert --vdo-config "$VDO_CONFIG" -v -y --name $vg/$lv "$TEST"
# Restore VDO configuration (as it's been removed with succeful vdo conversion
cp "$VDO_CONFIG.backup" "$VDO_CONFIG"
# Check VDO header is seen at 2M offset
blkid -c /dev/null --probe --offset 2M "$TEST"
fi
unset LVM_VDO_PREPARE
#lvm_import_vdo --no-snapshot --vdo-config "$VDO_CONFIG" -v -y --name $vg/$lv "$TEST"
lvm_import_vdo --vdo-config "$VDO_CONFIG" --uuid-prefix "$PREFIX" -v -y --name $vg/$lv "$TEST"
# Compare converted LV uses same VDO table line
dmsetup table "$vg-${lv}_vpool-vpool" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee new-vdo-lv dmsetup table "$vg-${lv}_vpool-vpool" | tr " " "\n" | sed -e '5,6d' -e '12d' | tee new-vdo-lv
# Check there is a match between VDO and LV managed volume # Check there is a match between VDO and LV managed volume
# (when differentiating parameters are deleted first) # (when differentiating parameters are deleted first)
diff -u vdo-orig new-vdo-lv || die "Found mismatching VDO table lines!" diff -u vdo-orig new-vdo-lv || die "Found mismatching VDO table lines!"
check lv_field $vg/$lv size "23.00g" check lv_field $vg/$lv size "<23.00g"
unset LVM_VDO_PREPARE