Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: Daniel Vacek <neelx@suse.com>, Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: 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:14:16 +1030	[thread overview]
Message-ID: <29ec66bd-27a0-443e-b19b-fb759a847dcb@suse.com> (raw)
In-Reply-To: <CAPjX3FcZ6TJZnHNf3sm00F49BVsDzQaZr5fJHMXRUXne3gLZ2w@mail.gmail.com>



在 2025/3/5 17:32, Daniel Vacek 写道:
> On Tue, 4 Mar 2025 at 22:31, Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
[...]
>>
>> I am not familiar with the compress level, but
>> btrfs_compress_set_level() does extra clamping, maybe we also want to do
>> that too?
> 
> This is intentionally left to be limited later. There's no need to do
> it at this point and the code is simpler. It's also compression
> type/method agnostic.

You're right, the level checks are done in the compression path already.

[...]
>>>        /* 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").

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.

With that commit message fixed:

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> 
>>
>> Thanks,
>> Qu
> 


  parent reply	other threads:[~2025-03-05  7:44 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 [this message]
2025-03-05  8:01       ` David Sterba
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=29ec66bd-27a0-443e-b19b-fb759a847dcb@suse.com \
    --to=wqu@suse.com \
    --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 \
    /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