On Fri, Jan 18, 2019 at 03:59:37AM -0800, Christoph Hellwig wrote: > xfs_bmapi_write will always do a xfs_iext_lookup_extent for the > passed in blocks anyway. So this trimming logic should move into > xfs_bmapi_write to ensure it does the right thing, instead of papering > over the logic in xfs_bmapi_write in the caller with another lookup. > > I think the improved XFS_BMAPI_DELALLOC handling in this patch: > > http://git.infradead.org/users/hch/xfs.git/commitdiff/553fed9ce7695df081779c6a9a205af4142b2a06 > > is the right answer, as writeback really should only ever convert > existing delalloc extents, and I'd much rather rely on that rather than > piling hacks of hacks to feed the right range into a function that must > do a lookup in the extent tree anyway. FYI, here is a tree that rebases my patches on top of your (minus this one) and also drops the internal i_size checks, although it still keeps the initial one for the truncate fast path. Testing is still ongoing, and for the writeback issue you probably only need the first three of my patches: http://git.infradead.org/users/hch/xfs.git/shortlog/refs/heads/xfs-mapping-validation