]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: eliminate ad hoc diff between kernel and userspace 4959/head
authorIlya Dryomov <idryomov@gmail.com>
Fri, 12 Jun 2015 15:48:46 +0000 (18:48 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 15 Jun 2015 15:13:40 +0000 (18:13 +0300)
- 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>
src/crush/crush.c
src/crush/crush.h
src/crush/mapper.c

index f3f7f6d4a15d191cd6ae9bd78c1c7957c78e0b5c..80d7c3a97cb84355e82e9d8f4c83fbf5b0d82893 100644 (file)
@@ -130,7 +130,9 @@ void crush_destroy(struct crush_map *map)
                kfree(map->rules);
        }
 
+#ifndef __KERNEL__
        kfree(map->choose_tries);
+#endif
        kfree(map);
 }
 
index 9c9a13492070137c386635b67903de58b04d27d5..48b49305716bd728e69477db6b430c34e7781746 100644 (file)
@@ -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
 };
 
 
index 82956586fa394edce61b475bf766ce9f5a2bf9ab..393bfb22d5bbafd83c20f5953b98c6709b637452 100644 (file)
@@ -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
 }