erofs-utils: add per-sb block size
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 14 Mar 2023 06:21:19 +0000 (14:21 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 15 Mar 2023 08:29:12 +0000 (16:29 +0800)
Will be used for subpage blocksize support.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230314062121.115020-2-hsiangkao@linux.alibaba.com
include/erofs/internal.h
lib/super.c
mkfs/main.c

index d4ae3b8d04f6f239813207bca678697b2e1fde29..a03191535b8d7aac70a17b788875a718b915007b 100644 (file)
@@ -88,6 +88,7 @@ struct erofs_sb_info {
        u32 build_time_nsec;
 
        unsigned char islotbits;
+       unsigned char blkszbits;
 
        /* what we really care is nid, rather than ino.. */
        erofs_nid_t root_nid;
index 30aeb36cef88ab04ac44ee3c8d01e86a39b4aa46..6b91011daacccf6a1d14e5173e5d4736579a4d4a 100644 (file)
@@ -70,7 +70,6 @@ int erofs_read_superblock(void)
 {
        char data[EROFS_BLKSIZ];
        struct erofs_super_block *dsb;
-       unsigned int blkszbits;
        int ret;
 
        ret = blk_read(0, data, 0, 1);
@@ -88,11 +87,11 @@ int erofs_read_superblock(void)
 
        sbi.feature_compat = le32_to_cpu(dsb->feature_compat);
 
-       blkszbits = dsb->blkszbits;
+       sbi.blkszbits = dsb->blkszbits;
        /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */
-       if (blkszbits != LOG_BLOCK_SIZE) {
+       if (sbi.blkszbits != LOG_BLOCK_SIZE) {
                erofs_err("blksize %d isn't supported on this platform",
-                         1 << blkszbits);
+                         1 << sbi.blkszbits);
                return ret;
        }
 
index 8e5a421ae41ce484db53c7b4857de44f7a05a250..be3d805c36f0fed2c6e9e3069a290b3cffbaf632 100644 (file)
@@ -641,6 +641,7 @@ static void erofs_mkfs_default_options(void)
 {
        cfg.c_showprogress = true;
        cfg.c_legacy_compress = false;
+       sbi.blkszbits = ilog2(PAGE_SIZE);
        sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_LZ4_0PADDING;
        sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
                             EROFS_FEATURE_COMPAT_MTIME;