All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs: fix wrong address in erofs_get_block
@ 2020-12-08  8:47 Huang Jianan
  2020-12-08  9:03 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Huang Jianan @ 2020-12-08  8:47 UTC (permalink / raw)
  To: linux-erofs; +Cc: guoweichao, zhangshiming

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

If the data has a disk mapping, map_bh should be used to read the
correct data from the device.

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 347be146884c..1415fee10180 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -316,7 +316,7 @@ 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,
+		.m_la = iblock << blknr_to_addr(iblock),
 	};
 	int err;
 
@@ -325,7 +325,7 @@ static int erofs_get_block(struct inode *inode, sector_t iblock,
 		return err;
 
 	if (map.m_flags & EROFS_MAP_MAPPED)
-		bh->b_blocknr = erofs_blknr(map.m_pa);
+		map_bh(bh, inode->i_sb, erofs_blknr(map.m_pa));
 
 	return err;
 }
-- 
2.25.1


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

* Re: [PATCH] erofs: fix wrong address in erofs_get_block
  2020-12-08  8:47 [PATCH] erofs: fix wrong address in erofs_get_block Huang Jianan
@ 2020-12-08  9:03 ` Gao Xiang
  2020-12-08  9:25   ` Huang Jianan
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2020-12-08  9:03 UTC (permalink / raw)
  To: Huang Jianan; +Cc: guoweichao, linux-erofs, zhangshiming

Hi Jianan,

On Tue, Dec 08, 2020 at 04:47:50PM +0800, Huang Jianan wrote:
> iblock indicates the number of i_blkbits-sized blocks rather than
> sectors, fix it.
> 
> If the data has a disk mapping, map_bh should be used to read the
> correct data from the device.
> 
> 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 | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
> index 347be146884c..1415fee10180 100644
> --- a/fs/erofs/data.c
> +++ b/fs/erofs/data.c
> @@ -316,7 +316,7 @@ 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,
> +		.m_la = iblock << blknr_to_addr(iblock),

Sorry I don't get the point although I think the problem may exist....
I mean is that correct? since it equals to iblocks << (iblock * EROFS_BLKSIZE) ....

Thanks,
Gao Xiang


>  	};
>  	int err;
>  
> @@ -325,7 +325,7 @@ static int erofs_get_block(struct inode *inode, sector_t iblock,
>  		return err;
>  
>  	if (map.m_flags & EROFS_MAP_MAPPED)
> -		bh->b_blocknr = erofs_blknr(map.m_pa);
> +		map_bh(bh, inode->i_sb, erofs_blknr(map.m_pa));
>  
>  	return err;
>  }
> -- 
> 2.25.1
> 


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

* Re: [PATCH] erofs: fix wrong address in erofs_get_block
  2020-12-08  9:03 ` Gao Xiang
@ 2020-12-08  9:25   ` Huang Jianan
  0 siblings, 0 replies; 3+ messages in thread
From: Huang Jianan @ 2020-12-08  9:25 UTC (permalink / raw)
  To: Gao Xiang; +Cc: guoweichao, linux-erofs, zhangshiming

Hi Xiang,

sorry, it

在 2020/12/8 17:03, Gao Xiang 写道:
> Hi Jianan,
>
> On Tue, Dec 08, 2020 at 04:47:50PM +0800, Huang Jianan wrote:
>> iblock indicates the number of i_blkbits-sized blocks rather than
>> sectors, fix it.
>>
>> If the data has a disk mapping, map_bh should be used to read the
>> correct data from the device.
>>
>> 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 | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
>> index 347be146884c..1415fee10180 100644
>> --- a/fs/erofs/data.c
>> +++ b/fs/erofs/data.c
>> @@ -316,7 +316,7 @@ 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,
>> +		.m_la = iblock << blknr_to_addr(iblock),
> Sorry I don't get the point although I think the problem may exist....
> I mean is that correct? since it equals to iblocks << (iblock * EROFS_BLKSIZE) ....
>
> Thanks,
> Gao Xiang
>
Sorry, it should be :

.m_la = blknr_to_addr(iblock),

I will send patch v2 to fix this. 😅

>>   	};
>>   	int err;
>>   
>> @@ -325,7 +325,7 @@ static int erofs_get_block(struct inode *inode, sector_t iblock,
>>   		return err;
>>   
>>   	if (map.m_flags & EROFS_MAP_MAPPED)
>> -		bh->b_blocknr = erofs_blknr(map.m_pa);
>> +		map_bh(bh, inode->i_sb, erofs_blknr(map.m_pa));
>>   
>>   	return err;
>>   }
>> -- 
>> 2.25.1
>>

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

end of thread, other threads:[~2020-12-08  9:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08  8:47 [PATCH] erofs: fix wrong address in erofs_get_block Huang Jianan
2020-12-08  9:03 ` Gao Xiang
2020-12-08  9:25   ` Huang Jianan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.