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: Brian Foster <bfoster@redhat.com> Reviewed-by: Bill O'Donnell <billodo@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>
This commit is contained in:
committed by
Darrick J. Wong
parent
91ef75b657
commit
c8eac49ef7
@ -792,7 +792,6 @@ xfs_free_eofblocks(
|
||||
int nimaps;
|
||||
struct xfs_bmbt_irec imap;
|
||||
struct xfs_mount *mp = ip->i_mount;
|
||||
struct xfs_defer_ops dfops;
|
||||
|
||||
/*
|
||||
* Figure out if there are any blocks beyond the end
|
||||
@ -832,7 +831,6 @@ xfs_free_eofblocks(
|
||||
ASSERT(XFS_FORCED_SHUTDOWN(mp));
|
||||
return error;
|
||||
}
|
||||
xfs_defer_init(tp, &dfops);
|
||||
|
||||
xfs_ilock(ip, XFS_ILOCK_EXCL);
|
||||
xfs_trans_ijoin(tp, ip, 0);
|
||||
@ -880,7 +878,6 @@ xfs_alloc_file_space(
|
||||
int rt;
|
||||
xfs_trans_t *tp;
|
||||
xfs_bmbt_irec_t imaps[1], *imapp;
|
||||
struct xfs_defer_ops dfops;
|
||||
uint qblocks, resblks, resrtextents;
|
||||
int error;
|
||||
|
||||
@ -973,7 +970,6 @@ xfs_alloc_file_space(
|
||||
|
||||
xfs_trans_ijoin(tp, ip, 0);
|
||||
|
||||
xfs_defer_init(tp, &dfops);
|
||||
error = xfs_bmapi_write(tp, ip, startoffset_fsb,
|
||||
allocatesize_fsb, alloc_type, resblks,
|
||||
imapp, &nimaps);
|
||||
@ -983,10 +979,6 @@ xfs_alloc_file_space(
|
||||
/*
|
||||
* Complete the transaction
|
||||
*/
|
||||
error = xfs_defer_finish(&tp, tp->t_dfops);
|
||||
if (error)
|
||||
goto error0;
|
||||
|
||||
error = xfs_trans_commit(tp);
|
||||
xfs_iunlock(ip, XFS_ILOCK_EXCL);
|
||||
if (error)
|
||||
@ -1005,8 +997,7 @@ xfs_alloc_file_space(
|
||||
|
||||
return error;
|
||||
|
||||
error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
|
||||
xfs_defer_cancel(&dfops);
|
||||
error0: /* unlock inode, unreserve quota blocks, cancel trans */
|
||||
xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
|
||||
|
||||
error1: /* Just cancel transaction */
|
||||
@ -1024,7 +1015,6 @@ xfs_unmap_extent(
|
||||
{
|
||||
struct xfs_mount *mp = ip->i_mount;
|
||||
struct xfs_trans *tp;
|
||||
struct xfs_defer_ops dfops;
|
||||
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
|
||||
int error;
|
||||
|
||||
@ -1042,23 +1032,17 @@ xfs_unmap_extent(
|
||||
|
||||
xfs_trans_ijoin(tp, ip, 0);
|
||||
|
||||
xfs_defer_init(tp, &dfops);
|
||||
error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
|
||||
if (error)
|
||||
goto out_bmap_cancel;
|
||||
goto out_trans_cancel;
|
||||
|
||||
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);
|
||||
out_unlock:
|
||||
xfs_iunlock(ip, XFS_ILOCK_EXCL);
|
||||
return error;
|
||||
|
||||
out_bmap_cancel:
|
||||
xfs_defer_cancel(tp->t_dfops);
|
||||
out_trans_cancel:
|
||||
xfs_trans_cancel(tp);
|
||||
goto out_unlock;
|
||||
@ -1310,7 +1294,6 @@ xfs_collapse_file_space(
|
||||
struct xfs_mount *mp = ip->i_mount;
|
||||
struct xfs_trans *tp;
|
||||
int error;
|
||||
struct xfs_defer_ops dfops;
|
||||
xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len);
|
||||
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
|
||||
uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
|
||||
@ -1343,22 +1326,16 @@ xfs_collapse_file_space(
|
||||
goto out_trans_cancel;
|
||||
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
|
||||
|
||||
xfs_defer_init(tp, &dfops);
|
||||
error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
|
||||
&done);
|
||||
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);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
out_bmap_cancel:
|
||||
xfs_defer_cancel(tp->t_dfops);
|
||||
out_trans_cancel:
|
||||
xfs_trans_cancel(tp);
|
||||
return error;
|
||||
@ -1385,7 +1362,6 @@ xfs_insert_file_space(
|
||||
struct xfs_mount *mp = ip->i_mount;
|
||||
struct xfs_trans *tp;
|
||||
int error;
|
||||
struct xfs_defer_ops dfops;
|
||||
xfs_fileoff_t stop_fsb = XFS_B_TO_FSB(mp, offset);
|
||||
xfs_fileoff_t next_fsb = NULLFSBLOCK;
|
||||
xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len);
|
||||
@ -1421,22 +1397,17 @@ xfs_insert_file_space(
|
||||
|
||||
xfs_ilock(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,
|
||||
&done, stop_fsb);
|
||||
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);
|
||||
}
|
||||
|
||||
return error;
|
||||
|
||||
out_bmap_cancel:
|
||||
xfs_defer_cancel(tp->t_dfops);
|
||||
out_trans_cancel:
|
||||
xfs_trans_cancel(tp);
|
||||
return error;
|
||||
}
|
||||
@ -1607,7 +1578,7 @@ xfs_swap_extent_rmap(
|
||||
|
||||
/* Unmap the old blocks in the source file. */
|
||||
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);
|
||||
|
||||
/* Read extent from the source file */
|
||||
@ -1831,7 +1802,6 @@ xfs_swap_extents(
|
||||
{
|
||||
struct xfs_mount *mp = ip->i_mount;
|
||||
struct xfs_trans *tp;
|
||||
struct xfs_defer_ops dfops;
|
||||
struct xfs_bstat *sbp = &sxp->sx_stat;
|
||||
int src_log_flags, target_log_flags;
|
||||
int error = 0;
|
||||
@ -1900,7 +1870,6 @@ xfs_swap_extents(
|
||||
error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp);
|
||||
if (error)
|
||||
goto out_unlock;
|
||||
xfs_defer_init(tp, &dfops);
|
||||
|
||||
/*
|
||||
* Lock and join the inodes to the tansaction so that transaction commit
|
||||
|
Reference in New Issue
Block a user