summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Farnum <greg@inktank.com>2013-07-16 09:33:52 -0700
committerGregory Farnum <greg@inktank.com>2013-07-16 09:33:52 -0700
commit38691e7f957a819325c50da0503c086cd96172d1 (patch)
treec1d845a5b21bbcc4a874d38cd5ff8c1a1ec37f47
parent39e5a2a406b77fa82e9a78c267b679d49927e3c3 (diff)
parent408014ee462a9fcf92971f90a3745f815a813d84 (diff)
downloadceph-38691e7f957a819325c50da0503c086cd96172d1.tar.gz
Merge pull request #438 from yehudasa/wip-rgw-next
Fix an issue with bucket placements and with listing on new installations. Reviewed-by: Greg Farnum <greg@inktank.com>
-rw-r--r--src/rgw/rgw_bucket.cc14
-rw-r--r--src/rgw/rgw_rados.cc54
-rw-r--r--src/rgw/rgw_rados.h1
3 files changed, 45 insertions, 24 deletions
diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc
index 23354233c96..aae7d31e21c 100644
--- a/src/rgw/rgw_bucket.cc
+++ b/src/rgw/rgw_bucket.cc
@@ -1476,8 +1476,13 @@ public:
int ret = store->list_raw_objects(store->zone.domain_root, no_filter,
max, info->ctx, unfiltered_keys, truncated);
- if (ret < 0)
+ if (ret < 0 && ret != -ENOENT)
return ret;
+ if (ret == -ENOENT) {
+ if (truncated)
+ *truncated = false;
+ return 0;
+ }
// now filter out the system entries
list<string>::iterator iter;
@@ -1618,8 +1623,13 @@ public:
int ret = store->list_raw_objects(store->zone.domain_root, no_filter,
max, info->ctx, unfiltered_keys, truncated);
- if (ret < 0)
+ if (ret < 0 && ret != -ENOENT)
return ret;
+ if (ret == -ENOENT) {
+ if (truncated)
+ *truncated = false;
+ return 0;
+ }
int prefix_size = sizeof(RGW_BUCKET_INSTANCE_MD_PREFIX) - 1;
// now filter in the relevant entries
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);