From: Adam C. Emerson Date: Wed, 10 Feb 2021 22:09:02 +0000 (-0500) Subject: rgw: Try to prune empties even if no empties found X-Git-Tag: v17.1.0~2399^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9bd9b7659fdb7a1a01d5e1523f0d461dbf5eaafe;p=ceph.git rgw: Try to prune empties even if no empties found Since we won't actually delete empties until much later. Signed-off-by: Adam C. Emerson --- diff --git a/src/rgw/rgw_datalog.cc b/src/rgw/rgw_datalog.cc index 2716a9c2bee3a..0f2be19d06600 100644 --- a/src/rgw/rgw_datalog.cc +++ b/src/rgw/rgw_datalog.cc @@ -882,38 +882,36 @@ void DataLogBackends::trim_entries(int shard_id, std::string_view marker, } int DataLogBackends::trim_generations(std::optional& through) { - if (size() == 1) { - return 0; - } - - std::vector 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 candidates; + { + std::scoped_lock l(m); + auto e = cend() - 1; + for (auto i = cbegin(); i < e; ++i) { + candidates.push_back(i->second); + } } - } - std::optional 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 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));