]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: bucket sync: get_hint_entities(), call read_bucket_info once
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 23 Jan 2020 01:16:53 +0000 (17:16 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:40 +0000 (10:20 -0800)
once per bucket

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/services/svc_bucket_sync_sobj.cc

index 005f09170a28d1fd8f61deb0b0adbd0e979bae5b..c9629a2a313259e19c07407084ae35b508a92d92 100644 (file)
@@ -73,18 +73,26 @@ void RGWSI_Bucket_Sync_SObj::get_hint_entities(RGWSI_Bucket_X_Ctx& ctx,
                                                std::set<rgw_sync_bucket_entity> *hint_entities,
                                                optional_yield y)
 {
-  for (auto& zone : zones) {
-    for (auto& b : buckets) {
-      RGWBucketInfo hint_bucket_info;
-      int ret = svc.bucket_sobj->read_bucket_info(ctx, b, &hint_bucket_info,
-                                                  nullptr, nullptr, boost::none,
-                                                  y);
-      if (ret < 0) {
-       ldout(cct, 20) << "could not init bucket info for hint bucket=" << b << " ... skipping" << dendl;
-       continue;
-      }
+  vector<rgw_bucket> hint_buckets;
+
+  hint_buckets.reserve(buckets.size());
 
-      hint_entities->insert(rgw_sync_bucket_entity(zone, hint_bucket_info.bucket));
+  for (auto& b : buckets) {
+    RGWBucketInfo hint_bucket_info;
+    int ret = svc.bucket_sobj->read_bucket_info(ctx, b, &hint_bucket_info,
+                                                nullptr, nullptr, boost::none,
+                                                y);
+    if (ret < 0) {
+      ldout(cct, 20) << "could not init bucket info for hint bucket=" << b << " ... skipping" << dendl;
+      continue;
+    }
+
+    hint_buckets.emplace_back(std::move(hint_bucket_info.bucket));
+  }
+
+  for (auto& zone : zones) {
+    for (auto& b : hint_buckets) {
+      hint_entities->insert(rgw_sync_bucket_entity(zone, b));
     }
   }
 }