From: Kefu Chai Date: Mon, 11 Mar 2019 13:40:42 +0000 (+0800) Subject: crimson/os: implement CyanStore::get_attr() X-Git-Tag: v15.0.0~199^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ada3dd05b588fdaf0723a40c3a7e1834c5f8fe48;p=ceph.git crimson/os: implement CyanStore::get_attr() it is used for retrieving object_info and snapset attributes. Signed-off-by: Kefu Chai --- diff --git a/src/crimson/os/cyan_store.cc b/src/crimson/os/cyan_store.cc index adebd41e74bd..d395c8631090 100644 --- a/src/crimson/os/cyan_store.cc +++ b/src/crimson/os/cyan_store.cc @@ -152,6 +152,36 @@ seastar::future CyanStore::read(CollectionRef c, return seastar::make_ready_future(std::move(bl)); } +seastar::future CyanStore::get_attr(CollectionRef c, + const ghobject_t& oid, + std::string_view name) +{ + logger().info("{} {} {}", + __func__, c->cid, oid); + auto o = c->get_object(oid); + if (!o) { + throw std::runtime_error(fmt::format("object does not exist: {}", oid)); + } + if (auto found = o->xattr.find(name); found != o->xattr.end()) { + return seastar::make_ready_future(found->second); + } else { + throw std::runtime_error(fmt::format("attr does not exist: {}/{}", + oid, name)); + } +} + +seastar::future CyanStore::get_attrs(CollectionRef c, + const ghobject_t& oid) +{ + logger().info("{} {} {}", + __func__, c->cid, oid); + auto o = c->get_object(oid); + if (!o) { + throw std::runtime_error(fmt::format("object does not exist: {}", oid)); + } + return seastar::make_ready_future(o->xattr); +} + seastar::future CyanStore::omap_get_values(CollectionRef c, const ghobject_t& oid, diff --git a/src/crimson/os/cyan_store.h b/src/crimson/os/cyan_store.h index 0b7f3d871e45..2a9c58989f72 100644 --- a/src/crimson/os/cyan_store.h +++ b/src/crimson/os/cyan_store.h @@ -37,6 +37,11 @@ public: uint64_t offset, size_t len, uint32_t op_flags = 0); + seastar::future get_attr(CollectionRef c, + const ghobject_t& oid, + std::string_view name); + using attrs_t = std::map>; + seastar::future get_attrs(CollectionRef c, const ghobject_t& oid); using omap_values_t = std::map>; seastar::future omap_get_values( CollectionRef c,