From ac0a22288b7cc1cc034517b96811b80cc6f7ffd9 Mon Sep 17 00:00:00 2001 From: Brian Foster Date: Thu, 4 Oct 2018 21:36:10 -0500 Subject: [PATCH] xfs: drop unnecessary xfs_defer_finish() dfops parameter Source kernel commit: 9e28a242be65b8274742425ca5d146f366205a90 Every caller of xfs_defer_finish() now passes the transaction and its associated ->t_dfops. The xfs_defer_ops parameter is therefore no longer necessary and can be removed. Since most xfs_defer_finish() callers also have to consider xfs_defer_cancel() on error, update the latter to also receive the transaction for consistency. The log recovery code contains an outlier case that cancels a dfops directly without an available transaction. Retain an internal wrapper to support this outlier case for the time being. Signed-off-by: Brian Foster Reviewed-by: Bill O'Donnell Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- include/xfs_trans.h | 4 ++++ libxfs/trans.c | 14 +++++++++++--- libxfs/xfs_attr.c | 27 +++++++++++++-------------- libxfs/xfs_attr_remote.c | 8 ++++---- libxfs/xfs_defer.c | 7 +++---- libxfs/xfs_defer.h | 4 ++-- 6 files changed, 37 insertions(+), 27 deletions(-) diff --git a/include/xfs_trans.h b/include/xfs_trans.h index 4c722b59e..c11e694f8 100644 --- a/include/xfs_trans.h +++ b/include/xfs_trans.h @@ -104,6 +104,10 @@ int libxfs_trans_alloc_rollable(struct xfs_mount *mp, uint blocks, int libxfs_trans_alloc_empty(struct xfs_mount *mp, struct xfs_trans **tpp); int libxfs_trans_commit(struct xfs_trans *); void libxfs_trans_cancel(struct xfs_trans *); + +/* cancel dfops associated with a transaction */ +void xfs_defer_cancel(struct xfs_trans *); + struct xfs_buf *libxfs_trans_getsb(struct xfs_trans *, struct xfs_mount *, int); int libxfs_trans_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, diff --git a/libxfs/trans.c b/libxfs/trans.c index ec509667c..d1736706d 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -115,6 +115,14 @@ libxfs_trans_roll( return xfs_trans_reserve(*tpp, &tres, 0, 0); } +void +xfs_defer_cancel( + struct xfs_trans *tp) +{ + __xfs_defer_cancel(tp->t_dfops); +} + + /* * Free the transaction structure. If there is more clean up * to do when the structure is freed, add it here. @@ -334,7 +342,7 @@ libxfs_trans_cancel( goto out; if (tp->t_dfops) - xfs_defer_cancel(tp->t_dfops); + xfs_defer_cancel(tp); xfs_trans_free_items(tp); xfs_trans_free(tp); @@ -996,9 +1004,9 @@ __xfs_trans_commit( /* finish deferred items on final commit */ if (!regrant && tp->t_dfops) { - error = xfs_defer_finish(&tp, tp->t_dfops); + error = xfs_defer_finish(&tp); if (error) { - xfs_defer_cancel(tp->t_dfops); + xfs_defer_cancel(tp); goto out_unreserve; } } diff --git a/libxfs/xfs_attr.c b/libxfs/xfs_attr.c index c14e8a346..63c92c764 100644 --- a/libxfs/xfs_attr.c +++ b/libxfs/xfs_attr.c @@ -317,7 +317,7 @@ xfs_attr_set( xfs_trans_bhold(args.trans, leaf_bp); xfs_defer_bjoin(args.trans->t_dfops, leaf_bp); xfs_defer_ijoin(args.trans->t_dfops, dp); - error = xfs_defer_finish(&args.trans, args.trans->t_dfops); + error = xfs_defer_finish(&args.trans); if (error) goto out; @@ -586,7 +586,7 @@ xfs_attr_leaf_addname( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; @@ -675,7 +675,7 @@ xfs_attr_leaf_addname( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; } @@ -693,7 +693,7 @@ xfs_attr_leaf_addname( } return error; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); return error; } @@ -739,13 +739,13 @@ xfs_attr_leaf_removename( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; } return 0; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); return error; } @@ -866,8 +866,7 @@ restart: if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, - args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; @@ -892,7 +891,7 @@ restart: if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; } else { @@ -989,7 +988,7 @@ restart: if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; } @@ -1018,7 +1017,7 @@ out: return error; return retval; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); goto out; } @@ -1113,7 +1112,7 @@ xfs_attr_node_removename( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; /* @@ -1145,7 +1144,7 @@ xfs_attr_node_removename( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; } else @@ -1157,7 +1156,7 @@ out: xfs_da_state_free(state); return error; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); goto out; } diff --git a/libxfs/xfs_attr_remote.c b/libxfs/xfs_attr_remote.c index 73e8598a7..2c03d4dbc 100644 --- a/libxfs/xfs_attr_remote.c +++ b/libxfs/xfs_attr_remote.c @@ -482,7 +482,7 @@ xfs_attr_rmtval_set( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; @@ -550,7 +550,7 @@ xfs_attr_rmtval_set( ASSERT(valuelen == 0); return 0; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); return error; } @@ -623,7 +623,7 @@ xfs_attr_rmtval_remove( if (error) goto out_defer_cancel; xfs_defer_ijoin(args->trans->t_dfops, args->dp); - error = xfs_defer_finish(&args->trans, args->trans->t_dfops); + error = xfs_defer_finish(&args->trans); if (error) goto out_defer_cancel; @@ -636,6 +636,6 @@ xfs_attr_rmtval_remove( } return 0; out_defer_cancel: - xfs_defer_cancel(args->trans->t_dfops); + xfs_defer_cancel(args->trans); return error; } diff --git a/libxfs/xfs_defer.c b/libxfs/xfs_defer.c index d8b940efb..bfc9f7f97 100644 --- a/libxfs/xfs_defer.c +++ b/libxfs/xfs_defer.c @@ -342,9 +342,9 @@ xfs_defer_reset( */ int xfs_defer_finish( - struct xfs_trans **tp, - struct xfs_defer_ops *dop) + struct xfs_trans **tp) { + struct xfs_defer_ops *dop = (*tp)->t_dfops; struct xfs_defer_pending *dfp; struct list_head *li; struct list_head *n; @@ -353,7 +353,6 @@ xfs_defer_finish( void (*cleanup_fn)(struct xfs_trans *, void *, int); ASSERT((*tp)->t_flags & XFS_TRANS_PERM_LOG_RES); - ASSERT((*tp)->t_dfops == dop); trace_xfs_defer_finish((*tp)->t_mountp, dop, _RET_IP_); @@ -454,7 +453,7 @@ out: * Free up any items left in the list. */ void -xfs_defer_cancel( +__xfs_defer_cancel( struct xfs_defer_ops *dop) { struct xfs_defer_pending *dfp; diff --git a/libxfs/xfs_defer.h b/libxfs/xfs_defer.h index 35507ca9a..56f927803 100644 --- a/libxfs/xfs_defer.h +++ b/libxfs/xfs_defer.h @@ -48,8 +48,8 @@ enum xfs_defer_ops_type { 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); +int xfs_defer_finish(struct xfs_trans **tp); +void __xfs_defer_cancel(struct xfs_defer_ops *dop); 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); -- 2.47.2