]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: bucket: crush_add_uniform_bucket_item should check for uniformity
authorSahid Orentino Ferdjaoui <sahid.ferdjaoui@redhat.com>
Thu, 23 Mar 2017 17:18:41 +0000 (13:18 -0400)
committerLoic Dachary <ldachary@redhat.com>
Tue, 28 Mar 2017 21:26:06 +0000 (23:26 +0200)
When defining a bucket using alg CRUSH_BUCKET_UNIFORM, the item weight
set during creation of bucket should be used to ensure that for every
new items added, the weights are the same.

Signed-off-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@redhat.com>
src/crush/builder.c

index 37c6d86ac030c6fd20f74decc60a13e3b36e9f5f..98eec1a7a708174d8344ec6478a1393f8c73293b 100644 (file)
@@ -685,7 +685,16 @@ int crush_add_uniform_bucket_item(struct crush_bucket_uniform *bucket, int item,
 {
         int newsize = bucket->h.size + 1;
        void *_realloc = NULL;
-       
+
+       /* In such situation 'CRUSH_BUCKET_UNIFORM', the weight
+          provided for the item should be the same as
+          bucket->item_weight defined with 'crush_make_bucket'. This
+          assumption is enforced by the return value which is always
+          0. */
+       if (bucket->item_weight != weight) {
+         return -EINVAL;
+       }
+
        if ((_realloc = realloc(bucket->h.items, sizeof(__s32)*newsize)) == NULL) {
                return -ENOMEM;
        } else {