net: add sk_stream_is_writeable() helper
authorEric Dumazet <edumazet@google.com>
Tue, 23 Jul 2013 03:26:31 +0000 (20:26 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 25 Jul 2013 00:54:48 +0000 (17:54 -0700)
Several call sites use the hardcoded following condition :

sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)

Lets use a helper because TCP_NOTSENT_LOWAT support will change this
condition for TCP sockets.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Acked-by: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/sock.h
net/ceph/messenger.c
net/core/stream.c
net/dccp/proto.c
net/ipv4/tcp.c
net/sunrpc/svcsock.c
net/sunrpc/xprtsock.c

index e0473f61693f079b4c323b476c926d09763f940a..d0b5fdee50a23fe7f09700381bb1e5ff5b0d5bd6 100644 (file)
@@ -1088,6 +1088,10 @@ static inline struct cg_proto *parent_cg_proto(struct proto *proto,
 }
 #endif
 
+static inline bool sk_stream_is_writeable(const struct sock *sk)
+{
+       return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk);
+}
 
 static inline bool sk_has_memory_pressure(const struct sock *sk)
 {
index eb0a46a49bd42351d23878f118384ab09a8d2ee8..3be308e143026ac3d831e4aefc13faa198400d21 100644 (file)
@@ -409,7 +409,7 @@ static void ceph_sock_write_space(struct sock *sk)
         * and net/core/stream.c:sk_stream_write_space().
         */
        if (con_flag_test(con, CON_FLAG_WRITE_PENDING)) {
-               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+               if (sk_stream_is_writeable(sk)) {
                        dout("%s %p queueing write work\n", __func__, con);
                        clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
                        queue_con(con);
index f5df85dcd20bc7f790aec8f58967f55e02586444..512f0a24269b59cc45baa14c13e586b34fce9b60 100644 (file)
@@ -30,7 +30,7 @@ void sk_stream_write_space(struct sock *sk)
        struct socket *sock = sk->sk_socket;
        struct socket_wq *wq;
 
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock) {
+       if (sk_stream_is_writeable(sk) && sock) {
                clear_bit(SOCK_NOSPACE, &sock->flags);
 
                rcu_read_lock();
index 6c7c78b839403f7582c8fd9daef4cfe0e1e571a0..ba64750f038726a990caa71d90e45f77bad93230 100644 (file)
@@ -336,7 +336,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
                        mask |= POLLIN | POLLRDNORM;
 
                if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
-                       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+                       if (sk_stream_is_writeable(sk)) {
                                mask |= POLLOUT | POLLWRNORM;
                        } else {  /* send SIGIO later */
                                set_bit(SOCK_ASYNC_NOSPACE,
@@ -347,7 +347,7 @@ unsigned int dccp_poll(struct file *file, struct socket *sock,
                                 * wspace test but before the flags are set,
                                 * IO signal will be lost.
                                 */
-                               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+                               if (sk_stream_is_writeable(sk))
                                        mask |= POLLOUT | POLLWRNORM;
                        }
                }
index 5423223e93c25074f87c92dc60b338fddcb66f3f..5eca9060bb8e28a2ff935dcacbc7ba16daa6f33a 100644 (file)
@@ -499,7 +499,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
                        mask |= POLLIN | POLLRDNORM;
 
                if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
-                       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) {
+                       if (sk_stream_is_writeable(sk)) {
                                mask |= POLLOUT | POLLWRNORM;
                        } else {  /* send SIGIO later */
                                set_bit(SOCK_ASYNC_NOSPACE,
@@ -510,7 +510,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
                                 * wspace test but before the flags are set,
                                 * IO signal will be lost.
                                 */
-                               if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+                               if (sk_stream_is_writeable(sk))
                                        mask |= POLLOUT | POLLWRNORM;
                        }
                } else
index 305374d4fb985ec4942040447f91e8d8277ea10d..0da6785ec15a7474b318b6eff48f14c0f437b192 100644 (file)
@@ -442,7 +442,7 @@ static void svc_tcp_write_space(struct sock *sk)
 {
        struct socket *sock = sk->sk_socket;
 
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock)
+       if (sk_stream_is_writeable(sk) && sock)
                clear_bit(SOCK_NOSPACE, &sock->flags);
        svc_write_space(sk);
 }
index ddf0602603bdef4ac0a6ad29a9815bae56f04626..d6656d7768f4e689e94aca67189a0634bd950fad 100644 (file)
@@ -1602,7 +1602,7 @@ static void xs_tcp_write_space(struct sock *sk)
        read_lock_bh(&sk->sk_callback_lock);
 
        /* from net/core/stream.c:sk_stream_write_space */
-       if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk))
+       if (sk_stream_is_writeable(sk))
                xs_write_space(sk);
 
        read_unlock_bh(&sk->sk_callback_lock);