From: Ilya Dryomov Date: Fri, 12 Jun 2015 15:48:46 +0000 (+0300) Subject: crush: eliminate ad hoc diff between kernel and userspace X-Git-Tag: v9.0.3~185^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1db1abc8328d5cfc2de32e0f1c20a12295eae0b3;p=ceph.git 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 --- diff --git a/src/crush/crush.c b/src/crush/crush.c index f3f7f6d4a15d..80d7c3a97cb8 100644 --- a/src/crush/crush.c +++ b/src/crush/crush.c @@ -130,7 +130,9 @@ void crush_destroy(struct crush_map *map) kfree(map->rules); } +#ifndef __KERNEL__ kfree(map->choose_tries); +#endif kfree(map); } diff --git a/src/crush/crush.h b/src/crush/crush.h index 9c9a13492070..48b49305716b 100644 --- a/src/crush/crush.h +++ b/src/crush/crush.h @@ -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 }; diff --git a/src/crush/mapper.c b/src/crush/mapper.c index 82956586fa39..393bfb22d5bb 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -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 }