]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use get_omap_keys2
authorSage Weil <sage@redhat.com>
Fri, 20 Jan 2017 16:52:27 +0000 (11:52 -0500)
committerNathan Cutler <ncutler@suse.com>
Sat, 3 Nov 2018 14:30:54 +0000 (15:30 +0100)
Making looping less fragile.

Signed-off-by: Sage Weil <sage@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit e320830a7123f915ea30370cb7fc4248e42796d7)

Conflicts:
src/rgw/rgw_data_sync.cc
- trivial resolution

src/rgw/rgw_cr_rados.cc
src/rgw/rgw_cr_rados.h
src/rgw/rgw_data_sync.cc
src/rgw/rgw_sync.cc

index 258552c5796cebfc0813bb89f646f090f1f4f1ab..706e84c4ab0dcb9401b529526c3be3f5097d1202 100644 (file)
@@ -256,10 +256,12 @@ int RGWRadosSetOmapKeysCR::request_complete()
 RGWRadosGetOmapKeysCR::RGWRadosGetOmapKeysCR(RGWRados *_store,
                       const rgw_raw_obj& _obj,
                       const string& _marker,
-                      std::set<std::string> *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()),
+                      std::set<std::string> *_entries,
+                      int _max_entries, bool *_pmore) : RGWSimpleCoroutine(_store->ctx()),
                                                 store(_store),
                                                 marker(_marker),
                                                 entries(_entries), max_entries(_max_entries),
+                                                pmore(_pmore),
                                                 obj(_obj), cn(NULL)
 {
   set_description() << "get omap keys dest=" << obj << " marker=" << marker;
@@ -275,7 +277,7 @@ int RGWRadosGetOmapKeysCR::send_request() {
   set_status() << "send request";
 
   librados::ObjectReadOperation op;
-  op.omap_get_keys2(marker, max_entries, entries, nullptr, nullptr);
+  op.omap_get_keys2(marker, max_entries, entries, pmore, nullptr);
 
   cn = stack->create_completion_notifier();
   return ref.ioctx.aio_operate(ref.oid, cn->completion(), &op, NULL);
index eb1b6288b3333d1b8f7eddd08783c255e76ef55a..37b5bdd911ec6f9545eadb738aaa01f750845c7b 100644 (file)
@@ -399,6 +399,7 @@ class RGWRadosGetOmapKeysCR : public RGWSimpleCoroutine {
   string marker;
   std::set<std::string> *entries;
   int max_entries;
+  bool *pmore;
 
   rgw_rados_ref ref;
 
@@ -410,7 +411,8 @@ public:
   RGWRadosGetOmapKeysCR(RGWRados *_store,
                      const rgw_raw_obj& _obj,
                      const string& _marker,
-                     std::set<std::string> *_entries, int _max_entries);
+                     std::set<std::string> *_entries,
+                        int _max_entries, bool *pmore);
 
   int send_request() override;
   int request_complete() override;
index 65a5b2a7242043522e3201db8867a99e67280c9b..819fc0dd08ee8bef3597803f020e511add3ebb6d 100644 (file)
@@ -184,7 +184,7 @@ bool RGWReadDataSyncRecoveringShardsCR::spawn_next()
  
   string error_oid = RGWDataSyncStatusManager::shard_obj_name(env->source_zone, shard_id) + ".retry";
   spawn(new RGWRadosGetOmapKeysCR(env->store, rgw_raw_obj(env->store->get_zone_params().log_pool, error_oid),
-                                  marker, &entries_map[shard_id], max_entries), false);
+                                  marker, &entries_map[shard_id], max_entries, nullptr), false);
 
   ++shard_id;
   return true;
@@ -1156,6 +1156,7 @@ class RGWDataSyncShardCR : public RGWCoroutine {
 
   std::set<std::string> entries;
   std::set<std::string>::iterator iter;
+  bool more = false;
 
   string oid;
 
@@ -1316,7 +1317,9 @@ public:
           drain_all();
           return set_cr_error(-ECANCELED);
         }
-        yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid), sync_marker.marker, &entries, max_entries));
+        yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid),
+                                             sync_marker.marker, &entries,
+                                             max_entries, &more));
         if (retcode < 0) {
           tn->log(0, SSTR("ERROR: RGWRadosGetOmapKeysCR() returned ret=" << retcode));
           lease_cr->go_down();
@@ -1350,7 +1353,7 @@ public:
             }
           }
         }
-      } while ((int)entries.size() == max_entries);
+      } while (more);
 
       drain_all_but_stack(lease_stack.get());
 
@@ -1429,7 +1432,7 @@ public:
           /* process bucket shards that previously failed */
           yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, error_oid),
                                                error_marker, &error_entries,
-                                               max_error_entries));
+                                               max_error_entries, &more));
           tn->log(20, SSTR("read error repo, got " << error_entries.size() << " entries"));
           iter = error_entries.begin();
           for (; iter != error_entries.end(); ++iter) {
@@ -1437,7 +1440,7 @@ public:
             tn->log(20, SSTR("handle error entry: " << error_marker));
             spawn(new RGWDataSyncSingleEntryCR(sync_env, error_marker, error_marker, nullptr /* no marker tracker */, error_repo, true, tn), false);
           }
-          if ((int)error_entries.size() != max_error_entries) {
+          if (!more) {
             if (error_marker.empty() && error_entries.empty()) {
               /* the retry repo is empty, we back off a bit before calling it again */
               retry_backoff_secs *= 2;
@@ -2122,6 +2125,7 @@ class RGWReadRecoveringBucketShardsCoroutine : public RGWCoroutine {
 
   set<string> error_entries;
   int max_omap_entries;
+  bool more = false;
   int count;
 
 public:
@@ -2144,7 +2148,7 @@ int RGWReadRecoveringBucketShardsCoroutine::operate()
     count = 0;
     do {
       yield call(new RGWRadosGetOmapKeysCR(store, rgw_raw_obj(store->get_zone_params().log_pool, error_oid), 
-            marker, &error_entries, max_omap_entries));
+            marker, &error_entries, max_omap_entries, &more));
 
       if (retcode == -ENOENT) {
         break;
@@ -2164,7 +2168,7 @@ int RGWReadRecoveringBucketShardsCoroutine::operate()
       marker = *error_entries.rbegin();
       recovering_buckets.insert(std::make_move_iterator(error_entries.begin()),
                                 std::make_move_iterator(error_entries.end()));
-    }while((int)error_entries.size() == max_omap_entries && count < max_entries);
+    } while(more && count < max_entries);
   
     return set_cr_done();
   }
index 3cde6e5812708cb8efc4407ae0d67cbe23210395..11953426bc12a843fc3f56ec6498d039a74a7555 100644 (file)
@@ -1385,6 +1385,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine {
   const std::string& period_marker; //< max marker stored in next period
 
   std::set<std::string> entries;
+  bool more = false;
   std::set<std::string>::iterator iter;
 
   string oid;
@@ -1572,7 +1573,7 @@ public:
           break;
         }
         yield call(new RGWRadosGetOmapKeysCR(sync_env->store, rgw_raw_obj(pool, oid),
-                                             marker, &entries, max_entries));
+                                             marker, &entries, max_entries, &more));
         if (retcode < 0) {
           ldout(sync_env->cct, 0) << "ERROR: " << __func__ << "(): RGWRadosGetOmapKeysCR() returned ret=" << retcode << dendl;
           tn->log(0, SSTR("ERROR: failed to list omap keys, status=" << retcode));
@@ -1602,7 +1603,7 @@ public:
           }
         }
         collect_children();
-      } while ((int)entries.size() == max_entries && can_adjust_marker);
+      } while (more && can_adjust_marker);
 
       tn->unset_flag(RGW_SNS_FLAG_ACTIVE); /* actually have entries to sync */