Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2115308ioo; Mon, 23 May 2022 10:22:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIQshXljz9V+lwmIL7UNFx6Y4Lv6bINOjPGSZHYDTc7tSAdqP9RyT+1okQO1imZ52Ba7wF X-Received: by 2002:a05:6a00:15c5:b0:518:9848:4915 with SMTP id o5-20020a056a0015c500b0051898484915mr7670669pfu.62.1653326565613; Mon, 23 May 2022 10:22:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653326565; cv=none; d=google.com; s=arc-20160816; b=cCp/cfbIfTKzoQnl0Aj6IPx01OOKC7Kiuwj58EiCIDui8thF1QuConGkg7x7U1ar8n CdvW1avhS971/wjMP/fQxuzp696RvDKla2S4NSXu2l7QVVPhWpoyy6XitJS/32tPvnlB +kBmajgvQAhtOkc/zbrIq4qcZnxyWLm9/D98YQkqBAoXmjlYbeHM9dILKMNvnaBiFhVj kqooJ8ju+58tddVOMJC8HnxCCQmY9cUtp5J6LmphSGJVP7sj+57yRzQNvujXp2zMae1B 9zE8fB0F6HuD+VcGITD1xOYqiuAwAak/M2R42c5Tqygxhdltf/huSRopWlU6o/+CkJgd pZkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N+MuP+9Yd99jGLJEoQ4M2LY1G5mO2YpAObKFgHEs4QI=; b=iFgXpYX8ewyyoAxmBXjoHHfbpum5VTRPhh6RBXm9DRUQL82evR1VbupUSsLyZt13yc lCepKPfSl4tz/mZ0kDsefEepfpGG6aEroqL7zmV+6mzmJxcnvmywnbzwBn5Wx2PGt8Vo 4pJkaT6gt40pvu1wtt2G4lSLQ/z8f8B5W05HVGe0VOBv7Oc8bXyGs+ryI57CBz7T5XDM Erle/CXlTEZ5T9Xavyi3EXW+k2anUhMmjE/trP/ydWlgWMynEAFlAvB+t2agis3Tx5eQ 41Lke3rgq9xG8O6lOOHrmmIO99by+i8cNShPFzIihJlhRHBX+p3g/EZk+GDYDmprS+59 0ddw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1Yrg43+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b33-20020a631b21000000b003f4e63b4685si6084036pgb.613.2022.05.23.10.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 10:22:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1Yrg43+C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E030531517; Mon, 23 May 2022 10:21:07 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240197AbiEWRSd (ORCPT + 99 others); Mon, 23 May 2022 13:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240166AbiEWRP3 (ORCPT ); Mon, 23 May 2022 13:15:29 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05FF062CE; Mon, 23 May 2022 10:12:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B4D12614CA; Mon, 23 May 2022 17:12:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6571C385A9; Mon, 23 May 2022 17:12:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325963; bh=iaOavnu9uVLIPR/Pfk/FPb5GyxAQ7s5vYCI00gmarEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1Yrg43+CiIjizx0a3kXSKPvqrxKSW2Lvk7PRNtECzXJyDlDM3wH8awXeNqumlvAYB JmdoAhAaGF5L9yNj6BrdsPzTyAL3B3+WG536gFlu97n1R8d0pWGShYn8CbvL5Uhok4 CTrc33KHD58cHDVlb6uVzpFBZENEoMeXyegpkivc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Trond Myklebust , Meena Shanmugam Subject: [PATCH 5.4 23/68] SUNRPC: Prevent immediate close+reconnect Date: Mon, 23 May 2022 19:04:50 +0200 Message-Id: <20220523165806.474707162@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Meena Shanmugam From: Trond Myklebust commit 3be232f11a3cc9b0ef0795e39fa11bdb8e422a06 upstream. If we have already set up the socket and are waiting for it to connect, then don't immediately close and retry. Signed-off-by: Trond Myklebust Signed-off-by: Meena Shanmugam Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/xprt.c | 3 ++- net/sunrpc/xprtsock.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -722,7 +722,8 @@ EXPORT_SYMBOL_GPL(xprt_disconnect_done); */ static void xprt_schedule_autoclose_locked(struct rpc_xprt *xprt) { - set_bit(XPRT_CLOSE_WAIT, &xprt->state); + if (test_and_set_bit(XPRT_CLOSE_WAIT, &xprt->state)) + return; if (test_and_set_bit(XPRT_LOCKED, &xprt->state) == 0) queue_work(xprtiod_workqueue, &xprt->task_cleanup); else if (xprt->snd_task && !test_bit(XPRT_SND_IS_COOKIE, &xprt->state)) --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2469,7 +2469,7 @@ static void xs_connect(struct rpc_xprt * WARN_ON_ONCE(!xprt_lock_connect(xprt, task, transport)); - if (transport->sock != NULL) { + if (transport->sock != NULL && !xprt_connecting(xprt)) { dprintk("RPC: xs_connect delayed xprt %p for %lu " "seconds\n", xprt, xprt->reestablish_timeout / HZ);