All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Yuanrun <chen-yuanrun@foxmail.com>
To: Ilya Dryomov <idryomov@gmail.com>, Xiubo Li <xiubli@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: ceph-devel@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Chen Yuanrun <chen-yuanrun@foxmail.com>
Subject: [PATCH] libceph: queue_con only if the sock is connected
Date: Sun, 2 Oct 2022 16:16:17 +0800	[thread overview]
Message-ID: <tencent_BC846D74CA86E95DAC48E65686FEE6359C07@qq.com> (raw)

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




                 reply	other threads:[~2022-10-02  8:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_BC846D74CA86E95DAC48E65686FEE6359C07@qq.com \
    --to=chen-yuanrun@foxmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.