[PATCH RFC 19/21] NFSD: Add lock and locku tracepoints

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

 



Record lock metadata.

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---
 fs/nfsd/nfs4state.c |    8 ++----
 fs/nfsd/trace.h     |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 8444e8b51fa8..b7c99fe8bdd0 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -6701,9 +6701,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	struct net *net = SVC_NET(rqstp);
 	struct nfsd_net *nn = net_generic(net, nfsd_net_id);
 
-	dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
-		(long long) lock->lk_offset,
-		(long long) lock->lk_length);
+	trace_nfsd4_lock(rqstp, lock);
 
 	if (check_lock_length(lock->lk_offset, lock->lk_length))
 		 return nfserr_inval;
@@ -7001,9 +6999,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	int err;
 	struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
 
-	dprintk("NFSD: nfsd4_locku: start=%Ld length=%Ld\n",
-		(long long) locku->lu_offset,
-		(long long) locku->lu_length);
+	trace_nfsd4_locku(rqstp, locku);
 
 	if (check_lock_length(locku->lu_offset, locku->lu_length))
 		 return nfserr_inval;
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index fd212fc1fd2a..c345a73a818f 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -1605,6 +1605,71 @@ TRACE_EVENT(nfsd4_exchange_id,
 	)
 );
 
+/*
+ * from include/linux/nfs4.h
+ */
+TRACE_DEFINE_ENUM(NFS4_UNLOCK_LT);
+TRACE_DEFINE_ENUM(NFS4_READ_LT);
+TRACE_DEFINE_ENUM(NFS4_WRITE_LT);
+TRACE_DEFINE_ENUM(NFS4_READW_LT);
+TRACE_DEFINE_ENUM(NFS4_WRITEW_LT);
+
+#define show_nfsd_lock_type(x)					\
+	__print_symbolic(x,					\
+		{ NFS4_UNLOCK_LT,	"UNLOCK" },		\
+		{ NFS4_READ_LT,		"READ" },		\
+		{ NFS4_WRITE_LT,	"WRITE" },		\
+		{ NFS4_READW_LT,	"READW" },		\
+		{ NFS4_WRITEW_LT,	"WRITEW" })
+
+TRACE_EVENT(nfsd4_lock,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct nfsd4_lock *lock
+	),
+	TP_ARGS(rqstp, lock),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(unsigned long, type)
+		__field(bool, new)
+		__field(long long, start)
+		__field(long long, length)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->type = lock->lk_type;
+		__entry->new = lock->lk_is_new;
+		__entry->start = lock->lk_offset;
+		__entry->length = lock->lk_length;
+	),
+	TP_printk("xid=0x%08x type=%s start=%Ld length=%Ld (%s)",
+		__entry->xid, show_nfsd_lock_type(__entry->type),
+		__entry->start, __entry->length,
+		__entry->new ? "new" : "not new"
+	)
+);
+
+TRACE_EVENT(nfsd4_locku,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const struct nfsd4_locku *locku
+	),
+	TP_ARGS(rqstp, locku),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(long long, start)
+		__field(long long, length)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->start = locku->lu_offset;
+		__entry->length = locku->lu_length;
+	),
+	TP_printk("xid=0x%08x start=%Ld length=%Ld",
+		__entry->xid, __entry->start, __entry->length
+	)
+);
+
 #endif /* _NFSD_TRACE_H */
 
 #undef TRACE_INCLUDE_PATH





[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