On Fri, Jun 12, 2026 at 10:20:01AM +0800, Gao Xiang wrote:
> External email: Use caution opening links or attachments
> 
> 
> Source kernel commit: 7cef3c8341940febf75db6c25199cd83fb74d52f
> 
> !lz4_0padding is simply an ancient layout which is mainly used for
> Linux kernels < 5.3 (prior to the initial EROFS formal version) and
> generated with the option `-Elegacy-compress` by mkfs.erofs between
> 1.0 and 1.8.x.
> 
> So recently Linux 7.0+ kernels simply use lz4_0padding as another
> indicator of whether it's an (LZ4) compressed filesystem.  Follow
> the new behavior for erofs-utils too to fix an incremental data
> build issue [1].
> 
> Reported-by: Jonathan Calmels <[email protected]>
> [1] https://lore.kernel.org/r/[email protected]
> Signed-off-by: Gao Xiang <[email protected]>
> ---
> Hi Jonathan,
> 
> Could you confirm if this issue works for you?
> 
> Thanks,
> Gao Xiang
> 

Yes this approach works too, thanks!

>  lib/decompress.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/lib/decompress.c b/lib/decompress.c
> index d23135e0cd43..e6d14f4cbd94 100644
> --- a/lib/decompress.c
> +++ b/lib/decompress.c
> @@ -466,17 +466,12 @@ static int z_erofs_decompress_lz4(struct 
> z_erofs_decompress_req *rq)
>         char *dest = rq->out;
>         char *src = rq->in;
>         char *buff = NULL;
> -       bool support_0padding = false;
>         unsigned int inputmargin = 0;
>         struct erofs_sb_info *sbi = rq->sbi;
> 
> -       if (erofs_sb_has_lz4_0padding(sbi)) {
> -               support_0padding = true;
> -
> -               inputmargin = z_erofs_fixup_insize((u8 *)src, rq->inputsize);
> -               if (inputmargin >= rq->inputsize)
> -                       return -EFSCORRUPTED;
> -       }
> +       inputmargin = z_erofs_fixup_insize((u8 *)src, rq->inputsize);
> +       if (inputmargin >= rq->inputsize)
> +               return -EFSCORRUPTED;
> 
>         if (rq->decodedskip) {
>                 buff = malloc(rq->decodedlength);
> @@ -485,7 +480,7 @@ static int z_erofs_decompress_lz4(struct 
> z_erofs_decompress_req *rq)
>                 dest = buff;
>         }
> 
> -       if (rq->partial_decoding || !support_0padding)
> +       if (rq->partial_decoding)
>                 ret = LZ4_decompress_safe_partial(src + inputmargin, dest,
>                                 rq->inputsize - inputmargin,
>                                 rq->decodedlength, rq->decodedlength);
> @@ -589,7 +584,10 @@ static int z_erofs_load_lz4_config(struct erofs_sb_info 
> *sbi,
>                         sbi->lz4.max_pclusterblks = 1;  /* reserved case */
>         } else {
>                 distance = le16_to_cpu(dsb->u1.lz4_max_distance);
> +               if (!distance && !erofs_sb_has_lz4_0padding(sbi))
> +                       return 0;
>                 sbi->lz4.max_pclusterblks = 1;
> +               sbi->available_compr_algs = 1 << Z_EROFS_COMPRESSION_LZ4;
>         }
>         sbi->lz4.max_distance = distance;
>         return 0;
> @@ -601,10 +599,8 @@ int z_erofs_parse_cfgs(struct erofs_sb_info *sbi, struct 
> erofs_super_block *dsb)
>         erofs_off_t offset;
>         int size, ret = 0;
> 
> -       if (!erofs_sb_has_compr_cfgs(sbi)) {
> -               sbi->available_compr_algs = 1 << Z_EROFS_COMPRESSION_LZ4;
> +       if (!erofs_sb_has_compr_cfgs(sbi))
>                 return z_erofs_load_lz4_config(sbi, dsb, NULL, 0);
> -       }
> 
>         sbi->available_compr_algs = le16_to_cpu(dsb->u1.available_compr_algs);
>         if (sbi->available_compr_algs & ~Z_EROFS_ALL_COMPR_ALGS) {
> --
> 2.43.5
> 

Reply via email to