]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/reshard: Backward Compatibility
authorliangmingyuan <liangmingyuan@baidu.com>
Fri, 22 Mar 2024 01:13:09 +0000 (09:13 +0800)
committerliangmingyuan <liangmingyuan@baidu.com>
Mon, 22 Jul 2024 01:19:25 +0000 (09:19 +0800)
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 <liangmingyuan@baidu.com>
14 files changed:
src/cls/rgw/cls_rgw.cc
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_const.h
src/cls/rgw/cls_rgw_types.h
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_reshard.cc
src/rgw/driver/rados/rgw_reshard.h
src/rgw/rgw_bucket_layout.h
src/rgw/services/svc_bi.h
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_bi_rados.h
src/test/cls_rgw/test_cls_rgw.cc

index 22d2e863f68aa8c89177eb44c44c4796d16f591d..af520b6bb0e2281fa0bbc61e8f91e5e51d8540cd 100644 (file)
@@ -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 ,
index f8990dfe02ee029806f870f51c588efbc2155e59..a9b1a5bdb1c474fc31033c31a84ca3e21e1dcb38 100644 (file)
@@ -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);
+}
index 2d4fd46e74aff222c3dea8156d1e4519fdb2b04b..c5336030c07c2c3bd64626d15a6bf406511afcc5 100644 (file)
@@ -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<int, std::string>& _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<int, std::string>& _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);
index d8c3f1dcb99e2591184bd95bf422814154fcf6f8..4c8f20ffa9e897f7120fce335a3777edd208f54f 100644 (file)
@@ -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"
index 9cc1ff1a580ded8fb065522e841f0666ae2a9f71..f3ef5ec6aec753c1cc93c48c79ebde02f2ae72f6 100644 (file)
@@ -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);
 
index c9a4ebd7b93b1f65e50ecb8168366ef27840b15c..1df24538067f48a7c1b24590a3bdf2800cbbc80d 100644 (file)
@@ -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<int, string> 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 << " (" <<
index 8f88650abd1999855ae90ea69e37dfbceb2a35db..4321cddf40ee37ef699a74ffaa3aec19c161cb8b 100644 (file)
@@ -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<rgw_obj_index_key>& oid_list);
index ac85bdecddc3ecaeaf6ffadf8fefa3359891dc23..3ff4915dd75c3775c32fc2e259333bec68cba106 100644 (file)
@@ -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<std::string, bufferlist>& 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<std::string, bufferlist>& 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) {
index 4101f9f06ed3c9bade8e71aecb9bd8e88e942306..ea5bb6e713d5a1bc17903ea9c0019a8e82e5e150 100644 (file)
@@ -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,
index daf890162f774916d9e61304ec4fee16d7f7a639..b360dd32c3715fa70a4e7e91b6b18a06d16cf626 100644 (file)
@@ -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);
index bd811e1623aa94128919f6ea23c382d7a4517f77..901c28d59fdb41b9b95a85484a414f8e5de3dff1 100644 (file)
@@ -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,
index 20c842c3805d0918e1244b45cf42e2fe76c28282..15cd5cd58ed36319fb325dd2125eb75cee1f25df 100644 (file)
@@ -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<int, string> 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)
index c6c11f8bc00b9590be902eba26f2a17191785017..7acf5c088070e5986f48c58b4b5ccdef09030f40 100644 (file)
@@ -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 */
 
index 0cee97e02a22829262ae84b3c00838093e90f860..be6d499faf23fad523decbf128ab58f0eb0c475c 100644 (file)
@@ -1346,7 +1346,7 @@ void set_reshard_status(librados::IoCtx& ioctx, const std::string& oid,
 {
   map<int, string> 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);
 }