Skip to contentSkip to conversation

I found some problem in CRUSH code

DISCUSSION ZhuRongze 2 participants 2 messages Feb 15, 2012 – Feb 23, 2012

lore
Share & tools
lore

ZhuRongze

author
#0 lore raw

Hi,

The function crush_adjust_tree_bucket_item_weight in ceph-0.41/src/crush/builder.c seem to have a bug. The argument weight is no use, because it is assigned .
--------------------------------------------------------------------
int crush_adjust_tree_bucket_item_weight(struct crush_bucket_tree *bucket, int item, int weight)

{
    int diff;
    int node;
    unsigned i, j;
    unsigned depth = calc_depth(bucket->h.size);

    for (i = 0; i < bucket->h.size; i++) {
        if (bucket->h.items[i] == item)
            break;
    }
    if (i == bucket->h.size)
        return 0;

    node = crush_calc_tree_node(i);
    diff = weight = bucket->node_weights[node];
    bucket->node_weights[node] = weight;
    bucket->h.weight += diff;

    for (j=1; j<depth; j++) {
        node = parent(node);
        bucket->node_weights[node] += diff;
    }

    return diff;

--------------------------------------------------------------------
The function crush_adjust_list_bucket_item_weight also have a same problem.

-ZhuRongze

begin:vcard
fn:Rongze Zhu
n:Zhu;Rongze
org:SINA;SWS
version:2.1
end:vcard

#1 lore raw

Hi,

Yes, that's a bug... Those ='s should be -, as with the straw bucket type. Opened http://tracker.newdream.net/issues/2096

Thanks! This'll be fixed in v0.43.
sage

Quoted 38 lines · ZhuRongze

Hi,

The function crush_adjust_tree_bucket_item_weight in ceph-0.41/src/crush/builder.c seem to have a bug. The argument weight is no use, because it is assigned .
--------------------------------------------------------------------
int crush_adjust_tree_bucket_item_weight(struct crush_bucket_tree *bucket, int item, int weight)

{
    int diff;
    int node;
    unsigned i, j;
    unsigned depth = calc_depth(bucket->h.size);

    for (i = 0; i < bucket->h.size; i++) {
        if (bucket->h.items[i] == item)
            break;
    }
    if (i == bucket->h.size)
        return 0;

    node = crush_calc_tree_node(i);
    diff = weight = bucket->node_weights[node];
    bucket->node_weights[node] = weight;
    bucket->h.weight += diff;

    for (j=1; j<depth; j++) {
        node = parent(node);
        bucket->node_weights[node] += diff;
    }

    return diff;

--------------------------------------------------------------------
The function crush_adjust_list_bucket_item_weight also have a same problem.

-ZhuRongze