From patchwork Sat Aug 19 21:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13358683 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B381EE49AC for ; Sun, 20 Aug 2023 00:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229580AbjHTAWQ (ORCPT ); Sat, 19 Aug 2023 20:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229878AbjHTAVk (ORCPT ); Sat, 19 Aug 2023 20:21:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96847E28CA for ; Sat, 19 Aug 2023 14:39:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3169461901 for ; Sat, 19 Aug 2023 21:39:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F9B8C433C8; Sat, 19 Aug 2023 21:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692481153; bh=8eHIRLLWEITf8NqTQbRpZXk03/aWt1++l3diAXcUgP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n5nWhf2eNIMAmpHjSupxxBuXK1jZvCo9TNw1XNjEsOzQ5YRWqpW5uZuiseDwzJC2t 132MY/tx+NH9iA/KCHYvnRMN+eiyUuGds/9vUVjGjtb9z0OmV0wzQxAV0gh3Is1hU2 4ADl5xZ+iqbaV/2MBRXAE9m7RDPrPOK/KJd8BdtZEVY3LQgx38tRnI5oUXkK7myH6W USIIu6X0GUh6bz7D7wXVC2a8WTqFHXnewZeNMxNR4hstC6eZU80S1dRvm63DBFOgi3 oTIwxxefu0UJP1pB+il++HCJqbyc8ShCafjjXvdWhhYa3k3j2vjsO4IThDq0Jk02// 0KdsCyttjWGhA== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/5] SUNRPC: Set the TCP_SYNCNT to match the socket timeout Date: Sat, 19 Aug 2023 17:32:21 -0400 Message-ID: <20230819213225.731214-2-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819213225.731214-1-trondmy@kernel.org> References: <20230819213225.731214-1-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Set the TCP SYN count so that we abort the connection attempt at around the expected timeout value. Signed-off-by: Trond Myklebust --- net/sunrpc/xprtsock.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 9f010369100a..47d0b6a8c32e 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2230,9 +2230,13 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt, struct socket *sock) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); + struct net *net = sock_net(sock->sk); + unsigned long connect_timeout; + unsigned long syn_retries; unsigned int keepidle; unsigned int keepcnt; unsigned int timeo; + unsigned long t; spin_lock(&xprt->transport_lock); keepidle = DIV_ROUND_UP(xprt->timeout->to_initval, HZ); @@ -2250,6 +2254,16 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt, /* TCP user timeout (see RFC5482) */ tcp_sock_set_user_timeout(sock->sk, timeo); + + /* Connect timeout */ + connect_timeout = max_t(unsigned long, + DIV_ROUND_UP(xprt->connect_timeout, HZ), 1); + syn_retries = max_t(unsigned long, + READ_ONCE(net->ipv4.sysctl_tcp_syn_retries), 1); + for (t = 0; t <= syn_retries && (1UL << t) < connect_timeout; t++) + ; + if (t <= syn_retries) + tcp_sock_set_syncnt(sock->sk, t - 1); } static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, From patchwork Sat Aug 19 21:32:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13358682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BDD7EE49AD for ; Sun, 20 Aug 2023 00:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229559AbjHTAWP (ORCPT ); Sat, 19 Aug 2023 20:22:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbjHTAVk (ORCPT ); Sat, 19 Aug 2023 20:21:40 -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 42CE0E28F5 for ; Sat, 19 Aug 2023 14:39:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C93C4619E0 for ; Sat, 19 Aug 2023 21:39:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE240C433C7; Sat, 19 Aug 2023 21:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692481154; bh=s8z4CSMnk0bp6fS9JenTXfCYBKPawhJCOW+NdDsvPYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPzu6sDvg7zf7QFkGtrAyOma8OW8YpU/WLSxfrglIyaV0DAZw7/e+qwXYeJOqzrHF mMKL/OylobQmjJ2xdNI2VbVHSNZagjUupRRzS7VQBQzrvsiHHjx0Qyn07iyA8yXkZX 49s4Hqr/SDPIO1Os16rg38nHiRsQO/YFB+RplWSlmX6TDnLTV8HbPddRP6ZSQpbJ0f o2oOree8NYkrqyoAvFO4NaSZLjjLqxX+kA9v4tymeW7me68MS3iCYtF1ln22qSZz3z hL/7evAKAhs2vd/e4Q/mPXAIzAQQqqjRkT4UKPsGGF74l6U5+n7610TbL2oQky4NK4 cKC1INVi7oW0g== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/5] SUNRPC: Refactor and simplify connect timeout Date: Sat, 19 Aug 2023 17:32:22 -0400 Message-ID: <20230819213225.731214-3-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819213225.731214-2-trondmy@kernel.org> References: <20230819213225.731214-1-trondmy@kernel.org> <20230819213225.731214-2-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Instead of requiring the requests to redrive the connection several times, just let the TCP connect code manage it now that we've adjusted the TCP_SYNCNT value. Signed-off-by: Trond Myklebust --- net/sunrpc/xprtsock.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 47d0b6a8c32e..e558f0024fe5 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2266,6 +2266,25 @@ static void xs_tcp_set_socket_timeouts(struct rpc_xprt *xprt, tcp_sock_set_syncnt(sock->sk, t - 1); } +static void xs_tcp_do_set_connect_timeout(struct rpc_xprt *xprt, + unsigned long connect_timeout) +{ + struct sock_xprt *transport = + container_of(xprt, struct sock_xprt, xprt); + struct rpc_timeout to; + unsigned long initval; + + memcpy(&to, xprt->timeout, sizeof(to)); + /* Arbitrary lower limit */ + initval = max_t(unsigned long, connect_timeout, XS_TCP_INIT_REEST_TO); + to.to_initval = initval; + to.to_maxval = initval; + to.to_retries = 0; + memcpy(&transport->tcp_timeout, &to, sizeof(transport->tcp_timeout)); + xprt->timeout = &transport->tcp_timeout; + xprt->connect_timeout = connect_timeout; +} + static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, unsigned long connect_timeout, unsigned long reconnect_timeout) @@ -2277,19 +2296,8 @@ static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, spin_lock(&xprt->transport_lock); if (reconnect_timeout < xprt->max_reconnect_timeout) xprt->max_reconnect_timeout = reconnect_timeout; - if (connect_timeout < xprt->connect_timeout) { - memcpy(&to, xprt->timeout, sizeof(to)); - initval = DIV_ROUND_UP(connect_timeout, to.to_retries + 1); - /* Arbitrary lower limit */ - if (initval < XS_TCP_INIT_REEST_TO << 1) - initval = XS_TCP_INIT_REEST_TO << 1; - to.to_initval = initval; - to.to_maxval = initval; - memcpy(&transport->tcp_timeout, &to, - sizeof(transport->tcp_timeout)); - xprt->timeout = &transport->tcp_timeout; - xprt->connect_timeout = connect_timeout; - } + if (connect_timeout < xprt->connect_timeout) + xs_tcp_do_set_connect_timeout(xprt, connect_timeout); set_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state); spin_unlock(&xprt->transport_lock); } From patchwork Sat Aug 19 21:32:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13358672 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDEDEEE49A6 for ; Sun, 20 Aug 2023 00:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229487AbjHTATD (ORCPT ); Sat, 19 Aug 2023 20:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbjHTASj (ORCPT ); Sat, 19 Aug 2023 20:18:39 -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 DE489E28F7 for ; Sat, 19 Aug 2023 14:39:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7573E60AB9 for ; Sat, 19 Aug 2023 21:39:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7AEDFC433C8; Sat, 19 Aug 2023 21:39:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692481154; bh=yLnfJs0YfhcZXlPCWYoc0+cFQb1558aLBHuxwac0FYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERRHlnygm44ACBkx6QvJxmYvw4oecGtf5BUD9xIf70ObQshn6DdwpkuJlgmxG1F+1 qZ84bOUdItJ8YWifiHiIp6iEnNksqHqxWBqQVnWvzOEI7riJZuPilzIXvo7IrPq0lg /WTR/kYveCv/RbFSadntolHU+gagZiaq0OdJTu2iSuI2l1/8yRnsSgUTNk0A/QNAS0 LCtXtSrHEGI9A5yBTL4Mtzle9qjNkiVU8ok6PpNAO7JAkhusl0BpV6cmWLGk4Kje37 mwWoV0qOdng9fLIZ48Ve/98JQ+pClPGv5YdLh5iyEqjgQ3p1rA4ab2FotsSJGWS1jS hZw8zsMfkOd/A== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/5] SUNRPC: Allow specification of TCP client connect timeout at setup Date: Sat, 19 Aug 2023 17:32:23 -0400 Message-ID: <20230819213225.731214-4-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819213225.731214-3-trondmy@kernel.org> References: <20230819213225.731214-1-trondmy@kernel.org> <20230819213225.731214-2-trondmy@kernel.org> <20230819213225.731214-3-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust When we create a TCP transport, the connect timeout parameters are currently fixed to be 90s. This is problematic in the pNFS flexfiles case, where we may have multiple mirrors, and we would like to fail over quickly to the next mirror if a data server is down. This patch adds the ability to specify the connection parameters at RPC client creation time. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/clnt.h | 2 ++ include/linux/sunrpc/xprt.h | 2 ++ net/sunrpc/clnt.c | 2 ++ net/sunrpc/xprtsock.c | 7 +++++-- 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 4f41d839face..af7358277f1c 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -148,6 +148,8 @@ struct rpc_create_args { const struct cred *cred; unsigned int max_connect; struct xprtsec_parms xprtsec; + unsigned long connect_timeout; + unsigned long reconnect_timeout; }; struct rpc_add_xprt_test { diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index b52411bcfe4e..4ecc89301eb7 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -351,6 +351,8 @@ struct xprt_create { struct rpc_xprt_switch *bc_xps; unsigned int flags; struct xprtsec_parms xprtsec; + unsigned long connect_timeout; + unsigned long reconnect_timeout; }; struct xprt_class { diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index d7c697af3762..9edebfdb5ce1 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -534,6 +534,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) .servername = args->servername, .bc_xprt = args->bc_xprt, .xprtsec = args->xprtsec, + .connect_timeout = args->connect_timeout, + .reconnect_timeout = args->reconnect_timeout, }; char servername[48]; struct rpc_clnt *clnt; diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index e558f0024fe5..6e845e51cbf3 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -2290,8 +2290,6 @@ static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, unsigned long reconnect_timeout) { struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); - struct rpc_timeout to; - unsigned long initval; spin_lock(&xprt->transport_lock); if (reconnect_timeout < xprt->max_reconnect_timeout) @@ -3350,8 +3348,13 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) xprt->timeout = &xs_tcp_default_timeout; xprt->max_reconnect_timeout = xprt->timeout->to_maxval; + if (args->reconnect_timeout) + xprt->max_reconnect_timeout = args->reconnect_timeout; + xprt->connect_timeout = xprt->timeout->to_initval * (xprt->timeout->to_retries + 1); + if (args->connect_timeout) + xs_tcp_do_set_connect_timeout(xprt, args->connect_timeout); INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); INIT_WORK(&transport->error_worker, xs_error_handle); From patchwork Sat Aug 19 21:32:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13358680 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29D78EE49A6 for ; Sun, 20 Aug 2023 00:22:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229479AbjHTAWQ (ORCPT ); Sat, 19 Aug 2023 20:22:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjHTAVk (ORCPT ); Sat, 19 Aug 2023 20:21:40 -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 B19D7E1C08 for ; Sat, 19 Aug 2023 14:39:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 43F35619E1 for ; Sat, 19 Aug 2023 21:39:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A1A7C433C9; Sat, 19 Aug 2023 21:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692481155; bh=8Vg7YLpqSpUemOlkTUZSjO5s6OVfvObnyW4C4J4K9zM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wuw+BC7BBBAJaaoeryuAPOFxnYPHMcQNUorGda//lmGkV8sD+Hp91iiM6c2/d5Ysl S71RRjTNZ8mieEyzGb7D2aeU7SvH+/Q+YVJo18kMNBEbQNikt0LE5wFZQ1xFE8j2MS 9p5fyEKCPL2J1AH9pSWBL7WcCcmICbzJEm8Dmo60WuTg7bSyS5xTFD5nGag5ZRcSIu TQKQ1XKRvbVou/DmBoQPViUJpM1VKc81qO9fh+HmCzh5akSdu3CxfAAepA0kXFMyEW qFxnFbYLIgcamPJ4X87fm/TH+UAB1qNdkg8epdRCCXpZMW8V78C/VbmxerZVgdrcTZ 1jD8JSw68Mgeg== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 4/5] SUNRPC: Don't override connect timeouts in rpc_clnt_add_xprt() Date: Sat, 19 Aug 2023 17:32:24 -0400 Message-ID: <20230819213225.731214-5-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819213225.731214-4-trondmy@kernel.org> References: <20230819213225.731214-1-trondmy@kernel.org> <20230819213225.731214-2-trondmy@kernel.org> <20230819213225.731214-3-trondmy@kernel.org> <20230819213225.731214-4-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If the caller specifies the connect timeouts in the arguments to rpc_clnt_add_xprt(), then we shouldn't override them. Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 9edebfdb5ce1..943dc3897378 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -3071,6 +3071,11 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, } xprt->resvport = resvport; xprt->reuseport = reuseport; + + if (xprtargs->connect_timeout) + connect_timeout = xprtargs->connect_timeout; + if (xprtargs->reconnect_timeout) + reconnect_timeout = xprtargs->reconnect_timeout; if (xprt->ops->set_connect_timeout != NULL) xprt->ops->set_connect_timeout(xprt, connect_timeout, From patchwork Sat Aug 19 21:32:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13358673 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD5F6EE49A5 for ; Sun, 20 Aug 2023 00:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229542AbjHTATD (ORCPT ); Sat, 19 Aug 2023 20:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbjHTASj (ORCPT ); Sat, 19 Aug 2023 20:18:39 -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 0EBCEE28FA for ; Sat, 19 Aug 2023 14:39:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E3FEE60304 for ; Sat, 19 Aug 2023 21:39:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC559C433C8; Sat, 19 Aug 2023 21:39:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692481156; bh=9F0mLVE6Px02gqZkud+RH0Oi+Kkcqan4L3icyQXLzm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=II3K8K4EbnzoAEdVTqeJYtQdyvTpS7tKYA2TtZPpryM3GfO0PJLDKtGhueKsHQNB0 9KfE2q/1oAre0iMwbGmB56WNyFtT1MtLAt8WVwQ539bW4TSz1ov4D3TyoDFtXQoDkG hVE75wP6ExGoZjaoTJNImAM8wvxCLdi3ehUeLKkdrCplncoxP56Z95Z46meqaRGdHF 6ghwlrmK+XmaiHkvnY1pyh85nLCxZPSfyuPw2RAheOPqm6UyvecTioC+GUQDXGSzE6 2CVkJmYDZpF8UZqZQV7Kol9zNQaYmAlQlGqA9qzDU9pkyhOMYlOVdtZErUOQTzVSXl aEaybopBJkqWA== From: trondmy@kernel.org To: Anna Schumaker Cc: linux-nfs@vger.kernel.org Subject: [PATCH v2 5/5] NFS/pNFS: Set the connect timeout for the pNFS flexfiles driver Date: Sat, 19 Aug 2023 17:32:25 -0400 Message-ID: <20230819213225.731214-6-trondmy@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230819213225.731214-5-trondmy@kernel.org> References: <20230819213225.731214-1-trondmy@kernel.org> <20230819213225.731214-2-trondmy@kernel.org> <20230819213225.731214-3-trondmy@kernel.org> <20230819213225.731214-4-trondmy@kernel.org> <20230819213225.731214-5-trondmy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust Ensure that the connect timeout for the pNFS flexfiles driver is of the same order as the I/O timeout, so that we can fail over quickly when trying to read from a data server that is down. Signed-off-by: Trond Myklebust --- fs/nfs/client.c | 2 ++ fs/nfs/internal.h | 2 ++ fs/nfs/nfs3client.c | 3 +++ fs/nfs/pnfs_nfs.c | 3 +++ 4 files changed, 10 insertions(+) diff --git a/fs/nfs/client.c b/fs/nfs/client.c index e4c5f193ed5e..44eca51b2808 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -517,6 +517,8 @@ int nfs_create_rpc_client(struct nfs_client *clp, .authflavor = flavor, .cred = cl_init->cred, .xprtsec = cl_init->xprtsec, + .connect_timeout = cl_init->connect_timeout, + .reconnect_timeout = cl_init->reconnect_timeout, }; if (test_bit(NFS_CS_DISCRTRY, &clp->cl_flags)) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 0019c7578f9d..4d80925c94f7 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -82,6 +82,8 @@ struct nfs_client_initdata { const struct rpc_timeout *timeparms; const struct cred *cred; struct xprtsec_parms xprtsec; + unsigned long connect_timeout; + unsigned long reconnect_timeout; }; /* diff --git a/fs/nfs/nfs3client.c b/fs/nfs/nfs3client.c index eff3802c5e03..674c012868b1 100644 --- a/fs/nfs/nfs3client.c +++ b/fs/nfs/nfs3client.c @@ -86,6 +86,7 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv, int ds_proto, unsigned int ds_timeo, unsigned int ds_retrans) { struct rpc_timeout ds_timeout; + unsigned long connect_timeout = ds_timeo * (ds_retrans + 1) * HZ / 10; struct nfs_client *mds_clp = mds_srv->nfs_client; struct nfs_client_initdata cl_init = { .addr = ds_addr, @@ -98,6 +99,8 @@ struct nfs_client *nfs3_set_ds_client(struct nfs_server *mds_srv, .timeparms = &ds_timeout, .cred = mds_srv->cred, .xprtsec = mds_clp->cl_xprtsec, + .connect_timeout = connect_timeout, + .reconnect_timeout = connect_timeout, }; struct nfs_client *clp; char buf[INET6_ADDRSTRLEN + 1]; diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index a0112ad4937a..a08cfda6fff1 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -852,6 +852,7 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, { struct nfs_client *clp = ERR_PTR(-EIO); struct nfs4_pnfs_ds_addr *da; + unsigned long connect_timeout = timeo * (retrans + 1) * HZ / 10; int status = 0; dprintk("--> %s DS %s\n", __func__, ds->ds_remotestr); @@ -870,6 +871,8 @@ static int _nfs4_pnfs_v3_ds_connect(struct nfs_server *mds_srv, .dstaddr = (struct sockaddr *)&da->da_addr, .addrlen = da->da_addrlen, .servername = clp->cl_hostname, + .connect_timeout = connect_timeout, + .reconnect_timeout = connect_timeout, }; if (da->da_transport != clp->cl_proto)