From 798a5b356c9d7f2bbaa5a80284de7f20a81175d6 Mon Sep 17 00:00:00 2001 From: mohans Date: Fri, 23 Jun 2006 00:42:26 +0000 Subject: Size the NFS server dupreq cache on the basis of nmbclusters. On servers with low nmbclusters, we tie up too many mbclusters in the NFS duplicate request cache. This change limits the size of the dupreq cache to 1/2 the nmbclusters (and flaots in a range of [64, 2048]). MFC after 2 weeks. Reported by: Steve Kargl, David O'Brien Tested by: Steve Kargl --- sys/nfsserver/nfs_srvcache.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sys/nfsserver/nfs_srvcache.c') diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c index 7873ea2..a116414 100644 --- a/sys/nfsserver/nfs_srvcache.c +++ b/sys/nfsserver/nfs_srvcache.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include /* for sodupsockaddr */ +#include #include #include @@ -57,7 +58,7 @@ __FBSDID("$FreeBSD$"); #include static long numnfsrvcache; -static long desirednfsrvcache = NFSRVCACHESIZ; +static long desirednfsrvcache; #define NFSRCHASH(xid) \ (&nfsrvhashtbl[((xid) + ((xid) >> 24)) & nfsrvhash]) @@ -122,15 +123,32 @@ static const int nfsv2_repstat[NFS_NPROCS] = { FALSE, }; +/* + * Size the NFS server's duplicate request cache at 1/2 the nmbclsters, floating + * within a (64, 2048) range. This is to prevent all mbuf clusters being tied up + * in the NFS dupreq cache for small values of nmbclusters. + */ +static void +nfsrvcache_size_change(void *tag) +{ + desirednfsrvcache = nmbclusters /2; + if (desirednfsrvcache > NFSRVCACHE_MAX_SIZE) + desirednfsrvcache = NFSRVCACHE_MAX_SIZE; + if (desirednfsrvcache < NFSRVCACHE_MIN_SIZE) + desirednfsrvcache = NFSRVCACHE_MIN_SIZE; +} + /* * Initialize the server request cache list */ void nfsrv_initcache(void) { - + nfsrvcache_size_change(NULL); nfsrvhashtbl = hashinit(desirednfsrvcache, M_NFSD, &nfsrvhash); TAILQ_INIT(&nfsrvlruhead); + EVENTHANDLER_REGISTER(nmbclusters_change, nfsrvcache_size_change, NULL, + EVENTHANDLER_PRI_FIRST); } /* -- cgit v1.1