Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp16251pxp; Tue, 15 Mar 2022 22:18:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB7renKVOfN7+jKnuvbRxsSNbKpzkEpk7iUcicHy4+UNEXeuMDOp0FG7YY6mRazu5YeACC X-Received: by 2002:a05:6402:34d5:b0:416:2f46:48f with SMTP id w21-20020a05640234d500b004162f46048fmr28144558edc.88.1647407884166; Tue, 15 Mar 2022 22:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647407884; cv=none; d=google.com; s=arc-20160816; b=qSoXC0i1WoCczHiRiY1fKS7qDv40iQ0nZTGF1Rs2d2eRJgTm/VgNKi2mP6aixEMQhc L64AXlLuvwtqG08wgSIkrrNZagTN2JTlcRDSpQdeWGmyuulELMw9FuUhcm2C1UPW80LR ZlrdGwCf5lkQ1U0QQtQPEu7H2L2xP87IzcCANnjQW5AtVRzmBZ1/80lACYMXi2QbDDlY aen248fGRYwyh4vQBFR2keo/rfP/8zKMPrMuukfclcbhePFYiDZzkp/8/vjdVWB3cXb7 IE0oLaahC/ZRfFmy1EC1JXqMrMR/Ej86YYaf8tfMwdzcygh0geJ8QDZyG+4I6G7aMZgZ 98Qw== 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:to:from :dkim-signature; bh=np28gV6hDB/KMu0ws1V+f6NGSgzXOU7xeX8aMhs7YHI=; b=fdi+XY8LzMK/usW9YBDKX69dKbtVwkNjbaNjeFy7DvJpuRyJH1nEbns2narT/kNCUW noviMBPwZNn3NvM3Cqe2s8kLeSwQuF0/NZzOrtmIiZWtKzVuAYZaC8wF2/qsiGm8AO3r 06gtR6/qPUhQa50p+qMRfdz/DKaL01uWGXWR7/uXxTqYC/a0p83h4EOEz1gim3OzhWc/ eyDf44TWtxU7lgHIxAkDsUhSjnkUvGmGNiB93m8MlMwQL0CzxfB45HjAsasWs4HFXjS0 gJUlYaErn54nxsPeIzpwsBul+UOJ2fAYMnyn/yImP4aUTB32M2CM8ogYDVtvIgt2NhRY hiuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KLVPchho; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h2-20020a170906828200b006df6c3c8884si514828ejx.800.2022.03.15.22.17.28; Tue, 15 Mar 2022 22:18:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KLVPchho; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1350097AbiCOQfr (ORCPT + 99 others); Tue, 15 Mar 2022 12:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350103AbiCOQfp (ORCPT ); Tue, 15 Mar 2022 12:35:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D6A506C7 for ; Tue, 15 Mar 2022 09:34:32 -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 6D2DA614A0 for ; Tue, 15 Mar 2022 16:34:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB2B2C340EE for ; Tue, 15 Mar 2022 16:34:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647362071; bh=MvfmD2iZlw1bl+V53u2scs6Uj9onrM6h2zMsfrP90xk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KLVPchhojpl4jshBELGyDjcDx6tVw+hWjT6Yt7ba3jWmwSG7UVQzAzijA2Upt9Ys2 i5S+C/zycx/yClFoI5PMR3CakUEzLzw3yqITCaxaIn3Uv6JN2d/LcfnuOIReVAMAwC 2CWT2ksrsI/w+ZgUR+AIWxsR4E70SMTI+Pa+/ZTGcVDOVppr3Xt0LAE0rwAe+utUH7 RXN/+0Z+wlSBWllE8sn/a7n34R9X6evt0JkTrg7hqTOnM+mzyjzXoLPfmgekem3W7r 7JA1FAfosdOnTa3enPQnyRQx5fwlo5L5qjG5weoSTcGP+jC7UfIlPwbC8bc7RCfoVK w+VN3aXwoGRfw== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 2/3] SUNRPC: Replace internal use of SOCKWQ_ASYNC_NOSPACE Date: Tue, 15 Mar 2022 12:28:04 -0400 Message-Id: <20220315162805.570850-2-trondmy@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220315162805.570850-1-trondmy@kernel.org> References: <20220315162805.570850-1-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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-nfs@vger.kernel.org From: Trond Myklebust The socket's SOCKWQ_ASYNC_NOSPACE can be cleared by various actors in the socket layer, so replace it with our own flag in the transport sock_state field. Reported-by: Chuck Lever Signed-off-by: Trond Myklebust --- include/linux/sunrpc/xprtsock.h | 1 + net/sunrpc/xprtsock.c | 22 ++++------------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/linux/sunrpc/xprtsock.h b/include/linux/sunrpc/xprtsock.h index 8c2a712cb242..121162a95863 100644 --- a/include/linux/sunrpc/xprtsock.h +++ b/include/linux/sunrpc/xprtsock.h @@ -89,5 +89,6 @@ struct sock_xprt { #define XPRT_SOCK_WAKE_WRITE (5) #define XPRT_SOCK_WAKE_PENDING (6) #define XPRT_SOCK_WAKE_DISCONNECT (7) +#define XPRT_SOCK_NOSPACE (8) #endif /* _LINUX_SUNRPC_XPRTSOCK_H */ diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 786df8c0cda3..23cdb841f056 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -779,14 +779,8 @@ static int xs_nospace(struct rpc_rqst *req, struct sock_xprt *transport) /* Don't race with disconnect */ if (xprt_connected(xprt)) { - struct socket_wq *wq; - - rcu_read_lock(); - wq = rcu_dereference(sk->sk_wq); - set_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags); - rcu_read_unlock(); - /* wait for more buffer space */ + set_bit(XPRT_SOCK_NOSPACE, &transport->sock_state); set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); sk->sk_write_pending++; xprt_wait_for_buffer_space(xprt); @@ -1148,6 +1142,7 @@ static void xs_sock_reset_state_flags(struct rpc_xprt *xprt) clear_bit(XPRT_SOCK_WAKE_ERROR, &transport->sock_state); clear_bit(XPRT_SOCK_WAKE_WRITE, &transport->sock_state); clear_bit(XPRT_SOCK_WAKE_DISCONNECT, &transport->sock_state); + clear_bit(XPRT_SOCK_NOSPACE, &transport->sock_state); } static void xs_run_error_worker(struct sock_xprt *transport, unsigned int nr) @@ -1494,7 +1489,6 @@ static void xs_tcp_state_change(struct sock *sk) static void xs_write_space(struct sock *sk) { - struct socket_wq *wq; struct sock_xprt *transport; struct rpc_xprt *xprt; @@ -1505,15 +1499,10 @@ static void xs_write_space(struct sock *sk) if (unlikely(!(xprt = xprt_from_sock(sk)))) return; transport = container_of(xprt, struct sock_xprt, xprt); - rcu_read_lock(); - wq = rcu_dereference(sk->sk_wq); - if (!wq || test_and_clear_bit(SOCKWQ_ASYNC_NOSPACE, &wq->flags) == 0) - goto out; - + if (!test_and_clear_bit(XPRT_SOCK_NOSPACE, &transport->sock_state)) + return; xs_run_error_worker(transport, XPRT_SOCK_WAKE_WRITE); sk->sk_write_pending--; -out: - rcu_read_unlock(); } /** @@ -1854,7 +1843,6 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt, sk->sk_user_data = xprt; sk->sk_data_ready = xs_data_ready; sk->sk_write_space = xs_udp_write_space; - sock_set_flag(sk, SOCK_FASYNC); sk->sk_error_report = xs_error_report; xprt_clear_connected(xprt); @@ -2048,7 +2036,6 @@ static void xs_udp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) sk->sk_user_data = xprt; sk->sk_data_ready = xs_data_ready; sk->sk_write_space = xs_udp_write_space; - sock_set_flag(sk, SOCK_FASYNC); xprt_set_connected(xprt); @@ -2215,7 +2202,6 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) sk->sk_data_ready = xs_data_ready; sk->sk_state_change = xs_tcp_state_change; sk->sk_write_space = xs_tcp_write_space; - sock_set_flag(sk, SOCK_FASYNC); sk->sk_error_report = xs_error_report; /* socket options */ -- 2.35.1