#define SOCK_MIN_SNDBUF 2048
#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
- * Kernel internally doesn't use the MIN_WRITE_SPACE threshold.
*/
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)
if (sk->state == TCP_ESTABLISHED) {
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;
}
break;
case SOCK_SEQPACKET:
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;
}
break;
case SOCK_DGRAM:
- if (sk->sndbuf - (int)atomic_read(&sk->wmem_alloc) >= SOCK_MIN_WRITE_SPACE)
+ if (sock_writeable(sk))
mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
break;
default:
#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;
/*
if (xprt->shutdown)
return;
-
- /* Wait until we have enough socket memory */
- if (sock_wspace(sk) < min_t(int, sk->sndbuf,XPRT_MIN_WRITE_SPACE))
+ /* Wait until we have enough socket memory. */
+ if (sock_writeable(sk))
return;
if (!xprt_test_and_set_wspace(xprt)) {