]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Try to prune empties even if no empties found
authorAdam C. Emerson <aemerson@redhat.com>
Wed, 10 Feb 2021 22:09:02 +0000 (17:09 -0500)
committerAdam C. Emerson <aemerson@redhat.com>
Mon, 29 Mar 2021 16:25:58 +0000 (12:25 -0400)
Since we won't actually delete empties until much later.

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

index 2716a9c2bee3a75d84a46e67130527da4d6ba656..0f2be19d066003f11dfc16c9b4a5d2985eded689 100644 (file)
@@ -882,38 +882,36 @@ void DataLogBackends::trim_entries(int shard_id, std::string_view marker,
 }
 
 int DataLogBackends::trim_generations(std::optional<uint64_t>& through) {
-  if (size() == 1) {
-    return 0;
-  }
-
-  std::vector<mapped_type> candidates;
-  {
-    std::scoped_lock l(m);
-    auto e = cend() - 1;
-    for (auto i = cbegin(); i < e; ++i) {
-      candidates.push_back(i->second);
+  if (size() != 1) {
+    std::vector<mapped_type> candidates;
+    {
+      std::scoped_lock l(m);
+      auto e = cend() - 1;
+      for (auto i = cbegin(); i < e; ++i) {
+       candidates.push_back(i->second);
+      }
     }
-  }
 
-  std::optional<uint64_t> highest;
-  for (auto& be : candidates) {
-    auto r = be->is_empty();
-    if (r < 0) {
-      return r;
-    } else if (r == 1) {
-      highest = be->gen_id;
-    } else {
-      break;
+    std::optional<uint64_t> highest;
+    for (auto& be : candidates) {
+      auto r = be->is_empty();
+      if (r < 0) {
+       return r;
+      } else if (r == 1) {
+       highest = be->gen_id;
+      } else {
+       break;
+      }
     }
-  }
 
-  through = highest;
-  if (!highest) {
-    return 0;
-  }
-  auto ec = empty_to(*highest, null_yield);
-  if (ec) {
-    return ceph::from_error_code(ec);
+    through = highest;
+    if (!highest) {
+      return 0;
+    }
+    auto ec = empty_to(*highest, null_yield);
+    if (ec) {
+      return ceph::from_error_code(ec);
+    }
   }
 
   return ceph::from_error_code(remove_empty(null_yield));