From: Casey Bodley Date: Fri, 15 Nov 2024 14:17:40 +0000 (-0500) Subject: rgw/rados: move RGWRados::bucket_set_reshard() to RGWSI_BucketIndex_RADOS X-Git-Tag: testing/wip-vshankar-testing-20250411.090237-debug~31^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e843ad38631ef7d3997361ce577dd86e4a159751;p=ceph-ci.git rgw/rados: move RGWRados::bucket_set_reshard() to RGWSI_BucketIndex_RADOS Signed-off-by: Casey Bodley --- diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index ebdea6f6e4a..2b3c0ffddf8 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -6172,31 +6172,6 @@ int RGWRados::bucket_resync_encrypted_multipart(const DoutPrefixProvider* dpp, return 0; } -int RGWRados::bucket_set_reshard(const DoutPrefixProvider *dpp, - const RGWBucketInfo& bucket_info, - const cls_rgw_bucket_instance_entry& entry) -{ - librados::IoCtx index_pool; - map bucket_objs; - - int r = svc.bi_rados->open_bucket_index(dpp, bucket_info, std::nullopt, bucket_info.layout.current_index, &index_pool, &bucket_objs, nullptr); - if (r < 0) { - ldpp_dout(dpp, 0) << "ERROR: " << __func__ << - ": unable to open bucket index, r=" << r << " (" << - cpp_strerror(-r) << ")" << dendl; - return r; - } - - maybe_warn_about_blocking(dpp); // TODO: use AioTrottle - r = CLSRGWIssueSetBucketResharding(index_pool, bucket_objs, entry, cct->_conf->rgw_bucket_index_max_aio)(); - if (r < 0) { - ldpp_dout(dpp, 0) << "ERROR: " << __func__ << - ": unable to issue set bucket resharding, r=" << r << " (" << - cpp_strerror(-r) << ")" << dendl; - } - return r; -} - int RGWRados::defer_gc(const DoutPrefixProvider *dpp, RGWObjectCtx* octx, RGWBucketInfo& bucket_info, const rgw_obj& obj, optional_yield y) { std::string oid, key; diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index 4c471bbd85b..eda57dc97c0 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1610,8 +1610,6 @@ public: const std::string& marker, RGWFormatterFlusher& flusher); - int bucket_set_reshard(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, - const cls_rgw_bucket_instance_entry& entry); int remove_objs_from_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const std::list& oid_list); diff --git a/src/rgw/driver/rados/rgw_reshard.cc b/src/rgw/driver/rados/rgw_reshard.cc index 82705602b36..d975a2ae0d7 100644 --- a/src/rgw/driver/rados/rgw_reshard.cc +++ b/src/rgw/driver/rados/rgw_reshard.cc @@ -362,24 +362,6 @@ RGWBucketReshard::RGWBucketReshard(rgw::sal::RadosStore* _store, outer_reshard_lock(_outer_reshard_lock) { } -// sets reshard status of bucket index shards for the current index layout -static int set_resharding_status(const DoutPrefixProvider *dpp, - rgw::sal::RadosStore* store, - const RGWBucketInfo& bucket_info, - cls_rgw_reshard_status status) -{ - cls_rgw_bucket_instance_entry instance_entry; - instance_entry.set_status(status); - - int ret = store->getRados()->bucket_set_reshard(dpp, bucket_info, instance_entry); - if (ret < 0) { - ldpp_dout(dpp, 0) << "RGWReshard::" << __func__ << " ERROR: error setting bucket resharding flag on bucket index: " - << cpp_strerror(-ret) << dendl; - return ret; - } - return 0; -} - static int remove_old_reshard_instance(rgw::sal::RadosStore* store, const rgw_bucket& bucket, const DoutPrefixProvider* dpp, optional_yield y) @@ -676,12 +658,12 @@ static int init_reshard(rgw::sal::RadosStore* store, if (support_logrecord) { if (ret = fault.check("logrecord_writes"); ret == 0) { // no fault injected, record log with writing to the current index shards - ret = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::IN_LOGRECORD); + ret = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::IN_LOGRECORD); } } else { - ret = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::IN_PROGRESS); + ret = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::IN_PROGRESS); } if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to pause " @@ -748,8 +730,8 @@ static int change_reshard_state(rgw::sal::RadosStore* store, bucket_info.layout = std::move(prev); // restore in-memory layout // unblock writes to the current index shard objects - int ret2 = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::NOT_RESHARDING); + int ret2 = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::NOT_RESHARDING); if (ret2 < 0) { ldpp_dout(dpp, 1) << "WARNING: " << __func__ << " failed to unblock " "writes to current index objects: " << cpp_strerror(ret2) << dendl; @@ -760,8 +742,8 @@ static int change_reshard_state(rgw::sal::RadosStore* store, if (ret = fault.check("block_writes"); ret == 0) { // no fault injected, block writes to the current index shards - ret = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::IN_PROGRESS); + ret = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::IN_PROGRESS); } if (ret < 0) { @@ -782,8 +764,8 @@ static int cancel_reshard(rgw::sal::RadosStore* store, const DoutPrefixProvider *dpp, optional_yield y) { // unblock writes to the current index shard objects - int ret = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::NOT_RESHARDING); + int ret = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::NOT_RESHARDING); if (ret < 0) { ldpp_dout(dpp, 1) << "WARNING: " << __func__ << " failed to unblock " "writes to current index objects: " << cpp_strerror(ret) << dendl; @@ -881,8 +863,8 @@ static int commit_reshard(rgw::sal::RadosStore* store, bucket_info.layout = std::move(prev); // restore in-memory layout // unblock writes to the current index shard objects - int ret2 = set_resharding_status(dpp, store, bucket_info, - cls_rgw_reshard_status::NOT_RESHARDING); + int ret2 = store->svc()->bi_rados->set_reshard_status( + dpp, bucket_info, cls_rgw_reshard_status::NOT_RESHARDING); if (ret2 < 0) { ldpp_dout(dpp, 1) << "WARNING: " << __func__ << " failed to unblock " "writes to current index objects: " << cpp_strerror(ret2) << dendl; diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index ec0113c1900..8253cbeea7b 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -11,6 +11,7 @@ #include "rgw_datalog.h" #include "cls/rgw/cls_rgw_client.h" +#include "common/errno.h" #define dout_subsys ceph_subsys_rgw @@ -479,6 +480,33 @@ int RGWSI_BucketIndex_RADOS::get_reshard_status(const DoutPrefixProvider *dpp, c return 0; } +int RGWSI_BucketIndex_RADOS::set_reshard_status(const DoutPrefixProvider *dpp, + const RGWBucketInfo& bucket_info, + cls_rgw_reshard_status status) +{ + const auto entry = cls_rgw_bucket_instance_entry{.reshard_status = status}; + + librados::IoCtx index_pool; + map bucket_objs; + + int r = open_bucket_index(dpp, bucket_info, std::nullopt, bucket_info.layout.current_index, &index_pool, &bucket_objs, nullptr); + if (r < 0) { + ldpp_dout(dpp, 0) << "ERROR: " << __func__ << + ": unable to open bucket index, r=" << r << " (" << + cpp_strerror(-r) << ")" << dendl; + return r; + } + + maybe_warn_about_blocking(dpp); // TODO: use AioTrottle + r = CLSRGWIssueSetBucketResharding(index_pool, bucket_objs, entry, cct->_conf->rgw_bucket_index_max_aio)(); + if (r < 0) { + ldpp_dout(dpp, 0) << "ERROR: " << __func__ << + ": unable to issue set bucket resharding, r=" << r << " (" << + cpp_strerror(-r) << ")" << dendl; + } + return r; +} + int RGWSI_BucketIndex_RADOS::handle_overwrite(const DoutPrefixProvider *dpp, const RGWBucketInfo& info, const RGWBucketInfo& orig_info, diff --git a/src/rgw/services/svc_bi_rados.h b/src/rgw/services/svc_bi_rados.h index b8990133fe0..41745d645b4 100644 --- a/src/rgw/services/svc_bi_rados.h +++ b/src/rgw/services/svc_bi_rados.h @@ -138,6 +138,9 @@ public: int get_reshard_status(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, std::list *status); + int set_reshard_status(const DoutPrefixProvider *dpp, + const RGWBucketInfo& bucket_info, + cls_rgw_reshard_status status); int handle_overwrite(const DoutPrefixProvider *dpp, const RGWBucketInfo& info, const RGWBucketInfo& orig_info,