From: Yehuda Sadeh Date: Fri, 26 Jul 2013 23:40:34 +0000 (-0700) Subject: rgw: track bucket instance oid X-Git-Tag: v0.67-rc3~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=68730d80c8aa393a583c92052ef5ffd11efe17a6;p=ceph.git rgw: track bucket instance oid We now keep the bucket instance oid in rgw_bucket. The reason we need it is that the bucket might have been created before the entrypoint / bucket instance separation. Fixes: #5790 Signed-off-by: Yehuda Sadeh Reviewed-by: Greg Farnum --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 543bdf213774..8e4126de2718 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 22c93f33ad58..9e8f56374151 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 *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;