Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Jan 2009 04:21:21 +0000 (UTC)
From:      Stephen McKay <mckay@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r187460 - head/sys/kern
Message-ID:  <200901200421.n0K4LLJ6032323@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901200421.n0K4LLJ6032323>