summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-07-26 16:35:24 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-07-29 10:57:30 -0700
commitcff24dbd1f4cdf82603a5c6d85d1a57aa98a58e3 (patch)
tree96a84e9ce45aabb51c8912c7ac2c665254bf304c
parent6ac8aed040049358aaf8aee5cfb16791c4bb54a2 (diff)
downloadceph-cff24dbd1f4cdf82603a5c6d85d1a57aa98a58e3.tar.gz
rgw: read / write bucket attributes from bucket instance
and not from bucket entry point. Fixes: #5770 Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_op.cc18
-rw-r--r--src/rgw/rgw_rados.cc7
-rw-r--r--src/rgw/rgw_rados.h1
3 files changed, 17 insertions, 9 deletions
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc
index 7760a2f5c52..7f60fa5bf8a 100644
--- a/src/rgw/rgw_op.cc
+++ b/src/rgw/rgw_op.cc
@@ -241,8 +241,10 @@ static int get_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx,
}
if (obj.object.empty()) {
+ rgw_obj actual_obj;
+ store->get_bucket_instance_obj(bucket_info.bucket, actual_obj);
return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs,
- policy, obj);
+ policy, actual_obj);
}
return get_obj_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs,
policy, obj);
@@ -1898,9 +1900,8 @@ void RGWPutCORS::execute()
RGWObjVersionTracker *ptracker = (s->object ? NULL : &s->bucket_info.objv_tracker);
- string no_obj;
cors_config->encode(bl);
- obj.init(s->bucket, no_obj);
+ store->get_bucket_instance_obj(s->bucket, obj);
store->set_atomic(s->obj_ctx, obj);
ret = store->set_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl, ptracker);
}
@@ -1917,13 +1918,12 @@ void RGWDeleteCORS::execute()
{
bufferlist bl;
rgw_obj obj;
- string no_obj;
if (!s->bucket_cors) {
dout(2) << "No CORS configuration set yet for this bucket" << dendl;
ret = -ENOENT;
return;
}
- obj.init(s->bucket, no_obj);
+ store->get_bucket_instance_obj(s->bucket, obj);
store->set_atomic(s->obj_ctx, obj);
map<string, bufferlist> orig_attrs, attrs, rmattrs;
map<string, bufferlist>::iterator iter;
@@ -2516,10 +2516,10 @@ int RGWHandler::read_cors_config(void)
bufferlist bl;
dout(10) << "Going to read cors from attrs" << dendl;
- string no_object;
- rgw_obj no_obj(s->bucket, no_object);
- if (no_obj.bucket.name.size()) {
- ret = store->get_attr(s->obj_ctx, no_obj, RGW_ATTR_CORS, bl);
+ rgw_obj obj;
+ store->get_bucket_instance_obj(s->bucket, obj);
+ if (obj.bucket.name.size()) {
+ ret = store->get_attr(s->obj_ctx, obj, RGW_ATTR_CORS, bl);
if (ret >= 0) {
bufferlist::iterator iter = bl.begin();
s->bucket_cors = new RGWCORSConfiguration();
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 8af03b03a8f..22c93f33ad5 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -4546,6 +4546,13 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid)
oid = RGW_BUCKET_INSTANCE_MD_PREFIX + entry;
}
+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);
+}
+
int RGWRados::get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs)
{
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index bcc40900299..099a7112514 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -1285,6 +1285,7 @@ public:
int decode_policy(bufferlist& bl, ACLOwner *owner);
int get_bucket_stats(rgw_bucket& bucket, uint64_t *bucket_ver, uint64_t *master_ver, map<RGWObjCategory, RGWBucketStats>& stats,
string *max_marker);
+ void get_bucket_instance_obj(rgw_bucket& bucket, rgw_obj& obj);
void get_bucket_instance_entry(rgw_bucket& bucket, string& entry);
void get_bucket_meta_oid(rgw_bucket& bucket, string& oid);