From c5f7963e6bd2245c09af626ea47a4631df2dfa63 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 21 Aug 2020 13:28:15 +0800 Subject: [PATCH] crimson/os/cyanstore: handle OP_ZERO Signed-off-by: Kefu Chai --- src/crimson/os/cyanstore/cyan_store.cc | 20 ++++++++++++++++++++ src/crimson/os/cyanstore/cyan_store.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index 3d362dd675a84..ec1bc5ce4bf31 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -350,6 +350,15 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch, r = _write(cid, oid, off, len, bl, fadvise_flags); } break; + case Transaction::OP_ZERO: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + uint64_t off = op->off; + uint64_t len = op->len; + r = _zero(cid, oid, off, len); + } + break; case Transaction::OP_TRUNCATE: { coll_t cid = i.get_cid(op->cid); @@ -512,6 +521,17 @@ int CyanStore::_write(const coll_t& cid, const ghobject_t& oid, return 0; } +int CyanStore::_zero(const coll_t& cid, const ghobject_t& oid, + uint64_t offset, size_t len) +{ + logger().debug("{} {} {} {} ~ {}", + __func__, cid, oid, offset, len); + + ceph::buffer::list bl; + bl.append_zero(len); + return _write(cid, oid, offset, len, bl, 0); +} + int CyanStore::_omap_clear( const coll_t& cid, const ghobject_t& oid) diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 71569d8154e11..86678042f305f 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -151,6 +151,8 @@ private: int _write(const coll_t& cid, const ghobject_t& oid, uint64_t offset, size_t len, const ceph::bufferlist& bl, uint32_t fadvise_flags); + int _zero(const coll_t& cid, const ghobject_t& oid, + uint64_t offset, size_t len); int _omap_clear( const coll_t& cid, const ghobject_t& oid); -- 2.39.5