Skip to content

Commit a4f0835

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
SUNRPC: Eliminate task->tk_xprt accesses that bypass rcu_dereference()
tk_xprt is just a shortcut for tk_client->cl_xprt, however cl_xprt is defined as an __rcu variable. Replace dereferences of tk_xprt with non-rcu dereferences where it is safe to do so. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 88b62b9 commit a4f0835

7 files changed

Lines changed: 18 additions & 16 deletions

File tree

‎net/sunrpc/auth_gss/auth_gss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1154,7 +1154,7 @@ gss_marshal(struct rpc_task *task, __be32 *p)
11541154

11551155
/* We compute the checksum for the verifier over the xdr-encoded bytes
11561156
* starting with the xid and ending at the end of the credential: */
1157-
iov.iov_base = xprt_skip_transport_header(task->tk_xprt,
1157+
iov.iov_base = xprt_skip_transport_header(req->rq_xprt,
11581158
req->rq_snd_buf.head[0].iov_base);
11591159
iov.iov_len = (u8 *)p - (u8 *)iov.iov_base;
11601160
xdr_buf_from_iov(&iov, &verf_buf);

‎net/sunrpc/clnt.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ call_allocate(struct rpc_task *task)
14001400
{
14011401
unsigned int slack = task->tk_rqstp->rq_cred->cr_auth->au_cslack;
14021402
struct rpc_rqst *req = task->tk_rqstp;
1403-
struct rpc_xprt *xprt = task->tk_xprt;
1403+
struct rpc_xprt *xprt = req->rq_xprt;
14041404
struct rpc_procinfo *proc = task->tk_msg.rpc_proc;
14051405

14061406
dprint_status(task);
@@ -1685,7 +1685,7 @@ call_transmit(struct rpc_task *task)
16851685
if (rpc_reply_expected(task))
16861686
return;
16871687
task->tk_action = rpc_exit_task;
1688-
rpc_wake_up_queued_task(&task->tk_xprt->pending, task);
1688+
rpc_wake_up_queued_task(&task->tk_rqstp->rq_xprt->pending, task);
16891689
}
16901690

16911691
/*
@@ -1784,7 +1784,7 @@ call_bc_transmit(struct rpc_task *task)
17841784
*/
17851785
printk(KERN_NOTICE "RPC: Could not send backchannel reply "
17861786
"error: %d\n", task->tk_status);
1787-
xprt_conditional_disconnect(task->tk_xprt,
1787+
xprt_conditional_disconnect(req->rq_xprt,
17881788
req->rq_connect_cookie);
17891789
break;
17901790
default:
@@ -1836,7 +1836,7 @@ call_status(struct rpc_task *task)
18361836
case -ETIMEDOUT:
18371837
task->tk_action = call_timeout;
18381838
if (task->tk_client->cl_discrtry)
1839-
xprt_conditional_disconnect(task->tk_xprt,
1839+
xprt_conditional_disconnect(req->rq_xprt,
18401840
req->rq_connect_cookie);
18411841
break;
18421842
case -ECONNRESET:
@@ -1991,7 +1991,7 @@ call_decode(struct rpc_task *task)
19911991
if (task->tk_rqstp == req) {
19921992
req->rq_reply_bytes_recvd = req->rq_rcv_buf.len = 0;
19931993
if (task->tk_client->cl_discrtry)
1994-
xprt_conditional_disconnect(task->tk_xprt,
1994+
xprt_conditional_disconnect(req->rq_xprt,
19951995
req->rq_connect_cookie);
19961996
}
19971997
}
@@ -2005,7 +2005,7 @@ rpc_encode_header(struct rpc_task *task)
20052005

20062006
/* FIXME: check buffer size? */
20072007

2008-
p = xprt_skip_transport_header(task->tk_xprt, p);
2008+
p = xprt_skip_transport_header(req->rq_xprt, p);
20092009
*p++ = req->rq_xid; /* XID */
20102010
*p++ = htonl(RPC_CALL); /* CALL */
20112011
*p++ = htonl(RPC_VERSION); /* RPC version */

‎net/sunrpc/xprt.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ __xprt_put_cong(struct rpc_xprt *xprt, struct rpc_rqst *req)
430430
*/
431431
void xprt_release_rqst_cong(struct rpc_task *task)
432432
{
433-
__xprt_put_cong(task->tk_xprt, task->tk_rqstp);
433+
struct rpc_rqst *req = task->tk_rqstp;
434+
435+
__xprt_put_cong(req->rq_xprt, req);
434436
}
435437
EXPORT_SYMBOL_GPL(xprt_release_rqst_cong);
436438

‎net/sunrpc/xprtrdma/rpc_rdma.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ rpcrdma_create_chunks(struct rpc_rqst *rqst, struct xdr_buf *target,
171171
struct rpcrdma_msg *headerp, enum rpcrdma_chunktype type)
172172
{
173173
struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
174-
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_task->tk_xprt);
174+
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_xprt);
175175
int nsegs, nchunks = 0;
176176
unsigned int pos;
177177
struct rpcrdma_mr_seg *seg = req->rl_segments;
@@ -366,7 +366,7 @@ rpcrdma_inline_pullup(struct rpc_rqst *rqst, int pad)
366366
int
367367
rpcrdma_marshal_req(struct rpc_rqst *rqst)
368368
{
369-
struct rpc_xprt *xprt = rqst->rq_task->tk_xprt;
369+
struct rpc_xprt *xprt = rqst->rq_xprt;
370370
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
371371
struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
372372
char *base;

‎net/sunrpc/xprtrdma/transport.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ xprt_rdma_reserve_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
475475
static void *
476476
xprt_rdma_allocate(struct rpc_task *task, size_t size)
477477
{
478-
struct rpc_xprt *xprt = task->tk_xprt;
478+
struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
479479
struct rpcrdma_req *req, *nreq;
480480

481481
req = rpcrdma_buffer_get(&rpcx_to_rdmax(xprt)->rx_buf);
@@ -627,7 +627,7 @@ static int
627627
xprt_rdma_send_request(struct rpc_task *task)
628628
{
629629
struct rpc_rqst *rqst = task->tk_rqstp;
630-
struct rpc_xprt *xprt = task->tk_xprt;
630+
struct rpc_xprt *xprt = rqst->rq_xprt;
631631
struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
632632
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
633633

‎net/sunrpc/xprtrdma/xprt_rdma.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,13 @@ struct rpcrdma_create_data_internal {
235235
};
236236

237237
#define RPCRDMA_INLINE_READ_THRESHOLD(rq) \
238-
(rpcx_to_rdmad(rq->rq_task->tk_xprt).inline_rsize)
238+
(rpcx_to_rdmad(rq->rq_xprt).inline_rsize)
239239

240240
#define RPCRDMA_INLINE_WRITE_THRESHOLD(rq)\
241-
(rpcx_to_rdmad(rq->rq_task->tk_xprt).inline_wsize)
241+
(rpcx_to_rdmad(rq->rq_xprt).inline_wsize)
242242

243243
#define RPCRDMA_INLINE_PAD_VALUE(rq)\
244-
rpcx_to_rdmad(rq->rq_task->tk_xprt).padding
244+
rpcx_to_rdmad(rq->rq_xprt).padding
245245

246246
/*
247247
* Statistics for RPCRDMA

‎net/sunrpc/xprtsock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ static void xs_tcp_release_xprt(struct rpc_xprt *xprt, struct rpc_task *task)
770770
goto out_release;
771771
if (req->rq_bytes_sent == req->rq_snd_buf.len)
772772
goto out_release;
773-
set_bit(XPRT_CLOSE_WAIT, &task->tk_xprt->state);
773+
set_bit(XPRT_CLOSE_WAIT, &xprt->state);
774774
out_release:
775775
xprt_release_xprt(xprt, task);
776776
}

0 commit comments

Comments
 (0)