diff mbox series

[RFC,1/2] xfs: Fix xfs_flush_unmap_range() range for RT

Message ID 20240503140337.3426159-2-john.g.garry@oracle.com (mailing list archive)
State Superseded
Headers show
Series xfs: fallocate RT flush unmap range fixes | expand

Commit Message

John Garry May 3, 2024, 2:03 p.m. UTC
Currently xfs_flush_unmap_range() does a flush for full FS blocks. Extend
this to cover full RT extents so that any range overlap with start/end of
the modification are clean and idle. 

This code change is originally from Dave Chinner.

Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 fs/xfs/xfs_bmap_util.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig May 7, 2024, 6:36 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Darrick J. Wong May 7, 2024, 8:58 p.m. UTC | #2
On Fri, May 03, 2024 at 02:03:36PM +0000, John Garry wrote:
> Currently xfs_flush_unmap_range() does a flush for full FS blocks. Extend
> this to cover full RT extents so that any range overlap with start/end of
> the modification are clean and idle. 
> 
> This code change is originally from Dave Chinner.
> 
> Signed-off-by: John Garry <john.g.garry@oracle.com>
> ---
>  fs/xfs/xfs_bmap_util.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index 2e6f08198c07..da67c52d5f94 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -802,12 +802,16 @@ xfs_flush_unmap_range(
>  	xfs_off_t		offset,
>  	xfs_off_t		len)
>  {
> -	struct xfs_mount	*mp = ip->i_mount;
>  	struct inode		*inode = VFS_I(ip);
>  	xfs_off_t		rounding, start, end;
>  	int			error;
>  
> -	rounding = max_t(xfs_off_t, mp->m_sb.sb_blocksize, PAGE_SIZE);
> +	/*
> +	 * Make sure we extend the flush out to extent alignment
> +	 * boundaries so any extent range overlapping the start/end
> +	 * of the modification we are about to do is clean and idle.
> +	 */
> +	rounding = max_t(xfs_off_t, xfs_inode_alloc_unitsize(ip), PAGE_SIZE);
>  	start = round_down(offset, rounding);

round_down requires the divisor to be a power of two.

--D

>  	end = round_up(offset + len, rounding) - 1;
>  
> -- 
> 2.31.1
> 
>
John Garry May 8, 2024, 6:39 a.m. UTC | #3
On 07/05/2024 21:58, Darrick J. Wong wrote:
>> -	rounding = max_t(xfs_off_t, mp->m_sb.sb_blocksize, PAGE_SIZE);
>> +	/*
>> +	 * Make sure we extend the flush out to extent alignment
>> +	 * boundaries so any extent range overlapping the start/end
>> +	 * of the modification we are about to do is clean and idle.
>> +	 */
>> +	rounding = max_t(xfs_off_t, xfs_inode_alloc_unitsize(ip), PAGE_SIZE);
>>   	start = round_down(offset, rounding);
> round_down requires the divisor to be a power of two.

well spotted, and so the round_up() call, below, also needs fixing.

> 
> --D
> 
>>   	end = round_up(offset + len, rounding) - 1;
John Garry May 8, 2024, 6:40 a.m. UTC | #4
On 07/05/2024 21:58, Darrick J. Wong wrote:
>> -	rounding = max_t(xfs_off_t, mp->m_sb.sb_blocksize, PAGE_SIZE);
>> +	/*
>> +	 * Make sure we extend the flush out to extent alignment
>> +	 * boundaries so any extent range overlapping the start/end
>> +	 * of the modification we are about to do is clean and idle.
>> +	 */
>> +	rounding = max_t(xfs_off_t, xfs_inode_alloc_unitsize(ip), PAGE_SIZE);
>>   	start = round_down(offset, rounding);
> round_down requires the divisor to be a power of two.

well spotted, and so the round_up() call, below, also needs fixing.

> 
> --D
> 
>>   	end = round_up(offset + len, rounding) - 1;
diff mbox series

Patch

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 2e6f08198c07..da67c52d5f94 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -802,12 +802,16 @@  xfs_flush_unmap_range(
 	xfs_off_t		offset,
 	xfs_off_t		len)
 {
-	struct xfs_mount	*mp = ip->i_mount;
 	struct inode		*inode = VFS_I(ip);
 	xfs_off_t		rounding, start, end;
 	int			error;
 
-	rounding = max_t(xfs_off_t, mp->m_sb.sb_blocksize, PAGE_SIZE);
+	/*
+	 * Make sure we extend the flush out to extent alignment
+	 * boundaries so any extent range overlapping the start/end
+	 * of the modification we are about to do is clean and idle.
+	 */
+	rounding = max_t(xfs_off_t, xfs_inode_alloc_unitsize(ip), PAGE_SIZE);
 	start = round_down(offset, rounding);
 	end = round_up(offset + len, rounding) - 1;