nfsd: new tracepoint for check_slot_seqid
authorChuck Lever <chuck.lever@oracle.com>
Fri, 5 Apr 2024 18:40:50 +0000 (14:40 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 6 May 2024 13:07:18 +0000 (09:07 -0400)
Replace a dprintk in check_slot_seqid with tracepoints. These new
tracepoints track slot sequence numbers during operation.

Suggested-by: Jeffrey Layton <jlayton@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c
fs/nfsd/trace.h

index 5ae70fb1d3a28ba2b2f0cda9ab85ab2abd59cbb5..bd81217ada7f7737a23d89da0658ca67d51cf8e6 100644 (file)
@@ -3636,12 +3636,8 @@ out_nolock:
        return status;
 }
 
-static __be32
-check_slot_seqid(u32 seqid, u32 slot_seqid, int slot_inuse)
+static __be32 check_slot_seqid(u32 seqid, u32 slot_seqid, bool slot_inuse)
 {
-       dprintk("%s enter. seqid %d slot_seqid %d\n", __func__, seqid,
-               slot_seqid);
-
        /* The slot is in use, and no response has been sent. */
        if (slot_inuse) {
                if (seqid == slot_seqid)
@@ -3818,10 +3814,13 @@ nfsd4_create_session(struct svc_rqst *rqstp,
        }
 
        /* RFC 8881 Section 18.36.4 Phase 2: Sequence ID processing. */
-       if (conf)
+       if (conf) {
                cs_slot = &conf->cl_cs_slot;
-       else
+               trace_nfsd_slot_seqid_conf(conf, cr_ses);
+       } else {
                cs_slot = &unconf->cl_cs_slot;
+               trace_nfsd_slot_seqid_unconf(unconf, cr_ses);
+       }
        status = check_slot_seqid(cr_ses->seqid, cs_slot->sl_seqid, 0);
        switch (status) {
        case nfs_ok:
@@ -4216,6 +4215,7 @@ nfsd4_sequence(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
         * sr_highest_slotid and the sr_target_slot id to maxslots */
        seq->maxslots = session->se_fchannel.maxreqs;
 
+       trace_nfsd_slot_seqid_sequence(clp, seq, slot);
        status = check_slot_seqid(seq->seqid, slot->sl_seqid,
                                        slot->sl_flags & NFSD4_SLOT_INUSE);
        if (status == nfserr_replay_cache) {
index c0cc345a576e01bc8ba57289fb3075247341a0f3..ac2124461a08fef7352be5718b633ae1fdf6d755 100644 (file)
@@ -749,6 +749,76 @@ TRACE_EVENT_CONDITION(nfsd_seq4_status,
        )
 );
 
+DECLARE_EVENT_CLASS(nfsd_cs_slot_class,
+       TP_PROTO(
+               const struct nfs4_client *clp,
+               const struct nfsd4_create_session *cs
+       ),
+       TP_ARGS(clp, cs),
+       TP_STRUCT__entry(
+               __field(u32, seqid)
+               __field(u32, slot_seqid)
+               __field(u32, cl_boot)
+               __field(u32, cl_id)
+               __sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
+       ),
+       TP_fast_assign(
+               const struct nfsd4_clid_slot *slot = &clp->cl_cs_slot;
+
+               __entry->cl_boot = clp->cl_clientid.cl_boot;
+               __entry->cl_id = clp->cl_clientid.cl_id;
+               __assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
+                                 clp->cl_cb_conn.cb_addrlen);
+               __entry->seqid = cs->seqid;
+               __entry->slot_seqid = slot->sl_seqid;
+       ),
+       TP_printk("addr=%pISpc client %08x:%08x seqid=%u slot_seqid=%u",
+               __get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
+               __entry->seqid, __entry->slot_seqid
+       )
+);
+
+#define DEFINE_CS_SLOT_EVENT(name) \
+DEFINE_EVENT(nfsd_cs_slot_class, nfsd_##name, \
+       TP_PROTO( \
+               const struct nfs4_client *clp, \
+               const struct nfsd4_create_session *cs \
+       ), \
+       TP_ARGS(clp, cs))
+
+DEFINE_CS_SLOT_EVENT(slot_seqid_conf);
+DEFINE_CS_SLOT_EVENT(slot_seqid_unconf);
+
+TRACE_EVENT(nfsd_slot_seqid_sequence,
+       TP_PROTO(
+               const struct nfs4_client *clp,
+               const struct nfsd4_sequence *seq,
+               const struct nfsd4_slot *slot
+       ),
+       TP_ARGS(clp, seq, slot),
+       TP_STRUCT__entry(
+               __field(u32, seqid)
+               __field(u32, slot_seqid)
+               __field(u32, cl_boot)
+               __field(u32, cl_id)
+               __sockaddr(addr, clp->cl_cb_conn.cb_addrlen)
+               __field(bool, in_use)
+       ),
+       TP_fast_assign(
+               __entry->cl_boot = clp->cl_clientid.cl_boot;
+               __entry->cl_id = clp->cl_clientid.cl_id;
+               __assign_sockaddr(addr, &clp->cl_cb_conn.cb_addr,
+                                 clp->cl_cb_conn.cb_addrlen);
+               __entry->seqid = seq->seqid;
+               __entry->slot_seqid = slot->sl_seqid;
+       ),
+       TP_printk("addr=%pISpc client %08x:%08x seqid=%u slot_seqid=%u (%sin use)",
+               __get_sockaddr(addr), __entry->cl_boot, __entry->cl_id,
+               __entry->seqid, __entry->slot_seqid,
+               __entry->in_use ? "" : "not "
+       )
+);
+
 DECLARE_EVENT_CLASS(nfsd_clientid_class,
        TP_PROTO(const clientid_t *clid),
        TP_ARGS(clid),