From 5e7de76407c6f782f1aa5e53376669bbe4689ade Mon Sep 17 00:00:00 2001 From: liangmingyuan Date: Fri, 22 Mar 2024 09:13:09 +0800 Subject: [PATCH] rgw/reshard: Backward Compatibility The privious release only has one reshard phase: the progress phase which will block client writes. Because our release contains this phase and the process is same too, that means it is superset of privious release. So when privious rgw initiates a reshard, it will execute as before. When a updated rgw initiates a reshard, it firstly enter the logrecord phase which privious releases do not realized. That means the nodes which do not upgraded will deal with client write operations without recording logs. It may leads to part of these index entries missed. So we forbit this scene by adding `cls_rgw_set_bucket_resharding2()` and `cls_rgw_bucket_init_index2()` control source and target versions, old osds would fail the request with -EOPNOTSUPP. so radosgw could start by trying that on all shards. if there are no errors, it can safely proceed with the new scheme. If any of the osds do return -EOPNOTSUPP there, then rgw fall back to the current resharding scheme where writes are blocked the whole time. Signed-off-by: Mingyuan Liang --- src/cls/rgw/cls_rgw.cc | 3 ++ src/cls/rgw/cls_rgw_client.cc | 43 +++++++++++++++ src/cls/rgw/cls_rgw_client.h | 25 +++++++++ src/cls/rgw/cls_rgw_const.h | 3 +- src/cls/rgw/cls_rgw_types.h | 6 +-- src/rgw/driver/rados/rgw_rados.cc | 10 +++- src/rgw/driver/rados/rgw_rados.h | 4 +- src/rgw/driver/rados/rgw_reshard.cc | 83 ++++++++++++++++++++--------- src/rgw/driver/rados/rgw_reshard.h | 2 +- src/rgw/rgw_bucket_layout.h | 2 +- src/rgw/services/svc_bi.h | 9 +++- src/rgw/services/svc_bi_rados.cc | 17 ++++-- src/rgw/services/svc_bi_rados.h | 9 +++- src/test/cls_rgw/test_cls_rgw.cc | 2 +- 14 files changed, 175 insertions(+), 43 deletions(-) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 22d2e863f68aa..af520b6bb0e22 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -5010,6 +5010,7 @@ CLS_INIT(rgw) /* bucket index */ cls_register_cxx_method(h_class, RGW_BUCKET_INIT_INDEX, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_init_index, &h_rgw_bucket_init_index); + cls_register_cxx_method(h_class, RGW_BUCKET_INIT_INDEX2, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_init_index, &h_rgw_bucket_init_index); cls_register_cxx_method(h_class, RGW_BUCKET_SET_TAG_TIMEOUT, CLS_METHOD_RD | CLS_METHOD_WR, rgw_bucket_set_tag_timeout, &h_rgw_bucket_set_tag_timeout); cls_register_cxx_method(h_class, RGW_BUCKET_LIST, CLS_METHOD_RD, rgw_bucket_list, &h_rgw_bucket_list); cls_register_cxx_method(h_class, RGW_BUCKET_CHECK_INDEX, CLS_METHOD_RD, rgw_bucket_check_index, &h_rgw_bucket_check_index); @@ -5073,6 +5074,8 @@ CLS_INIT(rgw) /* resharding attribute */ cls_register_cxx_method(h_class, RGW_SET_BUCKET_RESHARDING, CLS_METHOD_RD | CLS_METHOD_WR, rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding); + cls_register_cxx_method(h_class, RGW_SET_BUCKET_RESHARDING2, CLS_METHOD_RD | CLS_METHOD_WR, + rgw_set_bucket_resharding, &h_rgw_set_bucket_resharding); cls_register_cxx_method(h_class, RGW_CLEAR_BUCKET_RESHARDING, CLS_METHOD_RD | CLS_METHOD_WR, rgw_clear_bucket_resharding, &h_rgw_clear_bucket_resharding); cls_register_cxx_method(h_class, RGW_GUARD_BUCKET_RESHARDING, CLS_METHOD_RD , diff --git a/src/cls/rgw/cls_rgw_client.cc b/src/cls/rgw/cls_rgw_client.cc index f8990dfe02ee0..a9b1a5bdb1c47 100644 --- a/src/cls/rgw/cls_rgw_client.cc +++ b/src/cls/rgw/cls_rgw_client.cc @@ -204,6 +204,17 @@ static bool issue_bucket_index_init_op(librados::IoCtx& io_ctx, return manager->aio_operate(io_ctx, shard_id, oid, &op); } +static bool issue_bucket_index_init_op2(librados::IoCtx& io_ctx, + const int shard_id, + const string& oid, + BucketIndexAioManager *manager) { + bufferlist in; + librados::ObjectWriteOperation op; + op.create(true); + op.exec(RGW_CLASS, RGW_BUCKET_INIT_INDEX2, in); + return manager->aio_operate(io_ctx, shard_id, oid, &op); +} + static bool issue_bucket_index_clean_op(librados::IoCtx& io_ctx, const int shard_id, const string& oid, @@ -233,6 +244,11 @@ int CLSRGWIssueBucketIndexInit::issue_op(const int shard_id, const string& oid) return issue_bucket_index_init_op(io_ctx, shard_id, oid, &manager); } +int CLSRGWIssueBucketIndexInit2::issue_op(const int shard_id, const string& oid) +{ + return issue_bucket_index_init_op2(io_ctx, shard_id, oid, &manager); +} + void CLSRGWIssueBucketIndexInit::cleanup() { // Do best effort removal @@ -241,6 +257,14 @@ void CLSRGWIssueBucketIndexInit::cleanup() } } +void CLSRGWIssueBucketIndexInit2::cleanup() +{ + // Do best effort removal + for (auto citer = objs_container.begin(); citer != iter; ++citer) { + io_ctx.remove(citer->second); + } +} + int CLSRGWIssueBucketIndexClean::issue_op(const int shard_id, const string& oid) { return issue_bucket_index_clean_op(io_ctx, shard_id, oid, &manager); @@ -1251,7 +1275,26 @@ static bool issue_set_bucket_resharding(librados::IoCtx& io_ctx, return manager->aio_operate(io_ctx, shard_id, oid, &op); } +static bool issue_set_bucket_resharding2(librados::IoCtx& io_ctx, + const int shard_id, const string& oid, + const cls_rgw_bucket_instance_entry& entry, + BucketIndexAioManager *manager) { + bufferlist in; + cls_rgw_set_bucket_resharding_op call; + call.entry = entry; + encode(call, in); + librados::ObjectWriteOperation op; + op.assert_exists(); // the shard must exist; if not fail rather than recreate + op.exec(RGW_CLASS, RGW_SET_BUCKET_RESHARDING2, in); + return manager->aio_operate(io_ctx, shard_id, oid, &op); +} + int CLSRGWIssueSetBucketResharding::issue_op(const int shard_id, const string& oid) { return issue_set_bucket_resharding(io_ctx, shard_id, oid, entry, &manager); } + +int CLSRGWIssueSetBucketResharding2::issue_op(const int shard_id, const string& oid) +{ + return issue_set_bucket_resharding2(io_ctx, shard_id, oid, entry, &manager); +} diff --git a/src/cls/rgw/cls_rgw_client.h b/src/cls/rgw/cls_rgw_client.h index 2d4fd46e74aff..c5336030c07c2 100644 --- a/src/cls/rgw/cls_rgw_client.h +++ b/src/cls/rgw/cls_rgw_client.h @@ -316,6 +316,20 @@ public: }; +class CLSRGWIssueBucketIndexInit2 : public CLSRGWConcurrentIO { +protected: + int issue_op(int shard_id, const std::string& oid) override; + int valid_ret_code() override { return -EEXIST; } + void cleanup() override; +public: + CLSRGWIssueBucketIndexInit2(librados::IoCtx& ioc, + std::map& _bucket_objs, + uint32_t _max_aio) : + CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio) {} + virtual ~CLSRGWIssueBucketIndexInit2() override {} +}; + + class CLSRGWIssueBucketIndexClean : public CLSRGWConcurrentIO { protected: int issue_op(int shard_id, const std::string& oid) override; @@ -560,6 +574,17 @@ public: virtual ~CLSRGWIssueSetBucketResharding() override {} }; +class CLSRGWIssueSetBucketResharding2 : public CLSRGWConcurrentIO { + cls_rgw_bucket_instance_entry entry; +protected: + int issue_op(int shard_id, const std::string& oid) override; +public: + CLSRGWIssueSetBucketResharding2(librados::IoCtx& ioc, std::map& _bucket_objs, + const cls_rgw_bucket_instance_entry& _entry, + uint32_t _max_aio) : CLSRGWConcurrentIO(ioc, _bucket_objs, _max_aio), entry(_entry) {} + virtual ~CLSRGWIssueSetBucketResharding2() override {} +}; + class CLSRGWIssueResyncBucketBILog : public CLSRGWConcurrentIO { protected: int issue_op(int shard_id, const std::string& oid); diff --git a/src/cls/rgw/cls_rgw_const.h b/src/cls/rgw/cls_rgw_const.h index d8c3f1dcb99e2..4c8f20ffa9e89 100644 --- a/src/cls/rgw/cls_rgw_const.h +++ b/src/cls/rgw/cls_rgw_const.h @@ -12,7 +12,7 @@ constexpr int RGWBIAdvanceAndRetryError = -EFBIG; /* bucket index */ #define RGW_BUCKET_INIT_INDEX "bucket_init_index" - +#define RGW_BUCKET_INIT_INDEX2 "bucket_init_index2" #define RGW_BUCKET_SET_TAG_TIMEOUT "bucket_set_tag_timeout" #define RGW_BUCKET_LIST "bucket_list" @@ -76,6 +76,7 @@ constexpr int RGWBIAdvanceAndRetryError = -EFBIG; /* resharding attribute */ #define RGW_SET_BUCKET_RESHARDING "set_bucket_resharding" +#define RGW_SET_BUCKET_RESHARDING2 "set_bucket_resharding2" #define RGW_CLEAR_BUCKET_RESHARDING "clear_bucket_resharding" #define RGW_GUARD_BUCKET_RESHARDING "guard_bucket_resharding" #define RGW_GET_BUCKET_RESHARDING "get_bucket_resharding" diff --git a/src/cls/rgw/cls_rgw_types.h b/src/cls/rgw/cls_rgw_types.h index 9cc1ff1a580de..f3ef5ec6aec75 100644 --- a/src/cls/rgw/cls_rgw_types.h +++ b/src/cls/rgw/cls_rgw_types.h @@ -736,9 +736,9 @@ inline bool operator!=(const rgw_bucket_category_stats& lhs, enum class cls_rgw_reshard_status : uint8_t { NOT_RESHARDING = 0, - IN_LOGRECORD = 1, - IN_PROGRESS = 2, - DONE = 3 + IN_PROGRESS = 1, + DONE = 2, + IN_LOGRECORD = 3 }; std::ostream& operator<<(std::ostream&, cls_rgw_reshard_status); diff --git a/src/rgw/driver/rados/rgw_rados.cc b/src/rgw/driver/rados/rgw_rados.cc index c9a4ebd7b93b1..1df24538067f4 100644 --- a/src/rgw/driver/rados/rgw_rados.cc +++ b/src/rgw/driver/rados/rgw_rados.cc @@ -5593,7 +5593,10 @@ 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) +int RGWRados::bucket_set_reshard(const DoutPrefixProvider *dpp, + const RGWBucketInfo& bucket_info, + const cls_rgw_bucket_instance_entry& entry, + bool judge_support_logrecord) { librados::IoCtx index_pool; map bucket_objs; @@ -5606,7 +5609,10 @@ int RGWRados::bucket_set_reshard(const DoutPrefixProvider *dpp, const RGWBucketI return r; } - r = CLSRGWIssueSetBucketResharding(index_pool, bucket_objs, entry, cct->_conf->rgw_bucket_index_max_aio)(); + if (judge_support_logrecord) + r = CLSRGWIssueSetBucketResharding2(index_pool, bucket_objs, entry, cct->_conf->rgw_bucket_index_max_aio)(); + else + 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 << " (" << diff --git a/src/rgw/driver/rados/rgw_rados.h b/src/rgw/driver/rados/rgw_rados.h index 8f88650abd199..4321cddf40ee3 100644 --- a/src/rgw/driver/rados/rgw_rados.h +++ b/src/rgw/driver/rados/rgw_rados.h @@ -1586,7 +1586,9 @@ 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 bucket_set_reshard(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, + const cls_rgw_bucket_instance_entry& entry, + bool judge_support_logrecord = false); 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 ac85bdecddc3e..3ff4915dd75c3 100644 --- a/src/rgw/driver/rados/rgw_reshard.cc +++ b/src/rgw/driver/rados/rgw_reshard.cc @@ -386,12 +386,13 @@ RGWBucketReshard::RGWBucketReshard(rgw::sal::RadosStore* _store, static int set_resharding_status(const DoutPrefixProvider *dpp, rgw::sal::RadosStore* store, const RGWBucketInfo& bucket_info, - cls_rgw_reshard_status status) + cls_rgw_reshard_status status, + bool judge_support_logrecord = false) { cls_rgw_bucket_instance_entry instance_entry; instance_entry.set_status(status); - int ret = store->getRados()->bucket_set_reshard(dpp, bucket_info, instance_entry); + int ret = store->getRados()->bucket_set_reshard(dpp, bucket_info, instance_entry, judge_support_logrecord); if (ret < 0) { ldpp_dout(dpp, 0) << "RGWReshard::" << __func__ << " ERROR: error setting bucket resharding flag on bucket index: " << cpp_strerror(-ret) << dendl; @@ -421,9 +422,15 @@ static int remove_old_reshard_instance(rgw::sal::RadosStore* store, static int init_target_index(rgw::sal::RadosStore* store, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& index, + bool& support_logrecord, const DoutPrefixProvider* dpp) { - int ret = store->svc()->bi->init_index(dpp, bucket_info, index); + int ret = store->svc()->bi->init_index(dpp, bucket_info, index, true); + if (ret == -EOPNOTSUPP) { + ldpp_dout(dpp, 0) << "WARNING: " << "init_index() does not supported logrecord" << dendl; + support_logrecord = false; + ret = store->svc()->bi->init_index(dpp, bucket_info, index, false); + } if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to initialize " "target index shard objects: " << cpp_strerror(ret) << dendl; @@ -453,6 +460,7 @@ static int init_target_layout(rgw::sal::RadosStore* store, std::map& bucket_attrs, ReshardFaultInjector& fault, const uint32_t new_num_shards, + bool& support_logrecord, const DoutPrefixProvider* dpp, optional_yield y) { auto prev = bucket_info.layout; // make a copy for cleanup @@ -490,7 +498,7 @@ static int init_target_layout(rgw::sal::RadosStore* store, } // create the index shard objects - int ret = init_target_index(store, bucket_info, target, dpp); + int ret = init_target_index(store, bucket_info, target, support_logrecord, dpp); if (ret < 0) { return ret; } @@ -503,7 +511,11 @@ static int init_target_layout(rgw::sal::RadosStore* store, // update resharding state bucket_info.layout.target_index = target; - bucket_info.layout.resharding = rgw::BucketReshardState::InLogrecord; + if (support_logrecord) { + bucket_info.layout.resharding = rgw::BucketReshardState::InLogrecord; + } else { + bucket_info.layout.resharding = rgw::BucketReshardState::InProgress; + } // update the judge time meanwhile bucket_info.layout.judge_reshard_lock_time = ceph::real_clock::now(); @@ -633,6 +645,7 @@ static int init_reshard(rgw::sal::RadosStore* store, std::map& bucket_attrs, ReshardFaultInjector& fault, const uint32_t new_num_shards, + bool& support_logrecord, const DoutPrefixProvider *dpp, optional_yield y) { if (new_num_shards == 0) { @@ -640,17 +653,31 @@ static int init_reshard(rgw::sal::RadosStore* store, return -EINVAL; } - int ret = init_target_layout(store, bucket_info, bucket_attrs, fault, new_num_shards, dpp, y); + int ret = init_target_layout(store, bucket_info, bucket_attrs, fault, new_num_shards, + support_logrecord, dpp, y); if (ret < 0) { return ret; } - 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); + 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, + true); + } + if (ret == -EOPNOTSUPP) { + ldpp_dout(dpp, 0) << "WARNING: " << "set_resharding_status()" + << " doesn't support logrecords" << dendl; + support_logrecord = false; + } } + if (!support_logrecord) { + ret = set_resharding_status(dpp, store, bucket_info, + cls_rgw_reshard_status::IN_PROGRESS, + false); + } if (ret < 0) { ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to pause " "writes to the current index: " << cpp_strerror(ret) << dendl; @@ -1154,6 +1181,7 @@ int RGWBucketReshard::reshard_process(const rgw::bucket_index_layout_generation& int RGWBucketReshard::do_reshard(const rgw::bucket_index_layout_generation& current, const rgw::bucket_index_layout_generation& target, int max_op_entries, // max num to process per op + bool support_logrecord, bool verbose, ostream *out, Formatter *formatter, @@ -1175,24 +1203,26 @@ int RGWBucketReshard::do_reshard(const rgw::bucket_index_layout_generation& curr bool verbose_json_out = verbose && (formatter != nullptr) && (out != nullptr); - // a log is written to shard going with client op at this state - ceph_assert(bucket_info.layout.resharding == rgw::BucketReshardState::InLogrecord); - int ret = reshard_process(current, max_op_entries, target_shards_mgr, verbose_json_out, out, - formatter, bucket_info.layout.resharding, dpp, y); - if (ret < 0) { - ldpp_dout(dpp, 0) << __func__ << ": failed in logrecord state of reshard ret = " << ret << dendl; - return ret; - } + if (support_logrecord) { + // a log is written to shard going with client op at this state + ceph_assert(bucket_info.layout.resharding == rgw::BucketReshardState::InLogrecord); + int ret = reshard_process(current, max_op_entries, target_shards_mgr, verbose_json_out, out, + formatter, bucket_info.layout.resharding, dpp, y); + if (ret < 0) { + ldpp_dout(dpp, 0) << __func__ << ": failed in logrecord state of reshard ret = " << ret << dendl; + return ret; + } - ret = change_reshard_state(store, bucket_info, bucket_attrs, fault, dpp, y); - if (ret < 0) { - return ret; + ret = change_reshard_state(store, bucket_info, bucket_attrs, fault, dpp, y); + if (ret < 0) { + return ret; + } } // block the client op and complete the resharding ceph_assert(bucket_info.layout.resharding == rgw::BucketReshardState::InProgress); - ret = reshard_process(current, max_op_entries, target_shards_mgr, verbose_json_out, out, - formatter, bucket_info.layout.resharding, dpp, y); + int ret = reshard_process(current, max_op_entries, target_shards_mgr, verbose_json_out, out, + formatter, bucket_info.layout.resharding, dpp, y); if (ret < 0) { ldpp_dout(dpp, 0) << __func__ << ": failed in progress state of reshard ret = " << ret << dendl; return ret; @@ -1231,8 +1261,10 @@ int RGWBucketReshard::execute(int num_shards, } } + bool support_logrecord = true; // prepare the target index and add its layout the bucket info - ret = init_reshard(store, bucket_info, bucket_attrs, fault, num_shards, dpp, y); + ret = init_reshard(store, bucket_info, bucket_attrs, fault, num_shards, + support_logrecord, dpp, y); if (ret < 0) { return ret; } @@ -1241,7 +1273,8 @@ int RGWBucketReshard::execute(int num_shards, ret == 0) { // no fault injected, do the reshard ret = do_reshard(bucket_info.layout.current_index, *bucket_info.layout.target_index, - max_op_entries, verbose, out, formatter, fault, dpp, y); + max_op_entries, support_logrecord, + verbose, out, formatter, fault, dpp, y); } if (ret < 0) { diff --git a/src/rgw/driver/rados/rgw_reshard.h b/src/rgw/driver/rados/rgw_reshard.h index 4101f9f06ed3c..ea5bb6e713d5a 100644 --- a/src/rgw/driver/rados/rgw_reshard.h +++ b/src/rgw/driver/rados/rgw_reshard.h @@ -93,7 +93,7 @@ class RGWBucketReshard { const DoutPrefixProvider *dpp, optional_yield y); int do_reshard(const rgw::bucket_index_layout_generation& current, const rgw::bucket_index_layout_generation& target, - int max_entries, + int max_entries, bool support_logrecord, bool verbose, std::ostream *os, Formatter *formatter, diff --git a/src/rgw/rgw_bucket_layout.h b/src/rgw/rgw_bucket_layout.h index daf890162f774..b360dd32c3715 100644 --- a/src/rgw/rgw_bucket_layout.h +++ b/src/rgw/rgw_bucket_layout.h @@ -219,8 +219,8 @@ inline bucket_index_layout_generation log_to_index_layout(const bucket_log_layou enum class BucketReshardState : uint8_t { None, - InLogrecord, InProgress, + InLogrecord, }; std::string_view to_string(const BucketReshardState& s); bool parse(std::string_view str, BucketReshardState& s); diff --git a/src/rgw/services/svc_bi.h b/src/rgw/services/svc_bi.h index bd811e1623aa9..901c28d59fdb4 100644 --- a/src/rgw/services/svc_bi.h +++ b/src/rgw/services/svc_bi.h @@ -29,8 +29,13 @@ public: RGWSI_BucketIndex(CephContext *cct) : RGWServiceInstance(cct) {} virtual ~RGWSI_BucketIndex() {} - virtual int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) = 0; - virtual int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) = 0; + virtual int init_index(const DoutPrefixProvider *dpp, + RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& idx_layout, + bool judge_support_logrecord = false) = 0; + virtual int clean_index(const DoutPrefixProvider *dpp, + RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& idx_layout) = 0; virtual int read_stats(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info, diff --git a/src/rgw/services/svc_bi_rados.cc b/src/rgw/services/svc_bi_rados.cc index 20c842c3805d0..15cd5cd58ed36 100644 --- a/src/rgw/services/svc_bi_rados.cc +++ b/src/rgw/services/svc_bi_rados.cc @@ -351,7 +351,10 @@ int RGWSI_BucketIndex_RADOS::cls_bucket_head(const DoutPrefixProvider *dpp, return 0; } -int RGWSI_BucketIndex_RADOS::init_index(const DoutPrefixProvider *dpp,RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) +int RGWSI_BucketIndex_RADOS::init_index(const DoutPrefixProvider *dpp, + RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& idx_layout, + bool judge_support_logrecord) { librados::IoCtx index_pool; @@ -366,9 +369,15 @@ int RGWSI_BucketIndex_RADOS::init_index(const DoutPrefixProvider *dpp,RGWBucketI map bucket_objs; get_bucket_index_objects(dir_oid, idx_layout.layout.normal.num_shards, idx_layout.gen, &bucket_objs); - return CLSRGWIssueBucketIndexInit(index_pool, - bucket_objs, - cct->_conf->rgw_bucket_index_max_aio)(); + if (judge_support_logrecord) { + return CLSRGWIssueBucketIndexInit2(index_pool, + bucket_objs, + cct->_conf->rgw_bucket_index_max_aio)(); + } else { + return CLSRGWIssueBucketIndexInit(index_pool, + bucket_objs, + cct->_conf->rgw_bucket_index_max_aio)(); + } } int RGWSI_BucketIndex_RADOS::clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) diff --git a/src/rgw/services/svc_bi_rados.h b/src/rgw/services/svc_bi_rados.h index c6c11f8bc00b9..7acf5c088070e 100644 --- a/src/rgw/services/svc_bi_rados.h +++ b/src/rgw/services/svc_bi_rados.h @@ -121,8 +121,13 @@ public: return bucket_shard_index(sharding_key, num_shards); } - int init_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info,const rgw::bucket_index_layout_generation& idx_layout) override; - int clean_index(const DoutPrefixProvider *dpp, RGWBucketInfo& bucket_info, const rgw::bucket_index_layout_generation& idx_layout) override; + int init_index(const DoutPrefixProvider *dpp, + RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& idx_layout, + bool judge_support_logrecord = false) override; + int clean_index(const DoutPrefixProvider *dpp, + RGWBucketInfo& bucket_info, + const rgw::bucket_index_layout_generation& idx_layout) override; /* RADOS specific */ diff --git a/src/test/cls_rgw/test_cls_rgw.cc b/src/test/cls_rgw/test_cls_rgw.cc index 0cee97e02a228..be6d499faf23f 100644 --- a/src/test/cls_rgw/test_cls_rgw.cc +++ b/src/test/cls_rgw/test_cls_rgw.cc @@ -1346,7 +1346,7 @@ void set_reshard_status(librados::IoCtx& ioctx, const std::string& oid, { map bucket_objs; bucket_objs[0] = oid; - int r = CLSRGWIssueSetBucketResharding(ioctx, bucket_objs, entry, 1)(); + int r = CLSRGWIssueSetBucketResharding2(ioctx, bucket_objs, entry, 1)(); ASSERT_EQ(0, r); } -- 2.39.5