linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@kernel.org>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Daniel Vacek <neelx@suse.com>, Calvin Owens <calvin@wbinvd.org>,
	Sun YangKai <sunk67188@gmail.com>,
	 clm@fb.com, dsterba@suse.com, josef@toxicpanda.com,
	 linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: Accept and ignore compression level for lzo
Date: Mon, 25 Aug 2025 12:37:59 +0100	[thread overview]
Message-ID: <CAL3q7H4RgwGZwPdof=5NN6hcB7YRevOjA70vG19sRNXNMRMM3w@mail.gmail.com> (raw)
In-Reply-To: <663c2f5b-3bb1-4a40-b962-11c6d3a7f806@gmx.com>

On Mon, Aug 25, 2025 at 10:03 AM Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>
>
>
> 在 2025/8/25 18:21, Daniel Vacek 写道:
> > On Sun, 24 Aug 2025 at 17:58, Calvin Owens <calvin@wbinvd.org> wrote:
> >> From: Calvin Owens <calvin@wbinvd.org>
> >> Subject: [PATCH v3] btrfs: Accept and ignore compression level for lzo
> >>
> >> The compression level is meaningless for lzo, but before commit
> >> 3f093ccb95f30 ("btrfs: harden parsing of compression mount options"),
> >> it was silently ignored if passed.
> >>
> >> After that commit, passing a level with lzo fails to mount:
> >>
> >>      BTRFS error: unrecognized compression value lzo:1
> >>
> >> It seems reasonable for users to expect that lzo would permit a numeric
> >> level option, as all the other algos do, even though the kernel's
> >> implementation of LZO currently only supports a single level. Because it
> >> has always worked to pass a level, it seems likely to me that users in
> >> the real world are relying on doing so.
> >>
> >> This patch restores the old behavior, giving "lzo:N" the same semantics
> >> as all of the other compression algos.
> >>
> >> To be clear, silly variants like "lzo:one", "lzo:the_first_option", or
> >> "lzo:armageddon" also used to work. This isn't meant to suggest that
> >> any possible mis-interpretation of mount options that once worked must
> >> continue to work forever. This is an exceptional case where it makes
> >> sense to preserve compatibility, both because the mis-interpretation is
> >> reasonable, and because nothing tangible is sacrificed.
> >>
> >> Fixes: 3f093ccb95f30 ("btrfs: harden parsing of compression mount options")
> >> Signed-off-by: Calvin Owens <calvin@wbinvd.org>
> >> ---
> >>   fs/btrfs/super.c | 7 +++++--
> >>   1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > v3 looks good to me. The original hardening was meant to gate complete
> > nonsense like "compress=lzoutput", etc...
> >
> > Reviewed-by: Daniel Vacek <neelx@suse.com>
>
> Now merged and pushed to for-next branch with the latest reviewed-by tags.

Btw, don't forget a couple things:

1) In the subject, after the prefix "btrfs: " the first word should
not be capitalized;

2) In the log message (btrfs_warn() call), the first word should also
not be capitalized.

These are the styles we follow, so we should be consistent.

>
> Thanks,
> Qu
> >
> > Thank you.
> >
> >> diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
> >> index a262b494a89f..18eb00b3639b 100644
> >> --- a/fs/btrfs/super.c
> >> +++ b/fs/btrfs/super.c
> >> @@ -299,9 +299,12 @@ static int btrfs_parse_compress(struct btrfs_fs_context *ctx,
> >>                  btrfs_set_opt(ctx->mount_opt, COMPRESS);
> >>                  btrfs_clear_opt(ctx->mount_opt, NODATACOW);
> >>                  btrfs_clear_opt(ctx->mount_opt, NODATASUM);
> >> -       } else if (btrfs_match_compress_type(string, "lzo", false)) {
> >> +       } else if (btrfs_match_compress_type(string, "lzo", true)) {
> >>                  ctx->compress_type = BTRFS_COMPRESS_LZO;
> >> -               ctx->compress_level = 0;
> >> +               ctx->compress_level = btrfs_compress_str2level(BTRFS_COMPRESS_LZO,
> >> +                                                              string + 3);
> >> +               if (string[3] == ':' && string[4])
> >> +                       btrfs_warn(NULL, "Compression level ignored for LZO");
> >>                  btrfs_set_opt(ctx->mount_opt, COMPRESS);
> >>                  btrfs_clear_opt(ctx->mount_opt, NODATACOW);
> >>                  btrfs_clear_opt(ctx->mount_opt, NODATASUM);
> >> --
> >> 2.49.1
> >>
>
>

  reply	other threads:[~2025-08-25 11:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-22  7:45 [PATCH] btrfs: Accept and ignore compression level for lzo Calvin Owens
2025-08-22  8:27 ` Qu Wenruo
2025-08-22  9:28   ` Calvin Owens
2025-08-22 10:18     ` Qu Wenruo
2025-08-22 18:45     ` David Sterba
2025-08-22 21:42       ` Calvin Owens
2025-08-22 10:20 ` Sun YangKai
2025-08-22 10:23   ` Qu Wenruo
2025-08-22 15:54     ` Calvin Owens
2025-08-22 18:57       ` David Sterba
2025-08-22 21:44       ` Qu Wenruo
2025-08-22 23:24         ` Calvin Owens
2025-08-22 23:39           ` Qu Wenruo
2025-08-24 15:58             ` Calvin Owens
2025-08-24 21:40               ` Qu Wenruo
2025-08-25  8:51               ` Daniel Vacek
2025-08-25  9:03                 ` Qu Wenruo
2025-08-25 11:37                   ` Filipe Manana [this message]
2025-08-22 18:42   ` Calvin Owens

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='CAL3q7H4RgwGZwPdof=5NN6hcB7YRevOjA70vG19sRNXNMRMM3w@mail.gmail.com' \
    --to=fdmanana@kernel.org \
    --cc=calvin@wbinvd.org \
    --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=sunk67188@gmail.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;
as well as URLs for NNTP newsgroup(s).