#8 Add default `compress=zstd:1` mount option for Btrfs
Closed 3 years ago by salimma. Opened 3 years ago by salimma.
rpms/ salimma/python-blivet f34-btrfs  into  rawhide

@@ -0,0 +1,38 @@ 

+ 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

+ 

file modified
+5 -1
@@ -23,7 +23,7 @@ 

  

  #%%global prerelease .b2

  # prerelease, if defined, should be something like .a1, .b1, .b2.dev1, or .c2

- Release: 2%{?prerelease}%{?dist}

+ Release: 3%{?prerelease}%{?dist}

  Epoch: 1

  License: LGPLv2+

  %global realname blivet
@@ -34,6 +34,7 @@ 

  %if 0%{?rhel} >= 9

  Patch0: 0001-remove-btrfs-plugin.patch

  %endif

+ Patch1: blivet-btrfs-default-compression.patch

  

  # Versions of required components (done so we make sure the buildrequires

  # match the requires versions of things).
@@ -196,6 +197,9 @@ 

  %endif

  

  %changelog

+ * Mon Feb 15 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 1:3.3.2-3.b2%{?dist}

+ - Add default `compress=zstd:1` mount option for Btrfs (#1926892)

+ 

  * Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1:3.3.2-2

  - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

  

This implements an initial solution for https://fedoraproject.org/wiki/Changes/BtrfsTransparentCompression, while we work out a permanent solution with the Anaconda team.

Signed-off-by: Michel Alexandre Salim salimma@fedoraproject.org

Note: this needs to be applied to the f34 branch as well. I'm a provenpackager so I can do that, but I'd like this reviewed first to make sure this is OK.

Tested by:
- rebuilding python-blivet locally (updated RPMs in https://salimma.fedorapeople.org/specs/)
- downloading https://kojipkgs.fedoraproject.org/compose/branched/Fedora-34-20210215.n.0/compose/Spins/x86_64/iso/Fedora-KDE-Live-x86_64-34-20210215.n.0.iso from https://openqa.fedoraproject.org/nightlies.html
- setting up a new VM in virt-manager
- booting the live ISO, and installing the updated python3-blivet and blivet-data RPMs
- start liveinst
- mount | grep btrfs to verify compress=zstd:1 shows up
- reboot into the installed OS, install compsize, verify / is compressed (57% actual space used), verify /etc/fstab contains compress=zstd:1

I tested the above updated RPMs on Fedora-Workstation-Live-x86_64-34-20210213.n.0.iso and it also works, both Auto and Custom.

rebased onto 21563b9

3 years ago

Thanks, this looks good in general. As I mentioned on your upstream PR, blivet is not used only in Anaconda so this needs to be installer specific change, this can be simply done by adding a special flag to flags.py and enable it in Anaconda. I discussed this with Anaconda team and they also agree. Also please open this PR against upstream, I'm not a fan of dowstream patches and the anaconda-specific flag will make the change "safe" for upstream. Thanks.

I forgot to close this, now that blivet has a proper implementation upstream (and already built for Fedora).

Pull-Request has been closed by salimma

3 years ago