From patchwork Fri Aug 5 23:37:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9266145 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 5869960760 for ; Sat, 6 Aug 2016 23:46:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 46001281DB for ; Sat, 6 Aug 2016 23:46:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 386ED28415; Sat, 6 Aug 2016 23:46:51 +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 92703281DB for ; Sat, 6 Aug 2016 23:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751019AbcHFXqt (ORCPT ); Sat, 6 Aug 2016 19:46:49 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:34419 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750933AbcHFXqs (ORCPT ); Sat, 6 Aug 2016 19:46:48 -0400 Received: by mail-io0-f196.google.com with SMTP id i199so4368148ioi.1 for ; Sat, 06 Aug 2016 16:46:48 -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=bczfjLvteXPx2jo/2Wt39B0f/CO0IK5JqhqK1FSJBwI=; b=FDVeqHAYxxzYwRFBUwYbU41BNc2gykwCEzaHEnNN2RjVjwMq+kqsYY5B4ynqMalW0Y IAfqf3AAU96ygwfV9IU6GP4BBDzTqVlWZ7cwKkrXSHUpQ0wmVFXPshKcUl6OTVaGEucq rsw2FB9ChN5aA26cB2ixhp6J9uHXBXI8EOSuzPux0/jrG4s6Jqi3iUXmESHv2M1JdxQp ZX9nB5QbssoGMs1/HpgarPf06sASOLoPijE+dDSRRmDFyuDH61/xjyHaktCPvsLZDfSj z6lEq4YM//mN1aR+1me5cIqYTF0Dgt7EOjq1A1mB+IVG9+GWemsFiTHGUR+sIYuSzOz1 F6DQ== 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=bczfjLvteXPx2jo/2Wt39B0f/CO0IK5JqhqK1FSJBwI=; b=MAC8Z8YTdqG1DtU7b77B8XXFG52uc/Tw+nF43ye5iQ1WKeXkEIekpTCQfO2c6K+FGX dipeW9suHxe+mFZso+XfQ5nPjAhJvwu3UIfQ/DHtMKCmARFLD04tXalnn0G+YJ7yY7tv G9Bbmreynz2Lvs+4lY0xoSdGHRj4YIBKhv2vVRtIF5N4qFhCY1+Y+8FVfSdkqyv3YDpc aOCIbOFQdqK2fLLxhhBi9Yel9ouqeVomfqZrlv9Pc4QJDktV4hHbNdD2177j2Q9/zGZp QYcbompDCLBzAOkk6tnR7fVxIeWaV+btnM85DruucLLtEdW5liy32mRzlGND0bJUJ9Nz eUdg== X-Gm-Message-State: AEkoousm1TUDYHrh+WAjs5jSMwLYE9RDUfYgzvl6Dn96mw4p/ANKkhgFEK5iMvoehbuSTQ== X-Received: by 10.107.6.233 with SMTP id f102mr94538334ioi.55.1470440302280; Fri, 05 Aug 2016 16:38:22 -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.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Aug 2016 16:38:21 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] NFSv4: Cap the transport reconnection timer at 1/2 lease period Date: Fri, 5 Aug 2016 19:37:35 -0400 Message-Id: <1470440255-8612-4-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470440255-8612-3-git-send-email-trond.myklebust@primarydata.com> References: <1470440255-8612-1-git-send-email-trond.myklebust@primarydata.com> <1470440255-8612-2-git-send-email-trond.myklebust@primarydata.com> <1470440255-8612-3-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 We don't want to miss a lease period renewal due to the TCP connection failing to reconnect in a timely fashion. To ensure this doesn't happen, cap the reconnection timer so that we retry the connection attempt at least every 1/2 lease period. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4renewd.c | 3 +++ include/linux/sunrpc/clnt.h | 2 ++ net/sunrpc/clnt.c | 21 +++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/fs/nfs/nfs4renewd.c b/fs/nfs/nfs4renewd.c index 062029ab344a..82e77198d17e 100644 --- a/fs/nfs/nfs4renewd.c +++ b/fs/nfs/nfs4renewd.c @@ -151,6 +151,9 @@ void nfs4_set_lease_period(struct nfs_client *clp, clp->cl_lease_time = lease; clp->cl_last_renewal = lastrenewed; spin_unlock(&clp->cl_lock); + + /* Cap maximum reconnect timeout at 1/2 lease period */ + rpc_cap_max_reconnect_timeout(clp->cl_rpcclient, lease >> 1); } /* diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index b6810c92b8bb..5c02b0691587 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -195,6 +195,8 @@ int rpc_clnt_add_xprt(struct rpc_clnt *, struct xprt_create *, struct rpc_xprt *, void *), void *data); +void rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, + unsigned long timeo); const char *rpc_proc_name(const struct rpc_task *task); #endif /* __KERNEL__ */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index faac5472d14d..7f79fb7dc6a0 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2676,6 +2676,27 @@ out_put_switch: } EXPORT_SYMBOL_GPL(rpc_clnt_add_xprt); +static int +rpc_xprt_cap_max_reconnect_timeout(struct rpc_clnt *clnt, + struct rpc_xprt *xprt, + void *data) +{ + unsigned long timeout = *((unsigned long *)data); + + if (timeout < xprt->max_reconnect_timeout) + xprt->max_reconnect_timeout = timeout; + return 0; +} + +void +rpc_cap_max_reconnect_timeout(struct rpc_clnt *clnt, unsigned long timeo) +{ + rpc_clnt_iterate_for_each_xprt(clnt, + rpc_xprt_cap_max_reconnect_timeout, + &timeo); +} +EXPORT_SYMBOL_GPL(rpc_cap_max_reconnect_timeout); + #if IS_ENABLED(CONFIG_SUNRPC_DEBUG) static void rpc_show_header(void) {