diff mbox series

[RFC,15/21] NFSD: Add tracepoint to report arguments to NFSv4 OPEN

Message ID 160029261250.29208.13662626992884110140.stgit@klimt.1015granger.net
State New
Headers show
Series NFSD operation monitoring tracepoints | expand

Commit Message

Chuck Lever Sept. 16, 2020, 9:43 p.m. UTC
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@oracle.com>
---
 fs/nfsd/nfs4proc.c  |    4 +-
 fs/nfsd/nfs4state.c |    3 +-
 fs/nfsd/trace.h     |  101 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 6206ba7b1ac7..da94d769ed0a 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 fc58e1a3ef60..3c587d5076f7 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -348,6 +348,107 @@  DEFINE_NFSD_ERR_EVENT(write_err);
 #include "state.h"
 #include "filecache.h"
 #include "vfs.h"
+#include "xdr4.h"
+
+TRACE_DEFINE_ENUM(NFS4_OPEN_NOCREATE);
+TRACE_DEFINE_ENUM(NFS4_OPEN_CREATE);
+
+#define show_open_create(x) \
+	__print_symbolic(x, \
+		{ NFS4_OPEN_NOCREATE, "NOCREATE" }, \
+		{ NFS4_OPEN_CREATE,   "CREATE" })
+
+#define OPEN_CLAIM_TYPE_LIST				\
+	open_claim_type(NULL)				\
+	open_claim_type(DELEGATE_PREV)			\
+	open_claim_type(PREVIOUS)			\
+	open_claim_type(DELEGATE_CUR)			\
+	open_claim_type(FH)				\
+	open_claim_type(DELEG_PREV_FH)			\
+	open_claim_type_end(DELEG_CUR_FH)
+
+#undef open_claim_type
+#undef open_claim_type_end
+#define open_claim_type(x)	TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_##x);
+#define open_claim_type_end(x)	TRACE_DEFINE_ENUM(NFS4_OPEN_CLAIM_##x);
+
+OPEN_CLAIM_TYPE_LIST
+
+#undef open_claim_type
+#undef open_claim_type_end
+#define open_claim_type(x)	{ NFS4_OPEN_CLAIM_##x, #x },
+#define open_claim_type_end(x)	{ NFS4_OPEN_CLAIM_##x, #x }
+
+#define show_open_claimtype(x) \
+	__print_symbolic(x, OPEN_CLAIM_TYPE_LIST)
+
+/*
+ * from include/linux/nfs4.h
+ */
+TRACE_DEFINE_ENUM(NFS4_SHARE_ACCESS_READ);
+TRACE_DEFINE_ENUM(NFS4_SHARE_ACCESS_WRITE);
+TRACE_DEFINE_ENUM(NFS4_SHARE_ACCESS_BOTH);
+
+#define show_open_sharedeny_flags(x) \
+	__print_symbolic(x, \
+		{ NFS4_SHARE_ACCESS_READ,	"READ" }, \
+		{ NFS4_SHARE_ACCESS_WRITE,	"WRITE" }, \
+		{ NFS4_SHARE_ACCESS_BOTH,	"BOTH" })
+
+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_open_create(__entry->create),
+		show_open_claimtype(__entry->claim),
+		show_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_open_sharedeny_flags(__entry->share)
+	)
+);
 
 TRACE_EVENT(nfsd4_stateid_prep,
 	TP_PROTO(