Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2019 07:56:01 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347510 - head/sys/kern
Message-ID:  <201905120756.x4C7u1eL036561@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun May 12 07:56:01 2019
New Revision: 347510
URL: https://svnweb.freebsd.org/changeset/base/347510

Log:
  cache: fix a brainfart in r347505
  
  If bumping over the counter goes over the limit we have to decrement it back.
  
  Previous code would only bump the counter after adding the entry (thus allowing
  the cache to go over the limit).
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Sun May 12 07:55:25 2019	(r347509)
+++ head/sys/kern/vfs_cache.c	Sun May 12 07:56:01 2019	(r347510)
@@ -1647,8 +1647,10 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 	 * Avoid blowout in namecache entries.
 	 */
 	lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
-	if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor))
+	if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor)) {
+		atomic_add_long(&numcache, -1);
 		return;
+	}
 
 	cache_celockstate_init(&cel);
 	ndd = NULL;



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