svn commit: r186600 - head/sys/kern

Konstantin Belousov kib at FreeBSD.org
Tue Dec 30 12:51:15 UTC 2008


Author: kib
Date: Tue Dec 30 12:51:14 2008
New Revision: 186600
URL: http://svn.freebsd.org/changeset/base/186600

Log:
  In r185557, the check for existing negative entry for the given name
  did not compared nc_dvp with supplied parent directory vnode pointer.
  Add the check and note that now branches for vp != NULL and vp == NULL
  are the same, thus can be merged.
  
  Reported and reviewed by:	kan
  Tested by:	pho
  MFC after:	2 weeks

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Tue Dec 30 09:43:01 2008	(r186599)
+++ head/sys/kern/vfs_cache.c	Tue Dec 30 12:51:14 2008	(r186600)
@@ -526,28 +526,18 @@ cache_enter(dvp, vp, cnp)
 	CACHE_LOCK();
 
 	/*
-	 * See if this vnode is already in the cache with this name.
-	 * This can happen with concurrent lookups of the same path
-	 * name.
+	 * See if this vnode or negative entry is already in the cache
+	 * with this name.  This can happen with concurrent lookups of
+	 * the same path name.
 	 */
-	if (vp) {
-		TAILQ_FOREACH(n2, &vp->v_cache_dst, nc_dst) {
-			if (n2->nc_dvp == dvp &&
-			    n2->nc_nlen == cnp->cn_namelen &&
-			    !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) {
-				CACHE_UNLOCK();
-				cache_free(ncp);
-				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;
-			}
+	ncpp = NCHHASH(hash);
+	LIST_FOREACH(n2, ncpp, nc_hash) {
+		if (n2->nc_dvp == dvp &&
+		    n2->nc_nlen == cnp->cn_namelen &&
+		    !bcmp(n2->nc_name, cnp->cn_nameptr, n2->nc_nlen)) {
+			CACHE_UNLOCK();
+			cache_free(ncp);
+			return;
 		}
 	}
 
@@ -565,7 +555,6 @@ cache_enter(dvp, vp, cnp)
 	 * Insert the new namecache entry into the appropriate chain
 	 * within the cache entries table.
 	 */
-	ncpp = NCHHASH(hash);
 	LIST_INSERT_HEAD(ncpp, ncp, nc_hash);
 	if (LIST_EMPTY(&dvp->v_cache_src)) {
 		hold = 1;


More information about the svn-src-head mailing list