]> git.hungrycats.org Git - bees/commit
tempfile: make sure FS_COMPR_FL stays set
authorZygo Blaxell <bees@furryterror.org>
Tue, 25 Feb 2025 08:16:27 +0000 (03:16 -0500)
committerZygo Blaxell <bees@furryterror.org>
Mon, 30 Jun 2025 03:25:36 +0000 (23:25 -0400)
commit3a17a4dcdd8550a6e54f4c6e16272c7ce0f9eb14
treeeee3e012945865d82df419c7ef4e78de9680a6dc
parent4039ef229e5fcbfa34dfee2fd601073e5005a5b7
tempfile: make sure FS_COMPR_FL stays set

btrfs will set the FS_NOCOMP_FL flag when all of the following are true:

1.  The filesystem is not mounted with the `compress-force` option
2.  Heuristic analysis of the data suggests the data is compressible
3.  Compression fails to produce a result that is smaller than the original

If the compression ratio is 40%, and the original data is 128K long,
then compressed data will be about 52K long (rounded up to 4K), so item
3 is usually false; however, if the original data is 8K long, then the
compressed data will be 8K long too, and btrfs will set FS_NOCOMP_FL.

To work around that, keep setting FS_COMPR_FL and clearing FS_NOCOMP_FL
every time a TempFile is reset.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees.cc