From: Luis Henriques Date: Tue, 26 Nov 2019 11:54:51 +0000 (+0000) Subject: librados, osd: add copy_from2 to librados and Objecter X-Git-Tag: v15.1.0~335^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=92c6610b2632447123bac207bd8d28d435fba4f1;p=ceph-ci.git librados, osd: add copy_from2 to librados and Objecter This commit simply adds this new version of the copy_from operation to librados and to Objecter. Signed-off-by: Luis Henriques --- diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 2cda4d84756..ca520f510c6 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -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 * diff --git a/src/librados/librados_cxx.cc b/src/librados/librados_cxx.cc index 7b5c0f68e43..3ce889ce3f4 100644 --- a/src/librados/librados_cxx.cc +++ b/src/librados/librados_cxx.cc @@ -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); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index f669ce31c5f..6a79fb6438d 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -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