From e1261d8a29b56cdcec52041b95e6b27080e39482 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 2 Mar 2019 12:55:01 +0800 Subject: [PATCH] crimson/osd: keep track of last_peering_reset last_peering_reset is used to track the epoch when the most recent peering started. it is used to tell if a message is targeting a changed PG. the sender of a peering message will attach it. and the recipient will check it against its own last_peering_reset. for instance, if a message claims that that its map epoch is 16, while our last_peering_reset is 18, we will consider this message stale, and probably drop it. Signed-off-by: Kefu Chai --- src/crimson/osd/pg.cc | 10 ++++++++++ src/crimson/osd/pg.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/src/crimson/osd/pg.cc b/src/crimson/osd/pg.cc index b2a566a39f4..8d3f973f44e 100644 --- a/src/crimson/osd/pg.cc +++ b/src/crimson/osd/pg.cc @@ -148,3 +148,13 @@ bool PG::is_primary() const { return whoami == primary; } + +epoch_t PG::get_last_peering_reset() const +{ + return last_peering_reset; +} + +void PG::update_last_peering_reset() +{ + last_peering_reset = get_osdmap_epoch(); +} diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 72bb7a155a1..413f0e93d51 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -47,6 +47,8 @@ public: pg_shard_t get_primary() const; bool is_primary() const; pg_shard_t get_whoami() const; + epoch_t get_last_peering_reset() const; + void update_last_peering_reset(); seastar::future<> read_state(ceph::os::CyanStore* store); @@ -59,6 +61,8 @@ private: const spg_t pgid; pg_shard_t whoami; pg_pool_t pool; + + epoch_t last_peering_reset = 0; //< pg state pg_info_t info; //< last written info, for fast info persistence -- 2.39.5