From 7197f3e6f8a44fd00df74adfc95c79b9f5d9a430 Mon Sep 17 00:00:00 2001 From: Pavel Cahyna Date: Mon, 30 Aug 2021 23:49:47 +0200 Subject: [PATCH] Add patch for better handling of thin pools and other LV types not supported by vgcfgrestore Resolves: rhbz2004178 --- rear-bz1747468.patch | 112 +++++++++++++++++++++++++++++++++++++++++++ rear.spec | 1 + 2 files changed, 113 insertions(+) create mode 100644 rear-bz1747468.patch diff --git a/rear-bz1747468.patch b/rear-bz1747468.patch new file mode 100644 index 0000000..a2f7bb3 --- /dev/null +++ b/rear-bz1747468.patch @@ -0,0 +1,112 @@ +diff --git a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh +index 7cfdfcf2..1be17ba8 100644 +--- a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh ++++ b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh +@@ -68,9 +68,9 @@ create_lvmgrp() { + local vg=${vgrp#/dev/} + + cat >> "$LAYOUT_CODE" <> "$LAYOUT_CODE" <&2 ; then + + LogPrint "Sleeping 3 seconds to let udev or systemd-udevd create their devices..." + sleep 3 >&2 +- create_volume_group=0 +- create_logical_volumes=0 ++ create_volume_group=( \$( RmInArray "$vg" "\${create_volume_group[@]}" ) ) ++ create_logical_volumes=( \$( RmInArray "$vg" "\${create_logical_volumes[@]}" ) ) + ++EOF ++ if is_true "${FORCE_VGCFGRESTORE-no}"; then ++ cat >> "$LAYOUT_CODE" <&2 ; then + sleep 3 >&2 + + # All logical volumes have been created, except Thin volumes and pools +- create_volume_group=0 +- create_thin_volumes_only=1 ++ create_volume_group=( \$( RmInArray "$vg" "\${create_volume_group[@]}" ) ) ++ create_thin_volumes_only+=( "$vg" ) + ++EOF ++ fi ++ cat >> "$LAYOUT_CODE" <> "$LAYOUT_CODE" < in the first argument) ++# doesn't contain any LVs that use kernel metadata. ++# If the function returns true, we can safely use vgcfgrestore to restore the VG. ++function lvmgrp_supports_vgcfgrestore() { ++ if is_true "${FORCE_VGCFGRESTORE-no}"; then ++ # If we are willing to use vgcfgrestore --force and then remove broken volumes, ++ # then everything can be considered supported. Don't do it by default though. ++ return 0 ++ fi ++ ++ local lvmvol vgrp lvname size layout kval ++ ++ local supported_layouts=("linear" "striped") ++ ++ while read lvmvol vgrp lvname size layout kval; do ++ [ "$vgrp" == "$1" ] || BugError "vgrp '$vgrp' != '$1'" ++ if ! IsInArray $layout "${supported_layouts[@]}"; then ++ LogPrint "Layout '$layout' of LV '$lvname' in VG '$vgrp' not supported by vgcfgrestore" ++ return 1 ++ fi ++ done < <(grep "^lvmvol $1 " "$LAYOUT_FILE") ++} ++ + # vim: set et ts=4 sw=4: diff --git a/rear.spec b/rear.spec index f7c6367..2bc3540 100644 --- a/rear.spec +++ b/rear.spec @@ -24,6 +24,7 @@ Patch33: rear-bz1930662.patch Patch34: rear-tmpdir.patch Patch35: rear-bz1983013.patch Patch36: rear-bz1993296.patch +Patch37: rear-bz1747468.patch # rear contains only bash scripts plus documentation so that on first glance it could be "BuildArch: noarch" # but actually it is not "noarch" because it only works on those architectures that are explicitly supported.