]> www.infradead.org Git - users/hch/misc.git/commitdiff
xfs: avoid nested calls to __xfs_trans_commit
authorDarrick J. Wong <djwong@kernel.org>
Mon, 2 Dec 2024 18:57:34 +0000 (10:57 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 13 Dec 2024 01:45:11 +0000 (17:45 -0800)
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>
fs/xfs/xfs_trans.c

index 4a517250efc911d4ed974895cbb66f4c5b71414d..26bb2343082af4c1a51cc422a3fdc927688a06b8 100644 (file)
@@ -860,18 +860,6 @@ __xfs_trans_commit(
 
        trace_xfs_trans_commit(tp, _RET_IP_);
 
-       /*
-        * Finish deferred items on final commit. Only permanent transactions
-        * should ever have deferred ops.
-        */
-       WARN_ON_ONCE(!list_empty(&tp->t_dfops) &&
-                    !(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
-       if (!regrant && (tp->t_flags & XFS_TRANS_PERM_LOG_RES)) {
-               error = xfs_defer_finish_noroll(&tp);
-               if (error)
-                       goto out_unreserve;
-       }
-
        error = xfs_trans_run_precommits(tp);
        if (error)
                goto out_unreserve;
@@ -950,6 +938,20 @@ int
 xfs_trans_commit(
        struct xfs_trans        *tp)
 {
+       /*
+        * Finish deferred items on final commit. Only permanent transactions
+        * should ever have deferred ops.
+        */
+       WARN_ON_ONCE(!list_empty(&tp->t_dfops) &&
+                    !(tp->t_flags & XFS_TRANS_PERM_LOG_RES));
+       if (tp->t_flags & XFS_TRANS_PERM_LOG_RES) {
+               int error = xfs_defer_finish_noroll(&tp);
+               if (error) {
+                       xfs_trans_cancel(tp);
+                       return error;
+               }
+       }
+
        return __xfs_trans_commit(tp, false);
 }