]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: track deferred ops statistics
authorDarrick J. Wong <djwong@kernel.org>
Wed, 7 Aug 2024 22:54:51 +0000 (15:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 14 Aug 2024 03:08:25 +0000 (20:08 -0700)
Track some basic statistics on how hard we're pushing the defer ops.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
include/xfs_trans.h
libxfs/xfs_defer.c

index 248064019a0ab567d0c0ba3022ed10f043d2689b..64d73c36851b75e1ae670ff05bbb6fce37dc7308 100644 (file)
@@ -82,6 +82,10 @@ typedef struct xfs_trans {
        long                    t_frextents_delta;/* superblock freextents chg*/
        struct list_head        t_items;        /* log item descriptors */
        struct list_head        t_dfops;        /* deferred operations */
+
+       unsigned int    t_dfops_nr;
+       unsigned int    t_dfops_nr_max;
+       unsigned int    t_dfops_finished;
 } xfs_trans_t;
 
 void   xfs_trans_init(struct xfs_mount *);
index 8f6708c0f3bfcd22a775ceccac2b12b3a1669bfe..7e6167949f6509a0c9dd95e716bd6113084532f3 100644 (file)
@@ -611,6 +611,8 @@ xfs_defer_finish_one(
        /* Done with the dfp, free it. */
        list_del(&dfp->dfp_list);
        kmem_cache_free(xfs_defer_pending_cache, dfp);
+       tp->t_dfops_nr--;
+       tp->t_dfops_finished++;
 out:
        if (ops->finish_cleanup)
                ops->finish_cleanup(tp, state, error);
@@ -673,6 +675,9 @@ xfs_defer_finish_noroll(
 
                list_splice_init(&(*tp)->t_dfops, &dop_pending);
 
+               (*tp)->t_dfops_nr_max = max((*tp)->t_dfops_nr,
+                                           (*tp)->t_dfops_nr_max);
+
                if (has_intents < 0) {
                        error = has_intents;
                        goto out_shutdown;
@@ -714,6 +719,7 @@ out_shutdown:
        xfs_force_shutdown((*tp)->t_mountp, SHUTDOWN_CORRUPT_INCORE);
        trace_xfs_defer_finish_error(*tp, error);
        xfs_defer_cancel_list((*tp)->t_mountp, &dop_pending);
+       (*tp)->t_dfops_nr = 0;
        xfs_defer_cancel(*tp);
        return error;
 }
@@ -761,6 +767,7 @@ xfs_defer_cancel(
        trace_xfs_defer_cancel(tp, _RET_IP_);
        xfs_defer_trans_abort(tp, &tp->t_dfops);
        xfs_defer_cancel_list(mp, &tp->t_dfops);
+       tp->t_dfops_nr = 0;
 }
 
 /*
@@ -846,8 +853,10 @@ xfs_defer_add(
        }
 
        dfp = xfs_defer_find_last(tp, ops);
-       if (!dfp || !xfs_defer_can_append(dfp, ops))
+       if (!dfp || !xfs_defer_can_append(dfp, ops)) {
                dfp = xfs_defer_alloc(&tp->t_dfops, ops);
+               tp->t_dfops_nr++;
+       }
 
        xfs_defer_add_item(dfp, li);
        trace_xfs_defer_add_item(tp->t_mountp, dfp, li);
@@ -872,6 +881,7 @@ xfs_defer_add_barrier(
                return;
 
        xfs_defer_alloc(&tp->t_dfops, &xfs_barrier_defer_type);
+       tp->t_dfops_nr++;
 
        trace_xfs_defer_add_item(tp->t_mountp, dfp, NULL);
 }
@@ -932,6 +942,12 @@ xfs_defer_move(
        struct xfs_trans        *stp)
 {
        list_splice_init(&stp->t_dfops, &dtp->t_dfops);
+       dtp->t_dfops_nr += stp->t_dfops_nr;
+       dtp->t_dfops_nr_max = stp->t_dfops_nr_max;
+       dtp->t_dfops_finished = stp->t_dfops_finished;
+       stp->t_dfops_nr = 0;
+       stp->t_dfops_nr_max = 0;
+       stp->t_dfops_finished = 0;
 
        /*
         * Low free space mode was historically controlled by a dfops field.