From b214f42d1f1c5ecf728581438ef1087d1aba72d0 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 2 Sep 2021 14:46:26 +0000 Subject: [PATCH] src/crimson: Add various missing ops to cyanstore Signed-off-by: Mark Nelson --- src/crimson/os/cyanstore/cyan_store.cc | 45 +++++++++++++++++++++++--- src/crimson/os/cyanstore/cyan_store.h | 3 +- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/crimson/os/cyanstore/cyan_store.cc b/src/crimson/os/cyanstore/cyan_store.cc index a7c89d2d2af..cafcf8559ee 100644 --- a/src/crimson/os/cyanstore/cyan_store.cc +++ b/src/crimson/os/cyanstore/cyan_store.cc @@ -377,8 +377,17 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch, ceph::bufferlist bl; i.decode_bl(bl); std::map to_set; - to_set.emplace(name, std::move(bl)); - r = _setattrs(cid, oid, to_set); + to_set.emplace(name, std::move(bl)); + r = _setattrs(cid, oid, std::move(to_set)); + } + break; + case Transaction::OP_SETATTRS: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + std::map aset; + i.decode_attrset(aset); + r = _setattrs(cid, oid, std::move(aset)); } break; case Transaction::OP_RMATTR: @@ -389,12 +398,24 @@ seastar::future<> CyanStore::do_transaction(CollectionRef ch, r = _rm_attr(cid, oid, name); } break; + case Transaction::OP_RMATTRS: + { + coll_t cid = i.get_cid(op->cid); + ghobject_t oid = i.get_oid(op->oid); + r = _rm_attrs(cid, oid); + } + break; case Transaction::OP_MKCOLL: { coll_t cid = i.get_cid(op->cid); r = _create_collection(cid, op->split_bits); } break; + case Transaction::OP_SETALLOCHINT: + { + r = 0; + } + break; case Transaction::OP_OMAP_CLEAR: { coll_t cid = i.get_cid(op->cid); @@ -660,7 +681,7 @@ int CyanStore::_truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size } int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid, - std::map& aset) + std::map&& aset) { logger().debug("{} cid={} oid={}", __func__, cid, oid); @@ -671,8 +692,7 @@ int CyanStore::_setattrs(const coll_t& cid, const ghobject_t& oid, ObjectRef o = c->get_object(oid); if (!o) return -ENOENT; - for (std::map::const_iterator p = aset.begin(); - p != aset.end(); ++p) + for (auto p = aset.begin(); p != aset.end(); ++p) o->xattr[p->first] = p->second; return 0; } @@ -697,6 +717,21 @@ int CyanStore::_rm_attr(const coll_t& cid, const ghobject_t& oid, return 0; } +int CyanStore::_rm_attrs(const coll_t& cid, const ghobject_t& oid) +{ + logger().debug("{} cid={} oid={}", __func__, cid, oid); + auto c = _get_collection(cid); + if (!c) { + return -ENOENT; + } + ObjectRef o = c->get_object(oid); + if (!o) { + return -ENOENT; + } + o->xattr.clear(); + return 0; +} + int CyanStore::_create_collection(const coll_t& cid, int bits) { auto result = coll_map.try_emplace(cid); diff --git a/src/crimson/os/cyanstore/cyan_store.h b/src/crimson/os/cyanstore/cyan_store.h index 38f8f6d5ec9..8c182d0dd8a 100644 --- a/src/crimson/os/cyanstore/cyan_store.h +++ b/src/crimson/os/cyanstore/cyan_store.h @@ -172,9 +172,10 @@ private: const std::string &last); int _truncate(const coll_t& cid, const ghobject_t& oid, uint64_t size); int _setattrs(const coll_t& cid, const ghobject_t& oid, - std::map& aset); + std::map&& aset); int _rm_attr(const coll_t& cid, const ghobject_t& oid, std::string_view name); + int _rm_attrs(const coll_t& cid, const ghobject_t& oid); int _create_collection(const coll_t& cid, int bits); boost::intrusive_ptr _get_collection(const coll_t& cid); };