]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: reshard preserves old index in multisite wip-rgw-multisite-reshard-prebase-2021-05-12
authorCasey Bodley <cbodley@redhat.com>
Fri, 26 Mar 2021 15:00:57 +0000 (11:00 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 30 Apr 2021 18:46:55 +0000 (14:46 -0400)
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 9281f6d5054c35e41fc6740b659f54d0c5d3164a..bdd4c7143c98629b0e06287a5381988bcce73c3e 100644 (file)
@@ -441,6 +441,24 @@ static int commit_reshard(rgw::sal::RGWRadosStore* 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);
@@ -448,7 +466,6 @@ static int commit_reshard(rgw::sal::RGWRadosStore* 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");
@@ -474,8 +491,9 @@ static int commit_reshard(rgw::sal::RGWRadosStore* store,
   }
 
   // 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