NFSD: Add tracepoints to record NFSv4 WRITE arguments and results

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index c44b9c1..b8b6dba 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1618,6 +1618,7 @@
 	if (!xdr_stream_subsegment(argp->xdr, &write->wr_payload, write->wr_buflen))
 		return nfserr_bad_xdr;
 
+	trace_dec_write4args(argp, write);
 	return nfs_ok;
 }
 
@@ -4860,7 +4861,9 @@
 	*p++ = cpu_to_be32(write->wr_how_written);
 	p = xdr_encode_opaque_fixed(p, write->wr_verifier.data,
 						NFS4_VERIFIER_SIZE);
-	return 0;
+
+	trace_enc_write4resok(resp, write);
+	return nfs_ok;
 }
 
 static __be32
diff --git a/fs/nfsd/xdr4trace.h b/fs/nfsd/xdr4trace.h
index 4e4bb0d..c5f68f6 100644
--- a/fs/nfsd/xdr4trace.h
+++ b/fs/nfsd/xdr4trace.h
@@ -1909,6 +1909,36 @@
 	)
 );
 
+TRACE_EVENT(dec_write4args,
+	TP_PROTO(
+		const struct nfsd4_compoundargs *argp,
+		const struct nfsd4_write *write
+	),
+	TP_ARGS(argp, write),
+	TP_STRUCT__entry(
+		TRACE_SVC_XDR_CMPD_FIELDS
+		TRACE_NFS4_STATEID_FIELDS
+
+		__field(u32, count)
+		__field(u64, offset)
+		__field(unsigned long, stable)
+	),
+	TP_fast_assign(
+		TRACE_SVC_XDR_CMPD_ARG_ASSIGNS(argp);
+		TRACE_NFS4_STATEID_ASSIGNS(&write->wr_stateid);
+
+		__entry->count = write->wr_buflen;
+		__entry->offset = write->wr_offset;
+		__entry->stable = write->wr_stable_how;
+	),
+	TP_printk(TRACE_XDR_CMPD_FORMAT TRACE_NFS4_STATEID_FORMAT
+		"count=%u offset=%llu stable=%s",
+		TRACE_XDR_CMPD_VARARGS, TRACE_NFS4_STATEID_VARARGS,
+		__entry->count, __entry->offset,
+		show_nfs_stable_how(__entry->stable)
+	)
+);
+
 
 /**
  ** Server-side result encoding tracepoints
@@ -3002,6 +3032,34 @@
 	)
 );
 
+TRACE_EVENT(enc_write4resok,
+	TP_PROTO(
+		const struct nfsd4_compoundres *resp,
+		const struct nfsd4_write *write
+	),
+	TP_ARGS(resp, write),
+	TP_STRUCT__entry(
+		TRACE_SVC_XDR_CMPD_FIELDS
+
+		__field(u32, count)
+		__field(unsigned long, committed)
+		__array(u8, verifier, NFS4_VERIFIER_SIZE)
+	),
+	TP_fast_assign(
+		TRACE_SVC_XDR_CMPD_RES_ASSIGNS(resp);
+
+		__entry->count = write->wr_bytes_written;
+		__entry->committed = write->wr_how_written;
+		memcpy(__entry->verifier, write->wr_verifier.data,
+		       NFS4_VERIFIER_SIZE);
+	),
+	TP_printk(TRACE_XDR_CMPD_FORMAT "count=%u verifier=%s committed=%s",
+		TRACE_XDR_CMPD_VARARGS, __entry->count,
+		show_nfs4_verifier(__entry->verifier),
+		show_nfs_stable_how(__entry->committed)
+	)
+);
+
 
 /**
  ** FATTR4 tracepoints