]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore: return ghobject_t::max as the end when list_objects 53062/head
authorXuehan Xu <xuxuehan@qianxin.com>
Mon, 21 Aug 2023 08:33:16 +0000 (16:33 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Tue, 10 Oct 2023 09:33:39 +0000 (17:33 +0800)
reaches the end of the listing

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h
src/test/crimson/seastore/test_seastore.cc

index 1535ea84d78b06051a7420e812ce8e531938e618..8c2338ff034ce73e8448517caa797690b7086ec7 100644 (file)
@@ -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()) {
@@ -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());
index 876fadca8c78753511cf99ee4d9e90c7eddb2e89..70863e16b935c93452b19448b9312bd072967ad3 100644 (file)
@@ -144,6 +144,8 @@ public:
       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,
index d2f57a385f13a5a96bfdd28c2485ccda1df51a38..e71fffa928f3b5e6e20c082551ccf7a2e59f91d2 100644 (file)
@@ -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));
        }