NFSD: Add nfsd_seq4_status trace event
authorChuck Lever <chuck.lever@oracle.com>
Fri, 26 Jan 2024 17:45:42 +0000 (12:45 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 1 Mar 2024 14:12:13 +0000 (09:12 -0500)
Add a trace point that records SEQ4_STATUS flags returned in an
NFSv4.1 SEQUENCE response. SEQ4_STATUS flags report backchannel
issues and changes to lease state to clients. Knowing what the
server is reporting to clients is useful for debugging both
configuration and operational issues in real time.

For example, upcoming patches will enable server administrators to
revoke parts of a client's lease; that revocation is indicated to
the client when a subsequent SEQUENCE operation has one or more
SEQ4_STATUS flags that are set.

Sample trace records:

nfsd-927   [006]   615.581821: nfsd_seq4_status:     xid=0x095ded07 sessionid=65a032c3:b7845faf:00000001:00000000 status_flags=BACKCHANNEL_FAULT
nfsd-927   [006]   615.588043: nfsd_seq4_status:     xid=0x0a5ded07 sessionid=65a032c3:b7845faf:00000001:00000000 status_flags=BACKCHANNEL_FAULT
nfsd-928   [003]   615.588448: nfsd_seq4_status:     xid=0x0b5ded07 sessionid=65a032c3:b7845faf:00000001:00000000 status_flags=BACKCHANNEL_FAULT

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4state.c
fs/nfsd/trace.h

index 0ff7f83..3a00e8c 100644 (file)
@@ -4058,6 +4058,7 @@ out:
        }
        if (!list_empty(&clp->cl_revoked))
                seq->status_flags |= SEQ4_STATUS_RECALLABLE_STATE_REVOKED;
+       trace_nfsd_seq4_status(rqstp, seq);
 out_no_session:
        if (conn)
                free_conn(conn);
index d1e8cf0..38d11b4 100644 (file)
@@ -696,6 +696,41 @@ DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name,                    \
 
 DEFINE_STID_EVENT(revoke);
 
+TRACE_EVENT_CONDITION(nfsd_seq4_status,
+       TP_PROTO(
+               const struct svc_rqst *rqstp,
+               const struct nfsd4_sequence *sequence
+       ),
+       TP_ARGS(rqstp, sequence),
+       TP_CONDITION(sequence->status_flags),
+       TP_STRUCT__entry(
+               __field(unsigned int, netns_ino)
+               __field(u32, xid)
+               __field(u32, cl_boot)
+               __field(u32, cl_id)
+               __field(u32, seqno)
+               __field(u32, reserved)
+               __field(unsigned long, status_flags)
+       ),
+       TP_fast_assign(
+               const struct nfsd4_sessionid *sid =
+                       (struct nfsd4_sessionid *)&sequence->sessionid;
+
+               __entry->netns_ino = SVC_NET(rqstp)->ns.inum;
+               __entry->xid = be32_to_cpu(rqstp->rq_xid);
+               __entry->cl_boot = sid->clientid.cl_boot;
+               __entry->cl_id = sid->clientid.cl_id;
+               __entry->seqno = sid->sequence;
+               __entry->reserved = sid->reserved;
+               __entry->status_flags = sequence->status_flags;
+       ),
+       TP_printk("xid=0x%08x sessionid=%08x:%08x:%08x:%08x status_flags=%s",
+               __entry->xid, __entry->cl_boot, __entry->cl_id,
+               __entry->seqno, __entry->reserved,
+               show_nfs4_seq4_status(__entry->status_flags)
+       )
+);
+
 DECLARE_EVENT_CLASS(nfsd_clientid_class,
        TP_PROTO(const clientid_t *clid),
        TP_ARGS(clid),