From 9cf183ed46ad1594dcb5e0dce5387627d35ecde2 Mon Sep 17 00:00:00 2001 From: Chunmei Liu Date: Tue, 21 Jan 2020 23:03:56 -0800 Subject: [PATCH] os/bluestore: add BlueStore::omap_get_values() used by crimson::alienstore. as crimson is not using `ObjectStore::get_omap_iterator()` for implementing CEPH_OSD_OP_OMAPGETVALS op. instead, it's using a paged variant of `ObjectStore::omap_get_values()`, which only exists in CyanStore before this change. Signed-off-by: Chunmei Liu --- src/os/ObjectStore.h | 9 ++++++++ src/os/bluestore/BlueStore.cc | 42 +++++++++++++++++++++++++++++++++++ src/os/bluestore/BlueStore.h | 9 ++++++++ 3 files changed, 60 insertions(+) diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 4abd333e16f18..c51cd24e50992 100644 --- a/src/os/ObjectStore.h +++ b/src/os/ObjectStore.h @@ -705,6 +705,15 @@ public: std::map *out ///< [out] Returned keys and values ) = 0; +#ifdef WITH_SEASTAR + virtual int omap_get_values( + CollectionHandle &c, ///< [in] Collection containing oid + const ghobject_t &oid, ///< [in] Object containing omap + const std::optional &start_after, ///< [in] Keys to get + std::map *out ///< [out] Returned keys and values + ) = 0; +#endif + /// Filters keys into out which are defined on oid virtual int omap_check_keys( CollectionHandle &c, ///< [in] Collection containing oid diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 6d2088d8a4fa5..081b1944d5506 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -10718,6 +10718,48 @@ int BlueStore::omap_get_values( return r; } +#ifdef WITH_SEASTAR +int BlueStore::omap_get_values( + CollectionHandle &c_, ///< [in] Collection containing oid + const ghobject_t &oid, ///< [in] Object containing omap + const std::optional &start_after, ///< [in] Keys to get + map *output ///< [out] Returned keys and values + ) +{ + Collection *c = static_cast(c_.get()); + dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl; + if (!c->exists) + return -ENOENT; + std::shared_lock l(c->lock); + int r = 0; + OnodeRef o = c->get_onode(oid, false); + if (!o || !o->exists) { + r = -ENOENT; + goto out; + } + if (!o->onode.has_omap()) { + goto out; + } + o->flush(); + { + ObjectMap::ObjectMapIterator iter = get_omap_iterator(c_, oid); + if (!iter) { + r = -ENOENT; + goto out; + } + iter->upper_bound(*start_after); + for (; iter->valid(); iter->next()) { + output->insert(make_pair(iter->key(), iter->value())); + } + } + +out: + dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r + << dendl; + return r; +} +#endif + int BlueStore::omap_check_keys( CollectionHandle &c_, ///< [in] Collection containing oid const ghobject_t &oid, ///< [in] Object containing omap diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 544034a04bcc3..ec79184b48e0e 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -2771,6 +2771,15 @@ public: map *out ///< [out] Returned keys and values ) override; +#ifdef WITH_SEASTAR + int omap_get_values( + CollectionHandle &c, ///< [in] Collection containing oid + const ghobject_t &oid, ///< [in] Object containing omap + const std::optional &start_after, ///< [in] Keys to get + map *out ///< [out] Returned keys and values + ) override; +#endif + /// Filters keys into out which are defined on oid int omap_check_keys( CollectionHandle &c, ///< [in] Collection containing oid -- 2.39.5