• Brian Foster's avatar
    xfs: move bmbt owner change to last step of extent swap · cbf715dc
    Brian Foster authored
    commit 6fb10d6d upstream.
    
    The extent swap operation currently resets bmbt block owners before
    the inode forks are swapped. The bmbt buffers are marked as ordered
    so they do not have to be physically logged in the transaction.
    
    This use of ordered buffers is not safe as bmbt buffers may have
    been previously physically logged. The bmbt owner change algorithm
    needs to be updated to physically log buffers that are already dirty
    when/if they are encountered. This means that an extent swap will
    eventually require multiple rolling transactions to handle large
    btrees. In addition, all inode related changes must be logged before
    the bmbt owner change scan begins and can roll the transaction for
    the first time to preserve fs consistency via log recovery.
    
    In preparation for such fixes to the bmbt owner change algorithm,
    refactor the bmbt scan out of the extent fork swap code to the last
    operation before the transaction is committed. Update
    xfs_swap_extent_forks() to only set the inode log flags when an
    owner change scan is necessary. Update xfs_swap_extents() to trigger
    the owner change based on the inode log flags. Note that since the
    owner change now occurs after the extent fork swap, the inode btrees
    must be fixed up with the inode number of the current inode (similar
    to log recovery).
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    cbf715dc
xfs_bmap_util.c 56.3 KB