Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2834891pxb; Tue, 24 Aug 2021 08:39:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTCrJEwJK8fRKD0iBdE5Rc2S2PEV0ISu7Oke3UEE2MuxPMXAVBKaLLatOd3ZXUfhIvtKvh X-Received: by 2002:a17:906:3693:: with SMTP id a19mr42736644ejc.237.1629819593356; Tue, 24 Aug 2021 08:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629819593; cv=none; d=google.com; s=arc-20160816; b=geTGdSsRnPe8Z7eeiN3VroHdXRc0vTPAwYHW2pPOgibPBMRshBddoZtdqoSlyc6I0e TYSJXHG1sDY6VjvZnNFqzCbXPojZuvQTAUHJEPfUyw+1HJP6mhAJ2CuDJmCLbhK2JUgA 3mMeCAf+O6pZaQSj6Tsutu99ibMASLznUX+r52oK7DOGCzXQkIFcbc6EMpH8Fh3V3TeX 3vG5PHcccrhjUJKhWsuJ0WDX4HhyoJ5X0zHWw3iNf14zftXA8JwR6YDrLkKCMnxFLU/f 11Q21Xr8N1bYHuiO8GL6BE/j5pvedcHTMpkFbIuCuzJU8vGo/VzquJgbHhOBrdPzFNYt BX9A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lT92C5RrqsFdYXKMyLlE3ZhGtm7N4NdMWLXLvrThC1U=; b=yYphxZ7ArF9DLsTzpLoGzwqilIYcJRpT6/o8CgA69vM5nh4frCFnwz7oOfxmyXYOJI 5KqU6rMlkPd2AhrMa+GdV1v0U7/ZUKmPJAtjklLhYeqGs6wKKA08xW5ZTAUOtRWS/iR+ GBHZTqOuHhKoth23xVS1OqryvlT2QCTyDc60qMnlYhJdGhpr4QPs8VEOYqyDo7gR90Y7 gyUDIS+D93DoKUjOFFy8JC0ftDytqW8v5LkvO2jyiTIGavIAZY4bBJ5lXhkZt3R8mnov 7P/IJpaFQLHK8YL7OSzby2Zmt9ItnbvV/pVh/ZnB5pm6Lw9YDeMkecQnGc9bFbcKV8r4 KOwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LNZDD1bQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p26si19512682edu.78.2021.08.24.08.39.28; Tue, 24 Aug 2021 08:39:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LNZDD1bQ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238311AbhHXPjF (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit 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); } } -- 2.31.1