Commit 9cd3e072 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: rename SOCK_ASYNC_NOSPACE and SOCK_ASYNC_WAITDATA

This patch is a cleanup to make following patch easier to
review.

Goal is to move SOCK_ASYNC_NOSPACE and SOCK_ASYNC_WAITDATA
from (struct socket)->flags to a (struct socket_wq)->flags
to benefit from RCU protection in sock_wake_async()

To ease backports, we rename both constants.

Two new helpers, sk_set_bit(int nr, struct sock *sk)
and sk_clear_bit(int net, struct sock *sk) are added so that
following patch can change their implementation.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5738a09d
...@@ -125,7 +125,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags) ...@@ -125,7 +125,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags)
if (flags & MSG_DONTWAIT) if (flags & MSG_DONTWAIT)
return -EAGAIN; return -EAGAIN;
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
...@@ -139,7 +139,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags) ...@@ -139,7 +139,7 @@ static int aead_wait_for_data(struct sock *sk, unsigned flags)
} }
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
return err; return err;
} }
......
...@@ -212,7 +212,7 @@ static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags) ...@@ -212,7 +212,7 @@ static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags)
if (flags & MSG_DONTWAIT) if (flags & MSG_DONTWAIT)
return -EAGAIN; return -EAGAIN;
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
...@@ -258,7 +258,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags) ...@@ -258,7 +258,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags)
return -EAGAIN; return -EAGAIN;
} }
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
for (;;) { for (;;) {
if (signal_pending(current)) if (signal_pending(current))
...@@ -272,7 +272,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags) ...@@ -272,7 +272,7 @@ static int skcipher_wait_for_data(struct sock *sk, unsigned flags)
} }
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
return err; return err;
} }
......
...@@ -498,7 +498,7 @@ static void macvtap_sock_write_space(struct sock *sk) ...@@ -498,7 +498,7 @@ static void macvtap_sock_write_space(struct sock *sk)
wait_queue_head_t *wqueue; wait_queue_head_t *wqueue;
if (!sock_writeable(sk) || if (!sock_writeable(sk) ||
!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags)) !test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags))
return; return;
wqueue = sk_sleep(sk); wqueue = sk_sleep(sk);
...@@ -585,7 +585,7 @@ static unsigned int macvtap_poll(struct file *file, poll_table * wait) ...@@ -585,7 +585,7 @@ static unsigned int macvtap_poll(struct file *file, poll_table * wait)
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
if (sock_writeable(&q->sk) || if (sock_writeable(&q->sk) ||
(!test_and_set_bit(SOCK_ASYNC_NOSPACE, &q->sock.flags) && (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &q->sock.flags) &&
sock_writeable(&q->sk))) sock_writeable(&q->sk)))
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
......
...@@ -1040,7 +1040,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table *wait) ...@@ -1040,7 +1040,7 @@ static unsigned int tun_chr_poll(struct file *file, poll_table *wait)
mask |= POLLIN | POLLRDNORM; mask |= POLLIN | POLLRDNORM;
if (sock_writeable(sk) || if (sock_writeable(sk) ||
(!test_and_set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags) && (!test_and_set_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags) &&
sock_writeable(sk))) sock_writeable(sk)))
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
...@@ -1488,7 +1488,7 @@ static void tun_sock_write_space(struct sock *sk) ...@@ -1488,7 +1488,7 @@ static void tun_sock_write_space(struct sock *sk)
if (!sock_writeable(sk)) if (!sock_writeable(sk))
return; return;
if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags)) if (!test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sk->sk_socket->flags))
return; return;
wqueue = sk_sleep(sk); wqueue = sk_sleep(sk);
......
...@@ -421,7 +421,7 @@ static void lowcomms_write_space(struct sock *sk) ...@@ -421,7 +421,7 @@ static void lowcomms_write_space(struct sock *sk)
if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) { if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) {
con->sock->sk->sk_write_pending--; con->sock->sk->sk_write_pending--;
clear_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags);
} }
if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags))
...@@ -1448,7 +1448,7 @@ static void send_to_sock(struct connection *con) ...@@ -1448,7 +1448,7 @@ static void send_to_sock(struct connection *con)
msg_flags); msg_flags);
if (ret == -EAGAIN || ret == 0) { if (ret == -EAGAIN || ret == 0) {
if (ret == -EAGAIN && if (ret == -EAGAIN &&
test_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags) && test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) &&
!test_and_set_bit(CF_APP_LIMITED, &con->flags)) { !test_and_set_bit(CF_APP_LIMITED, &con->flags)) {
/* Notify TCP that we're limited by the /* Notify TCP that we're limited by the
* application window size. * application window size.
......
...@@ -34,8 +34,8 @@ struct inode; ...@@ -34,8 +34,8 @@ struct inode;
struct file; struct file;
struct net; struct net;
#define SOCK_ASYNC_NOSPACE 0 #define SOCKWQ_ASYNC_NOSPACE 0
#define SOCK_ASYNC_WAITDATA 1 #define SOCKWQ_ASYNC_WAITDATA 1
#define SOCK_NOSPACE 2 #define SOCK_NOSPACE 2
#define SOCK_PASSCRED 3 #define SOCK_PASSCRED 3
#define SOCK_PASSSEC 4 #define SOCK_PASSSEC 4
...@@ -96,7 +96,7 @@ struct socket_wq { ...@@ -96,7 +96,7 @@ struct socket_wq {
* struct socket - general BSD socket * struct socket - general BSD socket
* @state: socket state (%SS_CONNECTED, etc) * @state: socket state (%SS_CONNECTED, etc)
* @type: socket type (%SOCK_STREAM, etc) * @type: socket type (%SOCK_STREAM, etc)
* @flags: socket flags (%SOCK_ASYNC_NOSPACE, etc) * @flags: socket flags (%SOCK_NOSPACE, etc)
* @ops: protocol specific socket operations * @ops: protocol specific socket operations
* @file: File back pointer for gc * @file: File back pointer for gc
* @sk: internal networking protocol agnostic socket representation * @sk: internal networking protocol agnostic socket representation
......
...@@ -2005,6 +2005,16 @@ static inline unsigned long sock_wspace(struct sock *sk) ...@@ -2005,6 +2005,16 @@ static inline unsigned long sock_wspace(struct sock *sk)
return amt; return amt;
} }
static inline void sk_set_bit(int nr, struct sock *sk)
{
set_bit(nr, &sk->sk_socket->flags);
}
static inline void sk_clear_bit(int nr, struct sock *sk)
{
clear_bit(nr, &sk->sk_socket->flags);
}
static inline void sk_wake_async(struct sock *sk, int how, int band) static inline void sk_wake_async(struct sock *sk, int how, int band)
{ {
if (sock_flag(sk, SOCK_FASYNC)) if (sock_flag(sk, SOCK_FASYNC))
......
...@@ -271,11 +271,11 @@ static long bt_sock_data_wait(struct sock *sk, long timeo) ...@@ -271,11 +271,11 @@ static long bt_sock_data_wait(struct sock *sk, long timeo)
if (signal_pending(current) || !timeo) if (signal_pending(current) || !timeo)
break; break;
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
release_sock(sk); release_sock(sk);
timeo = schedule_timeout(timeo); timeo = schedule_timeout(timeo);
lock_sock(sk); lock_sock(sk);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
} }
__set_current_state(TASK_RUNNING); __set_current_state(TASK_RUNNING);
...@@ -441,7 +441,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock, ...@@ -441,7 +441,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock,
if (!test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags) && sock_writeable(sk)) if (!test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags) && sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
return mask; return mask;
} }
......
...@@ -323,7 +323,7 @@ static long caif_stream_data_wait(struct sock *sk, long timeo) ...@@ -323,7 +323,7 @@ static long caif_stream_data_wait(struct sock *sk, long timeo)
!timeo) !timeo)
break; break;
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
release_sock(sk); release_sock(sk);
timeo = schedule_timeout(timeo); timeo = schedule_timeout(timeo);
lock_sock(sk); lock_sock(sk);
...@@ -331,7 +331,7 @@ static long caif_stream_data_wait(struct sock *sk, long timeo) ...@@ -331,7 +331,7 @@ static long caif_stream_data_wait(struct sock *sk, long timeo)
if (sock_flag(sk, SOCK_DEAD)) if (sock_flag(sk, SOCK_DEAD))
break; break;
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
} }
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
......
...@@ -785,7 +785,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock, ...@@ -785,7 +785,7 @@ unsigned int datagram_poll(struct file *file, struct socket *sock,
if (sock_writeable(sk)) if (sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
return mask; return mask;
} }
......
...@@ -1815,7 +1815,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo) ...@@ -1815,7 +1815,7 @@ static long sock_wait_for_wmem(struct sock *sk, long timeo)
{ {
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
for (;;) { for (;;) {
if (!timeo) if (!timeo)
break; break;
...@@ -1861,7 +1861,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len, ...@@ -1861,7 +1861,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
if (sk_wmem_alloc_get(sk) < sk->sk_sndbuf) if (sk_wmem_alloc_get(sk) < sk->sk_sndbuf)
break; break;
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
err = -EAGAIN; err = -EAGAIN;
if (!timeo) if (!timeo)
...@@ -2048,9 +2048,9 @@ int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb) ...@@ -2048,9 +2048,9 @@ int sk_wait_data(struct sock *sk, long *timeo, const struct sk_buff *skb)
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
rc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb); rc = sk_wait_event(sk, timeo, skb_peek_tail(&sk->sk_receive_queue) != skb);
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
return rc; return rc;
} }
......
...@@ -126,7 +126,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) ...@@ -126,7 +126,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
current_timeo = vm_wait = (prandom_u32() % (HZ / 5)) + 2; current_timeo = vm_wait = (prandom_u32() % (HZ / 5)) + 2;
while (1) { while (1) {
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
...@@ -139,7 +139,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) ...@@ -139,7 +139,7 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p)
} }
if (signal_pending(current)) if (signal_pending(current))
goto do_interrupted; goto do_interrupted;
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
if (sk_stream_memory_free(sk) && !vm_wait) if (sk_stream_memory_free(sk) && !vm_wait)
break; break;
......
...@@ -339,8 +339,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock, ...@@ -339,8 +339,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
if (sk_stream_is_writeable(sk)) { if (sk_stream_is_writeable(sk)) {
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} else { /* send SIGIO later */ } else { /* send SIGIO later */
set_bit(SOCK_ASYNC_NOSPACE, sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
&sk->sk_socket->flags);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
/* Race breaker. If space is freed after /* Race breaker. If space is freed after
......
...@@ -1747,9 +1747,9 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -1747,9 +1747,9 @@ static int dn_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
} }
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target)); sk_wait_event(sk, &timeo, dn_data_ready(sk, queue, flags, target));
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
} }
...@@ -2004,10 +2004,10 @@ static int dn_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) ...@@ -2004,10 +2004,10 @@ static int dn_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
} }
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
sk_wait_event(sk, &timeo, sk_wait_event(sk, &timeo,
!dn_queue_too_long(scp, queue, flags)); !dn_queue_too_long(scp, queue, flags));
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
continue; continue;
} }
......
...@@ -517,8 +517,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -517,8 +517,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (sk_stream_is_writeable(sk)) { if (sk_stream_is_writeable(sk)) {
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} else { /* send SIGIO later */ } else { /* send SIGIO later */
set_bit(SOCK_ASYNC_NOSPACE, sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
&sk->sk_socket->flags);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
/* Race breaker. If space is freed after /* Race breaker. If space is freed after
...@@ -906,7 +905,7 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset, ...@@ -906,7 +905,7 @@ static ssize_t do_tcp_sendpages(struct sock *sk, struct page *page, int offset,
goto out_err; goto out_err;
} }
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
mss_now = tcp_send_mss(sk, &size_goal, flags); mss_now = tcp_send_mss(sk, &size_goal, flags);
copied = 0; copied = 0;
...@@ -1134,7 +1133,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) ...@@ -1134,7 +1133,7 @@ int tcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
} }
/* This should be in poll */ /* This should be in poll */
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
mss_now = tcp_send_mss(sk, &size_goal, flags); mss_now = tcp_send_mss(sk, &size_goal, flags);
......
...@@ -1483,7 +1483,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock, ...@@ -1483,7 +1483,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
if (sock_writeable(sk) && iucv_below_msglim(sk)) if (sock_writeable(sk) && iucv_below_msglim(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
return mask; return mask;
} }
......
...@@ -572,7 +572,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock, ...@@ -572,7 +572,7 @@ static unsigned int llcp_sock_poll(struct file *file, struct socket *sock,
if (sock_writeable(sk) && sk->sk_state == LLCP_CONNECTED) if (sock_writeable(sk) && sk->sk_state == LLCP_CONNECTED)
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
pr_debug("mask 0x%x\n", mask); pr_debug("mask 0x%x\n", mask);
......
...@@ -531,7 +531,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx, ...@@ -531,7 +531,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT); timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
/* this should be in poll */ /* this should be in poll */
clear_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_NOSPACE, sk);
if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN)) if (sk->sk_err || (sk->sk_shutdown & SEND_SHUTDOWN))
return -EPIPE; return -EPIPE;
......
...@@ -6458,7 +6458,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -6458,7 +6458,7 @@ unsigned int sctp_poll(struct file *file, struct socket *sock, poll_table *wait)
if (sctp_writeable(sk)) { if (sctp_writeable(sk)) {
mask |= POLLOUT | POLLWRNORM; mask |= POLLOUT | POLLWRNORM;
} else { } else {
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
/* /*
* Since the socket is not locked, the buffer * Since the socket is not locked, the buffer
* might be made available after the writeable check and * might be made available after the writeable check and
......
...@@ -1072,11 +1072,11 @@ int sock_wake_async(struct socket *sock, int how, int band) ...@@ -1072,11 +1072,11 @@ int sock_wake_async(struct socket *sock, int how, int band)
} }
switch (how) { switch (how) {
case SOCK_WAKE_WAITD: case SOCK_WAKE_WAITD:
if (test_bit(SOCK_ASYNC_WAITDATA, &sock->flags)) if (test_bit(SOCKWQ_ASYNC_WAITDATA, &sock->flags))
break; break;
goto call_kill; goto call_kill;
case SOCK_WAKE_SPACE: case SOCK_WAKE_SPACE:
if (!test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags)) if (!test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sock->flags))
break; break;
/* fall through */ /* fall through */
case SOCK_WAKE_IO: case SOCK_WAKE_IO:
......
...@@ -398,7 +398,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen, ...@@ -398,7 +398,7 @@ static int xs_sendpages(struct socket *sock, struct sockaddr *addr, int addrlen,
if (unlikely(!sock)) if (unlikely(!sock))
return -ENOTSOCK; return -ENOTSOCK;
clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &sock->flags);
if (base != 0) { if (base != 0) {
addr = NULL; addr = NULL;
addrlen = 0; addrlen = 0;
...@@ -442,7 +442,7 @@ static void xs_nospace_callback(struct rpc_task *task) ...@@ -442,7 +442,7 @@ static void xs_nospace_callback(struct rpc_task *task)
struct sock_xprt *transport = container_of(task->tk_rqstp->rq_xprt, struct sock_xprt, xprt); struct sock_xprt *transport = container_of(task->tk_rqstp->rq_xprt, struct sock_xprt, xprt);
transport->inet->sk_write_pending--; transport->inet->sk_write_pending--;
clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags);
} }
/** /**
...@@ -467,7 +467,7 @@ static int xs_nospace(struct rpc_task *task) ...@@ -467,7 +467,7 @@ static int xs_nospace(struct rpc_task *task)
/* Don't race with disconnect */ /* Don't race with disconnect */
if (xprt_connected(xprt)) { if (xprt_connected(xprt)) {
if (test_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags)) { if (test_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags)) {
/* /*
* Notify TCP that we're limited by the application * Notify TCP that we're limited by the application
* window size * window size
...@@ -478,7 +478,7 @@ static int xs_nospace(struct rpc_task *task) ...@@ -478,7 +478,7 @@ static int xs_nospace(struct rpc_task *task)
xprt_wait_for_buffer_space(task, xs_nospace_callback); xprt_wait_for_buffer_space(task, xs_nospace_callback);
} }
} else { } else {
clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags);
ret = -ENOTCONN; ret = -ENOTCONN;
} }
...@@ -626,7 +626,7 @@ static int xs_udp_send_request(struct rpc_task *task) ...@@ -626,7 +626,7 @@ static int xs_udp_send_request(struct rpc_task *task)
case -EPERM: case -EPERM:
/* When the server has died, an ICMP port unreachable message /* When the server has died, an ICMP port unreachable message
* prompts ECONNREFUSED. */ * prompts ECONNREFUSED. */
clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags);
} }
return status; return status;
...@@ -715,7 +715,7 @@ static int xs_tcp_send_request(struct rpc_task *task) ...@@ -715,7 +715,7 @@ static int xs_tcp_send_request(struct rpc_task *task)
case -EADDRINUSE: case -EADDRINUSE:
case -ENOBUFS: case -ENOBUFS:
case -EPIPE: case -EPIPE:
clear_bit(SOCK_ASYNC_NOSPACE, &transport->sock->flags); clear_bit(SOCKWQ_ASYNC_NOSPACE, &transport->sock->flags);
} }
return status; return status;
...@@ -1618,7 +1618,7 @@ static void xs_write_space(struct sock *sk) ...@@ -1618,7 +1618,7 @@ static void xs_write_space(struct sock *sk)
if (unlikely(!(xprt = xprt_from_sock(sk)))) if (unlikely(!(xprt = xprt_from_sock(sk))))
return; return;
if (test_and_clear_bit(SOCK_ASYNC_NOSPACE, &sock->flags) == 0) if (test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &sock->flags) == 0)
return; return;
xprt_write_space(xprt); xprt_write_space(xprt);
......
...@@ -2191,7 +2191,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo, ...@@ -2191,7 +2191,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo,
!timeo) !timeo)
break; break;
set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
unix_state_unlock(sk); unix_state_unlock(sk);
timeo = freezable_schedule_timeout(timeo); timeo = freezable_schedule_timeout(timeo);
unix_state_lock(sk); unix_state_lock(sk);
...@@ -2199,7 +2199,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo, ...@@ -2199,7 +2199,7 @@ static long unix_stream_data_wait(struct sock *sk, long timeo,
if (sock_flag(sk, SOCK_DEAD)) if (sock_flag(sk, SOCK_DEAD))
break; break;
clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
} }
finish_wait(sk_sleep(sk), &wait); finish_wait(sk_sleep(sk), &wait);
...@@ -2683,7 +2683,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock, ...@@ -2683,7 +2683,7 @@ static unsigned int unix_dgram_poll(struct file *file, struct socket *sock,
if (writable) if (writable)
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
else else
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
return mask; return mask;
} }
......
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