aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-02-03 01:31:31 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2010-03-16 18:05:11 -0400
commit61f8603d93fa0b0e2f73be7a4f048696417a24a3 (patch)
tree7de2f0fffd744026ef608c6df835944e8c4ba8bb /fs/nfsd
parentd202cce8963d9268ff355a386e20243e8332b308 (diff)
nfsd: factor out hash functions for export caches.
Both the _lookup and the _update functions for these two caches independently calculate the hash of the key. So factor out that code for improved reuse. Signed-off-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/export.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index a0c4016413f1..65ddc5b8eb33 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -258,10 +258,9 @@ static struct cache_detail svc_expkey_cache = {
258 .alloc = expkey_alloc, 258 .alloc = expkey_alloc,
259}; 259};
260 260
261static struct svc_expkey * 261static int
262svc_expkey_lookup(struct svc_expkey *item) 262svc_expkey_hash(struct svc_expkey *item)
263{ 263{
264 struct cache_head *ch;
265 int hash = item->ek_fsidtype; 264 int hash = item->ek_fsidtype;
266 char * cp = (char*)item->ek_fsid; 265 char * cp = (char*)item->ek_fsid;
267 int len = key_len(item->ek_fsidtype); 266 int len = key_len(item->ek_fsidtype);
@@ -269,6 +268,14 @@ svc_expkey_lookup(struct svc_expkey *item)
269 hash ^= hash_mem(cp, len, EXPKEY_HASHBITS); 268 hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
270 hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS); 269 hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS);
271 hash &= EXPKEY_HASHMASK; 270 hash &= EXPKEY_HASHMASK;
271 return hash;
272}
273
274static struct svc_expkey *
275svc_expkey_lookup(struct svc_expkey *item)
276{
277 struct cache_head *ch;
278 int hash = svc_expkey_hash(item);
272 279
273 ch = sunrpc_cache_lookup(&svc_expkey_cache, &item->h, 280 ch = sunrpc_cache_lookup(&svc_expkey_cache, &item->h,
274 hash); 281 hash);
@@ -282,13 +289,7 @@ static struct svc_expkey *
282svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old) 289svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
283{ 290{
284 struct cache_head *ch; 291 struct cache_head *ch;
285 int hash = new->ek_fsidtype; 292 int hash = svc_expkey_hash(new);
286 char * cp = (char*)new->ek_fsid;
287 int len = key_len(new->ek_fsidtype);
288
289 hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
290 hash ^= hash_ptr(new->ek_client, EXPKEY_HASHBITS);
291 hash &= EXPKEY_HASHMASK;
292 293
293 ch = sunrpc_cache_update(&svc_expkey_cache, &new->h, 294 ch = sunrpc_cache_update(&svc_expkey_cache, &new->h,
294 &old->h, hash); 295 &old->h, hash);
@@ -737,14 +738,22 @@ struct cache_detail svc_export_cache = {
737 .alloc = svc_export_alloc, 738 .alloc = svc_export_alloc,
738}; 739};
739 740
740static struct svc_export * 741static int
741svc_export_lookup(struct svc_export *exp) 742svc_export_hash(struct svc_export *exp)
742{ 743{
743 struct cache_head *ch;
744 int hash; 744 int hash;
745
745 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS); 746 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
746 hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS); 747 hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS);
747 hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS); 748 hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS);
749 return hash;
750}
751
752static struct svc_export *
753svc_export_lookup(struct svc_export *exp)
754{
755 struct cache_head *ch;
756 int hash = svc_export_hash(exp);
748 757
749 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h, 758 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
750 hash); 759 hash);
@@ -758,10 +767,7 @@ static struct svc_export *
758svc_export_update(struct svc_export *new, struct svc_export *old) 767svc_export_update(struct svc_export *new, struct svc_export *old)
759{ 768{
760 struct cache_head *ch; 769 struct cache_head *ch;
761 int hash; 770 int hash = svc_export_hash(old);
762 hash = hash_ptr(old->ex_client, EXPORT_HASHBITS);
763 hash ^= hash_ptr(old->ex_path.dentry, EXPORT_HASHBITS);
764 hash ^= hash_ptr(old->ex_path.mnt, EXPORT_HASHBITS);
765 771
766 ch = sunrpc_cache_update(&svc_export_cache, &new->h, 772 ch = sunrpc_cache_update(&svc_export_cache, &new->h,
767 &old->h, 773 &old->h,