diff options
author | Stephen McKay <mckay@FreeBSD.org> | 2009-01-20 04:21:21 +0000 |
---|---|---|
committer | Stephen McKay <mckay@FreeBSD.org> | 2009-01-20 04:21:21 +0000 |
commit | 58c1607e031275af22d4a3e82781f860b96f44d6 (patch) | |
tree | 0b4f1095b7e7fa5ccd0760c7148372e2612f8fdb /sys/kern/vfs_cache.c | |
parent | e8bbeae7b0bcacb1fb3881616181005894f83160 (diff) | |
download | src-58c1607e031275af22d4a3e82781f860b96f44d6.tar.gz src-58c1607e031275af22d4a3e82781f860b96f44d6.zip |
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
Notes
Notes:
svn path=/head/; revision=187460
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r-- | sys/kern/vfs_cache.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 977b8cf78300..e79a568cd427 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -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; |