diff mbox series

[v29,02/15] xfs: don't commit the first deferred transaction without intents

Message ID 20220323210715.201009-3-allison.henderson@oracle.com (mailing list archive)
State Superseded
Headers show
Series xfs: Log Attribute Replay | expand

Commit Message

Allison Henderson March 23, 2022, 9:07 p.m. UTC
If the first operation in a string of defer ops has no intents,
then there is no reason to commit it before running the first call
to xfs_defer_finish_one(). This allows the defer ops to be used
effectively for non-intent based operations without requiring an
unnecessary extra transaction commit when first called.

This fixes a regression in per-attribute modification transaction
count when delayed attributes are not being used.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandan.babu@oracle.com>
---
 fs/xfs/libxfs/xfs_defer.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 6dac8d6b8c21..5b3f3a7f1f65 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -510,9 +510,16 @@  xfs_defer_finish_noroll(
 		xfs_defer_create_intents(*tp);
 		list_splice_init(&(*tp)->t_dfops, &dop_pending);
 
-		error = xfs_defer_trans_roll(tp);
-		if (error)
-			goto out_shutdown;
+		/*
+		 * We must ensure the transaction is clean before we try to
+		 * finish the next deferred item by committing logged intent
+		 * items and anything else that dirtied the transaction.
+		 */
+		if ((*tp)->t_flags & XFS_TRANS_DIRTY) {
+			error = xfs_defer_trans_roll(tp);
+			if (error)
+				goto out_shutdown;
+		}
 
 		/* Possibly relog intent items to keep the log moving. */
 		error = xfs_defer_relog(tp, &dop_pending);