Skip to content

Commit 0122e88

Browse files
committed
NFSD: Trace filecache opens
Instrument calls to nfsd_open_verified() to get a sense of the filecache hit rate. Signed-off-by: Chuck Lever <[email protected]>
1 parent 7e2ce0c commit 0122e88

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

fs/nfsd/filecache.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,11 @@ nfsd_do_file_acquire(struct svc_rqst *rqstp, struct svc_fh *fhp,
995995

996996
nf->nf_mark = nfsd_file_mark_find_or_create(nf);
997997
if (nf->nf_mark) {
998-
if (open)
998+
if (open) {
999999
status = nfsd_open_verified(rqstp, fhp, may_flags,
10001000
&nf->nf_file);
1001-
else
1001+
trace_nfsd_file_open(nf, status);
1002+
} else
10021003
status = nfs_ok;
10031004
} else
10041005
status = nfserr_jukebox;

fs/nfsd/trace.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,34 @@ TRACE_EVENT(nfsd_file_acquire,
784784
__entry->nf_file, __entry->status)
785785
);
786786

787+
TRACE_EVENT(nfsd_file_open,
788+
TP_PROTO(struct nfsd_file *nf, __be32 status),
789+
TP_ARGS(nf, status),
790+
TP_STRUCT__entry(
791+
__field(unsigned int, nf_hashval)
792+
__field(void *, nf_inode) /* cannot be dereferenced */
793+
__field(int, nf_ref)
794+
__field(unsigned long, nf_flags)
795+
__field(unsigned long, nf_may)
796+
__field(void *, nf_file) /* cannot be dereferenced */
797+
),
798+
TP_fast_assign(
799+
__entry->nf_hashval = nf->nf_hashval;
800+
__entry->nf_inode = nf->nf_inode;
801+
__entry->nf_ref = refcount_read(&nf->nf_ref);
802+
__entry->nf_flags = nf->nf_flags;
803+
__entry->nf_may = nf->nf_may;
804+
__entry->nf_file = nf->nf_file;
805+
),
806+
TP_printk("hash=0x%x inode=%p ref=%d flags=%s may=%s file=%p",
807+
__entry->nf_hashval,
808+
__entry->nf_inode,
809+
__entry->nf_ref,
810+
show_nf_flags(__entry->nf_flags),
811+
show_nfsd_may_flags(__entry->nf_may),
812+
__entry->nf_file)
813+
)
814+
787815
DECLARE_EVENT_CLASS(nfsd_file_search_class,
788816
TP_PROTO(struct inode *inode, unsigned int hash, int found),
789817
TP_ARGS(inode, hash, found),

0 commit comments

Comments
 (0)