diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index 1535ea84d78b..8c2338ff034c 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -695,7 +695,7 @@ SeaStore::Shard::list_objects(CollectionRef ch, using list_iertr = OnodeManager::list_onodes_iertr; using repeat_ret = list_iertr::future; return trans_intr::repeat( - [this, &t, &ret, &limit, + [this, &t, &ret, &limit, end, filter, ranges = get_ranges(ch, start, end, filter) ]() mutable -> repeat_ret { if (limit == 0 || ranges.empty()) { @@ -711,7 +711,8 @@ SeaStore::Shard::list_objects(CollectionRef ch, DEBUGT("pstart {}, pend {}, limit {}", t, pstart, pend, limit); return onode_manager->list_onodes( t, pstart, pend, limit - ).si_then([&limit, &ret, pend](auto &&_ret) mutable { + ).si_then([&limit, &ret, pend, &t, last=ranges.empty(), end] + (auto &&_ret) mutable { auto &next_objects = std::get<0>(_ret); auto &ret_objects = std::get<0>(ret); ret_objects.insert( @@ -721,6 +722,12 @@ SeaStore::Shard::list_objects(CollectionRef ch, std::get<1>(ret) = std::get<1>(_ret); assert(limit >= next_objects.size()); limit -= next_objects.size(); + LOG_PREFIX(SeaStore::list_objects); + DEBUGT("got {} objects, left limit {}", + t, next_objects.size(), limit); + if (last && std::get<1>(ret) == pend) { + std::get<1>(ret) = end; + } assert(limit == 0 || std::get<1>(ret) == pend || std::get<1>(ret) == ghobject_t::get_max()); diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index 876fadca8c78..70863e16b935 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -144,6 +144,8 @@ class SeaStore final : public FuturizedStore { CollectionRef c, const ghobject_t& oid) final; + /// std::get<1>(ret) returns end if and only if the listing has listed all + /// the items within the range, otherwise it returns the next key to be listed. seastar::future, ghobject_t>> list_objects( CollectionRef c, const ghobject_t& start, diff --git a/src/test/crimson/seastore/test_seastore.cc b/src/test/crimson/seastore/test_seastore.cc index d2f57a385f13..e71fffa928f3 100644 --- a/src/test/crimson/seastore/test_seastore.cc +++ b/src/test/crimson/seastore/test_seastore.cc @@ -602,7 +602,7 @@ struct seastore_test_t : EXPECT_GE(next, right_bound); } else { // next <= *correct_end since *correct_end is the next object to list - EXPECT_LE(next, *correct_end); + EXPECT_LE(listed.back(), *correct_end); // next > *(correct_end - 1) since we already listed it EXPECT_GT(next, *(correct_end - 1)); }