Re: [PATCH 2/2] xfs: don't unconditionally clear the reflink flag on zero-block files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 04, 2017 at 08:49:44AM -0700, Darrick J. Wong wrote:
> If we have speculative cow preallocations hanging around in the cow
> fork, don't let a truncate operation clear the reflink flag because if
> we do then there's a chance we'll forget to free those extents when we
> destroy the incore inode.
> 
> Reported-by: Amir Goldstein <amir73il@xxxxxxxxx>
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

Looks good,
Reviewed-by: Carlos Maiolino <cmaiolino@xxxxxxxxxx>

> ---
>  fs/xfs/xfs_inode.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 5599dda..4ec5b7f 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -1624,10 +1624,12 @@ xfs_itruncate_extents(
>  		goto out;
>  
>  	/*
> -	 * Clear the reflink flag if we truncated everything.
> +	 * Clear the reflink flag if there are no data fork blocks and
> +	 * there are no extents staged in the cow fork.
>  	 */
> -	if (ip->i_d.di_nblocks == 0 && xfs_is_reflink_inode(ip)) {
> -		ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
> +	if (xfs_is_reflink_inode(ip) && ip->i_cnextents == 0) {
> +		if (ip->i_d.di_nblocks == 0)
> +			ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
>  		xfs_inode_clear_cowblocks_tag(ip);
>  	}
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Carlos
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux