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