[PATCH] erofs-utils: lib,fuse: fix encoded extents handling

Gao Xiang hsiangkao at linux.alibaba.com
Thu Feb 19 12:05:46 AEDT 2026


Source kernel commit: be45319c9fb1d5c272da9fd34854a7d39e7f58d1
Source kernel commit: a429b76114aaca3ef1aff4cd469dcf025431bd11

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/zmap.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/zmap.c b/lib/zmap.c
index c1cf698c828b..baec278cc745 100644
--- a/lib/zmap.c
+++ b/lib/zmap.c
@@ -560,7 +560,8 @@ static int z_erofs_map_blocks_ext(struct erofs_inode *vi,
 			pos += sizeof(__le64);
 			lstart = 0;
 		} else {
-			lstart = map->m_la >> vi->z_lclusterbits;
+			lstart = round_down(map->m_la, 1 << vi->z_lclusterbits);
+			pos += (lstart >> vi->z_lclusterbits) * recsz;
 			pa = EROFS_NULL_ADDR;
 		}
 
@@ -579,7 +580,7 @@ static int z_erofs_map_blocks_ext(struct erofs_inode *vi,
 		}
 		last = (lstart >= round_up(lend, 1 << vi->z_lclusterbits));
 		lend = min(lstart, lend);
-		lstart -= 1ULL << vi->z_lclusterbits;
+		lstart -= 1 << vi->z_lclusterbits;
 	} else {
 		lstart = lend;
 		for (l = 0, r = vi->z_extents; l < r; ) {
@@ -621,7 +622,7 @@ static int z_erofs_map_blocks_ext(struct erofs_inode *vi,
 			vi->z_fragmentoff = map->m_plen;
 			if (recsz > offsetof(struct z_erofs_extent, pstart_lo))
 				vi->z_fragmentoff |= map->m_pa << 32;
-		} else if (map->m_plen) {
+		} else if (map->m_plen & Z_EROFS_EXTENT_PLEN_MASK) {
 			map->m_flags |= EROFS_MAP_MAPPED |
 				EROFS_MAP_FULL_MAPPED | EROFS_MAP_ENCODED;
 			fmt = map->m_plen >> Z_EROFS_EXTENT_PLEN_FMT_BIT;
-- 
2.43.5



More information about the Linux-erofs mailing list