All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH]  xfs: handle racy AIO in xfs_reflink_end_cow
Date: Tue, 3 Oct 2017 10:26:03 -0700	[thread overview]
Message-ID: <20171003172603.GD6503@magnolia> (raw)
In-Reply-To: <20171003143416.12188-1-hch@lst.de>

On Tue, Oct 03, 2017 at 04:34:16PM +0200, Christoph Hellwig wrote:
> If we got two AIO writes into a COW area the second one might not have any
> COW extents left to convert.  Handle that case gracefully instead of
> triggering an assert or accessing beyond the bounds of the extent list.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok, will test.
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

> ---
>  fs/xfs/xfs_reflink.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 3246815c24d6..37e603bf1591 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -736,7 +736,13 @@ xfs_reflink_end_cow(
>  	/* If there is a hole at end_fsb - 1 go to the previous extent */
>  	if (!xfs_iext_lookup_extent(ip, ifp, end_fsb - 1, &idx, &got) ||
>  	    got.br_startoff > end_fsb) {
> -		ASSERT(idx > 0);
> +		/*
> +		 * In case of racing, overlapping AIO writes no COW extents
> +		 * might be left by the time I/O completes for the loser of
> +		 * the race.  In that case we are done.
> +		 */
> +		if (idx <= 0)
> +			goto out_cancel;
>  		xfs_iext_get_extent(ifp, --idx, &got);
>  	}
>  
> @@ -809,6 +815,7 @@ xfs_reflink_end_cow(
>  
>  out_defer:
>  	xfs_defer_cancel(&dfops);
> +out_cancel:
>  	xfs_trans_cancel(tp);
>  	xfs_iunlock(ip, XFS_ILOCK_EXCL);
>  out:
> -- 
> 2.14.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2017-10-03 17:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 14:34 [PATCH] xfs: handle racy AIO in xfs_reflink_end_cow Christoph Hellwig
2017-10-03 17:26 ` Darrick J. Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171003172603.GD6503@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.