From owner-svn-src-projects@freebsd.org Fri Jul 6 19:55:16 2018 Return-Path: Delivered-To: svn-src-projects@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 2F92E1025925 for ; Fri, 6 Jul 2018 19:55:16 +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 C587B94158; Fri, 6 Jul 2018 19:55:15 +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 99E35552C; Fri, 6 Jul 2018 19:55:15 +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 w66JtFoV086038; Fri, 6 Jul 2018 19:55:15 GMT (envelope-from rmacklem@FreeBSD.org) Received: (from rmacklem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w66JtF8j086036; Fri, 6 Jul 2018 19:55:15 GMT (envelope-from rmacklem@FreeBSD.org) Message-Id: <201807061955.w66JtF8j086036@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rmacklem set sender to rmacklem@FreeBSD.org using -f From: Rick Macklem Date: Fri, 6 Jul 2018 19:55:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336048 - in projects/pnfs-planb-server/sys: fs/nfs rpc X-SVN-Group: projects X-SVN-Commit-Author: rmacklem X-SVN-Commit-Paths: in projects/pnfs-planb-server/sys: fs/nfs rpc X-SVN-Commit-Revision: 336048 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2018 19:55:16 -0000 Author: rmacklem Date: Fri Jul 6 19:55:14 2018 New Revision: 336048 URL: https://svnweb.freebsd.org/changeset/base/336048 Log: Add code the the krpc client so that it sets SO_SBTIMEO on the TCP socket when the CLSET_TIMEOUT option is set. Until this patch CLSET_TIMEOUT was never used and this patch uses it specifically for the case of NFSv4.1 mounts to DSs. This patch gives the code better control over how long the client/MDS will take to fail, due to an unresponsive DS and disable the DS. This is actually a client/krpc patch and does not affect the pNFS server code. Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonkrpc.c projects/pnfs-planb-server/sys/rpc/clnt_rc.c Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_commonkrpc.c ============================================================================== --- projects/pnfs-planb-server/sys/fs/nfs/nfs_commonkrpc.c Fri Jul 6 19:50:44 2018 (r336047) +++ projects/pnfs-planb-server/sys/fs/nfs/nfs_commonkrpc.c Fri Jul 6 19:55:14 2018 (r336048) @@ -195,7 +195,7 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq */ if (nrp->nr_cred != NULL) td->td_ucred = nrp->nr_cred; - else + else if (cred != NULL) td->td_ucred = cred; saddr = nrp->nr_nam; @@ -298,6 +298,13 @@ 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. */ + timo.tv_sec = 15; + timo.tv_usec = 0; + CLNT_CONTROL(client, CLSET_TIMEOUT, + &timo); + } /* * Make sure the nfscbd_pool doesn't get * destroyed while doing this. @@ -326,6 +333,9 @@ newnfs_connect(struct nfsmount *nmp, struct nfssockreq * only case where using a "soft" mount is * recommended for NFSv4. */ + timo.tv_sec = 15; + timo.tv_usec = 0; + CLNT_CONTROL(client, CLSET_TIMEOUT, &timo); retries = 2; } } Modified: projects/pnfs-planb-server/sys/rpc/clnt_rc.c ============================================================================== --- projects/pnfs-planb-server/sys/rpc/clnt_rc.c Fri Jul 6 19:50:44 2018 (r336047) +++ projects/pnfs-planb-server/sys/rpc/clnt_rc.c Fri Jul 6 19:55:14 2018 (r336048) @@ -174,10 +174,21 @@ clnt_reconnect_connect(CLIENT *cl) newclient = clnt_dg_create(so, (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, rc->rc_sendsz, rc->rc_recvsz); - else + else { + if (rc->rc_timeout.tv_sec > 0 && rc->rc_timeout.tv_usec != -1) { + error = so_setsockopt(so, SOL_SOCKET, SO_SNDTIMEO, + &rc->rc_timeout, sizeof(struct timeval)); + if (error != 0) { + stat = rpc_createerr.cf_stat = RPC_CANTSEND; + rpc_createerr.cf_error.re_errno = error; + td->td_ucred = oldcred; + goto out; + } + } newclient = clnt_vc_create(so, (struct sockaddr *) &rc->rc_addr, rc->rc_prog, rc->rc_vers, rc->rc_sendsz, rc->rc_recvsz, rc->rc_intr); + } td->td_ucred = oldcred; if (!newclient) {