]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Fix cursor handling in DataLogBackends::list
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 2 Feb 2021 19:09:52 +0000 (14:09 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 29 Mar 2021 16:25:58 +0000 (12:25 -0400)
Don't assume that the lowest generation not greater than the requested
generation actually is the requested generation.

(Also don't hold the lock after we get a backend.)

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_datalog.cc

index a8d1cd1684193404cd246ad753f6af9f11f18ae8..2a7033eee6b9ee049cb6940df0e42cdd131f7401 100644 (file)
@@ -705,7 +705,8 @@ int DataLogBackends::list(int shard, int max_entries,
                          std::optional<std::string_view> marker,
                          std::string* out_marker, bool* truncated)
 {
-  auto [gen_id, cursor] = cursorgeno(marker);
+  const auto [start_id, start_cursor] = cursorgeno(marker);
+  auto gen_id = start_id;
   std::string out_cursor;
   while (max_entries > 0) {
     std::vector<rgw_data_change_log_entry> gentries;
@@ -713,7 +714,10 @@ int DataLogBackends::list(int shard, int max_entries,
     auto i = lower_bound(gen_id);
     if (i == end()) return 0;
     auto be = i->second;
-    auto r = be->list(shard, max_entries, gentries, cursor,
+    l.unlock();
+    gen_id = be->gen_id;
+    auto r = be->list(shard, max_entries, gentries,
+                     gen_id == start_id ? start_cursor : std::string{},
                      &out_cursor, truncated);
     if (r < 0)
       return r;
@@ -724,10 +728,13 @@ int DataLogBackends::list(int shard, int max_entries,
     for (auto& g : gentries) {
       g.log_id = gencursor(gen_id, g.log_id);
     }
-    max_entries -= gentries.size();
+    if (gentries.size() > max_entries)
+      max_entries = 0;
+    else
+      max_entries -= gentries.size();
+
     std::move(gentries.begin(), gentries.end(),
              std::back_inserter(entries));
-    cursor = {};
     ++gen_id;
   }
   return 0;