Skip to content

Commit 4efdd92

Browse files
committed
SUNRPC: Remove TCP client connection reset hack
Instead we rely on SO_REUSEPORT to provide the reconnection semantics that we need for NFSv2/v3. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
1 parent de84d89 commit 4efdd92

File tree

2 files changed

+1
-67
lines changed

2 files changed

+1
-67
lines changed

include/linux/sunrpc/xprt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ void xprt_unlock_connect(struct rpc_xprt *, void *);
363363
#define XPRT_CONNECTION_ABORT (7)
364364
#define XPRT_CONNECTION_CLOSE (8)
365365
#define XPRT_CONGESTED (9)
366-
#define XPRT_CONNECTION_REUSE (10)
367366

368367
static inline void xprt_set_connected(struct rpc_xprt *xprt)
369368
{

net/sunrpc/xprtsock.c

Lines changed: 1 addition & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -796,8 +796,6 @@ static void xs_error_report(struct sock *sk)
796796
dprintk("RPC: xs_error_report client %p, error=%d...\n",
797797
xprt, -err);
798798
trace_rpc_socket_error(xprt, sk->sk_socket, err);
799-
if (test_bit(XPRT_CONNECTION_REUSE, &xprt->state))
800-
goto out;
801799
xprt_wake_pending_tasks(xprt, err);
802800
out:
803801
read_unlock_bh(&sk->sk_callback_lock);
@@ -2102,57 +2100,6 @@ static void xs_udp_setup_socket(struct work_struct *work)
21022100
xprt_wake_pending_tasks(xprt, status);
21032101
}
21042102

2105-
/*
2106-
* We need to preserve the port number so the reply cache on the server can
2107-
* find our cached RPC replies when we get around to reconnecting.
2108-
*/
2109-
static void xs_abort_connection(struct sock_xprt *transport)
2110-
{
2111-
int result;
2112-
struct sockaddr any;
2113-
2114-
dprintk("RPC: disconnecting xprt %p to reuse port\n", transport);
2115-
2116-
/*
2117-
* Disconnect the transport socket by doing a connect operation
2118-
* with AF_UNSPEC. This should return immediately...
2119-
*/
2120-
memset(&any, 0, sizeof(any));
2121-
any.sa_family = AF_UNSPEC;
2122-
result = kernel_connect(transport->sock, &any, sizeof(any), 0);
2123-
trace_rpc_socket_reset_connection(&transport->xprt,
2124-
transport->sock, result);
2125-
if (!result)
2126-
xs_sock_reset_connection_flags(&transport->xprt);
2127-
dprintk("RPC: AF_UNSPEC connect return code %d\n", result);
2128-
}
2129-
2130-
static void xs_tcp_reuse_connection(struct sock_xprt *transport)
2131-
{
2132-
unsigned int state = transport->inet->sk_state;
2133-
2134-
if (state == TCP_CLOSE && transport->sock->state == SS_UNCONNECTED) {
2135-
/* we don't need to abort the connection if the socket
2136-
* hasn't undergone a shutdown
2137-
*/
2138-
if (transport->inet->sk_shutdown == 0)
2139-
return;
2140-
dprintk("RPC: %s: TCP_CLOSEd and sk_shutdown set to %d\n",
2141-
__func__, transport->inet->sk_shutdown);
2142-
}
2143-
if ((1 << state) & (TCPF_ESTABLISHED|TCPF_SYN_SENT)) {
2144-
/* we don't need to abort the connection if the socket
2145-
* hasn't undergone a shutdown
2146-
*/
2147-
if (transport->inet->sk_shutdown == 0)
2148-
return;
2149-
dprintk("RPC: %s: ESTABLISHED/SYN_SENT "
2150-
"sk_shutdown set to %d\n",
2151-
__func__, transport->inet->sk_shutdown);
2152-
}
2153-
xs_abort_connection(transport);
2154-
}
2155-
21562103
static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
21572104
{
21582105
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
@@ -2245,18 +2192,6 @@ static void xs_tcp_setup_socket(struct work_struct *work)
22452192
status = PTR_ERR(sock);
22462193
goto out;
22472194
}
2248-
} else {
2249-
int abort_and_exit;
2250-
2251-
abort_and_exit = test_and_clear_bit(XPRT_CONNECTION_ABORT,
2252-
&xprt->state);
2253-
/* "close" the socket, preserving the local port */
2254-
set_bit(XPRT_CONNECTION_REUSE, &xprt->state);
2255-
xs_tcp_reuse_connection(transport);
2256-
clear_bit(XPRT_CONNECTION_REUSE, &xprt->state);
2257-
2258-
if (abort_and_exit)
2259-
goto out_eagain;
22602195
}
22612196

22622197
dprintk("RPC: worker connecting xprt %p via %s to "
@@ -2296,9 +2231,9 @@ static void xs_tcp_setup_socket(struct work_struct *work)
22962231
case -EADDRINUSE:
22972232
case -ENOBUFS:
22982233
/* retry with existing socket, after a delay */
2234+
xs_tcp_force_close(xprt);
22992235
goto out;
23002236
}
2301-
out_eagain:
23022237
status = -EAGAIN;
23032238
out:
23042239
xprt_unlock_connect(xprt, transport);

0 commit comments

Comments
 (0)