From 7e41c1036de061e0d73cee8a6707d22bc16fb09f Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Mon, 24 Jun 2013 17:27:34 -0700 Subject: [PATCH] rgw: bucket entry point contains owner, other fix We now keep the owner at the bucket entry point. Also, reading bucket info at RGWCreateBucket::execute(), because previous changes has made it so that we didn't have the required bucket info initialized there. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_common.h | 3 +++ src/rgw/rgw_op.cc | 7 ++++++- src/rgw/rgw_rados.cc | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 847b3f07ec0..179c4fe70c6 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -683,6 +683,7 @@ WRITE_CLASS_ENCODER(RGWBucketInfo) struct RGWBucketEntryPoint { rgw_bucket bucket; + string owner; bool has_bucket_info; RGWBucketInfo old_bucket_info; @@ -692,6 +693,7 @@ struct RGWBucketEntryPoint void encode(bufferlist& bl) const { ENCODE_START(8, 8, bl); ::encode(bucket, bl); + ::encode(owner, bl); ENCODE_FINISH(bl); } void decode(bufferlist::iterator& bl) { @@ -705,6 +707,7 @@ struct RGWBucketEntryPoint } has_bucket_info = false; ::decode(bucket, bl); + ::decode(owner, bl); DECODE_FINISH(bl); } diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 01a2cfeee22..d4eaeccdbeb 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -182,7 +182,6 @@ static int get_bucket_policy_from_attr(CephContext *cct, RGWRados *store, void * RGWObjVersionTracker *objv_tracker) { int ret; - map::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL); if (aiter != bucket_attrs.end()) { @@ -951,6 +950,12 @@ void RGWCreateBucket::execute() return; } + /* we need to make sure we read bucket info, it's not read before for this specific request */ + ret = store->get_bucket_info(s->obj_ctx, s->bucket_name_str, s->bucket_info, NULL, &s->bucket_attrs); + if (ret < 0 && ret != -ENOENT) + return; + s->bucket_exists = (ret != -ENOENT); + s->bucket_owner.set_id(s->user.user_id); s->bucket_owner.set_name(s->user.display_name); if (s->bucket_exists) { diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index c8cb53d1433..e5cb6c8ecd4 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1812,9 +1812,9 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, if (r < 0) return r; + /* we need to reread the info and return it, caller will have a use for it */ index_ctx.remove(dir_oid); - RGWBucketInfo actual_info; - r = get_bucket_info(NULL, bucket.name, actual_info, NULL); + r = get_bucket_info(NULL, bucket.name, info, NULL, NULL); if (r < 0) { if (r == -ENOENT) { continue; @@ -1822,6 +1822,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket, ldout(cct, 0) << "get_bucket_info returned " << r << dendl; return r; } + /* ret == -ENOENT here */ } return ret; } @@ -4596,6 +4597,7 @@ int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exc RGWBucketEntryPoint entry_point; entry_point.bucket = info.bucket; + entry_point.owner = info.owner; ret = put_bucket_entrypoint_info(info.bucket.name, entry_point, exclusive, mtime); if (exclusive && ret == -EEXIST) { string oid;