From fd3a284ca9382e3e4dd3e98c6248ef5fa96bc86d Mon Sep 17 00:00:00 2001 From: mjg Date: Sun, 5 Nov 2017 22:29:45 +0000 Subject: [PATCH] namecache: bump numcache after dropping all locks This makes no difference correctness-wise, but shortens total hold time. --- sys/kern/vfs_cache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 8a7cf4a86ff..49a21ba1da5 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1606,6 +1606,7 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, int flag; int len; bool neg_locked; + int lnumcache; CTR3(KTR_VFS, "cache_enter(%p, %p, %s)", dvp, vp, cnp->cn_nameptr); VNASSERT(vp == NULL || (vp->v_iflag & VI_DOOMED) == 0, vp, @@ -1745,7 +1746,6 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, dvp->v_cache_dd = ncp; } - atomic_add_rel_long(&numcache, 1); if (vp != NULL) { if (vp->v_type == VDIR) { if (flag != NCF_ISDOTDOT) { @@ -1798,7 +1798,8 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, ncp->nc_name); } cache_enter_unlock(&cel); - if (numneg * ncnegfactor > numcache) + lnumcache = atomic_fetchadd_long(&numcache, 1) + 1; + if (numneg * ncnegfactor > lnumcache) cache_negative_zap_one(); cache_free(ndd); return; -- 2.45.0