Skip to content

Commit 9da681e

Browse files
chaseyugregkh
authored andcommitted
staging: erofs: support bmap
Add erofs_bmap() to support FIBMAP ioctl on flatmode inode. Reviewed-by: Gao Xiang <gaoxiang25@huawei.com> Signed-off-by: Chao Yu <yuchao0@huawei.com> Link: https://lore.kernel.org/r/20190716093256.108791-1-yuchao0@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 441dfcc commit 9da681e

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎drivers/staging/erofs/data.c‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,42 @@ static int erofs_raw_access_readpages(struct file *filp,
392392
return 0;
393393
}
394394

395+
static int erofs_get_block(struct inode *inode, sector_t iblock,
396+
struct buffer_head *bh, int create)
397+
{
398+
struct erofs_map_blocks map = {
399+
.m_la = iblock << 9,
400+
};
401+
int err;
402+
403+
err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
404+
if (err)
405+
return err;
406+
407+
if (map.m_flags & EROFS_MAP_MAPPED)
408+
bh->b_blocknr = erofs_blknr(map.m_pa);
409+
410+
return err;
411+
}
412+
413+
static sector_t erofs_bmap(struct address_space *mapping, sector_t block)
414+
{
415+
struct inode *inode = mapping->host;
416+
417+
if (is_inode_flat_inline(inode)) {
418+
erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
419+
420+
if (block >> LOG_SECTORS_PER_BLOCK >= blks)
421+
return 0;
422+
}
423+
424+
return generic_block_bmap(mapping, block, erofs_get_block);
425+
}
426+
395427
/* for uncompressed (aligned) files and raw access for other files */
396428
const struct address_space_operations erofs_raw_access_aops = {
397429
.readpage = erofs_raw_access_readpage,
398430
.readpages = erofs_raw_access_readpages,
431+
.bmap = erofs_bmap,
399432
};
400433

0 commit comments

Comments
 (0)