svn commit: r187460 - head/sys/kern
Stephen McKay
mckay at FreeBSD.org
Mon Jan 19 20:21:22 PST 2009
Author: mckay
Date: Tue Jan 20 04:21:21 2009
New Revision: 187460
URL: http://svn.freebsd.org/changeset/base/187460
Log:
Add a limit on namecache entries.
In normal operation, the number of cache entries is roughly equal to the
number of active vnodes. However, when most of the recently accessed
vnodes have many hard links, the number of cache entries can be 32000
times as large, exhausting kernel memory and provoking a panic in
kmem_malloc().
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 Jan 20 02:08:21 2009 (r187459)
+++ head/sys/kern/vfs_cache.c Tue Jan 20 04:21:21 2009 (r187460)
@@ -489,6 +489,12 @@ cache_enter(dvp, vp, cnp)
if (!doingcache)
return;
+ /*
+ * Avoid blowout in namecache entries.
+ */
+ if (numcache >= desiredvnodes * 2)
+ return;
+
if (cnp->cn_nameptr[0] == '.') {
if (cnp->cn_namelen == 1) {
return;
More information about the svn-src-head
mailing list