koverstreet / bcachefs

Other
643 stars 71 forks source link

Background compressing doesnt work if foreground compression and background compression algorithms are same #621

Closed inklesspen1rus closed 6 months ago

inklesspen1rus commented 7 months ago

Hello. Thank you for such great filesystem! I really like background compressing and device tiering. But I have a problem with background compressing. If foreground and background compressing have same algorithms but different compression level, background compressing does not work.

Steps to reproduce:

$ fallocate -l2g test1 # device with background compression
$ fallocate -l2g test2 # device with only foreground compression
$ bcachefs format test1 --compression zstd:1 --background_compression zstd:15 --foreground_target test1 --background_target test1
$ bcachefs format test2 --compression zstd:1
$ mkdir mtest{1,2}
$ mount test1 mtest1
$ mount test2 mtest2
$ cp 1gb.file mtest1/.
$ cp 1gb.file mtest2/.
$ bcachefs fs usage -h mtest1
                                data         buckets    fragmented
...
  user:                      551 MiB            2203       224 KiB
...
$ bcachefs fs usage -h mtest2
                                data         buckets    fragmented
...
  user:                      551 MiB            2203       224 KiB
...
$ # both fs have nearly same user data size

But if set foreground compression to none, background compression works as excepted

Environment

$ cat /sys/module/bcachefs/parameters/version 
1027
$ uname -a
Linux inklessloop 6.7.0-4-MANJARO #1 SMP PREEMPT_DYNAMIC Wed Dec 13 01:26:09 UTC 2023 x86_64 GNU/Linux
$ pacman -Ss linux67
core/linux67 6.7.0rc5-4 [installed]

Probably related to #557

farahnur42 commented 6 months ago

Hi, https://github.com/koverstreet/bcachefs/commit/e14d7c7195b974bbaf400f9c3f2bdaa94fc8d372 's commit message (linked in https://github.com/koverstreet/bcachefs/issues/557#issuecomment-1633829295) states the following:

Note that for compatibility, extents themselves only include the compression type, not the compression level. This means that specifying the same compression algorithm but different compression levels for the compression and background_compression options will have no effect.

So I would presume that this is intended behaviour, currently at least.

inklesspen1rus commented 6 months ago

Omg thank you for explanation. I think this issue can be closed.