Merge pull request #46127 from Matan-B/wip-matanb-cyan-clone

crimson/os: Add OP_CLONE to cyanstore

Reviewed-by: Samuel Just <sjust@redhat.com>
This commit is contained in:
Samuel Just 2022-05-09 12:53:30 -07:00 committed by GitHub
commit 396ff7b702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 0 deletions

View File

@ -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<std::string,bufferlist>&& aset)
{

View File

@ -169,6 +169,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<std::string,bufferlist>&& aset);
int _rm_attr(const coll_t& cid, const ghobject_t& oid,