From 3ccb16483a1c8611716b622a656c9bf435a47271 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 Aug 2009 13:20:42 -0700 Subject: [PATCH] crush: put temp arrays on the stack 40 ints on the stack.. not too much I hope? --- src/crush/mapper.c | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/src/crush/mapper.c b/src/crush/mapper.c index b8b9de4c4eb41..fc44b1b85c481 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -441,11 +441,11 @@ int crush_do_rule(struct crush_map *map, int force, __u32 *weight) { int result_len; - int *force_context = NULL; + int force_context[CRUSH_MAX_DEPTH]; int force_pos = -1; - int *a = NULL; - int *b = NULL; - int *c = NULL; + int a[CRUSH_MAX_SET]; + int b[CRUSH_MAX_SET]; + int c[CRUSH_MAX_SET]; int recurse_to_leaf; int *w; int wsize = 0; @@ -461,19 +461,6 @@ int crush_do_rule(struct crush_map *map, BUG_ON(ruleno >= map->max_rules); - a = kmalloc(CRUSH_MAX_SET * sizeof(int), GFP_KERNEL); - if (!a) - goto out; - b = kmalloc(CRUSH_MAX_SET * sizeof(int), GFP_KERNEL); - if (!b) - goto out; - c = kmalloc(CRUSH_MAX_SET * sizeof(int), GFP_KERNEL); - if (!c) - goto out; - force_context = kmalloc(CRUSH_MAX_DEPTH * sizeof(int), GFP_KERNEL); - if (!force_context) - goto out; - rule = map->rules[ruleno]; result_len = 0; w = a; @@ -595,11 +582,6 @@ int crush_do_rule(struct crush_map *map, rc = result_len; out: - kfree(a); - kfree(b); - kfree(c); - kfree(force_context); - return rc; } -- 2.39.5