diff mbox series

[6/7] xfs: fix fork selection in xfs_find_trim_cow_extent

Message ID 20181001123741.32005-7-hch@lst.de (mailing list archive)
State Superseded, archived
Headers show
Series [1/7] xfs: remove XFS_IO_INVALID | expand

Commit Message

Christoph Hellwig Oct. 1, 2018, 12:37 p.m. UTC
We should want to write directly into the data fork for blocks that don't
have an extent in the COW fork covering them yet.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_reflink.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Brian Foster Oct. 1, 2018, 2:27 p.m. UTC | #1
On Mon, Oct 01, 2018 at 05:37:40AM -0700, Christoph Hellwig wrote:
> We should want to write directly into the data fork for blocks that don't
> have an extent in the COW fork covering them yet.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/xfs_reflink.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 1e39a7d21c7e..ead35209ffae 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -369,9 +369,13 @@ xfs_find_trim_cow_extent(
>  	 * If we don't find an overlapping extent, trim the range we need to
>  	 * allocate to fit the hole we found.
>  	 */
> -	if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got) ||
> -	    got.br_startoff > offset_fsb)
> +	if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got))
> +		got.br_startoff = offset_fsb + count_fsb;
> +	if (got.br_startoff > offset_fsb) {
> +		xfs_trim_extent(imap, imap->br_startoff,
> +				got.br_startoff - imap->br_startoff);
>  		return xfs_reflink_trim_around_shared(ip, imap, shared);
> +	}
>  
>  	*shared = true;
>  	if (isnullstartblock(got.br_startblock)) {
> -- 
> 2.19.0
>
diff mbox series

Patch

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 1e39a7d21c7e..ead35209ffae 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -369,9 +369,13 @@  xfs_find_trim_cow_extent(
 	 * If we don't find an overlapping extent, trim the range we need to
 	 * allocate to fit the hole we found.
 	 */
-	if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got) ||
-	    got.br_startoff > offset_fsb)
+	if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got))
+		got.br_startoff = offset_fsb + count_fsb;
+	if (got.br_startoff > offset_fsb) {
+		xfs_trim_extent(imap, imap->br_startoff,
+				got.br_startoff - imap->br_startoff);
 		return xfs_reflink_trim_around_shared(ip, imap, shared);
+	}
 
 	*shared = true;
 	if (isnullstartblock(got.br_startblock)) {