Skip to content

Commit be45319

Browse files
committed
erofs: fix encoded extents handling
- The MSB 32 bits of `z_fragmentoff` are available only in extent records of size >= 8B. - Use round_down() to calculate `lstart` as well as increase `pos` correspondingly for extent records of size == 8B. Fixes: 1d191b4 ("erofs: implement encoded extent metadata") Signed-off-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d385f15 commit be45319

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/erofs/zmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
559559
pos += sizeof(__le64);
560560
lstart = 0;
561561
} else {
562-
lstart = map->m_la >> vi->z_lclusterbits;
562+
lstart = round_down(map->m_la, 1 << vi->z_lclusterbits);
563+
pos += (lstart >> vi->z_lclusterbits) * recsz;
563564
pa = EROFS_NULL_ADDR;
564565
}
565566

@@ -614,7 +615,7 @@ static int z_erofs_map_blocks_ext(struct inode *inode,
614615
if (last && (vi->z_advise & Z_EROFS_ADVISE_FRAGMENT_PCLUSTER)) {
615616
map->m_flags |= EROFS_MAP_MAPPED | EROFS_MAP_FRAGMENT;
616617
vi->z_fragmentoff = map->m_plen;
617-
if (recsz >= offsetof(struct z_erofs_extent, pstart_lo))
618+
if (recsz > offsetof(struct z_erofs_extent, pstart_lo))
618619
vi->z_fragmentoff |= map->m_pa << 32;
619620
} else if (map->m_plen) {
620621
map->m_flags |= EROFS_MAP_MAPPED |

0 commit comments

Comments
 (0)