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

lvm_import_vdo: correct the converted virtual size

Ensure the volume after conversion has the properly aligned size to the
volume group extent size. This would be visible when using virtual size,
that cannot be divided by extent size.

Before the user had to manually adjust the size after conversion to get
access to all data stored on VDO volume.
This commit is contained in:
Zdenek Kabelac 2023-06-23 18:01:32 +02:00
parent ea6b5b694b
commit 657dde6208

View File

@ -357,6 +357,7 @@ convert_lv_() {
# For best use the latest version of vdoprepareforlvm tool is required.
convert_non_lv_() {
local vdo_logicalSize=$1
local vdo_logicalSizeRounded
local extent_size
local output
local pvfree
@ -417,7 +418,7 @@ convert_non_lv_() {
# Round virtual size to the LOWER size expressed in extent units.
# lvm is parsing VDO metadata and can read real full size and use it instead of this smaller value.
# To precisely byte-synchronize the size of VDO LV, user can lvresize such VDO LV later.
vdo_logicalSize=$(( ( vdo_logicalSize / extent_size ) * extent_size ))
vdo_logicalSizeRounded=$(( ( vdo_logicalSize / extent_size ) * extent_size ))
verbose "Creating VG \"${NAME%/*}\" with extent size $extent_size KiB."
dry "$LVM" vgcreate $YES $VERB --devices "$devices" -s "${extent_size}k" "$VGNAME" "$devices" || {
@ -428,7 +429,12 @@ convert_non_lv_() {
dry "$LVM" lvcreate -Zn -Wn -an $YES $VERB --devices "$devices" -l100%VG -n "${LVNAME}_vpool" "$VGNAME" "$devices"
verbose "Converting to VDO pool."
dry "$LVM" lvconvert $YES $VERB $FORCE --devices "$devices" --config "$VDO_ALLOCATION_PARAMS" -Zn -V "${vdo_logicalSize}k" -n "$LVNAME" --type vdo-pool "$VGNAME/${LVNAME}_vpool"
dry "$LVM" lvconvert $YES $VERB $FORCE --devices "$devices" --config "$VDO_ALLOCATION_PARAMS" -Zn -V "${vdo_logicalSizeRounded}k" -n "$LVNAME" --type vdo-pool "$VGNAME/${LVNAME}_vpool"
if [ "$vdo_logicalSizeRounded" -lt "$vdo_logicalSize" ] ; then
# need to extend virtal size to be covering all the converted area
# let lvm2 to round to the proper virtual size of VDO LV
dry "$LVM" lvextend $YES $VERB --fs ignore --devices "$devices" -L "$vdo_logicalSize"k "$VGNAME/$LVNAME"
fi
dry "$LVM" vgchange -an $VERB $FORCE --devices "$devices" "$VGNAME"