diff options
author | Sage Weil <sage@newdream.net> | 2009-11-07 00:55:25 -0500 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2009-11-07 00:55:25 -0500 |
commit | 1654dd0cf5ee1827322aca156af7d96d757201c7 (patch) | |
tree | ba71b1a1e214b929937f02a1794b3d32b8ff1342 /fs/ceph/ceph_fs.c | |
parent | cfbbcd24a6bfd794295ee7ad76dfbff40ad6b934 (diff) |
ceph: make object hash a pg_pool property
The object will be hashed to a placement seed (ps) based on the pg_pool's
hash function. This allows new hashes to be introduced into an existing
object store, or selection of a hash appropriate to the objects that
will be stored in a particular pool.
Signed-off-by: Sage Weil <sage@newdream.net>
Diffstat (limited to 'fs/ceph/ceph_fs.c')
-rw-r--r-- | fs/ceph/ceph_fs.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/fs/ceph/ceph_fs.c b/fs/ceph/ceph_fs.c index b3ecf1b07521..79d76bc4303f 100644 --- a/fs/ceph/ceph_fs.c +++ b/fs/ceph/ceph_fs.c | |||
@@ -72,80 +72,3 @@ int ceph_caps_for_mode(int mode) | |||
72 | } | 72 | } |
73 | return 0; | 73 | return 0; |
74 | } | 74 | } |
75 | |||
76 | /* | ||
77 | * Robert Jenkin's hash function. | ||
78 | * http://burtleburtle.net/bob/hash/evahash.html | ||
79 | * This is in the public domain. | ||
80 | */ | ||
81 | #define mix(a, b, c) \ | ||
82 | do { \ | ||
83 | a = a - b; a = a - c; a = a ^ (c >> 13); \ | ||
84 | b = b - c; b = b - a; b = b ^ (a << 8); \ | ||
85 | c = c - a; c = c - b; c = c ^ (b >> 13); \ | ||
86 | a = a - b; a = a - c; a = a ^ (c >> 12); \ | ||
87 | b = b - c; b = b - a; b = b ^ (a << 16); \ | ||
88 | c = c - a; c = c - b; c = c ^ (b >> 5); \ | ||
89 | a = a - b; a = a - c; a = a ^ (c >> 3); \ | ||
90 | b = b - c; b = b - a; b = b ^ (a << 10); \ | ||
91 | c = c - a; c = c - b; c = c ^ (b >> 15); \ | ||
92 | } while (0) | ||
93 | |||
94 | unsigned int ceph_full_name_hash(const char *str, unsigned int length) | ||
95 | { | ||
96 | const unsigned char *k = (const unsigned char *)str; | ||
97 | __u32 a, b, c; /* the internal state */ | ||
98 | __u32 len; /* how many key bytes still need mixing */ | ||
99 | |||
100 | /* Set up the internal state */ | ||
101 | len = length; | ||
102 | a = 0x9e3779b9; /* the golden ratio; an arbitrary value */ | ||
103 | b = a; | ||
104 | c = 0; /* variable initialization of internal state */ | ||
105 | |||
106 | /* handle most of the key */ | ||
107 | while (len >= 12) { | ||
108 | a = a + (k[0] + ((__u32)k[1] << 8) + ((__u32)k[2] << 16) + | ||
109 | ((__u32)k[3] << 24)); | ||
110 | b = b + (k[4] + ((__u32)k[5] << 8) + ((__u32)k[6] << 16) + | ||
111 | ((__u32)k[7] << 24)); | ||
112 | c = c + (k[8] + ((__u32)k[9] << 8) + ((__u32)k[10] << 16) + | ||
113 | ((__u32)k[11] << 24)); | ||
114 | mix(a, b, c); | ||
115 | k = k + 12; | ||
116 | len = len - 12; | ||
117 | } | ||
118 | |||
119 | /* handle the last 11 bytes */ | ||
120 | c = c + length; | ||
121 | switch (len) { /* all the case statements fall through */ | ||
122 | case 11: | ||
123 | c = c + ((__u32)k[10] << 24); | ||
124 | case 10: | ||
125 | c = c + ((__u32)k[9] << 16); | ||
126 | case 9: | ||
127 | c = c + ((__u32)k[8] << 8); | ||
128 | /* the first byte of c is reserved for the length */ | ||
129 | case 8: | ||
130 | b = b + ((__u32)k[7] << 24); | ||
131 | case 7: | ||
132 | b = b + ((__u32)k[6] << 16); | ||
133 | case 6: | ||
134 | b = b + ((__u32)k[5] << 8); | ||
135 | case 5: | ||
136 | b = b + k[4]; | ||
137 | case 4: | ||
138 | a = a + ((__u32)k[3] << 24); | ||
139 | case 3: | ||
140 | a = a + ((__u32)k[2] << 16); | ||
141 | case 2: | ||
142 | a = a + ((__u32)k[1] << 8); | ||
143 | case 1: | ||
144 | a = a + k[0]; | ||
145 | /* case 0: nothing left to add */ | ||
146 | } | ||
147 | mix(a, b, c); | ||
148 | |||
149 | return c; | ||
150 | } | ||
151 | |||