Date: Fri, 6 Jul 2018 19:55:15 +0000 (UTC) From: Rick Macklem <rmacklem@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r336048 - in projects/pnfs-planb-server/sys: fs/nfs rpc Message-ID: <201807061955.w66JtF8j086036@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807061955.w66JtF8j086036>