diff --git a/0023-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch b/0023-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch new file mode 100644 index 0000000..8452076 --- /dev/null +++ b/0023-Add-a-pre-wipe-fixup-function-for-LVM-logical-volume.patch @@ -0,0 +1,65 @@ +From 598902388a09e2dd60b0b0f1e556c4661899be68 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-93966 +--- + 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 2e6a8489..6590898f 100644 +--- a/blivet/deviceaction.py ++++ b/blivet/deviceaction.py +@@ -766,6 +766,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 d0b0b2b9..10ed2c94 100644 +--- a/blivet/devices/lvm.py ++++ b/blivet/devices/lvm.py +@@ -2791,6 +2791,25 @@ class LVMLogicalVolumeDevice(LVMLogicalVolumeBase, LVMInternalLogicalVolumeMixin + except blockdev.LVMError as err: + raise errors.LVMError(err) + ++ 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 5ae08a5..82a52af 100644 --- a/python-blivet.spec +++ b/python-blivet.spec @@ -5,7 +5,7 @@ Version: 3.10.0 #%%global prerelease .b2 # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2 -Release: 22%{?prerelease}%{?dist} +Release: 23%{?prerelease}%{?dist} Epoch: 1 License: LGPL-2.1-or-later %global realname blivet @@ -37,6 +37,7 @@ Patch17: 0019-Make-ActionDestroyFormat-optional.patch Patch18: 0020-Wipe-end-partition-before-creating-it-as-well-as-the-start.patch Patch19: 0021-Tell-LVM-DBus-to-refresh-its-internal-status-during-reset.patch Patch20: 0022-Change-expected-Stratis-metadata-size.patch +Patch21: 0023-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). @@ -131,6 +132,10 @@ make DESTDIR=%{buildroot} install %{python3_sitelib}/* %changelog +* Mon Aug 04 2025 Vojtech Trefny - 3.10.0-23 +- Add a pre-wipe fixup function for LVM logical volumes + Resolves: RHEL-93966 + * Tue Jul 8 2025 Vojtech Trefny - 3.10.0-22 - tests: Change expected Stratis metadata size for stratisd 3.7.0 Resolves: RHEL-102299