linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "George Spelvin" <linux@horizon.com>
To: linux-ext4@vger.kernel.org
Cc: linux@horizon.com, tytso@mit.edu
Subject: [PATCH v1 5/10] ext4: Add DX_HASH_SIPHASH24 support
Date: 23 Sep 2014 06:16:12 -0400	[thread overview]
Message-ID: <20140923101612.930.qmail@ns.horizon.com> (raw)
In-Reply-To: <20140923100214.26896.qmail@ns.horizon.com>

This uses SipHash-2-4 for directory hashing.

Signed-off-by: George Spelvin <linux@horizon.com>
---
The actual feature.  Pretty simple, no?

 fs/ext4/ext4.h  | 3 ++-
 fs/ext4/hash.c  | 6 ++++++
 fs/ext4/namei.c | 3 ++-
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index cda8dd9c..13420bd4 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1737,6 +1737,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
 #define DX_HASH_LEGACY		0
 #define DX_HASH_HALF_MD4	1
 #define DX_HASH_TEA		2
+#define DX_HASH_SIPHASH24	3
 
 /*
  * For historical reasons, the first three hash algorithms
@@ -1744,7 +1745,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize)
  * use only, define some extra values outside the range of
  * what's allowed on disk.
  */
-#define DX_HASH_UNSIGNED_DELTA	3
+#define DX_HASH_UNSIGNED_DELTA	4
 
 #define DX_HASH_LEGACY_UNSIGNED   (DX_HASH_LEGACY   + DX_HASH_UNSIGNED_DELTA)
 #define DX_HASH_HALF_MD4_UNSIGNED (DX_HASH_HALF_MD4 + DX_HASH_UNSIGNED_DELTA)
diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index 5186e09a..584639f4 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -140,6 +140,7 @@ int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
 {
 	__u32	hash;
 	__u32	minor_hash = 0;
+	__u64	hash64;
 	int	i;
 	__u32	in[8], buf[4];
 	void	(*str2hashbuf)(const char *, int, __u32 *, int) =
@@ -192,6 +193,11 @@ int ext4fs_dirhash(const char *name, int len, struct dx_hash_info *hinfo)
 		hash = buf[0];
 		minor_hash = buf[1];
 		break;
+	case DX_HASH_SIPHASH24:
+		hash64 = siphash24(name, len, hinfo->seed);
+		hash = (__u32)hash64;
+		minor_hash = hash64 >> 32;
+		break;
 	default:
 		hinfo->hash = 0;
 		return -1;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 9e6eced1..922d6b48 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -685,7 +685,8 @@ dx_probe(const struct qstr *d_name, struct inode *dir,
 		goto fail;
 	}
 	root = (struct dx_root *) bh->b_data;
-	if (root->info.hash_version != DX_HASH_TEA &&
+	if (root->info.hash_version != DX_HASH_SIPHASH24 &&
+	    root->info.hash_version != DX_HASH_TEA &&
 	    root->info.hash_version != DX_HASH_HALF_MD4 &&
 	    root->info.hash_version != DX_HASH_LEGACY) {
 		ext4_warning(dir->i_sb, "Unrecognised inode hash code %d",
-- 
2.1.0


  parent reply	other threads:[~2014-09-23 10:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 10:02 [PATCH v1 0/10] Add SipHash-2-4 directory hashing support George Spelvin
2014-09-23 10:03 ` patch V1 1/10] ex4: Introduce DX_HASH_UNSIGNED_DELTA George Spelvin
2014-09-23 21:06   ` [PATCH v1.1 1/10] ext4: " George Spelvin
2014-09-23 10:05 ` [PATCH v1 2/10] ext4: Remove redundant local variable p from ext4fs_dirhash George Spelvin
2014-09-23 10:10 ` [PATCH v1 3/10] byteorder: Fix some erroneous comments George Spelvin
2014-09-23 10:14 ` [PATCH v1 4/10] lib/siphash.c: New file George Spelvin
2014-09-29 19:12   ` Darrick J. Wong
2014-12-06 23:32     ` George Spelvin
2014-12-08 13:16       ` Theodore Ts'o
2014-09-23 10:16 ` George Spelvin [this message]
2014-09-23 19:12   ` [PATCH v1 5/10] ext4: Add DX_HASH_SIPHASH24 support Andreas Dilger
2014-09-23 20:45     ` George Spelvin
2014-09-24  1:47       ` Theodore Ts'o
2014-09-24  3:08         ` George Spelvin
2014-09-24 15:35           ` Theodore Ts'o
2014-09-24 23:31             ` George Spelvin
2014-09-25  2:36               ` Theodore Ts'o
2014-09-23 10:17 ` [PATCH v1 6/10] Add EXT2_HASH_UNSIGNED instead of magic constant 3 George Spelvin
2014-09-23 10:19 ` [PATCH v1 7/10] dirhash.c (ext2fs_dirhash): Remove redundant local variable p George Spelvin
2014-09-23 10:27 ` [PATCH v1 8/10] dirhash.c: Add siphash24() George Spelvin
2014-09-23 10:29 ` [PATCH v1 9/10] Add EXT2_HASH_SIPHASH24 (=3) George Spelvin
2014-09-23 10:31 ` [PATCH v1 10/10] Add "hash_alg=siphash" support George Spelvin
2014-09-29 19:24   ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140923101612.930.qmail@ns.horizon.com \
    --to=linux@horizon.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).