]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - fs/ceph/crush/hash.h
42f3312783a1070d7aeeaba55ccf1fef8fe8b41e
5 * Robert Jenkins' function for mixing 32-bit values
6 * http://burtleburtle.net/bob/hash/evahash.html
7 * a, b = random bits, c = input and output
9 #define crush_hashmix(a, b, c) do { \
10 a = a-b; a = a-c; a = a^(c>>13); \
11 b = b-c; b = b-a; b = b^(a<<8); \
12 c = c-a; c = c-b; c = c^(b>>13); \
13 a = a-b; a = a-c; a = a^(c>>12); \
14 b = b-c; b = b-a; b = b^(a<<16); \
15 c = c-a; c = c-b; c = c^(b>>5); \
16 a = a-b; a = a-c; a = a^(c>>3); \
17 b = b-c; b = b-a; b = b^(a<<10); \
18 c = c-a; c = c-b; c = c^(b>>15); \
21 #define crush_hash_seed 1315423911
23 static inline __u32
crush_hash32(__u32 a
)
25 __u32 hash
= crush_hash_seed
^ a
;
29 crush_hashmix(b
, x
, hash
);
30 crush_hashmix(y
, a
, hash
);
34 static inline __u32
crush_hash32_2(__u32 a
, __u32 b
)
36 __u32 hash
= crush_hash_seed
^ a
^ b
;
39 crush_hashmix(a
, b
, hash
);
40 crush_hashmix(x
, a
, hash
);
41 crush_hashmix(b
, y
, hash
);
45 static inline __u32
crush_hash32_3(__u32 a
, __u32 b
, __u32 c
)
47 __u32 hash
= crush_hash_seed
^ a
^ b
^ c
;
50 crush_hashmix(a
, b
, hash
);
51 crush_hashmix(c
, x
, hash
);
52 crush_hashmix(y
, a
, hash
);
53 crush_hashmix(b
, x
, hash
);
54 crush_hashmix(y
, c
, hash
);
58 static inline __u32
crush_hash32_4(__u32 a
, __u32 b
, __u32 c
,
61 __u32 hash
= crush_hash_seed
^ a
^ b
^ c
^ d
;
64 crush_hashmix(a
, b
, hash
);
65 crush_hashmix(c
, d
, hash
);
66 crush_hashmix(a
, x
, hash
);
67 crush_hashmix(y
, b
, hash
);
68 crush_hashmix(c
, x
, hash
);
69 crush_hashmix(y
, d
, hash
);
73 static inline __u32
crush_hash32_5(__u32 a
, __u32 b
, __u32 c
,
76 __u32 hash
= crush_hash_seed
^ a
^ b
^ c
^ d
^ e
;
79 crush_hashmix(a
, b
, hash
);
80 crush_hashmix(c
, d
, hash
);
81 crush_hashmix(e
, x
, hash
);
82 crush_hashmix(y
, a
, hash
);
83 crush_hashmix(b
, x
, hash
);
84 crush_hashmix(y
, c
, hash
);
85 crush_hashmix(d
, x
, hash
);
86 crush_hashmix(y
, e
, hash
);