[PATCH v2 20/27] NFSD: Add tracepoint to report arguments to NFSv4 OPEN

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Surface the open create type and claim type, as well as the XID and
the file handle and open sequence number.

            nfsd-1025  [001]   257.085227: nfsd_open_args:       xid=0x08157d7a fh_hash=0x1ac91976 seqid=97 type=CREATE claim=NULL

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---
 fs/nfsd/nfs4proc.c         |    4 +--
 fs/nfsd/nfs4state.c        |    3 +-
 fs/nfsd/trace.h            |   55 ++++++++++++++++++++++++++++++++++++++++++++
 include/trace/events/nfs.h |   32 ++++++++++++++++++++++++++
 4 files changed, 89 insertions(+), 5 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 065ed5930250..914eb3f2a233 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -358,9 +358,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 	bool reclaim = false;
 
-	dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n",
-		(int)open->op_fname.len, open->op_fname.data,
-		open->op_openowner);
+	trace_nfsd4_open(rqstp, open);
 
 	/* This check required by spec. */
 	if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0cc928328c22..47790c7a29a3 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -6184,8 +6184,7 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp,
 	struct nfs4_ol_stateid *stp;
 	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 
-	dprintk("NFSD: nfsd4_open_downgrade on file %pd\n", 
-			cstate->current_fh.fh_dentry);
+	trace_nfsd4_open_downgrade(rqstp, od);
 
 	/* We don't yet support WANT bits: */
 	if (od->od_deleg_want)
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index be5fc0ce3c13..18b359a04d96 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -594,6 +594,61 @@ TRACE_EVENT(nfsd4_getattr,
 #include "filecache.h"
 #include "vfs.h"
 
+TRACE_EVENT(nfsd4_open,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct nfsd4_open *open
+	),
+	TP_ARGS(rqstp, open),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(u32, seqid)
+		__field(unsigned long, create)
+		__field(unsigned long, claim)
+		__field(unsigned long, share)
+		__dynamic_array(unsigned char, name, open->op_fname.len + 1)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->seqid = open->op_seqid;
+		__entry->create = open->op_create;
+		__entry->claim = open->op_claim_type;
+		__entry->share = open->op_share_access;
+		memcpy(__get_str(name), open->op_fname.data,
+		       open->op_fname.len);
+		__get_str(name)[open->op_fname.len] = '\0';
+	),
+	TP_printk("xid=0x%08x seqid=%u type=%s claim=%s share=%s name=%s",
+		__entry->xid, __entry->seqid,
+		show_nfs4_open_create(__entry->create),
+		show_nfs4_open_claimtype(__entry->claim),
+		show_nfs4_open_sharedeny_flags(__entry->share),
+		__get_str(name)
+	)
+);
+
+TRACE_EVENT(nfsd4_open_downgrade,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct nfsd4_open_downgrade *open
+	),
+	TP_ARGS(rqstp, open),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(u32, seqid)
+		__field(unsigned long, share)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->seqid = open->od_seqid;
+		__entry->share = open->od_share_access;
+	),
+	TP_printk("xid=0x%08x seqid=%u share=%s",
+		__entry->xid, __entry->seqid,
+		show_nfs4_open_sharedeny_flags(__entry->share)
+	)
+);
+
 TRACE_EVENT(nfsd4_stateid_prep,
 	TP_PROTO(
 		const struct svc_rqst *rqstp,
diff --git a/include/trace/events/nfs.h b/include/trace/events/nfs.h
index 19f7444e4bb2..e6da77eb95b5 100644
--- a/include/trace/events/nfs.h
+++ b/include/trace/events/nfs.h
@@ -463,3 +463,35 @@ TRACE_DEFINE_ENUM(SP4_SSV);
 		{ FATTR4_WORD2_SECURITY_LABEL,		"SECURITY_LABEL" }, \
 		{ FATTR4_WORD2_MODE_UMASK,		"MODE_UMASK" }, \
 		{ FATTR4_WORD2_XATTR_SUPPORT,		"XATTR_SUPPORT" })
+
+TRACE_DEFINE_ENUM(NFS4_OPEN_NOCREATE);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CREATE);
+
+#define show_nfs4_open_create(x) \
+	__print_symbolic(x, \
+		{ NFS4_OPEN_NOCREATE,			"NOCREATE" }, \
+		{ NFS4_OPEN_CREATE,			"CREATE" })
+
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_NULL);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_PREVIOUS);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_DELEGATE_CUR);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_DELEGATE_PREV);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_FH);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_DELEG_CUR_FH);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_DELEG_PREV_FH);
+
+#define show_nfs4_open_claimtype(x) \
+	__print_symbolic(x, \
+		{ NFS4_OPEN_CLAIM_NULL,			"NULL" }, \
+		{ NFS4_OPEN_CLAIM_PREVIOUS,		"PREVIOUS" }, \
+		{ NFS4_OPEN_CLAIM_DELEGATE_CUR,		"DELEGATE_CUR" }, \
+		{ NFS4_OPEN_CLAIM_DELEGATE_PREV,	"DELEGATE_PREV" }, \
+		{ NFS4_OPEN_CLAIM_FH,			"FH" }, \
+		{ NFS4_OPEN_CLAIM_DELEG_CUR_FH,		"DELEG_CUR_FH" }, \
+		{ NFS4_OPEN_CLAIM_DELEG_PREV_FH,	"DELEG_PREV_FH" })
+
+#define show_nfs4_open_sharedeny_flags(x) \
+	__print_symbolic(x, \
+		{ NFS4_SHARE_ACCESS_READ,		"READ" }, \
+		{ NFS4_SHARE_ACCESS_WRITE,		"WRITE" }, \
+		{ NFS4_SHARE_ACCESS_BOTH,		"BOTH" })





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux