netgod / rpms / anaconda

Forked from rpms/anaconda 2 years ago
Clone
Blob Blame History Raw
From c45667cb27c72293ebb16ae11350af2715d6a93b Mon Sep 17 00:00:00 2001
From: Michel Alexandre Salim <michel@michel-slm.name>
Date: Tue, 16 Feb 2021 18:39:29 -0800
Subject: [PATCH 20005/20007] [Storage] add btrfs_compression option

This is a new option to allow specifying the compression algorithm and
level for Btrfs filesystems. If set, it will be passed to Blivet and
applied when mounting Btrfs filesystems.

Default this to None, but set it to "zstd:1" for CentOS Stream Hyperscale.

(cherry picked from commit 15e06b6aa9876d55dedaa9c37f2f589361de8949)
---
 anaconda.spec.in                             |  3 ++-
 data/anaconda.conf                           |  3 +++
 data/product.d/centos-stream-hyperscale.conf |  1 +
 pyanaconda/core/configuration/storage.py     | 11 +++++++++++
 pyanaconda/modules/storage/initialization.py |  1 +
 5 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/anaconda.spec.in b/anaconda.spec.in
index b5c3b7824..0f0f904a5 100644
--- a/anaconda.spec.in
+++ b/anaconda.spec.in
@@ -35,6 +35,7 @@ Source0: %{name}-%{version}.tar.bz2
 %define nmver 1.0
 %define pykickstartver 3.16.11-1
 %define pypartedver 2.5-2
+%define pythonblivetver 1:3.2.2-11
 %define rpmver 4.10.0
 %define simplelinever 1.1-1
 %define utillinuxver 2.15.1
@@ -81,7 +82,7 @@ The anaconda package is a metapackage for the Anaconda installer.
 Summary: Core of the Anaconda installer
 Requires: python3-libs
 Requires: python3-dnf >= %{dnfver}
-Requires: python3-blivet >= 1:3.2.2-1
+Requires: python3-blivet >= %{pythonblivetver}
 Requires: python3-blockdev >= %{libblockdevver}
 Requires: python3-meh >= %{mehver}
 Requires: libreport-anaconda >= 2.0.21-1
diff --git a/data/anaconda.conf b/data/anaconda.conf
index 1508a7a8a..c84881091 100644
--- a/data/anaconda.conf
+++ b/data/anaconda.conf
@@ -156,6 +156,9 @@ multipath_friendly_names = True
 # Do you want to allow imperfect devices (for example, degraded mdraid array devices)?
 allow_imperfect_devices = False
 
+# Btrfs compression algorithm and level. e.g. zstd:1
+btrfs_compression =
+
 # Default file system type. Use whatever Blivet uses by default.
 file_system_type =
 
diff --git a/data/product.d/centos-stream-hyperscale.conf b/data/product.d/centos-stream-hyperscale.conf
index 88979adb5..226359344 100644
--- a/data/product.d/centos-stream-hyperscale.conf
+++ b/data/product.d/centos-stream-hyperscale.conf
@@ -9,6 +9,7 @@ product_name = CentOS Stream
 
 [Storage]
 default_scheme = BTRFS
+btrfs_compression = zstd:1
 
 [Payload]
 # RHEL removes btrfs-progs, but we want it back
diff --git a/pyanaconda/core/configuration/storage.py b/pyanaconda/core/configuration/storage.py
index 29f554ed5..4dcbadbba 100644
--- a/pyanaconda/core/configuration/storage.py
+++ b/pyanaconda/core/configuration/storage.py
@@ -82,6 +82,17 @@ class StorageSection(Section):
         """
         return self._get_option("allow_imperfect_devices", bool)
 
+    @property
+    def btrfs_compression(self):
+        """BTRFS compression setting.
+
+        Specifies the compression algorithm and level used when
+        mounting Btrfs partitions. Defaults to None.
+
+        For example: "zstd:1"
+        """
+        return self._get_option("btrfs_compression", str) or None
+
     @property
     def file_system_type(self):
         """Default file system type.
diff --git a/pyanaconda/modules/storage/initialization.py b/pyanaconda/modules/storage/initialization.py
index cb2488a31..6b2838ead 100644
--- a/pyanaconda/modules/storage/initialization.py
+++ b/pyanaconda/modules/storage/initialization.py
@@ -52,6 +52,7 @@ def enable_installer_mode():
     blivet_flags.ibft = conf.storage.ibft
     blivet_flags.multipath_friendly_names = conf.storage.multipath_friendly_names
     blivet_flags.allow_imperfect_devices = conf.storage.allow_imperfect_devices
+    blivet_flags.btrfs_compression = conf.storage.btrfs_compression
 
     # Platform class setup depends on flags, re-initialize it.
     platform.update_from_flags()
-- 
2.31.1