summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-25 12:56:25 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-25 12:56:25 -0700
commit82db84bec508239420d21187a85a3614dbfeb015 (patch)
tree3eeb8efc1319d9b2d776af776a6f6efb6eba83ef
parentc4be5a7057a01d2aa8a9a32ad795a1957fe0e6a7 (diff)
downloadceph-82db84bec508239420d21187a85a3614dbfeb015.tar.gz
rgw: some more internal api cleanups
Use of rgw_bucket when referring to the bucket instance, use bucket name when referring to the bucket entry point. Also, remove bucket input param where not needed (internally was using the bucket structure from the bucket info). Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_bucket.cc2
-rw-r--r--src/rgw/rgw_rados.cc33
-rw-r--r--src/rgw/rgw_rados.h9
3 files changed, 27 insertions, 17 deletions
diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc
index 22727f2558d..ac638f80dac 100644
--- a/src/rgw/rgw_bucket.cc
+++ b/src/rgw/rgw_bucket.cc
@@ -1522,7 +1522,7 @@ public:
bci.info.objv_tracker.read_version = old_bci.info.objv_tracker.read_version;
bci.info.objv_tracker.write_version = objv_tracker.write_version;
- ret = store->put_bucket_instance_info(oid, bci.info, false, mtime, &bci.attrs);
+ ret = store->put_bucket_instance_info(bci.info, false, mtime, &bci.attrs);
if (ret < 0)
return ret;
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index ad49fc962f4..6b952573d3c 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -1805,7 +1805,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
time(&info.creation_time);
else
info.creation_time = creation_time;
- ret = put_bucket_info(bucket.name, info, exclusive, 0, &attrs, true);
+ ret = put_bucket_info(info, exclusive, 0, &attrs, true);
if (ret == -EEXIST) {
/* remove bucket meta instance */
string entry;
@@ -2836,7 +2836,7 @@ int RGWRados::set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner)
{
RGWBucketInfo info;
map<string, bufferlist> attrs;
- int r = get_bucket_info(NULL, bucket.name, info, NULL, &attrs);
+ int r = get_bucket_instance_info(NULL, bucket, info, NULL, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl;
return r;
@@ -2844,7 +2844,7 @@ int RGWRados::set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner)
info.owner = owner.get_id();
- r = put_bucket_info(bucket.name, info, false, 0, &attrs, false);
+ r = put_bucket_instance_info(info, false, 0, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << dendl;
return r;
@@ -2869,7 +2869,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
RGWBucketInfo info;
map<string, bufferlist> attrs;
- int r = get_bucket_info(NULL, bucket.name, info, NULL, &attrs);
+ int r = get_bucket_instance_info(NULL, bucket, info, NULL, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: get_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
ret = r;
@@ -2881,7 +2881,7 @@ int RGWRados::set_buckets_enabled(vector<rgw_bucket>& buckets, bool enabled)
info.flags |= BUCKET_SUSPENDED;
}
- r = put_bucket_info(bucket.name, info, false, 0, &attrs, false);
+ r = put_bucket_instance_info(info, false, 0, &attrs);
if (r < 0) {
ldout(cct, 0) << "NOTICE: put_bucket_info on bucket=" << bucket.name << " returned err=" << r << ", skipping bucket" << dendl;
ret = r;
@@ -4490,14 +4490,23 @@ void RGWRados::get_bucket_meta_oid(rgw_bucket& bucket, string& oid)
oid = RGW_BUCKET_INSTANCE_MD_PREFIX + entry;
}
-int RGWRados::get_bucket_instance_info(void *ctx, string& entry, RGWBucketInfo& info,
+int RGWRados::get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs)
{
- int pos = entry.find(':');
+ int pos = meta_key.find(':');
if (pos < 0) {
return -EINVAL;
}
- string oid = RGW_BUCKET_INSTANCE_MD_PREFIX + entry;
+ string oid = RGW_BUCKET_INSTANCE_MD_PREFIX + meta_key;
+
+ return get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs);
+}
+
+int RGWRados::get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketInfo& info,
+ time_t *pmtime, map<string, bufferlist> *pattrs)
+{
+ string oid;
+ get_bucket_meta_oid(bucket, oid);
return get_bucket_instance_from_oid(ctx, oid, info, pmtime, pattrs);
}
@@ -4591,7 +4600,7 @@ int RGWRados::put_bucket_entrypoint_info(string& bucket_name, RGWBucketEntryPoin
return rgw_bucket_store_info(this, bucket_name, epbl, exclusive, NULL, &objv_tracker, mtime);
}
-int RGWRados::put_bucket_instance_info(string& bucket_name, RGWBucketInfo& info, bool exclusive,
+int RGWRados::put_bucket_instance_info(RGWBucketInfo& info, bool exclusive,
time_t mtime, map<string, bufferlist> *pattrs)
{
info.has_instance_obj = true;
@@ -4604,14 +4613,14 @@ int RGWRados::put_bucket_instance_info(string& bucket_name, RGWBucketInfo& info,
return rgw_bucket_instance_store_info(this, key, bl, exclusive, pattrs, &info.objv_tracker, mtime);
}
-int RGWRados::put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive,
- time_t mtime, map<string, bufferlist> *pattrs, bool create_entry_point)
+int RGWRados::put_bucket_info(RGWBucketInfo& info, bool exclusive, time_t mtime,
+ map<string, bufferlist> *pattrs, bool create_entry_point)
{
bufferlist bl;
bool create_head = !info.has_instance_obj || create_entry_point;
- int ret = put_bucket_instance_info(bucket_name, info, exclusive, mtime, pattrs);
+ int ret = put_bucket_instance_info(info, exclusive, mtime, pattrs);
if (ret < 0) {
return ret;
}
diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h
index 3b3ab67f0e6..d777a543b7b 100644
--- a/src/rgw/rgw_rados.h
+++ b/src/rgw/rgw_rados.h
@@ -1273,15 +1273,16 @@ public:
void get_bucket_meta_oid(rgw_bucket& bucket, string& oid);
int put_bucket_entrypoint_info(string& bucket_name, RGWBucketEntryPoint& entry_point, bool exclusive, RGWObjVersionTracker& objv_tracker, time_t mtime);
- int put_bucket_instance_info(string& bucket_name, RGWBucketInfo& info, bool exclusive, time_t mtime, map<string, bufferlist> *pattrs);
+ int put_bucket_instance_info(RGWBucketInfo& info, bool exclusive, time_t mtime, map<string, bufferlist> *pattrs);
int get_bucket_entrypoint_info(void *ctx, string& bucket_name, RGWBucketEntryPoint& entry_point, RGWObjVersionTracker *objv_tracker, time_t *pmtime);
- int get_bucket_instance_info(void *ctx, string& name, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
+ int get_bucket_instance_info(void *ctx, const string& meta_key, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
+ int get_bucket_instance_info(void *ctx, rgw_bucket& bucket, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
int get_bucket_instance_from_oid(void *ctx, string& oid, RGWBucketInfo& info, time_t *pmtime, map<string, bufferlist> *pattrs);
virtual int get_bucket_info(void *ctx, string& bucket_name, RGWBucketInfo& info,
time_t *pmtime, map<string, bufferlist> *pattrs = NULL);
- virtual int put_bucket_info(string& bucket_name, RGWBucketInfo& info, bool exclusive,
- time_t mtime, map<string, bufferlist> *pattrs, bool create_entry_point);
+ virtual int put_bucket_info(RGWBucketInfo& info, bool exclusive, time_t mtime,
+ map<string, bufferlist> *pattrs, bool create_entry_point);
int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
int cls_obj_prepare_op(rgw_bucket& bucket, RGWModifyOp op, string& tag,