]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/recovery_backend: scan_for_backfill to use obc_manager
authorMatan Breizman <mbreizma@redhat.com>
Mon, 27 Jan 2025 10:43:47 +0000 (10:43 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 10 Mar 2025 12:48:11 +0000 (12:48 +0000)
let obc_loader get the relevant obc and avoid duplicating the
loading logic.

Fixes: https://tracker.ceph.com/issues/69154
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/osd/recovery_backend.cc

index 9798ef3c9ecc1e067800d3cd3599b507560ba0a7..2d5ab2b89ae32cd8c5205c7e0eca2b864cd7cb59 100644 (file)
@@ -232,30 +232,24 @@ RecoveryBackend::scan_for_backfill(
   auto&& [objects, next] = co_await backend->list_objects(start, max);
   co_await interruptor::parallel_for_each(objects, [FNAME, this, version_map]
     (const hobject_t& object) -> interruptible_future<> {
-    crimson::osd::ObjectContextRef obc;
-    if (pg.is_primary()) {
-      obc = pg.obc_registry.maybe_get_cached_obc(object);
-    }
-    if (obc) {
-      if (obc->obs.exists) {
-        DEBUGDPP("found (primary): {}  {}",
-                 pg, object, obc->obs.oi.version);
-        version_map->emplace(object, obc->obs.oi.version);
-      } else {
-        // if the object does not exist here, it must have been removed
-        // between the collection_list_partial and here.  This can happen
-        // for the first item in the range, which is usually last_backfill.
-      }
+    DEBUGDPP("querying obj:{}", pg, object);
+    auto obc_manager = pg.obc_loader.get_obc_manager(object);
+    co_await pg.obc_loader.load_and_lock(
+      obc_manager, RWState::RWREAD
+    ).handle_error_interruptible(
+      crimson::ct_error::assert_all("unexpected error")
+    );
+
+    if (obc_manager.get_obc()->obs.exists) {
+      auto version = obc_manager.get_obc()->obs.oi.version;
+      version_map->emplace(object, version);
+      DEBUGDPP("found: {}  {}", pg,
+               object, version);
       co_return;
     } else {
-      auto md =
-        co_await backend->load_metadata(object).handle_error_interruptible(
-        PGBackend::load_metadata_ertr::assert_all{});
-      if (md->os.exists) {
-        DEBUGDPP("found: {}  {}", pg,
-                 object, md->os.oi.version);
-        version_map->emplace(object, md->os.oi.version);
-      }
+      // if the object does not exist here, it must have been removed
+      // between the collection_list_partial and here.  This can happen
+      // for the first item in the range, which is usually last_backfill.
       co_return;
     }
   });