* [PATCH] libceph: queue_con only if the sock is connected
@ 2022-10-02 8:16 Chen Yuanrun
0 siblings, 0 replies; only message in thread
From: Chen Yuanrun @ 2022-10-02 8:16 UTC (permalink / raw)
To: Ilya Dryomov, Xiubo Li, Jeff Layton, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: ceph-devel, netdev, linux-kernel, Chen Yuanrun
tcp_sendmsg_locked will trigger sk->sk_write_space while the sock
is still connecting, if con try to write to a connecting sock,
sk->sk_write_space will be called again, which lead to a endless loop.
This will happen if the public network of the cluster is down, and
the cpu will be in high usage.
Signed-off-by: Chen Yuanrun <chen-yuanrun@foxmail.com>
---
net/ceph/messenger.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index d3bb656308b4..eef5d4dfd1f1 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -367,7 +367,8 @@ static void ceph_sock_write_space(struct sock *sk)
* buffer. See net/ipv4/tcp_input.c:tcp_check_space()
* and net/core/stream.c:sk_stream_write_space().
*/
- if (ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING)) {
+ if (ceph_con_flag_test(con, CEPH_CON_F_WRITE_PENDING) &&
+ atomic_read(&con->sock_state) == CON_SOCK_STATE_CONNECTED) {
if (sk_stream_is_writeable(sk)) {
dout("%s %p queueing write work\n", __func__, con);
clear_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
--
2.31.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-02 8:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 8:16 [PATCH] libceph: queue_con only if the sock is connected Chen Yuanrun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).