diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2017-10-16 15:01:14 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2017-11-17 13:47:54 -0500 |
commit | 5381e0ec72eeb9467796ac4181ccb7bbce6d3e81 (patch) | |
tree | 8fb5bcdf34eedadf3f98f7b984b33437f8333619 /net/sunrpc | |
parent | 61433af56077f5fd8815281b44938d84feb04687 (diff) |
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>
Diffstat (limited to 'net/sunrpc')
-rw-r--r-- | net/sunrpc/xprtrdma/rpc_rdma.c | 36 | ||||
-rw-r--r-- | net/sunrpc/xprtrdma/xprt_rdma.h | 3 |
2 files changed, 20 insertions, 19 deletions
diff --git a/net/sunrpc/xprtrdma/rpc_rdma.c b/net/sunrpc/xprtrdma/rpc_rdma.c index 20c9e4cbaa73..e355cd322a32 100644 --- a/net/sunrpc/xprtrdma/rpc_rdma.c +++ b/net/sunrpc/xprtrdma/rpc_rdma.c | |||
@@ -970,14 +970,13 @@ rpcrdma_mark_remote_invalidation(struct list_head *mws, | |||
970 | * straightforward to check the RPC header's direction field. | 970 | * straightforward to check the RPC header's direction field. |
971 | */ | 971 | */ |
972 | static bool | 972 | static bool |
973 | rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, | 973 | rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep) |
974 | __be32 xid, __be32 proc) | ||
975 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) | 974 | #if defined(CONFIG_SUNRPC_BACKCHANNEL) |
976 | { | 975 | { |
977 | struct xdr_stream *xdr = &rep->rr_stream; | 976 | struct xdr_stream *xdr = &rep->rr_stream; |
978 | __be32 *p; | 977 | __be32 *p; |
979 | 978 | ||
980 | if (proc != rdma_msg) | 979 | if (rep->rr_proc != rdma_msg) |
981 | return false; | 980 | return false; |
982 | 981 | ||
983 | /* Peek at stream contents without advancing. */ | 982 | /* Peek at stream contents without advancing. */ |
@@ -992,7 +991,7 @@ rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep, | |||
992 | return false; | 991 | return false; |
993 | 992 | ||
994 | /* RPC header */ | 993 | /* RPC header */ |
995 | if (*p++ != xid) | 994 | if (*p++ != rep->rr_xid) |
996 | return false; | 995 | return false; |
997 | if (*p != cpu_to_be32(RPC_CALL)) | 996 | if (*p != cpu_to_be32(RPC_CALL)) |
998 | return false; | 997 | return false; |
@@ -1224,41 +1223,40 @@ rpcrdma_reply_handler(struct work_struct *work) | |||
1224 | container_of(work, struct rpcrdma_rep, rr_work); | 1223 | container_of(work, struct rpcrdma_rep, rr_work); |
1225 | struct rpcrdma_xprt *r_xprt = rep->rr_rxprt; | 1224 | struct rpcrdma_xprt *r_xprt = rep->rr_rxprt; |
1226 | struct rpc_xprt *xprt = &r_xprt->rx_xprt; | 1225 | struct rpc_xprt *xprt = &r_xprt->rx_xprt; |
1227 | struct xdr_stream *xdr = &rep->rr_stream; | ||
1228 | struct rpcrdma_req *req; | 1226 | struct rpcrdma_req *req; |
1229 | struct rpc_rqst *rqst; | 1227 | struct rpc_rqst *rqst; |
1230 | __be32 *p, xid, vers, proc; | ||
1231 | unsigned long cwnd; | 1228 | unsigned long cwnd; |
1232 | int status; | 1229 | int status; |
1230 | __be32 *p; | ||
1233 | 1231 | ||
1234 | dprintk("RPC: %s: incoming rep %p\n", __func__, rep); | 1232 | dprintk("RPC: %s: incoming rep %p\n", __func__, rep); |
1235 | 1233 | ||
1236 | if (rep->rr_hdrbuf.head[0].iov_len == 0) | 1234 | if (rep->rr_hdrbuf.head[0].iov_len == 0) |
1237 | goto out_badstatus; | 1235 | goto out_badstatus; |
1238 | 1236 | ||
1239 | xdr_init_decode(xdr, &rep->rr_hdrbuf, | 1237 | xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf, |
1240 | rep->rr_hdrbuf.head[0].iov_base); | 1238 | rep->rr_hdrbuf.head[0].iov_base); |
1241 | 1239 | ||
1242 | /* Fixed transport header fields */ | 1240 | /* Fixed transport header fields */ |
1243 | p = xdr_inline_decode(xdr, 4 * sizeof(*p)); | 1241 | p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p)); |
1244 | if (unlikely(!p)) | 1242 | if (unlikely(!p)) |
1245 | goto out_shortreply; | 1243 | goto out_shortreply; |
1246 | xid = *p++; | 1244 | rep->rr_xid = *p++; |
1247 | vers = *p++; | 1245 | rep->rr_vers = *p++; |
1248 | p++; /* credits */ | 1246 | p++; /* credits */ |
1249 | proc = *p++; | 1247 | rep->rr_proc = *p++; |
1250 | 1248 | ||
1251 | if (vers != rpcrdma_version) | 1249 | if (rep->rr_vers != rpcrdma_version) |
1252 | goto out_badversion; | 1250 | goto out_badversion; |
1253 | 1251 | ||
1254 | if (rpcrdma_is_bcall(r_xprt, rep, xid, proc)) | 1252 | if (rpcrdma_is_bcall(r_xprt, rep)) |
1255 | return; | 1253 | return; |
1256 | 1254 | ||
1257 | /* Match incoming rpcrdma_rep to an rpcrdma_req to | 1255 | /* Match incoming rpcrdma_rep to an rpcrdma_req to |
1258 | * get context for handling any incoming chunks. | 1256 | * get context for handling any incoming chunks. |
1259 | */ | 1257 | */ |
1260 | spin_lock(&xprt->recv_lock); | 1258 | spin_lock(&xprt->recv_lock); |
1261 | rqst = xprt_lookup_rqst(xprt, xid); | 1259 | rqst = xprt_lookup_rqst(xprt, rep->rr_xid); |
1262 | if (!rqst) | 1260 | if (!rqst) |
1263 | goto out_norqst; | 1261 | goto out_norqst; |
1264 | xprt_pin_rqst(rqst); | 1262 | xprt_pin_rqst(rqst); |
@@ -1267,7 +1265,7 @@ rpcrdma_reply_handler(struct work_struct *work) | |||
1267 | req->rl_reply = rep; | 1265 | req->rl_reply = rep; |
1268 | 1266 | ||
1269 | dprintk("RPC: %s: reply %p completes request %p (xid 0x%08x)\n", | 1267 | dprintk("RPC: %s: reply %p completes request %p (xid 0x%08x)\n", |
1270 | __func__, rep, req, be32_to_cpu(xid)); | 1268 | __func__, rep, req, be32_to_cpu(rep->rr_xid)); |
1271 | 1269 | ||
1272 | /* Invalidate and unmap the data payloads before waking the | 1270 | /* Invalidate and unmap the data payloads before waking the |
1273 | * waiting application. This guarantees the memory regions | 1271 | * waiting application. This guarantees the memory regions |
@@ -1284,7 +1282,7 @@ rpcrdma_reply_handler(struct work_struct *work) | |||
1284 | 1282 | ||
1285 | xprt->reestablish_timeout = 0; | 1283 | xprt->reestablish_timeout = 0; |
1286 | 1284 | ||
1287 | switch (proc) { | 1285 | switch (rep->rr_proc) { |
1288 | case rdma_msg: | 1286 | case rdma_msg: |
1289 | status = rpcrdma_decode_msg(r_xprt, rep, rqst); | 1287 | status = rpcrdma_decode_msg(r_xprt, rep, rqst); |
1290 | break; | 1288 | break; |
@@ -1324,7 +1322,7 @@ out_badstatus: | |||
1324 | 1322 | ||
1325 | out_badversion: | 1323 | out_badversion: |
1326 | dprintk("RPC: %s: invalid version %d\n", | 1324 | dprintk("RPC: %s: invalid version %d\n", |
1327 | __func__, be32_to_cpu(vers)); | 1325 | __func__, be32_to_cpu(rep->rr_vers)); |
1328 | goto repost; | 1326 | goto repost; |
1329 | 1327 | ||
1330 | /* If the incoming reply terminated a pending RPC, the next | 1328 | /* If the incoming reply terminated a pending RPC, the next |
@@ -1333,7 +1331,7 @@ out_badversion: | |||
1333 | */ | 1331 | */ |
1334 | out_badheader: | 1332 | out_badheader: |
1335 | dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n", | 1333 | dprintk("RPC: %5u %s: invalid rpcrdma reply (type %u)\n", |
1336 | rqst->rq_task->tk_pid, __func__, be32_to_cpu(proc)); | 1334 | rqst->rq_task->tk_pid, __func__, be32_to_cpu(rep->rr_proc)); |
1337 | r_xprt->rx_stats.bad_reply_count++; | 1335 | r_xprt->rx_stats.bad_reply_count++; |
1338 | status = -EIO; | 1336 | status = -EIO; |
1339 | goto out; | 1337 | goto out; |
@@ -1345,7 +1343,7 @@ out_badheader: | |||
1345 | out_norqst: | 1343 | out_norqst: |
1346 | spin_unlock(&xprt->recv_lock); | 1344 | spin_unlock(&xprt->recv_lock); |
1347 | dprintk("RPC: %s: no match for incoming xid 0x%08x\n", | 1345 | dprintk("RPC: %s: no match for incoming xid 0x%08x\n", |
1348 | __func__, be32_to_cpu(xid)); | 1346 | __func__, be32_to_cpu(rep->rr_xid)); |
1349 | goto repost; | 1347 | goto repost; |
1350 | 1348 | ||
1351 | out_shortreply: | 1349 | out_shortreply: |
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h index 74e017477e72..858b4c52047d 100644 --- a/net/sunrpc/xprtrdma/xprt_rdma.h +++ b/net/sunrpc/xprtrdma/xprt_rdma.h | |||
@@ -218,6 +218,9 @@ enum { | |||
218 | 218 | ||
219 | struct rpcrdma_rep { | 219 | struct rpcrdma_rep { |
220 | struct ib_cqe rr_cqe; | 220 | struct ib_cqe rr_cqe; |
221 | __be32 rr_xid; | ||
222 | __be32 rr_vers; | ||
223 | __be32 rr_proc; | ||
221 | int rr_wc_flags; | 224 | int rr_wc_flags; |
222 | u32 rr_inv_rkey; | 225 | u32 rr_inv_rkey; |
223 | struct rpcrdma_regbuf *rr_rdmabuf; | 226 | struct rpcrdma_regbuf *rr_rdmabuf; |