]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfs: new tracepoint in match_stateid operation
authorJeff Layton <jlayton@kernel.org>
Wed, 18 Jun 2025 13:19:15 +0000 (09:19 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 14 Jul 2025 22:20:27 +0000 (15:20 -0700)
Add new tracepoints in the NFSv4 match_stateid minorversion op that show
the info in both stateids.

Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://lore.kernel.org/r/20250618-nfs-tracepoints-v2-4-540c9fb48da2@kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4proc.c
fs/nfs/nfs4trace.h

index 92f1b2601b67cad5bf5f80e80208f0e94e26678c..ef2077e185b6a7a8c193718e78a2a6519d8358af 100644 (file)
@@ -10692,6 +10692,8 @@ nfs41_free_lock_state(struct nfs_server *server, struct nfs4_lock_state *lsp)
 static bool nfs41_match_stateid(const nfs4_stateid *s1,
                const nfs4_stateid *s2)
 {
+       trace_nfs41_match_stateid(s1, s2);
+
        if (s1->type != s2->type)
                return false;
 
@@ -10709,6 +10711,8 @@ static bool nfs41_match_stateid(const nfs4_stateid *s1,
 static bool nfs4_match_stateid(const nfs4_stateid *s1,
                const nfs4_stateid *s2)
 {
+       trace_nfs4_match_stateid(s1, s2);
+
        return nfs4_stateid_match(s1, s2);
 }
 
index 6ab05261ce34fa1ea1c7bb5877ec901c86850c7b..fe419147f60f1b5a5ac3c24f0532eb24a801ee9f 100644 (file)
@@ -1524,6 +1524,63 @@ DECLARE_EVENT_CLASS(nfs4_inode_stateid_callback_event,
 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_recall);
 DEFINE_NFS4_INODE_STATEID_CALLBACK_EVENT(nfs4_cb_layoutrecall_file);
 
+#define show_stateid_type(type) \
+       __print_symbolic(type, \
+               { NFS4_INVALID_STATEID_TYPE,    "INVALID" }, \
+               { NFS4_SPECIAL_STATEID_TYPE,    "SPECIAL" }, \
+               { NFS4_OPEN_STATEID_TYPE,       "OPEN" }, \
+               { NFS4_LOCK_STATEID_TYPE,       "LOCK" }, \
+               { NFS4_DELEGATION_STATEID_TYPE, "DELEGATION" }, \
+               { NFS4_LAYOUT_STATEID_TYPE,     "LAYOUT" },     \
+               { NFS4_PNFS_DS_STATEID_TYPE,    "PNFS_DS" }, \
+               { NFS4_REVOKED_STATEID_TYPE,    "REVOKED" }, \
+               { NFS4_FREED_STATEID_TYPE,      "FREED" })
+
+DECLARE_EVENT_CLASS(nfs4_match_stateid_event,
+               TP_PROTO(
+                       const nfs4_stateid *s1,
+                       const nfs4_stateid *s2
+               ),
+
+               TP_ARGS(s1, s2),
+
+               TP_STRUCT__entry(
+                       __field(int, s1_seq)
+                       __field(int, s2_seq)
+                       __field(u32, s1_hash)
+                       __field(u32, s2_hash)
+                       __field(int, s1_type)
+                       __field(int, s2_type)
+               ),
+
+               TP_fast_assign(
+                       __entry->s1_seq = s1->seqid;
+                       __entry->s1_hash = nfs_stateid_hash(s1);
+                       __entry->s1_type = s1->type;
+                       __entry->s2_seq = s2->seqid;
+                       __entry->s2_hash = nfs_stateid_hash(s2);
+                       __entry->s2_type = s2->type;
+               ),
+
+               TP_printk(
+                       "s1=%s:%x:%u s2=%s:%x:%u",
+                       show_stateid_type(__entry->s1_type),
+                       __entry->s1_hash, __entry->s1_seq,
+                       show_stateid_type(__entry->s2_type),
+                       __entry->s2_hash, __entry->s2_seq
+               )
+);
+
+#define DEFINE_NFS4_MATCH_STATEID_EVENT(name) \
+       DEFINE_EVENT(nfs4_match_stateid_event, name, \
+                       TP_PROTO( \
+                               const nfs4_stateid *s1, \
+                               const nfs4_stateid *s2 \
+                       ), \
+                       TP_ARGS(s1, s2))
+DEFINE_NFS4_MATCH_STATEID_EVENT(nfs41_match_stateid);
+DEFINE_NFS4_MATCH_STATEID_EVENT(nfs4_match_stateid);
+
 DECLARE_EVENT_CLASS(nfs4_idmap_event,
                TP_PROTO(
                        const char *name,