From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: haoqin huang <haoqinhuang7@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>, Minchan Kim <minchan@kernel.org>,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-block@vger.kernel.org,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Nick Terrell <terrelln@fb.com>, David Sterba <dsterba@suse.com>,
Jaegeuk Kim <jaegeuk@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Rongwei Wang <zigiwang@tencent.com>,
Haoqin Huang <haoqinhuang@tencent.com>
Subject: Re: [f2fs-dev] [PATCH v4 3/4] zram: validate parameters in each backend's setup_params
Date: Tue, 4 Aug 2026 13:42:21 +0900 [thread overview]
Message-ID: <anFspPi023HFlwwE@google.com> (raw)
In-Reply-To: <CAEjiKSkExTnRc77Va-cOSpoNJ4S0i_-r2-iGFyxoSw2mqh1Diw@mail.gmail.com>
On (26/08/03 20:20), haoqin huang wrote:
> On Thu, Jul 30, 2026 at 3:24 PM Sergey Senozhatsky
> <senozhatsky@chromium.org> wrote:
> > > diff --git a/drivers/block/zram/backend_lz4hc.c b/drivers/block/zram/backend_lz4hc.c
> > > index f6a336acfe20..5d551d165213 100644
> > > --- a/drivers/block/zram/backend_lz4hc.c
> > > +++ b/drivers/block/zram/backend_lz4hc.c
> > > @@ -20,6 +20,11 @@ static int lz4hc_setup_params(struct zcomp_params *params)
> > > {
> > > if (params->level == ZCOMP_PARAM_NOT_SET)
> > > params->level = LZ4HC_DEFAULT_CLEVEL;
> > > + else if (params->level < LZ4HC_MIN_CLEVEL ||
> > > + params->level > LZ4HC_MAX_CLEVEL) {
> > > + pr_err("lz4hc: invalid compression level %d\n", params->level);
> > > + return -EINVAL;
> > > + }
> >
> > So... lib/lz4/lz4hc_compress.c supports levels 1 and 2. However,
> > LZ4HC_MIN_CLEVEL is set to 3, but clearly the compression library
> > supports levels lower than LZ4HC_MIN_CLEVEL. In fact, LZ4HC_MIN_CLEVEL
> > is never used in the lz4 code. Maybe here we need to just hardcode
> > "< 1" and put a comment:
> >
>
> My bad, completely missed that LZ4HC_MIN_CLEVEL is advisory and the
> library actually accepts 1-2. Will hardcode < 1 in v5.
No worries, that LZ4HC_MIN_CLEVEL thing is difficult to spot.
> Btw, would it make sense to fix LZ4HC_MIN_CLEVEL to 1 in the lz4
> header as a separate cleanup? It seems misleading as-is.
I'm afraid we cannot do that. f2fs uses LZ4HC_MIN_CLEVEL, I assume
compression level is stored per-inode? So if we change LZ4HC_MIN_CLEVEL
then newer f2fs will start accepting compression levels that older kernels
don't support. Cc-ed Jaegeuk and Chao just for visibility.
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next parent reply other threads:[~2026-08-04 5:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260730025240.17724-1-haoqinhuang7@gmail.com>
[not found] ` <20260730060133.80233-1-haoqinhuang7@gmail.com>
[not found] ` <20260730060133.80233-4-haoqinhuang7@gmail.com>
[not found] ` <amr3P_4zxX2w7ZNR@google.com>
[not found] ` <CAEjiKSkExTnRc77Va-cOSpoNJ4S0i_-r2-iGFyxoSw2mqh1Diw@mail.gmail.com>
2026-08-04 4:42 ` Sergey Senozhatsky [this message]
2026-08-05 1:26 ` [f2fs-dev] [PATCH v4 3/4] zram: validate parameters in each backend's setup_params Jaegeuk Kim via Linux-f2fs-devel
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=anFspPi023HFlwwE@google.com \
--to=senozhatsky@chromium.org \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=dsterba@suse.com \
--cc=haoqinhuang7@gmail.com \
--cc=haoqinhuang@tencent.com \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=terrelln@fb.com \
--cc=zigiwang@tencent.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