]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: make sure min objs per shard is appropriate 58354/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Wed, 3 Jul 2024 19:44:52 +0000 (15:44 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 3 Jul 2024 19:44:52 +0000 (15:44 -0400)
The admin has control over the rgw_max_objs_per_shard configuration
option. Currently the minimum objects per shard is hard-coded. If that
max is lowered then we need to be certain that the minimum is an
appropriate value, certainly less than the max.

Signed-off-by: J. Eric Ivancich <ivancich@redhat.com>
src/rgw/driver/rados/rgw_reshard.cc

index 3d38aa29aa034489418607b3bcd0bb774d06f8aa..b57eabb099e1cd400ac811a3a6c37dd9f8f48065 100644 (file)
@@ -32,7 +32,7 @@ const string reshard_lock_name = "reshard_process";
 const string bucket_instance_lock_name = "bucket_instance_lock";
 
 // key reduction values; NB maybe expose some in options
-constexpr uint64_t min_objs_per_shard = 10000;
+constexpr uint64_t default_min_objs_per_shard = 10000;
 constexpr uint32_t min_dynamic_shards = 11;
 
 /* All primes up to 2000 used to attempt to make dynamic sharding use
@@ -95,9 +95,7 @@ void RGWBucketReshard::calculate_preferred_shards(
   const DoutPrefixProvider* dpp,
   const uint32_t max_dynamic_shards,
   const uint64_t max_objs_per_shard,
-//  const uint64_t min_objs_per_shard,
   const bool is_multisite,
-//  const uint64_t min_dynamic_shards, FIX THIS!!!!!!
   const uint64_t num_objs,
   const uint32_t current_num_shards,
   bool& need_resharding,
@@ -109,6 +107,11 @@ void RGWBucketReshard::calculate_preferred_shards(
   constexpr uint32_t multisite_multiplier = 8;
   const char* verb = "n/a";
 
+  // in case admin lowers max_objs_per_shard, we need to avoid thrashing
+  const uint64_t min_objs_per_shard =
+    std::min(default_min_objs_per_shard,
+            (uint64_t) std::ceil(max_objs_per_shard / 100.0));
+
   if (current_num_shards < max_dynamic_shards &&
       num_objs > current_num_shards * max_objs_per_shard) {
     need_resharding = true;