Skip to content

Commit 1b09209

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
SUNRPC: Pass a pointer to struct rpc_xprt to the connect callback
Avoid another RCU dereference by passing the pointer to struct rpc_xprt from the caller. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent a4f0835 commit 1b09209

4 files changed

Lines changed: 5 additions & 6 deletions

File tree

‎include/linux/sunrpc/xprt.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct rpc_xprt_ops {
117117
void (*alloc_slot)(struct rpc_xprt *xprt, struct rpc_task *task);
118118
void (*rpcbind)(struct rpc_task *task);
119119
void (*set_port)(struct rpc_xprt *xprt, unsigned short port);
120-
void (*connect)(struct rpc_task *task);
120+
void (*connect)(struct rpc_xprt *xprt, struct rpc_task *task);
121121
void * (*buf_alloc)(struct rpc_task *task, size_t size);
122122
void (*buf_free)(void *buffer);
123123
int (*send_request)(struct rpc_task *task);

‎net/sunrpc/xprt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ void xprt_connect(struct rpc_task *task)
724724
if (xprt_test_and_set_connecting(xprt))
725725
return;
726726
xprt->stat.connect_start = jiffies;
727-
xprt->ops->connect(task);
727+
xprt->ops->connect(xprt, task);
728728
}
729729
}
730730

‎net/sunrpc/xprtrdma/transport.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,8 @@ xprt_rdma_set_port(struct rpc_xprt *xprt, u16 port)
426426
}
427427

428428
static void
429-
xprt_rdma_connect(struct rpc_task *task)
429+
xprt_rdma_connect(struct rpc_xprt *xprt, struct rpc_task *task)
430430
{
431-
struct rpc_xprt *xprt = (struct rpc_xprt *)task->tk_xprt;
432431
struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
433432

434433
if (r_xprt->rx_ep.rep_connected != 0) {

‎net/sunrpc/xprtsock.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,6 +2205,7 @@ static void xs_tcp_setup_socket(struct work_struct *work)
22052205

22062206
/**
22072207
* xs_connect - connect a socket to a remote endpoint
2208+
* @xprt: pointer to transport structure
22082209
* @task: address of RPC task that manages state of connect request
22092210
*
22102211
* TCP: If the remote end dropped the connection, delay reconnecting.
@@ -2216,9 +2217,8 @@ static void xs_tcp_setup_socket(struct work_struct *work)
22162217
* If a UDP socket connect fails, the delay behavior here prevents
22172218
* retry floods (hard mounts).
22182219
*/
2219-
static void xs_connect(struct rpc_task *task)
2220+
static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task)
22202221
{
2221-
struct rpc_xprt *xprt = task->tk_xprt;
22222222
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
22232223

22242224
if (transport->sock != NULL && !RPC_IS_SOFTCONN(task)) {

0 commit comments

Comments
 (0)