• Brian Foster's avatar
    xfs: update freeblocks counter after extent deletion · b2706a05
    Brian Foster authored
    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: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
    
    b2706a05
xfs_bmap.c 172 KB