From: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
To: koraynilay <koray.fra@gmail.com>
Cc: Chris Mason <clm@fb.com>, David Sterba <dsterba@suse.com>,
Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 1/5] btrfs: fix -o compress= level getting inherited by compression xattr property
Date: Sun, 9 Aug 2026 16:15:43 -0400 [thread overview]
Message-ID: <anjf71ZUXUC4dd1W@hungrycats.org> (raw)
In-Reply-To: <20260809185303.600071-2-koray.fra@gmail.com>
On Sun, Aug 09, 2026 at 08:52:59PM +0200, koraynilay wrote:
> When setting the btrfs.compression xattr, btrfs uses the mount option level
> (since levels in the xattr aren't supported yet) to compress the data, even
> if the compression algorithm between the property and the compress= option
> are different (!!).
> For example, when mounting with compress=zstd:15 and setting
> btrfs.compression=zlib, the data would get compressed at zlib:9, because
> btrfs would take "zlib" from the xattr but "15" from the mount option,
> which would then get correctly clamped at 9.
>
> To fix, just hard-code the compress level at 0, forcing the property's
> algorithm default.
>
> Reported-by: Zygo Blaxell <ce3g8jdj@umail.furryterror.org>
> Signed-off-by: koraynilay <koray.fra@gmail.com>
> ---
> fs/btrfs/inode.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 2534cd9284d5..6d7f2aa2555c 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -938,6 +938,7 @@ static void compress_file_range(struct btrfs_work *work)
> compress_level = inode->defrag_compress_level;
> } else if (inode->prop_compress) {
> compress_type = inode->prop_compress;
> + compress_level = 0;
This set to zero should be conditional on inode->prop_compress !=
fs_info->compress_type; otherwise, it prevents the compress-level mount
option from working in the common case where 'btrfs.compression=zstd'
or 'chattr +c' has been set.
> }
>
> /* Compression level is applied here. */
> @@ -2326,6 +2327,7 @@ static int run_delalloc_inline(struct btrfs_inode *inode, struct folio *locked_f
> compress_level = inode->defrag_compress_level;
> } else if (inode->prop_compress) {
> compress_type = inode->prop_compress;
> + compress_level = 0;
> }
> cb = btrfs_compress_bio(inode, 0, blocksize, compress_type, compress_level, 0);
> if (IS_ERR(cb)) {
> --
> 2.55.0
>
>
next prev parent reply other threads:[~2026-08-09 20:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 18:52 [PATCH v3 0/5] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-09 18:52 ` [PATCH v3 1/5] btrfs: fix -o compress= level getting inherited by compression xattr property koraynilay
2026-08-09 20:15 ` Zygo Blaxell [this message]
2026-08-09 22:16 ` Qu Wenruo
2026-08-09 18:53 ` [PATCH v3 2/5] btrfs: export btrfs_match_compress_type(), move it to compression.h koraynilay
2026-08-09 18:53 ` [PATCH v3 3/5] btrfs: also validate compression levels in btrfs_compress_is_valid_type() koraynilay
2026-08-09 18:53 ` [PATCH v3 4/5] btrfs: add per-inode compression levels in xattrs koraynilay
2026-08-09 18:53 ` [PATCH v3 5/5] btrfs: support inheritance for per-inode compression levels koraynilay
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=anjf71ZUXUC4dd1W@hungrycats.org \
--to=ce3g8jdj@umail.furryterror.org \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=koray.fra@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.