]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: bypass final dfops roll in trans commit path
authorBrian Foster <bfoster@redhat.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
Source kernel commit: b277c37f43dd387f7430a2186deda0e58c943087

Once xfs_defer_finish() has completed all deferred operations, it
checks the dirty state of the transaction and rolls it once more to
return a clean transaction for the caller. This primarily to cover
the case where repeated xfs_defer_finish() calls are made in a loop
and we need to make sure that the caller starts the next iteration
with a clean transaction. Otherwise we risk transaction reservation
overrun.

This final transaction roll is not required in the transaction
into a separate helper such that we can avoid it in the transaction
until after the last call to xfs_defer_trans_roll(). The reset is
also unnecessary in the transaction commit path because the
transaction is about to complete.

This eliminates unnecessary regrants of transactions where the
associated transaction roll can be replaced by a transaction commit.

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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/trans.c
libxfs/xfs_defer.c
libxfs/xfs_defer.h

index d1736706da9f16dac56cb7bdb47d49490f0011e6..bda2d8c6808d5e8efc308129b9d4173ffa847bd1 100644 (file)
@@ -1004,7 +1004,7 @@ __xfs_trans_commit(
 
        /* finish deferred items on final commit */
        if (!regrant && tp->t_dfops) {
-               error = xfs_defer_finish(&tp);
+               error = xfs_defer_finish_noroll(&tp);
                if (error) {
                        xfs_defer_cancel(tp);
                        goto out_unreserve;
index bfc9f7f97ce64302c782bfb2baacb5e56199b291..1cd865dceda5989f68bf1766a5cf865c2a5e138b 100644 (file)
@@ -341,7 +341,7 @@ xfs_defer_reset(
  * If an inode is provided, relog it to the new transaction.
  */
 int
-xfs_defer_finish(
+xfs_defer_finish_noroll(
        struct xfs_trans                **tp)
 {
        struct xfs_defer_ops            *dop = (*tp)->t_dfops;
@@ -430,25 +430,37 @@ xfs_defer_finish(
                        cleanup_fn(*tp, state, error);
        }
 
-       /*
-        * Roll the transaction once more to avoid returning to the caller
-        * with a dirty transaction.
-        */
-       if ((*tp)->t_flags & XFS_TRANS_DIRTY) {
-               error = xfs_defer_trans_roll(tp);
-               dop = (*tp)->t_dfops;
-       }
 out:
-       if (error) {
+       if (error)
                trace_xfs_defer_finish_error((*tp)->t_mountp, dop, error);
-       } else {
+        else
                trace_xfs_defer_finish_done((*tp)->t_mountp, dop, _RET_IP_);
-               xfs_defer_reset(dop);
-       }
 
        return error;
 }
 
+int
+xfs_defer_finish(
+       struct xfs_trans        **tp)
+{
+       int                     error;
+
+       /*
+        * Finish and roll the transaction once more to avoid returning to the
+        * caller with a dirty transaction.
+        */
+       error = xfs_defer_finish_noroll(tp);
+       if (error)
+               return error;
+       if ((*tp)->t_flags & XFS_TRANS_DIRTY) {
+               error = xfs_defer_trans_roll(tp);
+               if (error)
+                       return error;
+       }
+       xfs_defer_reset((*tp)->t_dfops);
+       return 0;
+}
+
 /*
  * Free up any items left in the list.
  */
index 56f9278039407d94b7bf6b8dce26b7978ca1b69b..85c41fe4dbaebb4c4460e26da062910c5f12daa1 100644 (file)
@@ -48,6 +48,7 @@ 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_noroll(struct xfs_trans **tp);
 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);