From: sjust@redhat.com Date: Wed, 27 Mar 2019 18:31:11 +0000 (-0700) Subject: osd/: move should_restart_peering to PeeringState X-Git-Tag: v15.1.0~2774^2~69 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1d08ac58aa46bc80051663c4fbe465436c13ae39;p=ceph-ci.git osd/: move should_restart_peering to PeeringState Signed-off-by: sjust@redhat.com --- diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 4c30caead3a..5af3b642b74 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -5735,37 +5735,6 @@ void PG::fulfill_query(const MQuery& query, PeeringCtx *rctx) } } -bool PG::should_restart_peering( - int newupprimary, - int newactingprimary, - const vector& newup, - const vector& newacting, - OSDMapRef lastmap, - OSDMapRef osdmap) -{ - if (PastIntervals::is_new_interval( - primary.osd, - newactingprimary, - acting, - newacting, - up_primary.osd, - newupprimary, - up, - newup, - osdmap.get(), - lastmap.get(), - info.pgid.pgid)) { - dout(20) << "new interval newup " << newup - << " newacting " << newacting << dendl; - return true; - } - if (!lastmap->is_up(osd->whoami) && osdmap->is_up(osd->whoami)) { - dout(10) << __func__ << " osd transitioned from down -> up" << dendl; - return true; - } - return false; -} - bool PG::old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch) { if (last_peering_reset > reply_epoch || diff --git a/src/osd/PG.h b/src/osd/PG.h index a47d3db8ecd..167471c98e8 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1679,14 +1679,6 @@ protected: void fulfill_log(pg_shard_t from, const pg_query_t &query, epoch_t query_epoch); void fulfill_query(const MQuery& q, PeeringCtx *rctx); - bool should_restart_peering( - int newupprimary, - int newactingprimary, - const vector& newup, - const vector& newacting, - OSDMapRef lastmap, - OSDMapRef osdmap); - // OpRequest queueing bool can_discard_op(OpRequestRef& op); bool can_discard_scan(OpRequestRef op); diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 9ee0924e90c..eab00391a48 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -421,6 +421,36 @@ void PeeringState::check_full_transition(OSDMapRef lastmap, OSDMapRef osdmap) } } +bool PG::should_restart_peering( + int newupprimary, + int newactingprimary, + const vector& newup, + const vector& newacting, + OSDMapRef lastmap, + OSDMapRef osdmap) +{ + if (PastIntervals::is_new_interval( + primary.osd, + newactingprimary, + acting, + newacting, + up_primary.osd, + newupprimary, + up, + newup, + osdmap.get(), + lastmap.get(), + info.pgid.pgid)) { + dout(20) << "new interval newup " << newup + << " newacting " << newacting << dendl; + return true; + } + if (!lastmap->is_up(osd->whoami) && osdmap->is_up(osd->whoami)) { + dout(10) << __func__ << " osd transitioned from down -> up" << dendl; + return true; + } + return false; +} /*------------ Peering State Machine----------------*/ #undef dout_prefix @@ -502,7 +532,7 @@ boost::statechart::result PeeringState::Started::react(const AdvMap& advmap) PG *pg = context< PeeringMachine >().pg; psdout(10) << "Started advmap" << dendl; ps->check_full_transition(advmap.lastmap, advmap.osdmap); - if (pg->should_restart_peering( + if (ps->should_restart_peering( advmap.up_primary, advmap.acting_primary, advmap.newup, @@ -563,7 +593,7 @@ boost::statechart::result PeeringState::Reset::react(const AdvMap& advmap) ps->check_full_transition(advmap.lastmap, advmap.osdmap); - if (pg->should_restart_peering( + if (ps->should_restart_peering( advmap.up_primary, advmap.acting_primary, advmap.newup, @@ -1785,7 +1815,7 @@ PeeringState::Active::Active(my_context ctx) boost::statechart::result PeeringState::Active::react(const AdvMap& advmap) { PG *pg = context< PeeringMachine >().pg; - if (pg->should_restart_peering( + if (ps->should_restart_peering( advmap.up_primary, advmap.acting_primary, advmap.newup, diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 9d8473057de..8d39db3a9a7 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -1161,6 +1161,14 @@ public: void check_recovery_sources(const OSDMapRef& map); void set_last_peering_reset(); void check_full_transition(OSDMapRef lastmap, OSDMapRef osdmap); + bool should_restart_peering( + int newupprimary, + int newactingprimary, + const vector& newup, + const vector& newacting, + OSDMapRef lastmap, + OSDMapRef osdmap); + public: PeeringState( diff --git a/src/test/osd/types.cc b/src/test/osd/types.cc index 6aba395c56a..550d97c3b74 100644 --- a/src/test/osd/types.cc +++ b/src/test/osd/types.cc @@ -190,7 +190,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); ASSERT_TRUE(past_intervals.empty()); } @@ -219,7 +219,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); old_primary = new_primary; } @@ -248,7 +248,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); } @@ -275,7 +275,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); } @@ -309,7 +309,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); } @@ -343,7 +343,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pg_t(pg_num - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -378,7 +378,7 @@ for (unsigned i = 0; i < 4; ++i) { lastmap, // reverse order! osdmap, pg_t(pg_num - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -411,7 +411,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pg_t(pg_num - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -444,7 +444,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pg_t(pg_num / 2 - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -477,7 +477,7 @@ for (unsigned i = 0; i < 4; ++i) { lastmap, // reverse order! osdmap, pg_t(pg_num / 2 - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -510,7 +510,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pg_t(pg_num / 2 - 1, pool_id), - recoverable.get(), + *recoverable, &past_intervals)); } @@ -544,7 +544,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals)); } @@ -573,7 +573,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals, &out)); ASSERT_NE(string::npos, out.str().find("acting set is too small")); @@ -623,7 +623,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals, &out)); ASSERT_NE(string::npos, out.str().find("acting set is too small")); @@ -656,7 +656,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals, &out)); ASSERT_NE(string::npos, out.str().find("includes interval")); @@ -699,7 +699,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals, &out)); ASSERT_NE(string::npos, out.str().find("presumed to have been rw")); @@ -746,7 +746,7 @@ for (unsigned i = 0; i < 4; ++i) { osdmap, lastmap, pgid, - recoverable.get(), + *recoverable, &past_intervals, &out)); ASSERT_NE(string::npos, out.str().find("does not include interval"));