From 802b1728d8a3d2a016628022a7631f365f00e337 Mon Sep 17 00:00:00 2001 From: rmacklem Date: Wed, 14 Aug 2013 21:11:26 +0000 Subject: Fix several performance related issues in the new NFS server's DRC for NFS over TCP. - Increase the size of the hash tables. - Create a separate mutex for each hash list of the TCP hash table. - Single thread the code that deletes stale cache entries. - Add a tunable called vfs.nfsd.tcphighwater, which can be increased to allow the cache to grow larger, avoiding the overhead of frequent scans to delete stale cache entries. (The default value will result in frequent scans to delete stale cache entries, analagous to what the pre-patched code does.) - Add a tunable called vfs.nfsd.cachetcp that can be used to disable DRC caching for NFS over TCP, since the old NFS server didn't DRC cache TCP. It also adjusts the size of nfsrc_floodlevel dynamically, so that it is always greater than vfs.nfsd.tcphighwater. For UDP the algorithm remains the same as the pre-patched code, but the tunable vfs.nfsd.udphighwater can be used to allow the cache to grow larger and reduce the overhead caused by frequent scans for stale entries. UDP also uses a larger hash table size than the pre-patched code. Reported by: wollman Tested by: wollman (earlier version of patch) Submitted by: ivoras (earlier patch) Reviewed by: jhb (earlier version of patch) MFC after: 1 month --- sys/fs/nfs/nfsport.h | 5 ----- sys/fs/nfs/nfsrvcache.h | 10 +++++++++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'sys/fs/nfs') diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index f0e20f1..cec50a6 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -603,11 +603,6 @@ void nfsrvd_rcv(struct socket *, void *, int); #define NFSREQSPINLOCK extern struct mtx nfs_req_mutex #define NFSLOCKREQ() mtx_lock(&nfs_req_mutex) #define NFSUNLOCKREQ() mtx_unlock(&nfs_req_mutex) -#define NFSCACHEMUTEX extern struct mtx nfs_cache_mutex -#define NFSCACHEMUTEXPTR (&nfs_cache_mutex) -#define NFSLOCKCACHE() mtx_lock(&nfs_cache_mutex) -#define NFSUNLOCKCACHE() mtx_unlock(&nfs_cache_mutex) -#define NFSCACHELOCKREQUIRED() mtx_assert(&nfs_cache_mutex, MA_OWNED) #define NFSSOCKMUTEX extern struct mtx nfs_slock_mutex #define NFSSOCKMUTEXPTR (&nfs_slock_mutex) #define NFSLOCKSOCK() mtx_lock(&nfs_slock_mutex) diff --git a/sys/fs/nfs/nfsrvcache.h b/sys/fs/nfs/nfsrvcache.h index 30f757a..5c9dc57 100644 --- a/sys/fs/nfs/nfsrvcache.h +++ b/sys/fs/nfs/nfsrvcache.h @@ -41,8 +41,9 @@ #define NFSRVCACHE_MAX_SIZE 2048 #define NFSRVCACHE_MIN_SIZE 64 -#define NFSRVCACHE_HASHSIZE 20 +#define NFSRVCACHE_HASHSIZE 500 +/* Cache table entry. */ struct nfsrvcache { LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */ TAILQ_ENTRY(nfsrvcache) rc_lru; /* UDP lru chain */ @@ -104,4 +105,11 @@ struct nfsrvcache { LIST_HEAD(nfsrvhashhead, nfsrvcache); +/* The fine-grained locked cache hash table for TCP. */ +struct nfsrchash_bucket { + struct mtx mtx; + char lock_name[16]; + struct nfsrvhashhead tbl; +}; + #endif /* _NFS_NFSRVCACHE_H_ */ -- cgit v1.1