{
auto& layout = bucket_info.layout;
auto prev = layout; // make a copy for cleanup
+ const auto next_log_gen = layout.logs.back().gen + 1;
+
+ bool remove_index = true;
+
+ if (!store->svc()->zone->need_to_log_data()) {
+ // if we're not syncing data, we can drop any existing logs
+ layout.logs.clear();
+ } else {
+ const auto last_index_gen = prev.current_index.gen;
+ for (const auto& log : layout.logs) {
+ if (log.layout.type == rgw::BucketLogType::InIndex &&
+ log.layout.in_index.gen == last_index_gen) {
+ // we're storing logs in this index gen, we can't delete it yet
+ remove_index = false;
+ break;
+ }
+ }
+ }
// use the new index layout as current
ceph_assert(layout.target_index);
layout.target_index = std::nullopt;
layout.resharding = rgw::BucketReshardState::None;
// add the in-index log layout
- const auto next_log_gen = layout.logs.back().gen + 1;
layout.logs.push_back(log_layout_from_index(next_log_gen, layout.current_index));
int ret = fault.check("commit_target_layout");
}
// on success, delete index shard objects from the old layout (ignore errors)
- store->svc()->bi->clean_index(bucket_info, prev.current_index);
-
+ if (remove_index) {
+ store->svc()->bi->clean_index(bucket_info, prev.current_index);
+ }
return 0;
} // commit_reshard