From: "koraynilay" <koray.fra@gmail.com>
To: "Qu Wenruo" <wqu@suse.com>, "koraynilay" <koray.fra@gmail.com>,
"Chris Mason" <clm@fb.com>, "David Sterba" <dsterba@suse.com>
Cc: "Zygo Blaxell" <ce3g8jdj@umail.furryterror.org>,
<linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 3/4] btrfs: add per-inode compression levels in xattrs
Date: Tue, 11 Aug 2026 04:55:33 +0200 [thread overview]
Message-ID: <DKLRY9Q5SEI3.VUDASVYPW9MY@gmail.com> (raw)
In-Reply-To: <870d7e1f-3e87-4eac-86fe-107af7336101@suse.com>
[-- Attachment #1: Type: text/plain, Size: 2942 bytes --]
> I'd prefer to have a dedicated patch to set compress_level to the
> default value 0, as a proper bug fix as the first patch of the series.
>
> As you mentioned in the cover-letter, this is in fact fixing a bug in
> the old behavior (mismatched algo and level).
>
> So it's definitely worth a dedicated fix, so that we can backport the
> fix without pulling in the full series for older kernels.
Ok so, after thinking about it more and bouncing ideas around (with Zygo
too) I realized one thing, that while it *is* technically a bug, I don't
think it's a bug worth backporting.
My reasoning is simply that there is no use-case where the current
"buggy" behaviour would be damaging, as the levels get clamped to the
supported range anyway, while arguably there are (albeit very rare and
probably not very smart in the first place) use-cases where fixing it
could be somewhat (limitedly) damaging.
More importantly IMO, doing this would allow us to explicitly explain
the currently undocumented behaviour in the btrfs-property(8) manpage as
"just so you know, for kernel versions < 7.x cross-algo level leakage
from -o compress was happening".
As for how to handle it after having support for levels in the XATTR,
option 2, aka leaking the compress level only if the algo matches, would
be the best imo:
Example use-case:
- /fs has various types of files, from media to git repos, that would
benefit from the normal compress mount option;
- /fs also has big virtual machine disks, that have very compressible
parts but also very uncompressible parts;
using only `mount -o compress=zstd:7 /fs` may mark the vm disks with
NOCOMPRESS as soon as an incompressible extent gets found, but setting
btrfs.compression=zstd won't, as it will try to compress every extent
anyway[1].
This way if the user intends to change the compress level for the whole
fs, they can just change the mount option, knowing that the new level
will apply to the (new) vm extents too, like it will for all other files.
In this example "btrfs.compression=zstd" and "btrfs.compression=zstd:0"
would behave the same, which means the file's extent will get compressed
with zstd:7, but when the user remounts with e.g. zstd:15, they will use
this new level (only for the extents written from that point afterwards,
of course).
(I'm ignoring the case where the user wants to change the algorithm and
let the vms inherit it, as for this specific use-case that would likely
require a whole new feature/property to say "try to compress anyway but
not as much as compress-force" and probably most people use zstd anyway
nowadays).
After coming to this conclusion, I'm personally pretty satisfied with
this solution, while I wasn't as much with the other ones.
Thanks again.
Best,
koraynilay
[1]: https://github.com/kdave/btrfs-progs/pull/1152/commits/7ae9e2aa7a35af5e7b656424957a558a9d0dd676
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-08-11 2:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 1:50 [PATCH v2 0/4] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-09 1:50 ` [PATCH v2 1/4] btrfs: export btrfs_match_compress_type(), move it to compression.h koraynilay
2026-08-09 1:50 ` [PATCH v2 2/4] btrfs: also validate compression levels in btrfs_compress_is_valid_type() koraynilay
2026-08-09 2:53 ` Qu Wenruo
2026-08-09 3:35 ` koraynilay
2026-08-09 4:07 ` Qu Wenruo
2026-08-09 1:50 ` [PATCH v2 3/4] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-09 2:55 ` Qu Wenruo
2026-08-09 3:50 ` koraynilay
2026-08-09 4:05 ` Qu Wenruo
2026-08-11 2:55 ` koraynilay [this message]
2026-08-11 3:21 ` Qu Wenruo
2026-08-11 3:40 ` koraynilay
2026-08-11 12:47 ` koraynilay
2026-08-09 1:50 ` [PATCH v2 4/4] btrfs: support inheritance for per-inode compression levels koraynilay
2026-08-09 3:03 ` Qu Wenruo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DKLRY9Q5SEI3.VUDASVYPW9MY@gmail.com \
--to=koray.fra@gmail.com \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox