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)
rqstp->rq_next_page = xdr->page_ptr + 1;
}
/*
* Encode the reply stored in the stateowner reply cache
*
* XDR note: do not encode rp->rp_buflen: the buffer contains the
* previously sent already encoded operation.
/**
* nfsd4_encode_replay - encode a result stored in the stateowner reply cache
* @xdr: send buffer's XDR stream
* @op: operation being replayed
*
* @op->replay->rp_buf contains the previously-sent already-encoded result.
*/
void
nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op)
{
__be32 *p;
struct nfs4_replay *rp = op->replay;
p = xdr_reserve_space(xdr, 8 + rp->rp_buflen);
if (!p) {
WARN_ON_ONCE(1);
return;
}
*p++ = cpu_to_be32(op->opnum);
*p++ = rp->rp_status; /* already xdr'ed */
trace_nfsd_stateowner_replay(op->opnum, rp);
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)
......
......@@ -696,6 +696,24 @@ DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name, \
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,
TP_PROTO(
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