From fe31c31ed3ad26017d6dedf01db0043f228134a2 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 3 Apr 2019 16:56:47 -0700 Subject: [PATCH] osd/: Move init into PeeringState Signed-off-by: Samuel Just --- src/osd/PG.cc | 36 +++------------------------------ src/osd/PeeringState.cc | 45 +++++++++++++++++++++++++++++++++++++++++ src/osd/PeeringState.h | 9 +++++++++ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index c72ab4710a4..039ec2199f9 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -906,39 +906,9 @@ void PG::init( bool backfill, ObjectStore::Transaction *t) { - dout(10) << "init role " << role << " up " << newup << " acting " << newacting - << " history " << history - << " past_intervals " << pi - << dendl; - - recovery_state.set_role(role); - recovery_state.init_primary_up_acting( - newup, - newacting, - new_up_primary, - new_acting_primary); - - info.history = history; - past_intervals = pi; - - info.stats.up = up; - info.stats.up_primary = new_up_primary; - info.stats.acting = acting; - info.stats.acting_primary = new_acting_primary; - info.stats.mapping_epoch = info.history.same_interval_since; - - if (backfill) { - dout(10) << __func__ << ": Setting backfill" << dendl; - info.set_last_backfill(hobject_t()); - info.last_complete = info.last_update; - pg_log.mark_log_for_rewrite(); - } - - recovery_state.on_new_interval(); - - dirty_info = true; - dirty_big_info = true; - write_if_dirty(*t); + recovery_state.init( + role, newup, new_up_primary, newacting, + new_acting_primary, history, pi, backfill, t); } void PG::shutdown() diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 0554136f60d..6561d5298e2 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -3289,6 +3289,51 @@ std::optional PeeringState::prepare_stats_for_publish( } } +void PeeringState::init( + int role, + const vector& newup, int new_up_primary, + const vector& newacting, int new_acting_primary, + const pg_history_t& history, + const PastIntervals& pi, + bool backfill, + ObjectStore::Transaction *t) +{ + psdout(10) << "init role " << role << " up " + << newup << " acting " << newacting + << " history " << history + << " past_intervals " << pi + << dendl; + + set_role(role); + init_primary_up_acting( + newup, + newacting, + new_up_primary, + new_acting_primary); + + info.history = history; + past_intervals = pi; + + info.stats.up = up; + info.stats.up_primary = new_up_primary; + info.stats.acting = acting; + info.stats.acting_primary = new_acting_primary; + info.stats.mapping_epoch = info.history.same_interval_since; + + if (backfill) { + psdout(10) << __func__ << ": Setting backfill" << dendl; + info.set_last_backfill(hobject_t()); + info.last_complete = info.last_update; + pg_log.mark_log_for_rewrite(); + } + + on_new_interval(); + + dirty_info = true; + dirty_big_info = true; + write_if_dirty(*t); +} + /*------------ Peering State Machine----------------*/ #undef dout_prefix #define dout_prefix (context< PeeringMachine >().dpp->gen_prefix(*_dout) \ diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 1ea87b6bf03..d6123bfda39 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -1452,6 +1452,15 @@ public: end_handle(); } + void init( + int role, + const vector& newup, int new_up_primary, + const vector& newacting, int new_acting_primary, + const pg_history_t& history, + const PastIntervals& pi, + bool backfill, + ObjectStore::Transaction *t); + void start_split_stats( const set& childpgs, vector *out); void finish_split_stats( -- 2.39.5