aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c77
1 files changed, 13 insertions, 64 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 3b305ab17afe..87ce7e8bb8dc 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -75,7 +75,7 @@ static unsigned int xs_tcp_fin_timeout __read_mostly = XS_TCP_LINGER_TO;
75 * someone else's file names! 75 * someone else's file names!
76 */ 76 */
77 77
78#ifdef RPC_DEBUG 78#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
79 79
80static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE; 80static unsigned int min_slot_table_size = RPC_MIN_SLOT_TABLE;
81static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE; 81static unsigned int max_slot_table_size = RPC_MAX_SLOT_TABLE;
@@ -186,7 +186,7 @@ static struct ctl_table sunrpc_table[] = {
186 */ 186 */
187#define XS_IDLE_DISC_TO (5U * 60 * HZ) 187#define XS_IDLE_DISC_TO (5U * 60 * HZ)
188 188
189#ifdef RPC_DEBUG 189#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
190# undef RPC_DEBUG_DATA 190# undef RPC_DEBUG_DATA
191# define RPCDBG_FACILITY RPCDBG_TRANS 191# define RPCDBG_FACILITY RPCDBG_TRANS
192#endif 192#endif
@@ -216,65 +216,6 @@ static inline void xs_pktdump(char *msg, u32 *packet, unsigned int count)
216} 216}
217#endif 217#endif
218 218
219struct sock_xprt {
220 struct rpc_xprt xprt;
221
222 /*
223 * Network layer
224 */
225 struct socket * sock;
226 struct sock * inet;
227
228 /*
229 * State of TCP reply receive
230 */
231 __be32 tcp_fraghdr,
232 tcp_xid,
233 tcp_calldir;
234
235 u32 tcp_offset,
236 tcp_reclen;
237
238 unsigned long tcp_copied,
239 tcp_flags;
240
241 /*
242 * Connection of transports
243 */
244 struct delayed_work connect_worker;
245 struct sockaddr_storage srcaddr;
246 unsigned short srcport;
247
248 /*
249 * UDP socket buffer size parameters
250 */
251 size_t rcvsize,
252 sndsize;
253
254 /*
255 * Saved socket callback addresses
256 */
257 void (*old_data_ready)(struct sock *);
258 void (*old_state_change)(struct sock *);
259 void (*old_write_space)(struct sock *);
260 void (*old_error_report)(struct sock *);
261};
262
263/*
264 * TCP receive state flags
265 */
266#define TCP_RCV_LAST_FRAG (1UL << 0)
267#define TCP_RCV_COPY_FRAGHDR (1UL << 1)
268#define TCP_RCV_COPY_XID (1UL << 2)
269#define TCP_RCV_COPY_DATA (1UL << 3)
270#define TCP_RCV_READ_CALLDIR (1UL << 4)
271#define TCP_RCV_COPY_CALLDIR (1UL << 5)
272
273/*
274 * TCP RPC flags
275 */
276#define TCP_RPC_REPLY (1UL << 6)
277
278static inline struct rpc_xprt *xprt_from_sock(struct sock *sk) 219static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
279{ 220{
280 return (struct rpc_xprt *) sk->sk_user_data; 221 return (struct rpc_xprt *) sk->sk_user_data;
@@ -1415,6 +1356,7 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
1415 1356
1416 dprintk("RPC: xs_tcp_data_recv started\n"); 1357 dprintk("RPC: xs_tcp_data_recv started\n");
1417 do { 1358 do {
1359 trace_xs_tcp_data_recv(transport);
1418 /* Read in a new fragment marker if necessary */ 1360 /* Read in a new fragment marker if necessary */
1419 /* Can we ever really expect to get completely empty fragments? */ 1361 /* Can we ever really expect to get completely empty fragments? */
1420 if (transport->tcp_flags & TCP_RCV_COPY_FRAGHDR) { 1362 if (transport->tcp_flags & TCP_RCV_COPY_FRAGHDR) {
@@ -1439,6 +1381,7 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
1439 /* Skip over any trailing bytes on short reads */ 1381 /* Skip over any trailing bytes on short reads */
1440 xs_tcp_read_discard(transport, &desc); 1382 xs_tcp_read_discard(transport, &desc);
1441 } while (desc.count); 1383 } while (desc.count);
1384 trace_xs_tcp_data_recv(transport);
1442 dprintk("RPC: xs_tcp_data_recv done\n"); 1385 dprintk("RPC: xs_tcp_data_recv done\n");
1443 return len - desc.count; 1386 return len - desc.count;
1444} 1387}
@@ -1454,12 +1397,15 @@ static void xs_tcp_data_ready(struct sock *sk)
1454 struct rpc_xprt *xprt; 1397 struct rpc_xprt *xprt;
1455 read_descriptor_t rd_desc; 1398 read_descriptor_t rd_desc;
1456 int read; 1399 int read;
1400 unsigned long total = 0;
1457 1401
1458 dprintk("RPC: xs_tcp_data_ready...\n"); 1402 dprintk("RPC: xs_tcp_data_ready...\n");
1459 1403
1460 read_lock_bh(&sk->sk_callback_lock); 1404 read_lock_bh(&sk->sk_callback_lock);
1461 if (!(xprt = xprt_from_sock(sk))) 1405 if (!(xprt = xprt_from_sock(sk))) {
1406 read = 0;
1462 goto out; 1407 goto out;
1408 }
1463 /* Any data means we had a useful conversation, so 1409 /* Any data means we had a useful conversation, so
1464 * the we don't need to delay the next reconnect 1410 * the we don't need to delay the next reconnect
1465 */ 1411 */
@@ -1471,8 +1417,11 @@ static void xs_tcp_data_ready(struct sock *sk)
1471 do { 1417 do {
1472 rd_desc.count = 65536; 1418 rd_desc.count = 65536;
1473 read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv); 1419 read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
1420 if (read > 0)
1421 total += read;
1474 } while (read > 0); 1422 } while (read > 0);
1475out: 1423out:
1424 trace_xs_tcp_data_ready(xprt, read, total);
1476 read_unlock_bh(&sk->sk_callback_lock); 1425 read_unlock_bh(&sk->sk_callback_lock);
1477} 1426}
1478 1427
@@ -3042,7 +2991,7 @@ static struct xprt_class xs_bc_tcp_transport = {
3042 */ 2991 */
3043int init_socket_xprt(void) 2992int init_socket_xprt(void)
3044{ 2993{
3045#ifdef RPC_DEBUG 2994#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
3046 if (!sunrpc_table_header) 2995 if (!sunrpc_table_header)
3047 sunrpc_table_header = register_sysctl_table(sunrpc_table); 2996 sunrpc_table_header = register_sysctl_table(sunrpc_table);
3048#endif 2997#endif
@@ -3061,7 +3010,7 @@ int init_socket_xprt(void)
3061 */ 3010 */
3062void cleanup_socket_xprt(void) 3011void cleanup_socket_xprt(void)
3063{ 3012{
3064#ifdef RPC_DEBUG 3013#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
3065 if (sunrpc_table_header) { 3014 if (sunrpc_table_header) {
3066 unregister_sysctl_table(sunrpc_table_header); 3015 unregister_sysctl_table(sunrpc_table_header);
3067 sunrpc_table_header = NULL; 3016 sunrpc_table_header = NULL;