]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: bucket sync: no create param in find directional/symmetrical
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 23 Jan 2020 00:54:10 +0000 (16:54 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 28 Jan 2020 18:20:40 +0000 (10:20 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket_sync.cc
src/rgw/rgw_sync_policy.cc
src/rgw/rgw_sync_policy.h

index 11c66c10a4f99850eb912a71fb10e0b45adb0b8f..9a8c4eb0258b21e9b8f9d808b5852bf3c00d35da 100644 (file)
@@ -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();
index a1f9787c7eed38b7ae5863cf7f0e7dd74539fc84..2c7efc22920e255484fee261ca3d6292badc35cd 100644 (file)
@@ -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);
       }
     }
   }
index 2ed5fbbe91326f829fbf2223ced88ed918fe85cc..a026d491cf30025e2cc19ea500ae795a941afebb 100644 (file)
@@ -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;
 
index 3aa28da400ccbd3bf0f9e327fb1e654de043da21..f177e6b9e30a5bca6e5d8392303b45aecc6a30ce 100644 (file)
@@ -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<std::vector<rgw_zone_id> > 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<rgw_zone_id>& zones);