Btrfs compression integration
Summary: Btrfs supports per directory and per file compression. Consider using it.
Thoughts and questions:
-
Support full file system compression? (controlled by mount option) Or selective per dir/file? (controlled by XATTR) The performance of zstd:1 is good enough it might just make sense to always do it everywhere. But for performance considerations it might be reasonable to make it selective.
-
The XATTR can be set per directory or per file. It also appears as lsattr/chattr +c attribute. (Not to be confused with +C which is nodatacow attribute, and implies no compression.) On a directory, this attribute is inherited when new files are created or copied in that directory.
-
If the XATTR is set after the fact, it only compresses newly added data, it won't cause the whole file to become compressed.
-
Btrfs defragmentation can be directed at either a file or directory, and optionally compress them. This immediately compresses the file but doesn't itself add an XATTR.
-
A combination of (3) (4) might be indicated for per file compression. What are the user's expectations? From a strict write amplification reduction point of view, we'd only set the XATTR. But the user probably expects something to happen (soon) with the file. Or is per directory granularity sufficient?
-
API for collecting statistics? Might require enhancement to libbtrfsutils.