[PATCH v3 09/17] nfsd: add tracepoint to nfsd_readdir

From: Jeff Layton
Date: Sat May 03 2025 - 11:13:29 EST


Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
---
fs/nfsd/trace.h | 19 +++++++++++++++++++
fs/nfsd/vfs.c | 2 ++
2 files changed, 21 insertions(+)

diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 4e873ceca602098d2899c5ff2deee610ddb670a0..6f73ecc6bbf09cc174a93ce1dce12edfff6f60b8 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -2512,6 +2512,25 @@ TRACE_EVENT(nfsd_vfs_rename,
__entry->xid, __entry->sfh_hash, __entry->tfh_hash,
__get_str(name), __get_str(tgt))
);
+
+TRACE_EVENT(nfsd_vfs_readdir,
+ TP_PROTO(struct svc_rqst *rqstp,
+ struct svc_fh *fhp,
+ u64 offset),
+ TP_ARGS(rqstp, fhp, offset),
+ TP_STRUCT__entry(
+ SVC_RQST_ENDPOINT_FIELDS(rqstp)
+ __field(u32, fh_hash)
+ __field(u64, offset)
+ ),
+ TP_fast_assign(
+ SVC_RQST_ENDPOINT_ASSIGNMENTS(rqstp);
+ __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+ __entry->offset = offset;
+ ),
+ TP_printk("xid=0x%08x fh_hash=0x%08x offset=0x%llx",
+ __entry->xid, __entry->fh_hash, __entry->offset)
+);
#endif /* _NFSD_TRACE_H */

#undef TRACE_INCLUDE_PATH
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 9fd5f7d277b452e12a2d5854b9d3ff79418a8818..ec07e5867912bf87497b935d26e3039364596864 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -2249,6 +2249,8 @@ nfsd_readdir(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t *offsetp,
loff_t offset = *offsetp;
int may_flags = NFSD_MAY_READ;

+ trace_nfsd_vfs_readdir(rqstp, fhp, *offsetp);
+
err = nfsd_open(rqstp, fhp, S_IFDIR, may_flags, &file);
if (err)
goto out;

--
2.49.0