]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: add BlueStore::omap_get_values()
authorChunmei Liu <chunmei.liu@intel.com>
Wed, 22 Jan 2020 07:03:56 +0000 (23:03 -0800)
committerChunmei Liu <chunmei.liu@intel.com>
Fri, 28 Feb 2020 03:57:13 +0000 (19:57 -0800)
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 <chunmei.liu@intel.com>
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 4abd333e16f182047defa022f0a75b6e1c062041..c51cd24e50992d799e9e302477e761d77b3afa67 100644 (file)
@@ -705,6 +705,15 @@ public:
     std::map<std::string, ceph::buffer::list> *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<std::string> &start_after,     ///< [in] Keys to get
+    std::map<std::string, ceph::buffer::list> *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
index 6d2088d8a4fa59bc51ed58ea37ba30cd16d04679..081b1944d5506f805c2974fea4c5b14253015db9 100644 (file)
@@ -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<string> &start_after,     ///< [in] Keys to get
+  map<string, bufferlist> *output ///< [out] Returned keys and values
+  )
+{
+  Collection *c = static_cast<Collection *>(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
index 544034a04bcc30529a1f166b220d43a0bb7ce458..ec79184b48e0ec29d060bbe0a203803b9d173a7f 100644 (file)
@@ -2771,6 +2771,15 @@ public:
     map<string, bufferlist> *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<string> &start_after,     ///< [in] Keys to get
+    map<string, bufferlist> *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