rgw: put_bucket_info does not override attrs

This fixes #2487. When writing bucket info we just
wrote the object content, and were overriding any
attrs that object contained (that is -- corrupted
the ACLs).

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
Yehuda Sadeh 2012-05-30 15:40:39 -07:00
parent d8df1e9913
commit 767664dcb8
4 changed files with 12 additions and 11 deletions

View File

@ -1077,7 +1077,8 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
ldout(cct, 20) << "disabling bucket name=" << bucket.name << dendl;
RGWBucketInfo info;
int r = get_bucket_info(NULL, bucket.name, info);
map<string, bufferlist> attrs;
int r = get_bucket_info(NULL, bucket.name, info, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
ret = r;
@ -1089,7 +1090,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
info.flags |= BUCKET_SUSPENDED;
}
r = put_bucket_info(bucket.name, info, false);
r = put_bucket_info(bucket.name, info, false, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
ret = r;
@ -2129,11 +2130,11 @@ int RGWRados::get_bucket_stats(rgw_bucket& bucket, map<RGWObjCategory, RGWBucket
return 0;
}
int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info)
int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info, map<string, bufferlist> *pattrs)
{
bufferlist bl;
int ret = rgw_get_obj(ctx, pi_buckets_rados, bucket_name, bl);
int ret = rgw_get_obj(ctx, pi_buckets_rados, bucket_name, bl, pattrs);
if (ret < 0) {
if (ret != -ENOENT)
return ret;
@ -2156,7 +2157,7 @@ int RGWRados::get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& inf
return 0;
}
int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive)
int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive, map<string, bufferlist> *pattrs)
{
bufferlist bl;
@ -2164,7 +2165,7 @@ int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exc
string unused;
int ret = rgw_put_obj(unused, pi_buckets_rados, bucket_name, bl.c_str(), bl.length(), exclusive);
int ret = rgw_put_obj(unused, pi_buckets_rados, bucket_name, bl.c_str(), bl.length(), exclusive, pattrs);
return ret;
}

View File

@ -530,8 +530,8 @@ public:
int decode_policy(bufferlist& bl, ACLOwner *owner);
int get_bucket_stats(rgw_bucket& bucket, map<RGWObjCategory, RGWBucketStats>& stats);
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info);
virtual int put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive);
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info, map<string, bufferlist> *pattrs = NULL);
virtual int put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive, map<string, bufferlist> *pattrs);
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
int cls_obj_prepare_op(rgw_bucket& bucket, uint8_t op, string& tag,

View File

@ -33,7 +33,7 @@ int rgw_put_obj(string& uid, rgw_bucket& bucket, string& oid, const char *data,
return ret;
}
int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl)
int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, map<string, bufferlist> *pattrs)
{
int ret;
struct rgw_err err;
@ -41,7 +41,7 @@ int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl)
bufferlist::iterator iter;
int request_len = READ_CHUNK_LEN;
rgw_obj obj(bucket, key);
ret = rgwstore->prepare_get_obj(ctx, obj, NULL, NULL, NULL, NULL,
ret = rgwstore->prepare_get_obj(ctx, obj, NULL, NULL, pattrs, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, &handle, &err);
if (ret < 0)
return ret;

View File

@ -8,7 +8,7 @@
int rgw_put_obj(string& uid, rgw_bucket& bucket, string& oid, const char *data, size_t size, bool exclusive, map<string, bufferlist> *pattrs = NULL);
int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl);
int rgw_get_obj(void *ctx, rgw_bucket& bucket, string& key, bufferlist& bl, map<string, bufferlist> *pattrs = NULL);
int rgw_tools_init(CephContext *cct);
const char *rgw_find_mime_by_ext(string& ext);