From: Sage Weil Date: Fri, 20 Jan 2017 16:52:27 +0000 (-0500) Subject: rgw: use get_omap_keys2 X-Git-Tag: v13.2.3~47^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=994c4434784a665d8738efe9a0514fe2a3c409c6;p=ceph.git rgw: use get_omap_keys2 Making looping less fragile. Signed-off-by: Sage Weil Signed-off-by: Casey Bodley (cherry picked from commit e320830a7123f915ea30370cb7fc4248e42796d7) Conflicts: src/rgw/rgw_data_sync.cc - trivial resolution --- diff --git a/src/rgw/rgw_cr_rados.cc b/src/rgw/rgw_cr_rados.cc index 258552c5796ce..706e84c4ab0dc 100644 --- a/src/rgw/rgw_cr_rados.cc +++ b/src/rgw/rgw_cr_rados.cc @@ -256,10 +256,12 @@ int RGWRadosSetOmapKeysCR::request_complete() RGWRadosGetOmapKeysCR::RGWRadosGetOmapKeysCR(RGWRados *_store, const rgw_raw_obj& _obj, const string& _marker, - std::set *_entries, int _max_entries) : RGWSimpleCoroutine(_store->ctx()), + std::set *_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); diff --git a/src/rgw/rgw_cr_rados.h b/src/rgw/rgw_cr_rados.h index eb1b6288b3333..37b5bdd911ec6 100644 --- a/src/rgw/rgw_cr_rados.h +++ b/src/rgw/rgw_cr_rados.h @@ -399,6 +399,7 @@ class RGWRadosGetOmapKeysCR : public RGWSimpleCoroutine { string marker; std::set *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 *_entries, int _max_entries); + std::set *_entries, + int _max_entries, bool *pmore); int send_request() override; int request_complete() override; diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index 65a5b2a724204..819fc0dd08ee8 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -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 entries; std::set::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 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(); } diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 3cde6e5812708..11953426bc12a 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -1385,6 +1385,7 @@ class RGWMetaSyncShardCR : public RGWCoroutine { const std::string& period_marker; //< max marker stored in next period std::set entries; + bool more = false; std::set::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 */