Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Nov 2019 01:20:56 +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: r355124 - head/sys/kern
Message-ID:  <201911270120.xAR1Kuie034221@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mjg
Date: Wed Nov 27 01:20:55 2019
New Revision: 355124
URL: https://svnweb.freebsd.org/changeset/base/355124

Log:
  cache: fix numcache accounting on entry
  
  . entries are never created and .. can reuse existing entries,
  meaning the early count bump is both spurious and leading to
  overcounting in certain cases.

Modified:
  head/sys/kern/vfs_cache.c

Modified: head/sys/kern/vfs_cache.c
==============================================================================
--- head/sys/kern/vfs_cache.c	Wed Nov 27 01:20:21 2019	(r355123)
+++ head/sys/kern/vfs_cache.c	Wed Nov 27 01:20:55 2019	(r355124)
@@ -1690,15 +1690,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 		return;
 #endif
 
-	/*
-	 * Avoid blowout in namecache entries.
-	 */
-	lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
-	if (__predict_false(lnumcache >= ncsize)) {
-		atomic_add_long(&numcache, -1);
-		return;
-	}
-
 	cache_celockstate_init(&cel);
 	ndd = NULL;
 	ncp_ts = NULL;
@@ -1760,6 +1751,15 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, 
 			SDT_PROBE3(vfs, namecache, enter, done, dvp, "..", vp);
 			flag = NCF_ISDOTDOT;
 		}
+	}
+
+	/*
+	 * Avoid blowout in namecache entries.
+	 */
+	lnumcache = atomic_fetchadd_long(&numcache, 1) + 1;
+	if (__predict_false(lnumcache >= ncsize)) {
+		atomic_add_long(&numcache, -1);
+		return;
 	}
 
 	held_dvp = false;



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