From: Mykola Golub Date: Mon, 9 Nov 2020 20:19:48 +0000 (+0000) Subject: os/bluestore: fix "end reached" check in collection_list_legacy X-Git-Tag: v15.2.9~102^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F38098%2Fhead;p=ceph.git os/bluestore: fix "end reached" check in collection_list_legacy 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 (cherry picked from commit e63489f249f9ba3bc9cb1806568f860effd8a0b6) --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index c322e56f63d6..62f2def0e80e 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -698,6 +698,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; }; @@ -741,6 +751,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; @@ -816,6 +835,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 m_chunk; std::map::iterator m_chunk_iter; @@ -10776,14 +10807,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; } @@ -10799,7 +10830,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; }