From patchwork Sun Oct 2 08:16:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chen Yuanrun X-Patchwork-Id: 611783 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B365EC43217 for ; Sun, 2 Oct 2022 08:17:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbiJBIRo (ORCPT ); Sun, 2 Oct 2022 04:17:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229763AbiJBIRi (ORCPT ); Sun, 2 Oct 2022 04:17:38 -0400 X-Greylist: delayed 70 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 02 Oct 2022 01:17:34 PDT Received: from out203-205-221-239.mail.qq.com (out203-205-221-239.mail.qq.com [203.205.221.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E5AC3F1E6; Sun, 2 Oct 2022 01:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1664698651; bh=CScWYLEqhDwTIVrXOlh5cMj8TjSjE5p3uKPDNBlDjK8=; h=Date:From:Subject:To:Cc; b=IboCD5lPqZzL5G97Y3fc0KodNKhWK+JUdAD8PKQM9qhWwKk9vxUm2GF1wRaV+gVAJ qVvugQlJIRncCm34WLcidT1l7pY0m/WVWBI48Fxo67XMtnQKV268sDNSgjZrur8j6R pEbkZEjiiHXgL0bLbOORIRcDhjcmBR7qMJwbULkk= Received: from [10.30.0.92] ([211.137.109.91]) by newxmesmtplogicsvrsza7.qq.com (NewEsmtp) with SMTP id 41185641; Sun, 02 Oct 2022 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uT1zKsLun1YoJTkun3+Wi/NlK7l65Lh5p zgXwjbuQ== X-OQ-MSGID: <6c65cfea-1fcf-9d41-b905-12305c6c3458@foxmail.com> Date: Sun, 2 Oct 2022 16:16:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.0.3 From: Chen Yuanrun Subject: [PATCH] libceph: queue_con only if the sock is connected To: Ilya Dryomov , Xiubo Li , Jeff Layton , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Content-Language: en-US Cc: ceph-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Yuanrun Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org 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 ---  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);