nfsd: add tracepoint to nfsd_readdir

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>
This commit is contained in:
Jeff Layton 2025-05-03 15:59:28 -04:00 committed by Chuck Lever
parent b52f2a79fb
commit a91bfc4571
4 changed files with 33 additions and 0 deletions

View 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);

View 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)

View 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);

View 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