]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: move safe arithmetic functions to buider.c
authorIlya Dryomov <idryomov@gmail.com>
Thu, 11 Jun 2015 09:45:56 +0000 (12:45 +0300)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 15 Jun 2015 11:26:51 +0000 (14:26 +0300)
Given that crush_{addition,multiplication}_is_unsafe() are only used
for compiling maps, they have no business in crush.c which is shared
with the kernel.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/crush/builder.c
src/crush/builder.h
src/crush/crush.c
src/crush/crush.h

index 28d957db21f03d93c4c804f5fbd03cd59cad6718..1212e4be2d37b951608390b2a18659449ece83b0 100644 (file)
@@ -1465,3 +1465,23 @@ int crush_reweight_bucket(struct crush_map *crush, struct crush_bucket *b)
 
 /***************************/
 
+/* methods to check for safe arithmetic operations */
+
+int crush_addition_is_unsafe(__u32 a, __u32 b)
+{
+       if ((((__u32)(-1)) - b) < a)
+               return 1;
+       else
+               return 0;
+}
+
+int crush_multiplication_is_unsafe(__u32  a, __u32 b)
+{
+       /* prevent division by zero */
+       if (!b)
+               return 1;
+       if ((((__u32)(-1)) / b) < a)
+               return 1;
+       else
+               return 0;
+}
index efd7c8aec43d29a645ce75cb7a67602927584311..b436e3eb3cdf2f40e6b4aa42ff5f8da2e0fd3d62 100644 (file)
@@ -41,4 +41,7 @@ crush_make_straw_bucket(struct crush_map *map,
                        int *items,
                        int *weights);
 
+extern int crush_addition_is_unsafe(__u32 a, __u32 b);
+extern int crush_multiplication_is_unsafe(__u32  a, __u32 b);
+
 #endif
index c0bcdb794355f64942548e9bfcce2dbf4d686612..c400a410b0d892af44ec60e767dd8f3ac411bfa2 100644 (file)
@@ -143,23 +143,3 @@ void crush_destroy_rule(struct crush_rule *rule)
 {
        kfree(rule);
 }
-
-// methods to check for safe arithmetic operations
-int crush_addition_is_unsafe(__u32 a, __u32 b)
-{
-  if ((((__u32)(-1)) - b) < a)
-    return 1;
-  else
-    return 0;
-}
-
-int crush_multiplication_is_unsafe(__u32  a, __u32 b)
-{
-  // prevent division by zero 
-  if (!b)
-    return 1;
-  if ((((__u32)(-1)) / b) < a)
-    return 1;
-  else
-    return 0;
-}
index 5082c03196477b36c73bdc1855282bb41c48d210..baa8e1b08792a50f2e1ccb1c82921d652501abb8 100644 (file)
@@ -222,8 +222,6 @@ struct crush_map {
 
 /* crush.c */
 extern int crush_get_bucket_item_weight(const struct crush_bucket *b, int pos);
-extern int crush_addition_is_unsafe(__u32 a, __u32 b);
-extern int crush_multiplication_is_unsafe(__u32  a, __u32 b);
 extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
 extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
 extern void crush_destroy_bucket_tree(struct crush_bucket_tree *b);