Commit 66d7a56a authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Refactor TCP receive

Move the TCP data receive loop out of xs_tcp_data_ready(). Doing so
will allow us to move the data receive out of the softirq context in
a set of followup patches.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent c6fa8e6d
...@@ -1391,6 +1391,30 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns ...@@ -1391,6 +1391,30 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
return len - desc.count; return len - desc.count;
} }
static void xs_tcp_data_receive(struct sock_xprt *transport)
{
struct rpc_xprt *xprt = &transport->xprt;
struct sock *sk;
read_descriptor_t rd_desc = {
.count = 2*1024*1024,
.arg.data = xprt,
};
unsigned long total = 0;
int read = 0;
sk = transport->inet;
/* We use rd_desc to pass struct xprt to xs_tcp_data_recv */
for (;;) {
read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
if (read <= 0)
break;
total += read;
rd_desc.count = 65536;
}
trace_xs_tcp_data_ready(xprt, read, total);
}
/** /**
* xs_tcp_data_ready - "data ready" callback for TCP sockets * xs_tcp_data_ready - "data ready" callback for TCP sockets
* @sk: socket with data to read * @sk: socket with data to read
...@@ -1398,34 +1422,24 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns ...@@ -1398,34 +1422,24 @@ static int xs_tcp_data_recv(read_descriptor_t *rd_desc, struct sk_buff *skb, uns
*/ */
static void xs_tcp_data_ready(struct sock *sk) static void xs_tcp_data_ready(struct sock *sk)
{ {
struct sock_xprt *transport;
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
read_descriptor_t rd_desc;
int read;
unsigned long total = 0;
dprintk("RPC: xs_tcp_data_ready...\n"); dprintk("RPC: xs_tcp_data_ready...\n");
read_lock_bh(&sk->sk_callback_lock); read_lock_bh(&sk->sk_callback_lock);
if (!(xprt = xprt_from_sock(sk))) { if (!(xprt = xprt_from_sock(sk)))
read = 0;
goto out; goto out;
} transport = container_of(xprt, struct sock_xprt, xprt);
/* Any data means we had a useful conversation, so /* Any data means we had a useful conversation, so
* the we don't need to delay the next reconnect * the we don't need to delay the next reconnect
*/ */
if (xprt->reestablish_timeout) if (xprt->reestablish_timeout)
xprt->reestablish_timeout = 0; xprt->reestablish_timeout = 0;
/* We use rd_desc to pass struct xprt to xs_tcp_data_recv */ xs_tcp_data_receive(transport);
rd_desc.arg.data = xprt;
do {
rd_desc.count = 65536;
read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv);
if (read > 0)
total += read;
} while (read > 0);
out: out:
trace_xs_tcp_data_ready(xprt, read, total);
read_unlock_bh(&sk->sk_callback_lock); read_unlock_bh(&sk->sk_callback_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment