neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/1001-apply-compression-settings-from-blivet.flags.btrfs_c.patch

564f36
From 724855ff0c30eacab3448f66c6076151ed565e89 Mon Sep 17 00:00:00 2001
564f36
From: Michel Alexandre Salim <michel@michel-slm.name>
564f36
Date: Mon, 15 Feb 2021 20:55:18 -0800
564f36
Subject: [PATCH] apply compression settings from
564f36
 blivet.flags.btrfs_compression (#1926892)
564f36
564f36
If `blivet.flags.btrfs_compression` is set, and unless `compress=` is
564f36
already explicitly set, apply it to mount options.
564f36
564f36
Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
564f36
---
564f36
 blivet/devices/btrfs.py | 7 +++++++
564f36
 blivet/flags.py         | 4 ++++
564f36
 2 files changed, 11 insertions(+)
564f36
564f36
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
564f36
index edb82478..da652af8 100644
564f36
--- a/blivet/devices/btrfs.py
564f36
+++ b/blivet/devices/btrfs.py
564f36
@@ -494,11 +494,18 @@ class BTRFSSubVolumeDevice(BTRFSDevice):
564f36
 
564f36
         # propagate mount options specified for members via kickstart
564f36
         opts = "subvol=%s" % self.name
564f36
+        has_compress = False
564f36
         if self.volume.format.mountopts:
564f36
             for opt in self.volume.format.mountopts.split(","):
564f36
                 # do not add members subvol spec
564f36
                 if not opt.startswith("subvol"):
564f36
                     opts += ",%s" % opt
564f36
+                if opt.startswith("compress"):
564f36
+                    has_compress = True
564f36
+
564f36
+        # add default compression settings
564f36
+        if flags.btrfs_compression and not has_compress:
564f36
+            opts += ",compress=%s" % flags.btrfs_compression
564f36
 
564f36
         self.format.mountopts = opts
564f36
 
564f36
diff --git a/blivet/flags.py b/blivet/flags.py
564f36
index 6500be30..0140a4a5 100644
564f36
--- a/blivet/flags.py
564f36
+++ b/blivet/flags.py
564f36
@@ -81,6 +81,10 @@ class Flags(object):
564f36
 
564f36
         self.update_from_boot_cmdline()
564f36
         self.allow_imperfect_devices = True
564f36
+
564f36
+        # compression option for btrfs filesystems
564f36
+        self.btrfs_compression = None
564f36
+
564f36
         self.debug_threads = False
564f36
 
564f36
     def get_boot_cmdline(self):
564f36
-- 
564f36
2.31.1
564f36