mirror of
https://github.com/ceph/ceph
synced 2025-02-21 01:47:25 +00:00
crush: eliminate ad hoc diff between kernel and userspace
- map->choose_tries is not in the kernel - 64-bit/64-bit in the kernel needs a special helper for 32-bit architectures, crush_compat.h provides a stub - INT64_MIN is not in the kernel, crush_compat.h provides S64_MIN - use dprintk inside DEBUG_INDEP sections No functional changes. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
69316a9387
commit
1db1abc832
@ -130,7 +130,9 @@ void crush_destroy(struct crush_map *map)
|
||||
kfree(map->rules);
|
||||
}
|
||||
|
||||
#ifndef __KERNEL__
|
||||
kfree(map->choose_tries);
|
||||
#endif
|
||||
kfree(map);
|
||||
}
|
||||
|
||||
|
@ -205,6 +205,7 @@ struct crush_map {
|
||||
* mappings line up a bit better with previous mappings. */
|
||||
__u8 chooseleaf_vary_r;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
/*
|
||||
* version 0 (original) of straw_calc has various flaws. version 1
|
||||
* fixes a few of them.
|
||||
@ -221,6 +222,7 @@ struct crush_map {
|
||||
__u32 allowed_bucket_algs;
|
||||
|
||||
__u32 *choose_tries;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
@ -327,9 +327,9 @@ static int bucket_straw2_choose(struct crush_bucket_straw2 *bucket,
|
||||
* weight means a larger (less negative) value
|
||||
* for draw.
|
||||
*/
|
||||
draw = ln / w;
|
||||
draw = div64_s64(ln, w);
|
||||
} else {
|
||||
draw = INT64_MIN;
|
||||
draw = S64_MIN;
|
||||
}
|
||||
|
||||
if (i == 0 || draw > high_draw) {
|
||||
@ -574,9 +574,10 @@ reject:
|
||||
out[outpos] = item;
|
||||
outpos++;
|
||||
count--;
|
||||
|
||||
#ifndef __KERNEL__
|
||||
if (map->choose_tries && ftotal <= map->choose_total_tries)
|
||||
map->choose_tries[ftotal]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
dprintk("CHOOSE returns %d\n", outpos);
|
||||
@ -622,16 +623,16 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||
for (ftotal = 0; left > 0 && ftotal < tries; ftotal++) {
|
||||
#ifdef DEBUG_INDEP
|
||||
if (out2 && ftotal) {
|
||||
printf("%u %d a: ", ftotal, left);
|
||||
dprintk("%u %d a: ", ftotal, left);
|
||||
for (rep = outpos; rep < endpos; rep++) {
|
||||
printf(" %d", out[rep]);
|
||||
dprintk(" %d", out[rep]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("%u %d b: ", ftotal, left);
|
||||
dprintk("\n");
|
||||
dprintk("%u %d b: ", ftotal, left);
|
||||
for (rep = outpos; rep < endpos; rep++) {
|
||||
printf(" %d", out2[rep]);
|
||||
dprintk(" %d", out2[rep]);
|
||||
}
|
||||
printf("\n");
|
||||
dprintk("\n");
|
||||
}
|
||||
#endif
|
||||
for (rep = outpos; rep < endpos; rep++) {
|
||||
@ -750,21 +751,22 @@ static void crush_choose_indep(const struct crush_map *map,
|
||||
out2[rep] = CRUSH_ITEM_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __KERNEL__
|
||||
if (map->choose_tries && ftotal <= map->choose_total_tries)
|
||||
map->choose_tries[ftotal]++;
|
||||
#endif
|
||||
#ifdef DEBUG_INDEP
|
||||
if (out2) {
|
||||
printf("%u %d a: ", ftotal, left);
|
||||
dprintk("%u %d a: ", ftotal, left);
|
||||
for (rep = outpos; rep < endpos; rep++) {
|
||||
printf(" %d", out[rep]);
|
||||
dprintk(" %d", out[rep]);
|
||||
}
|
||||
printf("\n");
|
||||
printf("%u %d b: ", ftotal, left);
|
||||
dprintk("\n");
|
||||
dprintk("%u %d b: ", ftotal, left);
|
||||
for (rep = outpos; rep < endpos; rep++) {
|
||||
printf(" %d", out2[rep]);
|
||||
dprintk(" %d", out2[rep]);
|
||||
}
|
||||
printf("\n");
|
||||
dprintk("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user