Skip to content

Commit e989538

Browse files
committed
crimson/os/seastore: return ghobject_t::max as the end when list_objects
reaches the end of the listing Signed-off-by: Xuehan Xu <[email protected]>
1 parent 224a4ff commit e989538

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/crimson/os/seastore/seastore.cc

+9-2
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ SeaStore::Shard::list_objects(CollectionRef ch,
695695
using list_iertr = OnodeManager::list_onodes_iertr;
696696
using repeat_ret = list_iertr::future<seastar::stop_iteration>;
697697
return trans_intr::repeat(
698-
[this, &t, &ret, &limit,
698+
[this, &t, &ret, &limit, end,
699699
filter, ranges = get_ranges(ch, start, end, filter)
700700
]() mutable -> repeat_ret {
701701
if (limit == 0 || ranges.empty()) {
@@ -711,7 +711,8 @@ SeaStore::Shard::list_objects(CollectionRef ch,
711711
DEBUGT("pstart {}, pend {}, limit {}", t, pstart, pend, limit);
712712
return onode_manager->list_onodes(
713713
t, pstart, pend, limit
714-
).si_then([&limit, &ret, pend](auto &&_ret) mutable {
714+
).si_then([&limit, &ret, pend, &t, last=ranges.empty(), end]
715+
(auto &&_ret) mutable {
715716
auto &next_objects = std::get<0>(_ret);
716717
auto &ret_objects = std::get<0>(ret);
717718
ret_objects.insert(
@@ -721,6 +722,12 @@ SeaStore::Shard::list_objects(CollectionRef ch,
721722
std::get<1>(ret) = std::get<1>(_ret);
722723
assert(limit >= next_objects.size());
723724
limit -= next_objects.size();
725+
LOG_PREFIX(SeaStore::list_objects);
726+
DEBUGT("got {} objects, left limit {}",
727+
t, next_objects.size(), limit);
728+
if (last && std::get<1>(ret) == pend) {
729+
std::get<1>(ret) = end;
730+
}
724731
assert(limit == 0 ||
725732
std::get<1>(ret) == pend ||
726733
std::get<1>(ret) == ghobject_t::get_max());

src/crimson/os/seastore/seastore.h

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ class SeaStore final : public FuturizedStore {
144144
CollectionRef c,
145145
const ghobject_t& oid) final;
146146

147+
/// std::get<1>(ret) returns end if and only if the listing has listed all
148+
/// the items within the range, otherwise it returns the next key to be listed.
147149
seastar::future<std::tuple<std::vector<ghobject_t>, ghobject_t>> list_objects(
148150
CollectionRef c,
149151
const ghobject_t& start,

src/test/crimson/seastore/test_seastore.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ struct seastore_test_t :
602602
EXPECT_GE(next, right_bound);
603603
} else {
604604
// next <= *correct_end since *correct_end is the next object to list
605-
EXPECT_LE(next, *correct_end);
605+
EXPECT_LE(listed.back(), *correct_end);
606606
// next > *(correct_end - 1) since we already listed it
607607
EXPECT_GT(next, *(correct_end - 1));
608608
}

0 commit comments

Comments
 (0)