From owner-svn-src-stable@FreeBSD.ORG Fri Aug 17 14:22:57 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80159106564A; Fri, 17 Aug 2012 14:22:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 69FE08FC0C; Fri, 17 Aug 2012 14:22:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q7HEMvS6080937; Fri, 17 Aug 2012 14:22:57 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7HEMvE7080934; Fri, 17 Aug 2012 14:22:57 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201208171422.q7HEMvE7080934@svn.freebsd.org> From: John Baldwin Date: Fri, 17 Aug 2012 14:22:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r239355 - stable/7/sys/nfsclient X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2012 14:22:57 -0000 Author: jhb Date: Fri Aug 17 14:22:56 2012 New Revision: 239355 URL: http://svn.freebsd.org/changeset/base/239355 Log: MFC 230547: Add a timeout on positive name cache entries in the NFS client. That is, we will only trust a positive name cache entry for a specified amount of time before falling back to a LOOKUP RPC, even if the ctime for the file handle matches the cached copy in the name cache entry. The timeout is configured via a global 'vfs.nfs.name_timeout' sysctl and defaults to 60 seconds. It may be set to zero to disable positive name caching entirely. Note that this can result in increased NFS traffic under certain workloads. Increasing the threshold can mitigate this somewhat. Also, to match the existing 'vfs.nfs.negative_name_timeout' sysctl in 7, this version uses a sysctl rather than a mount option as in 8.x and later. Tested by: Mark Saad Modified: stable/7/sys/nfsclient/nfs_vnops.c stable/7/sys/nfsclient/nfsmount.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/nfsclient/nfs_vnops.c ============================================================================== --- stable/7/sys/nfsclient/nfs_vnops.c Fri Aug 17 14:14:25 2012 (r239354) +++ stable/7/sys/nfsclient/nfs_vnops.c Fri Aug 17 14:22:56 2012 (r239355) @@ -225,6 +225,10 @@ int nfs_directio_enable = 0; SYSCTL_INT(_vfs_nfs, OID_AUTO, nfs_directio_enable, CTLFLAG_RW, &nfs_directio_enable, 0, "Enable NFS directio"); +static u_int nametimeo = NFS_DEFAULT_NAMETIMEO; +SYSCTL_UINT(_vfs_nfs, OID_AUTO, name_timeout, CTLFLAG_RW, + &nametimeo, 0, "Positive name cache entry timeout"); + static u_int negnametimeo = NFS_DEFAULT_NEGNAMETIMEO; SYSCTL_UINT(_vfs_nfs, OID_AUTO, negative_name_timeout, CTLFLAG_RW, &negnametimeo, 0, "Negative name cache entry timeout"); @@ -908,7 +912,8 @@ nfs_lookup(struct vop_lookup_args *ap) * We only accept a positive hit in the cache if the * change time of the file matches our cached copy. * Otherwise, we discard the cache entry and fallback - * to doing a lookup RPC. + * to doing a lookup RPC. We also only trust cache + * entries for less than nametimeo seconds. * * To better handle stale file handles and attributes, * clear the attribute cache of this node if it is a @@ -927,7 +932,8 @@ nfs_lookup(struct vop_lookup_args *ap) newnp->n_attrstamp = 0; mtx_unlock(&newnp->n_mtx); } - if (VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td) == 0 && + if ((u_int)(ticks - ncticks) < (nametimeo * hz) && + VOP_GETATTR(newvp, &vattr, cnp->cn_cred, td) == 0 && timespeccmp(&vattr.va_ctime, &nctime, ==)) { nfsstats.lookupcache_hits++; if (cnp->cn_nameiop != LOOKUP && Modified: stable/7/sys/nfsclient/nfsmount.h ============================================================================== --- stable/7/sys/nfsclient/nfsmount.h Fri Aug 17 14:14:25 2012 (r239354) +++ stable/7/sys/nfsclient/nfsmount.h Fri Aug 17 14:22:56 2012 (r239355) @@ -114,6 +114,10 @@ struct nfsmount { #define NFS_TPRINTF_DELAY 30 #endif +#ifndef NFS_DEFAULT_NAMETIMEO +#define NFS_DEFAULT_NAMETIMEO 60 +#endif + #ifndef NFS_DEFAULT_NEGNAMETIMEO #define NFS_DEFAULT_NEGNAMETIMEO 60 #endif