• Brian Foster's avatar
    xfs: make deferred processing safe for embedded dfops · 03f4e4b2
    Brian Foster authored
    xfs_defer_finish() has a couple quirks that are not safe with
    respect to the upcoming internal dfops functionality. First,
    xfs_defer_finish() attaches the passed in dfops structure to
    ->t_dfops and caches and restores the original value. Second, it
    continues to use the initial dfops reference before and after the
    transaction roll.
    
    These behaviors assume that dop is an independent memory allocation
    from the transaction itself, which may not always be true once
    transactions begin to use an embedded dfops structure. In the latter
    model, dfops processing creates a new xfs_defer_ops structure with
    each transaction and the associated state is migrated across to the
    new transaction.
    
    Fix up xfs_defer_finish() to handle the possibility of the current
    dfops changing after a transaction roll. Since ->t_dfops is used
    unconditionally in this path, it is no longer necessary to
    attach/restore ->t_dfops and pass it explicitly down to
    xfs_defer_trans_roll(). Update dop in the latter function and the
    caller to ensure that it always refers to the current dfops
    structure.
    Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Reviewed-by: default avatarBill O'Donnell <billodo@redhat.com>
    Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    03f4e4b2
xfs_defer.c 16.9 KB