@@ -767,6 +767,12 @@ ReplicaActive::~ReplicaActive()
767767 clear_remote_reservation (false );
768768}
769769
770+ void ReplicaActive::exit ()
771+ {
772+ dout (20 ) << " ReplicaActive::exit()" << dendl;
773+ }
774+
775+
770776/*
771777 * Note: we are expected to be in the initial internal state (Idle) when
772778 * receiving any registration request. ReplicaActiveOp, our other internal
@@ -943,84 +949,32 @@ ReplicaIdle::ReplicaIdle(my_context ctx)
943949 dout (10 ) << " -- state -->> ReplicaActive/ReplicaIdle" << dendl;
944950}
945951
946- void ReplicaIdle::reset_ignored (const FullReset&)
947- {
948- dout (10 ) << " ReplicaIdle::react(const FullReset&): FullReset ignored"
949- << dendl;
950- }
951-
952-
953- // ---------------- ReplicaIdle/ReplicaUnreserved ---------------------------
954952
955- ReplicaUnreserved::ReplicaUnreserved (my_context ctx)
956- : my_base(ctx)
957- , NamedSimply(
958- context<ScrubMachine>().m_scrbr,
959- " ReplicaActive/ReplicaIdle/ReplicaUnreserved" )
960- {
961- dout (10 ) << " -- state -->> ReplicaActive/ReplicaIdle/ReplicaUnreserved"
962- << dendl;
963- }
964-
965-
966- sc::result ReplicaUnreserved::react (const StartReplica& ev)
953+ sc::result ReplicaIdle::react (const StartReplica& ev)
967954{
968955 DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
969- dout (10 ) << " ReplicaUnreserved::react(const StartReplica&)" << dendl;
970- post_event (ReplicaPushesUpd{});
971- return transit<ReplicaActiveOp>();
972- }
973-
974-
975- // ---------------- ReplicaIdle/ReplicaWaitingReservation ---------------------------
976-
977- ReplicaWaitingReservation::ReplicaWaitingReservation (my_context ctx)
978- : my_base(ctx)
979- , NamedSimply(
980- context<ScrubMachine>().m_scrbr,
981- " ReplicaActive/ReplicaIdle/ReplicaWaitingReservation" )
982- {
983- dout (10 )
984- << " -- state -->> ReplicaActive/ReplicaIdle/ReplicaWaitingReservation"
985- << dendl;
986- }
987-
988- sc::result ReplicaWaitingReservation::react (const StartReplica& ev)
989- {
990- DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
991- dout (10 ) << " ReplicaWaitingReservation::react(const StartReplica&)" << dendl;
992-
993- // this shouldn't happen. We will handle it, but will also log an error.
994- scrbr->get_clog ()->error () << fmt::format (
995- " osd.{} pg[{}]: new chunk request while still waiting for "
996- " reservation" ,
997- scrbr->get_whoami (), scrbr->get_spgid ());
998- context<ReplicaActive>().clear_remote_reservation (true );
956+ dout (10 ) << " ReplicaIdle::react(const StartReplica&)" << dendl;
957+
958+ // if we are waiting for a reservation grant from the reserver (an
959+ // illegal scenario!), that reservation must be cleared.
960+ if (context<ReplicaActive>().pending_reservation_nonce ) {
961+ scrbr->get_clog ()->warn () << fmt::format (
962+ " osd.{} pg[{}]: new chunk request while still waiting for "
963+ " reservation" ,
964+ scrbr->get_whoami (), scrbr->get_spgid ());
965+ context<ReplicaActive>().clear_remote_reservation (true );
966+ }
999967 post_event (ReplicaPushesUpd{});
1000968 return transit<ReplicaActiveOp>();
1001969}
1002970
1003971
1004- // ---------------- ReplicaIdle/ReplicaReserved ---------------------------
1005-
1006- ReplicaReserved::ReplicaReserved (my_context ctx)
1007- : my_base(ctx)
1008- , NamedSimply(
1009- context<ScrubMachine>().m_scrbr,
1010- " ReplicaActive/ReplicaIdle/ReplicaReserved" )
972+ void ReplicaIdle::reset_ignored (const FullReset&)
1011973{
1012- dout (10 ) << " -- state -->> ReplicaActive/ReplicaIdle/ReplicaReserved "
974+ dout (10 ) << " ReplicaIdle::react(const FullReset&): FullReset ignored "
1013975 << dendl;
1014976}
1015977
1016- sc::result ReplicaReserved::react (const StartReplica& ev)
1017- {
1018- DECLARE_LOCALS; // 'scrbr' & 'pg_id' aliases
1019- dout (10 ) << " ReplicaReserved::react(const StartReplica&)" << dendl;
1020- post_event (ReplicaPushesUpd{});
1021- return transit<ReplicaActiveOp>();
1022- }
1023-
1024978
1025979// ------------- ReplicaActive/ReplicaActiveOp --------------------------
1026980
@@ -1134,20 +1088,22 @@ sc::result ReplicaBuildingMap::react(const SchedReplica&)
11341088 dout (10 ) << " replica scrub job preempted" << dendl;
11351089
11361090 scrbr->send_preempted_replica ();
1137- return transit<ReplicaReserved >();
1091+ return transit<ReplicaIdle >();
11381092 }
11391093
11401094 // start or check progress of build_replica_map_chunk()
1141- auto ret_init = scrbr->build_replica_map_chunk ();
1142- if (ret_init != -EINPROGRESS) {
1143- dout ( 10 ) << " ReplicaBuildingMap::react(const SchedReplica&): back to idle "
1144- << dendl;
1145- return transit<ReplicaReserved> ();
1095+ if ( scrbr->build_replica_map_chunk () == -EINPROGRESS) {
1096+ // Must ask the backend for the next stride shortly.
1097+ // build_replica_map_chunk() has already requeued us.
1098+ dout ( 20 ) << " waiting for the backend... " << dendl;
1099+ return discard_event ();
11461100 }
11471101
1148- dout (20 ) << " ReplicaBuildingMap::react(const SchedReplica&): discarded"
1102+ // Note: build_replica_map_chunk() aborts the OSD on any backend retval
1103+ // which is not -EINPROGRESS or 0 ('done').
1104+ dout (10 ) << " ReplicaBuildingMap::react(const SchedReplica&): chunk done"
11491105 << dendl;
1150- return discard_event ();
1106+ return transit<ReplicaIdle> ();
11511107}
11521108
11531109} // namespace Scrub
0 commit comments