]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit - fs/xfs/xfs_reflink.c
xfs: clean up cow fork reservation and tag inodes correctly
authorBrian Foster <bfoster@redhat.com>
Mon, 28 Nov 2016 03:57:42 +0000 (14:57 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 28 Nov 2016 03:57:42 +0000 (14:57 +1100)
commit0260d8ff5f76617e3a55a1c471383ecb4404c3ad
tree24b2765b43a6d7234d8df25ec39c35902599444b
parent974ae922efd93b07b6cdf989ae959883f6f05fd8
xfs: clean up cow fork reservation and tag inodes correctly

COW fork reservation is implemented via delayed allocation. The code is
modeled after the traditional delalloc allocation code, but is slightly
different in terms of how preallocation occurs. Rather than post-eof
speculative preallocation, COW fork preallocation is implemented via a
COW extent size hint that is designed to minimize fragmentation as a
reflinked file is split over time.

xfs_reflink_reserve_cow() still uses logic that is oriented towards
dealing with post-eof speculative preallocation, however, and is stale
or not necessarily correct. First, the EOF alignment to the COW extent
size hint is implemented in xfs_bmapi_reserve_delalloc() (which does so
correctly by aligning the start and end offsets) and so is not necessary
in xfs_reflink_reserve_cow(). The backoff and retry logic on ENOSPC is
also ineffective for the same reason, as xfs_bmapi_reserve_delalloc()
will simply perform the same allocation request on the retry. Finally,
since the COW extent size hint aligns the start and end offset of the
range to allocate, the end_fsb != orig_end_fsb logic is not sufficient.
Indeed, if a write request happens to end on an aligned offset, it is
possible that we do not tag the inode for COW preallocation even though
xfs_bmapi_reserve_delalloc() may have preallocated at the start offset.

Kill the unnecessary, duplicate code in xfs_reflink_reserve_cow().
Remove the inode tag logic as well since xfs_bmapi_reserve_delalloc()
has been updated to tag the inode correctly.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_reflink.c