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;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to