--- fs/nfsserver/nfs_nfsdcache.c.orig 2012-02-29 21:07:53.000000000 -0500 +++ fs/nfsserver/nfs_nfsdcache.c 2012-10-03 08:23:24.000000000 -0400 @@ -164,8 +164,19 @@ NFSCACHEMUTEX; int nfsrc_floodlevel = NFSRVCACHE_FLOODLEVEL, nfsrc_tcpsavedreplies = 0; #endif /* !APPLEKEXT */ +SYSCTL_DECL(_vfs_nfsd); + +static int nfsrc_tcphighwater = 0; +SYSCTL_INT(_vfs_nfsd, OID_AUTO, tcphighwater, CTLFLAG_RW, + &nfsrc_tcphighwater, 0, + "High water mark for TCP cache entries"); +static int nfsrc_udphighwater = NFSRVCACHE_UDPHIGHWATER; +SYSCTL_INT(_vfs_nfsd, OID_AUTO, udphighwater, CTLFLAG_RW, + &nfsrc_udphighwater, 0, + "High water mark for UDP cache entries"); + static int nfsrc_tcpnonidempotent = 1; -static int nfsrc_udphighwater = NFSRVCACHE_UDPHIGHWATER, nfsrc_udpcachesize = 0; +static int nfsrc_udpcachesize = 0; static TAILQ_HEAD(, nfsrvcache) nfsrvudplru; static struct nfsrvhashhead nfsrvhashtbl[NFSRVCACHE_HASHSIZE], nfsrvudphashtbl[NFSRVCACHE_HASHSIZE]; @@ -781,8 +792,15 @@ nfsrc_trimcache(u_int64_t sockref, struc { struct nfsrvcache *rp, *nextrp; int i; + static time_t lasttrim = 0; + if (NFSD_MONOSEC == lasttrim && + nfsrc_tcpsavedreplies < nfsrc_tcphighwater && + nfsrc_udpcachesize < (nfsrc_udphighwater + + nfsrc_udphighwater / 2)) + return; NFSLOCKCACHE(); + lasttrim = NFSD_MONOSEC; TAILQ_FOREACH_SAFE(rp, &nfsrvudplru, rc_lru, nextrp) { if (!(rp->rc_flag & (RC_INPROG|RC_LOCKED|RC_WANTED)) && rp->rc_refcnt == 0