Skip to contentSkip to conversation

nfs: client-side tracepoints for delegations and cache coherency

PATCH New Jeff Layton 1 participant 5 messages Jun 18, 2025

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

v2 cover nfs: client-side tracepoints for delegations and cache coherency

These patches add some tracepoints that I rolled a while back when working on the client-side pieces of the directory delegation patchset. I think that these are useful in their own right, even without dir delegations.

Please consider these for v6.17.

---
Changes in v2:
- add NFS4_FREED_STATEID_TYPE to match_stateid tracepoint
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (4):
nfs: add cache_validity to the nfs_inode_event tracepoints
nfs: add a tracepoint to nfs_inode_detach_delegation_locked
nfs: new tracepoint in nfs_delegation_need_return
nfs: new tracepoint in match_stateid operation

 fs/nfs/delegation.c |   4 ++
 fs/nfs/nfs4proc.c   |   4 ++
 fs/nfs/nfs4trace.h  | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfstrace.h   |   8 +++-
 4 files changed, 119 insertions(+), 2 deletions(-)

---
base-commit: 52da431bf03b5506203bca27fe14a97895c80faf
change-id: 20250603-nfs-tracepoints-034454716137

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/4 nfs: add cache_validity to the nfs_inode_event tracepoints

Managing the cache_validity flags is the deep voodoo of NFS cache coherency. Let's have a little extra visibility into that value via the nfs_inode_event tracepoints.

---
 fs/nfs/nfstrace.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
fs/nfs/nfstrace.h +6 -2
index 7a058bd8c566e2976e24136e2901fbaa7070daac..55170cbf2ff115c85f56cbafb4fc0e06313918cf 100644
@@ -56,6 +56,7 @@ DECLARE_EVENT_CLASS(nfs_inode_event,
 			__field(u32, fhandle)
 			__field(u64, fileid)
 			__field(u64, version)
+			__field(unsigned long, cache_validity)
 		),
 
 		TP_fast_assign(
@@ -64,14 +65,17 @@ DECLARE_EVENT_CLASS(nfs_inode_event,
 			__entry->fileid = nfsi->fileid;
 			__entry->fhandle = nfs_fhandle_hash(&nfsi->fh);
 			__entry->version = inode_peek_iversion_raw(inode);
+			__entry->cache_validity = nfsi->cache_validity;
 		),
 
 		TP_printk(
-			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu ",
+			"fileid=%02x:%02x:%llu fhandle=0x%08x version=%llu cache_validity=0x%lx (%s)",
 			MAJOR(__entry->dev), MINOR(__entry->dev),
 			(unsigned long long)__entry->fileid,
 			__entry->fhandle,
-			(unsigned long long)__entry->version
+			(unsigned long long)__entry->version,
+			__entry->cache_validity,
+			nfs_show_cache_validity(__entry->cache_validity)
 		)
 );
 
Signature · 1 line
2.49.0
author maintainer
#2 lore raw

PATCH v2 2/4 nfs: add a tracepoint to nfs_inode_detach_delegation_locked

In reply to Jeff Layton

We have tracepoints for setting a delegation and reclaiming them. Add a tracepoint for when the delegation is being detached from the inode.

---
 fs/nfs/delegation.c | 2 ++
 fs/nfs/nfs4trace.h  | 1 +
 2 files changed, 3 insertions(+)
fs/nfs/delegation.c +2 -0
index 10ef46e29b2544920c026f023885301d5d8e22cd..78a97d340bbd98390ca8302176c17caf08dcab4a 100644
@@ -355,6 +355,8 @@ nfs_detach_delegation_locked(struct nfs_inode *nfsi,
 		rcu_dereference_protected(nfsi->delegation,
 				lockdep_is_held(&clp->cl_lock));
 
+	trace_nfs4_detach_delegation(&nfsi->vfs_inode, delegation->type);
+
 	if (deleg_cur == NULL || delegation != deleg_cur)
 		return NULL;
 
fs/nfs/nfs4trace.h +1 -0
index deab4c0e21a0642ee97b0b81f8c55812f5028f7c..6e1c4590ef9bf60eac994e85be816e82f5e0c741 100644
@@ -956,6 +956,7 @@ DECLARE_EVENT_CLASS(nfs4_set_delegation_event,
 			TP_ARGS(inode, fmode))
 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
 DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
+DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_detach_delegation);
 
 TRACE_EVENT(nfs4_delegreturn_exit,
 		TP_PROTO(
Signature · 1 line
2.49.0
author maintainer
#3 lore raw

PATCH v2 3/4 nfs: new tracepoint in nfs_delegation_need_return

In reply to Jeff Layton

Add a tracepoint in the function that decides whether to return a delegation to the server.

---
 fs/nfs/delegation.c |  2 ++
 fs/nfs/nfs4trace.h  | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
fs/nfs/delegation.c +2 -0
index 78a97d340bbd98390ca8302176c17caf08dcab4a..6f136c47eed7f1801af337f0e88f1a6bf477d0c6 100644
@@ -594,6 +594,8 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation)
 {
 	bool ret = false;
 
+	trace_nfs_delegation_need_return(delegation);
+
 	if (test_and_clear_bit(NFS_DELEGATION_RETURN, &delegation->flags))
 		ret = true;
 	if (test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) ||
fs/nfs/nfs4trace.h +47 -0

59 lines not on this page · raw message

Signature · 1 line
2.49.0
author maintainer
#4 lore raw

PATCH v2 4/4 nfs: new tracepoint in match_stateid operation

In reply to Jeff Layton

Add new tracepoints in the NFSv4 match_stateid minorversion op that show the info in both stateids.

---
 fs/nfs/nfs4proc.c  |  4 ++++
 fs/nfs/nfs4trace.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)
fs/nfs/nfs4proc.c +4 -0
index 341740fa293d8fb1cfabe0813c7fcadf04df4f62..80126290589aaccd801c8965252523894e37c44a 100644
@@ -10680,6 +10680,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;
 
@@ -10697,6 +10699,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);
 }
 
fs/nfs/nfs4trace.h +57 -0

63 lines not on this page · raw message

Signature · 1 line
2.49.0