diff options
author | Sage Weil <sage@inktank.com> | 2013-08-11 14:19:11 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-11 14:26:53 -0700 |
commit | a56ed9dbf777c5a702bde7075ddabd9eba4b8d31 (patch) | |
tree | 6c2a0b5ca699ee3ddec9a04706d8f2869ff4a4ef | |
parent | 429d599b1d900537537d7a22fc0ab22507d918d8 (diff) | |
download | ceph-a56ed9dbf777c5a702bde7075ddabd9eba4b8d31.tar.gz |
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.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/crush/CrushWrapper.h | 3 | ||||
-rw-r--r-- | src/crush/crush.h | 1 | ||||
-rw-r--r-- | src/crush/mapper.c | 9 | ||||
-rw-r--r-- | src/crush/mapper.h | 16 |
4 files changed, 22 insertions, 7 deletions
diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 3d07a281956..a46de18ca12 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -763,7 +763,8 @@ public: const vector<__u32>& weight) const { Mutex::Locker l(mapper_lock); int rawout[maxout]; - int numrep = crush_do_rule(crush, rule, x, rawout, maxout, &weight[0], weight.size()); + int scratch[maxout * 3]; + int numrep = crush_do_rule(crush, rule, x, rawout, maxout, &weight[0], weight.size(), scratch); if (numrep < 0) numrep = 0; out.resize(numrep); diff --git a/src/crush/crush.h b/src/crush/crush.h index 82d032879d9..4d55f8a12ff 100644 --- a/src/crush/crush.h +++ b/src/crush/crush.h @@ -26,7 +26,6 @@ #define CRUSH_MAX_DEPTH 10 /* max crush hierarchy depth */ -#define CRUSH_MAX_SET 10 /* max size of a mapping result */ #define CRUSH_MAX_DEVICE_WEIGHT (100u * 0x10000u) #define CRUSH_MAX_BUCKET_WEIGHT (65535u * 0x10000u) diff --git a/src/crush/mapper.c b/src/crush/mapper.c index ce23ef7c711..8af8810f3d3 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -478,12 +478,13 @@ reject: */ 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; diff --git a/src/crush/mapper.h b/src/crush/mapper.h index 73f3febbf3e..3df32fe084b 100644 --- a/src/crush/mapper.h +++ b/src/crush/mapper.h @@ -11,9 +11,23 @@ #include "crush.h" extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size); + +/** + * crush_do_rule - execute a crush rule to generate a mapping + * + * @param map pointer to crush map + * @param ruleno rule number + * @param x input + * @param result pointer to result vector + * @param result_max max number of requested results + * @param weights weight vector (for map leaves) + * @param weight_max size of weight vector + * @param scrach scratch vector for private use; must be >= 3 * result_max + */ 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 |