From 29771695a0776f716d15361f5fef9f43df4645a4 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 20 Dec 2016 13:32:57 -0800 Subject: [PATCH] rgw: metadata put of bucket instance sets bucket_id Need to parse the bucket id off the entry and then set it on the bucket struct. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_bucket.cc | 10 ++++++---- src/rgw/rgw_metadata.h | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index da55fbfd6a87b..8b2bc5f46df16 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -1922,7 +1922,7 @@ public: RGWObjectCtx obj_ctx(store); string tenant_name, bucket_name; - parse_bucket(entry, tenant_name, bucket_name); + parse_bucket(entry, &tenant_name, &bucket_name); int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &ot, &mtime, &attrs); if (ret < 0) return ret; @@ -1950,7 +1950,7 @@ public: RGWObjectCtx obj_ctx(store); string tenant_name, bucket_name; - parse_bucket(entry, tenant_name, bucket_name); + parse_bucket(entry, &tenant_name, &bucket_name); int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, old_be, &old_ot, &orig_mtime, &attrs); if (ret < 0 && ret != -ENOENT) return ret; @@ -1988,7 +1988,7 @@ public: RGWObjectCtx obj_ctx(store); string tenant_name, bucket_name; - parse_bucket(entry, tenant_name, bucket_name); + parse_bucket(entry, &tenant_name, &bucket_name); int ret = store->get_bucket_entrypoint_info(obj_ctx, tenant_name, bucket_name, be, &objv_tracker, NULL, NULL); if (ret < 0) return ret; @@ -2113,10 +2113,12 @@ public: rgw_bucket_instance_oid_to_key(key); string tenant_name; string bucket_name; - parse_bucket(key, tenant_name, bucket_name); + string bucket_instance; + parse_bucket(key, &tenant_name, &bucket_name, &bucket_instance); RGWZonePlacementInfo rule_info; bci.info.bucket.name = bucket_name; + bci.info.bucket.bucket_id = bucket_instance; bci.info.bucket.tenant = tenant_name; ret = store->select_bucket_location_by_rule(bci.info.placement_rule, bci.info.bucket, &rule_info); if (ret < 0) { diff --git a/src/rgw/rgw_metadata.h b/src/rgw/rgw_metadata.h index d150e6cd36e53..cd1150e6e6623 100644 --- a/src/rgw/rgw_metadata.h +++ b/src/rgw/rgw_metadata.h @@ -117,16 +117,27 @@ protected: /* * The tenant_name is always returned on purpose. May be empty, of course. */ - static void parse_bucket(const string &bucket, - string &tenant_name, string &bucket_name) + static void parse_bucket(const string& bucket, + string *tenant_name, + string *bucket_name, + string *bucket_instance = nullptr /* optional */) { int pos = bucket.find('/'); if (pos >= 0) { - tenant_name = bucket.substr(0, pos); + *tenant_name = bucket.substr(0, pos); } else { - tenant_name.clear(); + tenant_name->clear(); + } + string bn = bucket.substr(pos + 1); + pos = bn.find (':'); + if (pos < 0) { + *bucket_name = std::move(bn); + return; + } + *bucket_name = bn.substr(0, pos); + if (bucket_instance) { + *bucket_instance = bn.substr(pos + 1); } - bucket_name = bucket.substr(pos + 1); } }; -- 2.39.5