]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados, osd: add copy_from2 to librados and Objecter 31728/head
authorLuis Henriques <lhenriques@suse.com>
Tue, 26 Nov 2019 11:54:51 +0000 (11:54 +0000)
committerLuis Henriques <lhenriques@suse.com>
Wed, 4 Dec 2019 11:09:51 +0000 (11:09 +0000)
This commit simply adds this new version of the copy_from operation to
librados and to Objecter.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
src/include/rados/librados.hpp
src/librados/librados_cxx.cc
src/osdc/Objecter.h

index 2cda4d84756e99d250d875668d24ca234c8e10a1..ca520f510c65861f92673622d403a7e622aebc18 100644 (file)
@@ -459,6 +459,26 @@ inline namespace v14_2_0 {
     void copy_from(const std::string& src, const IoCtx& src_ioctx,
                   uint64_t src_version, uint32_t src_fadvise_flags);
 
+    /**
+     * Copy an object
+     *
+     * Copies an object from another location.  The operation is atomic in that
+     * the copy either succeeds in its entirety or fails (e.g., because the
+     * source object was modified while the copy was in progress).  Instead of
+     * copying truncate_seq and truncate_size from the source object it receives
+     * these values as parameters.
+     *
+     * @param src source object name
+     * @param src_ioctx ioctx for the source object
+     * @param src_version current version of the source object
+     * @param truncate_seq truncate sequence for the destination object
+     * @param truncate_size truncate size for the destination object
+     * @param src_fadvise_flags the fadvise flags for source object
+     */
+    void copy_from2(const std::string& src, const IoCtx& src_ioctx,
+                   uint64_t src_version, uint32_t truncate_seq,
+                   uint64_t truncate_size, uint32_t src_fadvise_flags);
+
     /**
      * undirty an object
      *
index 7b5c0f68e437b28836a8e97662c922896a481587..3ce889ce3f44705cbb9de7398d85e8802951a295 100644 (file)
@@ -587,6 +587,20 @@ void librados::ObjectWriteOperation::copy_from(const std::string& src,
               src_ioctx.io_ctx_impl->oloc, src_version, 0, src_fadvise_flags);
 }
 
+void librados::ObjectWriteOperation::copy_from2(const std::string& src,
+                                               const IoCtx& src_ioctx,
+                                               uint64_t src_version,
+                                               uint32_t truncate_seq,
+                                               uint64_t truncate_size,
+                                               uint32_t src_fadvise_flags)
+{
+  ceph_assert(impl);
+  ::ObjectOperation *o = &impl->o;
+  o->copy_from2(object_t(src), src_ioctx.io_ctx_impl->snap_seq,
+               src_ioctx.io_ctx_impl->oloc, src_version, 0,
+               truncate_seq, truncate_size, src_fadvise_flags);
+}
+
 void librados::ObjectWriteOperation::undirty()
 {
   ceph_assert(impl);
index f669ce31c5fbf6c23c899bca45f0751af0088ecf..6a79fb6438d4f1b1e918e2dd1ca5d32f5f0a3016 100644 (file)
@@ -1105,6 +1105,21 @@ struct ObjectOperation {
     encode(src, osd_op.indata);
     encode(src_oloc, osd_op.indata);
   }
+  void copy_from2(object_t src, snapid_t snapid, object_locator_t src_oloc,
+                version_t src_version, unsigned flags,
+                uint32_t truncate_seq, uint64_t truncate_size,
+                unsigned src_fadvise_flags) {
+    using ceph::encode;
+    OSDOp& osd_op = add_op(CEPH_OSD_OP_COPY_FROM2);
+    osd_op.op.copy_from.snapid = snapid;
+    osd_op.op.copy_from.src_version = src_version;
+    osd_op.op.copy_from.flags = flags;
+    osd_op.op.copy_from.src_fadvise_flags = src_fadvise_flags;
+    encode(src, osd_op.indata);
+    encode(src_oloc, osd_op.indata);
+    encode(truncate_seq, osd_op.indata);
+    encode(truncate_size, osd_op.indata);
+  }
 
   /**
    * writeback content to backing tier