From owner-svn-src-all@freebsd.org Sat Jul 21 01:33:08 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70F89102EF5F; Sat, 21 Jul 2018 01:33:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1E62375D55; Sat, 21 Jul 2018 01:33:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 009E9183D6; Sat, 21 Jul 2018 01:33:08 +0000 (UTC) (envelope-from rmacklem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6L1X7nZ045467; Sat, 21 Jul 2018 01:33:07 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6L1X7U3045466; Sat, 21 Jul 2018 01:33:07 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807210133.w6L1X7U3045466@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Sat, 21 Jul 2018 01:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336573 - head/sys/fs/nfs X-SVN-Group: head X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: head/sys/fs/nfs X-SVN-Commit-Revision: 336573 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2018 01:33:08 -0000 Author: rmacklem Date: Sat Jul 21 01:33:07 2018 New Revision: 336573 URL: https://svnweb.freebsd.org/changeset/base/336573 Log: Set CLSET_TIMEOUT on TCP connections to pNFS DSs. Use CLSET_TIMEOUT to set the timeout for connections to DSs instead of specifying a timeout on each RPC. This is done so that SO_SNDTIMEO is set on the TCP socket as well as specifying a time limit when waiting for an RPC reply. Useful if the send queue for the TCP connection has become constipated, due to a failed DS. The choice of lease_duration / 4 is fairly arbitrary, but seems to work ok, with a lower bound of 10sec. For client connections to a DS, set the retry limit to vfs.nfsd.dsretries, which is 2 by default. This patch should only affect pNFS connections to DSs. This patch requires r336542. MFC after: 2 weeks Modified: head/sys/fs/nfs/nfs_commonkrpc.c Modified: head/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- head/sys/fs/nfs/nfs_commonkrpc.c Sat Jul 21 00:12:41 2018 (r336572) +++ head/sys/fs/nfs/nfs_commonkrpc.c Sat Jul 21 01:33:07 2018 (r336573) @@ -98,6 +98,7 @@ extern int nfscl_ticks; extern void (*ncl_call_invalcaches)(struct vnode *); extern int nfs_numnfscbd; extern int nfscl_debuglevel; +extern int nfsrv_lease; SVCPOOL *nfscbd_pool; static int nfsrv_gsscallbackson = 0; @@ -105,6 +106,7 @@ static int nfs_bufpackets = 4; static int nfs_reconnects; static int nfs3_jukebox_delay = 10; static int nfs_skip_wcc_data_onerr = 1; +static int nfs_dsretries = 2; SYSCTL_DECL(_vfs_nfs); @@ -116,6 +118,8 @@ SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs3_jukebox_delay, CTL "Number of seconds to delay a retry after receiving EJUKEBOX"); SYSCTL_INT(_vfs_nfs, OID_AUTO, skip_wcc_data_onerr, CTLFLAG_RW, &nfs_skip_wcc_data_onerr, 0, "Disable weak cache consistency checking when server returns an error"); +SYSCTL_INT(_vfs_nfs, OID_AUTO, dsretries, CTLFLAG_RW, &nfs_dsretries, 0, + "Number of retries for a DS RPC before failure"); static void nfs_down(struct nfsmount *, struct thread *, const char *, int, int); @@ -298,6 +302,30 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq retries = INT_MAX; if (NFSHASNFSV4N(nmp)) { if (cred != NULL) { + if (NFSHASSOFT(nmp)) { + /* + * This should be a DS mount. + * Use CLSET_TIMEOUT to set the timeout + * for connections to DSs instead of + * specifying a timeout on each RPC. + * This is done so that SO_SNDTIMEO + * is set on the TCP socket as well + * as specifying a time limit when + * waiting for an RPC reply. Useful + * if the send queue for the TCP + * connection has become constipated, + * due to a failed DS. + * The choice of lease_duration / 4 is + * fairly arbitrary, but seems to work + * ok, with a lower bound of 10sec. + */ + timo.tv_sec = nfsrv_lease / 4; + if (timo.tv_sec < 10) + timo.tv_sec = 10; + timo.tv_usec = 0; + CLNT_CONTROL(client, CLSET_TIMEOUT, + &timo); + } /* * Make sure the nfscbd_pool doesn't get * destroyed while doing this. @@ -325,8 +353,18 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq * not maintain open/lock state and is the * only case where using a "soft" mount is * recommended for NFSv4. + * For mounts from the MDS to DS, this is done + * via mount options, but that is not the case + * here. The retry limit here can be adjusted + * via the sysctl vfs.nfs.dsretries. + * See the comment above w.r.t. timeout. */ - retries = 2; + timo.tv_sec = nfsrv_lease / 4; + if (timo.tv_sec < 10) + timo.tv_sec = 10; + timo.tv_usec = 0; + CLNT_CONTROL(client, CLSET_TIMEOUT, &timo); + retries = nfs_dsretries; } } } else {