Skip to content

Commit c6cf726

Browse files
committed
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>
1 parent 1bdb70e commit c6cf726

6 files changed

Lines changed: 107 additions & 96 deletions

File tree

‎fs/ceph/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ceph-objs := super.o inode.o dir.o file.o addr.o ioctl.o \
1111
messenger.o msgpool.o buffer.o \
1212
mds_client.o mdsmap.o \
1313
mon_client.o \
14-
osd_client.o osdmap.o crush/crush.o crush/mapper.o \
14+
osd_client.o osdmap.o crush/crush.o crush/mapper.o crush/hash.o \
1515
debugfs.o \
1616
ceph_fs.o ceph_strings.o ceph_frag.o
1717

‎fs/ceph/README‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ src/crush/crush.h fs/ceph/crush/crush.h
1515
src/crush/mapper.c fs/ceph/crush/mapper.c
1616
src/crush/mapper.h fs/ceph/crush/mapper.h
1717
src/crush/hash.h fs/ceph/crush/hash.h
18+
src/crush/hash.c fs/ceph/crush/hash.c

‎fs/ceph/crush/crush.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010

1111
#include "crush.h"
1212

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+
1324
/**
1425
* crush_get_bucket_item_weight - Get weight of an item in given bucket
1526
* @b: bucket pointer

‎fs/ceph/crush/crush.h‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,7 @@ enum {
9797
CRUSH_BUCKET_TREE = 3,
9898
CRUSH_BUCKET_STRAW = 4
9999
};
100-
static inline 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-
}
100+
extern const char *crush_bucket_alg_name(int alg);
110101

111102
struct crush_bucket {
112103
__s32 id; /* this'll be negative */

‎fs/ceph/crush/hash.c‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

‎fs/ceph/crush/hash.h‎

Lines changed: 7 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,12 @@
11
#ifndef _CRUSH_HASH_H
22
#define _CRUSH_HASH_H
33

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-
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-
}
4+
extern __u32 crush_hash32(__u32 a);
5+
extern __u32 crush_hash32_2(__u32 a, __u32 b);
6+
extern __u32 crush_hash32_3(__u32 a, __u32 b, __u32 c);
7+
extern __u32 crush_hash32_4(__u32 a, __u32 b, __u32 c,
8+
__u32 d);
9+
extern __u32 crush_hash32_5(__u32 a, __u32 b, __u32 c,
10+
__u32 d, __u32 e);
8911

9012
#endif

0 commit comments

Comments
 (0)