Skip to content

Commit a91bfc4

Browse files
jtlaytonchucklever
authored andcommitted
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>
1 parent b52f2a7 commit a91bfc4

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

fs/nfsd/nfs3proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp)
625625
dprintk("nfsd: READDIR(3) %s %d bytes at %d\n",
626626
SVCFH_fmt(&argp->fh),
627627
argp->count, (u32) argp->cookie);
628+
trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
628629

629630
nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
630631

@@ -659,6 +660,7 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp)
659660
dprintk("nfsd: READDIR+(3) %s %d bytes at %d\n",
660661
SVCFH_fmt(&argp->fh),
661662
argp->count, (u32) argp->cookie);
663+
trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
662664

663665
nfsd3_init_dirlist_pages(rqstp, resp, argp->count);
664666

fs/nfsd/nfs4proc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,9 @@ nfsd4_readdir(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
998998
u64 cookie = readdir->rd_cookie;
999999
static const nfs4_verifier zeroverf;
10001000

1001+
trace_nfsd_vfs_readdir(rqstp, &cstate->current_fh,
1002+
readdir->rd_maxcount, readdir->rd_cookie);
1003+
10011004
/* no need to check permission - this will be done in nfsd_readdir() */
10021005

10031006
if (readdir->rd_bmval[1] & NFSD_WRITEONLY_ATTRS_WORD1)

fs/nfsd/nfsproc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "cache.h"
1111
#include "xdr.h"
1212
#include "vfs.h"
13+
#include "trace.h"
1314

1415
#define NFSDDBG_FACILITY NFSDDBG_PROC
1516

@@ -618,6 +619,7 @@ nfsd_proc_readdir(struct svc_rqst *rqstp)
618619
dprintk("nfsd: READDIR %s %d bytes at %d\n",
619620
SVCFH_fmt(&argp->fh),
620621
argp->count, argp->cookie);
622+
trace_nfsd_vfs_readdir(rqstp, &argp->fh, argp->count, argp->cookie);
621623

622624
nfsd_init_dirlist_pages(rqstp, resp, argp->count);
623625

fs/nfsd/trace.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2553,6 +2553,32 @@ TRACE_EVENT(nfsd_vfs_rename,
25532553
)
25542554
);
25552555

2556+
TRACE_EVENT(nfsd_vfs_readdir,
2557+
TP_PROTO(
2558+
const struct svc_rqst *rqstp,
2559+
const struct svc_fh *fhp,
2560+
u32 count,
2561+
u64 offset
2562+
),
2563+
TP_ARGS(rqstp, fhp, count, offset),
2564+
TP_STRUCT__entry(
2565+
NFSD_TRACE_PROC_CALL_FIELDS(rqstp)
2566+
__field(u32, fh_hash)
2567+
__field(u32, count)
2568+
__field(u64, offset)
2569+
),
2570+
TP_fast_assign(
2571+
NFSD_TRACE_PROC_CALL_ASSIGNMENTS(rqstp);
2572+
__entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle);
2573+
__entry->count = count;
2574+
__entry->offset = offset;
2575+
),
2576+
TP_printk("xid=0x%08x fh_hash=0x%08x offset=%llu count=%u",
2577+
__entry->xid, __entry->fh_hash,
2578+
__entry->offset, __entry->count
2579+
)
2580+
);
2581+
25562582
#endif /* _NFSD_TRACE_H */
25572583

25582584
#undef TRACE_INCLUDE_PATH

0 commit comments

Comments
 (0)