[PATCH] erofs-utils: support detecting maximum block size

Gao Xiang hsiangkao at linux.alibaba.com
Thu Jun 1 23:14:56 AEST 2023



On 2023/6/1 20:48, Kelvin Zhang wrote:
> 
> 
> On Thu, Jun 1, 2023 at 2:46 AM Gao Xiang <hsiangkao at linux.alibaba.com <mailto:hsiangkao at linux.alibaba.com>> wrote:
> 
>     Previously PAGE_SIZE was actually unset for most cases so that it was
>     always hard-coded 4096.
> 
>     In order to set EROFS_MAX_BLOCK_SIZE correctly, let's detect the real
>     page size when configuring.
> 
>     Cc: Kelvin Zhang <zhangkelvin at google.com <mailto:zhangkelvin at google.com>>
>     Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com <mailto:hsiangkao at linux.alibaba.com>>

...

> 
>     -#ifndef PAGE_SHIFT
>     -#define PAGE_SHIFT             (12)
>     -#endif
>     -
>       #ifndef PAGE_SIZE
>     -#define PAGE_SIZE              (1U << PAGE_SHIFT)
>     +#define PAGE_SIZE              4096
>       #endif
> 
>     +#ifndef EROFS_MAX_BLOCK_SIZE
>       #define EROFS_MAX_BLOCK_SIZE   PAGE_SIZE
>     +#endif
> 
>       #define EROFS_ISLOTBITS                5
>       #define EROFS_SLOTSIZE         (1U << EROFS_ISLOTBITS)
>     diff --git a/lib/namei.c b/lib/namei.c
>     index 3d0cf93..3751741 100644
>     --- a/lib/namei.c
>     +++ b/lib/namei.c
>     @@ -137,7 +137,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi)
>                      vi->u.chunkbits = sbi.blkszbits +
>                              (vi->u.chunkformat & EROFS_CHUNK_FORMAT_BLKBITS_MASK);
>              } else if (erofs_inode_is_data_compressed(vi->datalayout)) {
>     -               if (erofs_blksiz() != PAGE_SIZE)
>     +               if (erofs_blksiz() != EROFS_MAX_BLOCK_SIZE)
>                              return -EOPNOTSUPP;
>                      return z_erofs_fill_inode(vi);
>              }
>     diff --git a/mkfs/main.c b/mkfs/main.c
>     index 3ec4903..a6a2d0e 100644
>     --- a/mkfs/main.c
>     +++ b/mkfs/main.c
>     @@ -532,7 +532,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
>                      cfg.c_dbg_lvl = EROFS_ERR;
>                      cfg.c_showprogress = false;
>              }
>     -       if (cfg.c_compr_alg[0] && erofs_blksiz() != PAGE_SIZE) {
>     +       if (cfg.c_compr_alg[0] && erofs_blksiz() != EROFS_MAX_BLOCK_SIZE) {
>                      erofs_err("compression is unsupported for now with block size %u",
>                                erofs_blksiz());
>                      return -EINVAL;
>     @@ -670,7 +670,7 @@ static void erofs_mkfs_default_options(void)
>       {
>              cfg.c_showprogress = true;
>              cfg.c_legacy_compress = false;
>     -       sbi.blkszbits = ilog2(PAGE_SIZE);
>     +       sbi.blkszbits = ilog2(EROFS_MAX_BLOCK_SIZE);
>              sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING;
>              sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
>                                   EROFS_FEATURE_COMPAT_MTIME;
>     -- 
>     2.24.4
> 
> 
> Overall it looks good to me. Do we still need the PAGE_SIZE macro then?

Ok, let's get rid of PAGE_SIZE. Will send the next version.

Thanks,
Gao Xiang

> 
> -- 
> Sincerely,
> 
> Kelvin Zhang


More information about the Linux-erofs mailing list