diff mbox series

[v2,19/27] NFSD: Add tracepoint in nfsd4_stateid_preprocess()

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

Commit Message

Chuck Lever Sept. 21, 2020, 6:12 p.m. UTC
Record the stateid being processed by each COMPOUND.

nfsd-1033  [003]   165.199589: nfsd_stateid_prep:    xid=0xeb2d9610 client 5f4fdc70:dbdb3569 stateid 00000001:00000002 status=OK

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4state.c |   24 ++++++++++++++----------
 fs/nfsd/trace.h     |   34 ++++++++++++++++++++++++++++++++--
 2 files changed, 46 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index f101202ed536..0cc928328c22 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -5881,12 +5881,14 @@  nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
 	if (nfp)
 		*nfp = NULL;
 
-	if (grace_disallows_io(net, ino))
-		return nfserr_grace;
+	if (grace_disallows_io(net, ino)) {
+		status = nfserr_grace;
+		goto out;
+	}
 
 	if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) {
 		status = check_special_stateids(net, fhp, stateid, flags);
-		goto done;
+		goto out_check;
 	}
 
 	status = nfsd4_lookup_stateid(cstate, stateid,
@@ -5895,11 +5897,11 @@  nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
 	if (status == nfserr_bad_stateid)
 		status = find_cpntf_state(nn, stateid, &s);
 	if (status)
-		return status;
+		goto out;
 	status = nfsd4_stid_check_stateid_generation(stateid, s,
 			nfsd4_has_session(cstate));
 	if (status)
-		goto out;
+		goto out_put;
 
 	switch (s->sc_type) {
 	case NFS4_DELEG_STID:
@@ -5914,19 +5916,21 @@  nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
 		break;
 	}
 	if (status)
-		goto out;
+		goto out_put;
 	status = nfs4_check_fh(fhp, s);
 
-done:
+out_check:
 	if (status == nfs_ok && nfp)
 		status = nfs4_check_file(rqstp, fhp, s, nfp, flags);
-out:
+out_put:
 	if (s) {
 		if (!status && cstid)
 			*cstid = s;
 		else
 			nfs4_put_stid(s);
 	}
+out:
+	trace_nfsd4_stateid_prep(rqstp, stateid, status);
 	return status;
 }
 
@@ -6066,7 +6070,7 @@  nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
 	struct nfs4_stid *s;
 	struct nfs4_ol_stateid *stp = NULL;
 
-	trace_nfsd_preprocess(seqid, stateid);
+	trace_nfsd4_seqid_prep(seqid, stateid);
 
 	*stpp = NULL;
 	status = nfsd4_lookup_stateid(cstate, stateid, typemask, &s, nn);
@@ -6135,7 +6139,7 @@  nfsd4_open_confirm(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 	oo->oo_flags |= NFS4_OO_CONFIRMED;
 	nfs4_inc_and_copy_stateid(&oc->oc_resp_stateid, &stp->st_stid);
 	mutex_unlock(&stp->st_mutex);
-	trace_nfsd_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid);
+	trace_nfsd4_open_confirm(oc->oc_seqid, &stp->st_stid.sc_stateid);
 	nfsd4_client_record_create(oo->oo_owner.so_client);
 	status = nfs_ok;
 put_stateid:
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index 4fb668257ce2..be5fc0ce3c13 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -594,6 +594,36 @@  TRACE_EVENT(nfsd4_getattr,
 #include "filecache.h"
 #include "vfs.h"
 
+TRACE_EVENT(nfsd4_stateid_prep,
+	TP_PROTO(
+		const struct svc_rqst *rqstp,
+		const stateid_t *stp,
+		__be32 status
+	),
+	TP_ARGS(rqstp, stp, status),
+	TP_STRUCT__entry(
+		__field(u32, xid)
+		__field(u32, cl_boot)
+		__field(u32, cl_id)
+		__field(u32, si_id)
+		__field(u32, si_generation)
+		__field(unsigned long, status)
+	),
+	TP_fast_assign(
+		__entry->xid = be32_to_cpu(rqstp->rq_xid);
+		__entry->cl_boot = stp->si_opaque.so_clid.cl_boot;
+		__entry->cl_id = stp->si_opaque.so_clid.cl_id;
+		__entry->si_id = stp->si_opaque.so_id;
+		__entry->si_generation = stp->si_generation;
+		__entry->status = be32_to_cpu(status);
+	),
+	TP_printk("xid=0x%08x client %08x:%08x stateid %08x:%08x status=%s",
+		__entry->xid, __entry->cl_boot, __entry->cl_id,
+		__entry->si_id, __entry->si_generation,
+		show_nfs4_status(__entry->status)
+	)
+);
+
 DECLARE_EVENT_CLASS(nfsd_stateid_class,
 	TP_PROTO(stateid_t *stp),
 	TP_ARGS(stp),
@@ -660,11 +690,11 @@  DECLARE_EVENT_CLASS(nfsd_stateseqid_class,
 )
 
 #define DEFINE_STATESEQID_EVENT(name) \
-DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \
+DEFINE_EVENT(nfsd_stateseqid_class, nfsd4_##name, \
 	TP_PROTO(u32 seqid, const stateid_t *stp), \
 	TP_ARGS(seqid, stp))
 
-DEFINE_STATESEQID_EVENT(preprocess);
+DEFINE_STATESEQID_EVENT(seqid_prep);
 DEFINE_STATESEQID_EVENT(open_confirm);
 
 DECLARE_EVENT_CLASS(nfsd_clientid_class,