]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crush/CrushWrapper: crush_choose_arg::ids should be __s32
authorIlya Dryomov <idryomov@gmail.com>
Tue, 27 Jun 2017 15:22:11 +0000 (17:22 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Fri, 30 Jun 2017 12:37:13 +0000 (14:37 +0200)
crush_choose_arg::ids array is encoded on the wire.  int is not fixed
size -- use __s32 instead (crush_bucket::id is __s32).

This was introduced in commit dbe36e08be00 ("crush: compile/decompile
crush_choose_arg_map") under SERVER_LUMINOUS bit.

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

index a6b62456699ff7b97fd1fca2b9fde492f2b8bfec..e01d089acbcf2e2c6e0a714abbf0c182ddc37fbd 100644 (file)
@@ -232,7 +232,7 @@ int CrushCompiler::decompile_weight_set(crush_weight_set *weight_set,
   return 0;
 }
 
-int CrushCompiler::decompile_ids(int *ids,
+int CrushCompiler::decompile_ids(__s32 *ids,
                                  __u32 size,
                                  ostream &out)
 {
@@ -972,7 +972,7 @@ int CrushCompiler::parse_choose_arg_ids(iter_t const& i, int bucket_id, crush_ch
     return -1;
   }
   arg->ids_size = size;
-  arg->ids = (int *)calloc(arg->ids_size, sizeof(int));
+  arg->ids = (__s32 *)calloc(arg->ids_size, sizeof(__s32));
   __u32 pos = 0;
   for (iter_t p = i->children.begin() + 2; pos < size; p++, pos++)
     arg->ids[pos] = int_node(*p);
index f375c7412f853cd762fd1b5bd91a09264d6ee701..7d4dd3c6abbaf44a367b51160a7c18e45c64217f 100644 (file)
@@ -1498,7 +1498,7 @@ int CrushWrapper::bucket_add_item(crush_bucket *bucket, int item, int weight)
       weight_set->size = new_size;
     }
     if (arg->ids_size) {
-      arg->ids = (int*)realloc(arg->ids, new_size * sizeof(int));
+      arg->ids = (__s32 *)realloc(arg->ids, new_size * sizeof(__s32));
       assert(arg->ids_size + 1 == new_size);
       arg->ids[arg->ids_size] = item;
       arg->ids_size = new_size;
@@ -1530,7 +1530,7 @@ int CrushWrapper::bucket_remove_item(crush_bucket *bucket, int item)
       assert(arg->ids_size - 1 == new_size);
       for (__u32 k = position; k < new_size; k++)
        arg->ids[k] = arg->ids[k+1];
-      arg->ids = (int*)realloc(arg->ids, new_size * sizeof(int));
+      arg->ids = (__s32 *)realloc(arg->ids, new_size * sizeof(__s32));
       arg->ids_size = new_size;
     }
   }
@@ -1915,7 +1915,7 @@ void CrushWrapper::decode(bufferlist::iterator& blp)
              ::decode(weight_set->weights[l], blp);
          }
          ::decode(arg->ids_size, blp);
-         arg->ids = (int*)calloc(arg->ids_size, sizeof(int));
+         arg->ids = (__s32 *)calloc(arg->ids_size, sizeof(__s32));
          for (__u32 k = 0; k < arg->ids_size; k++)
            ::decode(arg->ids[k], blp);
        }
index dc342d28a0168ceaa14952676a5933854fc28bc1..3b4ba25b277b4f35dc9c0816ec1783dbb629dedf 100644 (file)
@@ -1413,13 +1413,13 @@ struct crush_choose_arg *crush_make_choose_args(struct crush_map *map, int num_p
   int size = (sizeof(struct crush_choose_arg) * map->max_buckets +
               sizeof(struct crush_weight_set) * bucket_count * num_positions +
               sizeof(__u32) * sum_bucket_size * num_positions + // weights
-              sizeof(__u32) * sum_bucket_size); // ids
+              sizeof(__s32) * sum_bucket_size); // ids
   char *space = malloc(size);
   struct crush_choose_arg *arg = (struct crush_choose_arg *)space;
   struct crush_weight_set *weight_set = (struct crush_weight_set *)(arg + map->max_buckets);
   __u32 *weights = (__u32 *)(weight_set + bucket_count * num_positions);
   char *weight_set_ends = (char*)weights;
-  int *ids = (int *)(weights + sum_bucket_size * num_positions);
+  __s32 *ids = (__s32 *)(weights + sum_bucket_size * num_positions);
   char *weights_end = (char *)ids;
   char *ids_end = (char *)(ids + sum_bucket_size);
   BUG_ON(space + size != ids_end);
@@ -1442,7 +1442,7 @@ struct crush_choose_arg *crush_make_choose_args(struct crush_map *map, int num_p
     arg[b].weight_set_size = num_positions;
     weight_set += position;
 
-    memcpy(ids, bucket->h.items, sizeof(int) * bucket->h.size);
+    memcpy(ids, bucket->h.items, sizeof(__s32) * bucket->h.size);
     arg[b].ids = ids;
     arg[b].ids_size = bucket->h.size;
     ids += bucket->h.size;
index 31fb94deff48969c024b71762b8e5b4e216c6f54..4be114631e36b68e97cf51c1ac79331b1a3b5167 100644 (file)
@@ -271,7 +271,7 @@ struct crush_weight_set {
  *
  */
 struct crush_choose_arg {
-  int *ids;                             /*!< values to use instead of items */
+  __s32 *ids;                           /*!< values to use instead of items */
   __u32 ids_size;                       /*!< size of the __ids__ array */
   struct crush_weight_set *weight_set;  /*!< weight replacements for a given position */
   __u32 weight_set_size;                /*!< size of the __weight_set__ array */
index 321e7a7d549cf88ae74144e03ff39505f5760d77..8ea91897dfa412cf1518e66c0dbce9f9fac3584a 100644 (file)
@@ -312,8 +312,8 @@ static inline __u32 *get_choose_arg_weights(const struct crush_bucket_straw2 *bu
   return arg->weight_set[position].weights;
 }
 
-static inline int *get_choose_arg_ids(const struct crush_bucket_straw2 *bucket,
-                                        const struct crush_choose_arg *arg)
+static inline __s32 *get_choose_arg_ids(const struct crush_bucket_straw2 *bucket,
+                                       const struct crush_choose_arg *arg)
 {
   if ((arg == NULL) || (arg->ids == NULL))
     return bucket->h.items;
@@ -328,7 +328,7 @@ static int bucket_straw2_choose(const struct crush_bucket_straw2 *bucket,
        unsigned int u;
        __s64 ln, draw, high_draw = 0;
         __u32 *weights = get_choose_arg_weights(bucket, arg, position);
-        int *ids = get_choose_arg_ids(bucket, arg);
+        __s32 *ids = get_choose_arg_ids(bucket, arg);
        for (i = 0; i < bucket->h.size; i++) {
                 dprintk("weight 0x%x item %d\n", weights[i], ids[i]);
                if (weights[i]) {