Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp458802pxb; Fri, 29 Oct 2021 13:12:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6dzw5FKZJ6r4f9HwcMMK1cLr2fc0PU4/u8RZ5c05ul2IuDyIfm4XTM7HVQ9xj4VQIbDgY X-Received: by 2002:a05:6402:4308:: with SMTP id m8mr17579539edc.188.1635538328630; Fri, 29 Oct 2021 13:12:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635538328; cv=none; d=google.com; s=arc-20160816; b=xb2UhLZAfYu6s7apSj1qrEKb6JrKHlqAaH0CwJL+O8XSWrg3p9Gj+x+1IKdvo7jJDl Ztxa9OzTSDdqLga2BNHOYJJmlZW0DRn16pS5NJHt/nyF0c2wvebUkySUKizsbzLi6e+m WqJl3MHISeWqfIWC5HXIFZejePSGdhnNGgkR0NJBLg+ukZ7HqkiOOfy+Bh74Q0ynQmu1 4sn1wiCFp3n2hMGy6NEHkIiQEVa6MW+drg78YA+MuGR73/YFAOHYhIAB6/keZ/UrsHXq jKIwPOGbcyK0B0PC8MG9JdPplUpMc5kRSZ/+/nIDpX8SrYoa/UL7leHa6a1kjYqydLPl Eybg== 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 :message-id:date:subject:to:from:dkim-signature; bh=K0k945ZDTiOs/bEkGRtr+3DrVQXSvxSfxlEGtuQvfmY=; b=SyHVC303GXbNA6bP8j7v2BWlEyIiYX4sZJ251UavC/iJypydSbjWUtrazXLzDgbMy9 Z4Eh4ZDdzQ4EYyRAWLLqhhLbRJVA3e4LypVXnIpF3vCkNR3VlPyl8uALzOh2du468Vf4 4dHF06hKK7MrG6rl4HbOD6DsSN3/3UmD7AOnlrJSDlQ7W0OlC5Svd2H9FCcjOKpYX7nT zUqrwzgz/5iq5yybIRH90W6GMhGBS37oN4hN0ZFjvSOExmNKpNlCdsYxXdXTs0zVKOUK QUS1KgkXzPah3+plfZdpC+bVIu6JFVqWqtL3Po3Z0W8mvpEmH4/M3GDE6orxuAHrS5d2 SQuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=V1chCyeH; 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 k19si8211345ejv.36.2021.10.29.13.11.21; Fri, 29 Oct 2021 13:12:08 -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=V1chCyeH; 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 S229979AbhJ2UNs (ORCPT + 99 others); Fri, 29 Oct 2021 16:13:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:41150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbhJ2UNs (ORCPT ); Fri, 29 Oct 2021 16:13:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFF776101E for ; Fri, 29 Oct 2021 20:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635538279; bh=rl5sSDqPg28APT6gH5GVDrRhQz1w+QKO1pxW8T8Zmgc=; h=From:To:Subject:Date:From; b=V1chCyeHisQIO8eYKiOYHj5R/d48mLG/TSEsXlUmH1PE/NBIYw4Eiz50tsemGQtwN KOwlW7Om4omC7PwJH9yXQJ4AS1wibREL0Wzp/ImUNMtSk2GpC+HRcpA8nRZhzgr80M PMYFdx0CRHkgB2P+swQZt5JBLCqgGzR6yhAVI80dqzk5IzOLCawyH0+lncoKUxRHWW stH1FoSILQunnt2Dx2Jr+EwS8dv1JUnLJZfs6gUU5bTO2HIhqc3nCxzkY4uSn8rRtX CRW/JOIIkKGNmac2offS/On5FOn47xE+GlFX5N+TVJXnzWr9pBBWBiLNTv0bd99GZB an9qn+UlK4Wkg== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 1/4] SUNRPC: Fix races when closing the socket Date: Fri, 29 Oct 2021 16:04:18 -0400 Message-Id: <20211029200421.65090-1-trondmy@kernel.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Ensure that we bump the xprt->connect_cookie when we set the XPRT_CLOSE_WAIT flag so that another call to xprt_conditional_disconnect() won't race with the reconnection. Signed-off-by: Trond Myklebust --- net/sunrpc/xprt.c | 2 ++ net/sunrpc/xprtsock.c | 1 + 2 files changed, 3 insertions(+) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 48560188e84d..691fe5a682b6 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -735,6 +735,8 @@ static void xprt_autoclose(struct work_struct *work) unsigned int pflags = memalloc_nofs_save(); trace_xprt_disconnect_auto(xprt); + xprt->connect_cookie++; + smp_mb__before_atomic(); clear_bit(XPRT_CLOSE_WAIT, &xprt->state); xprt->ops->close(xprt); xprt_release_write(xprt, NULL); diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 04f1b78bcbca..b18d13479104 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -1134,6 +1134,7 @@ static void xs_run_error_worker(struct sock_xprt *transport, unsigned int nr) static void xs_sock_reset_connection_flags(struct rpc_xprt *xprt) { + xprt->connect_cookie++; smp_mb__before_atomic(); clear_bit(XPRT_CLOSE_WAIT, &xprt->state); clear_bit(XPRT_CLOSING, &xprt->state); -- 2.31.1