Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 May 2019 06:59:23 +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: r347505 - head/sys/kern
Message-ID:  <201905120659.x4C6xNXS005162@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Sun May 12 06:59:22 2019
New Revision: 347505
URL: https://svnweb.freebsd.org/changeset/base/347505

Log:
  cache: bump numcache on entry, while here fix lnumcache type
  
  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 06:42:17 2019	(r347504)
+++ head/sys/kern/vfs_cache.c	Sun May 12 06:59:22 2019	(r347505)
@@ -1632,7 +1632,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 	int flag;
 	int len;
 	bool neg_locked;
-	int lnumcache;
+	u_long lnumcache;
 
 	CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr);
 	VNASSERT(vp == NULL || (vp->v_iflag & VI_DOOMED) == 0, vp,
@@ -1646,7 +1646,8 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 	/*
 	 * Avoid blowout in namecache entries.
 	 */
-	if (__predict_false(numcache >= desiredvnodes * ncsizefactor))
+	lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
+	if (__predict_false(lnumcache >= desiredvnodes * ncsizefactor))
 		return;
 
 	cache_celockstate_init(&cel);
@@ -1825,7 +1826,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 		    ncp->nc_name);
 	}
 	cache_enter_unlock(&cel);
-	lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
 	if (numneg * ncnegfactor > lnumcache)
 		cache_negative_zap_one();
 	cache_free(ndd);



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