svn commit: r185796 - in stable/7/sys: . contrib/pf kern

Konstantin Belousov kib at FreeBSD.org
Tue Dec 9 08:20:59 PST 2008


Author: kib
Date: Tue Dec  9 16:20:58 2008
New Revision: 185796
URL: http://svn.freebsd.org/changeset/base/185796

Log:
  MFC r185557:
  Prevent creation of the duplicated negative namecache entries.
  
  Approved by:	re (kensmith)
  Requested by:	jhb

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/kern/vfs_cache.c

Modified: stable/7/sys/kern/vfs_cache.c
==============================================================================
--- stable/7/sys/kern/vfs_cache.c	Tue Dec  9 15:49:02 2008	(r185795)
+++ stable/7/sys/kern/vfs_cache.c	Tue Dec  9 16:20:58 2008	(r185796)
@@ -460,7 +460,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;
@@ -516,8 +516,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 &&
@@ -527,7 +525,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) {


More information about the svn-src-stable-7 mailing list