Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Dec 2008 11:14:17 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r185557 - head/sys/kern
Message-ID:  <200812021114.mB2BEHB3058629@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Tue Dec  2 11:14:16 2008
New Revision: 185557
URL: http://svn.freebsd.org/changeset/base/185557

Log:
  Shared lookup makes it possible to create several negative cache
  entries for one name. Then, creating inode with that name would remove
  one entry, leaving others dormant. Reclaiming the vnode would uncover
  negative entries, causing false return of ENOENT from the calls like
  stat, that do not create inode.
  
  Prevent creation of the duplicated negative entries.
  
  Reported and debugged with:	pho
  Reviewed by:	jhb
  X-MFC:	after shared lookup changes

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Tue Dec  2 11:12:50 2008	(r185556)
+++ head/sys/kern/vfs_cache.c	Tue Dec  2 11:14:16 2008	(r185557)
@@ -474,7 +474,7 @@ cache_enter(dvp, vp, cnp)
 	struct vnode *vp;
 	struct componentname *cnp;
 {
-	struct namecache *ncp;
+	struct namecache *ncp, *n2;
 	struct nchashhead *ncpp;
 	u_int32_t hash;
 	int hold;
@@ -530,8 +530,6 @@ cache_enter(dvp, vp, cnp)
 	 * name.
 	 */
 	if (vp) {
-		struct namecache *n2;
-
 		TAILQ_FOREACH(n2, &vp->v_cache_dst, nc_dst) {
 			if (n2->nc_dvp == dvp &&
 			    n2->nc_nlen == cnp->cn_namelen &&
@@ -541,7 +539,16 @@ cache_enter(dvp, vp, cnp)
 				return;
 			}
 		}
-	}	
+	} else {
+		TAILQ_FOREACH(n2, &ncneg, nc_dst) {
+			if (n2->nc_nlen == cnp->cn_namelen &&
+			    !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) {
+				CACHE_UNLOCK();
+				cache_free(ncp);
+				return;
+			}
+		}
+	}
 
 	numcache++;
 	if (!vp) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200812021114.mB2BEHB3058629>