• Brian Foster's avatar
    xfs: rework collapse range into an atomic operation · 211683b2
    Brian Foster authored
    The collapse range operation uses a unique transaction and ilock
    cycle for the hole punch and each extent shift iteration of the
    overall operation. While the hole punch is safe as a separate
    operation due to the iolock, cycling the ilock after each extent
    shift is risky w.r.t. concurrent operations, similar to insert range.
    
    To avoid this problem, make collapse range atomic with respect to
    ilock. Hold the ilock across the entire operation, replace the
    individual transactions with a single rolling transaction sequence
    and finish dfops on each iteration to perform pending frees and roll
    the transaction. Remove the unnecessary quota reservation as
    collapse range can only ever merge extents (and thus remove extent
    records and potentially free bmap blocks). The dfops call
    automatically relogs the inode to keep it moving in the log. This
    guarantees that nothing else can change the extent mapping of an
    inode while a collapse range operation is in progress.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    211683b2
xfs_bmap_util.c 46.2 KB