[PATCH v1] erofs-utils: fsck: fix support for 16k block size

Sandeep Dhavale dhavale at google.com
Wed Sep 13 08:12:04 AEST 2023


This basically follows the fix in kernel commit
001b8ccd0650 (erofs: fix compact 4B support for 16k
block size).

Without this patch fsck on images with 16k block size
reports corruption which is not correct.

Fixes: 76b822726ff8 ("erofs-utils: introduce compacted compression
indexes")

Signed-off-by: Sandeep Dhavale <dhavale at google.com>
---
 lib/zmap.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/lib/zmap.c b/lib/zmap.c
index cd91ca5..81fa22b 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -244,7 +244,7 @@ static int unpack_compacted_index(struct z_erofs_maprecorder *m,
 	u8 *in, type;
 	bool big_pcluster;
 
-	if (1 << amortizedshift == 4)
+	if (1 << amortizedshift == 4 && lclusterbits <= 14)
 		vcnt = 2;
 	else if (1 << amortizedshift == 2 && lclusterbits == 12)
 		vcnt = 16;
@@ -346,7 +346,6 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 {
 	struct erofs_inode *const vi = m->inode;
 	struct erofs_sb_info *sbi = vi->sbi;
-	const unsigned int lclusterbits = vi->z_logical_clusterbits;
 	const erofs_off_t ebase = round_up(erofs_iloc(vi) + vi->inode_isize +
 					   vi->xattr_isize, 8) +
 		sizeof(struct z_erofs_map_header);
@@ -356,9 +355,6 @@ static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m,
 	erofs_off_t pos;
 	int err;
 
-	if (lclusterbits != 12)
-		return -EOPNOTSUPP;
-
 	if (lcn >= totalidx)
 		return -EINVAL;
 
-- 
2.42.0.283.g2d96d420d3-goog



More information about the Linux-erofs mailing list