From: Chunmei Liu Date: Wed, 22 Jan 2020 07:03:56 +0000 (-0800) Subject: os/bluestore: add BlueStore::omap_get_values() X-Git-Tag: v15.1.1~182^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9cf183ed46ad1594dcb5e0dce5387627d35ecde2;p=ceph-ci.git 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 --- diff --git a/src/os/ObjectStore.h b/src/os/ObjectStore.h index 4abd333e16f..c51cd24e509 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 6d2088d8a4f..081b1944d55 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 544034a04bc..ec79184b48e 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