From: Brian Foster <bfoster@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: clm@fb.com, xfs@oss.sgi.com
Subject: Re: [PATCH 6/6] xfs: xfs_file_collapse_range is delalloc challenged
Date: Thu, 21 Aug 2014 09:09:25 -0400 [thread overview]
Message-ID: <20140821130924.GF64112@bfoster.bfoster> (raw)
In-Reply-To: <1408597754-13526-7-git-send-email-david@fromorbit.com>
On Thu, Aug 21, 2014 at 03:09:14PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> If we have delalloc extents on a file before we run a collapse range
> opertaion, we sync the range that we are going to collapse to
> convert delalloc extents in that region to real extents to simplify
> the shift operation.
>
> However, the shift operation then assumes that the extent list is
> not going to change as it iterates over the extent list moving
> things about. Unfortunately, this isn't true because we can't hold
> the ILOCK over all the operations. We can prevent new IO from
> modifying the extent list by holding the IOLOCK, but that doesn't
> prevent writeback from running....
>
> And when writeback runs, it can convert delalloc extents is the
> range of the file prior to the region being collapsed, and this
> changes the indexes of all the extents in the file. That causes the
> collapse range operation to Go Bad.
>
> The right fix is to rewrite the extent shift operation not to be
> dependent on the extent list not changing across the entire
> operation, but this is a fairly significant piece of work to do.
> Hence, as a short-term workaround for the problem, sync the entire
> file before starting a collapse operation to remove all delalloc
> ranges from the file and so avoid the problem of concurrent
> writeback changing the extent list.
>
> Diagnosed-and-Reported-by: Brian Foster <bfoster@redhat.com>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/xfs_bmap_util.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
> index c53cc03..035041d 100644
> --- a/fs/xfs/xfs_bmap_util.c
> +++ b/fs/xfs/xfs_bmap_util.c
> @@ -1460,6 +1460,19 @@ xfs_collapse_file_space(
> start_fsb = XFS_B_TO_FSB(mp, offset + len);
> shift_fsb = XFS_B_TO_FSB(mp, len);
>
> + /*
> + * writeback the entire file to prevent concurrent writeback of ranges
> + * outside the collapsing region from changing the extent list.
> + *
> + * XXX: This is a temporary fix until the extent shift loop below is
> + * converted to use offsets and lookups within the ILOCK rather than
> + * carrying around the index into the extent list for the next
> + * iteration.
> + */
> + error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
> + if (error)
> + return error;
> +
> error = xfs_free_file_space(ip, offset, len);
> if (error)
> return error;
> --
> 2.0.0
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2014-08-21 13:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 5:09 [PATCH 0/6] xfs: direct IO invalidation and related fixes Dave Chinner
2014-08-21 5:09 ` [PATCH 1/6] xfs: mmap write/read leaves bad state on pages Dave Chinner
2014-08-21 12:48 ` Brian Foster
2014-08-21 22:38 ` Dave Chinner
2014-08-21 13:08 ` Christoph Hellwig
2014-08-21 13:54 ` Anton Altaparmakov
2014-08-21 15:21 ` Chris Mason
2014-08-21 19:56 ` Jan Kara
2014-08-21 22:33 ` Dave Chinner
2014-08-26 16:06 ` Jan Kara
2014-08-26 21:38 ` Dave Chinner
2014-08-21 5:09 ` [PATCH 2/6] xfs: don't zero partial page cache pages during O_DIRECT writes Dave Chinner
2014-08-21 13:08 ` Brian Foster
2014-08-21 5:09 ` [PATCH 3/6] " Dave Chinner
2014-08-21 13:09 ` Brian Foster
2014-08-21 5:09 ` [PATCH 4/6] xfs: use ranged writeback and invalidation for direct IO Dave Chinner
2014-08-21 13:09 ` Brian Foster
2014-08-21 5:09 ` [PATCH 5/6] xfs: don't log inode unless extent shift makes extent modifications Dave Chinner
2014-08-21 5:09 ` [PATCH 6/6] xfs: xfs_file_collapse_range is delalloc challenged Dave Chinner
2014-08-21 13:09 ` Brian Foster [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=20140821130924.GF64112@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=clm@fb.com \
--cc=david@fromorbit.com \
--cc=xfs@oss.sgi.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox