summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_cache.c
diff options
context:
space:
mode:
authormckay <mckay@FreeBSD.org>2009-01-20 04:21:21 +0000
committermckay <mckay@FreeBSD.org>2009-01-20 04:21:21 +0000
commit7620a1118d5a4aa8aea748887ebdb85925c467c1 (patch)
tree0b4f1095b7e7fa5ccd0760c7148372e2612f8fdb /sys/kern/vfs_cache.c
parent79c7e27631126fa7b4578d3816784d4f4eecd02f (diff)
downloadFreeBSD-src-7620a1118d5a4aa8aea748887ebdb85925c467c1.zip
FreeBSD-src-7620a1118d5a4aa8aea748887ebdb85925c467c1.tar.gz
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
Diffstat (limited to 'sys/kern/vfs_cache.c')
-rw-r--r--sys/kern/vfs_cache.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c
index 977b8cf..e79a568 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;
OpenPOWER on IntegriCloud