From: Yehuda Sadeh Date: Sat, 27 Jul 2013 01:15:32 +0000 (-0700) Subject: rgw: keep a region connection map X-Git-Tag: v0.67-rc3~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eb6e6da1a90d3d94d623650556d78e56d04ab3a1;p=ceph.git rgw: keep a region connection map Fixes: #5793 Beforehand all remote copies were going to the master region which was awfully wrong. Signed-off-by: Yehuda Sadeh Reviewed-by: Greg Farnum --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 9e8f5637415..7131df9eaeb 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -831,6 +831,11 @@ void RGWRados::finalize() RGWRESTConn *conn = iter->second; delete conn; } + + for (iter = region_conn_map.begin(); iter != region_conn_map.end(); ++iter) { + RGWRESTConn *conn = iter->second; + delete conn; + } } /** @@ -896,6 +901,12 @@ int RGWRados::init_complete() } RGWRegion& region = iter->second; rest_master_conn = new RGWRESTConn(cct, this, region.endpoints); + + for (iter = region_map.regions.begin(); iter != region_map.regions.end(); ++iter) { + RGWRegion& region = iter->second; + + region_conn_map[region.name] = new RGWRESTConn(cct, this, region.endpoints); + } } map::iterator ziter; @@ -2535,7 +2546,17 @@ int RGWRados::copy_obj(void *ctx, RGWRESTConn *conn; if (source_zone.empty()) { - conn = rest_master_conn; + if (dest_bucket_info.region.empty()) { + /* source is in the master region */ + conn = rest_master_conn; + } else { + map::iterator iter = region_conn_map.find(src_bucket_info.region); + if (iter == zone_conn_map.end()) { + ldout(cct, 0) << "could not find region connection to region: " << source_zone << dendl; + return -ENOENT; + } + conn = iter->second; + } } else { map::iterator iter = zone_conn_map.find(source_zone); if (iter == zone_conn_map.end()) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 099a7112514..d01f76ec224 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -888,6 +888,7 @@ public: RGWRegionMap region_map; RGWRESTConn *rest_master_conn; map zone_conn_map; + map region_conn_map; RGWMetadataManager *meta_mgr;