linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] erofs: fix wrong address in erofs_get_block
@ 2020-12-08  9:31 Huang Jianan
  2020-12-08  9:48 ` Chao Yu
  0 siblings, 1 reply; 5+ messages in thread
From: Huang Jianan @ 2020-12-08  9:31 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..aad3fb68d6c8 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 = 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] 5+ messages in thread

* Re: [PATCH v2] erofs: fix wrong address in erofs_get_block
  2020-12-08  9:31 [PATCH v2] erofs: fix wrong address in erofs_get_block Huang Jianan
@ 2020-12-08  9:48 ` Chao Yu
  2020-12-08 10:35   ` Gao Xiang
  2020-12-08 13:07   ` Huang Jianan
  0 siblings, 2 replies; 5+ messages in thread
From: Chao Yu @ 2020-12-08  9:48 UTC (permalink / raw)
  To: Huang Jianan, linux-erofs; +Cc: guoweichao, zhangshiming

On 2020/12/8 17:31, 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.

Thanks for the fix, I was misled by sector_t type...

What about avoiding using generic_block_bmap() which uses buffer_head
structure, it limits mapped size to 32-bits:

https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=b876f4c94c3d1688edea021d45a528571499e0b9

Thanks,

> 
> 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..aad3fb68d6c8 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 = 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;
>   }
> 

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

* Re: [PATCH v2] erofs: fix wrong address in erofs_get_block
  2020-12-08  9:48 ` Chao Yu
@ 2020-12-08 10:35   ` Gao Xiang
  2020-12-08 13:09     ` Huang Jianan
  2020-12-08 13:07   ` Huang Jianan
  1 sibling, 1 reply; 5+ messages in thread
From: Gao Xiang @ 2020-12-08 10:35 UTC (permalink / raw)
  To: Huang Jianan; +Cc: zhangshiming, linux-erofs, guoweichao

On Tue, Dec 08, 2020 at 05:48:10PM +0800, Chao Yu wrote:
> On 2020/12/8 17:31, 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.
> 
> Thanks for the fix, I was misled by sector_t type...
> 
> What about avoiding using generic_block_bmap() which uses buffer_head
> structure, it limits mapped size to 32-bits:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=b876f4c94c3d1688edea021d45a528571499e0b9

Also a minor thing is to Cc: LKML <linux-kernel@vger.kernel.org>
in the next version and for all kernel patches, which is needed
for upstreaming.

(quite closing to merging window...)

Thanks,
Gao Xiang

> 
> Thanks,


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

* Re: [PATCH v2] erofs: fix wrong address in erofs_get_block
  2020-12-08  9:48 ` Chao Yu
  2020-12-08 10:35   ` Gao Xiang
@ 2020-12-08 13:07   ` Huang Jianan
  1 sibling, 0 replies; 5+ messages in thread
From: Huang Jianan @ 2020-12-08 13:07 UTC (permalink / raw)
  To: Chao Yu, linux-erofs; +Cc: guoweichao, zhangshiming


在 2020/12/8 17:48, Chao Yu 写道:
> On 2020/12/8 17:31, 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.
>
> Thanks for the fix, I was misled by sector_t type...
>
> What about avoiding using generic_block_bmap() which uses buffer_head
> structure, it limits mapped size to 32-bits:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=b876f4c94c3d1688edea021d45a528571499e0b9 
>
>
> Thanks,
>
Thanks for the suggestion, I will send a patch v3 to drop 
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 | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/erofs/data.c b/fs/erofs/data.c
>> index 347be146884c..aad3fb68d6c8 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 = 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;
>>   }
>>

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

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


在 2020/12/8 18:35, Gao Xiang 写道:
> On Tue, Dec 08, 2020 at 05:48:10PM +0800, Chao Yu wrote:
>> On 2020/12/8 17:31, 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.
>> Thanks for the fix, I was misled by sector_t type...
>>
>> What about avoiding using generic_block_bmap() which uses buffer_head
>> structure, it limits mapped size to 32-bits:
>>
>> https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev-test&id=b876f4c94c3d1688edea021d45a528571499e0b9
> Also a minor thing is to Cc: LKML <linux-kernel@vger.kernel.org>
> in the next version and for all kernel patches, which is needed
> for upstreaming.
>
> (quite closing to merging window...)
>
> Thanks,
> Gao Xiang
>
>> Thanks,
Thanks, good to learn about this.

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08  9:31 [PATCH v2] erofs: fix wrong address in erofs_get_block Huang Jianan
2020-12-08  9:48 ` Chao Yu
2020-12-08 10:35   ` Gao Xiang
2020-12-08 13:09     ` Huang Jianan
2020-12-08 13:07   ` 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).