diff options
author | Brian Foster <bfoster@redhat.com> | 2018-07-11 22:26:13 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2018-07-11 22:26:13 -0700 |
commit | 4bcfa613a0582a9992a6c2af82273bd770103d12 (patch) | |
tree | 07b05f8a462387bc4a8935b0c64f478f9484a979 /fs/xfs/xfs_inode.c | |
parent | 6e702a5dcbe1d38cf479931dd2e2a3da884143f0 (diff) |
xfs: use ->t_dfops for all xfs_bunmapi() callers
Use ->t_dfops for all remaining xfs_bunmapi() callers. This prepares
the latter to no longer require a dfops parameter.
Note that xfs_itruncate_extents_flags() associates a local dfops
with a transaction provided from the caller. Since there are
multiple callers, set and reset ->t_dfops before the function
returns to avoid exposure of stack memory to the caller.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_inode.c')
-rw-r--r-- | fs/xfs/xfs_inode.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e1bc686b70b4..539d96201666 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -1545,6 +1545,7 @@ xfs_itruncate_extents_flags( { struct xfs_mount *mp = ip->i_mount; struct xfs_trans *tp = *tpp; + struct xfs_defer_ops *odfops = tp->t_dfops; struct xfs_defer_ops dfops; xfs_fsblock_t first_block; xfs_fileoff_t first_unmap_block; @@ -1584,9 +1585,10 @@ xfs_itruncate_extents_flags( unmap_len = last_block - first_unmap_block + 1; while (!done) { xfs_defer_init(&dfops, &first_block); + tp->t_dfops = &dfops; error = xfs_bunmapi(tp, ip, first_unmap_block, unmap_len, flags, XFS_ITRUNC_MAX_EXTENTS, &first_block, - &dfops, &done); + tp->t_dfops, &done); if (error) goto out_bmap_cancel; @@ -1594,8 +1596,8 @@ xfs_itruncate_extents_flags( * Duplicate the transaction that has the permanent * reservation and commit the old transaction. */ - xfs_defer_ijoin(&dfops, ip); - error = xfs_defer_finish(&tp, &dfops); + xfs_defer_ijoin(tp->t_dfops, ip); + error = xfs_defer_finish(&tp, tp->t_dfops); if (error) goto out_bmap_cancel; @@ -1623,6 +1625,8 @@ xfs_itruncate_extents_flags( trace_xfs_itruncate_extents_end(ip, new_size); out: + /* ->t_dfops points to local stack, don't leak it! */ + tp->t_dfops = odfops; *tpp = tp; return error; out_bmap_cancel: @@ -1631,7 +1635,7 @@ out_bmap_cancel: * the transaction can be properly aborted. We just need to make sure * we're not holding any resources that we were not when we came in. */ - xfs_defer_cancel(&dfops); + xfs_defer_cancel(tp->t_dfops); goto out; } |