]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfsd: add tracepoint to nfsd_readdir
authorJeff Layton <jlayton@kernel.org>
Sat, 3 May 2025 19:59:28 +0000 (15:59 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 11 May 2025 23:48:34 +0000 (19:48 -0400)
Observe the start of NFS READDIR operations.

The NFS READDIR's count argument can be interesting when tuning a
client's readdir behavior.

However, the count argument is not passed to nfsd_readdir(). To
properly capture the count argument, this tracepoint must appear in
each proc function before the nfsd_readdir() call.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs3proc.c
fs/nfsd/nfs4proc.c
fs/nfsd/nfsproc.c
fs/nfsd/trace.h

index 5d2b081072e8c2e286c6815c34e5e58d4be15067..80096a5c486551a22efb10a16c60454dc0bc891b 100644 (file)
@@ -625,6 +625,7 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
        dprintk("nfsd: READDIR(3)  %s %d bytes at %d\n",
                                SVCFH_fmt(&argp->fh),
                                argp->count, (u32) argp->cookie);
+       trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
 
        nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
 
@@ -659,6 +660,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
        dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
                                SVCFH_fmt(&argp->fh),
                                argp->count, (u32) argp->cookie);
+       trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
 
        nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
 
index 77895e099673639c571a6ccc03f25381508a846b..483fd8b26f9df75b565dcac947aa63d055988b63 100644 (file)
@@ -998,6 +998,9 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        u64 cookie = readdir->rd_cookie;
        static const nfs4_verifier zeroverf;
 
+       trace_nfsd_vfs_readdir(rqstp, &cstate->current_fh,
+                              readdir->rd_maxcount, readdir->rd_cookie);
+
        /* no need to check permission - this will be done in nfsd_readdir() */
 
        if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)
index 6dda081eb24c00b834ab0965c3a35a12115bceb7..c561af30c37ab04c75038561817abc1b4628fa78 100644 (file)
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "xdr.h"
 #include "vfs.h"
+#include "trace.h"
 
 #define NFSDDBG_FACILITY               NFSDDBG_PROC
 
@@ -618,6 +619,7 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
        dprintk("nfsd: READDIR  %s %d bytes at %d\n",
                SVCFH_fmt(&argp->fh),           
                argp->count, argp->cookie);
+       trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
 
        nfsd_init_dirlist_pages(rqstp, resp, argp->count);
 
index 46091d7f2260cde8890bcff887a5d4d345223f9e..bed58cf55c10d0c95b274ec0da8c46eade167774 100644 (file)
@@ -2553,6 +2553,32 @@ TRACE_EVENT(nfsd_vfs_rename,
        )
 );
 
+TRACE_EVENT(nfsd_vfs_readdir,
+       TP_PROTO(
+               const struct svc_rqst *rqstp,
+               const struct svc_fh *fhp,
+               u32 count,
+               u64 offset
+       ),
+       TP_ARGS(rqstp, fhp, count, offset),
+       TP_STRUCT__entry(
+               NFSD_TRACE_PROC_CALL_FIELDS(rqstp)
+               __field(u32, fh_hash)
+               __field(u32, count)
+               __field(u64, offset)
+       ),
+       TP_fast_assign(
+               NFSD_TRACE_PROC_CALL_ASSIGNMENTS(rqstp);
+               __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
+               __entry->count = count;
+               __entry->offset = offset;
+       ),
+       TP_printk("xid=0x%08x fh_hash=0x%08x offset=%llu count=%u",
+               __entry->xid, __entry->fh_hash,
+               __entry->offset, __entry->count
+       )
+);
+
 #endif /* _NFSD_TRACE_H */
 
 #undef TRACE_INCLUDE_PATH