From ad654463dbce73563b0be9627aecb852c8a0dcb5 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Mon, 31 Mar 2025 09:49:36 +0000 Subject: [PATCH] import CS python-blivet-3.6.0-23.el9_6 --- ...w-discards-flag-for-new-LUKS-devices.patch | 39 +++++++++++++++++++ SPECS/python-blivet.spec | 7 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch diff --git a/SOURCES/0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch b/SOURCES/0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch new file mode 100644 index 0000000..a0b1530 --- /dev/null +++ b/SOURCES/0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch @@ -0,0 +1,39 @@ +From dd0ac302f2afcbbf4fd455416850a97a11d2d1b5 Mon Sep 17 00:00:00 2001 +From: Vojtech Trefny +Date: Mon, 10 Mar 2025 09:52:27 +0100 +Subject: [PATCH] Set persitent allow-discards flag for newly created LUKS + devices + +We are currently using the "allow-discards" in /etc/crypttab to +set the discards/fstrim feature for LUKS, but that doesn't work +for Fedora Silverblue so we need to set the persistent flag in the +LUKS header instead. + +Resolves: RHEL-82430 +--- + blivet/formats/luks.py | 11 +++++++++++ + 1 file changed, 11 insertions(+) + +diff --git a/blivet/formats/luks.py b/blivet/formats/luks.py +index adf3c7112..4fc6b1342 100644 +--- a/blivet/formats/luks.py ++++ b/blivet/formats/luks.py +@@ -336,7 +336,18 @@ def _create(self, **kwargs): + + def _post_create(self, **kwargs): + super(LUKS, self)._post_create(**kwargs) ++ ++ if self.luks_version == "luks2" and flags.discard_new: ++ try: ++ blockdev.crypto.luks_set_persistent_flags(self.device, ++ blockdev.CryptoLUKSPersistentFlags.ALLOW_DISCARDS) ++ except blockdev.CryptoError as e: ++ raise LUKSError("Failed to set allow discards flag for newly created LUKS format: %s" % str(e)) ++ except AttributeError: ++ log.warning("Cannot set allow discards flag: not supported") ++ + self.uuid = blockdev.crypto.luks_uuid(self.device) ++ + if not self.map_name: + self.map_name = "luks-%s" % self.uuid + diff --git a/SPECS/python-blivet.spec b/SPECS/python-blivet.spec index 7e86c4c..77407f9 100644 --- a/SPECS/python-blivet.spec +++ b/SPECS/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: 22%{?prerelease}%{?dist} +Release: 23%{?prerelease}%{?dist} Epoch: 1 License: LGPLv2+ %global realname blivet @@ -61,6 +61,7 @@ Patch27: 0028-Fix-checking-for-NVMe-plugin-availability.patch Patch28: 0029-Align-sizes-up-for-growable-LVs.patch Patch29: 0030-mod_pass_in_stratis_test.patch Patch30: 0031-Fix_running_tests_in_FIPS_mode.patch +Patch31: 0032-Set-persistent-allow-discards-flag-for-new-LUKS-devices.patch # Versions of required components (done so we make sure the buildrequires # match the requires versions of things). @@ -224,6 +225,10 @@ configuration. %endif %changelog +* Tue Mar 11 2025 Vojtech Trefny - 3.6.0-23 +- Set persistent allow-discards flag for newly created LUKS devices + Resolves: RHEL-82430 + * Tue Nov 12 2024 Vojtech Trefny - 3.6.0-22 - Fix running tests in FIPS mode Resolves: RHEL-8029