From 312a593945b77890c119e1a0bf1352ffe63bc99e 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] [btrfs] add default compression settings
Unless `compress=` is explicitly set, default to `compress=zstd:1`
Signed-off-by: Michel Alexandre Salim <michel@michel-slm.name>
---
blivet/devices/btrfs.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blivet/devices/btrfs.py b/blivet/devices/btrfs.py
index edb82478..eb6899ba 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 not has_compress:
+ opts += ",compress=zstd:1"
self.format.mountopts = opts
--
2.29.2