Skip to content

Commit 0ccc61b

Browse files
chuckleveramschuma-ntap
authored andcommitted
SUNRPC: Add xdr_stream::rqst field
Having access to the controlling rpc_rqst means a trace point in the XDR code can report: - the XID - the task ID and client ID - the p_name of RPC being processed Subsequent patches will introduce such trace points. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 6f70138 commit 0ccc61b

File tree

8 files changed

+26
-15
lines changed

8 files changed

+26
-15
lines changed

fs/nfs/callback_xdr.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,10 +943,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
943943
};
944944
unsigned int nops = 0;
945945

946-
xdr_init_decode(&xdr_in, &rqstp->rq_arg, rqstp->rq_arg.head[0].iov_base);
946+
xdr_init_decode(&xdr_in, &rqstp->rq_arg,
947+
rqstp->rq_arg.head[0].iov_base, NULL);
947948

948949
p = (__be32*)((char *)rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len);
949-
xdr_init_encode(&xdr_out, &rqstp->rq_res, p);
950+
xdr_init_encode(&xdr_out, &rqstp->rq_res, p, NULL);
950951

951952
status = decode_compound_hdr_arg(&xdr_in, &hdr_arg);
952953
if (status == htonl(NFS4ERR_RESOURCE))

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2036,7 +2036,7 @@ ff_layout_encode_layoutreturn(struct xdr_stream *xdr,
20362036

20372037
dprintk("%s: Begin\n", __func__);
20382038

2039-
xdr_init_encode(&tmp_xdr, &tmp_buf, NULL);
2039+
xdr_init_encode(&tmp_xdr, &tmp_buf, NULL, NULL);
20402040

20412041
ff_layout_encode_ioerr(&tmp_xdr, args, ff_args);
20422042
ff_layout_encode_iostats_array(&tmp_xdr, args, ff_args);

include/linux/sunrpc/xdr.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ struct xdr_stream {
217217
struct kvec scratch; /* Scratch buffer */
218218
struct page **page_ptr; /* pointer to the current page */
219219
unsigned int nwords; /* Remaining decode buffer length */
220+
221+
struct rpc_rqst *rqst; /* For debugging */
220222
};
221223

222224
/*
@@ -227,15 +229,17 @@ typedef void (*kxdreproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
227229
typedef int (*kxdrdproc_t)(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
228230
void *obj);
229231

230-
extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
232+
extern void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf,
233+
__be32 *p, struct rpc_rqst *rqst);
231234
extern __be32 *xdr_reserve_space(struct xdr_stream *xdr, size_t nbytes);
232235
extern void xdr_commit_encode(struct xdr_stream *xdr);
233236
extern void xdr_truncate_encode(struct xdr_stream *xdr, size_t len);
234237
extern int xdr_restrict_buflen(struct xdr_stream *xdr, int newbuflen);
235238
extern void xdr_write_pages(struct xdr_stream *xdr, struct page **pages,
236239
unsigned int base, unsigned int len);
237240
extern unsigned int xdr_stream_pos(const struct xdr_stream *xdr);
238-
extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p);
241+
extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf,
242+
__be32 *p, struct rpc_rqst *rqst);
239243
extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
240244
struct page **pages, unsigned int len);
241245
extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen);

net/sunrpc/auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ static void rpcauth_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp,
798798
{
799799
struct xdr_stream xdr;
800800

801-
xdr_init_encode(&xdr, &rqstp->rq_snd_buf, data);
801+
xdr_init_encode(&xdr, &rqstp->rq_snd_buf, data, rqstp);
802802
encode(rqstp, &xdr, obj);
803803
}
804804

@@ -823,7 +823,7 @@ rpcauth_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
823823
{
824824
struct xdr_stream xdr;
825825

826-
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data);
826+
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, data, rqstp);
827827
return decode(rqstp, &xdr, obj);
828828
}
829829

net/sunrpc/auth_gss/auth_gss.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ static void gss_wrap_req_encode(kxdreproc_t encode, struct rpc_rqst *rqstp,
17221722
{
17231723
struct xdr_stream xdr;
17241724

1725-
xdr_init_encode(&xdr, &rqstp->rq_snd_buf, p);
1725+
xdr_init_encode(&xdr, &rqstp->rq_snd_buf, p, rqstp);
17261726
encode(rqstp, &xdr, obj);
17271727
}
17281728

@@ -1998,7 +1998,7 @@ gss_unwrap_req_decode(kxdrdproc_t decode, struct rpc_rqst *rqstp,
19981998
{
19991999
struct xdr_stream xdr;
20002000

2001-
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p);
2001+
xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p, rqstp);
20022002
return decode(rqstp, &xdr, obj);
20032003
}
20042004

net/sunrpc/xdr.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos);
483483
* @xdr: pointer to xdr_stream struct
484484
* @buf: pointer to XDR buffer in which to encode data
485485
* @p: current pointer inside XDR buffer
486+
* @rqst: pointer to controlling rpc_rqst, for debugging
486487
*
487488
* Note: at the moment the RPC client only passes the length of our
488489
* scratch buffer in the xdr_buf's header kvec. Previously this
@@ -491,7 +492,8 @@ EXPORT_SYMBOL_GPL(xdr_stream_pos);
491492
* of the buffer length, and takes care of adjusting the kvec
492493
* length for us.
493494
*/
494-
void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
495+
void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p,
496+
struct rpc_rqst *rqst)
495497
{
496498
struct kvec *iov = buf->head;
497499
int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len;
@@ -513,6 +515,7 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
513515
buf->len += len;
514516
iov->iov_len += len;
515517
}
518+
xdr->rqst = rqst;
516519
}
517520
EXPORT_SYMBOL_GPL(xdr_init_encode);
518521

@@ -819,8 +822,10 @@ static bool xdr_set_next_buffer(struct xdr_stream *xdr)
819822
* @xdr: pointer to xdr_stream struct
820823
* @buf: pointer to XDR buffer from which to decode data
821824
* @p: current pointer inside XDR buffer
825+
* @rqst: pointer to controlling rpc_rqst, for debugging
822826
*/
823-
void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
827+
void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p,
828+
struct rpc_rqst *rqst)
824829
{
825830
xdr->buf = buf;
826831
xdr->scratch.iov_base = NULL;
@@ -836,6 +841,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p)
836841
xdr->nwords -= p - xdr->p;
837842
xdr->p = p;
838843
}
844+
xdr->rqst = rqst;
839845
}
840846
EXPORT_SYMBOL_GPL(xdr_init_decode);
841847

@@ -854,7 +860,7 @@ void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf,
854860
buf->page_len = len;
855861
buf->buflen = len;
856862
buf->len = len;
857-
xdr_init_decode(xdr, buf, NULL);
863+
xdr_init_decode(xdr, buf, NULL, NULL);
858864
}
859865
EXPORT_SYMBOL_GPL(xdr_init_decode_pages);
860866

net/sunrpc/xprtrdma/backchannel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static int rpcrdma_bc_marshal_reply(struct rpc_rqst *rqst)
123123

124124
rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0);
125125
xdr_init_encode(&req->rl_stream, &req->rl_hdrbuf,
126-
req->rl_rdmabuf->rg_base);
126+
req->rl_rdmabuf->rg_base, rqst);
127127

128128
p = xdr_reserve_space(&req->rl_stream, 28);
129129
if (unlikely(!p))

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
748748

749749
rpcrdma_set_xdrlen(&req->rl_hdrbuf, 0);
750750
xdr_init_encode(xdr, &req->rl_hdrbuf,
751-
req->rl_rdmabuf->rg_base);
751+
req->rl_rdmabuf->rg_base, rqst);
752752

753753
/* Fixed header fields */
754754
ret = -EMSGSIZE;
@@ -1329,7 +1329,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
13291329

13301330
/* Fixed transport header fields */
13311331
xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf,
1332-
rep->rr_hdrbuf.head[0].iov_base);
1332+
rep->rr_hdrbuf.head[0].iov_base, NULL);
13331333
p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p));
13341334
if (unlikely(!p))
13351335
goto out_shortreply;

0 commit comments

Comments
 (0)