summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2012-05-07 15:36:49 -0700
committerSage Weil <sage@inktank.com>2012-05-07 15:39:35 -0700
commitf671d4cd9b36691ac4ef42cde44c1b7a84e13631 (patch)
tree9f961d2a6dfdee4ffa3b4c8d2b7308dfda85e177
parentfc7c3ae5ab9246ad96aab4d0d57f67e9255cfb56 (diff)
downloadop-kernel-dev-f671d4cd9b36691ac4ef42cde44c1b7a84e13631.zip
op-kernel-dev-f671d4cd9b36691ac4ef42cde44c1b7a84e13631.tar.gz
crush: fix tree node weight lookup
Fix the node weight lookup for tree buckets by using a correct accessor. Reflects ceph.git commit d287ade5bcbdca82a3aef145b92924cf1e856733. Reviewed-by: Alex Elder <elder@inktank.com> Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r--include/linux/crush/crush.h5
-rw-r--r--net/ceph/crush/crush.c4
2 files changed, 6 insertions, 3 deletions
diff --git a/include/linux/crush/crush.h b/include/linux/crush/crush.h
index 158a4d2..7c47508 100644
--- a/include/linux/crush/crush.h
+++ b/include/linux/crush/crush.h
@@ -166,4 +166,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 2160791..b93575f 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];
}
OpenPOWER on IntegriCloud