]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
xfs: don't lose solo superblock counter update transactions
authorDarrick J. Wong <djwong@kernel.org>
Mon, 2 Dec 2024 18:57:35 +0000 (10:57 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Fri, 13 Dec 2024 01:45:11 +0000 (17:45 -0800)
Superblock counter updates are tracked via per-transaction counters in
the xfs_trans object.  These changes are then turned into dirty log
items in xfs_trans_apply_sb_deltas just prior to commiting the log items
to the CIL.

However, updating the per-transaction counter deltas do not cause
XFS_TRANS_DIRTY to be set on the transaction.  In other words, a pure sb
counter update will be silently discarded if there are no other dirty
log items attached to the transaction.

This is currently not the case anywhere in the filesystem because sb
counter updates always dirty at least one other metadata item, but let's
not leave a logic bomb.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_trans.c

index 26bb2343082af4c1a51cc422a3fdc927688a06b8..427a8ba0ab99e223f1ffb61a9b0a1e6ef19a8c66 100644 (file)
@@ -860,6 +860,13 @@ __xfs_trans_commit(
 
        trace_xfs_trans_commit(tp, _RET_IP_);
 
+       /*
+        * Commit per-transaction changes that are not already tracked through
+        * log items.  This can add dirty log items to the transaction.
+        */
+       if (tp->t_flags & XFS_TRANS_SB_DIRTY)
+               xfs_trans_apply_sb_deltas(tp);
+
        error = xfs_trans_run_precommits(tp);
        if (error)
                goto out_unreserve;
@@ -890,8 +897,6 @@ __xfs_trans_commit(
        /*
         * If we need to update the superblock, then do it now.
         */
-       if (tp->t_flags & XFS_TRANS_SB_DIRTY)
-               xfs_trans_apply_sb_deltas(tp);
        xfs_trans_apply_dquot_deltas(tp);
 
        xlog_cil_commit(log, tp, &commit_seq, regrant);