From 48ef9f72249e7618737a848d0c97bd2666eb0fcd Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Mon, 11 May 2020 22:03:54 +0200 Subject: [PATCH] crimson/osd: wire-up pg scanning on replicas. Signed-off-by: Radoslaw Zarzynski --- src/crimson/osd/backfill_state.h | 4 ++++ src/crimson/osd/pg.h | 2 +- src/crimson/osd/pg_recovery.cc | 14 +++++++++++++- src/crimson/osd/pg_recovery_listener.h | 1 + src/crimson/osd/recovery_backend.cc | 18 +++++++++++++++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/crimson/osd/backfill_state.h b/src/crimson/osd/backfill_state.h index fea0f4ba93052..58b307b32fb68 100644 --- a/src/crimson/osd/backfill_state.h +++ b/src/crimson/osd/backfill_state.h @@ -36,6 +36,10 @@ struct BackfillState { struct ReplicaScanned : sc::event { pg_shard_t from; BackfillInterval result; + ReplicaScanned(pg_shard_t from, BackfillInterval&& result) + : from(std::move(from)), + result(std::move(result)) { + } }; struct ObjectPushed : sc::event { diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 647f989bc2da3..30b025d35d7bc 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -592,7 +592,7 @@ public: const pg_missing_tracker_t& get_local_missing() const { return peering_state.get_pg_log().get_missing(); } - epoch_t get_last_peering_reset() const { + epoch_t get_last_peering_reset() const final { return peering_state.get_last_peering_reset(); } const set &get_acting_recovery_backfill() const { diff --git a/src/crimson/osd/pg_recovery.cc b/src/crimson/osd/pg_recovery.cc index c5670ed353719..d9328c5a4ca68 100644 --- a/src/crimson/osd/pg_recovery.cc +++ b/src/crimson/osd/pg_recovery.cc @@ -417,7 +417,19 @@ void PGRecovery::request_replica_scan( const hobject_t& begin, const hobject_t& end) { - ceph_abort_msg("Not implemented"); + logger().debug("{}: target.osd={}", __func__, target.osd); + auto msg = make_message( + MOSDPGScan::OP_SCAN_GET_DIGEST, + pg->get_pg_whoami(), + pg->get_osdmap_epoch(), + pg->get_last_peering_reset(), + spg_t(pg->get_pgid().pgid, target.shard), + begin, + end); + std::ignore = pg->get_shard_services().send_to_osd( + target.osd, + std::move(msg), + pg->get_osdmap_epoch()); } void PGRecovery::request_primary_scan( diff --git a/src/crimson/osd/pg_recovery_listener.h b/src/crimson/osd/pg_recovery_listener.h index f9df92a4aafb4..3c8d3b66a8528 100644 --- a/src/crimson/osd/pg_recovery_listener.h +++ b/src/crimson/osd/pg_recovery_listener.h @@ -32,5 +32,6 @@ public: virtual bool is_unreadable_object(const hobject_t&, eversion_t* v = 0) const = 0; virtual bool has_reset_since(epoch_t) const = 0; virtual std::vector get_replica_recovery_order() const = 0; + virtual epoch_t get_last_peering_reset() const = 0; virtual seastar::future<> stop() = 0; }; diff --git a/src/crimson/osd/recovery_backend.cc b/src/crimson/osd/recovery_backend.cc index 64f0c735c3496..e81e38668ccff 100644 --- a/src/crimson/osd/recovery_backend.cc +++ b/src/crimson/osd/recovery_backend.cc @@ -156,7 +156,23 @@ seastar::future<> RecoveryBackend::handle_scan_digest( MOSDPGScan& m) { logger().debug("{}", __func__); - ceph_assert("Not implemented" == nullptr); + // Check that from is in backfill_targets vector + ceph_assert(pg.get_peering_state().is_backfill_target(m.from)); + + BackfillInterval bi; + bi.begin = m.begin; + bi.end = m.end; + { + auto p = m.get_data().cbegin(); + // take care to preserve ordering! + bi.clear_objects(); + ::decode_noclear(bi.objects, p); + } + shard_services.start_operation( + static_cast(&pg), + shard_services, + pg.get_osdmap_epoch(), + crimson::osd::BackfillState::ReplicaScanned{ m.from, std::move(bi) }); return seastar::now(); } -- 2.39.5