]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix "end reached" check in collection_list_legacy 37062/head
authorMykola Golub <mgolub@suse.com>
Mon, 9 Nov 2020 20:19:48 +0000 (20:19 +0000)
committerMykola Golub <mgolub@suse.com>
Tue, 17 Nov 2020 15:01:47 +0000 (17:01 +0200)
To preserve the old bluestore behavior it should compare the
current object with the end using bluestore keys, not oids.

Fixes: https://tracker.ceph.com/issues/48153
Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit e63489f249f9ba3bc9cb1806568f860effd8a0b6)

src/os/bluestore/BlueStore.cc

index accc4388e51dc7883e1d6754e93188c81edf48e9..1cc3cd3c276aeb567bfe65a66c203662111c6e50 100644 (file)
@@ -692,6 +692,16 @@ public:
   virtual void upper_bound(const ghobject_t &oid) = 0;
   virtual void next() = 0;
 
+  virtual int cmp(const ghobject_t &oid) const = 0;
+
+  bool is_ge(const ghobject_t &oid) const {
+    return cmp(oid) >= 0;
+  }
+
+  bool is_lt(const ghobject_t &oid) const {
+    return cmp(oid) < 0;
+  }
+
 protected:
   KeyValueDB::Iterator m_it;
 };
@@ -735,6 +745,15 @@ public:
     get_oid();
   }
 
+  int cmp(const ghobject_t &oid) const override {
+    ceph_assert(valid());
+
+    string key;
+    get_object_key(m_cct, oid, &key);
+
+    return m_it->key().compare(key);
+  }
+
 private:
   CephContext *m_cct;
   ghobject_t m_oid;
@@ -810,6 +829,18 @@ public:
     }
   }
 
+  int cmp(const ghobject_t &oid) const override {
+    ceph_assert(valid());
+
+    if (this->oid() < oid) {
+      return -1;
+    }
+    if (this->oid() > oid) {
+      return 1;
+    }
+    return 0;
+  }
+
 private:
   std::map<ghobject_t, std::string> m_chunk;
   std::map<ghobject_t, std::string>::iterator m_chunk_iter;
@@ -8000,14 +8031,14 @@ int BlueStore::_collection_list(
   }
   dout(20) << __func__ << " pend " << pend << dendl;
   while (true) {
-    if (!it->valid() || it->oid() >= pend) {
+    if (!it->valid() || it->is_ge(pend)) {
       if (!it->valid())
        dout(20) << __func__ << " iterator not valid (end of db?)" << dendl;
       else
        dout(20) << __func__ << " oid " << it->oid() << " >= " << pend << dendl;
       if (temp) {
        if (end.hobj.is_temp()) {
-          if (it->valid() && it->oid() < coll_range_temp_end) {
+          if (it->valid() && it->is_lt(coll_range_temp_end)) {
             *pnext = it->oid();
             set_next = true;
           }
@@ -8023,7 +8054,7 @@ int BlueStore::_collection_list(
        dout(30) << __func__ << " pend " << pend << dendl;
        continue;
       }
-      if (it->valid() && it->oid() < coll_range_end) {
+      if (it->valid() && it->is_lt(coll_range_end)) {
         *pnext = it->oid();
         set_next = true;
       }