From: Casey Bodley Date: Fri, 29 Apr 2016 21:47:07 +0000 (-0400) Subject: rgw: check for short_zone_id collisions on period update X-Git-Tag: v11.0.0~489^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=31e3104b47e97327bba812418ccd9130ce3adee7;p=ceph.git rgw: check for short_zone_id collisions on period update Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f1d7bfcdff78..38e9ddc98e4c 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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;