From: Sage Weil Date: Mon, 7 May 2012 22:36:49 +0000 (-0700) Subject: crush: fix tree node weight lookup X-Git-Tag: v3.4.20~114 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9a0117ae53308d0d8284ba5664ed4c1d0ec54176;p=karo-tx-linux.git crush: fix tree node weight lookup (cherry picked from commit f671d4cd9b36691ac4ef42cde44c1b7a84e13631) Fix the node weight lookup for tree buckets by using a correct accessor. Reflects ceph.git commit d287ade5bcbdca82a3aef145b92924cf1e856733. Reviewed-by: Alex Elder Signed-off-by: Sage Weil Signed-off-by: Greg Kroah-Hartman --- diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h index 3f50369a50e8..e7a8c9055cb2 100644 --- a/include/linux/crush/crush.h +++ b/include/linux/crush/crush.h @@ -177,4 +177,9 @@ extern void crush_destroy_bucket_straw(struct crush_bucket_straw *b); extern void crush_destroy_bucket(struct crush_bucket *b); extern void crush_destroy(struct crush_map *map); +static inline int crush_calc_tree_node(int i) +{ + return ((i+1) << 1)-1; +} + #endif diff --git a/net/ceph/crush/crush.c b/net/ceph/crush/crush.c index 8dd19a0deedc..f23611d0cdee 100644 --- a/net/ceph/crush/crush.c +++ b/net/ceph/crush/crush.c @@ -37,9 +37,7 @@ int crush_get_bucket_item_weight(const struct crush_bucket *b, int p) case CRUSH_BUCKET_LIST: return ((struct crush_bucket_list *)b)->item_weights[p]; case CRUSH_BUCKET_TREE: - if (p & 1) - return ((struct crush_bucket_tree *)b)->node_weights[p]; - return 0; + return ((struct crush_bucket_tree *)b)->node_weights[crush_calc_tree_node(p)]; case CRUSH_BUCKET_STRAW: return ((struct crush_bucket_straw *)b)->item_weights[p]; }