summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-07-15 15:49:42 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-07-15 15:49:42 -0700
commiteef44582798c443bcc55c6a1f4f8cbb6e9ca2653 (patch)
tree64d2570882b713d21e53764c7d2fc0acc90a7f3a
parent1b5258155ab2de7b7bc565eafdacf69b79e1bc08 (diff)
downloadceph-eef44582798c443bcc55c6a1f4f8cbb6e9ca2653.tar.gz
rgw: fix bucket placement assignment
When we set bucket.instance meta, we need to set the correct bucket placement to the bucket (according to the specific placement rule). However, it might be that bucket placement was never configured and we just go by the defaults, using the old legacy pools selection. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_rados.cc54
-rw-r--r--src/rgw/rgw_rados.h1
2 files changed, 33 insertions, 22 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index b3e297effa4..c9d6c70980b 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -1908,11 +1908,29 @@ int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& r
}
}
- /* yay, user is permitted, now just make sure that zone has this rule configured. We're
+ if (pselected_rule)
+ *pselected_rule = rule;
+
+ return set_bucket_location_by_rule(rule, bucket_name, bucket);
+}
+
+int RGWRados::set_bucket_location_by_rule(const string& location_rule, const std::string& bucket_name, rgw_bucket& bucket)
+{
+ bucket.name = bucket_name;
+
+ if (location_rule.empty()) {
+ /* we can only reach here if we're trying to set a bucket location from a bucket
+ * created on a different zone, using a legacy / default pool configuration
+ */
+ return select_legacy_bucket_placement(bucket_name, bucket);
+ }
+
+ /*
+ * make sure that zone has this rule configured. We're
* checking it for the local zone, because that's where this bucket object is going to
* reside.
*/
- map<string, RGWZonePlacementInfo>::iterator piter = zone.placement_pools.find(rule);
+ 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) ||
@@ -1926,22 +1944,6 @@ int RGWRados::select_new_bucket_location(RGWUserInfo& user_info, const string& r
}
}
- if (pselected_rule)
- *pselected_rule = rule;
-
- return set_bucket_location_by_rule(rule, bucket_name, bucket);
-}
-
-int RGWRados::set_bucket_location_by_rule(const string& location_rule, const std::string& bucket_name, rgw_bucket& bucket)
-{
- bucket.name = bucket_name;
-
- map<string, RGWZonePlacementInfo>::iterator piter = zone.placement_pools.find(location_rule);
- if (piter == zone.placement_pools.end()) {
- /* silently ignore, bucket will not reside in this zone */
- return 0;
- }
-
RGWZonePlacementInfo& placement_info = piter->second;
bucket.data_pool = placement_info.data_pool;
@@ -1954,15 +1956,23 @@ int RGWRados::set_bucket_location_by_rule(const string& location_rule, const std
int RGWRados::select_bucket_placement(RGWUserInfo& user_info, const string& region_name, const string& placement_rule,
const string& bucket_name, rgw_bucket& bucket, string *pselected_rule)
{
+ if (!zone.placement_pools.empty()) {
+ return select_new_bucket_location(user_info, region_name, placement_rule, bucket_name, bucket, pselected_rule);
+ }
+
+ if (pselected_rule)
+ pselected_rule->clear();
+
+ return select_legacy_bucket_placement(bucket_name, bucket);
+}
+
+int RGWRados::select_legacy_bucket_placement(const string& bucket_name, rgw_bucket& bucket)
+{
bufferlist map_bl;
map<string, bufferlist> m;
string pool_name;
bool write_map = false;
- if (!zone.placement_pools.empty()) {
- return select_new_bucket_location(user_info, region_name, placement_rule, bucket_name, bucket, pselected_rule);
- }
-
rgw_obj obj(zone.domain_root, avail_pools);
int ret = rgw_get_system_obj(this, NULL, zone.domain_root, avail_pools, map_bl, NULL, NULL);
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 3e747d2b8fb..fb1a1756ba8 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -973,6 +973,7 @@ public:
virtual int init_bucket_index(rgw_bucket& bucket);
int select_bucket_placement(RGWUserInfo& user_info, const string& region_name, const std::string& rule,
const std::string& bucket_name, rgw_bucket& bucket, string *pselected_rule);
+ int select_legacy_bucket_placement(const string& bucket_name, rgw_bucket& bucket);
int select_new_bucket_location(RGWUserInfo& user_info, const string& region_name, const string& rule,
const std::string& bucket_name, rgw_bucket& bucket, string *pselected_rule);
int set_bucket_location_by_rule(const string& location_rule, const std::string& bucket_name, rgw_bucket& bucket);