From patchwork Tue Aug 24 15:38:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 12455355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24CA4C432BE for ; Tue, 24 Aug 2021 15:38:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05BE061357 for ; Tue, 24 Aug 2021 15:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238311AbhHXPjF (ORCPT ); Tue, 24 Aug 2021 11:39:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:43778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234546AbhHXPjE (ORCPT ); Tue, 24 Aug 2021 11:39:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3081F60F21; Tue, 24 Aug 2021 15:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629819500; bh=SBAfLUjaYPT3+w+gakgXifkv2GwqKpwectilx5Pu7fI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LNZDD1bQtS7dAzsvQXIMKkgXWBE0khJ4MT4nUjYtv/+gXwnw5VgBZuWlzVW1jX9MY 3l/X0p/ueZ1S6HuZt92Lfdj0fLwg9OcR7RV/S3WAsOt2NAKiTQDzM2LU5CF6z6ywzb FGErgzTXIBc+mthlwWmg7+XJrVHrUTWFI70p133eyv+zprqsaN8ltnu5lyxvj6JuI2 yBBxF0JTRa1V3i6Hxol/8RM+Z4/Tixe4H2tSqKc6Ct3bhqmPYOq257TDNitFNOVeFa 19FJiTYTwJe2ve4zVwklUc3H/CNSrM6lnqoyivX5qi3V40kwMDloBVM3Bc7QxNXfmC x+Au31SfNoXrQ== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/2] SUNRPC: Tweak TCP socket shutdown in the RPC client Date: Tue, 24 Aug 2021 11:38:18 -0400 Message-Id: <20210824153818.322833-2-trondmy@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210824153818.322833-1-trondmy@kernel.org> References: <20210824153818.322833-1-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust We only really need to call shutdown() if we're in the ESTABLISHED TCP state, since that is the only case where the client is initiating a close of an established connection. If the socket is in FIN_WAIT1 or FIN_WAIT2, then we've already initiated socket shutdown and are waiting for the server's reply, so do nothing. In all other cases where we've already received a FIN from the server, we should be able to just close the socket. Signed-off-by: Trond Myklebust --- net/sunrpc/xprtsock.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 7e94f1d17edb..b91027d140df 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2104,12 +2104,15 @@ static void xs_tcp_shutdown(struct rpc_xprt *xprt) return; } switch (skst) { - default: + case TCP_FIN_WAIT1: + case TCP_FIN_WAIT2: + break; + case TCP_ESTABLISHED: + case TCP_CLOSE_WAIT: kernel_sock_shutdown(sock, SHUT_RDWR); trace_rpc_socket_shutdown(xprt, sock); break; - case TCP_CLOSE: - case TCP_TIME_WAIT: + default: xs_reset_transport(transport); } }