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: Sun, 09 Aug 2026 05:50:02 +0200 [thread overview]
Message-ID: <DKK3UWEQ1P6G.JHCWEPD1M09Q@gmail.com> (raw)
In-Reply-To: <870d7e1f-3e87-4eac-86fe-107af7336101@suse.com>
[-- Attachment #1: Type: text/plain, Size: 2745 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.
Ah yes of course, although, would it be better to have a single patch
that looks like this[2], which would also need to add
prop_compress_level's initialization to 0 as per [1] (that would
probably be good anyway) or simply a:
compress_type = inode->prop_compress;
+compress_level = 0; //level in xattr isn't supported yet
in the 2 relevant places?
Thanks.
Best,
koraynilay
P.S. I also noticed that defrag_compress_level too doesn't get
initialized to 0, so if we choose that approach a separate patch that
adds it would be in order IMO.
[1]:
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e057aceaa68d..aec977f47cfb 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7896,7 +7896,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
BTRFS_BLOCK_RSV_DELALLOC);
ei->runtime_flags = 0;
ei->prop_compress = BTRFS_COMPRESS_NONE;
+ ei->prop_compress_level = 0;
ei->defrag_compress = BTRFS_COMPRESS_NONE;
ei->delayed_node = NULL;
[2]:
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 1082fa92c145..0a4e567d0109 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -130,6 +130,7 @@ struct btrfs_inode {
/* Cached value of inode property 'compression'. */
u8 prop_compress;
+ s8 prop_compress_level;
/*
* Force compression on the file using the defrag ioctl, could be
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 2534cd9284d5..cff4b3e97559 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 = inode->prop_compress_level;
}
/* 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 = inode->prop_compress_level;
}
cb = btrfs_compress_bio(inode, 0, blocksize, compress_type, compress_level, 0);
if (IS_ERR(cb)) {
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2026-08-09 3:50 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 [this message]
2026-08-09 4:05 ` Qu Wenruo
2026-08-11 2:55 ` koraynilay
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=DKK3UWEQ1P6G.JHCWEPD1M09Q@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