Skip to content

Commit b96215e

Browse files
authored
Merge pull request ceph#55239 from jianwei1216/fix_pg_created_lost_main3
Solution 1: osd/OSD: reply pg_created when pg is peered Reviewed-by: Samuel Just <[email protected]>
2 parents d74e98d + b0e6ce3 commit b96215e

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

src/osd/OSD.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,7 @@ void OSDService::send_pg_created(pg_t pgid)
12671267
auto o = get_osdmap();
12681268
if (o->require_osd_release >= ceph_release_t::luminous) {
12691269
pg_created.insert(pgid);
1270+
dout(20) << __func__ << " reply to mon " << pgid << " created." << dendl;
12701271
monc->send_mon_message(new MOSDPGCreated(pgid));
12711272
}
12721273
}
@@ -1278,6 +1279,7 @@ void OSDService::send_pg_created()
12781279
auto o = get_osdmap();
12791280
if (o->require_osd_release >= ceph_release_t::luminous) {
12801281
for (auto pgid : pg_created) {
1282+
dout(20) << __func__ << " reply to mon " << pgid << " created!" << dendl;
12811283
monc->send_mon_message(new MOSDPGCreated(pgid));
12821284
}
12831285
}
@@ -9227,7 +9229,7 @@ void OSD::handle_fast_pg_create(MOSDPGCreate2 *m)
92279229
std::make_shared<PGPeeringEvent>(
92289230
m->epoch,
92299231
m->epoch,
9230-
NullEvt(),
9232+
PgCreateEvt(),
92319233
true,
92329234
new PGCreateInfo(
92339235
pgid,

src/osd/PGPeeringEvent.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > {
193193
};
194194

195195
TrivialEvent(NullEvt)
196+
TrivialEvent(PgCreateEvt)
196197
TrivialEvent(RemoteBackfillReserved)
197198
TrivialEvent(RemoteReservationRejectedTooFull)
198199
TrivialEvent(RemoteReservationRevokedTooFull)

src/osd/PeeringState.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6335,6 +6335,22 @@ boost::statechart::result PeeringState::Active::react(const CheckReadable &evt)
63356335
return discard_event();
63366336
}
63376337

6338+
boost::statechart::result PeeringState::Active::react(const PgCreateEvt &evt)
6339+
{
6340+
DECLARE_LOCALS;
6341+
pg_t pgid = context< PeeringMachine >().spgid.pgid;
6342+
6343+
psdout(10) << __func__ << " receive PgCreateEvt"
6344+
<< " is_peered=" << ps->is_peered() << dendl;
6345+
6346+
if (ps->is_peered()) {
6347+
psdout(10) << __func__ << " pg is peered, reply pg_created" << dendl;
6348+
pl->send_pg_created(pgid);
6349+
}
6350+
6351+
return discard_event();
6352+
}
6353+
63386354
/*
63396355
* update info.history.last_epoch_started ONLY after we and all
63406356
* replicas have activated AND committed the activate transaction

src/osd/PeeringState.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ class PeeringState : public MissingLoc::MappingInfo {
690690
typedef boost::mpl::list <
691691
boost::statechart::transition< Initialize, Reset >,
692692
boost::statechart::custom_reaction< NullEvt >,
693+
boost::statechart::custom_reaction< PgCreateEvt >,
693694
boost::statechart::transition< boost::statechart::event_base, Crashed >
694695
> reactions;
695696

@@ -711,6 +712,7 @@ class PeeringState : public MissingLoc::MappingInfo {
711712
boost::statechart::custom_reaction< AdvMap >,
712713
boost::statechart::custom_reaction< ActMap >,
713714
boost::statechart::custom_reaction< NullEvt >,
715+
boost::statechart::custom_reaction< PgCreateEvt >,
714716
boost::statechart::custom_reaction< IntervalFlush >,
715717
boost::statechart::transition< boost::statechart::event_base, Crashed >
716718
> reactions;
@@ -737,6 +739,7 @@ class PeeringState : public MissingLoc::MappingInfo {
737739
boost::statechart::custom_reaction< IntervalFlush >,
738740
// ignored
739741
boost::statechart::custom_reaction< NullEvt >,
742+
boost::statechart::custom_reaction< PgCreateEvt >,
740743
boost::statechart::custom_reaction<SetForceRecovery>,
741744
boost::statechart::custom_reaction<UnsetForceRecovery>,
742745
boost::statechart::custom_reaction<SetForceBackfill>,
@@ -867,7 +870,8 @@ class PeeringState : public MissingLoc::MappingInfo {
867870
boost::statechart::custom_reaction< DoRecovery>,
868871
boost::statechart::custom_reaction< RenewLease>,
869872
boost::statechart::custom_reaction< MLeaseAck>,
870-
boost::statechart::custom_reaction< CheckReadable>
873+
boost::statechart::custom_reaction< CheckReadable>,
874+
boost::statechart::custom_reaction< PgCreateEvt >
871875
> reactions;
872876
boost::statechart::result react(const QueryState& q);
873877
boost::statechart::result react(const QueryUnfound& q);
@@ -906,6 +910,7 @@ class PeeringState : public MissingLoc::MappingInfo {
906910
return discard_event();
907911
}
908912
boost::statechart::result react(const CheckReadable&);
913+
boost::statechart::result react(const PgCreateEvt&);
909914
void all_activated_and_committed();
910915
};
911916

0 commit comments

Comments
 (0)