]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: clean up refcount log intent item tracepoint callsites
authorDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:23:07 +0000 (11:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 2 Jul 2024 18:37:06 +0000 (11:37 -0700)
Pass the incore refcount intent structure to the tracepoints instead of
open-coding the argument passing.

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

index b777762494e7f71a8b80c30367b4d4b0c971c75c..c0572bb86cdb861d58b35630f2c76f0ae0050653 100644 (file)
@@ -1367,9 +1367,7 @@ xfs_refcount_finish_one(
 
        bno = XFS_FSB_TO_AGBNO(mp, ri->ri_startblock);
 
-       trace_xfs_refcount_deferred(mp, XFS_FSB_TO_AGNO(mp, ri->ri_startblock),
-                       ri->ri_type, XFS_FSB_TO_AGBNO(mp, ri->ri_startblock),
-                       ri->ri_blockcount);
+       trace_xfs_refcount_deferred(mp, ri);
 
        if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE))
                return -EIO;
@@ -1432,8 +1430,7 @@ xfs_refcount_finish_one(
                return -EFSCORRUPTED;
        }
        if (!error && ri->ri_blockcount > 0)
-               trace_xfs_refcount_finish_one_leftover(mp, ri->ri_pag->pag_agno,
-                               ri->ri_type, bno, ri->ri_blockcount);
+               trace_xfs_refcount_finish_one_leftover(mp, ri);
        return error;
 }
 
@@ -1449,11 +1446,6 @@ __xfs_refcount_add(
 {
        struct xfs_refcount_intent      *ri;
 
-       trace_xfs_refcount_defer(tp->t_mountp,
-                       XFS_FSB_TO_AGNO(tp->t_mountp, startblock),
-                       type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
-                       blockcount);
-
        ri = kmem_cache_alloc(xfs_refcount_intent_cache,
                        GFP_KERNEL | __GFP_NOFAIL);
        INIT_LIST_HEAD(&ri->ri_list);
@@ -1461,6 +1453,8 @@ __xfs_refcount_add(
        ri->ri_startblock = startblock;
        ri->ri_blockcount = blockcount;
 
+       trace_xfs_refcount_defer(tp->t_mountp, ri);
+
        xfs_refcount_update_get_group(tp->t_mountp, ri);
        xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
 }
index 9b56768a590c01f5adf132abf3a77f9bd67f90d8..01a20621192ed2d434eaa696fed5e92dfdd199f0 100644 (file)
@@ -48,6 +48,12 @@ enum xfs_refcount_intent_type {
        XFS_REFCOUNT_FREE_COW,
 };
 
+#define XFS_REFCOUNT_INTENT_STRINGS \
+       { XFS_REFCOUNT_INCREASE,        "incr" }, \
+       { XFS_REFCOUNT_DECREASE,        "decr" }, \
+       { XFS_REFCOUNT_ALLOC_COW,       "alloc_cow" }, \
+       { XFS_REFCOUNT_FREE_COW,        "free_cow" }
+
 struct xfs_refcount_intent {
        struct list_head                        ri_list;
        struct xfs_perag                        *ri_pag;
index ae30178120897f7560c748dfb3b69e968c579b6b..f98fb86ff8d741f44135fab254c4f398497a4c88 100644 (file)
@@ -42,6 +42,7 @@
 #include "xfs_exchrange.h"
 #include "xfs_parent.h"
 #include "xfs_rmap.h"
+#include "xfs_refcount.h"
 
 /*
  * We include this last to have the helpers above available for the trace
index d4725d66a9b2d6528b07a019c8a83dab9f7012d9..56c8333a470bbd2692b949132e73ccac39a7d15b 100644 (file)
@@ -92,6 +92,7 @@ struct xfs_parent_irec;
 struct xfs_attrlist_cursor_kern;
 struct xfs_extent_free_item;
 struct xfs_rmap_intent;
+struct xfs_refcount_intent;
 
 #define XFS_ATTR_FILTER_FLAGS \
        { XFS_ATTR_ROOT,        "ROOT" }, \
@@ -3503,66 +3504,42 @@ DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared);
 DEFINE_REFCOUNT_EVENT(xfs_refcount_find_shared_result);
 DEFINE_BTREE_ERROR_EVENT(xfs_refcount_find_shared_error);
 
+TRACE_DEFINE_ENUM(XFS_REFCOUNT_INCREASE);
+TRACE_DEFINE_ENUM(XFS_REFCOUNT_DECREASE);
+TRACE_DEFINE_ENUM(XFS_REFCOUNT_ALLOC_COW);
+TRACE_DEFINE_ENUM(XFS_REFCOUNT_FREE_COW);
+
 DECLARE_EVENT_CLASS(xfs_refcount_deferred_class,
-       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
-                int type, xfs_agblock_t agbno, xfs_extlen_t len),
-       TP_ARGS(mp, agno, type, agbno, len),
+       TP_PROTO(struct xfs_mount *mp, struct xfs_refcount_intent *refc),
+       TP_ARGS(mp, refc),
        TP_STRUCT__entry(
                __field(dev_t, dev)
                __field(xfs_agnumber_t, agno)
-               __field(int, type)
+               __field(int, op)
                __field(xfs_agblock_t, agbno)
                __field(xfs_extlen_t, len)
        ),
        TP_fast_assign(
                __entry->dev = mp->m_super->s_dev;
-               __entry->agno = agno;
-               __entry->type = type;
-               __entry->agbno = agbno;
-               __entry->len = len;
+               __entry->agno = XFS_FSB_TO_AGNO(mp, refc->ri_startblock);
+               __entry->op = refc->ri_type;
+               __entry->agbno = XFS_FSB_TO_AGBNO(mp, refc->ri_startblock);
+               __entry->len = refc->ri_blockcount;
        ),
-       TP_printk("dev %d:%d op %d agno 0x%x agbno 0x%x fsbcount 0x%x",
+       TP_printk("dev %d:%d op %s agno 0x%x agbno 0x%x fsbcount 0x%x",
                  MAJOR(__entry->dev), MINOR(__entry->dev),
-                 __entry->type,
+                 __print_symbolic(__entry->op, XFS_REFCOUNT_INTENT_STRINGS),
                  __entry->agno,
                  __entry->agbno,
                  __entry->len)
 );
 #define DEFINE_REFCOUNT_DEFERRED_EVENT(name) \
 DEFINE_EVENT(xfs_refcount_deferred_class, name, \
-       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno, \
-                int type, \
-                xfs_agblock_t bno, \
-                xfs_extlen_t len), \
-       TP_ARGS(mp, agno, type, bno, len))
+       TP_PROTO(struct xfs_mount *mp, struct xfs_refcount_intent *refc), \
+       TP_ARGS(mp, refc))
 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_defer);
 DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_deferred);
-
-TRACE_EVENT(xfs_refcount_finish_one_leftover,
-       TP_PROTO(struct xfs_mount *mp, xfs_agnumber_t agno,
-                int type, xfs_agblock_t agbno, xfs_extlen_t len),
-       TP_ARGS(mp, agno, type, agbno, len),
-       TP_STRUCT__entry(
-               __field(dev_t, dev)
-               __field(xfs_agnumber_t, agno)
-               __field(int, type)
-               __field(xfs_agblock_t, agbno)
-               __field(xfs_extlen_t, len)
-       ),
-       TP_fast_assign(
-               __entry->dev = mp->m_super->s_dev;
-               __entry->agno = agno;
-               __entry->type = type;
-               __entry->agbno = agbno;
-               __entry->len = len;
-       ),
-       TP_printk("dev %d:%d type %d agno 0x%x agbno 0x%x fsbcount 0x%x",
-                 MAJOR(__entry->dev), MINOR(__entry->dev),
-                 __entry->type,
-                 __entry->agno,
-                 __entry->agbno,
-                 __entry->len)
-);
+DEFINE_REFCOUNT_DEFERRED_EVENT(xfs_refcount_finish_one_leftover);
 
 /* simple inode-based error/%ip tracepoint class */
 DECLARE_EVENT_CLASS(xfs_inode_error_class,