Skip to content

Commit

Permalink
crush: fix tree node weight lookup
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Sage Weil committed May 7, 2012
1 parent fc7c3ae commit f671d4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 5 additions & 0 deletions include/linux/crush/crush.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions net/ceph/crush/crush.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit f671d4c

Please sign in to comment.