Commit c8eac49e authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: remove all boilerplate defer init/finish code

At this point, the transaction subsystem completely manages deferred
items internally such that the common and boilerplate
xfs_trans_alloc() -> xfs_defer_init() -> xfs_defer_finish() ->
xfs_trans_commit() sequence can be replaced with a simple
transaction allocation and commit.

Remove all such boilerplate deferred ops code. In doing so, we
change each case over to use the dfops in the transaction and
specifically eliminate:

- The on-stack dfops and associated xfs_defer_init() call, as the
  internal dfops is initialized on transaction allocation.
- xfs_bmap_finish() calls that precede a final xfs_trans_commit() of
  a transaction.
- xfs_defer_cancel() calls in error handlers that precede a
  transaction cancel.

The only deferred ops calls that remain are those that are
non-deterministic with respect to the final commit of the associated
transaction or are open-coded due to special handling.
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarBill O'Donnell <billodo@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>
parent 91ef75b6
...@@ -1018,7 +1018,6 @@ xfs_bmap_add_attrfork( ...@@ -1018,7 +1018,6 @@ xfs_bmap_add_attrfork(
int size, /* space new attribute needs */ int size, /* space new attribute needs */
int rsvd) /* xact may use reserved blks */ int rsvd) /* xact may use reserved blks */
{ {
struct xfs_defer_ops dfops; /* freed extent records */
xfs_mount_t *mp; /* mount structure */ xfs_mount_t *mp; /* mount structure */
xfs_trans_t *tp; /* transaction pointer */ xfs_trans_t *tp; /* transaction pointer */
int blks; /* space reservation */ int blks; /* space reservation */
...@@ -1037,7 +1036,6 @@ xfs_bmap_add_attrfork( ...@@ -1037,7 +1036,6 @@ xfs_bmap_add_attrfork(
rsvd ? XFS_TRANS_RESERVE : 0, &tp); rsvd ? XFS_TRANS_RESERVE : 0, &tp);
if (error) if (error)
return error; return error;
xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
...@@ -1102,7 +1100,7 @@ xfs_bmap_add_attrfork( ...@@ -1102,7 +1100,7 @@ xfs_bmap_add_attrfork(
if (logflags) if (logflags)
xfs_trans_log_inode(tp, ip, logflags); xfs_trans_log_inode(tp, ip, logflags);
if (error) if (error)
goto bmap_cancel; goto trans_cancel;
if (!xfs_sb_version_hasattr(&mp->m_sb) || if (!xfs_sb_version_hasattr(&mp->m_sb) ||
(!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) {
bool log_sb = false; bool log_sb = false;
...@@ -1121,15 +1119,10 @@ xfs_bmap_add_attrfork( ...@@ -1121,15 +1119,10 @@ xfs_bmap_add_attrfork(
xfs_log_sb(tp); xfs_log_sb(tp);
} }
error = xfs_defer_finish(&tp, &dfops);
if (error)
goto bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
bmap_cancel:
xfs_defer_cancel(&dfops);
trans_cancel: trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
...@@ -5953,14 +5946,12 @@ xfs_bmap_split_extent( ...@@ -5953,14 +5946,12 @@ xfs_bmap_split_extent(
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
int error; int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write,
XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp); XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
if (error) if (error)
return error; return error;
xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
...@@ -5969,14 +5960,9 @@ xfs_bmap_split_extent( ...@@ -5969,14 +5960,9 @@ xfs_bmap_split_extent(
if (error) if (error)
goto out; goto out;
error = xfs_defer_finish(&tp, &dfops);
if (error)
goto out;
return xfs_trans_commit(tp); return xfs_trans_commit(tp);
out: out:
xfs_defer_cancel(&dfops);
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;
} }
......
...@@ -1635,7 +1635,6 @@ xfs_refcount_recover_cow_leftovers( ...@@ -1635,7 +1635,6 @@ xfs_refcount_recover_cow_leftovers(
struct list_head debris; struct list_head debris;
union xfs_btree_irec low; union xfs_btree_irec low;
union xfs_btree_irec high; union xfs_btree_irec high;
struct xfs_defer_ops dfops;
xfs_fsblock_t fsb; xfs_fsblock_t fsb;
xfs_agblock_t agbno; xfs_agblock_t agbno;
int error; int error;
...@@ -1691,22 +1690,17 @@ xfs_refcount_recover_cow_leftovers( ...@@ -1691,22 +1690,17 @@ xfs_refcount_recover_cow_leftovers(
trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec); trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
/* Free the orphan record */ /* Free the orphan record */
xfs_defer_init(tp, &dfops);
agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START; agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
fsb = XFS_AGB_TO_FSB(mp, agno, agbno); fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb, error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,
rr->rr_rrec.rc_blockcount); rr->rr_rrec.rc_blockcount);
if (error) if (error)
goto out_defer; goto out_trans;
/* Free the block. */ /* Free the block. */
xfs_bmap_add_free(mp, tp->t_dfops, fsb, xfs_bmap_add_free(mp, tp->t_dfops, fsb,
rr->rr_rrec.rc_blockcount, NULL); rr->rr_rrec.rc_blockcount, NULL);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_defer;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_free; goto out_free;
...@@ -1716,8 +1710,6 @@ xfs_refcount_recover_cow_leftovers( ...@@ -1716,8 +1710,6 @@ xfs_refcount_recover_cow_leftovers(
} }
return error; return error;
out_defer:
xfs_defer_cancel(tp->t_dfops);
out_trans: out_trans:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_free: out_free:
......
...@@ -382,7 +382,6 @@ xfs_attr_inactive( ...@@ -382,7 +382,6 @@ xfs_attr_inactive(
{ {
struct xfs_trans *trans; struct xfs_trans *trans;
struct xfs_mount *mp; struct xfs_mount *mp;
struct xfs_defer_ops dfops;
int lock_mode = XFS_ILOCK_SHARED; int lock_mode = XFS_ILOCK_SHARED;
int error = 0; int error = 0;
...@@ -399,7 +398,6 @@ xfs_attr_inactive( ...@@ -399,7 +398,6 @@ xfs_attr_inactive(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrinval, 0, 0, 0, &trans); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_attrinval, 0, 0, 0, &trans);
if (error) if (error)
goto out_destroy_fork; goto out_destroy_fork;
xfs_defer_init(trans, &dfops);
lock_mode = XFS_ILOCK_EXCL; lock_mode = XFS_ILOCK_EXCL;
xfs_ilock(dp, lock_mode); xfs_ilock(dp, lock_mode);
......
...@@ -792,7 +792,6 @@ xfs_free_eofblocks( ...@@ -792,7 +792,6 @@ xfs_free_eofblocks(
int nimaps; int nimaps;
struct xfs_bmbt_irec imap; struct xfs_bmbt_irec imap;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_defer_ops dfops;
/* /*
* Figure out if there are any blocks beyond the end * Figure out if there are any blocks beyond the end
...@@ -832,7 +831,6 @@ xfs_free_eofblocks( ...@@ -832,7 +831,6 @@ xfs_free_eofblocks(
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
return error; return error;
} }
xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
...@@ -880,7 +878,6 @@ xfs_alloc_file_space( ...@@ -880,7 +878,6 @@ xfs_alloc_file_space(
int rt; int rt;
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_bmbt_irec_t imaps[1], *imapp; xfs_bmbt_irec_t imaps[1], *imapp;
struct xfs_defer_ops dfops;
uint qblocks, resblks, resrtextents; uint qblocks, resblks, resrtextents;
int error; int error;
...@@ -973,7 +970,6 @@ xfs_alloc_file_space( ...@@ -973,7 +970,6 @@ xfs_alloc_file_space(
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
xfs_defer_init(tp, &dfops);
error = xfs_bmapi_write(tp, ip, startoffset_fsb, error = xfs_bmapi_write(tp, ip, startoffset_fsb,
allocatesize_fsb, alloc_type, resblks, allocatesize_fsb, alloc_type, resblks,
imapp, &nimaps); imapp, &nimaps);
...@@ -983,10 +979,6 @@ xfs_alloc_file_space( ...@@ -983,10 +979,6 @@ xfs_alloc_file_space(
/* /*
* Complete the transaction * Complete the transaction
*/ */
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto error0;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error) if (error)
...@@ -1005,8 +997,7 @@ xfs_alloc_file_space( ...@@ -1005,8 +997,7 @@ xfs_alloc_file_space(
return error; return error;
error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ error0: /* unlock inode, unreserve quota blocks, cancel trans */
xfs_defer_cancel(&dfops);
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag); xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
error1: /* Just cancel transaction */ error1: /* Just cancel transaction */
...@@ -1024,7 +1015,6 @@ xfs_unmap_extent( ...@@ -1024,7 +1015,6 @@ xfs_unmap_extent(
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
int error; int error;
...@@ -1042,23 +1032,17 @@ xfs_unmap_extent( ...@@ -1042,23 +1032,17 @@ xfs_unmap_extent(
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
xfs_defer_init(tp, &dfops);
error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done); error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_defer_ijoin(tp->t_dfops, ip); xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
out_unlock: out_unlock:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
out_bmap_cancel:
xfs_defer_cancel(tp->t_dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
goto out_unlock; goto out_unlock;
...@@ -1310,7 +1294,6 @@ xfs_collapse_file_space( ...@@ -1310,7 +1294,6 @@ xfs_collapse_file_space(
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
int error; int error;
struct xfs_defer_ops dfops;
xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len); xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len);
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len); xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
...@@ -1343,22 +1326,16 @@ xfs_collapse_file_space( ...@@ -1343,22 +1326,16 @@ xfs_collapse_file_space(
goto out_trans_cancel; goto out_trans_cancel;
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_defer_init(tp, &dfops);
error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb, error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
&done); &done);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
} }
return error; return error;
out_bmap_cancel:
xfs_defer_cancel(tp->t_dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;
...@@ -1385,7 +1362,6 @@ xfs_insert_file_space( ...@@ -1385,7 +1362,6 @@ xfs_insert_file_space(
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
int error; int error;
struct xfs_defer_ops dfops;
xfs_fileoff_t stop_fsb = XFS_B_TO_FSB(mp, offset); xfs_fileoff_t stop_fsb = XFS_B_TO_FSB(mp, offset);
xfs_fileoff_t next_fsb = NULLFSBLOCK; xfs_fileoff_t next_fsb = NULLFSBLOCK;
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len); xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
...@@ -1421,22 +1397,17 @@ xfs_insert_file_space( ...@@ -1421,22 +1397,17 @@ xfs_insert_file_space(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_defer_init(tp, &dfops);
error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb, error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
&done, stop_fsb); &done, stop_fsb);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
} }
return error; return error;
out_bmap_cancel: out_trans_cancel:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -1607,7 +1578,7 @@ xfs_swap_extent_rmap( ...@@ -1607,7 +1578,7 @@ xfs_swap_extent_rmap(
/* Unmap the old blocks in the source file. */ /* Unmap the old blocks in the source file. */
while (tirec.br_blockcount) { while (tirec.br_blockcount) {
xfs_defer_init(tp, tp->t_dfops); ASSERT(tp->t_firstblock == NULLFSBLOCK);
trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec); trace_xfs_swap_extent_rmap_remap_piece(tip, &tirec);
/* Read extent from the source file */ /* Read extent from the source file */
...@@ -1831,7 +1802,6 @@ xfs_swap_extents( ...@@ -1831,7 +1802,6 @@ xfs_swap_extents(
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
struct xfs_bstat *sbp = &sxp->sx_stat; struct xfs_bstat *sbp = &sxp->sx_stat;
int src_log_flags, target_log_flags; int src_log_flags, target_log_flags;
int error = 0; int error = 0;
...@@ -1900,7 +1870,6 @@ xfs_swap_extents( ...@@ -1900,7 +1870,6 @@ xfs_swap_extents(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
if (error) if (error)
goto out_unlock; goto out_unlock;
xfs_defer_init(tp, &dfops);
/* /*
* Lock and join the inodes to the tansaction so that transaction commit * Lock and join the inodes to the tansaction so that transaction commit
......
...@@ -295,8 +295,6 @@ xfs_dquot_disk_alloc( ...@@ -295,8 +295,6 @@ xfs_dquot_disk_alloc(
trace_xfs_dqalloc(dqp); trace_xfs_dqalloc(dqp);
xfs_defer_init(tp, tp->t_dfops);
xfs_ilock(quotip, XFS_ILOCK_EXCL); xfs_ilock(quotip, XFS_ILOCK_EXCL);
if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) { if (!xfs_this_quota_on(dqp->q_mount, dqp->dq_flags)) {
/* /*
...@@ -538,7 +536,6 @@ xfs_qm_dqread_alloc( ...@@ -538,7 +536,6 @@ xfs_qm_dqread_alloc(
struct xfs_buf **bpp) struct xfs_buf **bpp)
{ {
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
struct xfs_buf *bp; struct xfs_buf *bp;
int error; int error;
...@@ -546,7 +543,6 @@ xfs_qm_dqread_alloc( ...@@ -546,7 +543,6 @@ xfs_qm_dqread_alloc(
XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp); XFS_QM_DQALLOC_SPACE_RES(mp), 0, 0, &tp);
if (error) if (error)
goto err; goto err;
xfs_defer_init(tp, &dfops);
error = xfs_dquot_disk_alloc(&tp, dqp, &bp); error = xfs_dquot_disk_alloc(&tp, dqp, &bp);
if (error) if (error)
......
...@@ -1142,7 +1142,6 @@ xfs_create( ...@@ -1142,7 +1142,6 @@ xfs_create(
struct xfs_inode *ip = NULL; struct xfs_inode *ip = NULL;
struct xfs_trans *tp = NULL; struct xfs_trans *tp = NULL;
int error; int error;
struct xfs_defer_ops dfops;
bool unlock_dp_on_error = false; bool unlock_dp_on_error = false;
prid_t prid; prid_t prid;
struct xfs_dquot *udqp = NULL; struct xfs_dquot *udqp = NULL;
...@@ -1194,8 +1193,6 @@ xfs_create( ...@@ -1194,8 +1193,6 @@ xfs_create(
xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT); xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
unlock_dp_on_error = true; unlock_dp_on_error = true;
xfs_defer_init(tp, &dfops);
/* /*
* Reserve disk quota and the inode. * Reserve disk quota and the inode.
*/ */
...@@ -1236,11 +1233,11 @@ xfs_create( ...@@ -1236,11 +1233,11 @@ xfs_create(
if (is_dir) { if (is_dir) {
error = xfs_dir_init(tp, ip, dp); error = xfs_dir_init(tp, ip, dp);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
error = xfs_bumplink(tp, dp); error = xfs_bumplink(tp, dp);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
} }
/* /*
...@@ -1258,10 +1255,6 @@ xfs_create( ...@@ -1258,10 +1255,6 @@ xfs_create(
*/ */
xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp);
error = xfs_defer_finish(&tp, &dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_release_inode; goto out_release_inode;
...@@ -1273,8 +1266,6 @@ xfs_create( ...@@ -1273,8 +1266,6 @@ xfs_create(
*ipp = ip; *ipp = ip;
return 0; return 0;
out_bmap_cancel:
xfs_defer_cancel(&dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_release_inode: out_release_inode:
...@@ -1399,7 +1390,6 @@ xfs_link( ...@@ -1399,7 +1390,6 @@ xfs_link(
xfs_mount_t *mp = tdp->i_mount; xfs_mount_t *mp = tdp->i_mount;
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
struct xfs_defer_ops dfops;
int resblks; int resblks;
trace_xfs_link(tdp, target_name); trace_xfs_link(tdp, target_name);
...@@ -1448,8 +1438,6 @@ xfs_link( ...@@ -1448,8 +1438,6 @@ xfs_link(
goto error_return; goto error_return;
} }
xfs_defer_init(tp, &dfops);
/* /*
* Handle initial link state of O_TMPFILE inode * Handle initial link state of O_TMPFILE inode
*/ */
...@@ -1478,12 +1466,6 @@ xfs_link( ...@@ -1478,12 +1466,6 @@ xfs_link(
if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_defer_finish(&tp, &dfops);
if (error) {
xfs_defer_cancel(&dfops);
goto error_return;
}
return xfs_trans_commit(tp); return xfs_trans_commit(tp);
error_return: error_return:
...@@ -1719,7 +1701,6 @@ xfs_inactive_truncate( ...@@ -1719,7 +1701,6 @@ xfs_inactive_truncate(
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
int error; int error;
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
...@@ -1727,8 +1708,6 @@ xfs_inactive_truncate( ...@@ -1727,8 +1708,6 @@ xfs_inactive_truncate(
ASSERT(XFS_FORCED_SHUTDOWN(mp)); ASSERT(XFS_FORCED_SHUTDOWN(mp));
return error; return error;
} }
xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
...@@ -1769,7 +1748,6 @@ STATIC int ...@@ -1769,7 +1748,6 @@ STATIC int
xfs_inactive_ifree( xfs_inactive_ifree(
struct xfs_inode *ip) struct xfs_inode *ip)
{ {
struct xfs_defer_ops dfops;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
int error; int error;
...@@ -1806,7 +1784,6 @@ xfs_inactive_ifree( ...@@ -1806,7 +1784,6 @@ xfs_inactive_ifree(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
xfs_defer_init(tp, &dfops);
error = xfs_ifree(tp, ip); error = xfs_ifree(tp, ip);
if (error) { if (error) {
/* /*
...@@ -1833,12 +1810,6 @@ xfs_inactive_ifree( ...@@ -1833,12 +1810,6 @@ xfs_inactive_ifree(
* Just ignore errors at this point. There is nothing we can do except * Just ignore errors at this point. There is nothing we can do except
* to try to keep going. Make sure it's not a silent error. * to try to keep going. Make sure it's not a silent error.
*/ */
error = xfs_defer_finish(&tp, &dfops);
if (error) {
xfs_notice(mp, "%s: xfs_defer_finish returned error %d",
__func__, error);
xfs_defer_cancel(&dfops);
}
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
xfs_notice(mp, "%s: xfs_trans_commit returned error %d", xfs_notice(mp, "%s: xfs_trans_commit returned error %d",
...@@ -2569,7 +2540,6 @@ xfs_remove( ...@@ -2569,7 +2540,6 @@ xfs_remove(
xfs_trans_t *tp = NULL; xfs_trans_t *tp = NULL;
int is_dir = S_ISDIR(VFS_I(ip)->i_mode); int is_dir = S_ISDIR(VFS_I(ip)->i_mode);
int error = 0; int error = 0;
struct xfs_defer_ops dfops;
uint resblks; uint resblks;
trace_xfs_remove(dp, name); trace_xfs_remove(dp, name);
...@@ -2649,11 +2619,10 @@ xfs_remove( ...@@ -2649,11 +2619,10 @@ xfs_remove(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
xfs_defer_init(tp, &dfops);
error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks);
if (error) { if (error) {
ASSERT(error != -ENOENT); ASSERT(error != -ENOENT);
goto out_bmap_cancel; goto out_trans_cancel;
} }
/* /*
...@@ -2664,10 +2633,6 @@ xfs_remove( ...@@ -2664,10 +2633,6 @@ xfs_remove(
if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_defer_finish(&tp, &dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto std_return; goto std_return;
...@@ -2677,8 +2642,6 @@ xfs_remove( ...@@ -2677,8 +2642,6 @@ xfs_remove(
return 0; return 0;
out_bmap_cancel:
xfs_defer_cancel(&dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
std_return: std_return:
...@@ -2740,9 +2703,6 @@ static int ...@@ -2740,9 +2703,6 @@ static int
xfs_finish_rename( xfs_finish_rename(
struct xfs_trans *tp) struct xfs_trans *tp)
{ {
struct xfs_defer_ops *dfops = tp->t_dfops;
int error;
/* /*
* If this is a synchronous mount, make sure that the rename transaction * If this is a synchronous mount, make sure that the rename transaction
* goes to disk before returning to the user. * goes to disk before returning to the user.
...@@ -2750,13 +2710,6 @@ xfs_finish_rename( ...@@ -2750,13 +2710,6 @@ xfs_finish_rename(
if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC))
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
error = xfs_defer_finish(&tp, dfops);
if (error) {
xfs_defer_cancel(dfops);
xfs_trans_cancel(tp);
return error;
}
return xfs_trans_commit(tp); return xfs_trans_commit(tp);
} }
...@@ -2869,7 +2822,6 @@ xfs_cross_rename( ...@@ -2869,7 +2822,6 @@ xfs_cross_rename(
return xfs_finish_rename(tp); return xfs_finish_rename(tp);
out_trans_abort: out_trans_abort:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;
} }
...@@ -2924,7 +2876,6 @@ xfs_rename( ...@@ -2924,7 +2876,6 @@ xfs_rename(
{ {
struct xfs_mount *mp = src_dp->i_mount; struct xfs_mount *mp = src_dp->i_mount;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
struct xfs_inode *wip = NULL; /* whiteout inode */ struct xfs_inode *wip = NULL; /* whiteout inode */
struct xfs_inode *inodes[__XFS_SORT_INODES]; struct xfs_inode *inodes[__XFS_SORT_INODES];
int num_inodes = __XFS_SORT_INODES; int num_inodes = __XFS_SORT_INODES;
...@@ -3006,8 +2957,6 @@ xfs_rename( ...@@ -3006,8 +2957,6 @@ xfs_rename(
goto out_trans_cancel; goto out_trans_cancel;
} }
xfs_defer_init(tp, &dfops);
/* RENAME_EXCHANGE is unique from here on. */ /* RENAME_EXCHANGE is unique from here on. */
if (flags & RENAME_EXCHANGE) if (flags & RENAME_EXCHANGE)
return xfs_cross_rename(tp, src_dp, src_name, src_ip, return xfs_cross_rename(tp, src_dp, src_name, src_ip,
...@@ -3035,7 +2984,7 @@ xfs_rename( ...@@ -3035,7 +2984,7 @@ xfs_rename(
error = xfs_dir_createname(tp, target_dp, target_name, error = xfs_dir_createname(tp, target_dp, target_name,
src_ip->i_ino, spaceres); src_ip->i_ino, spaceres);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp, xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -3043,7 +2992,7 @@ xfs_rename( ...@@ -3043,7 +2992,7 @@ xfs_rename(
if (new_parent && src_is_directory) { if (new_parent && src_is_directory) {
error = xfs_bumplink(tp, target_dp); error = xfs_bumplink(tp, target_dp);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
} }
} else { /* target_ip != NULL */ } else { /* target_ip != NULL */
/* /*
...@@ -3074,7 +3023,7 @@ xfs_rename( ...@@ -3074,7 +3023,7 @@ xfs_rename(
error = xfs_dir_replace(tp, target_dp, target_name, error = xfs_dir_replace(tp, target_dp, target_name,
src_ip->i_ino, spaceres); src_ip->i_ino, spaceres);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_trans_ichgtime(tp, target_dp, xfs_trans_ichgtime(tp, target_dp,
XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
...@@ -3085,7 +3034,7 @@ xfs_rename( ...@@ -3085,7 +3034,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, target_ip); error = xfs_droplink(tp, target_ip);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
if (src_is_directory) { if (src_is_directory) {
/* /*
...@@ -3093,7 +3042,7 @@ xfs_rename( ...@@ -3093,7 +3042,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, target_ip); error = xfs_droplink(tp, target_ip);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
} }
} /* target_ip != NULL */ } /* target_ip != NULL */
...@@ -3109,7 +3058,7 @@ xfs_rename( ...@@ -3109,7 +3058,7 @@ xfs_rename(
target_dp->i_ino, spaceres); target_dp->i_ino, spaceres);
ASSERT(error != -EEXIST); ASSERT(error != -EEXIST);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
} }
/* /*
...@@ -3135,7 +3084,7 @@ xfs_rename( ...@@ -3135,7 +3084,7 @@ xfs_rename(
*/ */
error = xfs_droplink(tp, src_dp); error = xfs_droplink(tp, src_dp);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
} }
/* /*
...@@ -3150,7 +3099,7 @@ xfs_rename( ...@@ -3150,7 +3099,7 @@ xfs_rename(
error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
spaceres); spaceres);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
/* /*
* For whiteouts, we need to bump the link count on the whiteout inode. * For whiteouts, we need to bump the link count on the whiteout inode.
...@@ -3164,10 +3113,10 @@ xfs_rename( ...@@ -3164,10 +3113,10 @@ xfs_rename(
ASSERT(VFS_I(wip)->i_nlink == 0); ASSERT(VFS_I(wip)->i_nlink == 0);
error = xfs_bumplink(tp, wip); error = xfs_bumplink(tp, wip);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
error = xfs_iunlink_remove(tp, wip); error = xfs_iunlink_remove(tp, wip);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, wip, XFS_ILOG_CORE);
/* /*
...@@ -3188,8 +3137,6 @@ xfs_rename( ...@@ -3188,8 +3137,6 @@ xfs_rename(
IRELE(wip); IRELE(wip);
return error; return error;
out_bmap_cancel:
xfs_defer_cancel(&dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_release_wip: out_release_wip:
......
...@@ -157,7 +157,6 @@ xfs_iomap_write_direct( ...@@ -157,7 +157,6 @@ xfs_iomap_write_direct(
int quota_flag; int quota_flag;
int rt; int rt;
xfs_trans_t *tp; xfs_trans_t *tp;
struct xfs_defer_ops dfops;
uint qblocks, resblks, resrtextents; uint qblocks, resblks, resrtextents;
int error; int error;
int lockmode; int lockmode;
...@@ -253,20 +252,15 @@ xfs_iomap_write_direct( ...@@ -253,20 +252,15 @@ xfs_iomap_write_direct(
* From this point onwards we overwrite the imap pointer that the * From this point onwards we overwrite the imap pointer that the
* caller gave to us. * caller gave to us.
*/ */
xfs_defer_init(tp, &dfops);
nimaps = 1; nimaps = 1;
error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
bmapi_flags, resblks, imap, &nimaps); bmapi_flags, resblks, imap, &nimaps);
if (error) if (error)
goto out_bmap_cancel; goto out_res_cancel;
/* /*
* Complete the transaction * Complete the transaction
*/ */
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_unlock; goto out_unlock;
...@@ -286,8 +280,7 @@ xfs_iomap_write_direct( ...@@ -286,8 +280,7 @@ xfs_iomap_write_direct(
xfs_iunlock(ip, lockmode); xfs_iunlock(ip, lockmode);
return error; return error;
out_bmap_cancel: out_res_cancel:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag); xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
...@@ -663,7 +656,6 @@ xfs_iomap_write_allocate( ...@@ -663,7 +656,6 @@ xfs_iomap_write_allocate(
xfs_mount_t *mp = ip->i_mount; xfs_mount_t *mp = ip->i_mount;
xfs_fileoff_t offset_fsb, last_block; xfs_fileoff_t offset_fsb, last_block;
xfs_fileoff_t end_fsb, map_start_fsb; xfs_fileoff_t end_fsb, map_start_fsb;
struct xfs_defer_ops dfops;
xfs_filblks_t count_fsb; xfs_filblks_t count_fsb;
xfs_trans_t *tp; xfs_trans_t *tp;
int nimaps; int nimaps;
...@@ -713,8 +705,6 @@ xfs_iomap_write_allocate( ...@@ -713,8 +705,6 @@ xfs_iomap_write_allocate(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
xfs_defer_init(tp, &dfops);
/* /*
* it is possible that the extents have changed since * it is possible that the extents have changed since
* we did the read call as we dropped the ilock for a * we did the read call as we dropped the ilock for a
...@@ -772,10 +762,6 @@ xfs_iomap_write_allocate( ...@@ -772,10 +762,6 @@ xfs_iomap_write_allocate(
if (error) if (error)
goto trans_cancel; goto trans_cancel;
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto trans_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto error0; goto error0;
...@@ -806,7 +792,6 @@ xfs_iomap_write_allocate( ...@@ -806,7 +792,6 @@ xfs_iomap_write_allocate(
} }
trans_cancel: trans_cancel:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
error0: error0:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
...@@ -827,7 +812,6 @@ xfs_iomap_write_unwritten( ...@@ -827,7 +812,6 @@ xfs_iomap_write_unwritten(
int nimaps; int nimaps;
xfs_trans_t *tp; xfs_trans_t *tp;
xfs_bmbt_irec_t imap; xfs_bmbt_irec_t imap;
struct xfs_defer_ops dfops;
struct inode *inode = VFS_I(ip); struct inode *inode = VFS_I(ip);
xfs_fsize_t i_size; xfs_fsize_t i_size;
uint resblks; uint resblks;
...@@ -872,7 +856,6 @@ xfs_iomap_write_unwritten( ...@@ -872,7 +856,6 @@ xfs_iomap_write_unwritten(
/* /*
* Modify the unwritten extent state of the buffer. * Modify the unwritten extent state of the buffer.
*/ */
xfs_defer_init(tp, &dfops);
nimaps = 1; nimaps = 1;
error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb, error = xfs_bmapi_write(tp, ip, offset_fsb, count_fsb,
XFS_BMAPI_CONVERT, resblks, &imap, XFS_BMAPI_CONVERT, resblks, &imap,
...@@ -896,10 +879,6 @@ xfs_iomap_write_unwritten( ...@@ -896,10 +879,6 @@ xfs_iomap_write_unwritten(
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
} }
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto error_on_bmapi_transaction;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
if (error) if (error)
...@@ -923,7 +902,6 @@ xfs_iomap_write_unwritten( ...@@ -923,7 +902,6 @@ xfs_iomap_write_unwritten(
return 0; return 0;
error_on_bmapi_transaction: error_on_bmapi_transaction:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return error; return error;
......
...@@ -813,7 +813,6 @@ xfs_setattr_size( ...@@ -813,7 +813,6 @@ xfs_setattr_size(
struct inode *inode = VFS_I(ip); struct inode *inode = VFS_I(ip);
xfs_off_t oldsize, newsize; xfs_off_t oldsize, newsize;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
int error; int error;
uint lock_flags = 0; uint lock_flags = 0;
bool did_zeroing = false; bool did_zeroing = false;
...@@ -917,7 +916,6 @@ xfs_setattr_size( ...@@ -917,7 +916,6 @@ xfs_setattr_size(
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
if (error) if (error)
return error; return error;
xfs_defer_init(tp, &dfops);
lock_flags |= XFS_ILOCK_EXCL; lock_flags |= XFS_ILOCK_EXCL;
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
......
...@@ -4857,15 +4857,7 @@ xlog_finish_defer_ops( ...@@ -4857,15 +4857,7 @@ xlog_finish_defer_ops(
/* transfer all collected dfops to this transaction */ /* transfer all collected dfops to this transaction */
xfs_defer_move(tp->t_dfops, dfops); xfs_defer_move(tp->t_dfops, dfops);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_cancel;
return xfs_trans_commit(tp); return xfs_trans_commit(tp);
out_cancel:
xfs_trans_cancel(tp);
return error;
} }
/* /*
......
...@@ -214,7 +214,6 @@ xfs_qm_scall_trunc_qfile( ...@@ -214,7 +214,6 @@ xfs_qm_scall_trunc_qfile(
{ {
struct xfs_inode *ip; struct xfs_inode *ip;
struct xfs_trans *tp; struct xfs_trans *tp;
struct xfs_defer_ops dfops;
int error; int error;
if (ino == NULLFSINO) if (ino == NULLFSINO)
...@@ -231,7 +230,6 @@ xfs_qm_scall_trunc_qfile( ...@@ -231,7 +230,6 @@ xfs_qm_scall_trunc_qfile(
xfs_iunlock(ip, XFS_IOLOCK_EXCL); xfs_iunlock(ip, XFS_IOLOCK_EXCL);
goto out_put; goto out_put;
} }
xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
......
...@@ -364,7 +364,6 @@ xfs_reflink_allocate_cow( ...@@ -364,7 +364,6 @@ xfs_reflink_allocate_cow(
xfs_fileoff_t offset_fsb = imap->br_startoff; xfs_fileoff_t offset_fsb = imap->br_startoff;
xfs_filblks_t count_fsb = imap->br_blockcount; xfs_filblks_t count_fsb = imap->br_blockcount;
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_defer_ops dfops;
struct xfs_trans *tp = NULL; struct xfs_trans *tp = NULL;
int nimaps, error = 0; int nimaps, error = 0;
bool trimmed; bool trimmed;
...@@ -424,7 +423,6 @@ xfs_reflink_allocate_cow( ...@@ -424,7 +423,6 @@ xfs_reflink_allocate_cow(
xfs_trans_ijoin(tp, ip, 0); xfs_trans_ijoin(tp, ip, 0);
xfs_defer_init(tp, &dfops);
nimaps = 1; nimaps = 1;
/* Allocate the entire reservation as unwritten blocks. */ /* Allocate the entire reservation as unwritten blocks. */
...@@ -432,15 +430,11 @@ xfs_reflink_allocate_cow( ...@@ -432,15 +430,11 @@ xfs_reflink_allocate_cow(
XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC, XFS_BMAPI_COWFORK | XFS_BMAPI_PREALLOC,
resblks, imap, &nimaps); resblks, imap, &nimaps);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_inode_set_cowblocks_tag(ip); xfs_inode_set_cowblocks_tag(ip);
/* Finish up. */ /* Finish up. */
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
return error; return error;
...@@ -453,8 +447,7 @@ xfs_reflink_allocate_cow( ...@@ -453,8 +447,7 @@ xfs_reflink_allocate_cow(
return -ENOSPC; return -ENOSPC;
convert: convert:
return xfs_reflink_convert_cow_extent(ip, imap, offset_fsb, count_fsb); return xfs_reflink_convert_cow_extent(ip, imap, offset_fsb, count_fsb);
out_bmap_cancel: out_trans_cancel:
xfs_defer_cancel(tp->t_dfops);
xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0, xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0,
XFS_QMOPT_RES_REGBLKS); XFS_QMOPT_RES_REGBLKS);
out: out:
...@@ -624,7 +617,6 @@ xfs_reflink_end_cow( ...@@ -624,7 +617,6 @@ xfs_reflink_end_cow(
struct xfs_trans *tp; struct xfs_trans *tp;
xfs_fileoff_t offset_fsb; xfs_fileoff_t offset_fsb;
xfs_fileoff_t end_fsb; xfs_fileoff_t end_fsb;
struct xfs_defer_ops dfops;
int error; int error;
unsigned int resblks; unsigned int resblks;
xfs_filblks_t rlen; xfs_filblks_t rlen;
...@@ -691,11 +683,11 @@ xfs_reflink_end_cow( ...@@ -691,11 +683,11 @@ xfs_reflink_end_cow(
goto prev_extent; goto prev_extent;
/* Unmap the old blocks in the data fork. */ /* Unmap the old blocks in the data fork. */
xfs_defer_init(tp, &dfops); ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK);
rlen = del.br_blockcount; rlen = del.br_blockcount;
error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1); error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1);
if (error) if (error)
goto out_defer; goto out_cancel;
/* Trim the extent to whatever got unmapped. */ /* Trim the extent to whatever got unmapped. */
if (rlen) { if (rlen) {
...@@ -708,13 +700,13 @@ xfs_reflink_end_cow( ...@@ -708,13 +700,13 @@ xfs_reflink_end_cow(
error = xfs_refcount_free_cow_extent(tp->t_mountp, tp->t_dfops, error = xfs_refcount_free_cow_extent(tp->t_mountp, tp->t_dfops,
del.br_startblock, del.br_blockcount); del.br_startblock, del.br_blockcount);
if (error) if (error)
goto out_defer; goto out_cancel;
/* Map the new blocks into the data fork. */ /* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(tp->t_mountp, tp->t_dfops, ip, error = xfs_bmap_map_extent(tp->t_mountp, tp->t_dfops, ip,
&del); &del);
if (error) if (error)
goto out_defer; goto out_cancel;
/* Charge this new data fork mapping to the on-disk quota. */ /* Charge this new data fork mapping to the on-disk quota. */
xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_DELBCOUNT, xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_DELBCOUNT,
...@@ -726,7 +718,7 @@ xfs_reflink_end_cow( ...@@ -726,7 +718,7 @@ xfs_reflink_end_cow(
xfs_defer_ijoin(tp->t_dfops, ip); xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops); error = xfs_defer_finish(&tp, tp->t_dfops);
if (error) if (error)
goto out_defer; goto out_cancel;
if (!xfs_iext_get_extent(ifp, &icur, &got)) if (!xfs_iext_get_extent(ifp, &icur, &got))
break; break;
continue; continue;
...@@ -741,8 +733,6 @@ xfs_reflink_end_cow( ...@@ -741,8 +733,6 @@ xfs_reflink_end_cow(
goto out; goto out;
return 0; return 0;
out_defer:
xfs_defer_cancel(tp->t_dfops);
out_cancel: out_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
...@@ -998,7 +988,6 @@ xfs_reflink_remap_extent( ...@@ -998,7 +988,6 @@ xfs_reflink_remap_extent(
bool real_extent = xfs_bmap_is_real_extent(irec); bool real_extent = xfs_bmap_is_real_extent(irec);
struct xfs_trans *tp; struct xfs_trans *tp;
unsigned int resblks; unsigned int resblks;
struct xfs_defer_ops dfops;
struct xfs_bmbt_irec uirec; struct xfs_bmbt_irec uirec;
xfs_filblks_t rlen; xfs_filblks_t rlen;
xfs_filblks_t unmap_len; xfs_filblks_t unmap_len;
...@@ -1039,10 +1028,10 @@ xfs_reflink_remap_extent( ...@@ -1039,10 +1028,10 @@ xfs_reflink_remap_extent(
/* Unmap the old blocks in the data fork. */ /* Unmap the old blocks in the data fork. */
rlen = unmap_len; rlen = unmap_len;
while (rlen) { while (rlen) {
xfs_defer_init(tp, &dfops); ASSERT(tp->t_dfops && tp->t_firstblock == NULLFSBLOCK);
error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1); error = __xfs_bunmapi(tp, ip, destoff, &rlen, 0, 1);
if (error) if (error)
goto out_defer; goto out_cancel;
/* /*
* Trim the extent to whatever got unmapped. * Trim the extent to whatever got unmapped.
...@@ -1063,12 +1052,12 @@ xfs_reflink_remap_extent( ...@@ -1063,12 +1052,12 @@ xfs_reflink_remap_extent(
/* Update the refcount tree */ /* Update the refcount tree */
error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec); error = xfs_refcount_increase_extent(mp, tp->t_dfops, &uirec);
if (error) if (error)
goto out_defer; goto out_cancel;
/* Map the new blocks into the data fork. */ /* Map the new blocks into the data fork. */
error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec); error = xfs_bmap_map_extent(mp, tp->t_dfops, ip, &uirec);
if (error) if (error)
goto out_defer; goto out_cancel;
/* Update quota accounting. */ /* Update quota accounting. */
xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT,
...@@ -1090,7 +1079,7 @@ xfs_reflink_remap_extent( ...@@ -1090,7 +1079,7 @@ xfs_reflink_remap_extent(
xfs_defer_ijoin(tp->t_dfops, ip); xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops); error = xfs_defer_finish(&tp, tp->t_dfops);
if (error) if (error)
goto out_defer; goto out_cancel;
} }
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
...@@ -1099,8 +1088,6 @@ xfs_reflink_remap_extent( ...@@ -1099,8 +1088,6 @@ xfs_reflink_remap_extent(
goto out; goto out;
return 0; return 0;
out_defer:
xfs_defer_cancel(tp->t_dfops);
out_cancel: out_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
......
...@@ -761,7 +761,6 @@ xfs_growfs_rt_alloc( ...@@ -761,7 +761,6 @@ xfs_growfs_rt_alloc(
struct xfs_buf *bp; /* temporary buffer for zeroing */ struct xfs_buf *bp; /* temporary buffer for zeroing */
xfs_daddr_t d; /* disk block address */ xfs_daddr_t d; /* disk block address */
int error; /* error return value */ int error; /* error return value */
struct xfs_defer_ops dfops; /* list of freed blocks */
xfs_fsblock_t fsbno; /* filesystem block for bno */ xfs_fsblock_t fsbno; /* filesystem block for bno */
struct xfs_bmbt_irec map; /* block map output */ struct xfs_bmbt_irec map; /* block map output */
int nmap; /* number of block maps */ int nmap; /* number of block maps */
...@@ -786,7 +785,6 @@ xfs_growfs_rt_alloc( ...@@ -786,7 +785,6 @@ xfs_growfs_rt_alloc(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_defer_init(tp, &dfops);
/* /*
* Allocate blocks to the bitmap file. * Allocate blocks to the bitmap file.
*/ */
...@@ -797,13 +795,10 @@ xfs_growfs_rt_alloc( ...@@ -797,13 +795,10 @@ xfs_growfs_rt_alloc(
if (!error && nmap < 1) if (!error && nmap < 1)
error = -ENOSPC; error = -ENOSPC;
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
/* /*
* Free any blocks freed up in the transaction, then commit. * Free any blocks freed up in the transaction, then commit.
*/ */
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
return error; return error;
...@@ -853,8 +848,6 @@ xfs_growfs_rt_alloc( ...@@ -853,8 +848,6 @@ xfs_growfs_rt_alloc(
return 0; return 0;
out_bmap_cancel:
xfs_defer_cancel(tp->t_dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
return error; return error;
......
...@@ -163,7 +163,6 @@ xfs_symlink( ...@@ -163,7 +163,6 @@ xfs_symlink(
struct xfs_inode *ip = NULL; struct xfs_inode *ip = NULL;
int error = 0; int error = 0;
int pathlen; int pathlen;
struct xfs_defer_ops dfops;
bool unlock_dp_on_error = false; bool unlock_dp_on_error = false;
xfs_fileoff_t first_fsb; xfs_fileoff_t first_fsb;
xfs_filblks_t fs_blocks; xfs_filblks_t fs_blocks;
...@@ -241,12 +240,6 @@ xfs_symlink( ...@@ -241,12 +240,6 @@ xfs_symlink(
if (error) if (error)
goto out_trans_cancel; goto out_trans_cancel;
/*
* Initialize the bmap freelist prior to calling either
* bmapi or the directory create code.
*/
xfs_defer_init(tp, &dfops);
/* /*
* Allocate an inode for the symlink. * Allocate an inode for the symlink.
*/ */
...@@ -290,7 +283,7 @@ xfs_symlink( ...@@ -290,7 +283,7 @@ xfs_symlink(
error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks, error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
XFS_BMAPI_METADATA, resblks, mval, &nmaps); XFS_BMAPI_METADATA, resblks, mval, &nmaps);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
if (resblks) if (resblks)
resblks -= fs_blocks; resblks -= fs_blocks;
...@@ -308,7 +301,7 @@ xfs_symlink( ...@@ -308,7 +301,7 @@ xfs_symlink(
BTOBB(byte_cnt), 0); BTOBB(byte_cnt), 0);
if (!bp) { if (!bp) {
error = -ENOMEM; error = -ENOMEM;
goto out_bmap_cancel; goto out_trans_cancel;
} }
bp->b_ops = &xfs_symlink_buf_ops; bp->b_ops = &xfs_symlink_buf_ops;
...@@ -337,7 +330,7 @@ xfs_symlink( ...@@ -337,7 +330,7 @@ xfs_symlink(
*/ */
error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks); error = xfs_dir_createname(tp, dp, link_name, ip->i_ino, resblks);
if (error) if (error)
goto out_bmap_cancel; goto out_trans_cancel;
xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE); xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
...@@ -350,10 +343,6 @@ xfs_symlink( ...@@ -350,10 +343,6 @@ xfs_symlink(
xfs_trans_set_sync(tp); xfs_trans_set_sync(tp);
} }
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto out_bmap_cancel;
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) if (error)
goto out_release_inode; goto out_release_inode;
...@@ -365,8 +354,6 @@ xfs_symlink( ...@@ -365,8 +354,6 @@ xfs_symlink(
*ipp = ip; *ipp = ip;
return 0; return 0;
out_bmap_cancel:
xfs_defer_cancel(tp->t_dfops);
out_trans_cancel: out_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
out_release_inode: out_release_inode:
...@@ -399,7 +386,6 @@ xfs_inactive_symlink_rmt( ...@@ -399,7 +386,6 @@ xfs_inactive_symlink_rmt(
xfs_buf_t *bp; xfs_buf_t *bp;
int done; int done;
int error; int error;
struct xfs_defer_ops dfops;
int i; int i;
xfs_mount_t *mp; xfs_mount_t *mp;
xfs_bmbt_irec_t mval[XFS_SYMLINK_MAPS]; xfs_bmbt_irec_t mval[XFS_SYMLINK_MAPS];
...@@ -438,7 +424,6 @@ xfs_inactive_symlink_rmt( ...@@ -438,7 +424,6 @@ xfs_inactive_symlink_rmt(
* Find the block(s) so we can inval and unmap them. * Find the block(s) so we can inval and unmap them.
*/ */
done = 0; done = 0;
xfs_defer_init(tp, &dfops);
nmaps = ARRAY_SIZE(mval); nmaps = ARRAY_SIZE(mval);
error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size), error = xfs_bmapi_read(ip, 0, xfs_symlink_blocks(mp, size),
mval, &nmaps, 0); mval, &nmaps, 0);
...@@ -453,7 +438,7 @@ xfs_inactive_symlink_rmt( ...@@ -453,7 +438,7 @@ xfs_inactive_symlink_rmt(
XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0); XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
if (!bp) { if (!bp) {
error = -ENOMEM; error = -ENOMEM;
goto error_bmap_cancel; goto error_trans_cancel;
} }
xfs_trans_binval(tp, bp); xfs_trans_binval(tp, bp);
} }
...@@ -462,19 +447,14 @@ xfs_inactive_symlink_rmt( ...@@ -462,19 +447,14 @@ xfs_inactive_symlink_rmt(
*/ */
error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done); error = xfs_bunmapi(tp, ip, 0, size, 0, nmaps, &done);
if (error) if (error)
goto error_bmap_cancel; goto error_trans_cancel;
ASSERT(done); ASSERT(done);
/*
* Commit the first transaction. This logs the EFI and the inode.
*/
xfs_defer_ijoin(tp->t_dfops, ip);
error = xfs_defer_finish(&tp, tp->t_dfops);
if (error)
goto error_bmap_cancel;
/* /*
* Commit the transaction containing extent freeing and EFDs. * Commit the transaction. This first logs the EFI and the inode, then
* rolls and commits the transaction that frees the extents.
*/ */
xfs_defer_ijoin(tp->t_dfops, ip);
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
error = xfs_trans_commit(tp); error = xfs_trans_commit(tp);
if (error) { if (error) {
...@@ -492,8 +472,6 @@ xfs_inactive_symlink_rmt( ...@@ -492,8 +472,6 @@ xfs_inactive_symlink_rmt(
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
return 0; return 0;
error_bmap_cancel:
xfs_defer_cancel(tp->t_dfops);
error_trans_cancel: error_trans_cancel:
xfs_trans_cancel(tp); xfs_trans_cancel(tp);
error_unlock: error_unlock:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment