xfs: update freeblocks counter after extent deletion
authorBrian Foster <bfoster@redhat.com>
Tue, 15 Mar 2016 00:42:46 +0000 (11:42 +1100)
committerDave Chinner <david@fromorbit.com>
Tue, 15 Mar 2016 00:42:46 +0000 (11:42 +1100)
commitb2706a05bad36c0a826493c6ba84c8a9caf8a3ae
treed6efbf12931b4b110a619203741c192e7a7cf4e0
parent801cc4e17a34c32e1527827292fac9cec5d3393b
xfs: update freeblocks counter after extent deletion

xfs_bunmapi() currently updates the fdblocks counter, unreserves quota,
etc. before the extent is deleted by xfs_bmap_del_extent(). The function
has problems dividing up the indirect reserved blocks for scenarios
where a single delalloc extent is split in two. Particularly, there
aren't always enough blocks reserved for multiple extents in a single
extent reservation.

The solution to this problem is to allow the extent removal code to
steal from the deleted extent to meet indirect reservation requirements.
Move the block of code in xfs_bmapi() that updates the fdblocks counter
to after the call to xfs_bmap_del_extent() to allow the codepath to
update the extent record before the free blocks are accounted. Also,
reshuffle the code slightly so the delalloc accounting occurs near the
xfs_bmap_del_extent() call to provide context for the comments.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_bmap.c