[PATCH 20/25] ext4: support large block size in __ext4_block_zero_page_range()

libaokun@huaweicloud.com posted 25 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH 20/25] ext4: support large block size in __ext4_block_zero_page_range()
Posted by libaokun@huaweicloud.com 3 months, 2 weeks ago
From: Zhihao Cheng <chengzhihao1@huawei.com>

Use the EXT4_P_TO_LBLK() macro to convert folio indexes to blocks to avoid
negative left shifts after supporting blocksize greater than PAGE_SIZE.

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Zhang Yi <yi.zhang@huawei.com>
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index ce48cc6780a3..b3fa29923a1d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -4066,7 +4066,7 @@ static int __ext4_block_zero_page_range(handle_t *handle,
 
 	blocksize = inode->i_sb->s_blocksize;
 
-	iblock = folio->index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
+	iblock = EXT4_P_TO_LBLK(inode, folio->index);
 
 	bh = folio_buffers(folio);
 	if (!bh)
-- 
2.46.1
Re: [PATCH 20/25] ext4: support large block size in __ext4_block_zero_page_range()
Posted by Jan Kara 3 months ago
On Sat 25-10-25 11:22:16, libaokun@huaweicloud.com wrote:
> From: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> Use the EXT4_P_TO_LBLK() macro to convert folio indexes to blocks to avoid
> negative left shifts after supporting blocksize greater than PAGE_SIZE.
> 
> Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
> Signed-off-by: Baokun Li <libaokun1@huawei.com>
> Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/ext4/inode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index ce48cc6780a3..b3fa29923a1d 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -4066,7 +4066,7 @@ static int __ext4_block_zero_page_range(handle_t *handle,
>  
>  	blocksize = inode->i_sb->s_blocksize;
>  
> -	iblock = folio->index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits);
> +	iblock = EXT4_P_TO_LBLK(inode, folio->index);
>  
>  	bh = folio_buffers(folio);
>  	if (!bh)
> -- 
> 2.46.1
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR