From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: dsterba@suse.cz, Qu Wenruo <wqu@suse.com>
Cc: Daniel Vacek <neelx@suse.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 18:38:49 +1030 [thread overview]
Message-ID: <10b0cfa5-eadb-48a7-806a-3fc044682b04@gmx.com> (raw)
In-Reply-To: <20250305080150.GB5777@suse.cz>
在 2025/3/5 18:31, David Sterba 写道:
> 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.
I know it's backported to all stable kernels, but I still won't consider
a patch that's only one year old to be applied to all the kernels in the
wide.
Maybe I'm really paranoid on this.
>
>> 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.
Since the fallback behavior is sane, I'm fine with the union solution.
Thanks,
Qu
next prev parent reply other threads:[~2025-03-05 8:08 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
2025-03-05 8:08 ` Qu Wenruo [this message]
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=10b0cfa5-eadb-48a7-806a-3fc044682b04@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=dsterba@suse.cz \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neelx@suse.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