xprtrdma: Move decoded header fields into rpcrdma_rep

Clean up: Make it easier to pass the decoded XID, vers, credits, and
proc fields around by moving these variables into struct rpcrdma_rep.

Note: the credits field will be handled in a subsequent patch.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
Chuck Lever 2017-10-16 15:01:14 -04:00 committed by Anna Schumaker
parent 61433af560
commit 5381e0ec72
2 changed files with 20 additions and 19 deletions

View File

@ -970,14 +970,13 @@ rpcrdma_mark_remote_invalidation(struct list_head *mws,
* straightforward to check the RPC header's direction field. * straightforward to check the RPC header's direction field.
*/ */
static bool static bool
rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep)
__be32 xid, __be32 proc)
#if defined(CONFIG_SUNRPC_BACKCHANNEL) #if defined(CONFIG_SUNRPC_BACKCHANNEL)
{ {
struct xdr_stream *xdr = &rep->rr_stream; struct xdr_stream *xdr = &rep->rr_stream;
__be32 *p; __be32 *p;
if (proc != rdma_msg) if (rep->rr_proc != rdma_msg)
return false; return false;
/* Peek at stream contents without advancing. */ /* Peek at stream contents without advancing. */
@ -992,7 +991,7 @@ rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep,
return false; return false;
/* RPC header */ /* RPC header */
if (*p++ != xid) if (*p++ != rep->rr_xid)
return false; return false;
if (*p != cpu_to_be32(RPC_CALL)) if (*p != cpu_to_be32(RPC_CALL))
return false; return false;
@ -1224,41 +1223,40 @@ rpcrdma_reply_handler(struct work_struct *work)
container_of(work, struct rpcrdma_rep, rr_work); container_of(work, struct rpcrdma_rep, rr_work);
struct rpcrdma_xprt *r_xprt = rep->rr_rxprt; struct rpcrdma_xprt *r_xprt = rep->rr_rxprt;
struct rpc_xprt *xprt = &r_xprt->rx_xprt; struct rpc_xprt *xprt = &r_xprt->rx_xprt;
struct xdr_stream *xdr = &rep->rr_stream;
struct rpcrdma_req *req; struct rpcrdma_req *req;
struct rpc_rqst *rqst; struct rpc_rqst *rqst;
__be32 *p, xid, vers, proc;
unsigned long cwnd; unsigned long cwnd;
int status; int status;
__be32 *p;
dprintk("RPC: %s: incoming rep %p\n", __func__, rep); dprintk("RPC: %s: incoming rep %p\n", __func__, rep);
if (rep->rr_hdrbuf.head[0].iov_len == 0) if (rep->rr_hdrbuf.head[0].iov_len == 0)
goto out_badstatus; goto out_badstatus;
xdr_init_decode(xdr, &rep->rr_hdrbuf, xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf,
rep->rr_hdrbuf.head[0].iov_base); rep->rr_hdrbuf.head[0].iov_base);
/* Fixed transport header fields */ /* Fixed transport header fields */
p = xdr_inline_decode(xdr, 4 * sizeof(*p)); p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p));
if (unlikely(!p)) if (unlikely(!p))
goto out_shortreply; goto out_shortreply;
xid = *p++; rep->rr_xid = *p++;
vers = *p++; rep->rr_vers = *p++;
p++; /* credits */ p++; /* credits */
proc = *p++; rep->rr_proc = *p++;
if (vers != rpcrdma_version) if (rep->rr_vers != rpcrdma_version)
goto out_badversion; goto out_badversion;
if (rpcrdma_is_bcall(r_xprt, rep, xid, proc)) if (rpcrdma_is_bcall(r_xprt, rep))
return; return;
/* Match incoming rpcrdma_rep to an rpcrdma_req to /* Match incoming rpcrdma_rep to an rpcrdma_req to
* get context for handling any incoming chunks. * get context for handling any incoming chunks.
*/ */
spin_lock(&xprt->recv_lock); spin_lock(&xprt->recv_lock);
rqst = xprt_lookup_rqst(xprt, xid); rqst = xprt_lookup_rqst(xprt, rep->rr_xid);
if (!rqst) if (!rqst)
goto out_norqst; goto out_norqst;
xprt_pin_rqst(rqst); xprt_pin_rqst(rqst);
@ -1267,7 +1265,7 @@ rpcrdma_reply_handler(struct work_struct *work)
req->rl_reply = rep; req->rl_reply = rep;
dprintk("RPC: %s: reply %p completes request %p (xid 0x%08x)\n", dprintk("RPC: %s: reply %p completes request %p (xid 0x%08x)\n",
__func__, rep, req, be32_to_cpu(xid)); __func__, rep, req, be32_to_cpu(rep->rr_xid));
/* Invalidate and unmap the data payloads before waking the /* Invalidate and unmap the data payloads before waking the
* waiting application. This guarantees the memory regions * waiting application. This guarantees the memory regions
@ -1284,7 +1282,7 @@ rpcrdma_reply_handler(struct work_struct *work)
xprt->reestablish_timeout = 0; xprt->reestablish_timeout = 0;
switch (proc) { switch (rep->rr_proc) {
case rdma_msg: case rdma_msg:
status = rpcrdma_decode_msg(r_xprt, rep, rqst); status = rpcrdma_decode_msg(r_xprt, rep, rqst);
break; break;
@ -1324,7 +1322,7 @@ out_badstatus:
out_badversion: out_badversion:
dprintk("RPC: %s: invalid version %d\n", dprintk("RPC: %s: invalid version %d\n",
__func__, be32_to_cpu(vers)); __func__, be32_to_cpu(rep->rr_vers));
goto repost; goto repost;
/* If the incoming reply terminated a pending RPC, the next /* If the incoming reply terminated a pending RPC, the next
@ -1333,7 +1331,7 @@ out_badversion:
*/ */
out_badheader: out_badheader:
dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n", dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n",
rqst->rq_task->tk_pid, __func__, be32_to_cpu(proc)); rqst->rq_task->tk_pid, __func__, be32_to_cpu(rep->rr_proc));
r_xprt->rx_stats.bad_reply_count++; r_xprt->rx_stats.bad_reply_count++;
status = -EIO; status = -EIO;
goto out; goto out;
@ -1345,7 +1343,7 @@ out_badheader:
out_norqst: out_norqst:
spin_unlock(&xprt->recv_lock); spin_unlock(&xprt->recv_lock);
dprintk("RPC: %s: no match for incoming xid 0x%08x\n", dprintk("RPC: %s: no match for incoming xid 0x%08x\n",
__func__, be32_to_cpu(xid)); __func__, be32_to_cpu(rep->rr_xid));
goto repost; goto repost;
out_shortreply: out_shortreply:

View File

@ -218,6 +218,9 @@ enum {
struct rpcrdma_rep { struct rpcrdma_rep {
struct ib_cqe rr_cqe; struct ib_cqe rr_cqe;
__be32 rr_xid;
__be32 rr_vers;
__be32 rr_proc;
int rr_wc_flags; int rr_wc_flags;
u32 rr_inv_rkey; u32 rr_inv_rkey;
struct rpcrdma_regbuf *rr_rdmabuf; struct rpcrdma_regbuf *rr_rdmabuf;