xfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real
authorChristoph Hellwig <hch@lst.de>
Fri, 3 Nov 2017 17:34:38 +0000 (10:34 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Mon, 6 Nov 2017 19:53:38 +0000 (11:53 -0800)
commit1bfd7618cbf2de630c845f60f5370671c2cd1c5d
treeca5e5871cf639baa91acc37860726b89648adb83
parent0dca060c2a5a83dc8bd28eb2d8b559bd33238175
xfs: don't create overlapping extents in xfs_bmap_add_extent_delay_real

Two cases in xfs_bmap_add_extent_delay_real currently insert a new
extent before updating the existing one that is being split.  While
this works fine with a simple extent list, a more complex tree can't
easily cope with overlapping extent.  Reshuffle the code a bit to update
the slot of the existing delalloc extent to the new real extent before
inserting the shortened delalloc extent before or after it.  This
avoids the overlapping extents while still allowing to update the
br_startblock field of the delalloc extent with the updated indirect
block reservation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_bmap.c