summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2018-07-12 08:26:33 +0300
committerDarrick J. Wong <darrick.wong@oracle.com>2018-07-12 08:26:33 +0300
commit5fdd97944ee5ae0fcdd88227224d0c2c87aa6db9 (patch)
treea0591072c0a52ff66ce245c008ad6547ff7708f8 /fs/xfs/libxfs
parent9c3bf5da80efc1d502c7ef55ea5b77628e341510 (diff)
downloadlinux-5fdd97944ee5ae0fcdd88227224d0c2c87aa6db9.tar.xz
xfs: remove xfs_defer_init() firstblock param
All but one caller of xfs_defer_init() passes in the ->t_firstblock of the associated transaction. The one outlier is xlog_recover_process_intents(), which simply passes a dummy value because a valid pointer is required. This firstblock variable can simply be removed. At this point we could remove the xfs_defer_init() firstblock parameter and initialize ->t_firstblock directly. Even that is not necessary, however, because ->t_firstblock is automatically reinitialized in the new transaction on a transaction roll. Since xfs_defer_init() should never occur more than once on a particular transaction (since the corresponding finish will roll it), replace the reinit from xfs_defer_init() with an assert that verifies the transaction has a NULLFSBLOCK firstblock. 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/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_attr.c28
-rw-r--r--fs/xfs/libxfs/xfs_attr_remote.c9
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c4
-rw-r--r--fs/xfs/libxfs/xfs_defer.c5
-rw-r--r--fs/xfs/libxfs/xfs_defer.h3
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c2
6 files changed, 19 insertions, 32 deletions
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 153d2e29f872..927d4c968f9a 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -251,7 +251,7 @@ xfs_attr_set(
rsvd ? XFS_TRANS_RESERVE : 0, &args.trans);
if (error)
return error;
- xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
+ xfs_defer_init(args.trans, &dfops);
xfs_ilock(dp, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
@@ -422,7 +422,7 @@ xfs_attr_remove(
&args.trans);
if (error)
return error;
- xfs_defer_init(args.trans, &dfops, &args.trans->t_firstblock);
+ xfs_defer_init(args.trans, &dfops);
xfs_ilock(dp, XFS_ILOCK_EXCL);
/*
@@ -593,8 +593,7 @@ xfs_attr_leaf_addname(
* Commit that transaction so that the node_addname() call
* can manage its own transactions.
*/
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_node(args);
if (error)
goto out_defer_cancel;
@@ -683,8 +682,7 @@ xfs_attr_leaf_addname(
* If the result is small enough, shrink it all into the inode.
*/
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
@@ -749,8 +747,7 @@ xfs_attr_leaf_removename(
* If the result is small enough, shrink it all into the inode.
*/
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
@@ -879,8 +876,7 @@ restart:
*/
xfs_da_state_free(state);
state = NULL;
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_node(args);
if (error)
goto out_defer_cancel;
@@ -907,8 +903,7 @@ restart:
* in the index/blkno/rmtblkno/rmtblkcnt fields and
* in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
*/
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_split(state);
if (error)
goto out_defer_cancel;
@@ -1006,8 +1001,7 @@ restart:
* Check to see if the tree needs to be collapsed.
*/
if (retval && (state->path.active > 1)) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_join(state);
if (error)
goto out_defer_cancel;
@@ -1132,8 +1126,7 @@ xfs_attr_node_removename(
* Check to see if the tree needs to be collapsed.
*/
if (retval && (state->path.active > 1)) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_da3_join(state);
if (error)
goto out_defer_cancel;
@@ -1165,8 +1158,7 @@ xfs_attr_node_removename(
goto out;
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
/* bp is gone due to xfs_da_shrink_inode */
if (error)
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c
index f02c705965ff..7841e6255129 100644
--- a/fs/xfs/libxfs/xfs_attr_remote.c
+++ b/fs/xfs/libxfs/xfs_attr_remote.c
@@ -480,8 +480,7 @@ xfs_attr_rmtval_set(
* extent and then crash then the block may not contain the
* correct metadata after log recovery occurs.
*/
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
nmap = 1;
error = xfs_bmapi_write(args->trans, dp, (xfs_fileoff_t)lblkno,
blkcnt, XFS_BMAPI_ATTRFORK, args->total, &map,
@@ -523,8 +522,7 @@ xfs_attr_rmtval_set(
ASSERT(blkcnt > 0);
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
nmap = 1;
error = xfs_bmapi_read(dp, (xfs_fileoff_t)lblkno,
blkcnt, &map, &nmap,
@@ -628,8 +626,7 @@ xfs_attr_rmtval_remove(
blkcnt = args->rmtblkcnt;
done = 0;
while (!done) {
- xfs_defer_init(args->trans, args->trans->t_dfops,
- &args->trans->t_firstblock);
+ xfs_defer_init(args->trans, args->trans->t_dfops);
error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
XFS_BMAPI_ATTRFORK, 1, &done);
if (error)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 12be9ad888c3..7b93b1e16ad9 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1038,7 +1038,7 @@ xfs_bmap_add_attrfork(
rsvd ? XFS_TRANS_RESERVE : 0, &tp);
if (error)
return error;
- xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+ xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
@@ -5968,7 +5968,7 @@ xfs_bmap_split_extent(
XFS_DIOSTRAT_SPACE_RES(mp, 0), 0, 0, &tp);
if (error)
return error;
- xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+ xfs_defer_init(tp, &dfops);
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 6b25a9436829..2713e2d808a7 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -524,16 +524,15 @@ xfs_defer_init_op_type(
void
xfs_defer_init(
struct xfs_trans *tp,
- struct xfs_defer_ops *dop,
- xfs_fsblock_t *fbp)
+ struct xfs_defer_ops *dop)
{
struct xfs_mount *mp = NULL;
memset(dop, 0, sizeof(struct xfs_defer_ops));
- *fbp = NULLFSBLOCK;
INIT_LIST_HEAD(&dop->dop_intake);
INIT_LIST_HEAD(&dop->dop_pending);
if (tp) {
+ ASSERT(tp->t_firstblock == NULLFSBLOCK);
tp->t_dfops = dop;
mp = tp->t_mountp;
}
diff --git a/fs/xfs/libxfs/xfs_defer.h b/fs/xfs/libxfs/xfs_defer.h
index 56eaaac31df5..c17c9deda995 100644
--- a/fs/xfs/libxfs/xfs_defer.h
+++ b/fs/xfs/libxfs/xfs_defer.h
@@ -63,8 +63,7 @@ void xfs_defer_add(struct xfs_defer_ops *dop, enum xfs_defer_ops_type type,
struct list_head *h);
int xfs_defer_finish(struct xfs_trans **tp, struct xfs_defer_ops *dop);
void xfs_defer_cancel(struct xfs_defer_ops *dop);
-void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop,
- xfs_fsblock_t *fbp);
+void xfs_defer_init(struct xfs_trans *tp, struct xfs_defer_ops *dop);
bool xfs_defer_has_unfinished_work(struct xfs_defer_ops *dop);
int xfs_defer_ijoin(struct xfs_defer_ops *dop, struct xfs_inode *ip);
int xfs_defer_bjoin(struct xfs_defer_ops *dop, struct xfs_buf *bp);
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index d81c17aac710..2ecfb0518580 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1691,7 +1691,7 @@ xfs_refcount_recover_cow_leftovers(
trace_xfs_refcount_recover_extent(mp, agno, &rr->rr_rrec);
/* Free the orphan record */
- xfs_defer_init(tp, &dfops, &tp->t_firstblock);
+ xfs_defer_init(tp, &dfops);
agbno = rr->rr_rrec.rc_startblock - XFS_REFC_COW_START;
fsb = XFS_AGB_TO_FSB(mp, agno, agbno);
error = xfs_refcount_free_cow_extent(mp, tp->t_dfops, fsb,