Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
linux
Commits
ec6867b3
Commit
ec6867b3
authored
Jan 05, 2003
by
Neil Brown
Committed by
Linus Torvalds
Jan 05, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] knfsd: Use hash_long from hash.h for hashing in rpc/svc caches.
It works much better than my little toy hash functions.
parent
bb1eb94c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
25 deletions
+33
-25
fs/nfsd/export.c
fs/nfsd/export.c
+10
-17
include/linux/sunrpc/svcauth.h
include/linux/sunrpc/svcauth.h
+5
-1
net/sunrpc/svcauth.c
net/sunrpc/svcauth.c
+15
-6
net/sunrpc/svcauth_unix.c
net/sunrpc/svcauth_unix.c
+3
-1
No files found.
fs/nfsd/export.c
View file @
ec6867b3
...
...
@@ -24,6 +24,7 @@
#include <linux/dcache.h>
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/hash.h>
#include <linux/sunrpc/svc.h>
#include <linux/nfsd/nfsd.h>
...
...
@@ -59,12 +60,9 @@ static inline int svc_expkey_hash(struct svc_expkey *item)
int
hash
=
item
->
ek_fsidtype
;
char
*
cp
=
(
char
*
)
item
->
ek_fsid
;
int
len
=
(
item
->
ek_fsidtype
==
0
)
?
8
:
4
;
while
(
len
--
)
hash
+=
*
cp
++
;
cp
=
(
char
*
)
&
item
->
ek_client
;
len
=
sizeof
(
item
->
ek_client
);
while
(
len
--
)
hash
+=
*
cp
++
;
hash
^=
hash_mem
(
cp
,
len
,
EXPKEY_HASHBITS
);
hash
^=
hash_ptr
(
item
->
ek_client
,
EXPKEY_HASHBITS
);
return
hash
&
EXPKEY_HASHMASK
;
}
...
...
@@ -239,17 +237,12 @@ static struct cache_head *export_table[EXPORT_HASHMAX];
static
inline
int
svc_export_hash
(
struct
svc_export
*
item
)
{
void
*
k
[
2
];
unsigned
char
*
cp
;
int
rv
,
i
;
k
[
0
]
=
item
->
ex_client
;
k
[
1
]
=
item
->
ex_dentry
;
cp
=
(
char
*
)
k
;
rv
=
0
;
for
(
i
=
0
;
i
<
sizeof
(
k
);
i
++
)
rv
^=
cp
[
i
];
return
rv
&
EXPORT_HASHMASK
;
int
rv
;
rv
=
hash_ptr
(
item
->
ex_client
,
EXPORT_HASHBITS
);
rv
^=
hash_ptr
(
item
->
ex_dentry
,
EXPORT_HASHBITS
);
rv
^=
hash_ptr
(
item
->
ex_mnt
,
EXPORT_HASHBITS
);
return
rv
;
}
void
svc_export_put
(
struct
cache_head
*
item
,
struct
cache_detail
*
cd
)
...
...
include/linux/sunrpc/svcauth.h
View file @
ec6867b3
...
...
@@ -111,7 +111,11 @@ extern struct auth_domain *auth_unix_lookup(struct in_addr addr);
extern
int
auth_unix_forget_old
(
struct
auth_domain
*
dom
);
extern
void
svcauth_unix_purge
(
void
);
extern
int
name_hash
(
char
*
name
,
int
size
);
extern
int
hash_mem
(
char
*
buf
,
int
len
,
int
bits
);
static
inline
int
hash_str
(
char
*
name
,
int
bits
)
{
return
hash_mem
(
name
,
strlen
(
name
),
bits
);
}
extern
struct
cache_detail
auth_domain_cache
,
ip_map_cache
;
...
...
net/sunrpc/svcauth.c
View file @
ec6867b3
...
...
@@ -16,6 +16,7 @@
#include <linux/sunrpc/svcsock.h>
#include <linux/sunrpc/svcauth.h>
#include <linux/err.h>
#include <linux/hash.h>
#define RPCDBG_FACILITY RPCDBG_AUTH
...
...
@@ -111,14 +112,22 @@ svc_auth_unregister(rpc_authflavor_t flavor)
* it will complain.
*/
int
name_hash
(
char
*
name
,
int
size
)
int
hash_mem
(
char
*
buf
,
int
len
,
int
bits
)
{
int
hash
=
0
;
while
(
*
name
)
{
hash
+=
*
name
;
name
++
;
unsigned
long
l
;
while
(
len
>=
BITS_PER_LONG
/
8
)
{
l
=
*
(
unsigned
long
*
)
buf
;
buf
+=
BITS_PER_LONG
/
8
;
len
-=
BITS_PER_LONG
/
8
;
hash
^=
hash_long
(
l
,
bits
);
}
return
hash
%
size
;
if
(
len
)
{
l
=
0
;
memcpy
((
char
*
)
&
l
,
buf
,
len
);
hash
^=
hash_long
(
l
,
bits
);
}
return
hash
;
}
...
...
@@ -161,7 +170,7 @@ void auth_domain_put(struct auth_domain *dom)
static
inline
int
auth_domain_hash
(
struct
auth_domain
*
item
)
{
return
name_hash
(
item
->
name
,
DN_HASHMAX
);
return
hash_str
(
item
->
name
,
DN_HASHBITS
);
}
static
inline
int
auth_domain_match
(
struct
auth_domain
*
tmp
,
struct
auth_domain
*
item
)
{
...
...
net/sunrpc/svcauth_unix.c
View file @
ec6867b3
...
...
@@ -6,6 +6,7 @@
#include <linux/sunrpc/svcauth.h>
#include <linux/err.h>
#include <linux/seq_file.h>
#include <linux/hash.h>
#define RPCDBG_FACILITY RPCDBG_AUTH
...
...
@@ -108,7 +109,8 @@ void ip_map_put(struct cache_head *item, struct cache_detail *cd)
static
inline
int
ip_map_hash
(
struct
ip_map
*
item
)
{
return
(
name_hash
(
item
->
m_class
,
IP_HASHMAX
)
^
item
->
m_addr
.
s_addr
)
&
IP_HASHMASK
;
return
hash_str
(
item
->
m_class
,
IP_HASHBITS
)
^
hash_long
((
unsigned
long
)
item
->
m_addr
.
s_addr
,
IP_HASHBITS
);
}
static
inline
int
ip_map_match
(
struct
ip_map
*
item
,
struct
ip_map
*
tmp
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment