mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
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:
parent
1e3161a84e
commit
7e41c1036d
@ -683,6 +683,7 @@ WRITE_CLASS_ENCODER(RGWBucketInfo)
|
|||||||
struct RGWBucketEntryPoint
|
struct RGWBucketEntryPoint
|
||||||
{
|
{
|
||||||
rgw_bucket bucket;
|
rgw_bucket bucket;
|
||||||
|
string owner;
|
||||||
|
|
||||||
bool has_bucket_info;
|
bool has_bucket_info;
|
||||||
RGWBucketInfo old_bucket_info;
|
RGWBucketInfo old_bucket_info;
|
||||||
@ -692,6 +693,7 @@ struct RGWBucketEntryPoint
|
|||||||
void encode(bufferlist& bl) const {
|
void encode(bufferlist& bl) const {
|
||||||
ENCODE_START(8, 8, bl);
|
ENCODE_START(8, 8, bl);
|
||||||
::encode(bucket, bl);
|
::encode(bucket, bl);
|
||||||
|
::encode(owner, bl);
|
||||||
ENCODE_FINISH(bl);
|
ENCODE_FINISH(bl);
|
||||||
}
|
}
|
||||||
void decode(bufferlist::iterator& bl) {
|
void decode(bufferlist::iterator& bl) {
|
||||||
@ -705,6 +707,7 @@ struct RGWBucketEntryPoint
|
|||||||
}
|
}
|
||||||
has_bucket_info = false;
|
has_bucket_info = false;
|
||||||
::decode(bucket, bl);
|
::decode(bucket, bl);
|
||||||
|
::decode(owner, bl);
|
||||||
DECODE_FINISH(bl);
|
DECODE_FINISH(bl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +182,6 @@ static int get_bucket_policy_from_attr(CephContext *cct, RGWRados *store, void *
|
|||||||
RGWObjVersionTracker *objv_tracker)
|
RGWObjVersionTracker *objv_tracker)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL);
|
map<string, bufferlist>::iterator aiter = bucket_attrs.find(RGW_ATTR_ACL);
|
||||||
|
|
||||||
if (aiter != bucket_attrs.end()) {
|
if (aiter != bucket_attrs.end()) {
|
||||||
@ -951,6 +950,12 @@ void RGWCreateBucket::execute()
|
|||||||
return;
|
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_id(s->user.user_id);
|
||||||
s->bucket_owner.set_name(s->user.display_name);
|
s->bucket_owner.set_name(s->user.display_name);
|
||||||
if (s->bucket_exists) {
|
if (s->bucket_exists) {
|
||||||
|
@ -1812,9 +1812,9 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
/* we need to reread the info and return it, caller will have a use for it */
|
||||||
index_ctx.remove(dir_oid);
|
index_ctx.remove(dir_oid);
|
||||||
RGWBucketInfo actual_info;
|
r = get_bucket_info(NULL, bucket.name, info, NULL, NULL);
|
||||||
r = get_bucket_info(NULL, bucket.name, actual_info, NULL);
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
if (r == -ENOENT) {
|
if (r == -ENOENT) {
|
||||||
continue;
|
continue;
|
||||||
@ -1822,6 +1822,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
|
|||||||
ldout(cct, 0) << "get_bucket_info returned " << r << dendl;
|
ldout(cct, 0) << "get_bucket_info returned " << r << dendl;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
/* ret == -ENOENT here */
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -4596,6 +4597,7 @@ int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exc
|
|||||||
|
|
||||||
RGWBucketEntryPoint entry_point;
|
RGWBucketEntryPoint entry_point;
|
||||||
entry_point.bucket = info.bucket;
|
entry_point.bucket = info.bucket;
|
||||||
|
entry_point.owner = info.owner;
|
||||||
ret = put_bucket_entrypoint_info(info.bucket.name, entry_point, exclusive, mtime);
|
ret = put_bucket_entrypoint_info(info.bucket.name, entry_point, exclusive, mtime);
|
||||||
if (exclusive && ret == -EEXIST) {
|
if (exclusive && ret == -EEXIST) {
|
||||||
string oid;
|
string oid;
|
||||||
|
Loading…
Reference in New Issue
Block a user