Skip to content

Commit d9adbb6

Browse files
jtlaytonchucklever
authored andcommitted
sunrpc: delay pc_release callback until after the reply is sent
The server-side sunrpc code currently calls pc_release before sending the reply. Change svc_process and svc_process_bc to call pc_release after sending the reply instead. Reviewed-by: NeilBrown <neil@brown.name> Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent c1f203e commit d9adbb6

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

net/sunrpc/svc.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,6 @@ svc_process_common(struct svc_rqst *rqstp)
14261426

14271427
/* Call the function that processes the request. */
14281428
rc = process.dispatch(rqstp);
1429-
if (procp->pc_release)
1430-
procp->pc_release(rqstp);
14311429
xdr_finish_decode(xdr);
14321430

14331431
if (!rc)
@@ -1526,6 +1524,14 @@ static void svc_drop(struct svc_rqst *rqstp)
15261524
trace_svc_drop(rqstp);
15271525
}
15281526

1527+
static void svc_release_rqst(struct svc_rqst *rqstp)
1528+
{
1529+
const struct svc_procedure *procp = rqstp->rq_procinfo;
1530+
1531+
if (procp && procp->pc_release)
1532+
procp->pc_release(rqstp);
1533+
}
1534+
15291535
/**
15301536
* svc_process - Execute one RPC transaction
15311537
* @rqstp: RPC transaction context
@@ -1565,9 +1571,12 @@ void svc_process(struct svc_rqst *rqstp)
15651571
if (unlikely(*p != rpc_call))
15661572
goto out_baddir;
15671573

1568-
if (!svc_process_common(rqstp))
1574+
if (!svc_process_common(rqstp)) {
1575+
svc_release_rqst(rqstp);
15691576
goto out_drop;
1577+
}
15701578
svc_send(rqstp);
1579+
svc_release_rqst(rqstp);
15711580
return;
15721581

15731582
out_baddir:
@@ -1635,6 +1644,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
16351644
if (!proc_error) {
16361645
/* Processing error: drop the request */
16371646
xprt_free_bc_request(req);
1647+
svc_release_rqst(rqstp);
16381648
return;
16391649
}
16401650
/* Finally, send the reply synchronously */
@@ -1648,6 +1658,7 @@ void svc_process_bc(struct rpc_rqst *req, struct svc_rqst *rqstp)
16481658
timeout.to_maxval = timeout.to_initval;
16491659
memcpy(&req->rq_snd_buf, &rqstp->rq_res, sizeof(req->rq_snd_buf));
16501660
task = rpc_run_bc_task(req, &timeout);
1661+
svc_release_rqst(rqstp);
16511662

16521663
if (IS_ERR(task))
16531664
return;

0 commit comments

Comments
 (0)