Re: [PATCH v2 3/5] zstd: move ZSTD_MAX_CLEVEL to zstd_lib.h
haoqin huang <[email protected]> Wed, 29 Jul 2026 12:16:09 +0800
| Newsgroups | org.kernel.vger.linux-block,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAEjiKSkotZQAwUGgAggpS0Ar8Ewo5suB1kDssDK7jw=1w7xDoQ@mail.gmail.com> |
On Wed, Jul 29, 2026 at 11:03 AM Sergey Senozhatsky <[email protected]> wrote: > > On (26/07/28 17:29), Haoqin Huang wrote: > [..] > > diff --git a/include/linux/zstd_lib.h b/include/linux/zstd_lib.h > > index e295d4125dde..f4b26844e53a 100644 > > --- a/include/linux/zstd_lib.h > > +++ b/include/linux/zstd_lib.h > > @@ -1241,6 +1241,7 @@ ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); > > #define ZSTD_SEARCHLOG_MIN 1 > > #define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */ > > #define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */ > > +#define ZSTD_MAX_CLEVEL 22 > > #define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX > > #define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */ > > #define ZSTD_STRATEGY_MIN ZSTD_fast > > diff --git a/lib/zstd/compress/clevels.h b/lib/zstd/compress/clevels.h > > index 6ab8be6532ef..06565e064456 100644 > > --- a/lib/zstd/compress/clevels.h > > +++ b/lib/zstd/compress/clevels.h > > @@ -17,8 +17,6 @@ > > > > /*-===== Pre-defined compression levels =====-*/ > > > > -#define ZSTD_MAX_CLEVEL 22 > > - > > __attribute__((__unused__)) > > Sashiko made a good point. Can we use zstd_max_clevel() instead? Good point, I'll drop this patch and use zstd_max_clevel() instead in v3. Since it's a runtime function and can't be used for static struct initialization, I plan to set backend_zstd's level_max to -1 as a sentinel value, and query the actual maximum in zcomp_validate_params(): s32 max = backend->level_max; if (max < 0) max = zstd_max_clevel(); Do you think this approach is feasible?