From df1f1a4b6a89e1c8804dc2789e2f2b2b4af11a8f Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 20 Aug 2020 21:06:24 +0800 Subject: [PATCH] crimson/os/cyanstore: handle OP_OMAP_CLEAR Signed-off-by: Kefu Chai --- src/crimson/os/cyanstore/cyan_store.cc | 26 ++++++++++++++++++++++++++ src/crimson/os/cyanstore/cyan_store.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index 57363b1d81abb..3d362dd675a84 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -376,6 +376,13 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch, r = _create_collection(cid, op->split_bits); } break; + case Transaction::OP_OMAP_CLEAR: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + r = _omap_clear(cid, oid); + } + break; case Transaction::OP_OMAP_SETKEYS: { coll_t cid = i.get_cid(op->cid); @@ -505,6 +512,25 @@ int CyanStore::_write(const coll_t& cid, const ghobject_t& oid, return 0; } +int CyanStore::_omap_clear( + const coll_t& cid, + const ghobject_t& oid) +{ + logger().debug("{} {} {}", __func__, cid, oid); + + auto c = _get_collection(cid); + if (!c) { + return -ENOENT; + } + ObjectRef o = c->get_object(oid); + if (!o) { + return -ENOENT; + } + o->omap.clear(); + o->omap_header.clear(); + return 0; +} + int CyanStore::_omap_set_values( 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 877400272b56c..71569d8154e11 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -151,6 +151,9 @@ 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 _omap_clear( + const coll_t& cid, + const ghobject_t& oid); int _omap_set_values( const coll_t& cid, const ghobject_t& oid, -- 2.39.5