* [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency
@ 2025-06-18 13:19 Jeff Layton
2025-06-18 13:19 ` [PATCH v2 1/4] nfs: add cache_validity to the nfs_inode_event tracepoints Jeff Layton
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Jeff Layton @ 2025-06-18 13:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: linux-nfs, linux-kernel, Benjamin Coddington, Jeff Layton
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.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
Changes in v2:
- add NFS4_FREED_STATEID_TYPE to match_stateid tracepoint
- Link to v1: https://lore.kernel.org/r/20250603-nfs-tracepoints-v1-0-d2615f3bbe6c@kernel.org
---
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,
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/4] nfs: add cache_validity to the nfs_inode_event tracepoints
2025-06-18 13:19 [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency Jeff Layton
@ 2025-06-18 13:19 ` Jeff Layton
2025-06-18 13:19 ` [PATCH v2 2/4] nfs: add a tracepoint to nfs_inode_detach_delegation_locked Jeff Layton
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-06-18 13:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: linux-nfs, linux-kernel, Benjamin Coddington, Jeff Layton
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.
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfs/nfstrace.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index 7a058bd8c566e2976e24136e2901fbaa7070daac..55170cbf2ff115c85f56cbafb4fc0e06313918cf 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -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)
)
);
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/4] nfs: add a tracepoint to nfs_inode_detach_delegation_locked
2025-06-18 13:19 [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency Jeff Layton
2025-06-18 13:19 ` [PATCH v2 1/4] nfs: add cache_validity to the nfs_inode_event tracepoints Jeff Layton
@ 2025-06-18 13:19 ` Jeff Layton
2025-06-18 13:19 ` [PATCH v2 3/4] nfs: new tracepoint in nfs_delegation_need_return Jeff Layton
2025-06-18 13:19 ` [PATCH v2 4/4] nfs: new tracepoint in match_stateid operation Jeff Layton
3 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-06-18 13:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: linux-nfs, linux-kernel, Benjamin Coddington, 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.
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfs/delegation.c | 2 ++
fs/nfs/nfs4trace.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 10ef46e29b2544920c026f023885301d5d8e22cd..78a97d340bbd98390ca8302176c17caf08dcab4a 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -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;
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index deab4c0e21a0642ee97b0b81f8c55812f5028f7c..6e1c4590ef9bf60eac994e85be816e82f5e0c741 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -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(
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/4] nfs: new tracepoint in nfs_delegation_need_return
2025-06-18 13:19 [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency Jeff Layton
2025-06-18 13:19 ` [PATCH v2 1/4] nfs: add cache_validity to the nfs_inode_event tracepoints Jeff Layton
2025-06-18 13:19 ` [PATCH v2 2/4] nfs: add a tracepoint to nfs_inode_detach_delegation_locked Jeff Layton
@ 2025-06-18 13:19 ` Jeff Layton
2025-06-18 13:19 ` [PATCH v2 4/4] nfs: new tracepoint in match_stateid operation Jeff Layton
3 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-06-18 13:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: linux-nfs, linux-kernel, Benjamin Coddington, Jeff Layton
Add a tracepoint in the function that decides whether to return a
delegation to the server.
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/nfs/delegation.c | 2 ++
fs/nfs/nfs4trace.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 78a97d340bbd98390ca8302176c17caf08dcab4a..6f136c47eed7f1801af337f0e88f1a6bf477d0c6 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -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) ||
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index 6e1c4590ef9bf60eac994e85be816e82f5e0c741..73a6b60a848066546c2ae98b4982b0ab36bb0f73 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -14,6 +14,8 @@
#include <trace/misc/fs.h>
#include <trace/misc/nfs.h>
+#include "delegation.h"
+
#define show_nfs_fattr_flags(valid) \
__print_flags((unsigned long)valid, "|", \
{ NFS_ATTR_FATTR_TYPE, "TYPE" }, \
@@ -958,6 +960,51 @@ DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_set_delegation);
DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_reclaim_delegation);
DEFINE_NFS4_SET_DELEGATION_EVENT(nfs4_detach_delegation);
+#define show_delegation_flags(flags) \
+ __print_flags(flags, "|", \
+ { BIT(NFS_DELEGATION_NEED_RECLAIM), "NEED_RECLAIM" }, \
+ { BIT(NFS_DELEGATION_RETURN), "RETURN" }, \
+ { BIT(NFS_DELEGATION_RETURN_IF_CLOSED), "RETURN_IF_CLOSED" }, \
+ { BIT(NFS_DELEGATION_REFERENCED), "REFERENCED" }, \
+ { BIT(NFS_DELEGATION_RETURNING), "RETURNING" }, \
+ { BIT(NFS_DELEGATION_REVOKED), "REVOKED" }, \
+ { BIT(NFS_DELEGATION_TEST_EXPIRED), "TEST_EXPIRED" }, \
+ { BIT(NFS_DELEGATION_INODE_FREEING), "INODE_FREEING" }, \
+ { BIT(NFS_DELEGATION_RETURN_DELAYED), "RETURN_DELAYED" })
+
+DECLARE_EVENT_CLASS(nfs4_delegation_event,
+ TP_PROTO(
+ const struct nfs_delegation *delegation
+ ),
+
+ TP_ARGS(delegation),
+
+ TP_STRUCT__entry(
+ __field(u32, fhandle)
+ __field(unsigned int, fmode)
+ __field(unsigned long, flags)
+ ),
+
+ TP_fast_assign(
+ __entry->fhandle = nfs_fhandle_hash(NFS_FH(delegation->inode));
+ __entry->fmode = delegation->type;
+ __entry->flags = delegation->flags;
+ ),
+
+ TP_printk(
+ "fhandle=0x%08x fmode=%s flags=%s",
+ __entry->fhandle, show_fs_fmode_flags(__entry->fmode),
+ show_delegation_flags(__entry->flags)
+ )
+);
+#define DEFINE_NFS4_DELEGATION_EVENT(name) \
+ DEFINE_EVENT(nfs4_delegation_event, name, \
+ TP_PROTO( \
+ const struct nfs_delegation *delegation \
+ ), \
+ TP_ARGS(delegation))
+DEFINE_NFS4_DELEGATION_EVENT(nfs_delegation_need_return);
+
TRACE_EVENT(nfs4_delegreturn_exit,
TP_PROTO(
const struct nfs4_delegreturnargs *args,
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 4/4] nfs: new tracepoint in match_stateid operation
2025-06-18 13:19 [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency Jeff Layton
` (2 preceding siblings ...)
2025-06-18 13:19 ` [PATCH v2 3/4] nfs: new tracepoint in nfs_delegation_need_return Jeff Layton
@ 2025-06-18 13:19 ` Jeff Layton
3 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-06-18 13:19 UTC (permalink / raw)
To: Trond Myklebust, Anna Schumaker
Cc: linux-nfs, linux-kernel, Benjamin Coddington, Jeff Layton
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>
---
fs/nfs/nfs4proc.c | 4 ++++
fs/nfs/nfs4trace.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 341740fa293d8fb1cfabe0813c7fcadf04df4f62..80126290589aaccd801c8965252523894e37c44a 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -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);
}
diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h
index 73a6b60a848066546c2ae98b4982b0ab36bb0f73..c1a332da565d31e808d9230089c92c5ec472da81 100644
--- a/fs/nfs/nfs4trace.h
+++ b/fs/nfs/nfs4trace.h
@@ -1497,6 +1497,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,
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-18 13:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-18 13:19 [PATCH v2 0/4] nfs: client-side tracepoints for delegations and cache coherency Jeff Layton
2025-06-18 13:19 ` [PATCH v2 1/4] nfs: add cache_validity to the nfs_inode_event tracepoints Jeff Layton
2025-06-18 13:19 ` [PATCH v2 2/4] nfs: add a tracepoint to nfs_inode_detach_delegation_locked Jeff Layton
2025-06-18 13:19 ` [PATCH v2 3/4] nfs: new tracepoint in nfs_delegation_need_return Jeff Layton
2025-06-18 13:19 ` [PATCH v2 4/4] nfs: new tracepoint in match_stateid operation Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).