Skip to content

Commit 830f111

Browse files
author
Trond Myklebust
committed
NFS: Replace readdir's use of xxhash() with hash_64()
Both xxhash() and hash_64() appear to give similarly low collision rates with a standard linearly increasing readdir offset. They both give similarly higher collision rates when applied to ext4's offsets. So switch to using the standard hash_64(). Signed-off-by: Trond Myklebust <[email protected]>
1 parent eb07d5a commit 830f111

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

fs/nfs/Kconfig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ config NFS_FS
44
depends on INET && FILE_LOCKING && MULTIUSER
55
select LOCKD
66
select SUNRPC
7-
select CRYPTO
8-
select CRYPTO_HASH
9-
select XXHASH
10-
select CRYPTO_XXHASH
117
select NFS_ACL_SUPPORT if NFS_V3_ACL
128
help
139
Choose Y here if you want to access files residing on other

fs/nfs/dir.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <linux/sched.h>
4040
#include <linux/kmemleak.h>
4141
#include <linux/xattr.h>
42-
#include <linux/xxhash.h>
42+
#include <linux/hash.h>
4343

4444
#include "delegation.h"
4545
#include "iostat.h"
@@ -350,10 +350,7 @@ static int nfs_readdir_page_array_append(struct page *page,
350350
* of directory cookies. Content is addressed by the value of the
351351
* cookie index of the first readdir entry in a page.
352352
*
353-
* The xxhash algorithm is chosen because it is fast, and is supposed
354-
* to result in a decent flat distribution of hashes.
355-
*
356-
* We then select only the first 18 bits to avoid issues with excessive
353+
* We select only the first 18 bits to avoid issues with excessive
357354
* memory use for the page cache XArray. 18 bits should allow the caching
358355
* of 262144 pages of sequences of readdir entries. Since each page holds
359356
* 127 readdir entries for a typical 64-bit system, that works out to a
@@ -363,7 +360,7 @@ static pgoff_t nfs_readdir_page_cookie_hash(u64 cookie)
363360
{
364361
if (cookie == 0)
365362
return 0;
366-
return xxhash(&cookie, sizeof(cookie), 0) & NFS_READDIR_COOKIE_MASK;
363+
return hash_64(cookie, 18);
367364
}
368365

369366
static bool nfs_readdir_page_validate(struct page *page, u64 last_cookie,

0 commit comments

Comments
 (0)