]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: allow uniform buckets with no items 13521/head
authorLoic Dachary <ldachary@redhat.com>
Wed, 15 Feb 2017 20:46:26 +0000 (21:46 +0100)
committerLoic Dachary <ldachary@redhat.com>
Sun, 19 Feb 2017 09:00:55 +0000 (10:00 +0100)
When a uniform bucket is created with zero size, it returns on error
because crush_multiplication_is_unsafe returns false. Since the goal
of this safegard is to avoid overflow, it should not fail.

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/crush/builder.c

index 71a6264e76a913f9abd2300f2abb7d10bafec5d8..364db9256c07cbadd0911a0d96fde8d7fe25b31b 100644 (file)
@@ -1416,6 +1416,8 @@ int crush_addition_is_unsafe(__u32 a, __u32 b)
 int crush_multiplication_is_unsafe(__u32  a, __u32 b)
 {
        /* prevent division by zero */
+        if (!a)
+                return 0;
        if (!b)
                return 1;
        if ((((__u32)(-1)) / b) < a)