Skip to content

Commit

Permalink
crimson/os/seastore: return ghobject_t::max as the end when list_objects
Browse files Browse the repository at this point in the history
reaches the end of the listing

Signed-off-by: Xuehan Xu <[email protected]>
  • Loading branch information
xxhdx1985126 committed Oct 10, 2023
1 parent 224a4ff commit e989538
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/crimson/os/seastore/seastore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ SeaStore::Shard::list_objects(CollectionRef ch,
using list_iertr = OnodeManager::list_onodes_iertr;
using repeat_ret = list_iertr::future<seastar::stop_iteration>;
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()) {
Expand All @@ -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(
Expand All @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions src/crimson/os/seastore/seastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::tuple<std::vector<ghobject_t>, ghobject_t>> list_objects(
CollectionRef c,
const ghobject_t& start,
Expand Down
2 changes: 1 addition & 1 deletion src/test/crimson/seastore/test_seastore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit e989538

Please sign in to comment.