aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/crush/crush.h2
-rw-r--r--include/linux/crush/mapper.h6
-rw-r--r--net/ceph/crush/crush.c8
-rw-r--r--net/ceph/crush/mapper.c31
4 files changed, 24 insertions, 23 deletions
diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h
index 97e435b191f4..3f50369a50e8 100644
--- a/include/linux/crush/crush.h
+++ b/include/linux/crush/crush.h
@@ -168,7 +168,7 @@ struct crush_map {
168 168
169 169
170/* crush.c */ 170/* crush.c */
171extern int crush_get_bucket_item_weight(struct crush_bucket *b, int pos); 171extern int crush_get_bucket_item_weight(const struct crush_bucket *b, int pos);
172extern void crush_calc_parents(struct crush_map *map); 172extern void crush_calc_parents(struct crush_map *map);
173extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b); 173extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
174extern void crush_destroy_bucket_list(struct crush_bucket_list *b); 174extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
diff --git a/include/linux/crush/mapper.h b/include/linux/crush/mapper.h
index c46b99c18bb0..9322ab8bccd8 100644
--- a/include/linux/crush/mapper.h
+++ b/include/linux/crush/mapper.h
@@ -10,11 +10,11 @@
10 10
11#include "crush.h" 11#include "crush.h"
12 12
13extern int crush_find_rule(struct crush_map *map, int pool, int type, int size); 13extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size);
14extern int crush_do_rule(struct crush_map *map, 14extern int crush_do_rule(const struct crush_map *map,
15 int ruleno, 15 int ruleno,
16 int x, int *result, int result_max, 16 int x, int *result, int result_max,
17 int forcefeed, /* -1 for none */ 17 int forcefeed, /* -1 for none */
18 __u32 *weights); 18 const __u32 *weights);
19 19
20#endif 20#endif
diff --git a/net/ceph/crush/crush.c b/net/ceph/crush/crush.c
index d6ebb13a18a4..8dd19a0deedc 100644
--- a/net/ceph/crush/crush.c
+++ b/net/ceph/crush/crush.c
@@ -26,9 +26,9 @@ const char *crush_bucket_alg_name(int alg)
26 * @b: bucket pointer 26 * @b: bucket pointer
27 * @p: item index in bucket 27 * @p: item index in bucket
28 */ 28 */
29int crush_get_bucket_item_weight(struct crush_bucket *b, int p) 29int crush_get_bucket_item_weight(const struct crush_bucket *b, int p)
30{ 30{
31 if (p >= b->size) 31 if ((__u32)p >= b->size)
32 return 0; 32 return 0;
33 33
34 switch (b->alg) { 34 switch (b->alg) {
@@ -124,10 +124,9 @@ void crush_destroy_bucket(struct crush_bucket *b)
124 */ 124 */
125void crush_destroy(struct crush_map *map) 125void crush_destroy(struct crush_map *map)
126{ 126{
127 int b;
128
129 /* buckets */ 127 /* buckets */
130 if (map->buckets) { 128 if (map->buckets) {
129 __s32 b;
131 for (b = 0; b < map->max_buckets; b++) { 130 for (b = 0; b < map->max_buckets; b++) {
132 if (map->buckets[b] == NULL) 131 if (map->buckets[b] == NULL)
133 continue; 132 continue;
@@ -138,6 +137,7 @@ void crush_destroy(struct crush_map *map)
138 137
139 /* rules */ 138 /* rules */
140 if (map->rules) { 139 if (map->rules) {
140 __u32 b;
141 for (b = 0; b < map->max_rules; b++) 141 for (b = 0; b < map->max_rules; b++)
142 kfree(map->rules[b]); 142 kfree(map->rules[b]);
143 kfree(map->rules); 143 kfree(map->rules);
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index b79747c4b645..436102a8a461 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -32,9 +32,9 @@
32 * @type: storage ruleset type (user defined) 32 * @type: storage ruleset type (user defined)
33 * @size: output set size 33 * @size: output set size
34 */ 34 */
35int crush_find_rule(struct crush_map *map, int ruleset, int type, int size) 35int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size)
36{ 36{
37 int i; 37 __u32 i;
38 38
39 for (i = 0; i < map->max_rules; i++) { 39 for (i = 0; i < map->max_rules; i++) {
40 if (map->rules[i] && 40 if (map->rules[i] &&
@@ -72,7 +72,7 @@ static int bucket_perm_choose(struct crush_bucket *bucket,
72 unsigned i, s; 72 unsigned i, s;
73 73
74 /* start a new permutation if @x has changed */ 74 /* start a new permutation if @x has changed */
75 if (bucket->perm_x != x || bucket->perm_n == 0) { 75 if (bucket->perm_x != (__u32)x || bucket->perm_n == 0) {
76 dprintk("bucket %d new x=%d\n", bucket->id, x); 76 dprintk("bucket %d new x=%d\n", bucket->id, x);
77 bucket->perm_x = x; 77 bucket->perm_x = x;
78 78
@@ -219,7 +219,7 @@ static int bucket_tree_choose(struct crush_bucket_tree *bucket,
219static int bucket_straw_choose(struct crush_bucket_straw *bucket, 219static int bucket_straw_choose(struct crush_bucket_straw *bucket,
220 int x, int r) 220 int x, int r)
221{ 221{
222 int i; 222 __u32 i;
223 int high = 0; 223 int high = 0;
224 __u64 high_draw = 0; 224 __u64 high_draw = 0;
225 __u64 draw; 225 __u64 draw;
@@ -262,7 +262,7 @@ static int crush_bucket_choose(struct crush_bucket *in, int x, int r)
262 * true if device is marked "out" (failed, fully offloaded) 262 * true if device is marked "out" (failed, fully offloaded)
263 * of the cluster 263 * of the cluster
264 */ 264 */
265static int is_out(struct crush_map *map, __u32 *weight, int item, int x) 265static int is_out(const struct crush_map *map, const __u32 *weight, int item, int x)
266{ 266{
267 if (weight[item] >= 0x10000) 267 if (weight[item] >= 0x10000)
268 return 0; 268 return 0;
@@ -287,16 +287,16 @@ static int is_out(struct crush_map *map, __u32 *weight, int item, int x)
287 * @recurse_to_leaf: true if we want one device under each item of given type 287 * @recurse_to_leaf: true if we want one device under each item of given type
288 * @out2: second output vector for leaf items (if @recurse_to_leaf) 288 * @out2: second output vector for leaf items (if @recurse_to_leaf)
289 */ 289 */
290static int crush_choose(struct crush_map *map, 290static int crush_choose(const struct crush_map *map,
291 struct crush_bucket *bucket, 291 struct crush_bucket *bucket,
292 __u32 *weight, 292 const __u32 *weight,
293 int x, int numrep, int type, 293 int x, int numrep, int type,
294 int *out, int outpos, 294 int *out, int outpos,
295 int firstn, int recurse_to_leaf, 295 int firstn, int recurse_to_leaf,
296 int *out2) 296 int *out2)
297{ 297{
298 int rep; 298 int rep;
299 int ftotal, flocal; 299 unsigned int ftotal, flocal;
300 int retry_descent, retry_bucket, skip_rep; 300 int retry_descent, retry_bucket, skip_rep;
301 struct crush_bucket *in = bucket; 301 struct crush_bucket *in = bucket;
302 int r; 302 int r;
@@ -304,7 +304,7 @@ static int crush_choose(struct crush_map *map,
304 int item = 0; 304 int item = 0;
305 int itemtype; 305 int itemtype;
306 int collide, reject; 306 int collide, reject;
307 const int orig_tries = 5; /* attempts before we fall back to search */ 307 const unsigned int orig_tries = 5; /* attempts before we fall back to search */
308 308
309 dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "", 309 dprintk("CHOOSE%s bucket %d x %d outpos %d numrep %d\n", recurse_to_leaf ? "_LEAF" : "",
310 bucket->id, x, outpos, numrep); 310 bucket->id, x, outpos, numrep);
@@ -325,7 +325,7 @@ static int crush_choose(struct crush_map *map,
325 r = rep; 325 r = rep;
326 if (in->alg == CRUSH_BUCKET_UNIFORM) { 326 if (in->alg == CRUSH_BUCKET_UNIFORM) {
327 /* be careful */ 327 /* be careful */
328 if (firstn || numrep >= in->size) 328 if (firstn || (__u32)numrep >= in->size)
329 /* r' = r + f_total */ 329 /* r' = r + f_total */
330 r += ftotal; 330 r += ftotal;
331 else if (in->size % numrep == 0) 331 else if (in->size % numrep == 0)
@@ -425,7 +425,7 @@ reject:
425 /* else give up */ 425 /* else give up */
426 skip_rep = 1; 426 skip_rep = 1;
427 dprintk(" reject %d collide %d " 427 dprintk(" reject %d collide %d "
428 "ftotal %d flocal %d\n", 428 "ftotal %u flocal %u\n",
429 reject, collide, ftotal, 429 reject, collide, ftotal,
430 flocal); 430 flocal);
431 } 431 }
@@ -456,9 +456,9 @@ reject:
456 * @result_max: maximum result size 456 * @result_max: maximum result size
457 * @force: force initial replica choice; -1 for none 457 * @force: force initial replica choice; -1 for none
458 */ 458 */
459int crush_do_rule(struct crush_map *map, 459int crush_do_rule(const struct crush_map *map,
460 int ruleno, int x, int *result, int result_max, 460 int ruleno, int x, int *result, int result_max,
461 int force, __u32 *weight) 461 int force, const __u32 *weight)
462{ 462{
463 int result_len; 463 int result_len;
464 int force_context[CRUSH_MAX_DEPTH]; 464 int force_context[CRUSH_MAX_DEPTH];
@@ -473,7 +473,7 @@ int crush_do_rule(struct crush_map *map,
473 int osize; 473 int osize;
474 int *tmp; 474 int *tmp;
475 struct crush_rule *rule; 475 struct crush_rule *rule;
476 int step; 476 __u32 step;
477 int i, j; 477 int i, j;
478 int numrep; 478 int numrep;
479 int firstn; 479 int firstn;
@@ -488,7 +488,8 @@ int crush_do_rule(struct crush_map *map,
488 /* 488 /*
489 * determine hierarchical context of force, if any. note 489 * determine hierarchical context of force, if any. note
490 * that this may or may not correspond to the specific types 490 * that this may or may not correspond to the specific types
491 * referenced by the crush rule. 491 * referenced by the crush rule. it will also only affect
492 * the first descent (TAKE).
492 */ 493 */
493 if (force >= 0 && 494 if (force >= 0 &&
494 force < map->max_devices && 495 force < map->max_devices &&