From 42536184a5a950a31aebc7f0d981537229ae5c6c Mon Sep 17 00:00:00 2001 From: Paul Emmerich Date: Tue, 11 Jun 2019 14:10:55 +0200 Subject: [PATCH] rgw: fix bucket limit check fill_status warnings all variables in the calculation where ints, so the warning would only ever trigger if objects_per_shard == limit_objects and the percentage for > 100% used a granularity of 100% Fixes: http://tracker.ceph.com/issues/40255 Signed-off-by: Paul Emmerich (cherry picked from commit 694076419e6f20d1ed6c95b4b1ff94f134a10d4d) --- src/rgw/rgw_bucket.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 263df2fde198..323f7a99b06e 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -1540,32 +1540,28 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store, continue; for (const auto& s : stats) { - num_objects += s.second.num_objects; + num_objects += s.second.num_objects; } num_shards = info.num_shards; uint64_t objs_per_shard = (num_shards) ? num_objects/num_shards : num_objects; { - bool warn = false; + bool warn; stringstream ss; - if (objs_per_shard > safe_max_objs_per_shard) { - double over = - 100 - (safe_max_objs_per_shard/objs_per_shard * 100); - ss << boost::format("OVER %4f%%") % over; - warn = true; + uint64_t fill_pct = objs_per_shard * 100 / safe_max_objs_per_shard; + if (fill_pct > 100) { + ss << "OVER " << fill_pct << "%"; + warn = true; + } else if (fill_pct >= shard_warn_pct) { + ss << "WARN " << fill_pct << "%"; + warn = true; } else { - double fill_pct = - objs_per_shard / safe_max_objs_per_shard * 100; - if (fill_pct >= shard_warn_pct) { - ss << boost::format("WARN %4f%%") % fill_pct; - warn = true; - } else { - ss << "OK"; - } + ss << "OK"; + warn = false; } - if (warn || (! warnings_only)) { + if (warn || !warnings_only) { formatter->open_object_section("bucket"); formatter->dump_string("bucket", bucket->get_name()); formatter->dump_string("tenant", bucket->get_tenant()); -- 2.47.3