]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: create specialized classes for refcount tracepoints
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:23:05 +0000 (11:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:37:05 +0000 (11:37 -0700)
The only user of the "ag" tracepoint event classes is the refcount
btree, so rename them to make that obvious and make them take the btree
cursor to simplify the arguments.  This will save us a lot of trouble
later on.

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

index 77acd311aa55ce364831b42c36813f8fae2d4645..1916f8281450eaeb44a5f10dea3754b660c53f5a 100644 (file)
@@ -51,7 +51,7 @@ xfs_refcount_lookup_le(
        xfs_agblock_t           bno,
        int                     *stat)
 {
-       trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno,
+       trace_xfs_refcount_lookup(cur,
                        xfs_refcount_encode_startblock(bno, domain),
                        XFS_LOOKUP_LE);
        cur->bc_rec.rc.rc_startblock = bno;
@@ -71,7 +71,7 @@ xfs_refcount_lookup_ge(
        xfs_agblock_t           bno,
        int                     *stat)
 {
-       trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno,
+       trace_xfs_refcount_lookup(cur,
                        xfs_refcount_encode_startblock(bno, domain),
                        XFS_LOOKUP_GE);
        cur->bc_rec.rc.rc_startblock = bno;
@@ -91,7 +91,7 @@ xfs_refcount_lookup_eq(
        xfs_agblock_t           bno,
        int                     *stat)
 {
-       trace_xfs_refcount_lookup(cur->bc_mp, cur->bc_ag.pag->pag_agno,
+       trace_xfs_refcount_lookup(cur,
                        xfs_refcount_encode_startblock(bno, domain),
                        XFS_LOOKUP_LE);
        cur->bc_rec.rc.rc_startblock = bno;
@@ -1262,11 +1262,9 @@ xfs_refcount_adjust(
        int                     error;
 
        if (adj == XFS_REFCOUNT_ADJUST_INCREASE)
-               trace_xfs_refcount_increase(cur->bc_mp,
-                               cur->bc_ag.pag->pag_agno, *agbno, *aglen);
+               trace_xfs_refcount_increase(cur, *agbno, *aglen);
        else
-               trace_xfs_refcount_decrease(cur->bc_mp,
-                               cur->bc_ag.pag->pag_agno, *agbno, *aglen);
+               trace_xfs_refcount_decrease(cur, *agbno, *aglen);
 
        /*
         * Ensure that no rcextents cross the boundary of the adjustment range.
@@ -1526,8 +1524,7 @@ xfs_refcount_find_shared(
        int                             have;
        int                             error;
 
-       trace_xfs_refcount_find_shared(cur->bc_mp, cur->bc_ag.pag->pag_agno,
-                       agbno, aglen);
+       trace_xfs_refcount_find_shared(cur, agbno, aglen);
 
        /* By default, skip the whole range */
        *fbno = NULLAGBLOCK;
@@ -1614,8 +1611,7 @@ xfs_refcount_find_shared(
        }
 
 done:
-       trace_xfs_refcount_find_shared_result(cur->bc_mp,
-                       cur->bc_ag.pag->pag_agno, *fbno, *flen);
+       trace_xfs_refcount_find_shared_result(cur, *fbno, *flen);
 
 out_error:
        if (error)
@@ -1833,8 +1829,7 @@ __xfs_refcount_cow_alloc(
        xfs_agblock_t           agbno,
        xfs_extlen_t            aglen)
 {
-       trace_xfs_refcount_cow_increase(rcur->bc_mp, rcur->bc_ag.pag->pag_agno,
-                       agbno, aglen);
+       trace_xfs_refcount_cow_increase(rcur, agbno, aglen);
 
        /* Add refcount btree reservation */
        return xfs_refcount_adjust_cow(rcur, agbno, aglen,
@@ -1850,8 +1845,7 @@ __xfs_refcount_cow_free(
        xfs_agblock_t           agbno,
        xfs_extlen_t            aglen)
 {
-       trace_xfs_refcount_cow_decrease(rcur->bc_mp, rcur->bc_ag.pag->pag_agno,
-                       agbno, aglen);
+       trace_xfs_refcount_cow_decrease(rcur, agbno, aglen);
 
        /* Remove refcount btree reservation */
        return xfs_refcount_adjust_cow(rcur, agbno, aglen,
index 42a8f89c8d425b9dec100ee58526a0b708ed80f7..c945b2d9b6bcf30470cad4ea2b8eb01fabcb82d9 100644 (file)
@@ -3176,17 +3176,41 @@ DEFINE_AG_ERROR_EVENT(xfs_ag_resv_init_error);
 
 /* refcount tracepoint classes */
 
-/* reuse the discard trace class for agbno/aglen-based traces */
-#define DEFINE_AG_EXTENT_EVENT(name) DEFINE_DISCARD_EVENT(name)
+DECLARE_EVENT_CLASS(xfs_refcount_class,
+       TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno,
+               xfs_extlen_t len),
+       TP_ARGS(cur, agbno, len),
+       TP_STRUCT__entry(
+               __field(dev_t, dev)
+               __field(xfs_agnumber_t, agno)
+               __field(xfs_agblock_t, agbno)
+               __field(xfs_extlen_t, len)
+       ),
+       TP_fast_assign(
+               __entry->dev = cur->bc_mp->m_super->s_dev;
+               __entry->agno = cur->bc_ag.pag->pag_agno;
+               __entry->agbno = agbno;
+               __entry->len = len;
+       ),
+       TP_printk("dev %d:%d agno 0x%x agbno 0x%x fsbcount 0x%x",
+                 MAJOR(__entry->dev), MINOR(__entry->dev),
+                 __entry->agno,
+                 __entry->agbno,
+                 __entry->len)
+);
+#define DEFINE_REFCOUNT_EVENT(name) \
+DEFINE_EVENT(xfs_refcount_class, name, \
+       TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno, \
+               xfs_extlen_t len), \
+       TP_ARGS(cur, agbno, len))
 
-/* ag btree lookup tracepoint class */
 TRACE_DEFINE_ENUM(XFS_LOOKUP_EQi);
 TRACE_DEFINE_ENUM(XFS_LOOKUP_LEi);
 TRACE_DEFINE_ENUM(XFS_LOOKUP_GEi);
-DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
-       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
-                xfs_agblock_t agbno, xfs_lookup_t dir),
-       TP_ARGS(mp, agno, agbno, dir),
+TRACE_EVENT(xfs_refcount_lookup,
+       TP_PROTO(struct xfs_btree_cur *cur, xfs_agblock_t agbno,
+               xfs_lookup_t dir),
+       TP_ARGS(cur, agbno, dir),
        TP_STRUCT__entry(
                __field(dev_t, dev)
                __field(xfs_agnumber_t, agno)
@@ -3194,8 +3218,8 @@ DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
                __field(xfs_lookup_t, dir)
        ),
        TP_fast_assign(
-               __entry->dev = mp->m_super->s_dev;
-               __entry->agno = agno;
+               __entry->dev = cur->bc_mp->m_super->s_dev;
+               __entry->agno = cur->bc_ag.pag->pag_agno;
                __entry->agbno = agbno;
                __entry->dir = dir;
        ),
@@ -3207,12 +3231,6 @@ DECLARE_EVENT_CLASS(xfs_ag_btree_lookup_class,
                  __entry->dir)
 )
 
-#define DEFINE_AG_BTREE_LOOKUP_EVENT(name) \
-DEFINE_EVENT(xfs_ag_btree_lookup_class, name, \
-       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
-                xfs_agblock_t agbno, xfs_lookup_t dir), \
-       TP_ARGS(mp, agno, agbno, dir))
-
 /* single-rcext tracepoint class */
 DECLARE_EVENT_CLASS(xfs_refcount_extent_class,
        TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
@@ -3456,7 +3474,6 @@ DEFINE_EVENT(xfs_refcount_triple_extent_class, name, \
        TP_ARGS(mp, agno, i1, i2, i3))
 
 /* refcount btree tracepoints */
-DEFINE_AG_BTREE_LOOKUP_EVENT(xfs_refcount_lookup);
 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_get);
 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_update);
 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_insert);
@@ -3466,10 +3483,10 @@ DEFINE_BTREE_ERROR_EVENT(xfs_refcount_delete_error);
 DEFINE_BTREE_ERROR_EVENT(xfs_refcount_update_error);
 
 /* refcount adjustment tracepoints */
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_increase);
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_decrease);
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_increase);
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_cow_decrease);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_increase);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_decrease);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_increase);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_cow_decrease);
 DEFINE_REFCOUNT_TRIPLE_EXTENT_EVENT(xfs_refcount_merge_center_extents);
 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_modify_extent);
 DEFINE_REFCOUNT_EXTENT_EVENT(xfs_refcount_recover_extent);
@@ -3489,8 +3506,8 @@ DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_left_extent_error);
 DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_right_extent_error);
 
 /* reflink helpers */
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared);
-DEFINE_AG_EXTENT_EVENT(xfs_refcount_find_shared_result);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared);
+DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared_result);
 DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error);
 
 DECLARE_EVENT_CLASS(xfs_refcount_deferred_class,