From patchwork Fri Aug 5 23:37:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9266147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA3226075A for ; Sun, 7 Aug 2016 00:42:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DDAD279E0 for ; Sun, 7 Aug 2016 00:42:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D8E12840A; Sun, 7 Aug 2016 00:42:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D923D279E0 for ; Sun, 7 Aug 2016 00:42:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751044AbcHGAmx (ORCPT ); Sat, 6 Aug 2016 20:42:53 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:33672 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751040AbcHGAmw (ORCPT ); Sat, 6 Aug 2016 20:42:52 -0400 Received: by mail-io0-f194.google.com with SMTP id y195so26622945iod.0 for ; Sat, 06 Aug 2016 17:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=MaocUpxWOrbHUiswY9+7qLWqPrqDiAiRiHJT0UCKaWw=; b=V74mFURCF542kU+gtDvAfcGiDfYeVWt6pOOV7+BxUJNjC6vOsx+b/ldr1ikHKA9MHl 0TDgofy+VyeWVEexkCxZdL5QHzlecqwwDHOIVmt/MpN/H9hBXkHNLHqNT/D9+jgspQP1 2rNPQLfZTFBobhW/Eb6uA8jwXyuPDJP190FA40DRBC6XHf32D7ny1SS1ZYupfI6by8wT SlgDTE4m7JrFd5VHsipN1fQHZnUy6CbYv7BUUJZQMLzbHEz+Zqucxrs14rRCu2sLB3wk o0A8k7SeMpo/yRFUSNRp9wCiA1wvu6X6VmdMKb2Zpc/L1F9gGEhiLheYit1Uw1e+s6pm /Gdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=MaocUpxWOrbHUiswY9+7qLWqPrqDiAiRiHJT0UCKaWw=; b=jh9Vqw0SacjNow07LLauY6hhaunYZEeQiaqWmGh3xJ/xu5CmQs9mIC+rwUCqNxAWbE 70tpP8+79gZ85lit63N5hcRb8Pu/SBq4A2dRSJvF5gTg+39FnIJXU/btMskl0lqXrv9G iXXFr3Pc1PqW03X0FXX6fAmH51b0Zy4UsPT/Sz2TSzZCHhdIigPSn3xPiofyQEa77KnU zmKxX9utcXAqShxQEYlfHDJobseX7eDFlV1Fg00mn4TGyeOhMtP+5CovndJJ/zJCjwLY JRrP+JawKGrkLeBmjFhXiwrSe1AMxAbS176xz5yntR61Ar6uXmUZ0tdPJY/A+lTkR84i z1EQ== X-Gm-Message-State: AEkoouv+Q7eFf2qtdN8hM7ASD8+tfnW/K79HVCSjgVLhPIGhWuYvMWkkRlPvi0EytAkEAg== X-Received: by 10.107.9.6 with SMTP id j6mr83359029ioi.89.1470440297945; Fri, 05 Aug 2016 16:38:17 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id v7sm4874775itd.6.2016.08.05.16.38.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2016 16:38:17 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/3] SUNRPC: Limit the reconnect backoff timer to the max RPC message timeout Date: Fri, 5 Aug 2016 19:37:33 -0400 Message-Id: <1470440255-8612-2-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470440255-8612-1-git-send-email-trond.myklebust@primarydata.com> References: <1470440255-8612-1-git-send-email-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ...and ensure that we propagate it to new transports on the same client. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/xprt.h | 3 ++- net/sunrpc/clnt.c | 3 +++ net/sunrpc/xprtsock.c | 18 ++++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/include/linux/sunrpc/xprt.h b/include/linux/sunrpc/xprt.h index 5e3e1b63dbb3..a16070dd03ee 100644 --- a/include/linux/sunrpc/xprt.h +++ b/include/linux/sunrpc/xprt.h @@ -218,7 +218,8 @@ struct rpc_xprt { struct work_struct task_cleanup; struct timer_list timer; unsigned long last_used, - idle_timeout; + idle_timeout, + max_reconnect_timeout; /* * Send stuff diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index cb49898a5a58..faac5472d14d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2638,6 +2638,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, { struct rpc_xprt_switch *xps; struct rpc_xprt *xprt; + unsigned long reconnect_timeout; unsigned char resvport; int ret = 0; @@ -2649,6 +2650,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, return -EAGAIN; } resvport = xprt->resvport; + reconnect_timeout = xprt->max_reconnect_timeout; rcu_read_unlock(); xprt = xprt_create_transport(xprtargs); @@ -2657,6 +2659,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, goto out_put_switch; } xprt->resvport = resvport; + xprt->max_reconnect_timeout = reconnect_timeout; rpc_xprt_switch_set_roundrobin(xps); if (setup) { diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 04b0c4190dd7..8ede3bc52481 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c @@ -177,7 +177,6 @@ static struct ctl_table sunrpc_table[] = { * increase over time if the server is down or not responding. */ #define XS_TCP_INIT_REEST_TO (3U * HZ) -#define XS_TCP_MAX_REEST_TO (5U * 60 * HZ) /* * TCP idle timeout; client drops the transport socket if it is idle @@ -2396,6 +2395,15 @@ static unsigned long xs_reconnect_delay(const struct rpc_xprt *xprt) return 0; } +static void xs_reconnect_backoff(struct rpc_xprt *xprt) +{ + xprt->reestablish_timeout <<= 1; + if (xprt->reestablish_timeout > xprt->max_reconnect_timeout) + xprt->reestablish_timeout = xprt->max_reconnect_timeout; + if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO) + xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; +} + /** * xs_connect - connect a socket to a remote endpoint * @xprt: pointer to transport structure @@ -2426,12 +2434,8 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) xs_reset_transport(transport); delay = xs_reconnect_delay(xprt); + xs_reconnect_backoff(xprt); - xprt->reestablish_timeout <<= 1; - if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO) - xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO; - if (xprt->reestablish_timeout > XS_TCP_MAX_REEST_TO) - xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO; } else dprintk("RPC: xs_connect scheduled xprt %p\n", xprt); @@ -2989,6 +2993,8 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) xprt->ops = &xs_tcp_ops; xprt->timeout = &xs_tcp_default_timeout; + xprt->max_reconnect_timeout = xprt->timeout->to_maxval; + INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn); INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket);