]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: a few fixes to copy object across region
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 13 Jun 2013 06:59:49 +0000 (23:59 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 13 Jun 2013 06:59:49 +0000 (23:59 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_client.cc

index baf6a2c9bba6ae747efd605f5cfaabeaf8bacd95..0bf33a931f31eb4e8fbcc9ad02ca26784fc49d89 100644 (file)
@@ -1152,7 +1152,7 @@ void RGWPutObj::execute()
 
   processor = select_processor();
 
-  ret = processor->prepare(store, s);
+  ret = processor->prepare(store, s->obj_ctx);
   if (ret < 0)
     goto done;
 
index 0f39753f33867d9ffb90908c96b189c3a35f87ed..809be0343c029c37a3739e2aab44f86ce1f8813b 100644 (file)
@@ -2109,11 +2109,25 @@ bool RGWRados::aio_completed(void *handle)
 class RGWRadosPutObj : public RGWGetDataCB
 {
   rgw_obj obj;
+  RGWPutObjProcessor_Atomic *processor;
 public:
-  RGWRadosPutObj(rgw_obj& _o) : obj(_o) {}
+  RGWRadosPutObj(RGWPutObjProcessor_Atomic *p) : processor(p) {}
   int handle_data(bufferlist& bl, off_t ofs, off_t len) {
+    void *handle;
+    int ret = processor->handle_data(bl, ofs, &handle);
+    if (ret < 0)
+      return ret;
+
+    ret = processor->throttle_data(handle);
+    if (ret < 0)
+      return ret;
+
     return 0;
   }
+
+  int complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs) {
+    return processor->complete(etag, mtime, attrs);
+  }
 };
 
 /**
@@ -2182,7 +2196,16 @@ int RGWRados::copy_obj(void *ctx,
     map<string, bufferlist> src_attrs;
 
     RGWRESTStreamReadRequest *in_stream_req;
-    RGWRadosPutObj cb(dest_obj);
+    string tag;
+    append_rand_alpha(cct, tag, tag, 32);
+
+    RGWPutObjProcessor_Atomic processor(dest_obj.bucket, dest_obj.object,
+                                        cct->_conf->rgw_obj_stripe_size, tag);
+    ret = processor.prepare(this, ctx);
+    if (ret < 0)
+      return ret;
+
+    RGWRadosPutObj cb(&processor);
   
     int ret = rest_conn->get_obj(user_id, src_obj, &cb, &in_stream_req);
     if (ret < 0)
@@ -2194,6 +2217,10 @@ int RGWRados::copy_obj(void *ctx,
     if (ret < 0)
       return ret;
 
+    ret = cb.complete(etag, mtime, attrs);
+    if (ret < 0)
+      return ret;
+
     return 0;
   }
 
index f6a6a8d078aafd869d38766c820b58635a5560af..9952feafa25503707e81e63e261b43888ab03951 100644 (file)
@@ -211,10 +211,10 @@ class RGWPutObjProcessor_Plain : public RGWPutObjProcessor
 protected:
   int prepare(RGWRados *store, void *obj_ctx);
   int handle_data(bufferlist& bl, off_t ofs, void **phandle);
-  int throttle_data(void *handle) { return 0; }
   int do_complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs);
 
 public:
+  int throttle_data(void *handle) { return 0; }
   RGWPutObjProcessor_Plain(rgw_bucket& b, const string& o) : bucket(b), obj_str(o), ofs(0) {}
 };
 
@@ -236,6 +236,8 @@ protected:
   uint64_t obj_len;
 
   int handle_obj_data(rgw_obj& obj, bufferlist& bl, off_t ofs, off_t abs_ofs, void **phandle);
+
+public:
   int throttle_data(void *handle);
 
   RGWPutObjProcessor_Aio() : max_chunks(RGW_MAX_PENDING_CHUNKS), obj_len(0) {}
@@ -264,7 +266,6 @@ protected:
 
   virtual bool immutable_head() { return false; }
 
-  int prepare(RGWRados *store, void *obj_ctx);
   virtual int do_complete(string& etag, time_t *mtime, map<string, bufferlist>& attrs);
 
   void prepare_next_part(off_t ofs);
@@ -279,6 +280,7 @@ public:
                                 bucket(_b),
                                 obj_str(_o),
                                 unique_tag(_t) {}
+  int prepare(RGWRados *store, void *obj_ctx);
   int handle_data(bufferlist& bl, off_t ofs, void **phandle);
 };
 
index 9ff6ba57d8e2f28f1a37f312db75ec365beb588f..907ac0c423b43302b7ba2d3cfbad3ff1eb6274e0 100644 (file)
@@ -584,13 +584,15 @@ int RGWRESTStreamReadRequest::complete(string& etag, time_t *mtime)
   if (mtime) {
     string mtime_str;
     set_str_from_headers(out_headers, "RGWX_MTIME", mtime_str);
-    string err;
-    long t = strict_strtol(mtime_str.c_str(), 10, &err);
-    if (!err.empty()) {
-      ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
-      return -EINVAL;
+    if (!mtime_str.empty()) {
+      string err;
+      long t = strict_strtol(mtime_str.c_str(), 10, &err);
+      if (!err.empty()) {
+        ldout(cct, 0) << "ERROR: failed converting mtime (" << mtime_str << ") to int " << dendl;
+        return -EINVAL;
+      }
+      *mtime = (time_t)t;
     }
-    *mtime = (time_t)t;
   }
 
   return status;