diff mbox series

btrfs: Use round_down while calculating start position in btrfs_dirty_pages()

Message ID 20201014145545.10878-1-rgoldwyn@suse.de (mailing list archive)
State New, archived
Headers show
Series btrfs: Use round_down while calculating start position in btrfs_dirty_pages() | expand

Commit Message

Goldwyn Rodrigues Oct. 14, 2020, 2:55 p.m. UTC
From: Goldwyn Rodrigues <rgoldwyn@suse.com>

round_down looks prettier than the bit mask operations.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---
 fs/btrfs/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov Oct. 14, 2020, 5:49 p.m. UTC | #1
On 14.10.20 г. 17:55 ч., Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> round_down looks prettier than the bit mask operations.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Qu Wenruo Oct. 15, 2020, 7:26 a.m. UTC | #2
On 2020/10/14 下午10:55, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> round_down looks prettier than the bit mask operations.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
> index 0ff659455b1e..6e52e2360d8e 100644
> --- a/fs/btrfs/file.c
> +++ b/fs/btrfs/file.c
> @@ -514,7 +514,7 @@ int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
>  	loff_t isize = i_size_read(&inode->vfs_inode);
>  	unsigned int extra_bits = 0;
>  
> -	start_pos = pos & ~((u64) fs_info->sectorsize - 1);
> +	start_pos = round_down(pos, fs_info->sectorsize);
>  	num_bytes = round_up(write_bytes + pos - start_pos,
>  			     fs_info->sectorsize);
>  
>
David Sterba Oct. 16, 2020, 3:22 p.m. UTC | #3
On Wed, Oct 14, 2020 at 09:55:44AM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> round_down looks prettier than the bit mask operations.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

1 and 2 added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 0ff659455b1e..6e52e2360d8e 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -514,7 +514,7 @@  int btrfs_dirty_pages(struct btrfs_inode *inode, struct page **pages,
 	loff_t isize = i_size_read(&inode->vfs_inode);
 	unsigned int extra_bits = 0;
 
-	start_pos = pos & ~((u64) fs_info->sectorsize - 1);
+	start_pos = round_down(pos, fs_info->sectorsize);
 	num_bytes = round_up(write_bytes + pos - start_pos,
 			     fs_info->sectorsize);