linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] erofs: avoid using generic_block_bmap
@ 2020-12-09  2:39 Huang Jianan
  2020-12-09  2:46 ` Gao Xiang
  2020-12-09 10:08 ` Chao Yu
  0 siblings, 2 replies; 5+ messages in thread
From: Huang Jianan @ 2020-12-09  2:39 UTC (permalink / raw)
  To: linux-erofs; +Cc: linux-kernel, guoweichao, zhangshiming

iblock indicates the number of i_blkbits-sized blocks rather than
sectors.

In addition, considering buffer_head limits mapped size to 32-bits,
should avoid using generic_block_bmap.

Fixes: 9da681e017a3 ("staging: erofs: support bmap")
Signed-off-by: Huang Jianan <huangjianan@oppo.com>
Signed-off-by: Guo Weichao <guoweichao@oppo.com>
---
 fs/erofs/data.c | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 347be146884c..d6ea0a216b57 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
 		submit_bio(bio);
 }
 
-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;
+	struct erofs_map_blocks map = {
+		.m_la = blknr_to_addr(block),
+	};
+	sector_t blknr = 0;
 
 	if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
 		erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
 
 		if (block >> LOG_SECTORS_PER_BLOCK >= blks)
-			return 0;
+			goto out;
 	}
 
-	return generic_block_bmap(mapping, block, erofs_get_block);
+	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
+		blknr = erofs_blknr(map.m_pa);
+
+out:
+	return blknr;
 }
 
 /* for uncompressed (aligned) files and raw access for other files */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] erofs: avoid using generic_block_bmap
  2020-12-09  2:39 [PATCH v4] erofs: avoid using generic_block_bmap Huang Jianan
@ 2020-12-09  2:46 ` Gao Xiang
  2020-12-09 10:08 ` Chao Yu
  1 sibling, 0 replies; 5+ messages in thread
From: Gao Xiang @ 2020-12-09  2:46 UTC (permalink / raw)
  To: Huang Jianan; +Cc: zhangshiming, guoweichao, linux-erofs, linux-kernel

On Wed, Dec 09, 2020 at 10:39:30AM +0800, Huang Jianan wrote:
> iblock indicates the number of i_blkbits-sized blocks rather than
> sectors.
> 
> In addition, considering buffer_head limits mapped size to 32-bits,
> should avoid using generic_block_bmap.
> 
> Fixes: 9da681e017a3 ("staging: erofs: support bmap")
> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
> Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> ---

Looks good to me in general, yet see my v3 reply as below:
https://lore.kernel.org/r/20201209024415.GA33948@xiangao.remote.csb/

Thanks,
Gao Xiang


>  fs/erofs/data.c | 30 ++++++++++--------------------
>  1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 347be146884c..d6ea0a216b57 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
>  		submit_bio(bio);
>  }
>  
> -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;
> +	struct erofs_map_blocks map = {
> +		.m_la = blknr_to_addr(block),
> +	};
> +	sector_t blknr = 0;
>  
>  	if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
>  		erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
>  
>  		if (block >> LOG_SECTORS_PER_BLOCK >= blks)
> -			return 0;
> +			goto out;
>  	}
>  
> -	return generic_block_bmap(mapping, block, erofs_get_block);
> +	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
> +		blknr = erofs_blknr(map.m_pa);
> +
> +out:
> +	return blknr;
>  }
>  
>  /* for uncompressed (aligned) files and raw access for other files */
> -- 
> 2.25.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] erofs: avoid using generic_block_bmap
  2020-12-09  2:39 [PATCH v4] erofs: avoid using generic_block_bmap Huang Jianan
  2020-12-09  2:46 ` Gao Xiang
@ 2020-12-09 10:08 ` Chao Yu
  2020-12-09 11:39   ` Gao Xiang
  1 sibling, 1 reply; 5+ messages in thread
From: Chao Yu @ 2020-12-09 10:08 UTC (permalink / raw)
  To: Huang Jianan, linux-erofs; +Cc: zhangshiming, guoweichao, linux-kernel

On 2020/12/9 10:39, Huang Jianan wrote:
> iblock indicates the number of i_blkbits-sized blocks rather than
> sectors.
> 
> In addition, considering buffer_head limits mapped size to 32-bits,
> should avoid using generic_block_bmap.
> 
> Fixes: 9da681e017a3 ("staging: erofs: support bmap")
> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
> Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> ---
>   fs/erofs/data.c | 30 ++++++++++--------------------
>   1 file changed, 10 insertions(+), 20 deletions(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 347be146884c..d6ea0a216b57 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
>   		submit_bio(bio);
>   }
>   
> -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;
> +	struct erofs_map_blocks map = {
> +		.m_la = blknr_to_addr(block),
> +	};
> +	sector_t blknr = 0;

It could be removed?

>   
>   	if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
>   		erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
>   
>   		if (block >> LOG_SECTORS_PER_BLOCK >= blks)
> -			return 0;

return 0;

> +			goto out;
>   	}
>   
> -	return generic_block_bmap(mapping, block, erofs_get_block);
> +	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
> +		blknr = erofs_blknr(map.m_pa);

return erofs_blknr(map.m_pa);

> +
> +out:
> +	return blknr;

return 0;

Anyway, LGTM.

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] erofs: avoid using generic_block_bmap
  2020-12-09 10:08 ` Chao Yu
@ 2020-12-09 11:39   ` Gao Xiang
  2020-12-09 11:54     ` Huang Jianan
  0 siblings, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2020-12-09 11:39 UTC (permalink / raw)
  To: Huang Jianan; +Cc: guoweichao, linux-erofs, zhangshiming, linux-kernel

Hi Jianan,

On Wed, Dec 09, 2020 at 06:08:41PM +0800, Chao Yu wrote:
> On 2020/12/9 10:39, Huang Jianan wrote:
> > iblock indicates the number of i_blkbits-sized blocks rather than
> > sectors.
> > 
> > In addition, considering buffer_head limits mapped size to 32-bits,
> > should avoid using generic_block_bmap.
> > 
> > Fixes: 9da681e017a3 ("staging: erofs: support bmap")
> > Signed-off-by: Huang Jianan <huangjianan@oppo.com>
> > Signed-off-by: Guo Weichao <guoweichao@oppo.com>

Could you send out an updated version? I might get a point to freeze
dev branch since it needs some time on linux-next....

Thanks,
Gao Xiang

> > ---
> >   fs/erofs/data.c | 30 ++++++++++--------------------
> >   1 file changed, 10 insertions(+), 20 deletions(-)
> > 
> > diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> > index 347be146884c..d6ea0a216b57 100644
> > --- a/fs/erofs/data.c
> > +++ b/fs/erofs/data.c
> > @@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
> >   		submit_bio(bio);
> >   }
> > -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;
> > +	struct erofs_map_blocks map = {
> > +		.m_la = blknr_to_addr(block),
> > +	};
> > +	sector_t blknr = 0;
> 
> It could be removed?
> 
> >   	if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
> >   		erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
> >   		if (block >> LOG_SECTORS_PER_BLOCK >= blks)
> > -			return 0;
> 
> return 0;
> 
> > +			goto out;
> >   	}
> > -	return generic_block_bmap(mapping, block, erofs_get_block);
> > +	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
> > +		blknr = erofs_blknr(map.m_pa);
> 
> return erofs_blknr(map.m_pa);
> 
> > +
> > +out:
> > +	return blknr;
> 
> return 0;
> 
> Anyway, LGTM.
> 
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> 
> Thanks,
> 
> >   }
> >   /* for uncompressed (aligned) files and raw access for other files */
> > 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4] erofs: avoid using generic_block_bmap
  2020-12-09 11:39   ` Gao Xiang
@ 2020-12-09 11:54     ` Huang Jianan
  0 siblings, 0 replies; 5+ messages in thread
From: Huang Jianan @ 2020-12-09 11:54 UTC (permalink / raw)
  To: Gao Xiang, Chao Yu; +Cc: zhangshiming, linux-erofs, guoweichao, linux-kernel

Thanks for review, i will update it soon.

在 2020/12/9 19:39, Gao Xiang 写道:
> Hi Jianan,
>
> On Wed, Dec 09, 2020 at 06:08:41PM +0800, Chao Yu wrote:
>> On 2020/12/9 10:39, Huang Jianan wrote:
>>> iblock indicates the number of i_blkbits-sized blocks rather than
>>> sectors.
>>>
>>> In addition, considering buffer_head limits mapped size to 32-bits,
>>> should avoid using generic_block_bmap.
>>>
>>> Fixes: 9da681e017a3 ("staging: erofs: support bmap")
>>> Signed-off-by: Huang Jianan <huangjianan@oppo.com>
>>> Signed-off-by: Guo Weichao <guoweichao@oppo.com>
> Could you send out an updated version? I might get a point to freeze
> dev branch since it needs some time on linux-next....
>
> Thanks,
> Gao Xiang
>
>>> ---
>>>    fs/erofs/data.c | 30 ++++++++++--------------------
>>>    1 file changed, 10 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
>>> index 347be146884c..d6ea0a216b57 100644
>>> --- a/fs/erofs/data.c
>>> +++ b/fs/erofs/data.c
>>> @@ -312,36 +312,26 @@ static void erofs_raw_access_readahead(struct readahead_control *rac)
>>>    		submit_bio(bio);
>>>    }
>>> -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;
>>> +	struct erofs_map_blocks map = {
>>> +		.m_la = blknr_to_addr(block),
>>> +	};
>>> +	sector_t blknr = 0;
>> It could be removed?
>>
>>>    	if (EROFS_I(inode)->datalayout == EROFS_INODE_FLAT_INLINE) {
>>>    		erofs_blk_t blks = i_size_read(inode) >> LOG_BLOCK_SIZE;
>>>    		if (block >> LOG_SECTORS_PER_BLOCK >= blks)
>>> -			return 0;
>> return 0;
>>
>>> +			goto out;
>>>    	}
>>> -	return generic_block_bmap(mapping, block, erofs_get_block);
>>> +	if (!erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW))
>>> +		blknr = erofs_blknr(map.m_pa);
>> return erofs_blknr(map.m_pa);
>>
>>> +
>>> +out:
>>> +	return blknr;
>> return 0;
>>
>> Anyway, LGTM.
>>
>> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>>
>> Thanks,
>>
>>>    }
>>>    /* for uncompressed (aligned) files and raw access for other files */
>>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-09 11:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  2:39 [PATCH v4] erofs: avoid using generic_block_bmap Huang Jianan
2020-12-09  2:46 ` Gao Xiang
2020-12-09 10:08 ` Chao Yu
2020-12-09 11:39   ` Gao Xiang
2020-12-09 11:54     ` Huang Jianan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).