]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xfs: only relog deferred intent items if free space in the log gets low
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 16 Feb 2023 05:20:14 +0000 (10:50 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:50:37 +0000 (12:50 +0100)
commit 05f0c16f5a2c159655e4226c98d6420b32f8ce1e upstream.

Now that we have the ability to ask the log how far the tail needs to be
pushed to maintain its free space targets, augment the decision to relog
an intent item so that we only do it if the log has hit the 75% full
threshold.  There's no point in relogging an intent into the same
checkpoint, and there's no need to relog if there's plenty of free space
in the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/xfs/libxfs/xfs_defer.c

index b0b3823234136a3ecc17a8ae9bdfcebb0c0518aa..3a78a189ea01828ed7a829c0546c3d40bfd259e0 100644 (file)
@@ -372,7 +372,10 @@ xfs_defer_relog(
        struct xfs_trans                **tpp,
        struct list_head                *dfops)
 {
+       struct xlog                     *log = (*tpp)->t_mountp->m_log;
        struct xfs_defer_pending        *dfp;
+       xfs_lsn_t                       threshold_lsn = NULLCOMMITLSN;
+
 
        ASSERT((*tpp)->t_flags & XFS_TRANS_PERM_LOG_RES);
 
@@ -388,6 +391,19 @@ xfs_defer_relog(
                    xfs_log_item_in_current_chkpt(dfp->dfp_intent))
                        continue;
 
+               /*
+                * Figure out where we need the tail to be in order to maintain
+                * the minimum required free space in the log.  Only sample
+                * the log threshold once per call.
+                */
+               if (threshold_lsn == NULLCOMMITLSN) {
+                       threshold_lsn = xlog_grant_push_threshold(log, 0);
+                       if (threshold_lsn == NULLCOMMITLSN)
+                               break;
+               }
+               if (XFS_LSN_CMP(dfp->dfp_intent->li_lsn, threshold_lsn) >= 0)
+                       continue;
+
                trace_xfs_defer_relog_intent((*tpp)->t_mountp, dfp);
                XFS_STATS_INC((*tpp)->t_mountp, defer_relog);
                dfp->dfp_intent = xfs_trans_item_relog(dfp->dfp_intent, *tpp);