From e9ae52d3f32da8856badc5eeeea4c2ad5a154434 Mon Sep 17 00:00:00 2001 From: Zizhi Wo Date: Thu, 13 Nov 2025 15:54:30 +0800 Subject: [PATCH] erofs: Fix erofs_bmap error hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/ID6FYU -------------------------------- Currently, there is an issue with the bmap of erofs. When formatted as the chunk type, the bmap returns not the block granularity but the chunk granularity, which is inaccurate. Unify it with the bmap of other file systems, return the block granularity. Calculate the offset within the chunk to solve this problem. Fixes: 9da681e017a3 ("staging: erofs: support bmap") Signed-off-by: Zizhi Wo --- fs/erofs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/erofs/data.c b/fs/erofs/data.c index e228a2d52aaf..99c5da8e6338 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -458,6 +458,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block) struct erofs_map_blocks map = { .m_la = blknr_to_addr(block), }; + erofs_off_t offset = map.m_la; if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) { erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE; @@ -467,7 +468,7 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block) } if (!erofs_map_blocks(inode, &map)) - return erofs_blknr(map.m_pa); + return erofs_blknr(map.m_pa + offset - map.m_la); return 0; } -- Gitee