diff options
-rw-r--r-- | src/rgw/rgw_common.h | 4 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 18 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 543bdf21377..8e4126de271 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -542,6 +542,10 @@ struct rgw_bucket { std::string marker; std::string bucket_id; + std::string oid; /* + * runtime in-memory only info. If not empty, points to the bucket instance object + */ + rgw_bucket() { } rgw_bucket(const char *n) : name(n) { assert(*n == '.'); // only rgw private buckets should be initialized without pool diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 22c93f33ad5..9e8f5637415 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4548,9 +4548,13 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid) void RGWRados::get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj) { - string oid; - get_bucket_meta_oid(bucket, oid); - obj.init(zone.domain_root, oid); + if (!bucket.oid.empty()) { + obj.init(zone.domain_root, bucket.oid); + } else { + string oid; + get_bucket_meta_oid(bucket, oid); + obj.init(zone.domain_root, oid); + } } int RGWRados::get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info, @@ -4569,7 +4573,11 @@ int RGWRados::get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketI time_t *pmtime, map<string, bufferlist> *pattrs) { string oid; - get_bucket_meta_oid(bucket, oid); + if (!bucket.oid.empty()) { + get_bucket_meta_oid(bucket, oid); + } else { + oid = bucket.oid; + } return get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs); } @@ -4593,6 +4601,7 @@ int RGWRados::get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo ldout(cct, 0) << "ERROR: could not decode buffer info, caught buffer::error" << dendl; return -EIO; } + info.bucket.oid = oid; return 0; } @@ -4635,6 +4644,7 @@ int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& inf if (entry_point.has_bucket_info) { info = entry_point.old_bucket_info; + info.bucket.oid = bucket_name; info.ep_objv = ot.read_version; ldout(cct, 20) << "rgw_get_bucket_info: old bucket info, bucket=" << info.bucket << " owner " << info.owner << dendl; return 0; |