]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check if bucket index layout can be resharded before progressing 53929/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Tue, 10 Oct 2023 15:24:08 +0000 (11:24 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 18 Oct 2023 16:20:23 +0000 (12:20 -0400)
Adds a test for a reshardable index layout when a bucket is considered
for immediate, scheduled, or dynamic resharding.

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

index 5437d12d4b7654cbafdd196b41fa825850e9e827..e0880437989328c54c6a4828af57e5e316348e30 100644 (file)
@@ -10065,6 +10065,10 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info,
       return 0;
   }
 
+  if (! is_layout_reshardable(bucket_info.layout)) {
+    return 0;
+  }
+
   bool need_resharding = false;
   uint32_t num_source_shards = rgw::current_num_shards(bucket_info.layout);
   const uint32_t max_dynamic_shards =
index 4369bc8a05c8bcf8b4cff8741b676c35fb675f28..7a54da7fe7d08afa39baba2af377ed746f27e563 100644 (file)
@@ -994,11 +994,11 @@ int RGWBucketReshard::execute(int num_shards,
   return 0;
 } // execute
 
-bool RGWBucketReshard::can_reshard(const RGWBucketInfo& bucket,
-                                   const RGWSI_Zone* zone_svc)
+bool RGWBucketReshard::should_zone_reshard_now(const RGWBucketInfo& bucket,
+                                              const RGWSI_Zone* zone_svc)
 {
   return !zone_svc->need_to_log_data() ||
-      bucket.layout.logs.size() < max_bilog_history;
+    bucket.layout.logs.size() < max_bilog_history;
 }
 
 
@@ -1240,7 +1240,7 @@ int RGWReshard::process_entry(const cls_rgw_reshard_entry& entry,
     return 0;
   }
 
-  if (!RGWBucketReshard::can_reshard(bucket_info, store->svc()->zone)) {
+  if (!RGWBucketReshard::should_zone_reshard_now(bucket_info, store->svc()->zone)) {
     ldpp_dout(dpp, 1) << "Bucket " << bucket_info.bucket << " is not "
         "eligible for resharding until peer zones finish syncing one "
         "or more of its old log generations" << dendl;
index 768e6c8b359335184af0225a50471c681cf1e46f..0497414566ad28182e52c1cd802cc46bf50c71f7 100644 (file)
@@ -175,8 +175,8 @@ public:
   // too large by refusing to reshard the bucket until the old logs get trimmed
   static constexpr size_t max_bilog_history = 4;
 
-  static bool can_reshard(const RGWBucketInfo& bucket,
-                          const RGWSI_Zone* zone_svc);
+  static bool should_zone_reshard_now(const RGWBucketInfo& bucket,
+                                     const RGWSI_Zone* zone_svc);
 }; // RGWBucketReshard
 
 
index a4e17b8895ae80619947fc2ddb239ec1c8c76b82..cc7f5811c9efeee2a3341cbddb5e9a8c8637e34d 100644 (file)
@@ -3006,6 +3006,14 @@ int check_reshard_bucket_params(rgw::sal::Driver* driver,
     return ret;
   }
 
+  if (! is_layout_reshardable((*bucket)->get_info().layout)) {
+    std::cerr << "Bucket '" << (*bucket)->get_name() <<
+      "' currently has layout '" <<
+      current_layout_desc((*bucket)->get_info().layout) <<
+      "', which does not support resharding." << std::endl;
+    return -EINVAL;
+  }
+
   int num_source_shards = rgw::current_num_shards((*bucket)->get_info().layout);
 
   if (num_shards <= num_source_shards && !yes_i_really_mean_it) {
@@ -8105,7 +8113,8 @@ next:
           "have the resharding feature enabled." << std::endl;
       return ENOTSUP;
     }
-    if (!RGWBucketReshard::can_reshard(bucket->get_info(), zone_svc) &&
+
+    if (!RGWBucketReshard::should_zone_reshard_now(bucket->get_info(), zone_svc) &&
         !yes_i_really_mean_it) {
       std::cerr << "Bucket '" << bucket->get_name() << "' already has too many "
           "log generations (" << bucket->get_info().layout.logs.size() << ") "
index 40aafd4dd8dede1c5388612f2d073bd05c0b2de1..114f1f1ff589c591c7429fbc3b784c149a479e44 100644 (file)
@@ -278,5 +278,14 @@ inline uint32_t current_num_shards(const BucketLayout& layout) {
 inline bool is_layout_indexless(const bucket_index_layout_generation& layout) {
   return layout.layout.type == BucketIndexType::Indexless;
 }
+inline bool is_layout_reshardable(const bucket_index_layout_generation& layout) {
+  return layout.layout.type == BucketIndexType::Normal;
+}
+inline bool is_layout_reshardable(const BucketLayout& layout) {
+  return is_layout_reshardable(layout.current_index);
+}
+inline std::string_view current_layout_desc(const BucketLayout& layout) {
+  return rgw::to_string(layout.current_index.layout.type);
+}
 
 } // namespace rgw