From ed95206e22bb2e6d45fb939459bfebb5147e6dca Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Wed, 22 Jan 2020 17:16:53 -0800 Subject: [PATCH] rgw: bucket sync: get_hint_entities(), call read_bucket_info once once per bucket Signed-off-by: Yehuda Sadeh --- src/rgw/services/svc_bucket_sync_sobj.cc | 30 +++++++++++++++--------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/rgw/services/svc_bucket_sync_sobj.cc b/src/rgw/services/svc_bucket_sync_sobj.cc index 005f09170a2..c9629a2a313 100644 --- a/src/rgw/services/svc_bucket_sync_sobj.cc +++ b/src/rgw/services/svc_bucket_sync_sobj.cc @@ -73,18 +73,26 @@ void RGWSI_Bucket_Sync_SObj::get_hint_entities(RGWSI_Bucket_X_Ctx& ctx, std::set *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 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)); } } } -- 2.39.5