]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: put locator key in rgw_obj
authorYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 8 Jun 2011 20:10:01 +0000 (13:10 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Wed, 8 Jun 2011 20:10:01 +0000 (13:10 -0700)
src/rgw/rgw_access.h
src/rgw/rgw_admin.cc
src/rgw/rgw_common.h
src/rgw/rgw_fs.cc
src/rgw/rgw_fs.h
src/rgw/rgw_log.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_user.cc

index c22ed2d5a11ec882f488fd51f698fb28ff739fd6..3b597d847df5f7be9d123cddd126d44e7f258221 100644 (file)
@@ -46,16 +46,16 @@ public:
   virtual int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, uint64_t auid=0) = 0;
   /** write an object to the storage device in the appropriate pool
     with the given stats */
-  virtual int put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc, time_t *mtime,
+  virtual int put_obj_meta(std::string& id, rgw_obj& obj, time_t *mtime,
                       map<std::string, bufferlist>& attrs, bool exclusive) = 0;
-  virtual int put_obj_data(std::string& id, rgw_obj& obj, std::string& loc, const char *data,
+  virtual int put_obj_data(std::string& id, rgw_obj& obj, const char *data,
                       off_t ofs, size_t len, time_t *mtime) = 0;
 
-  int put_obj(std::string& id, rgw_obj& obj, std::string& loc, const char *data, size_t len,
+  int put_obj(std::string& id, rgw_obj& obj, const char *data, size_t len,
               time_t *mtime, map<std::string, bufferlist>& attrs) {
-    int ret = put_obj_meta(id, obj, loc, NULL, attrs, false);
+    int ret = put_obj_meta(id, obj, NULL, attrs, false);
     if (ret >= 0) {
-      ret = put_obj_data(id, obj, loc, data, -1, len, mtime);
+      ret = put_obj_data(id, obj, data, -1, len, mtime);
     }
     return ret;
   }
@@ -121,7 +121,7 @@ public:
  *          (if get_data==true) length of read data,
  *          (if get_data==false) length of the object
  */
-  virtual int prepare_get_obj(rgw_obj& obj, std::string& loc,
+  virtual int prepare_get_obj(rgw_obj& obj,
             off_t ofs, off_t *end,
             map<string, bufferlist> *attrs,
             const time_t *mod_ptr,
@@ -133,14 +133,14 @@ public:
             void **handle,
             struct rgw_err *err) = 0;
 
-  virtual int get_obj(void **handle, rgw_obj& obj, std::string& loc,
+  virtual int get_obj(void **handle, rgw_obj& obj,
             char **data, off_t ofs, off_t end) = 0;
 
   virtual void finish_get_obj(void **handle) = 0;
 
   virtual int clone_range(rgw_obj& dst_obj, off_t dst_ofs,
                           rgw_obj& src_obj, off_t src_ofs,
-                          size_t size, std::string& loc) = 0;
+                          size_t size) = 0;
  /**
    * a simple object read without keeping state
    */
@@ -154,7 +154,7 @@ public:
    * dest: bufferlist to store the result in
    * Returns: 0 on success, -ERR# otherwise.
    */
-  virtual int get_attr(rgw_obj& obj, std::string& loc, const char *name, bufferlist& dest) = 0;
+  virtual int get_attr(rgw_obj& obj, const char *name, bufferlist& dest) = 0;
 
   /**
    * Set an attr on an object.
index 4e371e284fd8fd8d9a54a8b9fbd280278ee3022c..410fc4daac59271e19d3282d43398d4e1bec2896 100644 (file)
@@ -550,7 +550,7 @@ int main(int argc, char **argv)
     string bucket_str(bucket);
     string object_str(object);
     rgw_obj obj(bucket_str, object_str);
-    int ret = store->get_attr(obj, object_str, RGW_ATTR_ACL, bl);
+    int ret = store->get_attr(obj, RGW_ATTR_ACL, bl);
 
     RGWAccessControlPolicy policy;
     if (ret >= 0) {
index 30d53ce97547d0b086c14fa1554c3cb1aa2e2d24..28934fa6deca0f05b020e436bcfede098411f6dd 100644 (file)
@@ -452,12 +452,23 @@ class rgw_obj {
 public:
   std::string bucket;
   std::string object;
+  std::string key;
 
   rgw_obj() {}
-  rgw_obj(std::string& b, std::string& o) : bucket(b), object(o) {}
+  rgw_obj(std::string& b, std::string& o) {
+    init(b, o);
+  }
+  rgw_obj(std::string& b, std::string& o, std::string& k) {
+    init(b, o, k);
+  }
+  void init(std::string& b, std::string& o, std::string& k) {
+    bucket = b;
+    object = o;
+  }
   void init(std::string& b, std::string& o) {
     bucket = b;
     object = o;
+    key = o;
   }
 };
 
index 312105ce5b3c9a6fce1cd566f1986605d68d7eb1..b4e8442ad069d9eebb7917a65c1e9a9879c29548 100644 (file)
@@ -185,7 +185,7 @@ int RGWFS::create_bucket(std::string& id, std::string& bucket, map<std::string,
   return 0;
 }
 
-int RGWFS::put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc,
+int RGWFS::put_obj_meta(std::string& id, rgw_obj& obj,
                   time_t *mtime, map<string, bufferlist>& attrs, bool exclusive)
 {
   std::string& bucket = obj.bucket;
@@ -232,7 +232,7 @@ done_err:
   return -errno;
 }
 
-int RGWFS::put_obj_data(std::string& id, rgw_obj& obj, std::string& loc, const char *data,
+int RGWFS::put_obj_data(std::string& id, rgw_obj& obj, const char *data,
                   off_t ofs, size_t size, time_t *mtime)
 {
   std::string& bucket = obj.bucket;
@@ -291,10 +291,6 @@ int RGWFS::copy_obj(std::string& id, rgw_obj& dest_obj,
                map<string, bufferlist>& attrs,
                struct rgw_err *err)
 {
-  std::string& dest_bucket = dest_obj.bucket;
-  std::string& dest_oid = dest_obj.object;
-  std::string& src_bucket = src_obj.bucket;
-  std::string& src_oid = src_obj.object;
   int ret;
   char *data;
   void *handle;
@@ -303,13 +299,13 @@ int RGWFS::copy_obj(std::string& id, rgw_obj& dest_obj,
   time_t lastmod;
 
   map<string, bufferlist> attrset;
-  ret = prepare_get_obj(src_obj, src_oid, 0, &end, &attrset, mod_ptr, unmod_ptr, &lastmod,
+  ret = prepare_get_obj(src_obj, 0, &end, &attrset, mod_ptr, unmod_ptr, &lastmod,
                         if_match, if_nomatch, &total_len, &handle, err);
   if (ret < 0)
     return ret;
  
   do { 
-    ret = get_obj(&handle, src_obj, src_oid, &data, ofs, end);
+    ret = get_obj(&handle, src_obj, &data, ofs, end);
     if (ret < 0)
       return ret;
     ofs += ret;
@@ -321,7 +317,7 @@ int RGWFS::copy_obj(std::string& id, rgw_obj& dest_obj,
   }
   attrs = attrset;
 
-  ret = put_obj(id, dest_obj, dest_oid, data, ret, mtime, attrs);
+  ret = put_obj(id, dest_obj, data, ret, mtime, attrs);
 
   return ret;
 }
@@ -407,8 +403,7 @@ int RGWFS::get_attr(const char *name, const char *path, char **attr)
   return attr_len;
 }
 
-int RGWFS::get_attr(rgw_obj& obj, std::string& loc,
-                       const char *name, bufferlist& dest)
+int RGWFS::get_attr(rgw_obj& obj, const char *name, bufferlist& dest)
 {
   std::string& bucket = obj.bucket;
   std::string& oid = obj.object;
@@ -448,7 +443,7 @@ int RGWFS::set_attr(rgw_obj& obj,
   return ret;
 }
 
-int RGWFS::prepare_get_obj(rgw_obj& obj, std::string& loc,
+int RGWFS::prepare_get_obj(rgw_obj& obj,
             off_t ofs, off_t *end,
             map<string, bufferlist> *attrs,
             const time_t *mod_ptr,
@@ -552,8 +547,7 @@ done_err:
   return r;
 }
 
-int RGWFS::get_obj(void **handle, rgw_obj& obj, std::string& loc,
-            char **data, off_t ofs, off_t end)
+int RGWFS::get_obj(void **handle, rgw_obj& obj, char **data, off_t ofs, off_t end)
 {
   uint64_t len;
   bufferlist bl;
index cd5cfc8ae25f9c42cb68eef3b966d53cc8c550c8..00a5c670cb8a0ceb6be067cbc7733e1a07732dc7 100644 (file)
@@ -19,12 +19,12 @@ public:
                    bool get_content_type);
 
   int create_bucket(std::string& id, std::string& bucket, map<std::string, bufferlist>& attrs, uint64_t auid=0);
-  int put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc, time_t *mtime,
+  int put_obj_meta(std::string& id, rgw_obj& obj, time_t *mtime,
              map<std::string, bufferlist>& attrs, bool exclusive);
-  int put_obj_data(std::string& id, rgw_obj& obj, std::string& loc, const char *data,
+  int put_obj_data(std::string& id, rgw_obj& obj, const char *data,
               off_t ofs, size_t size, time_t *mtime);
   int clone_range(rgw_obj& dst_obj, off_t dst_ofs,
-                  rgw_obj& src_obj, off_t src_ofs, size_t size, std::string& loc) { return -ENOTSUP; }
+                  rgw_obj& src_obj, off_t src_ofs, size_t size) { return -ENOTSUP; }
   int copy_obj(std::string& id, rgw_obj& dest_obj,
                rgw_obj& src_obj,
                time_t *mtime,
@@ -39,10 +39,10 @@ public:
 
   int get_attr(const char *name, int fd, char **attr);
   int get_attr(const char *name, const char *path, char **attr);
-  int get_attr(rgw_obj& obj, std::string& loc, const char *name, bufferlist& dest);
+  int get_attr(rgw_obj& obj, const char *name, bufferlist& dest);
   int set_attr(rgw_obj& obj, const char *name, bufferlist& bl);
 
-  int prepare_get_obj(rgw_obj& obj, std::string& loc,
+  int prepare_get_obj(rgw_obj& obj,
             off_t ofs, off_t *end,
            map<std::string, bufferlist> *attrs,
             const time_t *mod_ptr,
@@ -54,8 +54,7 @@ public:
             void **handle,
             struct rgw_err *err);
 
-  int get_obj(void **handle, rgw_obj& obj, std::string& loc,
-            char **data, off_t ofs, off_t end);
+  int get_obj(void **handle, rgw_obj& obj, char **data, off_t ofs, off_t end);
 
   void finish_get_obj(void **handle);
   int read(rgw_obj& obj, off_t ofs, size_t size, bufferlist& bl);
index ce9b0bf4a1b72cc2a9c46064374a0fe9c9611240..25fdf7daa9b7680b5944abcf01e7b8da354dbed4 100644 (file)
@@ -69,9 +69,8 @@ int rgw_log_op(struct req_state *s)
   
   char buf[entry.bucket.size() + 16];
   sprintf(buf, "%.4d-%.2d-%.2d-%s", (bdt.tm_year+1900), (bdt.tm_mon+1), bdt.tm_mday, entry.bucket.c_str());
-  rgw_obj obj;
-  obj.bucket = log_bucket;
-  obj.object = buf;
+  string oid(buf);
+  rgw_obj obj(log_bucket, oid);
 
   int ret = rgwstore->append_async(obj, bl.length(), bl);
 
index 1d758e3cfe170cc9f5f9f497d5a9cb10c23f08c4..e91a1a01854fe9f2f5e171b1d29f69d85bcfa7bb 100644 (file)
@@ -84,14 +84,13 @@ void get_request_metadata(struct req_state *s, map<string, bufferlist>& attrs)
  * object: name of the object to get the ACL for.
  * Returns: 0 on success, -ERR# otherwise.
  */
-static int get_policy_from_attr(RGWAccessControlPolicy *policy, string& bucket, string& object, string& loc)
+static int get_policy_from_attr(RGWAccessControlPolicy *policy, rgw_obj& obj)
 {
   bufferlist bl;
   int ret = 0;
 
-  if (bucket.size()) {
-    rgw_obj obj(bucket, object);
-    ret = rgwstore->get_attr(obj, loc, RGW_ATTR_ACL, bl);
+  if (obj.bucket.size()) {
+    ret = rgwstore->get_attr(obj, RGW_ATTR_ACL, bl);
 
     if (ret >= 0) {
       bufferlist::iterator iter = bl.begin();
@@ -110,21 +109,22 @@ static int get_policy_from_attr(RGWAccessControlPolicy *policy, string& bucket,
 int read_acls(struct req_state *s, RGWAccessControlPolicy *policy, string& bucket, string& object)
 {
   string upload_id = s->args.get("uploadId");
-  string obj = object;
-  string loc = object;
+  string oid = object;
 
-  if (!obj.empty() && !upload_id.empty()) {
-    obj.append(".");
-    obj.append(upload_id);
+  if (!oid.empty() && !upload_id.empty()) {
+    oid.append(".");
+    oid.append(upload_id);
   }
+  rgw_obj obj(bucket, oid, object);
 
-  int ret = get_policy_from_attr(policy, bucket, obj, loc);
+  int ret = get_policy_from_attr(policy, obj);
   if (ret == -ENOENT && object.size()) {
     /* object does not exist checking the bucket's ACL to make sure
        that we send a proper error code */
     RGWAccessControlPolicy bucket_policy;
     string no_object;
-    ret = get_policy_from_attr(&bucket_policy, bucket, no_object, no_object);
+    rgw_obj no_obj(bucket, no_object);
+    ret = get_policy_from_attr(&bucket_policy, no_obj);
     if (ret < 0)
       return ret;
 
@@ -183,7 +183,7 @@ void RGWGetObj::execute()
   init_common();
 
   obj.init(s->bucket_str, s->object_str);
-  ret = rgwstore->prepare_get_obj(obj, s->object_str, ofs, &end, &attrs, mod_ptr,
+  ret = rgwstore->prepare_get_obj(obj, ofs, &end, &attrs, mod_ptr,
                                   unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &handle, &s->err);
   if (ret < 0)
     goto done;
@@ -194,7 +194,7 @@ void RGWGetObj::execute()
     goto done;
 
   while (ofs <= end) {
-    ret = rgwstore->get_obj(&handle, obj, s->object_str, &data, ofs, end);
+    ret = rgwstore->get_obj(&handle, obj, &data, ofs, end);
     if (ret < 0) {
       goto done;
     }
@@ -322,7 +322,9 @@ void RGWCreateBucket::execute()
   bool existed;
   bool pol_ret;
 
-  int r = get_policy_from_attr(&old_policy, rgw_root_bucket, s->bucket_str, s->bucket_str);
+  rgw_obj obj(rgw_root_bucket, s->bucket_str);
+
+  int r = get_policy_from_attr(&old_policy, obj);
   if (r >= 0)  {
     if (old_policy.get_owner().get_id().compare(s->user.user_id) != 0) {
       ret = -EEXIST;
@@ -443,7 +445,7 @@ void RGWPutObj::execute()
       oid.append(".");
       oid.append(part_num);
     }
-    rgw_obj obj(s->bucket_str, oid);
+    rgw_obj obj(s->bucket_str, oid, s->object_str);
     do {
       get_data();
       if (len > 0) {
@@ -451,7 +453,7 @@ void RGWPutObj::execute()
        // For the first call to put_obj_data, pass -1 as the offset to
        // do a write_full.
         ret = rgwstore->put_obj_data(s->user.user_id, obj,
-                                    s->object_str, data,
+                                    data,
                                     ((ofs == 0) ? -1 : ofs), len, NULL);
         free(data);
         if (ret < 0)
@@ -488,7 +490,7 @@ void RGWPutObj::execute()
 
     get_request_metadata(s, attrs);
 
-    ret = rgwstore->put_obj_meta(s->user.user_id, obj, s->object_str, NULL, attrs, false);
+    ret = rgwstore->put_obj_meta(s->user.user_id, obj, NULL, attrs, false);
     if (ret < 0)
       goto done;
 
@@ -506,9 +508,9 @@ void RGWPutObj::execute()
       RGW_LOG(0) << "JJJ name=" << p << "bl.length()=" << bl.length() << dendl;
       meta_attrs[p] = bl;
 
-      rgw_obj meta_obj(s->bucket_str, multipart_meta_obj);
+      rgw_obj meta_obj(s->bucket_str, multipart_meta_obj, s->object_str);
       
-      ret  = rgwstore->put_obj_meta(s->user.user_id, meta_obj, s->object_str, NULL, meta_attrs, false);
+      ret  = rgwstore->put_obj_meta(s->user.user_id, meta_obj, NULL, meta_attrs, false);
     }
   }
 done:
@@ -879,8 +881,8 @@ void RGWInitMultipart::execute()
     tmp_obj_name.append(".");
     tmp_obj_name.append(upload_id);
 
-    obj.init(s->bucket_str, tmp_obj_name);
-    ret = rgwstore->put_obj_meta(s->user.user_id, obj, s->object_str, NULL, attrs, true);
+    obj.init(s->bucket_str, tmp_obj_name, s->object_str);
+    ret = rgwstore->put_obj_meta(s->user.user_id, obj, NULL, attrs, true);
   } while (ret == -EEXIST);
 done:
   send_response();
@@ -893,9 +895,9 @@ static int get_multiparts_info(struct req_state *s, string& oid, map<uint32_t, R
   map<string, bufferlist> attrs;
   map<string, bufferlist>::iterator iter;
 
-  rgw_obj obj(s->bucket_str, oid);
+  rgw_obj obj(s->bucket_str, oid, s->object_str);
 
-  int ret = rgwstore->prepare_get_obj(obj, s->object_str, 0, NULL, &attrs, NULL,
+  int ret = rgwstore->prepare_get_obj(obj, 0, NULL, &attrs, NULL,
                                       NULL, NULL, NULL, NULL, NULL, &handle, &s->err);
   rgwstore->finish_get_obj(&handle);
 
@@ -1015,7 +1017,7 @@ void RGWCompleteMultipart::execute()
   attrs[RGW_ATTR_ETAG] = etag_bl;
 
   target_obj.init(s->bucket_str, s->object_str);
-  ret = rgwstore->put_obj_meta(s->user.user_id, target_obj, s->object_str, NULL, attrs, false);
+  ret = rgwstore->put_obj_meta(s->user.user_id, target_obj, NULL, attrs, false);
   if (ret < 0)
     goto done;
 
@@ -1024,9 +1026,9 @@ void RGWCompleteMultipart::execute()
     char buf[16];
     snprintf(buf, sizeof(buf), "%d", obj_iter->second.num);
     oid.append(buf);
-    rgw_obj src_obj(s->bucket_str, oid);
+    rgw_obj src_obj(s->bucket_str, oid, s->object_str);
     rgw_obj dst_obj(s->bucket_str, s->object_str);
-    rgwstore->clone_range(dst_obj, ofs, src_obj, 0, obj_iter->second.size, s->object_str);
+    rgwstore->clone_range(dst_obj, ofs, src_obj, 0, obj_iter->second.size);
     ofs += obj_iter->second.size;
   }
 
@@ -1036,11 +1038,11 @@ void RGWCompleteMultipart::execute()
     char buf[16];
     snprintf(buf, sizeof(buf), "%d", obj_iter->second.num);
     oid.append(buf);
-    rgw_obj obj(s->bucket_str, oid);
+    rgw_obj obj(s->bucket_str, oid, s->object_str);
     rgwstore->delete_obj(s->user.user_id, obj);
   }
   // and also remove the metadata obj
-  meta_obj.init(s->bucket_str, meta_oid);
+  meta_obj.init(s->bucket_str, meta_oid, s->object_str);
   rgwstore->delete_obj(s->user.user_id, meta_obj);
 
 
index 41b7379efcc7ec9f949af7698b53a50dbb01ea9a..8ff650b28e1cf32530697bdbc3d82c9af44b04c2 100644 (file)
@@ -256,7 +256,7 @@ int RGWRados::create_bucket(std::string& id, std::string& bucket, map<std::strin
  * exclusive: create object exclusively
  * Returns: 0 on success, -ERR# otherwise.
  */
-int RGWRados::put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc,
+int RGWRados::put_obj_meta(std::string& id, rgw_obj& obj,
                   time_t *mtime, map<string, bufferlist>& attrs, bool exclusive)
 {
   std::string& bucket = obj.bucket;
@@ -267,7 +267,7 @@ int RGWRados::put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc,
   if (r < 0)
     return r;
 
-  io_ctx.locator_set_key(loc);
+  io_ctx.locator_set_key(obj.key);
 
   if (exclusive) {
     r = io_ctx.create(oid, true);
@@ -309,7 +309,7 @@ int RGWRados::put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc,
  * attrs: all the given attrs are written to bucket storage for the given object
  * Returns: 0 on success, -ERR# otherwise.
  */
-int RGWRados::put_obj_data(std::string& id, rgw_obj& obj, std::string& loc,
+int RGWRados::put_obj_data(std::string& id, rgw_obj& obj,
                           const char *data, off_t ofs, size_t len, time_t *mtime)
 {
   std::string& bucket = obj.bucket;
@@ -320,7 +320,7 @@ int RGWRados::put_obj_data(std::string& id, rgw_obj& obj, std::string& loc,
   if (r < 0)
     return r;
 
-  io_ctx.locator_set_key(loc);
+  io_ctx.locator_set_key(obj.key);
 
   bufferlist bl;
   bl.append(data, len);
@@ -367,10 +367,6 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
                map<string, bufferlist>& attrs,  /* in/out */
                struct rgw_err *err)
 {
-  string& dest_bucket = dest_obj.bucket;
-  string& dest_oid = dest_obj.object;
-  string& src_bucket = src_obj.bucket;
-  string& src_oid = src_obj.object;
   int ret, r;
   char *data;
   off_t end = -1;
@@ -378,12 +374,12 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
   time_t lastmod;
   map<string, bufferlist>::iterator iter;
 
-  RGW_LOG(5) << "Copy object " << src_bucket << ":" << src_oid << " => " << dest_bucket << ":" << dest_oid << dendl;
+  RGW_LOG(5) << "Copy object " << src_obj.bucket << ":" << src_obj.object << " => " << dest_obj.bucket << ":" << dest_obj.object << dendl;
 
   void *handle = NULL;
 
   map<string, bufferlist> attrset;
-  ret = prepare_get_obj(src_obj, src_oid, 0, &end, &attrset,
+  ret = prepare_get_obj(src_obj, 0, &end, &attrset,
                 mod_ptr, unmod_ptr, &lastmod, if_match, if_nomatch, &total_len, &handle, err);
 
   if (ret < 0)
@@ -391,13 +387,13 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
 
   off_t ofs = 0;
   do {
-    ret = get_obj(&handle, src_obj, src_oid, &data, ofs, end);
+    ret = get_obj(&handle, src_obj, &data, ofs, end);
     if (ret < 0)
       return ret;
 
     // In the first call to put_obj_data, we pass ofs == -1 so that it will do
     // a write_full, wiping out whatever was in the object before this
-    r = put_obj_data(id, dest_obj, dest_oid, data,
+    r = put_obj_data(id, dest_obj, data,
                     ((ofs == 0) ? -1 : ofs), ret, NULL);
     free(data);
     if (r < 0)
@@ -411,7 +407,7 @@ int RGWRados::copy_obj(std::string& id, rgw_obj& dest_obj,
   }
   attrs = attrset;
 
-  ret = put_obj_meta(id, dest_obj, dest_oid, mtime, attrs, false);
+  ret = put_obj_meta(id, dest_obj, mtime, attrs, false);
 
   finish_get_obj(&handle);
 
@@ -486,8 +482,7 @@ int RGWRados::delete_obj(std::string& id, rgw_obj& obj)
  * dest: bufferlist to store the result in
  * Returns: 0 on success, -ERR# otherwise.
  */
-int RGWRados::get_attr(rgw_obj& obj, std::string& loc,
-                       const char *name, bufferlist& dest)
+int RGWRados::get_attr(rgw_obj& obj, const char *name, bufferlist& dest)
 {
   std::string& bucket = obj.bucket;
   std::string& oid = obj.object;
@@ -504,7 +499,7 @@ int RGWRados::get_attr(rgw_obj& obj, std::string& loc,
   if (r < 0)
     return r;
 
-  io_ctx.locator_set_key(loc);
+  io_ctx.locator_set_key(obj.key);
 
   r = io_ctx.getxattr(actual_obj, name, dest);
   if (r < 0)
@@ -568,7 +563,7 @@ int RGWRados::set_attr(rgw_obj& obj, const char *name, bufferlist& bl)
  *          (if get_data==true) length of read data,
  *          (if get_data==false) length of the object
  */
-int RGWRados::prepare_get_obj(rgw_obj& obj, std::string& loc,
+int RGWRados::prepare_get_obj(rgw_obj& obj,
             off_t ofs, off_t *end,
             map<string, bufferlist> *attrs,
             const time_t *mod_ptr,
@@ -602,7 +597,7 @@ int RGWRados::prepare_get_obj(rgw_obj& obj, std::string& loc,
   if (r < 0)
     goto done_err;
 
-  state->io_ctx.locator_set_key(loc);
+  state->io_ctx.locator_set_key(obj.key);
 
   if (total_size || end) {
     r = state->io_ctx.stat(oid, &size, &mtime);
@@ -644,7 +639,7 @@ int RGWRados::prepare_get_obj(rgw_obj& obj, std::string& loc,
     }
   }
   if (if_match || if_nomatch) {
-    r = get_attr(obj, loc, RGW_ATTR_ETAG, etag);
+    r = get_attr(obj, RGW_ATTR_ETAG, etag);
     if (r < 0)
       goto done_err;
 
@@ -685,7 +680,7 @@ done_err:
 }
 
 int RGWRados::clone_range(rgw_obj& dst_obj, off_t dst_ofs,
-                          rgw_obj& src_obj, off_t src_ofs, size_t size, std::string& loc)
+                          rgw_obj& src_obj, off_t src_ofs, size_t size)
 {
   std::string& bucket = dst_obj.bucket;
   std::string& dst_oid = dst_obj.object;
@@ -696,17 +691,15 @@ int RGWRados::clone_range(rgw_obj& dst_obj, off_t dst_ofs,
   if (r < 0)
     return r;
 
-  io_ctx.locator_set_key(loc);
+  io_ctx.locator_set_key(dst_obj.key);
 
   return io_ctx.clone_range(dst_oid, dst_ofs, src_oid, src_ofs, size);
 }
 
 
-int RGWRados::get_obj(void **handle,
-            rgw_obj& obj, string& loc,
+int RGWRados::get_obj(void **handle, rgw_obj& obj,
             char **data, off_t ofs, off_t end)
 {
-  std::string& bucket = obj.bucket;
   std::string& oid = obj.object;
   uint64_t len;
   bufferlist bl;
@@ -721,7 +714,7 @@ int RGWRados::get_obj(void **handle,
   if (len > RGW_MAX_CHUNK_SIZE)
     len = RGW_MAX_CHUNK_SIZE;
 
-  state->io_ctx.locator_set_key(loc);
+  state->io_ctx.locator_set_key(obj.key);
 
   RGW_LOG(20) << "rados->read ofs=" << ofs << " len=" << len << dendl;
   int r = state->io_ctx.read(oid, bl, len, ofs);
index 8cb7592fce85f4b6c1546d3b96c304e18eb09fb7..4b3fa2b4ce4baf65d0482f8c81fbc9fd0e795740 100644 (file)
@@ -42,12 +42,12 @@ public:
   virtual int create_bucket(std::string& id, std::string& bucket, map<std::string,bufferlist>& attrs, uint64_t auid=0);
 
   /** Write/overwrite an object to the bucket storage. */
-  virtual int put_obj_meta(std::string& id, rgw_obj& obj, std::string& loc, time_t *mtime,
+  virtual int put_obj_meta(std::string& id, rgw_obj& obj, time_t *mtime,
               map<std::string, bufferlist>& attrs, bool exclusive);
-  virtual int put_obj_data(std::string& id, rgw_obj& obj, std::string& loc, const char *data,
+  virtual int put_obj_data(std::string& id, rgw_obj& obj, const char *data,
               off_t ofs, size_t len, time_t *mtime);
   virtual int clone_range(rgw_obj& dst_obj, off_t dst_ofs,
-                          rgw_obj& src_obj, off_t src_ofs, size_t size, std::string& loc);
+                          rgw_obj& src_obj, off_t src_ofs, size_t size);
   /** Copy an object, with many extra options */
   virtual int copy_obj(std::string& id, rgw_obj& dest_obj,
                rgw_obj& src_obj,
@@ -65,14 +65,13 @@ public:
   virtual int delete_obj(std::string& id, rgw_obj& src_obj);
 
   /** Get the attributes for an object.*/
-  virtual int get_attr(rgw_obj& obj, std::string& loc,
-               const char *name, bufferlist& dest);
+  virtual int get_attr(rgw_obj& obj, const char *name, bufferlist& dest);
 
   /** Set an attr on an object. */
   virtual int set_attr(rgw_obj& obj, const char *name, bufferlist& bl);
 
   /** Get data about an object out of RADOS and into memory. */
-  virtual int prepare_get_obj(rgw_obj& obj, std::string& loc,  
+  virtual int prepare_get_obj(rgw_obj& obj,
             off_t ofs, off_t *end,
             map<string, bufferlist> *attrs,
             const time_t *mod_ptr,
@@ -84,7 +83,7 @@ public:
             void **handle,
             struct rgw_err *err);
 
-  virtual int get_obj(void **handle, rgw_obj& obj, std::string& loc,
+  virtual int get_obj(void **handle, rgw_obj& obj,
             char **data, off_t ofs, off_t end);
 
   virtual void finish_get_obj(void **handle);
index 73bb535f32f4872f78f55c5a00c5977c56247e8a..0704b407e768d64c7ab652c999dac67b5237b9b1 100644 (file)
@@ -35,16 +35,14 @@ static int put_obj(string& uid, string& bucket, string& oid, const char *data, s
 {
   map<string,bufferlist> attrs;
 
-  rgw_obj obj;
-  obj.bucket = bucket;
-  obj.object = oid;
+  rgw_obj obj(bucket, oid);
 
-  int ret = rgwstore->put_obj(uid, obj, oid, data, size, NULL, attrs);
+  int ret = rgwstore->put_obj(uid, obj, data, size, NULL, attrs);
 
   if (ret == -ENOENT) {
     ret = rgwstore->create_bucket(uid, bucket, attrs);
     if (ret >= 0)
-      ret = rgwstore->put_obj(uid, obj, oid, data, size, NULL, attrs);
+      ret = rgwstore->put_obj(uid, obj, data, size, NULL, attrs);
   }
 
   return ret;
@@ -129,13 +127,13 @@ int rgw_get_user_info_from_index(string& key, string& bucket, RGWUserInfo& info)
   bufferlist::iterator iter;
   int request_len = READ_CHUNK_LEN;
   rgw_obj obj(bucket, key);
-  ret = rgwstore->prepare_get_obj(obj, key, 0, NULL, NULL, NULL,
+  ret = rgwstore->prepare_get_obj(obj, 0, NULL, NULL, NULL,
                                   NULL, NULL, NULL, NULL, NULL, &handle, &err);
   if (ret < 0)
     return ret;
 
   do {
-    ret = rgwstore->get_obj(&handle, obj, key, &data, 0, request_len - 1);
+    ret = rgwstore->get_obj(&handle, obj, &data, 0, request_len - 1);
     if (ret < 0)
       goto done;
     if (ret < request_len)
@@ -204,7 +202,7 @@ static int rgw_read_buckets_from_attr(string& user_id, RGWUserBuckets& buckets)
 {
   bufferlist bl;
   rgw_obj obj(ui_uid_bucket, user_id);
-  int ret = rgwstore->get_attr(obj, user_id, RGW_ATTR_BUCKETS, bl);
+  int ret = rgwstore->get_attr(obj, RGW_ATTR_BUCKETS, bl);
   if (ret)
     return ret;