Bug 1224808

Summary: incorrect btrfs compression level for /
Product: [openSUSE] openSUSE Tumbleweed Reporter: Frederic Crozat <fcrozat>
Component: BootloaderAssignee: openSUSE Kernel Bugs <kernel-bugs>
Status: NEW --- QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: antonio.feijoo, dfaggioli, dsterba, fdmanana, tiwai, wqu
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Frederic Crozat 2024-05-21 13:39:26 UTC
On a MicroOS Desktop system, I'm trying to enable btrfs compression on root fs.

The change is made at /etc/fstab level.

The initial fstab relevant line was:

UUID=no_interest_here / btrfs ro 0 0

Changed to:

UUID=no_interest_here / btrfs ro,compress=zstd:1 0 0

and then running transaction-update initrd to ensure dracut is run in the transactional system.

However, the stored kernel cmdline by dracut becomes:
dracut[I]:  root=UUID=980c03f5-35f5-405d-8686-d51ec67c17b4 rootfstype=btrfs rootflags=rw,relatime,seclabel,compress=,ssd,discard=async,space_cache=v2,subvolid=774,subvol=/@/.snapshots/619/snapshot,subvol=@/.snapshots/619/snapshot

compress parameter is being stripped.

This is with dracut-059+suse.588.g528264be-1.1.x86_64
Comment 1 Antonio Feijoo 2024-05-22 07:38:33 UTC
By default, dracut gets this info from /proc/self/mountinfo. To use /etc/fstab as the primary source, you must use the `--fstab` command line option or the `use_fstab=yes` configuration option.
Comment 2 Frederic Crozat 2024-05-22 09:16:58 UTC
(In reply to Antonio Feijoo from comment #1)
> By default, dracut gets this info from /proc/self/mountinfo. To use
> /etc/fstab as the primary source, you must use the `--fstab` command line
> option or the `use_fstab=yes` configuration option.

When I did the change initially, I changed fstab, regenerated initrd and  rebooted (so it is used) but system end-up with compress= and not compress=zstd:1 

Regenerating initrd on the rebooted system still give the same thing.
Comment 3 Antonio Feijoo 2024-05-22 09:26:19 UTC
(In reply to Frederic Crozat from comment #2)
> (In reply to Antonio Feijoo from comment #1)
> > By default, dracut gets this info from /proc/self/mountinfo. To use
> > /etc/fstab as the primary source, you must use the `--fstab` command line
> > option or the `use_fstab=yes` configuration option.
> 
> When I did the change initially, I changed fstab, regenerated initrd and 
> rebooted (so it is used) but system end-up with compress= and not
> compress=zstd:1 
> 
> Regenerating initrd on the rebooted system still give the same thing.

That's strange, I tested it before and it works for me:

> May 22 07:44:43 localhost dracut-cmdline[218]: Using kernel command line parameters: ... rootfstype=btrfs rootflags=ro,compress=zstd:1 ...

Do your have `use_fstab=yes` in any conf file under /etc/dracut.conf.d/? Otherwise it will not work.
Comment 4 Frederic Crozat 2024-05-22 09:57:55 UTC
(In reply to Antonio Feijoo from comment #3)
> (In reply to Frederic Crozat from comment #2)
> > (In reply to Antonio Feijoo from comment #1)
> > > By default, dracut gets this info from /proc/self/mountinfo. To use
> > > /etc/fstab as the primary source, you must use the `--fstab` command line
> > > option or the `use_fstab=yes` configuration option.
> > 
> > When I did the change initially, I changed fstab, regenerated initrd and 
> > rebooted (so it is used) but system end-up with compress= and not
> > compress=zstd:1 
> > 
> > Regenerating initrd on the rebooted system still give the same thing.
> 
> That's strange, I tested it before and it works for me:
> 
> > May 22 07:44:43 localhost dracut-cmdline[218]: Using kernel command line parameters: ... rootfstype=btrfs rootflags=ro,compress=zstd:1 ...
> 
> Do your have `use_fstab=yes` in any conf file under /etc/dracut.conf.d/?
> Otherwise it will not work.

I just tested by adding it. It is now properly part of dracut stored kernel cmdline but when the system is booted, it ends-up with compress= and not compress=zstd:1 when checking /proc/self/mountinfo
Comment 5 Antonio Feijoo 2024-05-22 10:08:26 UTC
(In reply to Frederic Crozat from comment #4)
> I just tested by adding it. It is now properly part of dracut stored kernel
> cmdline but when the system is booted, it ends-up with compress= and not
> compress=zstd:1 when checking /proc/self/mountinfo

At least in my case it's ok:

> localhost:~ # grep -r -m1 compress= /proc/self/mountinfo 
> 62 1 0:34 /@/.snapshots/7/snapshot / ro,relatime shared:1 - btrfs /dev/mapper/luks rw,seclabel,compress=zstd:1,space_cache=v2,subvolid=276,subvol=/@/.snapshots/7/snapshot

But, I'm testing this with SL Micro, I'll download the latest MicroOS snapshot later and check if I can reproduce it.
Comment 6 Antonio Feijoo 2024-05-22 11:22:19 UTC
(In reply to Antonio Feijoo from comment #5)
> But, I'm testing this with SL Micro, I'll download the latest MicroOS
> snapshot later and check if I can reproduce it.

Ok, my bad, I should've tested this with MicroOS since the beginning, I can reproduce it with snapshot 20240520.

> localhost:~ # grep -m1 compress= /proc/self/mountinfo 
> 64 1 0:36 /@/.snapshots/2/snapshot / ro,relatime shared:1 - btrfs /dev/vda3 rw,seclabel,compress=,discard=async,space_cache=v2,subvolid=268,subvol=/@/.snapshots/2/snapshot

There was not any change in dracut that could affect this between the version shipped with SL Micro and the latest Factory version, and the arguments in dracut look ok:

> May 22 13:05:43 localhost dracut-cmdline[233]: dracut-059+suse.588.g528264be-1.1
> May 22 13:05:43 localhost dracut-cmdline[233]: Using kernel command line parameters:  ... rootfstype=btrfs rootflags=ro,compress=zstd:1 ...

Also, `findmnt` reports the right options on the running system:

> localhost:~ # findmnt --fstab -e -v -n -o 'OPTIONS' --target /
ro,compress=zstd:1

But, /proc/self/mountinfo trims the value of compress=... So, I guess this should be an issue with kernel 6.9.1-1-default (it works with 6.4.0-17-default).
Comment 7 Antonio Feijoo 2024-05-22 11:52:54 UTC
Observed:

> [    1.415049] localhost kernel: BTRFS: device label ROOT devid 1 transid 65 /dev/vda3 (254:3) scanned by mount (450)
> [    1.415283] localhost kernel: BTRFS info (device vda3): first mount of filesystem 0ccd61f9-7e1a-4329-9b48-04673b6ba623
> [    1.415292] localhost kernel: BTRFS info (device vda3): using crc32c (crc32c-intel) checksum algorithm
> [    1.415295] localhost kernel: BTRFS info (device vda3): using free-space-tree
> [    1.757878] localhost systemd[1]: Switching root.
> [    2.935997] localhost kernel: BTRFS info (device vda3 state M): use zstd compression, level 1
> ...
> [    3.179772] localhost systemd[1]: Mounting /.snapshots...
> [    3.180726] localhost kernel: BTRFS info (device vda3 state M): use  compression, level 0
Comment 8 Frederic Crozat 2024-05-22 12:02:53 UTC
It was also broken with kernel 6.8.9 on MicroOS
Comment 9 Dario Faggioli 2024-06-26 10:14:26 UTC
Wow, I just noticed that I'm affected as well... :-(