From 84d71e6a10b02591b5d5e126b346771871eb1575 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 4 Oct 2017 15:28:26 -0500 Subject: [PATCH] osd/PG: separate event for RemoteReservationCanceled Right now we transparently map a RemoteReservationRejected into a *Canceled event because this what peers send over the wire. Even once new peers start sending and explicit CANCEL, old peers will still do so, so we'll maintain this mapping for a while. Signed-off-by: Sage Weil --- src/osd/PG.cc | 14 ++++++++++++-- src/osd/PG.h | 21 +++++++++++++++++---- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 5d1bc8eaa8a..51937233363 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -6470,7 +6470,7 @@ PG::RecoveryState::RepWaitRecoveryReserved::react(const RemoteRecoveryReserved & boost::statechart::result PG::RecoveryState::RepWaitRecoveryReserved::react( - const RemoteReservationRejected &evt) + const RemoteReservationCanceled &evt) { PG *pg = context< RecoveryMachine >().pg; pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); @@ -6568,7 +6568,17 @@ PG::RecoveryState::RepWaitBackfillReserved::react( } boost::statechart::result -PG::RecoveryState::RepWaitBackfillReserved::react(const RemoteReservationRejected &evt) +PG::RecoveryState::RepWaitBackfillReserved::react( + const RemoteReservationRejected &evt) +{ + PG *pg = context< RecoveryMachine >().pg; + pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); + return transit(); +} + +boost::statechart::result +PG::RecoveryState::RepWaitBackfillReserved::react( + const RemoteReservationCanceled &evt) { PG *pg = context< RecoveryMachine >().pg; pg->osd->remote_reserver.cancel_reservation(pg->info.pgid); diff --git a/src/osd/PG.h b/src/osd/PG.h index dd02579f2ef..16d81cb5118 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1584,6 +1584,7 @@ public: TrivialEvent(RemoteBackfillReserved) TrivialEvent(RejectRemoteReservation) TrivialEvent(RemoteReservationRejected) + TrivialEvent(RemoteReservationCanceled) TrivialEvent(RequestBackfill) TrivialEvent(RequestRecovery) TrivialEvent(RecoveryDone) @@ -1981,7 +1982,9 @@ public: struct RepRecovering : boost::statechart::state< RepRecovering, ReplicaActive >, NamedState { typedef boost::mpl::list< boost::statechart::transition< RecoveryDone, RepNotRecovering >, + // for compat with old peers boost::statechart::transition< RemoteReservationRejected, RepNotRecovering >, + boost::statechart::transition< RemoteReservationCanceled, RepNotRecovering >, boost::statechart::custom_reaction< BackfillTooFull > > reactions; explicit RepRecovering(my_context ctx); @@ -1993,24 +1996,33 @@ public: typedef boost::mpl::list< boost::statechart::custom_reaction< RemoteBackfillReserved >, boost::statechart::custom_reaction< RejectRemoteReservation >, - boost::statechart::custom_reaction< RemoteReservationRejected > + boost::statechart::custom_reaction< RemoteReservationRejected >, + boost::statechart::custom_reaction< RemoteReservationCanceled > > reactions; explicit RepWaitBackfillReserved(my_context ctx); void exit(); boost::statechart::result react(const RemoteBackfillReserved &evt); boost::statechart::result react(const RejectRemoteReservation &evt); boost::statechart::result react(const RemoteReservationRejected &evt); + boost::statechart::result react(const RemoteReservationCanceled &evt); }; struct RepWaitRecoveryReserved : boost::statechart::state< RepWaitRecoveryReserved, ReplicaActive >, NamedState { typedef boost::mpl::list< boost::statechart::custom_reaction< RemoteRecoveryReserved >, - boost::statechart::custom_reaction< RemoteReservationRejected > + // for compat with old peers + boost::statechart::custom_reaction< RemoteReservationRejected >, + boost::statechart::custom_reaction< RemoteReservationCanceled > > reactions; explicit RepWaitRecoveryReserved(my_context ctx); void exit(); boost::statechart::result react(const RemoteRecoveryReserved &evt); - boost::statechart::result react(const RemoteReservationRejected &evt); + boost::statechart::result react(const RemoteReservationRejected &evt) { + // for compat with old peers + post_event(RemoteReservationCanceled()); + return discard_event(); + } + boost::statechart::result react(const RemoteReservationCanceled &evt); }; struct RepNotRecovering : boost::statechart::state< RepNotRecovering, ReplicaActive>, NamedState { @@ -2018,7 +2030,8 @@ public: boost::statechart::custom_reaction< RequestBackfillPrio >, boost::statechart::transition< RequestRecovery, RepWaitRecoveryReserved >, boost::statechart::custom_reaction< RejectRemoteReservation >, - boost::statechart::transition< RemoteReservationRejected, RepNotRecovering >, // if primary is preempted or cancels + boost::statechart::transition< RemoteReservationRejected, RepNotRecovering >, + boost::statechart::transition< RemoteReservationCanceled, RepNotRecovering >, boost::statechart::transition< RecoveryDone, RepNotRecovering > // for compat with pre-reservation peers > reactions; explicit RepNotRecovering(my_context ctx); -- 2.39.5