]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: eliminate get_omap_keys method 65763/head
authorGarry Drankovich <garry.drankovich@clyso.com>
Thu, 2 Oct 2025 20:15:10 +0000 (23:15 +0300)
committerGarry Drankovich <garry.drankovich@clyso.com>
Mon, 6 Oct 2025 19:57:10 +0000 (22:57 +0300)
One can use omap_iterate instead.

The primary goal of this change is to cleanup ObjectStore API

Signed-off-by: Garry Drankovich <garry.drankovich@clyso.com>
src/os/FuseStore.cc
src/os/ObjectStore.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/kstore/KStore.cc
src/os/kstore/KStore.h
src/os/memstore/MemStore.cc
src/os/memstore/MemStore.h
src/test/objectstore/ObjectStoreImitator.h
src/test/objectstore/store_test.cc

index a1a9aa6d007cd3996199bd165c0938b2fe6367ca..35cb6a78388a33500c1a06243d87b43a6e41a82a 100644 (file)
@@ -538,7 +538,14 @@ static int os_readdir(const char *path,
   case FN_OBJECT_OMAP:
     {
       set<string> keys;
-      fs->store->omap_get_keys(ch, oid, &keys);
+      fs->store->omap_iterate(
+       ch, oid,
+       ObjectStore::omap_iter_seek_t::min_lower_bound(),
+       [&keys]
+       (std::string_view key, std::string_view) mutable {
+         keys.emplace(key);
+         return ObjectStore::omap_iter_ret_t::NEXT;
+       });
       unsigned skip = offset;
       for (auto k : keys) {
        if (skip) {
index 13e9b577e3ad69d0c3169f250bb88647b95bc53d..dcd02a899aa1f61f20a94c98609b8a314ae4c133 100644 (file)
@@ -721,13 +721,6 @@ public:
     bool allow_eio = false ///< [in] don't assert on eio
     ) = 0;
 
-  /// Get keys defined on oid
-  virtual int omap_get_keys(
-    CollectionHandle &c,   ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    std::set<std::string> *keys      ///< [out] Keys defined on oid
-    ) = 0;
-
   /// Get key values
   virtual int omap_get_values(
     CollectionHandle &c,         ///< [in] Collection containing oid
index 8533d6761190454e9c353bed030211938eb2dd72..eb1b5370defeab6b7f07ed60b97272b28125d7fe 100644 (file)
@@ -13731,59 +13731,6 @@ int BlueStore::omap_get_header(
   return r;
 }
 
-int BlueStore::omap_get_keys(
-  CollectionHandle &c_,              ///< [in] Collection containing oid
-  const ghobject_t &oid, ///< [in] Object containing omap
-  set<string> *keys      ///< [out] Keys defined on oid
-  )
-{
-  Collection *c = static_cast<Collection *>(c_.get());
-  dout(15) << __func__ << " " << c->get_cid() << " oid " << oid << dendl;
-  if (!c->exists)
-    return -ENOENT;
-  auto start1 = mono_clock::now();
-  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();
-  {
-    const string& prefix = o->get_omap_prefix();
-    string head, tail;
-    o->get_omap_key(string(), &head);
-    o->get_omap_tail(&tail);
-    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, KeyValueDB::IteratorBounds{head, tail});
-    it->lower_bound(head);
-    while (it->valid()) {
-      if (it->key() >= tail) {
-       dout(30) << __func__ << "  reached tail" << dendl;
-       break;
-      }
-      string user_key;
-      o->decode_omap_key(it->key(), &user_key);
-      dout(20) << __func__ << "  got " << pretty_binary_string(it->key())
-              << " -> " << user_key << dendl;
-      keys->insert(user_key);
-      it->next();
-    }
-  }
- out:
-  c->store->log_latency(
-    __func__,
-    l_bluestore_omap_get_keys_lat,
-    mono_clock::now() - start1,
-    c->store->cct->_conf->bluestore_log_omap_iterator_age);
-
-  dout(10) << __func__ << " " << c->get_cid() << " oid " << oid << " = " << r
-          << dendl;
-  return r;
-}
-
 int BlueStore::omap_get_values(
   CollectionHandle &c_,        ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
index 693d4499a30ea0815a0825f8d50ee2bc7997ae2e..4f1aad83ff37a558991d98c365a09529ce02b0f3 100644 (file)
@@ -3367,13 +3367,6 @@ public:
     bool allow_eio = false ///< [in] don't assert on eio
     ) override;
 
-  /// Get keys defined on oid
-  int omap_get_keys(
-    CollectionHandle &c,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    std::set<std::string> *keys      ///< [out] Keys defined on oid
-    ) override;
-
   /// Get key values
   int omap_get_values(
     CollectionHandle &c,         ///< [in] Collection containing oid
index 12cf6f6aef5f33d4100916396239a9eb7436712a..f8f96f5cb1560c5a43b062587ee6a2fc50becdb1 100644 (file)
@@ -1645,49 +1645,6 @@ int KStore::omap_get_header(
   return r;
 }
 
-int KStore::omap_get_keys(
-  CollectionHandle& ch,              ///< [in] Collection containing oid
-  const ghobject_t &oid, ///< [in] Object containing omap
-  set<string> *keys      ///< [out] Keys defined on oid
-  )
-{
-  dout(15) << __func__ << " " << ch->cid << " oid " << oid << dendl;
-  Collection *c = static_cast<Collection*>(ch.get());
-  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.omap_head)
-    goto out;
-  o->flush();
-  {
-    KeyValueDB::Iterator it = db->get_iterator(PREFIX_OMAP);
-    string head, tail;
-    get_omap_key(o->onode.omap_head, string(), &head);
-    get_omap_tail(o->onode.omap_head, &tail);
-    it->lower_bound(head);
-    while (it->valid()) {
-      if (it->key() >= tail) {
-       dout(30) << __func__ << "  reached tail" << dendl;
-       break;
-      }
-      string user_key;
-      decode_omap_key(it->key(), &user_key);
-      dout(30) << __func__ << "  got " << pretty_binary_string(it->key())
-              << " -> " << user_key << dendl;
-      ceph_assert(it->key() < tail);
-      keys->insert(user_key);
-      it->next();
-    }
-  }
- out:
-  dout(10) << __func__ << " " << ch->cid << " oid " << oid << " = " << r << dendl;
-  return r;
-}
-
 int KStore::omap_get_values(
   CollectionHandle& ch,                    ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
index 81b9a0c45a2b80806ebca3275cacce34b83a679a..17573a29b197a4a15e33e517aa26210f73c68b19 100644 (file)
@@ -502,14 +502,6 @@ public:
     bool allow_eio = false ///< [in] don't assert on eio
     ) override;
 
-  using ObjectStore::omap_get_keys;
-  /// Get keys defined on oid
-  int omap_get_keys(
-    CollectionHandle& c,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    std::set<std::string> *keys      ///< [out] Keys defined on oid
-    ) override;
-
   using ObjectStore::omap_get_values;
   /// Get key values
   int omap_get_values(
index f1278a0f025b0058eee1cd57b1b94e3a8cb34802..8a44b7f01c732a0cbffb0ac5dbecb972fd998b56 100644 (file)
@@ -497,23 +497,6 @@ int MemStore::omap_get_header(
   return 0;
 }
 
-int MemStore::omap_get_keys(
-  CollectionHandle& ch,              ///< [in] Collection containing oid
-  const ghobject_t &oid, ///< [in] Object containing omap
-  std::set<std::string> *keys      ///< [out] Keys defined on oid
-  )
-{
-  dout(10) << __func__ << " " << ch->cid << " " << oid << dendl;
-  Collection *c = static_cast<Collection*>(ch.get());
-  ObjectRef o = c->get_object(oid);
-  if (!o)
-    return -ENOENT;
-  std::lock_guard lock{o->omap_mutex};
-  for (auto p = o->omap.begin(); p != o->omap.end(); ++p)
-    keys->insert(p->first);
-  return 0;
-}
-
 int MemStore::omap_get_values(
   CollectionHandle& ch,                    ///< [in] Collection containing oid
   const ghobject_t &oid,       ///< [in] Object containing omap
index 9f9e401c25641b96f2af7b4e5d88e784a69a0836..d81556166500923958d9c106ae37887f8eb37e84 100644 (file)
@@ -346,14 +346,6 @@ public:
     bool allow_eio = false ///< [in] don't assert on eio
     ) override;
 
-  using ObjectStore::omap_get_keys;
-  /// Get keys defined on oid
-  int omap_get_keys(
-    CollectionHandle& c,              ///< [in] Collection containing oid
-    const ghobject_t &oid, ///< [in] Object containing omap
-    std::set<std::string> *keys      ///< [out] Keys defined on oid
-    ) override;
-
   using ObjectStore::omap_get_values;
   /// Get key values
   int omap_get_values(
index e1fcf7ec9335576254764590068e8af16962982a..0810c426588ddbc83d5362eded345f55c3c5a04e 100644 (file)
@@ -319,12 +319,6 @@ public:
                       ) override {
     return 0;
   }
-  int omap_get_keys(CollectionHandle &c,   ///< [in] Collection containing oid
-                    const ghobject_t &oid, ///< [in] Object containing omap
-                    std::set<std::string> *keys ///< [out] Keys defined on oid
-                    ) override {
-    return 0;
-  }
   int omap_get_values(CollectionHandle &c,   ///< [in] Collection containing oid
                       const ghobject_t &oid, ///< [in] Object containing omap
                       const std::set<std::string> &keys, ///< [in] Keys to get
index eb101fd803745c7b48747516ed185cadf614f168..29cbd98ff538dd8ff8b6af2d13874a18e9f94459 100644 (file)
@@ -6139,10 +6139,6 @@ TEST_P(StoreTest, OMapTest) {
     ASSERT_EQ(cur_attrs.size(), size_t(1));
     ASSERT_TRUE(bl_eq(bl1, bl3));
  
-    set<string> keys;
-    r = store->omap_get_keys(ch, hoid, &keys);
-    ASSERT_EQ(r, 0);
-    ASSERT_EQ(keys.size(), size_t(1));
   }
 
   // test omap_clear, omap_rmkey_range