From: Matan Breizman Date: Tue, 3 May 2022 14:15:57 +0000 (+0000) Subject: crimson/os: Add OP_CLONE to cyanstore X-Git-Tag: v18.0.0~938^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=54b8d69232cd3d661a64eb4457dfe15c51c75e45;p=ceph-ci.git crimson/os: Add OP_CLONE to cyanstore Signed-off-by: Matan Breizman --- diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index d58d55a2255..d0674766276 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -392,6 +392,14 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch, r = _truncate(cid, oid, off); } break; + case Transaction::OP_CLONE: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + ghobject_t noid = i.get_oid(op->dest_oid); + r = _clone(cid, oid, noid); + } + break; case Transaction::OP_SETATTR: { coll_t cid = i.get_cid(op->cid); @@ -703,6 +711,30 @@ int CyanStore::_truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size return r; } +int CyanStore::_clone(const coll_t& cid, const ghobject_t& oid, + const ghobject_t& noid) +{ + logger().debug("{} cid={} oid={} noid={}", + __func__, cid, oid, noid); + auto c = _get_collection(cid); + if (!c) + return -ENOENT; + + ObjectRef oo = c->get_object(oid); + if (!oo) + return -ENOENT; + if (local_conf()->memstore_debug_omit_block_device_write) + return 0; + ObjectRef no = c->get_or_create_object(noid); + used_bytes += ((ssize_t)oo->get_size() - (ssize_t)no->get_size()); + no->clone(oo.get(), 0, oo->get_size(), 0); + + no->omap_header = oo->omap_header; + no->omap = oo->omap; + no->xattr = oo->xattr; + return 0; +} + int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid, std::map&& aset) { diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index edba296ac19..d3ae138d47b 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -171,6 +171,8 @@ private: const std::string &first, const std::string &last); int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size); + int _clone(const coll_t& cid, const ghobject_t& oid, + const ghobject_t& noid); int _setattrs(const coll_t& cid, const ghobject_t& oid, std::map&& aset); int _rm_attr(const coll_t& cid, const ghobject_t& oid,