Commit 0e28f14f authored by David S. Miller's avatar David S. Miller

Make sock_writeable (used mostly by datagram

protocols) more reasonable.  Kill all references
to SOCK_MIN_WRITE_SPACE and kill its definition.
Replace with appropriate sock_writeable calls.
parent 44303b29
...@@ -750,16 +750,13 @@ static inline void sk_wake_async(struct sock *sk, int how, int band) ...@@ -750,16 +750,13 @@ static inline void sk_wake_async(struct sock *sk, int how, int band)
#define SOCK_MIN_SNDBUF 2048 #define SOCK_MIN_SNDBUF 2048
#define SOCK_MIN_RCVBUF 256 #define SOCK_MIN_RCVBUF 256
/* Must be less or equal SOCK_MIN_SNDBUF */
#define SOCK_MIN_WRITE_SPACE SOCK_MIN_SNDBUF
/* /*
* Default write policy as shown to user space via poll/select/SIGIO * Default write policy as shown to user space via poll/select/SIGIO
* Kernel internally doesn't use the MIN_WRITE_SPACE threshold.
*/ */
static inline int sock_writeable(struct sock *sk) static inline int sock_writeable(struct sock *sk)
{ {
return sock_wspace(sk) >= SOCK_MIN_WRITE_SPACE; return atomic_read(&sk->wmem_alloc) < (sk->sndbuf / 2);
} }
static inline int gfp_any(void) static inline int gfp_any(void)
......
...@@ -1700,7 +1700,7 @@ static unsigned int irda_poll(struct file * file, struct socket *sock, ...@@ -1700,7 +1700,7 @@ static unsigned int irda_poll(struct file * file, struct socket *sock,
if (sk->state == TCP_ESTABLISHED) { if (sk->state == TCP_ESTABLISHED) {
if ((self->tx_flow == FLOW_START) && if ((self->tx_flow == FLOW_START) &&
(sk->sndbuf - (int)atomic_read(&sk->wmem_alloc) >= SOCK_MIN_WRITE_SPACE)) sock_writeable(sk))
{ {
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
} }
...@@ -1708,13 +1708,13 @@ static unsigned int irda_poll(struct file * file, struct socket *sock, ...@@ -1708,13 +1708,13 @@ static unsigned int irda_poll(struct file * file, struct socket *sock,
break; break;
case SOCK_SEQPACKET: case SOCK_SEQPACKET:
if ((self->tx_flow == FLOW_START) && if ((self->tx_flow == FLOW_START) &&
(sk->sndbuf - (int)atomic_read(&sk->wmem_alloc) >= SOCK_MIN_WRITE_SPACE)) sock_writeable(sk))
{ {
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
} }
break; break;
case SOCK_DGRAM: case SOCK_DGRAM:
if (sk->sndbuf - (int)atomic_read(&sk->wmem_alloc) >= SOCK_MIN_WRITE_SPACE) if (sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND; mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
break; break;
default: default:
......
...@@ -67,9 +67,6 @@ ...@@ -67,9 +67,6 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
/* Following value should be > 32k + RPC overhead */
#define XPRT_MIN_WRITE_SPACE (35000 + SOCK_MIN_WRITE_SPACE)
extern spinlock_t rpc_queue_lock; extern spinlock_t rpc_queue_lock;
/* /*
...@@ -1099,9 +1096,8 @@ udp_write_space(struct sock *sk) ...@@ -1099,9 +1096,8 @@ udp_write_space(struct sock *sk)
if (xprt->shutdown) if (xprt->shutdown)
return; return;
/* Wait until we have enough socket memory. */
/* Wait until we have enough socket memory */ if (sock_writeable(sk))
if (sock_wspace(sk) < min_t(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
return; return;
if (!xprt_test_and_set_wspace(xprt)) { if (!xprt_test_and_set_wspace(xprt)) {
......
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