mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-14 09:09:56 +00:00
SUNRPC: Move AF_LOCAL receive data path into a workqueue context
Now that we've done it for TCP and UDP, let's convert AF_LOCAL as well. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
parent
f9b2ee714c
commit
a26480942c
@ -909,44 +909,36 @@ static int xs_local_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xs_local_data_ready - "data ready" callback for AF_LOCAL sockets
|
* xs_local_data_read_skb
|
||||||
* @sk: socket with data to read
|
* @xprt: transport
|
||||||
|
* @sk: socket
|
||||||
|
* @skb: skbuff
|
||||||
*
|
*
|
||||||
* Currently this assumes we can read the whole reply in a single gulp.
|
* Currently this assumes we can read the whole reply in a single gulp.
|
||||||
*/
|
*/
|
||||||
static void xs_local_data_ready(struct sock *sk)
|
static void xs_local_data_read_skb(struct rpc_xprt *xprt,
|
||||||
|
struct sock *sk,
|
||||||
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
struct rpc_task *task;
|
struct rpc_task *task;
|
||||||
struct rpc_xprt *xprt;
|
|
||||||
struct rpc_rqst *rovr;
|
struct rpc_rqst *rovr;
|
||||||
struct sk_buff *skb;
|
int repsize, copied;
|
||||||
int err, repsize, copied;
|
|
||||||
u32 _xid;
|
u32 _xid;
|
||||||
__be32 *xp;
|
__be32 *xp;
|
||||||
|
|
||||||
read_lock_bh(&sk->sk_callback_lock);
|
|
||||||
dprintk("RPC: %s...\n", __func__);
|
|
||||||
xprt = xprt_from_sock(sk);
|
|
||||||
if (xprt == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
skb = skb_recv_datagram(sk, 0, 1, &err);
|
|
||||||
if (skb == NULL)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
repsize = skb->len - sizeof(rpc_fraghdr);
|
repsize = skb->len - sizeof(rpc_fraghdr);
|
||||||
if (repsize < 4) {
|
if (repsize < 4) {
|
||||||
dprintk("RPC: impossible RPC reply size %d\n", repsize);
|
dprintk("RPC: impossible RPC reply size %d\n", repsize);
|
||||||
goto dropit;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the XID from the skb... */
|
/* Copy the XID from the skb... */
|
||||||
xp = skb_header_pointer(skb, sizeof(rpc_fraghdr), sizeof(_xid), &_xid);
|
xp = skb_header_pointer(skb, sizeof(rpc_fraghdr), sizeof(_xid), &_xid);
|
||||||
if (xp == NULL)
|
if (xp == NULL)
|
||||||
goto dropit;
|
return;
|
||||||
|
|
||||||
/* Look up and lock the request corresponding to the given XID */
|
/* Look up and lock the request corresponding to the given XID */
|
||||||
spin_lock(&xprt->transport_lock);
|
spin_lock_bh(&xprt->transport_lock);
|
||||||
rovr = xprt_lookup_rqst(xprt, *xp);
|
rovr = xprt_lookup_rqst(xprt, *xp);
|
||||||
if (!rovr)
|
if (!rovr)
|
||||||
goto out_unlock;
|
goto out_unlock;
|
||||||
@ -964,11 +956,35 @@ static void xs_local_data_ready(struct sock *sk)
|
|||||||
xprt_complete_rqst(task, copied);
|
xprt_complete_rqst(task, copied);
|
||||||
|
|
||||||
out_unlock:
|
out_unlock:
|
||||||
spin_unlock(&xprt->transport_lock);
|
spin_unlock_bh(&xprt->transport_lock);
|
||||||
dropit:
|
}
|
||||||
skb_free_datagram(sk, skb);
|
|
||||||
out:
|
static void xs_local_data_receive(struct sock_xprt *transport)
|
||||||
read_unlock_bh(&sk->sk_callback_lock);
|
{
|
||||||
|
struct sk_buff *skb;
|
||||||
|
struct sock *sk;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
mutex_lock(&transport->recv_mutex);
|
||||||
|
sk = transport->inet;
|
||||||
|
if (sk == NULL)
|
||||||
|
goto out;
|
||||||
|
for (;;) {
|
||||||
|
skb = skb_recv_datagram(sk, 0, 1, &err);
|
||||||
|
if (skb == NULL)
|
||||||
|
break;
|
||||||
|
xs_local_data_read_skb(&transport->xprt, sk, skb);
|
||||||
|
skb_free_datagram(sk, skb);
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
mutex_unlock(&transport->recv_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xs_local_data_receive_workfn(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct sock_xprt *transport =
|
||||||
|
container_of(work, struct sock_xprt, recv_worker);
|
||||||
|
xs_local_data_receive(transport);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1895,10 +1911,6 @@ static inline void xs_reclassify_socket(int family, struct socket *sock)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void xs_dummy_data_receive_workfn(struct work_struct *work)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
static void xs_dummy_setup_socket(struct work_struct *work)
|
static void xs_dummy_setup_socket(struct work_struct *work)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -1946,7 +1958,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
|
|||||||
xs_save_old_callbacks(transport, sk);
|
xs_save_old_callbacks(transport, sk);
|
||||||
|
|
||||||
sk->sk_user_data = xprt;
|
sk->sk_user_data = xprt;
|
||||||
sk->sk_data_ready = xs_local_data_ready;
|
sk->sk_data_ready = xs_data_ready;
|
||||||
sk->sk_write_space = xs_udp_write_space;
|
sk->sk_write_space = xs_udp_write_space;
|
||||||
sk->sk_error_report = xs_error_report;
|
sk->sk_error_report = xs_error_report;
|
||||||
sk->sk_allocation = GFP_NOIO;
|
sk->sk_allocation = GFP_NOIO;
|
||||||
@ -2777,7 +2789,7 @@ static struct rpc_xprt *xs_setup_local(struct xprt_create *args)
|
|||||||
xprt->ops = &xs_local_ops;
|
xprt->ops = &xs_local_ops;
|
||||||
xprt->timeout = &xs_local_default_timeout;
|
xprt->timeout = &xs_local_default_timeout;
|
||||||
|
|
||||||
INIT_WORK(&transport->recv_worker, xs_dummy_data_receive_workfn);
|
INIT_WORK(&transport->recv_worker, xs_local_data_receive_workfn);
|
||||||
INIT_DELAYED_WORK(&transport->connect_worker,
|
INIT_DELAYED_WORK(&transport->connect_worker,
|
||||||
xs_dummy_setup_socket);
|
xs_dummy_setup_socket);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user