From f05b1bef64256cc8c31f496cd0d97e40e0bc8a3e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 9 Mar 2009 14:50:37 -0700 Subject: [PATCH] kclient: fix osdmap decoding of straw buckets Surprised this worked until now. --- src/kernel/osdmap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/kernel/osdmap.c b/src/kernel/osdmap.c index a783f7f75041c..6be0984d02268 100644 --- a/src/kernel/osdmap.c +++ b/src/kernel/osdmap.c @@ -97,6 +97,9 @@ static int crush_decode_straw_bucket(void **p, void *end, { int j; dout(30, "crush_decode_straw_bucket %p to %p\n", *p, end); + b->item_weights = kmalloc(b->h.size * sizeof(u32), GFP_NOFS); + if (b->item_weights == NULL) + return -ENOMEM; b->straws = kmalloc(b->h.size * sizeof(u32), GFP_NOFS); if (b->straws == NULL) return -ENOMEM; @@ -153,19 +156,18 @@ static struct crush_map *crush_decode(void *pbyval, void *end) /* buckets */ for (i = 0; i < c->max_buckets; i++) { int size = 0; - u32 type; + u32 alg; struct crush_bucket *b; - dout(30, "crush_decode bucket %d off %x %p to %p\n", - i, (int)(*p-start), *p, end); - - ceph_decode_32_safe(p, end, type, bad); - if (type == 0) { + ceph_decode_32_safe(p, end, alg, bad); + if (alg == 0) { c->buckets[i] = NULL; continue; } + dout(30, "crush_decode bucket %d off %x %p to %p\n", + i, (int)(*p-start), *p, end); - switch (type) { + switch (alg) { case CRUSH_BUCKET_UNIFORM: size = sizeof(struct crush_bucket_uniform); break; @@ -204,7 +206,7 @@ static struct crush_map *crush_decode(void *pbyval, void *end) for (j = 0; j < b->size; j++) ceph_decode_32(p, b->items[j]); - switch (b->type) { + switch (b->alg) { case CRUSH_BUCKET_UNIFORM: err = crush_decode_uniform_bucket(p, end, (struct crush_bucket_uniform *)b); -- 2.39.5