From 90984c5d00f0b9bebf90cacce072964769eecbb1 Mon Sep 17 00:00:00 2001 From: Vojtech Trefny Date: Mon, 4 Aug 2025 13:13:55 +0200 Subject: [PATCH] Add a pre-wipe fixup function for LVM logical volumes Resolves: RHEL-68368 --- ...ixup-function-for-LVM-logical-volume.patch | 65 +++++++++++++++++++ python-blivet.spec | 7 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch diff --git a/0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch b/0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch new file mode 100644 index 0000000..613c6aa --- /dev/null +++ b/0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch @@ -0,0 +1,65 @@ +From f70ee1ef08c20485f49b30fe1072a7ccafaaa2fe Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Fri, 1 Aug 2025 15:03:09 +0200 +Subject: [PATCH] Add a pre-wipe fixup function for LVM logical volumes + +LVs scheduled to be removed are always activated to remove the +format during installation. If there is a read-only LV with the +skip activation flag with MD metadata this means after activating +the LV to remove the format the MD array is auto-assembled by udev +preventing us from removing it. For this special case, we simply +stop the array before removing the format. + +Resolves: RHEL-68368 +--- + blivet/deviceaction.py | 3 +++ + blivet/devices/lvm.py | 19 +++++++++++++++++++ + 2 files changed, 22 insertions(+) + +diff --git a/blivet/deviceaction.py b/blivet/deviceaction.py +index a6fc211e..169c3a10 100644 +--- a/blivet/deviceaction.py ++++ b/blivet/deviceaction.py +@@ -760,6 +760,9 @@ class ActionDestroyFormat(DeviceAction): + if hasattr(self.device, 'set_rw'): + self.device.set_rw() + ++ if hasattr(self.device, 'pre_format_destroy'): ++ self.device.pre_format_destroy() ++ + self.format.destroy() + udev.settle() + if isinstance(self.device, PartitionDevice) and self.device.disklabel_supported: +diff --git a/blivet/devices/lvm.py b/blivet/devices/lvm.py +index a03d57f9..6ea35212 100644 +--- a/blivet/devices/lvm.py ++++ b/blivet/devices/lvm.py +@@ -2695,6 +2695,25 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin + else: + blockdev.lvm.lvactivate(self.vg.name, self._name, ignore_skip=ignore_skip_activation) + ++ def pre_format_destroy(self): ++ """ Fixup needed to run before wiping this device """ ++ if self.ignore_skip_activation > 0: ++ # the LV was not activated during the initial scan so if there is an MD array on it ++ # it will now also get activated and we need to stop it to be able to remove the LV ++ try: ++ info = blockdev.md.examine(self.path) ++ except blockdev.MDRaidError: ++ pass ++ else: ++ # give udev a bit time to activate the array so we can deactivate it again ++ time.sleep(5) ++ log.info("MD metadata found on LV with skip activation, stopping the array %s", ++ info.device) ++ try: ++ blockdev.md.deactivate(info.device) ++ except blockdev.MDRaidError as err: ++ log.info("failed to deactivate %s: %s", info.device, str(err)) ++ + @type_specific + def _pre_create(self): + LVMLogicalVolumeBase._pre_create(self) +-- +2.50.1 + diff --git a/python-blivet.spec b/python-blivet.spec index 2638d94..2af0814 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -23,7 +23,7 @@ Version: 3.6.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 27%{?prerelease}%{?dist} +Release: 28%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ %global realname blivet @@ -67,6 +67,7 @@ Patch33: 0034-Include-additional-information-in-PartitioningError.patch Patch34: 0035-LVMPV-format-size-fix.patch Patch35: 0036-Make-ActionDestroyFormat-optional.patch Patch36: 0037-Wipe-end-partition-before-creating-it-as-well-as-the-start.patch +Patch37: 0038-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -230,6 +231,10 @@ configuration. %endif %changelog +* Mon Aug 04 2025 Vojtech Trefny - 3.6.0-28 +- Add a pre-wipe fixup function for LVM logical volumes + Resolves: RHEL-68368 + * Fri May 30 2025 Vojtech Trefny - 3.6.0-27 - Wipe end partition before creating it as well as the start Resolves: RHEL-76917