Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: add sk_stream_is_writeable() helper

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>

authored by

Eric Dumazet and committed by
David S. Miller
64dc6130 4d58c025

+12 -8
+4
include/net/sock.h
··· 1088 1088 } 1089 1089 #endif 1090 1090 1091 + static inline bool sk_stream_is_writeable(const struct sock *sk) 1092 + { 1093 + return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk); 1094 + } 1091 1095 1092 1096 static inline bool sk_has_memory_pressure(const struct sock *sk) 1093 1097 {
+1 -1
net/ceph/messenger.c
··· 409 409 * and net/core/stream.c:sk_stream_write_space(). 410 410 */ 411 411 if (con_flag_test(con, CON_FLAG_WRITE_PENDING)) { 412 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) { 412 + if (sk_stream_is_writeable(sk)) { 413 413 dout("%s %p queueing write work\n", __func__, con); 414 414 clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags); 415 415 queue_con(con);
+1 -1
net/core/stream.c
··· 30 30 struct socket *sock = sk->sk_socket; 31 31 struct socket_wq *wq; 32 32 33 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock) { 33 + if (sk_stream_is_writeable(sk) && sock) { 34 34 clear_bit(SOCK_NOSPACE, &sock->flags); 35 35 36 36 rcu_read_lock();
+2 -2
net/dccp/proto.c
··· 336 336 mask |= POLLIN | POLLRDNORM; 337 337 338 338 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { 339 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) { 339 + if (sk_stream_is_writeable(sk)) { 340 340 mask |= POLLOUT | POLLWRNORM; 341 341 } else { /* send SIGIO later */ 342 342 set_bit(SOCK_ASYNC_NOSPACE, ··· 347 347 * wspace test but before the flags are set, 348 348 * IO signal will be lost. 349 349 */ 350 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) 350 + if (sk_stream_is_writeable(sk)) 351 351 mask |= POLLOUT | POLLWRNORM; 352 352 } 353 353 }
+2 -2
net/ipv4/tcp.c
··· 499 499 mask |= POLLIN | POLLRDNORM; 500 500 501 501 if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { 502 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) { 502 + if (sk_stream_is_writeable(sk)) { 503 503 mask |= POLLOUT | POLLWRNORM; 504 504 } else { /* send SIGIO later */ 505 505 set_bit(SOCK_ASYNC_NOSPACE, ··· 510 510 * wspace test but before the flags are set, 511 511 * IO signal will be lost. 512 512 */ 513 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) 513 + if (sk_stream_is_writeable(sk)) 514 514 mask |= POLLOUT | POLLWRNORM; 515 515 } 516 516 } else
+1 -1
net/sunrpc/svcsock.c
··· 442 442 { 443 443 struct socket *sock = sk->sk_socket; 444 444 445 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && sock) 445 + if (sk_stream_is_writeable(sk) && sock) 446 446 clear_bit(SOCK_NOSPACE, &sock->flags); 447 447 svc_write_space(sk); 448 448 }
+1 -1
net/sunrpc/xprtsock.c
··· 1602 1602 read_lock_bh(&sk->sk_callback_lock); 1603 1603 1604 1604 /* from net/core/stream.c:sk_stream_write_space */ 1605 - if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) 1605 + if (sk_stream_is_writeable(sk)) 1606 1606 xs_write_space(sk); 1607 1607 1608 1608 read_unlock_bh(&sk->sk_callback_lock);