mirror of
https://github.com/torvalds/linux.git
synced 2024-11-29 07:31:29 +00:00
crush: eliminate CRUSH_MAX_SET result size limitation
This is only present to size the temporary scratch arrays that we put on the stack. Let the caller allocate them as they wish and remove the limitation. Reflects ceph.git commit 1cfe140bf2dab99517589a82a916f4c75b9492d1. Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
parent
2a4ba74ef6
commit
e8ef19c4ad
@ -21,7 +21,6 @@
|
||||
|
||||
|
||||
#define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */
|
||||
#define CRUSH_MAX_SET 10 /* max size of a mapping result */
|
||||
|
||||
|
||||
/*
|
||||
|
@ -14,6 +14,7 @@ extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, i
|
||||
extern int crush_do_rule(const struct crush_map *map,
|
||||
int ruleno,
|
||||
int x, int *result, int result_max,
|
||||
const __u32 *weights, int weight_max);
|
||||
const __u32 *weights, int weight_max,
|
||||
int *scratch);
|
||||
|
||||
#endif
|
||||
|
@ -478,15 +478,17 @@ reject:
|
||||
* @result_max: maximum result size
|
||||
* @weight: weight vector (for map leaves)
|
||||
* @weight_max: size of weight vector
|
||||
* @scratch: scratch vector for private use; must be >= 3 * result_max
|
||||
*/
|
||||
int crush_do_rule(const struct crush_map *map,
|
||||
int ruleno, int x, int *result, int result_max,
|
||||
const __u32 *weight, int weight_max)
|
||||
const __u32 *weight, int weight_max,
|
||||
int *scratch)
|
||||
{
|
||||
int result_len;
|
||||
int a[CRUSH_MAX_SET];
|
||||
int b[CRUSH_MAX_SET];
|
||||
int c[CRUSH_MAX_SET];
|
||||
int *a = scratch;
|
||||
int *b = scratch + result_max;
|
||||
int *c = scratch + result_max*2;
|
||||
int recurse_to_leaf;
|
||||
int *w;
|
||||
int wsize = 0;
|
||||
|
@ -1110,6 +1110,16 @@ int ceph_calc_ceph_pg(struct ceph_pg *pg, const char *oid,
|
||||
}
|
||||
EXPORT_SYMBOL(ceph_calc_ceph_pg);
|
||||
|
||||
static int crush_do_rule_ary(const struct crush_map *map, int ruleno, int x,
|
||||
int *result, int result_max,
|
||||
const __u32 *weight, int weight_max)
|
||||
{
|
||||
int scratch[result_max * 3];
|
||||
|
||||
return crush_do_rule(map, ruleno, x, result, result_max,
|
||||
weight, weight_max, scratch);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate raw osd vector for the given pgid. Return pointer to osd
|
||||
* array, or NULL on failure.
|
||||
@ -1163,8 +1173,8 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,
|
||||
pool->pgp_num_mask) +
|
||||
(unsigned)pgid.pool;
|
||||
}
|
||||
r = crush_do_rule(osdmap->crush, ruleno, pps, osds,
|
||||
min_t(int, pool->size, *num),
|
||||
r = crush_do_rule_ary(osdmap->crush, ruleno, pps,
|
||||
osds, min_t(int, pool->size, *num),
|
||||
osdmap->osd_weight, osdmap->max_osd);
|
||||
if (r < 0) {
|
||||
pr_err("error %d from crush rule: pool %lld ruleset %d type %d"
|
||||
|
Loading…
Reference in New Issue
Block a user