[PATCH v2 2/4] erofs-utils: add per-sb block size

Gao Xiang hsiangkao at linux.alibaba.com
Tue Mar 14 17:21:19 AEDT 2023


Will be used for subpage blocksize support.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
v2: fold in runtime blkszbits modification from 4/4.
 include/erofs/internal.h | 1 +
 lib/super.c              | 7 +++----
 mkfs/main.c              | 1 +
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/include/erofs/internal.h b/include/erofs/internal.h
index d4ae3b8..a031915 100644
--- a/include/erofs/internal.h
+++ b/include/erofs/internal.h
@@ -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;
diff --git a/lib/super.c b/lib/super.c
index 30aeb36..6b91011 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -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;
 	}
 
diff --git a/mkfs/main.c b/mkfs/main.c
index 8e5a421..be3d805 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -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;
-- 
2.24.4



More information about the Linux-erofs mailing list