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>
This commit is contained in:
Родитель
d202cce896
Коммит
61f8603d93
|
@ -258,10 +258,9 @@ static struct cache_detail svc_expkey_cache = {
|
||||||
.alloc = expkey_alloc,
|
.alloc = expkey_alloc,
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct svc_expkey *
|
static int
|
||||||
svc_expkey_lookup(struct svc_expkey *item)
|
svc_expkey_hash(struct svc_expkey *item)
|
||||||
{
|
{
|
||||||
struct cache_head *ch;
|
|
||||||
int hash = item->ek_fsidtype;
|
int hash = item->ek_fsidtype;
|
||||||
char * cp = (char*)item->ek_fsid;
|
char * cp = (char*)item->ek_fsid;
|
||||||
int len = key_len(item->ek_fsidtype);
|
int len = key_len(item->ek_fsidtype);
|
||||||
|
@ -269,6 +268,14 @@ svc_expkey_lookup(struct svc_expkey *item)
|
||||||
hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
|
hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
|
||||||
hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS);
|
hash ^= hash_ptr(item->ek_client, EXPKEY_HASHBITS);
|
||||||
hash &= EXPKEY_HASHMASK;
|
hash &= EXPKEY_HASHMASK;
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct svc_expkey *
|
||||||
|
svc_expkey_lookup(struct svc_expkey *item)
|
||||||
|
{
|
||||||
|
struct cache_head *ch;
|
||||||
|
int hash = svc_expkey_hash(item);
|
||||||
|
|
||||||
ch = sunrpc_cache_lookup(&svc_expkey_cache, &item->h,
|
ch = sunrpc_cache_lookup(&svc_expkey_cache, &item->h,
|
||||||
hash);
|
hash);
|
||||||
|
@ -282,13 +289,7 @@ static struct svc_expkey *
|
||||||
svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
|
svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
|
||||||
{
|
{
|
||||||
struct cache_head *ch;
|
struct cache_head *ch;
|
||||||
int hash = new->ek_fsidtype;
|
int hash = svc_expkey_hash(new);
|
||||||
char * cp = (char*)new->ek_fsid;
|
|
||||||
int len = key_len(new->ek_fsidtype);
|
|
||||||
|
|
||||||
hash ^= hash_mem(cp, len, EXPKEY_HASHBITS);
|
|
||||||
hash ^= hash_ptr(new->ek_client, EXPKEY_HASHBITS);
|
|
||||||
hash &= EXPKEY_HASHMASK;
|
|
||||||
|
|
||||||
ch = sunrpc_cache_update(&svc_expkey_cache, &new->h,
|
ch = sunrpc_cache_update(&svc_expkey_cache, &new->h,
|
||||||
&old->h, hash);
|
&old->h, hash);
|
||||||
|
@ -737,14 +738,22 @@ struct cache_detail svc_export_cache = {
|
||||||
.alloc = svc_export_alloc,
|
.alloc = svc_export_alloc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int
|
||||||
|
svc_export_hash(struct svc_export *exp)
|
||||||
|
{
|
||||||
|
int hash;
|
||||||
|
|
||||||
|
hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
|
||||||
|
hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS);
|
||||||
|
hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
|
||||||
static struct svc_export *
|
static struct svc_export *
|
||||||
svc_export_lookup(struct svc_export *exp)
|
svc_export_lookup(struct svc_export *exp)
|
||||||
{
|
{
|
||||||
struct cache_head *ch;
|
struct cache_head *ch;
|
||||||
int hash;
|
int hash = svc_export_hash(exp);
|
||||||
hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
|
|
||||||
hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS);
|
|
||||||
hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS);
|
|
||||||
|
|
||||||
ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
|
ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
|
||||||
hash);
|
hash);
|
||||||
|
@ -758,10 +767,7 @@ static struct svc_export *
|
||||||
svc_export_update(struct svc_export *new, struct svc_export *old)
|
svc_export_update(struct svc_export *new, struct svc_export *old)
|
||||||
{
|
{
|
||||||
struct cache_head *ch;
|
struct cache_head *ch;
|
||||||
int hash;
|
int hash = svc_export_hash(old);
|
||||||
hash = hash_ptr(old->ex_client, EXPORT_HASHBITS);
|
|
||||||
hash ^= hash_ptr(old->ex_path.dentry, EXPORT_HASHBITS);
|
|
||||||
hash ^= hash_ptr(old->ex_path.mnt, EXPORT_HASHBITS);
|
|
||||||
|
|
||||||
ch = sunrpc_cache_update(&svc_export_cache, &new->h,
|
ch = sunrpc_cache_update(&svc_export_cache, &new->h,
|
||||||
&old->h,
|
&old->h,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче