1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

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:
Stephen McKay 2009-01-20 04:21:21 +00:00
parent e8bbeae7b0
commit 58c1607e03
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=187460

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;