]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSD: reply pg_created when pg is peered 55239/head
authorzhangjianwei2 <zhangjianwei2_yewu@cmss.chinamobile.com>
Thu, 4 Jan 2024 09:28:29 +0000 (17:28 +0800)
committerzhangjianwei2 <zhangjianwei2_yewu@cmss.chinamobile.com>
Mon, 15 Jan 2024 12:54:12 +0000 (20:54 +0800)
Problem:
  when PG is active+clean
  ceph osd force-create-pg 1.0 --yes-i-really-mean-it
  because osd is not reply pg_created to mon.
Affects:
  pool remains creating flags,
  mon creating_pgs.pg is not empty,
  lead to mon cannot trim OSDMaps
Solution:
  add PgCreateEvt for pg create
  if pg Active and is_peered,
  reply pg_created to mon.

Fixes: https://tracker.ceph.com/issues/63912
Signed-off-by: zhangjianwei2 <zhangjianwei2@cmss.chinamobile.com>
src/osd/OSD.cc
src/osd/PGPeeringEvent.h
src/osd/PeeringState.cc
src/osd/PeeringState.h

index ab83ef7ba4f6ca9c1971c9dc6ba484c85bd9b92b..ec90af93b201ae47f3103f623ae5e5f9f54d888c 100644 (file)
@@ -1265,6 +1265,7 @@ void OSDService::send_pg_created(pg_t pgid)
   auto o = get_osdmap();
   if (o->require_osd_release >= ceph_release_t::luminous) {
     pg_created.insert(pgid);
+    dout(20) << __func__ << " reply to mon " << pgid << " created." << dendl;
     monc->send_mon_message(new MOSDPGCreated(pgid));
   }
 }
@@ -1276,6 +1277,7 @@ void OSDService::send_pg_created()
   auto o = get_osdmap();
   if (o->require_osd_release >= ceph_release_t::luminous) {
     for (auto pgid : pg_created) {
+      dout(20) << __func__ << " reply to mon " << pgid << " created!" << dendl;
       monc->send_mon_message(new MOSDPGCreated(pgid));
     }
   }
@@ -9222,7 +9224,7 @@ void OSD::handle_fast_pg_create(MOSDPGCreate2 *m)
            std::make_shared<PGPeeringEvent>(
              m->epoch,
              m->epoch,
-             NullEvt(),
+             PgCreateEvt(),
              true,
              new PGCreateInfo(
                pgid,
index 2828880f6565aca4a9b9701ebc9e6c7892d5f429..ceabcb799ec610c150019969df6c62e5493ba36f 100644 (file)
@@ -193,6 +193,7 @@ struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > {
   };
 
 TrivialEvent(NullEvt)
+TrivialEvent(PgCreateEvt)
 TrivialEvent(RemoteBackfillReserved)
 TrivialEvent(RemoteReservationRejectedTooFull)
 TrivialEvent(RemoteReservationRevokedTooFull)
index c81cb958a7a97a9a4a75cfadcb3d1f66cf3c0e28..dbe94d9d5f4db312cecb3d96ae95bd71b96616b4 100644 (file)
@@ -6332,6 +6332,22 @@ boost::statechart::result PeeringState::Active::react(const CheckReadable &evt)
   return discard_event();
 }
 
+boost::statechart::result PeeringState::Active::react(const PgCreateEvt &evt)
+{
+  DECLARE_LOCALS;
+  pg_t pgid = context< PeeringMachine >().spgid.pgid;
+
+  psdout(10) << __func__ << " receive PgCreateEvt"
+             << " is_peered=" << ps->is_peered() << dendl;
+
+  if (ps->is_peered()) {
+    psdout(10) << __func__ << " pg is peered, reply pg_created" << dendl;
+    pl->send_pg_created(pgid);
+  }
+
+  return discard_event();
+}
+
 /*
  * update info.history.last_epoch_started ONLY after we and all
  * replicas have activated AND committed the activate transaction
index 89ef702e0fea91261365715bd394ccb45a4c9c0e..f036bb44b1159504606c3ce4d87fdac0a3d38401 100644 (file)
@@ -690,6 +690,7 @@ public:
     typedef boost::mpl::list <
       boost::statechart::transition< Initialize, Reset >,
       boost::statechart::custom_reaction< NullEvt >,
+      boost::statechart::custom_reaction< PgCreateEvt >,
       boost::statechart::transition< boost::statechart::event_base, Crashed >
       > reactions;
 
@@ -711,6 +712,7 @@ public:
       boost::statechart::custom_reaction< AdvMap >,
       boost::statechart::custom_reaction< ActMap >,
       boost::statechart::custom_reaction< NullEvt >,
+      boost::statechart::custom_reaction< PgCreateEvt >,
       boost::statechart::custom_reaction< IntervalFlush >,
       boost::statechart::transition< boost::statechart::event_base, Crashed >
       > reactions;
@@ -737,6 +739,7 @@ public:
       boost::statechart::custom_reaction< IntervalFlush >,
       // ignored
       boost::statechart::custom_reaction< NullEvt >,
+      boost::statechart::custom_reaction< PgCreateEvt >,
       boost::statechart::custom_reaction<SetForceRecovery>,
       boost::statechart::custom_reaction<UnsetForceRecovery>,
       boost::statechart::custom_reaction<SetForceBackfill>,
@@ -867,7 +870,8 @@ public:
       boost::statechart::custom_reaction< DoRecovery>,
       boost::statechart::custom_reaction< RenewLease>,
       boost::statechart::custom_reaction< MLeaseAck>,
-      boost::statechart::custom_reaction< CheckReadable>
+      boost::statechart::custom_reaction< CheckReadable>,
+      boost::statechart::custom_reaction< PgCreateEvt >
       > reactions;
     boost::statechart::result react(const QueryState& q);
     boost::statechart::result react(const QueryUnfound& q);
@@ -906,6 +910,7 @@ public:
       return discard_event();
     }
     boost::statechart::result react(const CheckReadable&);
+    boost::statechart::result react(const PgCreateEvt&);
     void all_activated_and_committed();
   };