]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rados: move RGWRados::bucket_set_reshard() to RGWSI_BucketIndex_RADOS
authorCasey Bodley <cbodley@redhat.com>
Fri, 15 Nov 2024 14:17:40 +0000 (09:17 -0500)
committerCasey Bodley <cbodley@redhat.com>
Mon, 7 Apr 2025 17:14:27 +0000 (13:14 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_rados.h
src/rgw/driver/rados/rgw_reshard.cc
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_bi_rados.h

index ebdea6f6e4a26218cb466da040e5eca59631d5af..2b3c0ffddf8a5856189b0726656f021ce16c3de4 100644 (file)
@@ -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<int, string> 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;
index 4c471bbd85b54118048f025f1ed2837d630340bc..eda57dc97c01b7af5314029e9becf3a0c64046ce 100644 (file)
@@ -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<rgw_obj_index_key>& oid_list);
index 82705602b361b90ae0ac6819995c520f41ca7fa5..d975a2ae0d7a88bfe6edd6dc87da7c41178dd230 100644 (file)
@@ -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;
index ec0113c190093465343e15cedadd71349f1638b6..8253cbeea7b905f5ab99e39669b1ef5380247b6b 100644 (file)
@@ -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<int, string> 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,
index b8990133fe09a781d5b4a57c672f1fcc1be4963b..41745d645b44c3b5c66c66fd61120041c326f1d6 100644 (file)
@@ -138,6 +138,9 @@ public:
 
   int get_reshard_status(const DoutPrefixProvider *dpp, const RGWBucketInfo& bucket_info,
                          std::list<cls_rgw_bucket_instance_entry> *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,