]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: reshard preserves old index in multisite
authorCasey Bodley <cbodley@redhat.com>
Fri, 26 Mar 2021 15:00:57 +0000 (11:00 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 1 Feb 2022 17:45:04 +0000 (12:45 -0500)
if the old index is still referenced by an InIndex log layout, we can't
call clean_index() to remove the index objects yet. log trimming will do
that later, once the bilogs are no longer needed

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_reshard.cc

index b7a013df5021be60af5ece7e88203876166964f7..89f80e119eb4b1364e6851518521d11d79a9addc 100644 (file)
@@ -446,6 +446,24 @@ static int commit_reshard(rgw::sal::RadosStore* store,
 {
   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);
@@ -453,7 +471,6 @@ static int commit_reshard(rgw::sal::RadosStore* store,
   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");
@@ -479,8 +496,9 @@ static int commit_reshard(rgw::sal::RadosStore* store,
   }
 
   // on success, delete index shard objects from the old layout (ignore errors)
-  store->svc()->bi->clean_index(dpp, bucket_info, prev.current_index);
-
+  if (remove_index) {
+    store->svc()->bi->clean_index(dpp, bucket_info, prev.current_index);
+  }
   return 0;
 } // commit_reshard