Commit 9b350d3e authored by Chuck Lever's avatar Chuck Lever

NFSD: Clean up nfsd4_encode_replay()

Replace open-coded encoding logic with the use of conventional XDR
utility functions. Add a tracepoint to make replays observable in
field troubleshooting situations.

The WARN_ON is removed. A stack trace is of little use, as there is
only one call site for nfsd4_encode_replay(), and a buffer length
shortage here is unlikely.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent bad4c585
...@@ -5732,27 +5732,24 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) ...@@ -5732,27 +5732,24 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
rqstp->rq_next_page = xdr->page_ptr + 1; rqstp->rq_next_page = xdr->page_ptr + 1;
} }
/* /**
* Encode the reply stored in the stateowner reply cache * nfsd4_encode_replay - encode a result stored in the stateowner reply cache
* * @xdr: send buffer's XDR stream
* XDR note: do not encode rp->rp_buflen: the buffer contains the * @op: operation being replayed
* previously sent already encoded operation. *
* @op->replay->rp_buf contains the previously-sent already-encoded result.
*/ */
void void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
{ {
__be32 *p;
struct nfs4_replay *rp = op->replay; struct nfs4_replay *rp = op->replay;
p = xdr_reserve_space(xdr, 8 + rp->rp_buflen); trace_nfsd_stateowner_replay(op->opnum, rp);
if (!p) {
WARN_ON_ONCE(1);
return;
}
*p++ = cpu_to_be32(op->opnum);
*p++ = rp->rp_status; /* already xdr'ed */
p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen); if (xdr_stream_encode_u32(xdr, op->opnum) != XDR_UNIT)
return;
if (xdr_stream_encode_be32(xdr, rp->rp_status) != XDR_UNIT)
return;
xdr_stream_encode_opaque_fixed(xdr, rp->rp_buf, rp->rp_buflen);
} }
void nfsd4_release_compoundargs(struct svc_rqst *rqstp) void nfsd4_release_compoundargs(struct svc_rqst *rqstp)
......
...@@ -696,6 +696,24 @@ DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name, \ ...@@ -696,6 +696,24 @@ DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name, \
DEFINE_STID_EVENT(revoke); DEFINE_STID_EVENT(revoke);
TRACE_EVENT(nfsd_stateowner_replay,
TP_PROTO(
u32 opnum,
const struct nfs4_replay *rp
),
TP_ARGS(opnum, rp),
TP_STRUCT__entry(
__field(unsigned long, status)
__field(u32, opnum)
),
TP_fast_assign(
__entry->status = be32_to_cpu(rp->rp_status);
__entry->opnum = opnum;
),
TP_printk("opnum=%u status=%lu",
__entry->opnum, __entry->status)
);
TRACE_EVENT_CONDITION(nfsd_seq4_status, TRACE_EVENT_CONDITION(nfsd_seq4_status,
TP_PROTO( TP_PROTO(
const struct svc_rqst *rqstp, const struct svc_rqst *rqstp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment