svn commit: r190945 - head/sys/kern
Alexander Kabaev
kan at FreeBSD.org
Sat Apr 11 20:23:09 UTC 2009
Author: kan
Date: Sat Apr 11 20:23:08 2009
New Revision: 190945
URL: http://svn.freebsd.org/changeset/base/190945
Log:
Fix v_cache_dd handling for negative entries. v_cache_dd pointer was
not populated in parent directory if negative entry was being
created, yet entry itself was added to the nc_neg list. It was
possible for parent vnode to get discarded later, leaving negative
entry pointing to now unused memory block.
Reported by: dho
Revewed by: kib
Modified:
head/sys/kern/vfs_cache.c
Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c Sat Apr 11 17:36:11 2009 (r190944)
+++ head/sys/kern/vfs_cache.c Sat Apr 11 20:23:08 2009 (r190945)
@@ -678,14 +678,19 @@ cache_enter(dvp, vp, cnp)
}
}
- /*
- * See if we are trying to add .. entry, but some other lookup
- * has populated v_cache_dd pointer already.
- */
- if (flag == NCF_ISDOTDOT && dvp->v_cache_dd != NULL) {
- CACHE_WUNLOCK();
- cache_free(ncp);
- return;
+ if (flag == NCF_ISDOTDOT) {
+ /*
+ * See if we are trying to add .. entry, but some other lookup
+ * has populated v_cache_dd pointer already.
+ */
+ if (dvp->v_cache_dd != NULL) {
+ CACHE_WUNLOCK();
+ cache_free(ncp);
+ return;
+ }
+ KASSERT(vp == NULL || vp->v_type == VDIR,
+ ("wrong vnode type %p", vp));
+ dvp->v_cache_dd = ncp;
}
numcache++;
@@ -694,11 +699,7 @@ cache_enter(dvp, vp, cnp)
if (cnp->cn_flags & ISWHITEOUT)
ncp->nc_flag |= NCF_WHITE;
} else if (vp->v_type == VDIR) {
- if (flag == NCF_ISDOTDOT) {
- KASSERT(dvp->v_cache_dd == NULL,
- ("dangling v_cache_dd"));
- dvp->v_cache_dd = ncp;
- } else {
+ if (flag != NCF_ISDOTDOT) {
if ((n2 = vp->v_cache_dd) != NULL &&
(n2->nc_flag & NCF_ISDOTDOT) != 0)
cache_zap(n2);
More information about the svn-src-head
mailing list