All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6/8] knfsd: repcache: use client IP address in hash
@ 2006-10-11 11:28 Greg Banks
  2006-10-12  2:30 ` Trond Myklebust
  2006-10-23 19:51 ` J. Bruce Fields
  0 siblings, 2 replies; 10+ messages in thread
From: Greg Banks @ 2006-10-11 11:28 UTC (permalink / raw)
  To: Neil Brown; +Cc: Linux NFS Mailing List

knfsd: Use the client's IP address in the duplicate request cache
hash function, instead of just the XID.  This avoids contention
on hash buckets when the workload has many clients whose XIDs are
nearly in lockstep, a property seen on compute clusters using NFS
for shared storage.

Signed-off-by: Greg Banks <gnb@melbourne.sgi.com>
---

 fs/nfsd/nfscache.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

Index: linux-git-20061009/fs/nfsd/nfscache.c
===================================================================
--- linux-git-20061009.orig/fs/nfsd/nfscache.c	2006-10-10 16:41:07.121363949 +1000
+++ linux-git-20061009/fs/nfsd/nfscache.c	2006-10-10 16:41:49.107949488 +1000
@@ -93,13 +93,18 @@ static int			cache_disabled = 1;
  * Calculate the hash index from an XID.  Note, some clients increment
  * their XIDs in host order, which can result in all the variation being
  * in the top bits we see here.  So we fold those bits down.
+ *
+ * Experiment shows that using the Jenkins hash improves the spectral
+ * properties of this hash, but the CPU cost of calculating it outweighs
+ * the advantages.
  */
 static inline u32
-request_hash(u32 xid)
+request_hash(u32 xid, const struct sockaddr_in *sin)
 {
 	u32 h = xid;
 	h ^= (xid >> 24);
 	h ^= ((xid & 0xff0000) >> 8);
+	h ^= sin->sin_addr.s_addr;
 	return h;
 }
 
@@ -248,7 +253,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp
 	int			safe = 0;
 	int			expand = 0;
 
-	h = request_hash(xid);
+	h = request_hash(xid, &rqstp->rq_addr);
 	b = bucket_for_hash(h);
 	h = (h / CACHE_NUM_BUCKETS) & (HASHSIZE-1);
 
@@ -399,7 +404,7 @@ nfsd_cache_update(struct svc_rqst *rqstp
 	if (!(rp = rqstp->rq_cacherep) || cache_disabled)
 		return;
 
-	b = bucket_for_hash(request_hash(rp->c_xid));
+	b = bucket_for_hash(request_hash(rp->c_xid, &rp->c_addr));
 
 	len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
 	len >>= 2;

Greg.
-- 
Greg Banks, R&D Software Engineer, SGI Australian Software Group.
I don't speak for SGI.



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-10-23 19:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-11 11:28 [PATCH 6/8] knfsd: repcache: use client IP address in hash Greg Banks
2006-10-12  2:30 ` Trond Myklebust
2006-10-12  8:21   ` Greg Banks
2006-10-12 14:19     ` Chuck Lever
2006-10-12 15:31     ` J. Bruce Fields
2006-10-16  2:27   ` Neil Brown
2006-10-16 10:59     ` Greg Banks
2006-10-16 13:42     ` Trond Myklebust
2006-10-16 22:49       ` Neil Brown
2006-10-23 19:51 ` J. Bruce Fields

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.