erofs-utils: fsck: fix support for 16k block size
authorSandeep Dhavale <dhavale@google.com>
Tue, 12 Sep 2023 22:12:04 +0000 (15:12 -0700)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 13 Sep 2023 02:15:52 +0000 (10:15 +0800)
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@google.com>
Link: https://lore.kernel.org/r/20230912221204.52184-1-dhavale@google.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/zmap.c

index cd91ca5fa31daaaced4d0735115ca97c26645d1e..81fa22b6c860e5b8ed62759f4d5ba4ef8eb2f7b3 100644 (file)
@@ -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;