Skip to content

Commit a60cb39

Browse files
hjn-1gregkh
authored andcommitted
erofs: avoid using generic_block_bmap
[ Upstream commit d8b3df8 ] Surprisingly, `block' in sector_t indicates the number of i_blkbits-sized blocks rather than sectors for bmap. In addition, considering buffer_head limits mapped size to 32-bits, should avoid using generic_block_bmap. Link: https://lore.kernel.org/r/20201209115740.18802-1-huangjianan@oppo.com Fixes: 9da681e ("staging: erofs: support bmap") Reviewed-by: Chao Yu <yuchao0@huawei.com> Reviewed-by: Gao Xiang <hsiangkao@redhat.com> Signed-off-by: Huang Jianan <huangjianan@oppo.com> Signed-off-by: Guo Weichao <guoweichao@oppo.com> [ Gao Xiang: slightly update the commit message description. ] Signed-off-by: Gao Xiang <hsiangkao@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 82d87b5 commit a60cb39

1 file changed

Lines changed: 7 additions & 19 deletions

File tree

‎fs/erofs/data.c‎

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -312,27 +312,12 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
312312
submit_bio(bio);
313313
}
314314

315-
static int erofs_get_block(struct inode *inode, sector_t iblock,
316-
struct buffer_head *bh, int create)
317-
{
318-
struct erofs_map_blocks map = {
319-
.m_la = iblock << 9,
320-
};
321-
int err;
322-
323-
err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
324-
if (err)
325-
return err;
326-
327-
if (map.m_flags & EROFS_MAP_MAPPED)
328-
bh->b_blocknr = erofs_blknr(map.m_pa);
329-
330-
return err;
331-
}
332-
333315
static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
334316
{
335317
struct inode *inode = mapping->host;
318+
struct erofs_map_blocks map = {
319+
.m_la = blknr_to_addr(block),
320+
};
336321

337322
if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
338323
erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
@@ -341,7 +326,10 @@ static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
341326
return 0;
342327
}
343328

344-
return generic_block_bmap(mapping, block, erofs_get_block);
329+
if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
330+
return erofs_blknr(map.m_pa);
331+
332+
return 0;
345333
}
346334

347335
/* for uncompressed (aligned) files and raw access for other files */

0 commit comments

Comments
 (0)