]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/rgw: Changing null_yield to optional_yield
authorKalpesh Pandya <kapandya@redhat.com>
Mon, 20 Feb 2023 20:22:16 +0000 (01:52 +0530)
committerKalpesh Pandya <kapandya@redhat.com>
Mon, 19 Jun 2023 21:48:30 +0000 (03:18 +0530)
Changing null_yield in rgw_reshard.cc

Signed-off-by: Kalpesh Pandya <kapandya@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_reshard.cc
src/rgw/driver/rados/rgw_reshard.h
src/rgw/rgw_admin.cc

index e8710607b66e290838ecc18f409706d4725bac6a..0c930581189b23b5ac7e984e639e5ae5a617e8a5 100644 (file)
@@ -7029,7 +7029,7 @@ int RGWRados::block_while_resharding(RGWRados::BucketShard *bs,
           continue; // try again
         }
 
-       ret = RGWBucketReshard::clear_resharding(this->driver, bucket_info, bucket_attrs, dpp);
+       ret = RGWBucketReshard::clear_resharding(this->driver, bucket_info, bucket_attrs, dpp, y);
        reshard_lock.unlock();
        if (ret == -ENOENT) {
          ldpp_dout(dpp, 5) << __func__ <<
index 444253933961cfbb052c7d505460904975ccec15..31eff5312df4812e2d70fe30bb0400fa1fc5cc82 100644 (file)
@@ -275,11 +275,11 @@ static int set_resharding_status(const DoutPrefixProvider *dpp,
 
 static int remove_old_reshard_instance(rgw::sal::RadosStore* store,
                                        const rgw_bucket& bucket,
-                                       const DoutPrefixProvider* dpp)
+                                       const DoutPrefixProvider* dpp, optional_yield y)
 {
   RGWBucketInfo info;
   int r = store->getRados()->get_bucket_instance_info(bucket, info, nullptr,
-                                                      nullptr, null_yield, dpp);
+                                                      nullptr, y, dpp);
   if (r < 0) {
     return r;
   }
@@ -287,7 +287,7 @@ static int remove_old_reshard_instance(rgw::sal::RadosStore* store,
   // delete its shard objects (ignore errors)
   store->svc()->bi->clean_index(dpp, info, info.layout.current_index);
   // delete the bucket instance metadata
-  return store->ctl()->bucket->remove_bucket_instance_info(bucket, info, null_yield, dpp);
+  return store->ctl()->bucket->remove_bucket_instance_info(bucket, info, y, dpp);
 }
 
 // initialize the new bucket index shard objects
@@ -326,7 +326,7 @@ static int init_target_layout(rgw::sal::RadosStore* store,
                              std::map<std::string, bufferlist>& bucket_attrs,
                               ReshardFaultInjector& fault,
                               uint32_t new_num_shards,
-                              const DoutPrefixProvider* dpp)
+                              const DoutPrefixProvider* dpp, optional_yield y)
 {
   auto prev = bucket_info.layout; // make a copy for cleanup
   const auto current = prev.current_index;
@@ -346,7 +346,7 @@ static int init_target_layout(rgw::sal::RadosStore* store,
       ldout(store->ctx(), 10) << __func__ << " removing target bucket instance "
           "from a previous reshard attempt" << dendl;
       // ignore errors
-      remove_old_reshard_instance(store, new_bucket, dpp);
+      remove_old_reshard_instance(store, new_bucket, dpp, y);
     }
     bucket_info.reshard_status = cls_rgw_reshard_status::NOT_RESHARDING;
   }
@@ -379,7 +379,7 @@ static int init_target_layout(rgw::sal::RadosStore* store,
     if (ret = fault.check("set_target_layout");
         ret == 0) { // no fault injected, write the bucket instance metadata
       ret = store->getRados()->put_bucket_instance_info(bucket_info, false,
-                                                        real_time(), &bucket_attrs, dpp, null_yield);
+                                                        real_time(), &bucket_attrs, dpp, y);
     } else if (ret == -ECANCELED) {
       fault.clear(); // clear the fault so a retry can succeed
     }
@@ -388,7 +388,7 @@ static int init_target_layout(rgw::sal::RadosStore* store,
       // racing write detected, read the latest bucket info and try again
       int ret2 = store->getRados()->get_bucket_instance_info(
           bucket_info.bucket, bucket_info,
-          nullptr, &bucket_attrs, null_yield, dpp);
+          nullptr, &bucket_attrs, y, dpp);
       if (ret2 < 0) {
         ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to read "
             "bucket info: " << cpp_strerror(ret2) << dendl;
@@ -428,7 +428,7 @@ static int revert_target_layout(rgw::sal::RadosStore* store,
                                 RGWBucketInfo& bucket_info,
                                std::map<std::string, bufferlist>& bucket_attrs,
                                 ReshardFaultInjector& fault,
-                                const DoutPrefixProvider* dpp)
+                                const DoutPrefixProvider* dpp, optional_yield y)
 {
   auto prev = bucket_info.layout; // make a copy for cleanup
 
@@ -452,7 +452,7 @@ static int revert_target_layout(rgw::sal::RadosStore* store,
         ret == 0) { // no fault injected, revert the bucket instance metadata
       ret = store->getRados()->put_bucket_instance_info(bucket_info, false,
                                                         real_time(),
-                                                        &bucket_attrs, dpp, null_yield);
+                                                        &bucket_attrs, dpp, y);
     } else if (ret == -ECANCELED) {
       fault.clear(); // clear the fault so a retry can succeed
     }
@@ -461,7 +461,7 @@ static int revert_target_layout(rgw::sal::RadosStore* store,
       // racing write detected, read the latest bucket info and try again
       int ret2 = store->getRados()->get_bucket_instance_info(
           bucket_info.bucket, bucket_info,
-          nullptr, &bucket_attrs, null_yield, dpp);
+          nullptr, &bucket_attrs, y, dpp);
       if (ret2 < 0) {
         ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to read "
             "bucket info: " << cpp_strerror(ret2) << dendl;
@@ -502,14 +502,14 @@ static int init_reshard(rgw::sal::RadosStore* store,
                        std::map<std::string, bufferlist>& bucket_attrs,
                         ReshardFaultInjector& fault,
                         uint32_t new_num_shards,
-                        const DoutPrefixProvider *dpp)
+                        const DoutPrefixProvider *dpp, optional_yield y)
 {
   if (new_num_shards == 0) {
     ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " got invalid new_num_shards=0" << dendl;
     return -EINVAL;
   }
 
-  int ret = init_target_layout(store, bucket_info, bucket_attrs, fault, new_num_shards, dpp);
+  int ret = init_target_layout(store, bucket_info, bucket_attrs, fault, new_num_shards, dpp, y);
   if (ret < 0) {
     return ret;
   }
@@ -524,7 +524,7 @@ static int init_reshard(rgw::sal::RadosStore* store,
     ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to pause "
         "writes to the current index: " << cpp_strerror(ret) << dendl;
     // clean up the target layout (ignore errors)
-    revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp);
+    revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp, y);
     return ret;
   }
   return 0;
@@ -534,7 +534,7 @@ static int cancel_reshard(rgw::sal::RadosStore* store,
                           RGWBucketInfo& bucket_info,
                          std::map<std::string, bufferlist>& bucket_attrs,
                           ReshardFaultInjector& fault,
-                          const DoutPrefixProvider *dpp)
+                          const DoutPrefixProvider *dpp, optional_yield y)
 {
   // unblock writes to the current index shard objects
   int ret = set_resharding_status(dpp, store, bucket_info,
@@ -546,7 +546,7 @@ static int cancel_reshard(rgw::sal::RadosStore* store,
   }
 
   if (bucket_info.layout.target_index) {
-    return revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp);
+    return revert_target_layout(store, bucket_info, bucket_attrs, fault, dpp, y);
   }
   // there is nothing to revert
   return 0;
@@ -556,7 +556,7 @@ static int commit_target_layout(rgw::sal::RadosStore* store,
                                 RGWBucketInfo& bucket_info,
                                 std::map<std::string, bufferlist>& bucket_attrs,
                                 ReshardFaultInjector& fault,
-                                const DoutPrefixProvider *dpp)
+                                const DoutPrefixProvider *dpp, optional_yield y)
 {
   auto& layout = bucket_info.layout;
   const auto next_log_gen = layout.logs.empty() ? 1 :
@@ -578,7 +578,7 @@ static int commit_target_layout(rgw::sal::RadosStore* store,
   int ret = fault.check("commit_target_layout");
   if (ret == 0) { // no fault injected, write the bucket instance metadata
     ret = store->getRados()->put_bucket_instance_info(
-        bucket_info, false, real_time(), &bucket_attrs, dpp, null_yield);
+        bucket_info, false, real_time(), &bucket_attrs, dpp, y);
   } else if (ret == -ECANCELED) {
     fault.clear(); // clear the fault so a retry can succeed
   }
@@ -589,7 +589,7 @@ static int commit_reshard(rgw::sal::RadosStore* store,
                           RGWBucketInfo& bucket_info,
                          std::map<std::string, bufferlist>& bucket_attrs,
                           ReshardFaultInjector& fault,
-                          const DoutPrefixProvider *dpp)
+                          const DoutPrefixProvider *dpp, optional_yield y)
 {
   auto prev = bucket_info.layout; // make a copy for cleanup
 
@@ -598,12 +598,12 @@ static int commit_reshard(rgw::sal::RadosStore* store,
   int tries = 0;
   int ret = 0;
   do {
-    ret = commit_target_layout(store, bucket_info, bucket_attrs, fault, dpp);
+    ret = commit_target_layout(store, bucket_info, bucket_attrs, fault, dpp, y);
     if (ret == -ECANCELED) {
       // racing write detected, read the latest bucket info and try again
       int ret2 = store->getRados()->get_bucket_instance_info(
           bucket_info.bucket, bucket_info,
-          nullptr, &bucket_attrs, null_yield, dpp);
+          nullptr, &bucket_attrs, y, dpp);
       if (ret2 < 0) {
         ldpp_dout(dpp, 0) << "ERROR: " << __func__ << " failed to read "
             "bucket info: " << cpp_strerror(ret2) << dendl;
@@ -681,13 +681,13 @@ static int commit_reshard(rgw::sal::RadosStore* store,
 int RGWBucketReshard::clear_resharding(rgw::sal::RadosStore* store,
                                        RGWBucketInfo& bucket_info,
                                       std::map<std::string, bufferlist>& bucket_attrs,
-                                       const DoutPrefixProvider* dpp)
+                                       const DoutPrefixProvider* dpp, optional_yield y)
 {
   ReshardFaultInjector no_fault;
-  return cancel_reshard(store, bucket_info, bucket_attrs, no_fault, dpp);
+  return cancel_reshard(store, bucket_info, bucket_attrs, no_fault, dpp, y);
 }
 
-int RGWBucketReshard::cancel(const DoutPrefixProvider* dpp)
+int RGWBucketReshard::cancel(const DoutPrefixProvider* dpp, optional_yield y)
 {
   int ret = reshard_lock.lock(dpp);
   if (ret < 0) {
@@ -698,7 +698,7 @@ int RGWBucketReshard::cancel(const DoutPrefixProvider* dpp)
     ldpp_dout(dpp, -1) << "ERROR: bucket is not resharding" << dendl;
     ret = -EINVAL;
   } else {
-    ret = clear_resharding(store, bucket_info, bucket_attrs, dpp);
+    ret = clear_resharding(store, bucket_info, bucket_attrs, dpp, y);
   }
 
   reshard_lock.unlock();
@@ -964,7 +964,7 @@ int RGWBucketReshard::execute(int num_shards,
   }
 
   // prepare the target index and add its layout the bucket info
-  ret = init_reshard(store, bucket_info, bucket_attrs, fault, num_shards, dpp);
+  ret = init_reshard(store, bucket_info, bucket_attrs, fault, num_shards, dpp, y);
   if (ret < 0) {
     return ret;
   }
@@ -977,14 +977,14 @@ int RGWBucketReshard::execute(int num_shards,
   }
 
   if (ret < 0) {
-    cancel_reshard(store, bucket_info, bucket_attrs, fault, dpp);
+    cancel_reshard(store, bucket_info, bucket_attrs, fault, dpp, y);
 
     ldpp_dout(dpp, 1) << __func__ << " INFO: reshard of bucket \""
         << bucket_info.bucket.name << "\" canceled due to errors" << dendl;
     return ret;
   }
 
-  ret = commit_reshard(store, bucket_info, bucket_attrs, fault, dpp);
+  ret = commit_reshard(store, bucket_info, bucket_attrs, fault, dpp, y);
   if (ret < 0) {
     return ret;
   }
@@ -1204,7 +1204,7 @@ int RGWReshard::process_entry(const cls_rgw_reshard_entry& entry,
                                                entry.tenant,
                                               entry.bucket_name,
                                                bucket_info, nullptr,
-                                               null_yield, dpp,
+                                               y, dpp,
                                               &bucket_attrs);
   if (ret < 0 || bucket_info.bucket.bucket_id != entry.bucket_id) {
     if (ret < 0) {
index ec4752e7f2a7ea925aa2a5ec0341a8cbcfeb902d..768e6c8b359335184af0225a50471c681cf1e46f 100644 (file)
@@ -103,12 +103,12 @@ public:
               ceph::Formatter *formatter = nullptr,
              RGWReshard *reshard_log = nullptr);
   int get_status(const DoutPrefixProvider *dpp, std::list<cls_rgw_bucket_instance_entry> *status);
-  int cancel(const DoutPrefixProvider* dpp);
+  int cancel(const DoutPrefixProvider* dpp, optional_yield y);
 
   static int clear_resharding(rgw::sal::RadosStore* store,
                              RGWBucketInfo& bucket_info,
                              std::map<std::string, bufferlist>& bucket_attrs,
-                              const DoutPrefixProvider* dpp);
+                              const DoutPrefixProvider* dpp, optional_yield y);
 
   static uint32_t get_max_prime_shards() {
     return *std::crbegin(reshard_primes);
index c54803af0e6ee5444661d19970a093363efc8b49..14ff7e327c3de998eef3adaf5288b73049796ba7 100644 (file)
@@ -8179,7 +8179,7 @@ next:
        RGWBucketReshard br(static_cast<rgw::sal::RadosStore*>(driver),
                            bucket->get_info(), bucket->get_attrs(),
                            nullptr /* no callback */);
-      int ret = br.cancel(dpp());
+      int ret = br.cancel(dpp(), null_yield);
       if (ret < 0) {
         if (ret == -EBUSY) {
           cerr << "There is ongoing resharding, please retry after " <<