From owner-svn-src-stable-7@FreeBSD.ORG Tue May 4 21:21:05 2010 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A73A8106566B; Tue, 4 May 2010 21:21:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id 8CB318FC15; Tue, 4 May 2010 21:21:05 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o44LL57W036586; Tue, 4 May 2010 21:21:05 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o44LL5g6036581; Tue, 4 May 2010 21:21:05 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201005042121.o44LL5g6036581@svn.freebsd.org> From: John Baldwin Date: Tue, 4 May 2010 21:21:05 +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: r207634 - stable/7/sys/nfsclient X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 May 2010 21:21:05 -0000 Author: jhb Date: Tue May 4 21:21:05 2010 New Revision: 207634 URL: http://svn.freebsd.org/changeset/base/207634 Log: MFC: 202767,202774 Add a timeout for the negative name cache entries in the NFS client. This avoids a bogus negative name cache entry from persisting forever when another client creates an entry with the same name within the same NFS server time of day clock tick. Unlike 8.x and later, the timeout is only adjustable via a system-wide sysctl (vfs.nfs.negative_name_timeout) rather than a mount option. Setting the timeout to 0 disables negative name caching. I also fixed one obvious typo where args.timeo should be args.maxgrouplist. Modified: stable/7/sys/nfsclient/nfs_vfsops.c stable/7/sys/nfsclient/nfs_vnops.c stable/7/sys/nfsclient/nfsmount.h stable/7/sys/nfsclient/nfsnode.h Modified: stable/7/sys/nfsclient/nfs_vfsops.c ============================================================================== --- stable/7/sys/nfsclient/nfs_vfsops.c Tue May 4 21:16:01 2010 (r207633) +++ stable/7/sys/nfsclient/nfs_vfsops.c Tue May 4 21:21:05 2010 (r207634) @@ -951,7 +951,7 @@ nfs_mount(struct mount *mp, struct threa } if (vfs_getopt(mp->mnt_optnew, "maxgroups", (void **)&opt, NULL) == 0) { ret = sscanf(opt, "%d", &args.maxgrouplist); - if (ret != 1 || args.timeo <= 0) { + if (ret != 1 || args.maxgrouplist <= 0) { vfs_mount_error(mp, "illegal maxgroups: %s", opt); error = EINVAL; Modified: stable/7/sys/nfsclient/nfs_vnops.c ============================================================================== --- stable/7/sys/nfsclient/nfs_vnops.c Tue May 4 21:16:01 2010 (r207633) +++ stable/7/sys/nfsclient/nfs_vnops.c Tue May 4 21:21:05 2010 (r207634) @@ -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 negnametimeo = NFS_DEFAULT_NEGNAMETIMEO; +SYSCTL_UINT(_vfs_nfs, OID_AUTO, negative_name_timeout, CTLFLAG_RW, + &negnametimeo, 0, "Negative name cache entry timeout"); + /* * This sysctl allows other processes to mmap a file that has been opened * O_DIRECT by a process. In general, having processes mmap the file while @@ -918,9 +922,12 @@ nfs_lookup(struct vop_lookup_args *ap) * We only accept a negative hit in the cache if the * modification time of the parent directory matches * our cached copy. Otherwise, we discard all of the - * negative cache entries for this directory. + * negative cache entries for this directory. We also + * only trust -ve cache entries for less than + * negnametimeo seconds. */ - if (VOP_GETATTR(dvp, &vattr, cnp->cn_cred, td) == 0 && + if ((u_int)(ticks - np->n_dmtime_ticks) < (negnametimeo * hz) && + VOP_GETATTR(dvp, &vattr, cnp->cn_cred, td) == 0 && vattr.va_mtime.tv_sec == np->n_dmtime) { nfsstats.lookupcache_hits++; return (ENOENT); @@ -1063,8 +1070,10 @@ nfsmout: */ mtx_lock(&np->n_mtx); if (np->n_dmtime <= dmtime) { - if (np->n_dmtime == 0) + if (np->n_dmtime == 0) { np->n_dmtime = dmtime; + np->n_dmtime_ticks = ticks; + } mtx_unlock(&np->n_mtx); cache_enter(dvp, NULL, cnp); } else Modified: stable/7/sys/nfsclient/nfsmount.h ============================================================================== --- stable/7/sys/nfsclient/nfsmount.h Tue May 4 21:16:01 2010 (r207633) +++ stable/7/sys/nfsclient/nfsmount.h Tue May 4 21:21:05 2010 (r207634) @@ -114,6 +114,10 @@ struct nfsmount { #define NFS_TPRINTF_DELAY 30 #endif +#ifndef NFS_DEFAULT_NEGNAMETIMEO +#define NFS_DEFAULT_NEGNAMETIMEO 60 +#endif + #endif #endif Modified: stable/7/sys/nfsclient/nfsnode.h ============================================================================== --- stable/7/sys/nfsclient/nfsnode.h Tue May 4 21:16:01 2010 (r207633) +++ stable/7/sys/nfsclient/nfsnode.h Tue May 4 21:21:05 2010 (r207634) @@ -110,6 +110,7 @@ struct nfsnode { struct timespec n_mtime; /* Prev modify time. */ time_t n_ctime; /* Prev create time. */ time_t n_dmtime; /* Prev dir modify time. */ + int n_dmtime_ticks; /* Tick of -ve cache entry */ time_t n_expiry; /* Lease expiry time */ nfsfh_t *n_fhp; /* NFS File Handle */ struct vnode *n_vnode; /* associated vnode */