From: J. Eric Ivancich Date: Tue, 10 Oct 2023 15:24:08 +0000 (-0400) Subject: rgw: check if bucket index layout can be resharded before progressing X-Git-Tag: v19.0.0~263^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ee4f5d7de2f900553c791066137388ae1a6e85c7;p=ceph.git rgw: check if bucket index layout can be resharded before progressing 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 --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index 5437d12d4b7..e0880437989 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -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 = diff --git a/src/rgw/driver/rados/rgw_reshard.cc b/src/rgw/driver/rados/rgw_reshard.cc index 4369bc8a05c..7a54da7fe7d 100644 --- a/src/rgw/driver/rados/rgw_reshard.cc +++ b/src/rgw/driver/rados/rgw_reshard.cc @@ -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; diff --git a/src/rgw/driver/rados/rgw_reshard.h b/src/rgw/driver/rados/rgw_reshard.h index 768e6c8b359..0497414566a 100644 --- a/src/rgw/driver/rados/rgw_reshard.h +++ b/src/rgw/driver/rados/rgw_reshard.h @@ -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 diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index a4e17b8895a..cc7f5811c9e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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() << ") " diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index 40aafd4dd8d..114f1f1ff58 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -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