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
This commit is contained in:
Mateusz Guzik 2019-05-12 07:56:01 +00:00
parent 2425b5168c
commit 8ba6c1391b

View File

@ -1647,8 +1647,10 @@ cache_enter_time(struct vnode *dvp, struct vnode *vp, struct componentname *cnp,
* 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;