diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-07-19 09:44:43 -0700 |
---|---|---|
committer | Greg Farnum <greg@inktank.com> | 2013-07-19 13:21:50 -0700 |
commit | 4e05786a58a1218e1b68d5fbcddefa7a72ac03ce (patch) | |
tree | a19934190b4126fe7a4e6152b494053fa071ff55 | |
parent | e4d2787b023a10d782438e1dc9bb32be8d8ccd76 (diff) | |
download | ceph-4e05786a58a1218e1b68d5fbcddefa7a72ac03ce.tar.gz |
rgw: replace logic that compares regions
The logic was a bit broken. Basically, we want to make sure
that region names are the same. However, if region name is not
set then we need to check whether it's the master region. This
can happen in upgrade cases where originally we didn't have
a region name set.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_op.cc | 6 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 20 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 1 |
3 files changed, 14 insertions, 13 deletions
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 644f8a8921d..6a9d2319de7 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -334,8 +334,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu ret = store->get_bucket_info(s->obj_ctx, copy_source_str, source_info, NULL); if (ret == 0) { string& region = source_info.region; - s->local_source = (region.empty() && store->region.is_master) || - (region == store->region.name); + s->local_source = store->region.equals(region); } } @@ -362,8 +361,7 @@ static int rgw_build_policies(RGWRados *store, struct req_state *s, bool only_bu s->bucket_owner = s->bucket_acl->get_owner(); string& region = s->bucket_info.region; - if (s->bucket_exists && ((region.empty() && !store->region.is_master) || - (region != store->region.name))) { + if (s->bucket_exists && !store->region.equals(region)) { ldout(s->cct, 0) << "NOTICE: request for data in a different region (" << region << " != " << store->region.name << ")" << dendl; /* we now need to make sure that the operation actually requires copy source, that is * it's a copy operation diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index a8061e99bf1..e3312d9d373 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -259,6 +259,13 @@ int RGWRegion::store_info(bool exclusive) return ret; } +int RGWRegion::equals(const string& other_region) +{ + if (is_master && other_region.empty()) + return true; + + return (name == other_region); +} void RGWZoneParams::init_default(RGWRados *store) { @@ -429,8 +436,7 @@ int RGWRegionMap::update(RGWRegion& region) { Mutex::Locker l(lock); - if (region.is_master && !master_region.empty() && - master_region.compare(region.name) != 0) { + if (region.is_master && !region.equals(master_region)) { derr << "cannot update region map, master_region conflict" << dendl; return -EINVAL; } @@ -1938,8 +1944,7 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const std map<string, RGWZonePlacementInfo>::iterator piter = zone.placement_pools.find(location_rule); if (piter == zone.placement_pools.end()) { /* couldn't find, means we cannot really place data for this bucket in this zone */ - if ((region_name.empty() && region.is_master) || - region_name == region.name) { + if (region.equals(region_name)) { /* that's a configuration error, zone should have that rule, as we're within the requested * region */ return -EINVAL; @@ -2486,11 +2491,8 @@ int RGWRados::copy_obj(void *ctx, append_rand_alpha(cct, dest_obj.object, shadow_oid, 32); shadow_obj.init_ns(dest_obj.bucket, shadow_oid, shadow_ns); - remote_dest = ((dest_bucket_info.region.empty() && !region.is_master) || - (dest_bucket_info.region != region.name)); - - remote_src = ((src_bucket_info.region.empty() && !region.is_master) || - (src_bucket_info.region != region.name)); + remote_dest = !region.equals(dest_bucket_info.region); + remote_src = !region.equals(src_bucket_info.region); if (remote_src && remote_dest) { ldout(cct, 0) << "ERROR: can't copy object when both src and dest buckets are remote" << dendl; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 99e66a91b1c..e083879b582 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -619,6 +619,7 @@ struct RGWRegion { int read_info(const string& region_name); int read_default(RGWDefaultRegionInfo& default_region); int set_as_default(); + int equals(const string& other_region); static string get_pool_name(CephContext *cct); |