From: Loic Dachary Date: Wed, 15 Feb 2017 20:46:26 +0000 (+0100) Subject: crush: allow uniform buckets with no items X-Git-Tag: v12.0.1~293^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d4990c9d98bb16fa8b2f2d9cd6108afc9f86f7a1;p=ceph.git crush: allow uniform buckets with no items 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 --- diff --git a/src/crush/builder.c b/src/crush/builder.c index 71a6264e76a91..364db9256c07c 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -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)