Skip to content

Commit 0ba6f37

Browse files
chuckleveramschuma-ntap
authored andcommitted
xprtrdma: Refactor rpcrdma_deferred_completion
Invoke a common routine for releasing hardware resources (for example, invalidating MRs). This needs to be done whether an RPC Reply has arrived or the RPC was terminated early. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 531cca0 commit 0ba6f37

File tree

3 files changed

+22
-13
lines changed

3 files changed

+22
-13
lines changed

net/sunrpc/xprtrdma/rpc_rdma.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,6 +1293,20 @@ void rpcrdma_complete_rqst(struct rpcrdma_rep *rep)
12931293
goto out;
12941294
}
12951295

1296+
void rpcrdma_release_rqst(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
1297+
{
1298+
/* Invalidate and unmap the data payloads before waking
1299+
* the waiting application. This guarantees the memory
1300+
* regions are properly fenced from the server before the
1301+
* application accesses the data. It also ensures proper
1302+
* send flow control: waking the next RPC waits until this
1303+
* RPC has relinquished all its Send Queue entries.
1304+
*/
1305+
if (!list_empty(&req->rl_registered))
1306+
r_xprt->rx_ia.ri_ops->ro_unmap_sync(r_xprt,
1307+
&req->rl_registered);
1308+
}
1309+
12961310
/* Reply handling runs in the poll worker thread. Anything that
12971311
* might wait is deferred to a separate workqueue.
12981312
*/
@@ -1301,18 +1315,9 @@ void rpcrdma_deferred_completion(struct work_struct *work)
13011315
struct rpcrdma_rep *rep =
13021316
container_of(work, struct rpcrdma_rep, rr_work);
13031317
struct rpcrdma_req *req = rpcr_to_rdmar(rep->rr_rqst);
1304-
struct rpcrdma_xprt *r_xprt = rep->rr_rxprt;
13051318

1306-
/* Invalidate and unmap the data payloads before waking
1307-
* the waiting application. This guarantees the memory
1308-
* regions are properly fenced from the server before the
1309-
* application accesses the data. It also ensures proper
1310-
* send flow control: waking the next RPC waits until this
1311-
* RPC has relinquished all its Send Queue entries.
1312-
*/
13131319
rpcrdma_mark_remote_invalidation(&req->rl_registered, rep);
1314-
r_xprt->rx_ia.ri_ops->ro_unmap_sync(r_xprt, &req->rl_registered);
1315-
1320+
rpcrdma_release_rqst(rep->rr_rxprt, req);
13161321
rpcrdma_complete_rqst(rep);
13171322
}
13181323

@@ -1374,6 +1379,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
13741379
req = rpcr_to_rdmar(rqst);
13751380
req->rl_reply = rep;
13761381
rep->rr_rqst = rqst;
1382+
clear_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags);
13771383

13781384
dprintk("RPC: %s: reply %p completes request %p (xid 0x%08x)\n",
13791385
__func__, rep, req, be32_to_cpu(rep->rr_xid));

net/sunrpc/xprtrdma/transport.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,15 +678,14 @@ xprt_rdma_free(struct rpc_task *task)
678678
struct rpc_rqst *rqst = task->tk_rqstp;
679679
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_xprt);
680680
struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
681-
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
682681

683682
if (test_bit(RPCRDMA_REQ_F_BACKCHANNEL, &req->rl_flags))
684683
return;
685684

686685
dprintk("RPC: %s: called on 0x%p\n", __func__, req->rl_reply);
687686

688-
if (!list_empty(&req->rl_registered))
689-
ia->ri_ops->ro_unmap_sync(r_xprt, &req->rl_registered);
687+
if (test_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags))
688+
rpcrdma_release_rqst(r_xprt, req);
690689
rpcrdma_buffer_put(req);
691690
}
692691

@@ -742,6 +741,7 @@ xprt_rdma_send_request(struct rpc_task *task)
742741
goto drop_connection;
743742
req->rl_connect_cookie = xprt->connect_cookie;
744743

744+
set_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags);
745745
if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req))
746746
goto drop_connection;
747747

net/sunrpc/xprtrdma/xprt_rdma.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ struct rpcrdma_req {
386386
/* rl_flags */
387387
enum {
388388
RPCRDMA_REQ_F_BACKCHANNEL = 0,
389+
RPCRDMA_REQ_F_PENDING,
389390
};
390391

391392
static inline void
@@ -655,6 +656,8 @@ int rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst);
655656
void rpcrdma_set_max_header_sizes(struct rpcrdma_xprt *);
656657
void rpcrdma_complete_rqst(struct rpcrdma_rep *rep);
657658
void rpcrdma_reply_handler(struct rpcrdma_rep *rep);
659+
void rpcrdma_release_rqst(struct rpcrdma_xprt *r_xprt,
660+
struct rpcrdma_req *req);
658661
void rpcrdma_deferred_completion(struct work_struct *work);
659662

660663
static inline void rpcrdma_set_xdrlen(struct xdr_buf *xdr, size_t len)

0 commit comments

Comments
 (0)