Skip to content

Commit a004afd

Browse files
author
Darrick J. Wong
committed
xfs: avoid nested calls to __xfs_trans_commit
Currently, __xfs_trans_commit calls xfs_defer_finish_noroll, which calls __xfs_trans_commit again on the same transaction. In other words, there's a nested function call (albeit with slightly different arguments) that has caused minor amounts of confusion in the past. There's no reason to keep this around, since there's only one place where we actually want the xfs_defer_finish_noroll, and that is in the top level xfs_trans_commit call. This also reduces stack usage a little bit. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent 44d9b07 commit a004afd

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

fs/xfs/xfs_trans.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -860,18 +860,6 @@ __xfs_trans_commit(
860860

861861
trace_xfs_trans_commit(tp, _RET_IP_);
862862

863-
/*
864-
* Finish deferred items on final commit. Only permanent transactions
865-
* should ever have deferred ops.
866-
*/
867-
WARN_ON_ONCE(!list_empty(&tp->t_dfops) &&
868-
!(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
869-
if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) {
870-
error = xfs_defer_finish_noroll(&tp);
871-
if (error)
872-
goto out_unreserve;
873-
}
874-
875863
error = xfs_trans_run_precommits(tp);
876864
if (error)
877865
goto out_unreserve;
@@ -950,6 +938,20 @@ int
950938
xfs_trans_commit(
951939
struct xfs_trans *tp)
952940
{
941+
/*
942+
* Finish deferred items on final commit. Only permanent transactions
943+
* should ever have deferred ops.
944+
*/
945+
WARN_ON_ONCE(!list_empty(&tp->t_dfops) &&
946+
!(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
947+
if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) {
948+
int error = xfs_defer_finish_noroll(&tp);
949+
if (error) {
950+
xfs_trans_cancel(tp);
951+
return error;
952+
}
953+
}
954+
953955
return __xfs_trans_commit(tp, false);
954956
}
955957

0 commit comments

Comments
 (0)