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
This commit is contained in:
mckay 2009-01-20 04:21:21 +00:00
parent 79c7e27631
commit 7620a1118d

View File

@ -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;