From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: Daniel Vacek <neelx@suse.com>, Qu Wenruo <quwenruo.btrfs@gmx.com>,
Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs/defrag: implement compression levels
Date: Wed, 5 Mar 2025 09:01:50 +0100 [thread overview]
Message-ID: <20250305080150.GB5777@suse.cz> (raw)
In-Reply-To: <29ec66bd-27a0-443e-b19b-fb759a847dcb@suse.com>
On Wed, Mar 05, 2025 at 06:14:16PM +1030, Qu Wenruo wrote:
> [...]
> >>> /* spare for later */
> >>> __u32 unused[4];
> >>
> >> We have enough space left here, although u32 is overkilled for
> >> compress_type, using the unused space for a new s8/s16/s32 member should
> >> be fine.
> >
> > That is what I did originally, but discussing with Dave he suggested
> > this solution.
>
> Normally I would be fine with the union, to save some memory.
>
> Maybe I'm a little paranoid, but the defrag ioctl flag check is only
> introduced last year by commit 173431b274a9 ("btrfs: defrag: reject
> unknown flags of btrfs_ioctl_defrag_range_args").
The commit has been backported to stable trees 4.19.307 5.10.210 5.15.149
5.4.269 6.1.76 6.6.15 6.7.3 , so we could assume the flags are
validated.
> So it's possible that some older kernels don't have that commit, and may
> incorrectly continue by ignoring the flag.
> Thankfully that should fail with -EINVAL (type always in the higher
> bits, thus always tricking the NR_COMPRESS_TYPES check.
>
> If that layout (type in higher bits, level in lower bits) is
> intentionally, I'd say it's very clever.
>
> Anyway either solution looks fine to me now.
The layout also depends on endianness, but should not matter as long as
the flgags are validated. If not, either the level is ignored or it
fails due to the >= NR_COMPRESS_TYPES check. Both should be acceptable
as fallback.
next prev parent reply other threads:[~2025-03-05 8:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-04 17:14 [PATCH] btrfs/defrag: implement compression levels Daniel Vacek
2025-03-04 21:31 ` Qu Wenruo
2025-03-05 7:02 ` David Sterba
2025-03-05 7:08 ` Daniel Vacek
2025-03-05 7:02 ` Daniel Vacek
2025-03-05 7:05 ` David Sterba
2025-03-05 7:21 ` Daniel Vacek
2025-03-05 7:44 ` Qu Wenruo
2025-03-05 8:01 ` David Sterba [this message]
2025-03-05 8:08 ` Qu Wenruo
2025-03-05 10:32 ` [PATCH v2] " Daniel Vacek
2025-03-06 8:27 ` David Sterba
2025-03-06 13:15 ` Daniel Vacek
2025-03-06 13:15 ` [PATCH v3] " Daniel Vacek
2025-03-06 17:16 ` David Sterba
2025-03-06 21:54 ` 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=20250305080150.GB5777@suse.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neelx@suse.com \
--cc=quwenruo.btrfs@gmx.com \
--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