]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/pg: rebuild missing set when a new interval is created 49540/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Thu, 22 Dec 2022 08:36:41 +0000 (16:36 +0800)
committerXuehan Xu <xxhdx1985126@gmail.com>
Fri, 6 Jan 2023 07:42:20 +0000 (07:42 +0000)
Fixes: https://tracker.ceph.com/issues/58339
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/osd/pg.h
src/osd/PGLog.cc
src/osd/PGLog.h

index 11e5a4ae8adbe46460cce52d0d3a7d7e83c51ab4..a1b0a70ccd1abbd510b223748f878ce00fd94f5c 100644 (file)
@@ -415,7 +415,10 @@ public:
   }
 
   void rebuild_missing_set_with_deletes(PGLog &pglog) final {
-    ceph_assert(0 == "Impossible for crimson");
+    pglog.rebuild_missing_set_with_deletes_crimson(
+      shard_services.get_store(),
+      coll_ref,
+      peering_state.get_info()).get();
   }
 
   PerfCounters &get_peering_perf() final {
index 1d00e3a8a3127ad43df743ca6a184e9833e7f4d5..fdb3715e91333e4b5f097969d82c8f71e5d263f9 100644 (file)
@@ -1206,4 +1206,85 @@ seastar::future<> PGLog::read_log_and_missing_crimson(
   });
 }
 
+seastar::future<> PGLog::rebuild_missing_set_with_deletes_crimson(
+  crimson::os::FuturizedStore &store,
+  crimson::os::CollectionRef ch,
+  const pg_info_t &info)
+{
+  // save entries not generated from the current log (e.g. added due
+  // to repair, EIO handling, or divergent_priors).
+  map<hobject_t, pg_missing_item> extra_missing;
+  for (const auto& p : missing.get_items()) {
+    if (!log.logged_object(p.first)) {
+      ldpp_dout(this, 20) << __func__ << " extra missing entry: " << p.first
+              << " " << p.second << dendl;
+      extra_missing[p.first] = p.second;
+    }
+  }
+  missing.clear();
+
+  // go through the log and add items that are not present or older
+  // versions on disk, just as if we were reading the log + metadata
+  // off disk originally
+  return seastar::do_with(
+    set<hobject_t>(),
+    log.log.rbegin(),
+    [this, &store, ch, &info](auto &did, auto &it) {
+    return seastar::repeat([this, &store, ch, &info, &it, &did] {
+      if (it == log.log.rend()) {
+       return seastar::make_ready_future<seastar::stop_iteration>(
+         seastar::stop_iteration::yes);
+      }
+      auto &log_entry = *it;
+      it++;
+      if (log_entry.version <= info.last_complete)
+       return seastar::make_ready_future<seastar::stop_iteration>(
+         seastar::stop_iteration::yes);
+      if (log_entry.soid > info.last_backfill ||
+         log_entry.is_error() ||
+         did.find(log_entry.soid) != did.end())
+       return seastar::make_ready_future<seastar::stop_iteration>(
+         seastar::stop_iteration::no);
+      did.insert(log_entry.soid);
+      return store.get_attr(
+       ch,
+       ghobject_t(log_entry.soid, ghobject_t::NO_GEN, info.pgid.shard),
+       OI_ATTR
+      ).safe_then([this, &log_entry](auto bv) {
+       object_info_t oi(bv);
+       ldpp_dout(this, 20)
+         << "rebuild_missing_set_with_deletes_crimson found obj "
+         << log_entry.soid
+         << " version = " << oi.version << dendl;
+       if (oi.version < log_entry.version) {
+         ldpp_dout(this, 20)
+           << "rebuild_missing_set_with_deletes_crimson missing obj "
+           << log_entry.soid
+           << " for version = " << log_entry.version << dendl;
+         missing.add(
+           log_entry.soid,
+           log_entry.version,
+           oi.version,
+           log_entry.is_delete());
+       }
+      },
+      crimson::ct_error::enoent::handle([this, &log_entry] {
+       ldpp_dout(this, 20)
+         << "rebuild_missing_set_with_deletes_crimson missing object "
+         << log_entry.soid << dendl;
+       missing.add(
+         log_entry.soid,
+         log_entry.version,
+         eversion_t(),
+         log_entry.is_delete());
+      }),
+      crimson::ct_error::enodata::handle([] { ceph_abort("unexpected enodata"); })
+      ).then([] {
+       return seastar::stop_iteration::no;
+      });
+    });
+  }).then([this] {
+    set_missing_may_contain_deletes();
+  });
+}
 #endif
index 5fe78e7845c23fbfeac112b22cf80069070dc7ed..10016752bf7c1c6dc538ca43ffc767fd14cfb8eb 100644 (file)
@@ -943,6 +943,13 @@ public:
                                        ObjectStore::CollectionHandle& ch,
                                        const pg_info_t &info);
 
+#ifdef WITH_SEASTAR
+  seastar::future<> rebuild_missing_set_with_deletes_crimson(
+    crimson::os::FuturizedStore &store,
+    crimson::os::CollectionRef ch,
+    const pg_info_t &info);
+#endif
+
 protected:
   static void split_by_object(
     mempool::osd_pglog::list<pg_log_entry_t> &entries,