diff options
author | Sage Weil <sage@newdream.net> | 2009-11-06 19:39:26 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-11-06 19:39:26 -0500 |
commit | c6cf726316abd613cfb7c325d950f3629f964ec6 (patch) | |
tree | 446a686988656a355ee7ff94a43912c94f36ac63 /fs/ceph/crush | |
parent | 1bdb70e59026838a79f77c440f8fe480a66e65e8 (diff) |
ceph: make CRUSH hash functions non-inline
These are way to big to be inline. I missed crush/* when doing the inline
audit for akpm's review.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/crush')
-rw-r--r-- | fs/ceph/crush/crush.c | 11 | ||||
-rw-r--r-- | fs/ceph/crush/crush.h | 11 | ||||
-rw-r--r-- | fs/ceph/crush/hash.c | 86 | ||||
-rw-r--r-- | fs/ceph/crush/hash.h | 92 |
4 files changed, 105 insertions, 95 deletions
diff --git a/fs/ceph/crush/crush.c b/fs/ceph/crush/crush.c index 13755cdc4fb3..fabd302e5779 100644 --- a/fs/ceph/crush/crush.c +++ b/fs/ceph/crush/crush.c | |||
@@ -10,6 +10,17 @@ | |||
10 | 10 | ||
11 | #include "crush.h" | 11 | #include "crush.h" |
12 | 12 | ||
13 | const char *crush_bucket_alg_name(int alg) | ||
14 | { | ||
15 | switch (alg) { | ||
16 | case CRUSH_BUCKET_UNIFORM: return "uniform"; | ||
17 | case CRUSH_BUCKET_LIST: return "list"; | ||
18 | case CRUSH_BUCKET_TREE: return "tree"; | ||
19 | case CRUSH_BUCKET_STRAW: return "straw"; | ||
20 | default: return "unknown"; | ||
21 | } | ||
22 | } | ||
23 | |||
13 | /** | 24 | /** |
14 | * crush_get_bucket_item_weight - Get weight of an item in given bucket | 25 | * crush_get_bucket_item_weight - Get weight of an item in given bucket |
15 | * @b: bucket pointer | 26 | * @b: bucket pointer |
diff --git a/fs/ceph/crush/crush.h b/fs/ceph/crush/crush.h index 9ac7e091126f..92c6b3c3a571 100644 --- a/fs/ceph/crush/crush.h +++ b/fs/ceph/crush/crush.h | |||
@@ -97,16 +97,7 @@ enum { | |||
97 | CRUSH_BUCKET_TREE = 3, | 97 | CRUSH_BUCKET_TREE = 3, |
98 | CRUSH_BUCKET_STRAW = 4 | 98 | CRUSH_BUCKET_STRAW = 4 |
99 | }; | 99 | }; |
100 | static inline const char *crush_bucket_alg_name(int alg) | 100 | extern const char *crush_bucket_alg_name(int alg); |
101 | { | ||
102 | switch (alg) { | ||
103 | case CRUSH_BUCKET_UNIFORM: return "uniform"; | ||
104 | case CRUSH_BUCKET_LIST: return "list"; | ||
105 | case CRUSH_BUCKET_TREE: return "tree"; | ||
106 | case CRUSH_BUCKET_STRAW: return "straw"; | ||
107 | default: return "unknown"; | ||
108 | } | ||
109 | } | ||
110 | 101 | ||
111 | struct crush_bucket { | 102 | struct crush_bucket { |
112 | __s32 id; /* this'll be negative */ | 103 | __s32 id; /* this'll be negative */ |
diff --git a/fs/ceph/crush/hash.c b/fs/ceph/crush/hash.c new file mode 100644 index 000000000000..b438c5d27816 --- /dev/null +++ b/fs/ceph/crush/hash.c | |||
@@ -0,0 +1,86 @@ | |||
1 | |||
2 | #include <linux/types.h> | ||
3 | |||
4 | /* | ||
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 | ||
8 | */ | ||
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); \ | ||
19 | } while (0) | ||
20 | |||
21 | #define crush_hash_seed 1315423911 | ||
22 | |||
23 | __u32 crush_hash32(__u32 a) | ||
24 | { | ||
25 | __u32 hash = crush_hash_seed ^ a; | ||
26 | __u32 b = a; | ||
27 | __u32 x = 231232; | ||
28 | __u32 y = 1232; | ||
29 | crush_hashmix(b, x, hash); | ||
30 | crush_hashmix(y, a, hash); | ||
31 | return hash; | ||
32 | } | ||
33 | |||
34 | __u32 crush_hash32_2(__u32 a, __u32 b) | ||
35 | { | ||
36 | __u32 hash = crush_hash_seed ^ a ^ b; | ||
37 | __u32 x = 231232; | ||
38 | __u32 y = 1232; | ||
39 | crush_hashmix(a, b, hash); | ||
40 | crush_hashmix(x, a, hash); | ||
41 | crush_hashmix(b, y, hash); | ||
42 | return hash; | ||
43 | } | ||
44 | |||
45 | __u32 crush_hash32_3(__u32 a, __u32 b, __u32 c) | ||
46 | { | ||
47 | __u32 hash = crush_hash_seed ^ a ^ b ^ c; | ||
48 | __u32 x = 231232; | ||
49 | __u32 y = 1232; | ||
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); | ||
55 | return hash; | ||
56 | } | ||
57 | |||
58 | __u32 crush_hash32_4(__u32 a, __u32 b, __u32 c, __u32 d) | ||
59 | { | ||
60 | __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d; | ||
61 | __u32 x = 231232; | ||
62 | __u32 y = 1232; | ||
63 | crush_hashmix(a, b, hash); | ||
64 | crush_hashmix(c, d, hash); | ||
65 | crush_hashmix(a, x, hash); | ||
66 | crush_hashmix(y, b, hash); | ||
67 | crush_hashmix(c, x, hash); | ||
68 | crush_hashmix(y, d, hash); | ||
69 | return hash; | ||
70 | } | ||
71 | |||
72 | __u32 crush_hash32_5(__u32 a, __u32 b, __u32 c, __u32 d, __u32 e) | ||
73 | { | ||
74 | __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d ^ e; | ||
75 | __u32 x = 231232; | ||
76 | __u32 y = 1232; | ||
77 | crush_hashmix(a, b, hash); | ||
78 | crush_hashmix(c, d, hash); | ||
79 | crush_hashmix(e, x, hash); | ||
80 | crush_hashmix(y, a, hash); | ||
81 | crush_hashmix(b, x, hash); | ||
82 | crush_hashmix(y, c, hash); | ||
83 | crush_hashmix(d, x, hash); | ||
84 | crush_hashmix(y, e, hash); | ||
85 | return hash; | ||
86 | } | ||
diff --git a/fs/ceph/crush/hash.h b/fs/ceph/crush/hash.h index 42f3312783a1..9ce89f85dc7d 100644 --- a/fs/ceph/crush/hash.h +++ b/fs/ceph/crush/hash.h | |||
@@ -1,90 +1,12 @@ | |||
1 | #ifndef _CRUSH_HASH_H | 1 | #ifndef _CRUSH_HASH_H |
2 | #define _CRUSH_HASH_H | 2 | #define _CRUSH_HASH_H |
3 | 3 | ||
4 | /* | 4 | extern __u32 crush_hash32(__u32 a); |
5 | * Robert Jenkins' function for mixing 32-bit values | 5 | extern __u32 crush_hash32_2(__u32 a, __u32 b); |
6 | * http://burtleburtle.net/bob/hash/evahash.html | 6 | extern __u32 crush_hash32_3(__u32 a, __u32 b, __u32 c); |
7 | * a, b = random bits, c = input and output | 7 | extern __u32 crush_hash32_4(__u32 a, __u32 b, __u32 c, |
8 | */ | 8 | __u32 d); |
9 | #define crush_hashmix(a, b, c) do { \ | 9 | extern __u32 crush_hash32_5(__u32 a, __u32 b, __u32 c, |
10 | a = a-b; a = a-c; a = a^(c>>13); \ | 10 | __u32 d, __u32 e); |
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); \ | ||
19 | } while (0) | ||
20 | |||
21 | #define crush_hash_seed 1315423911 | ||
22 | |||
23 | static inline __u32 crush_hash32(__u32 a) | ||
24 | { | ||
25 | __u32 hash = crush_hash_seed ^ a; | ||
26 | __u32 b = a; | ||
27 | __u32 x = 231232; | ||
28 | __u32 y = 1232; | ||
29 | crush_hashmix(b, x, hash); | ||
30 | crush_hashmix(y, a, hash); | ||
31 | return hash; | ||
32 | } | ||
33 | |||
34 | static inline __u32 crush_hash32_2(__u32 a, __u32 b) | ||
35 | { | ||
36 | __u32 hash = crush_hash_seed ^ a ^ b; | ||
37 | __u32 x = 231232; | ||
38 | __u32 y = 1232; | ||
39 | crush_hashmix(a, b, hash); | ||
40 | crush_hashmix(x, a, hash); | ||
41 | crush_hashmix(b, y, hash); | ||
42 | return hash; | ||
43 | } | ||
44 | |||
45 | static inline __u32 crush_hash32_3(__u32 a, __u32 b, __u32 c) | ||
46 | { | ||
47 | __u32 hash = crush_hash_seed ^ a ^ b ^ c; | ||
48 | __u32 x = 231232; | ||
49 | __u32 y = 1232; | ||
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); | ||
55 | return hash; | ||
56 | } | ||
57 | |||
58 | static inline __u32 crush_hash32_4(__u32 a, __u32 b, __u32 c, | ||
59 | __u32 d) | ||
60 | { | ||
61 | __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d; | ||
62 | __u32 x = 231232; | ||
63 | __u32 y = 1232; | ||
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); | ||
70 | return hash; | ||
71 | } | ||
72 | |||
73 | static inline __u32 crush_hash32_5(__u32 a, __u32 b, __u32 c, | ||
74 | __u32 d, __u32 e) | ||
75 | { | ||
76 | __u32 hash = crush_hash_seed ^ a ^ b ^ c ^ d ^ e; | ||
77 | __u32 x = 231232; | ||
78 | __u32 y = 1232; | ||
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); | ||
87 | return hash; | ||
88 | } | ||
89 | 11 | ||
90 | #endif | 12 | #endif |