On Fri, Feb 01, 2019 at 09:32:55AM -0500, Brian Foster wrote: > The writeback delalloc conversion code is racy with respect to > changes in the currently cached file mapping. This stems from the > fact that the bmapi allocation code requires a file range to > allocate and the writeback conversion code assumes the range of the > currently cached mapping is still valid with respect to the fork. It > may not be valid, however, because the ilock is cycled (potentially > multiple times) between the time the cached mapping was populated > and the delalloc conversion occurs. > > To facilitate a solution to this problem, create a new > xfs_bmapi_delalloc() wrapper to xfs_bmapi_write() that takes a file > (FSB) offset and attempts to allocate whatever delalloc extent backs > the offset. Use a new bmapi flag to cause xfs_bmapi_write() to set > the range based on the extent backing the bno parameter unless bno > lands in a hole. If bno does land in a hole, fall back to the > current behavior (which may result in an error or quietly skipping > holes in the specified range depending on other parameters). This > patch does not change behavior. > > [hch: Rename helper function and tweak interface.] > > Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx> > Signed-off-by: Christoph Hellwig <hch@xxxxxx> Looks good. Feel free to drop the [hch: ] note and replace my signoff for that with a: Reviewed-by: Christoph Hellwig <hch@xxxxxx> for the whole patch.