aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/crush/crush.h1
-rw-r--r--include/linux/crush/mapper.h3
-rw-r--r--net/ceph/crush/mapper.c10
-rw-r--r--net/ceph/osdmap.c16
4 files changed, 21 insertions, 9 deletions
diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h
index 09561a04c127..83543c504b5a 100644
--- a/include/linux/crush/crush.h
+++ b/include/linux/crush/crush.h
@@ -21,7 +21,6 @@
21 21
22 22
23#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */ 23#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */
24#define CRUSH_MAX_SET 10 /* max size of a mapping result */
25 24
26 25
27/* 26/*
diff --git a/include/linux/crush/mapper.h b/include/linux/crush/mapper.h
index 69310b031875..eab367446eea 100644
--- a/include/linux/crush/mapper.h
+++ b/include/linux/crush/mapper.h
@@ -14,6 +14,7 @@ extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, i
14extern int crush_do_rule(const 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 const __u32 *weights, int weight_max); 17 const __u32 *weights, int weight_max,
18 int *scratch);
18 19
19#endif 20#endif
diff --git a/net/ceph/crush/mapper.c b/net/ceph/crush/mapper.c
index 82cab7d3e89d..dcf48bc504ea 100644
--- a/net/ceph/crush/mapper.c
+++ b/net/ceph/crush/mapper.c
@@ -478,15 +478,17 @@ reject:
478 * @result_max: maximum result size 478 * @result_max: maximum result size
479 * @weight: weight vector (for map leaves) 479 * @weight: weight vector (for map leaves)
480 * @weight_max: size of weight vector 480 * @weight_max: size of weight vector
481 * @scratch: scratch vector for private use; must be >= 3 * result_max
481 */ 482 */
482int crush_do_rule(const struct crush_map *map, 483int crush_do_rule(const struct crush_map *map,
483 int ruleno, int x, int *result, int result_max, 484 int ruleno, int x, int *result, int result_max,
484 const __u32 *weight, int weight_max) 485 const __u32 *weight, int weight_max,
486 int *scratch)
485{ 487{
486 int result_len; 488 int result_len;
487 int a[CRUSH_MAX_SET]; 489 int *a = scratch;
488 int b[CRUSH_MAX_SET]; 490 int *b = scratch + result_max;
489 int c[CRUSH_MAX_SET]; 491 int *c = scratch + result_max*2;
490 int recurse_to_leaf; 492 int recurse_to_leaf;
491 int *w; 493 int *w;
492 int wsize = 0; 494 int wsize = 0;
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 6477a68ddecb..8b1a6b48bb5d 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1110,6 +1110,16 @@ int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
1110} 1110}
1111EXPORT_SYMBOL(ceph_calc_ceph_pg); 1111EXPORT_SYMBOL(ceph_calc_ceph_pg);
1112 1112
1113static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x,
1114 int *result, int result_max,
1115 const __u32 *weight, int weight_max)
1116{
1117 int scratch[result_max * 3];
1118
1119 return crush_do_rule(map, ruleno, x, result, result_max,
1120 weight, weight_max, scratch);
1121}
1122
1113/* 1123/*
1114 * Calculate raw osd vector for the given pgid. Return pointer to osd 1124 * Calculate raw osd vector for the given pgid. Return pointer to osd
1115 * array, or NULL on failure. 1125 * array, or NULL on failure.
@@ -1163,9 +1173,9 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
1163 pool->pgp_num_mask) + 1173 pool->pgp_num_mask) +
1164 (unsigned)pgid.pool; 1174 (unsigned)pgid.pool;
1165 } 1175 }
1166 r = crush_do_rule(osdmap->crush, ruleno, pps, osds, 1176 r = crush_do_rule_ary(osdmap->crush, ruleno, pps,
1167 min_t(int, pool->size, *num), 1177 osds, min_t(int, pool->size, *num),
1168 osdmap->osd_weight, osdmap->max_osd); 1178 osdmap->osd_weight, osdmap->max_osd);
1169 if (r < 0) { 1179 if (r < 0) {
1170 pr_err("error %d from crush rule: pool %lld ruleset %d type %d" 1180 pr_err("error %d from crush rule: pool %lld ruleset %d type %d"
1171 " size %d\n", r, pgid.pool, pool->crush_ruleset, 1181 " size %d\n", r, pgid.pool, pool->crush_ruleset,