]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: clone_obj can set mtime
authorYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 6 Aug 2011 00:22:21 +0000 (17:22 -0700)
committerYehuda Sadeh <yehuda@hq.newdream.net>
Sat, 6 Aug 2011 00:22:21 +0000 (17:22 -0700)
src/rgw/rgw_access.h
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 52e6398ade4631a304af8c7cf42f588f6fc63e63..226e53dcf63a2e81734129bf49dae26d057b57d1 100644 (file)
@@ -173,7 +173,8 @@ public:
 
   virtual int clone_obj(void *ctx, rgw_obj& dst_obj, off_t dst_ofs,
                           rgw_obj& src_obj, off_t src_ofs,
-                          uint64_t size, map<string, bufferlist> attrs) {
+                          uint64_t size, time_t *pmtime,
+                          map<string, bufferlist> attrs) {
     RGWCloneRangeInfo info;
     vector<RGWCloneRangeInfo> v;
     info.src = src_obj;
@@ -181,12 +182,13 @@ public:
     info.dst_ofs = dst_ofs;
     info.len = size;
     v.push_back(info);
-    return clone_objs(ctx, dst_obj, v, attrs, true);
+    return clone_objs(ctx, dst_obj, v, attrs, pmtime, true);
   }
 
   virtual int clone_objs(void *ctx, rgw_obj& dst_obj,
                         vector<RGWCloneRangeInfo>& ranges,
-                        map<string, bufferlist> attrs, bool truncate_dest) { return -ENOTSUP; }
+                        map<string, bufferlist> attrs, time_t *pmtime,
+                        bool truncate_dest) { return -ENOTSUP; }
  /**
    * a simple object read without keeping state
    */
index 5f6e3869a535b1336d376c5ae3dab52cf89ba289..e7dbb806efa59bb9d3893e3452aa596052a8f21f 100644 (file)
@@ -693,7 +693,7 @@ void RGWPutObj::execute()
     if (!multipart) {
       rgw_obj dst_obj(s->bucket_str, s->object_str);
       rgwstore->set_atomic(s->obj_ctx, dst_obj);
-      ret = rgwstore->clone_obj(s->obj_ctx, dst_obj, 0, obj, 0, s->obj_size, attrs);
+      ret = rgwstore->clone_obj(s->obj_ctx, dst_obj, 0, obj, 0, s->obj_size, NULL, attrs);
       if (ret < 0)
         goto done_err;
       if (created_obj) {
@@ -1288,7 +1288,7 @@ void RGWCompleteMultipart::execute()
 
     ofs += obj_iter->second.size;
   }
-  ret = rgwstore->clone_objs(s->obj_ctx, target_obj, ranges, attrs, true);
+  ret = rgwstore->clone_objs(s->obj_ctx, target_obj, ranges, attrs, NULL, true);
   if (ret < 0)
     goto done;
 
index 51e42244af32d3d090c68362dfa8e5730e6d0c87..bd6f7022976b6c039ac1e57ddeeefb8bd380a308 100644 (file)
@@ -521,7 +521,7 @@ int RGWRados::copy_obj(void *ctx, std::string& id, rgw_obj& dest_obj,
   }
   attrs = attrset;
 
-  ret = clone_obj(ctx, dest_obj, 0, tmp_obj, 0, end + 1, attrs);
+  ret = clone_obj(ctx, dest_obj, 0, tmp_obj, 0, end + 1, NULL, attrs);
   if (mtime)
     obj_stat(ctx, tmp_obj, NULL, mtime);
 
@@ -846,7 +846,7 @@ int RGWRados::prepare_atomic_for_write(RGWRadosCtx *rctx, rgw_obj& obj, librados
 
     /* FIXME: clone obj should be conditional, should check src object id-tag */
     pair<string, bufferlist> cond(RGW_ATTR_ID_TAG, state->obj_tag);
-    r = clone_obj_cond(NULL, dest_obj, 0, obj, 0, state->size, state->attrset, &cond);
+    r = clone_obj_cond(NULL, dest_obj, 0, obj, 0, state->size, state->attrset, &state->mtime, &cond);
     if (r == -ECANCELED) {
       /* we lost in a race here, original object was replaced, we assume it was cloned
          as required */
@@ -1083,6 +1083,7 @@ done_err:
 int RGWRados::clone_objs(void *ctx, rgw_obj& dst_obj,
                         vector<RGWCloneRangeInfo>& ranges,
                         map<string, bufferlist> attrs,
+                        time_t *pmtime,
                         bool truncate_dest,
                         pair<string, bufferlist> *xattr_cond)
 {
@@ -1135,6 +1136,9 @@ int RGWRados::clone_objs(void *ctx, rgw_obj& dst_obj,
     }
   }
 
+  if (pmtime)
+    op.mtime(pmtime);
+
   bufferlist outbl;
   int ret = io_ctx.operate(dst_oid, &op, &outbl);
   return ret;
index d2957fd7bbce95ebd94b8ceab752b17104f98cdb..7bc9188e5018be87f0e95d27527a78a445c36c84 100644 (file)
@@ -100,18 +100,21 @@ public:
   virtual bool aio_completed(void *handle);
   virtual int clone_objs(void *ctx, rgw_obj& dst_obj, 
                          vector<RGWCloneRangeInfo>& ranges,
-                         map<string, bufferlist> attrs, bool truncate_dest) {
-    return clone_objs(ctx, dst_obj, ranges, attrs, truncate_dest, NULL);
+                         map<string, bufferlist> attrs, time_t *pmtime, bool truncate_dest) {
+    return clone_objs(ctx, dst_obj, ranges, attrs, pmtime, truncate_dest, NULL);
   }
 
   int clone_objs(void *ctx, rgw_obj& dst_obj, 
                  vector<RGWCloneRangeInfo>& ranges,
-                 map<string, bufferlist> attrs, bool truncate_dest,
+                 map<string, bufferlist> attrs,
+                 time_t *pmtime,
+                 bool truncate_dest,
                  pair<string, bufferlist> *cmp_xattr);
 
   int clone_obj_cond(void *ctx, rgw_obj& dst_obj, off_t dst_ofs,
                 rgw_obj& src_obj, off_t src_ofs,
                 uint64_t size, map<string, bufferlist> attrs,
+                time_t *pmtime,
                 pair<string, bufferlist> *xattr_cond) {
     RGWCloneRangeInfo info;
     vector<RGWCloneRangeInfo> v;
@@ -120,7 +123,7 @@ public:
     info.dst_ofs = dst_ofs;
     info.len = size;
     v.push_back(info);
-    return clone_objs(ctx, dst_obj, v, attrs, true, xattr_cond);
+    return clone_objs(ctx, dst_obj, v, attrs, pmtime, true, xattr_cond);
   }
 
   /** Copy an object, with many extra options */