From: Yehuda Sadeh Date: Thu, 23 Jan 2020 00:54:10 +0000 (-0800) Subject: rgw: bucket sync: no create param in find directional/symmetrical X-Git-Tag: v15.1.0~22^2~11 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=fbec3aeff6c4f909faf9c1028310c6a38eb3171d;p=ceph-ci.git rgw: bucket sync: no create param in find directional/symmetrical Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 11c66c10a4f..9a8c4eb0258 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -8226,7 +8226,7 @@ next: rgw_sync_symmetric_group *flow_group; - group.data_flow.find_symmetrical(*opt_flow_id, true, &flow_group); + group.data_flow.find_or_create_symmetrical(*opt_flow_id, &flow_group); for (auto& z : *opt_zone_ids) { flow_group->zones.insert(z); @@ -8237,7 +8237,7 @@ next: rgw_sync_directional_rule *flow_rule; - group.data_flow.find_directional(*opt_source_zone_id, *opt_dest_zone_id, true, &flow_rule); + group.data_flow.find_or_create_directional(*opt_source_zone_id, *opt_dest_zone_id, &flow_rule); } ret = sync_policy_ctx.write_policy(); diff --git a/src/rgw/rgw_bucket_sync.cc b/src/rgw/rgw_bucket_sync.cc index a1f9787c7ee..2c7efc22920 100644 --- a/src/rgw/rgw_bucket_sync.cc +++ b/src/rgw/rgw_bucket_sync.cc @@ -637,10 +637,9 @@ void RGWSyncPolicyCompat::convert_old_sync_config(RGWSI_Zone *zone_svc, if (z1.syncs_from(z2.name)) { found = true; rgw_sync_directional_rule *rule; - group.data_flow.find_directional(id2, - id1, - true, - &rule); + group.data_flow.find_or_create_directional(id2, + id1, + &rule); } } } diff --git a/src/rgw/rgw_sync_policy.cc b/src/rgw/rgw_sync_policy.cc index 2ed5fbbe913..a026d491cf3 100644 --- a/src/rgw/rgw_sync_policy.cc +++ b/src/rgw/rgw_sync_policy.cc @@ -351,14 +351,8 @@ void rgw_sync_bucket_pipes::get_potential_related_buckets(const rgw_bucket& buck } } -bool rgw_sync_data_flow_group::find_symmetrical(const string& flow_id, bool create, rgw_sync_symmetric_group **flow_group) +bool rgw_sync_data_flow_group::find_or_create_symmetrical(const string& flow_id, rgw_sync_symmetric_group **flow_group) { - if (symmetrical.empty()) { - if (!create) { - return false; - } - } - for (auto& group : symmetrical) { if (flow_id == group.id) { *flow_group = &group; @@ -366,10 +360,6 @@ bool rgw_sync_data_flow_group::find_symmetrical(const string& flow_id, bool crea } } - if (!create) { - return false; - } - auto& group = symmetrical.emplace_back(); *flow_group = &group; (*flow_group)->id = flow_id; @@ -417,14 +407,8 @@ void rgw_sync_data_flow_group::remove_symmetrical(const string& flow_id, std::op } } -bool rgw_sync_data_flow_group::find_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, bool create, rgw_sync_directional_rule **flow_group) +bool rgw_sync_data_flow_group::find_or_create_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, rgw_sync_directional_rule **flow_group) { - if (directional.empty()) { - if (!create) { - return false; - } - } - for (auto& rule : directional) { if (source_zone == rule.source_zone && dest_zone == rule.dest_zone) { @@ -433,10 +417,6 @@ bool rgw_sync_data_flow_group::find_directional(const rgw_zone_id& source_zone, } } - if (!create) { - return false; - } - auto& rule = directional.emplace_back(); *flow_group = &rule; diff --git a/src/rgw/rgw_sync_policy.h b/src/rgw/rgw_sync_policy.h index 3aa28da400c..f177e6b9e30 100644 --- a/src/rgw/rgw_sync_policy.h +++ b/src/rgw/rgw_sync_policy.h @@ -577,9 +577,9 @@ struct rgw_sync_data_flow_group { return (symmetrical.empty() && directional.empty()); } - bool find_symmetrical(const string& flow_id, bool create, rgw_sync_symmetric_group **flow_group); + bool find_or_create_symmetrical(const string& flow_id, rgw_sync_symmetric_group **flow_group); void remove_symmetrical(const string& flow_id, std::optional > zones); - bool find_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, bool create, rgw_sync_directional_rule **flow_group); + bool find_or_create_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone, rgw_sync_directional_rule **flow_group); void remove_directional(const rgw_zone_id& source_zone, const rgw_zone_id& dest_zone); void init_default(const std::set& zones);