1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-18 10:04:20 +03:00

vdo: better support for devicesfile

Instead of relying on 'pvs' output - check directly system
configuation and use lvmdevice accrording to use_devicesfile setting.

Also drop use of --fs ignore for filesystem extension for better
backward compatibility with older lvm version.

Shuffle code a bit so the '--no-snapshot' path does not execute
a few unnecessary commands.
This commit is contained in:
Zdenek Kabelac 2023-09-13 13:20:31 +02:00
parent 8cbfd72f68
commit e1cfc075c2

View File

@ -203,7 +203,7 @@ snapshot_merge_() {
error "ABORTING: Failed to initialize snapshot merge! Origin volume is unchanged." error "ABORTING: Failed to initialize snapshot merge! Origin volume is unchanged."
} }
verbose "Merging converted VDO volume..." verbose "Merging converted VDO volume \"$VDO_DM_SNAPSHOT_NAME\"."
VDO_INCONSISTENT=1 VDO_INCONSISTENT=1
# Running merging # Running merging
@ -235,12 +235,15 @@ snapshot_merge_() {
VDO_INCONSISTENT= VDO_INCONSISTENT=
VDO_CONFIG_RESTORE= VDO_CONFIG_RESTORE=
verbose "Converted VDO volume is merged to \"$1\"."
"$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || { "$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || {
sleep 1 # sleep and retry once more sleep 1 # sleep and retry once more
"$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || { "$DMSETUP" remove "$VDO_DM_SNAPSHOT_NAME" || {
error "ABORTING: Cannot remove snapshot $VDO_DM_SNAPSHOT_NAME! (check volume autoactivation...)" error "ABORTING: Cannot remove snapshot $VDO_DM_SNAPSHOT_NAME! (check volume autoactivation...)"
} }
} }
VDO_DM_SNAPSHOT_NAME= VDO_DM_SNAPSHOT_NAME=
"$LOSETUP" -d "$VDO_SNAPSHOT_LOOP" "$LOSETUP" -d "$VDO_SNAPSHOT_LOOP"
VDO_SNAPSHOT_LOOP= VDO_SNAPSHOT_LOOP=
@ -500,44 +503,40 @@ convert_non_lv_() {
if [ "$vdo_logicalSizeRounded" -lt "$vdo_logicalSize" ]; then if [ "$vdo_logicalSizeRounded" -lt "$vdo_logicalSize" ]; then
# need to extend virtual size to be covering all the converted area # need to extend virtual size to be covering all the converted area
# let lvm2 to round to the proper virtual size of VDO LV # let lvm2 to round to the proper virtual size of VDO LV
dry "$LVM" lvextend $YES $VERB --fs ignore --devices "$device" -L "$vdo_logicalSize"k "$VGNAME/$LVNAME" dry "$LVM" lvextend $YES $VERB --devices "$device" -L "$vdo_logicalSize"k "$VGNAME/$LVNAME"
fi fi
VDO_INCONSISTENT= VDO_INCONSISTENT=
if [ -n "$USE_VDO_DM_SNAPSHOT" ]; then [ -z "$USE_VDO_DM_SNAPSHOT" ] && return # no-snapshot case finished
dry "$LVM" vgchange -an $VERB $FORCE --devices "$device" "$VGNAME"
# Prevent unwanted auto activation when VG is merged dry "$LVM" vgchange -an $VERB $FORCE --devices "$device" "$VGNAME"
dry "$LVM" vgchange --setautoactivation n $VERB $FORCE --devices "$device" "$VGNAME"
if [ -z "$YES" ]; then # Prevent unwanted auto activation when VG is merged
PROMPTING=yes dry "$LVM" vgchange --setautoactivation n $VERB $FORCE --devices "$device" "$VGNAME"
warn "Do not interrupt merging process once it starts (VDO data may become irrecoverable)!"
echo -n "$TOOL: Do you want to merge converted VDO device \"$DEVICE\" to VDO LV \"$VGNAME/$LVNAME\"? [y|N]: "
read -r -n 1 -s ANSWER
case "${ANSWER:0:1}" in
y|Y ) echo "Yes" ;;
* ) echo "No" ; PROMPTING=""; return 1 ;;
esac
PROMPTING=""
YES="-y" # From now, now prompting
fi
dry snapshot_merge_ "$DEVICE" if [ -z "$YES" ]; then
PROMPTING=yes
verbose "Merging of VDO device finished." warn "Do not interrupt merging process once it starts (VDO data may become irrecoverable)!"
echo -n "$TOOL: Do you want to merge converted VDO device \"$DEVICE\" to VDO LV \"$VGNAME/$LVNAME\"? [y|N]: "
read -r -n 1 -s ANSWER
case "${ANSWER:0:1}" in
y|Y ) echo "Yes" ;;
* ) echo "No" ; PROMPTING=""; return 1 ;;
esac
PROMPTING=""
YES="-y" # From now, now prompting
fi fi
output=$("$LVM" pvs "$DEVICE" 2>&1) || { dry snapshot_merge_ "$DEVICE"
if echo "$output" | grep -q "not in devices file" ; then
verbose "Adding \"$DEVICE\" to devices file." # For systems using devicesfile add 'merged' PV into system.devices.
dry "$LVM" lvmdevices --adddev "$DEVICE" if [ "$("$LVM" lvmconfig --valuesonly devices/use_devicesfile --typeconfig full)" = "1" ]; then
fi dry "$LVM" lvmdevices --adddev "$DEVICE"
} fi
# Restore auto activation for a VG # Restore auto activation for a VG
[ -n "$USE_VDO_DM_SNAPSHOT" ] && dry "$LVM" vgchange --setautoactivation y $VERB $FORCE "$VGNAME" dry "$LVM" vgchange --setautoactivation y $VERB $FORCE "$VGNAME"
dry "$LVM" lvchange -ay $VERB $FORCE "$VGNAME/$LVNAME" dry "$LVM" lvchange -ay $VERB $FORCE "$VGNAME/$LVNAME"
} }