]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check for short_zone_id collisions on period update 8886/head
authorCasey Bodley <cbodley@redhat.com>
Fri, 29 Apr 2016 21:47:07 +0000 (17:47 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 2 May 2016 20:27:59 +0000 (16:27 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_rados.cc

index f1d7bfcdff7896d22da91940811624a4558c6463..38e9ddc98e4c154f7083fcfc8f8310a4ca36c07c 100644 (file)
@@ -1654,11 +1654,24 @@ int RGWPeriodMap::update(const RGWZoneGroup& zonegroup, CephContext *cct)
   }
 
   for (auto& i : zonegroup.zones) {
-    string& zone_id = i.second.id;
-    if (short_zone_ids.find(zone_id) == short_zone_ids.end()) {
-      uint32_t short_id = gen_short_zone_id(zone_id);
-      short_zone_ids[i.second.id] = short_id;
+    auto& zone = i.second;
+    if (short_zone_ids.find(zone.id) != short_zone_ids.end()) {
+      continue;
     }
+    // calculate the zone's short id
+    uint32_t short_id = gen_short_zone_id(zone.id);
+
+    // search for an existing zone with the same short id
+    for (auto& s : short_zone_ids) {
+      if (s.second == short_id) {
+        ldout(cct, 0) << "New zone '" << zone.name << "' (" << zone.id
+            << ") generates the same short_zone_id " << short_id
+            << " as existing zone id " << s.first << dendl;
+        return -EEXIST;
+      }
+    }
+
+    short_zone_ids[zone.id] = short_id;
   }
 
   return 0;