crush: assume weight_set != null imples weight_set_size > 0
authorIlya Dryomov <idryomov@gmail.com>
Mon, 24 Jul 2017 13:49:52 +0000 (15:49 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 1 Aug 2017 14:46:44 +0000 (16:46 +0200)
Reflects ceph.git commit 5e8fa3e06b68fae1582c9230a3a8d1abc6146286.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Sage Weil <sage@redhat.com>
net/ceph/crush/mapper.c
net/ceph/osdmap.c

index 746b145bfd113975e1f17399d845e2fcbdc7541a..417df675c71b0a2e53a25b0f7e9195c6f3c7804e 100644 (file)
@@ -306,7 +306,7 @@ static __u32 *get_choose_arg_weights(const struct crush_bucket_straw2 *bucket,
                                     const struct crush_choose_arg *arg,
                                     int position)
 {
-       if (!arg || !arg->weight_set || arg->weight_set_size == 0)
+       if (!arg || !arg->weight_set)
                return bucket->item_weights;
 
        if (position >= arg->weight_set_size)
index eb57a06373ca93cd1594c557eae22259114bd87a..2586e55461438bd1cd7a1127bfc8179e6ba84cb0 100644 (file)
@@ -295,6 +295,10 @@ static int decode_choose_args(void **p, void *end, struct crush_map *c)
                        ret = decode_choose_arg(p, end, arg);
                        if (ret)
                                goto fail;
+
+                       if (arg->ids_size &&
+                           arg->ids_size != c->buckets[bucket_index]->size)
+                               goto e_inval;
                }
 
                insert_choose_arg_map(&c->choose_args, arg_map);