summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-01-05 17:46:08 -0800
committerDarrick J. Wong <djwong@kernel.org>2021-03-25 17:08:54 -0700
commit077f94200f28630fc14e2347cf89d47135f878ef (patch)
treeb9455d8e87beab6608ce3d2791ae2181a6a3db4e
parent0193fdacb9ef1c53eb36b3a457fa2cb8403bb477 (diff)
xfs: track deferred ops statistics
Track some basic statistics on how hard we're pushing the defer ops. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/libxfs/xfs_defer.c14
-rw-r--r--fs/xfs/xfs_trace.h19
-rw-r--r--fs/xfs/xfs_trans.c2
-rw-r--r--fs/xfs/xfs_trans.h7
4 files changed, 42 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c
index 927e7245d7ec..dc6fbfc2cadd 100644
--- a/fs/xfs/libxfs/xfs_defer.c
+++ b/fs/xfs/libxfs/xfs_defer.c
@@ -441,6 +441,8 @@ xfs_defer_finish_one(
/* Done with the dfp, free it. */
list_del(&dfp->dfp_list);
kmem_free(dfp);
+ tp->t_dfops_nr--;
+ tp->t_dfops_finished++;
out:
if (ops->finish_cleanup)
ops->finish_cleanup(tp, state, error);
@@ -481,6 +483,9 @@ xfs_defer_finish_noroll(
xfs_defer_create_intents(*tp);
list_splice_init(&(*tp)->t_dfops, &dop_pending);
+ (*tp)->t_dfops_nr_max = max((*tp)->t_dfops_nr,
+ (*tp)->t_dfops_nr_max);
+
error = xfs_defer_trans_roll(tp);
if (error)
goto out_shutdown;
@@ -505,6 +510,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;
}
@@ -545,6 +551,7 @@ xfs_defer_cancel(
trace_xfs_defer_cancel(tp, _RET_IP_);
xfs_defer_cancel_list(mp, &tp->t_dfops);
+ tp->t_dfops_nr = 0;
}
/* Add an item for later deferred processing. */
@@ -582,6 +589,7 @@ xfs_defer_add(
dfp->dfp_count = 0;
INIT_LIST_HEAD(&dfp->dfp_work);
list_add_tail(&dfp->dfp_list, &tp->t_dfops);
+ tp->t_dfops_nr++;
}
list_add_tail(li, &dfp->dfp_work);
@@ -599,6 +607,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.
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
index 906ae35d3136..df2fe071de0c 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
@@ -2388,6 +2388,25 @@ DEFINE_BTREE_CUR_EVENT(xfs_btree_overlapped_query_range);
/* deferred ops */
struct xfs_defer_pending;
+TRACE_EVENT(xfs_defer_stats,
+ TP_PROTO(struct xfs_trans *tp),
+ TP_ARGS(tp),
+ TP_STRUCT__entry(
+ __field(dev_t, dev)
+ __field(unsigned int, max)
+ __field(unsigned int, finished)
+ ),
+ TP_fast_assign(
+ __entry->dev = tp->t_mountp->m_super->s_dev;
+ __entry->max = tp->t_dfops_nr_max;
+ __entry->finished = tp->t_dfops_finished;
+ ),
+ TP_printk("dev %d:%d max %u finished %u",
+ MAJOR(__entry->dev), MINOR(__entry->dev),
+ __entry->max,
+ __entry->finished)
+)
+
DECLARE_EVENT_CLASS(xfs_defer_class,
TP_PROTO(struct xfs_trans *tp, unsigned long caller_ip),
TP_ARGS(tp, caller_ip),
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 09aa14579239..4f04bb4b2c52 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -73,6 +73,8 @@ xfs_trans_free(
if (tp->t_flags & XFS_TRANS_LOG_INCOMPAT)
xlog_drop_incompat_feat(tp->t_mountp->m_log);
+ if (tp->t_dfops_finished > 0)
+ trace_xfs_defer_stats(tp);
trace_xfs_trans_free(tp, _RET_IP_);
xfs_trans_clear_context(tp);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 1ec37485592e..57565fb86f5a 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -157,6 +157,13 @@ typedef struct xfs_trans {
struct list_head t_busy; /* list of busy extents */
struct list_head t_dfops; /* deferred operations */
unsigned long t_pflags; /* saved process flags state */
+
+ /* Count of deferred ops attached to transaction. */
+ unsigned int t_dfops_nr;
+ /* Maximum t_dfops_nr seen in a loop. */
+ unsigned int t_dfops_nr_max;
+ /* Number of dfops finished. */
+ unsigned int t_dfops_finished;
} xfs_trans_t;
/*