staging: erofs: support bmap
PATCH 1/1 staging: erofs: support bmap
Add erofs_bmap() to support FIBMAP ioctl on flatmode inode.
--- drivers/staging/erofs/data.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/staging/erofs/data.c +29 -0
@@ -308,9 +308,38 @@ static int erofs_raw_access_readpages(struct file *filp,return iomap_readpages (mapping, pages, nr_pages, &erofs_iomap_ops); } +static int erofs_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh,int create) +{ +struct erofs_map_blocks map = { + .m_la = iblock <<9 , + }; +int err; + + err =erofs_map_blocks (inode, &map,EROFS_GET_BLOCKS_RAW ); +if (err) +return err; + +if (map.m_flags &EROFS_MAP_MAPPED ) + bh->b_blocknr =erofs_blknr (map.m_pa); + +return err; +} + +static sector_t erofs_bmap (struct address_space *mapping,sector_t block) +{ +struct inode *inode = mapping->host; + +if (is_inode_flat_inline (inode)) +return 0 ; + +return generic_block_bmap (mapping, block, erofs_get_block); +} +/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_raw_access_aops = { .readpage = erofs_raw_access_readpage, .readpages = erofs_raw_access_readpages, + .bmap = erofs_bmap, };
Signature · 1 line
2.18.0.rc1
PATCH 1/1 staging: erofs: support bmap
Hi Chao,
Quoted 29 lines · Chao Yu
Add
erofs_bmap()to support FIBMAP ioctl on flatmode inode.Signed-off-by Chao Yu <yuchao0 at huawei.com>--- drivers/staging/erofs/data.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/staging/erofs/data.c +14
-0@@ -308,9 +308,38 @@ static int erofs_raw_access_readpages(struct file *filp,return iomap_readpages (mapping, pages, nr_pages, &erofs_iomap_ops); } +static int erofs_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh,int create) +{ +struct erofs_map_blocks map = { + .m_la = iblock <<9 , + }; +int err; + + err =erofs_map_blocks (inode, &map,EROFS_GET_BLOCKS_RAW ); +if (err) +return err; + +if (map.m_flags &EROFS_MAP_MAPPED ) + bh->b_blocknr =erofs_blknr (map.m_pa);
drivers/staging/erofs/data.c static int erofs_raw_access_readpages(struct file *filp, · line 334
Quoted 10 lines
drivers/staging/erofs/data.c +10
-0+ +return err; +} + +static sector_t erofs_bmap (struct address_space *mapping,sector_t block) +{ +struct inode *inode = mapping->host; + +if (is_inode_flat_inline (inode)) +return 0 ;
could we support flat_inline as well? some difficulty on this?
(I have no idea return 0 is suitable for us since we have tail-end packing...)
Thanks,
Gao Xiang
Quoted 12 lines
drivers/staging/erofs/data.c +5
-0+ +return generic_block_bmap (mapping, block, erofs_get_block); +} +/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_raw_access_aops = { .readpage = erofs_raw_access_readpage, .readpages = erofs_raw_access_readpages, + .bmap = erofs_bmap, };
PATCH 1/1 staging: erofs: support bmap
Hi Xiang,
Quoted 36 lines · Gao Xiang
Hi Chao,
Quoted 33 lines · Chao Yu
Add
erofs_bmap()to support FIBMAP ioctl on flatmode inode.Signed-off-by Chao Yu <yuchao0 at huawei.com>--- drivers/staging/erofs/data.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/staging/erofs/data.c +18
-0@@ -308,9 +308,38 @@ static int erofs_raw_access_readpages(struct file *filp,return iomap_readpages (mapping, pages, nr_pages, &erofs_iomap_ops); } +static int erofs_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh,int create) +{ +struct erofs_map_blocks map = { + .m_la = iblock <<9 , + }; +int err; + + err =erofs_map_blocks (inode, &map,EROFS_GET_BLOCKS_RAW ); +if (err) +return err; + +if (map.m_flags &EROFS_MAP_MAPPED ) + bh->b_blocknr =erofs_blknr (map.m_pa); + +return err; +} +
Quoted 8 lines
drivers/staging/erofs/data.c static int erofs_raw_access_readpages(struct file *filp, · line 334
Quoted 6 lines
drivers/staging/erofs/data.c +6
-0+static sector_t erofs_bmap (struct address_space *mapping,sector_t block) +{ +struct inode *inode = mapping->host; + +if (is_inode_flat_inline (inode)) +return 0 ;could we support
flat_inlineas well? some difficulty on this?
I think we can support partial of this on inline inode, e.g.:
[0, 4k] mapped
[4k, 5k] inline
We can find and return the physical block address for first block, but for last block locating in metadata, we should just return 0 (0 indicate bmap has failed to get mapped block address).
Thanks,
Quoted 19 lines
(I have no idea return 0 is suitable for us since we have tail-end packing...)
Thanks,
Gao Xiangdrivers/staging/erofs/data.c static int erofs_raw_access_readpages(struct file *filp, · line 345
Quoted 12 lines
drivers/staging/erofs/data.c +5
-0+ +return generic_block_bmap (mapping, block, erofs_get_block); +} +/* for uncompressed (aligned) files and raw access for other files */ const struct address_space_operations erofs_raw_access_aops = { .readpage = erofs_raw_access_readpage, .readpages = erofs_raw_access_readpages, + .bmap = erofs_bmap, };.
PATCH 1/1 staging: erofs: support bmap
Quoted 48 lines · Chao Yu
Hi Xiang,
Quoted 36 lines · Gao Xiang
Hi Chao,
Quoted 33 lines · Chao Yu
Add
erofs_bmap()to support FIBMAP ioctl on flatmode inode.Signed-off-by Chao Yu <yuchao0 at huawei.com>--- drivers/staging/erofs/data.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/staging/erofs/data.c +18
-0@@ -308,9 +308,38 @@ static int erofs_raw_access_readpages(struct file *filp,return iomap_readpages (mapping, pages, nr_pages, &erofs_iomap_ops); } +static int erofs_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh,int create) +{ +struct erofs_map_blocks map = { + .m_la = iblock <<9 , + }; +int err; + + err =erofs_map_blocks (inode, &map,EROFS_GET_BLOCKS_RAW ); +if (err) +return err; + +if (map.m_flags &EROFS_MAP_MAPPED ) + bh->b_blocknr =erofs_blknr (map.m_pa); + +return err; +} +Quoted 8 lines
drivers/staging/erofs/data.c static int erofs_raw_access_readpages(struct file *filp, · line 334
Quoted 6 lines
drivers/staging/erofs/data.c +6
-0+static sector_t erofs_bmap (struct address_space *mapping,sector_t block) +{ +struct inode *inode = mapping->host; + +if (is_inode_flat_inline (inode)) +return 0 ;could we support
flat_inlineas well? some difficulty on this?
Quoted 8 lines
I think we can support partial of this on inline inode, e.g.:
[0, 4k] mapped
[4k, 5k] inlineWe can find and return the physical block address for first block, but for last block locating in metadata, we should just return 0 (0 indicate bmap has failed to get mapped block address).
I think that is fine (in the long term, FIEMAP is preferred of course.)
Thanks,
Gao Xiang
PATCH 1/1 staging: erofs: support bmap
Quoted 53 lines · Gao Xiang
Quoted 50 lines · Chao Yu
Hi Xiang,
Quoted 36 lines · Gao Xiang
Hi Chao,
Quoted 33 lines · Chao Yu
Add
erofs_bmap()to support FIBMAP ioctl on flatmode inode.Signed-off-by Chao Yu <yuchao0 at huawei.com>--- drivers/staging/erofs/data.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)drivers/staging/erofs/data.c +18
-0@@ -308,9 +308,38 @@ static int erofs_raw_access_readpages(struct file *filp,return iomap_readpages (mapping, pages, nr_pages, &erofs_iomap_ops); } +static int erofs_get_block (struct inode *inode,sector_t iblock, +struct buffer_head *bh,int create) +{ +struct erofs_map_blocks map = { + .m_la = iblock <<9 , + }; +int err; + + err =erofs_map_blocks (inode, &map,EROFS_GET_BLOCKS_RAW ); +if (err) +return err; + +if (map.m_flags &EROFS_MAP_MAPPED ) + bh->b_blocknr =erofs_blknr (map.m_pa); + +return err; +} +Quoted 8 lines
drivers/staging/erofs/data.c static int erofs_raw_access_readpages(struct file *filp, · line 334
Quoted 6 lines
drivers/staging/erofs/data.c +6
-0+static sector_t erofs_bmap (struct address_space *mapping,sector_t block) +{ +struct inode *inode = mapping->host; + +if (is_inode_flat_inline (inode)) +return 0 ;could we support
flat_inlineas well? some difficulty on this?I think we can support partial of this on inline inode, e.g.:
Quoted 8 lines
Quoted 6 lines
[0, 4k] mapped
[4k, 5k] inlineWe can find and return the physical block address for first block, but for last block locating in metadata, we should just return 0 (0 indicate bmap has failed to get mapped block address).
I think that is fine (in the long term, FIEMAP is preferred of course.)
Right, I can take a look at fiemap() implementation.
Thanks,
Quoted 5 lines
Thanks,
Gao Xiang
.