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 <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2013-06-24 17:27:34 -07:00
parent 1e3161a84e
commit 7e41c1036d
3 changed files with 13 additions and 3 deletions

View File

@ -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);
}

View File

@ -182,7 +182,6 @@ static int get_bucket_policy_from_attr(CephContext *cct, RGWRados *store, void *
RGWObjVersionTracker *objv_tracker)
{
int ret;
map<string, bufferlist>::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) {

View File

@ -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;