From aea80d9afb6a72693da1977a325c3f8abe1b239a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 5 Dec 2017 20:13:48 -0600 Subject: [PATCH] osd/PG: move peering event type out of PG class We will create these directly from peering Messages shortly. Signed-off-by: Sage Weil --- src/CMakeLists.txt | 1 + src/osd/OSD.cc | 28 +++++------ src/osd/PG.cc | 2 - src/osd/PG.h | 90 --------------------------------- src/osd/PGPeeringEvent.cc | 8 +++ src/osd/PGPeeringEvent.h | 101 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 124 insertions(+), 106 deletions(-) create mode 100644 src/osd/PGPeeringEvent.cc diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73a3cc43564..d0a2d9e66d6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -483,6 +483,7 @@ set(libcommon_files osd/OSDMapMapping.cc common/histogram.cc osd/osd_types.cc + osd/PGPeeringEvent.cc osd/OpRequest.cc common/blkdev.cc common/common_init.cc diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 73921cfbc35..961289932e1 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -8518,7 +8518,7 @@ void OSD::handle_pg_notify(OpRequestRef op) PGPeeringEventRef( new PGPeeringEvent( it->first.epoch_sent, it->first.query_epoch, - PG::MNotifyRec(pg_shard_t(from, it->first.from), it->first, + MNotifyRec(pg_shard_t(from, it->first.from), it->first, op->get_req()->get_connection()->get_features()))) ); } @@ -8544,7 +8544,7 @@ void OSD::handle_pg_log(OpRequestRef op) PGPeeringEventRef( new PGPeeringEvent( m->get_epoch(), m->get_query_epoch(), - PG::MLogRec(pg_shard_t(from, m->from), m))) + MLogRec(pg_shard_t(from, m->from), m))) ); } @@ -8572,7 +8572,7 @@ void OSD::handle_pg_info(OpRequestRef op) PGPeeringEventRef( new PGPeeringEvent( p->first.epoch_sent, p->first.query_epoch, - PG::MInfoRec( + MInfoRec( pg_shard_t( from, p->first.from), p->first.info, p->first.epoch_sent))) ); @@ -8620,13 +8620,13 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op) new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RequestBackfillPrio(m->priority))); + RequestBackfillPrio(m->priority))); } else if (m->type == MBackfillReserve::GRANT) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteBackfillReserved())); + RemoteBackfillReserved())); } else if (m->type == MBackfillReserve::REJECT) { // NOTE: this is replica -> primary "i reject your request" // and also primary -> replica "cancel my previously-granted request" @@ -8637,25 +8637,25 @@ void OSD::handle_pg_backfill_reserve(OpRequestRef op) new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteReservationRejected())); + RemoteReservationRejected())); } else if (m->type == MBackfillReserve::RELEASE) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteReservationCanceled())); + RemoteReservationCanceled())); } else if (m->type == MBackfillReserve::TOOFULL) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteReservationRevokedTooFull())); + RemoteReservationRevokedTooFull())); } else if (m->type == MBackfillReserve::REVOKE) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteReservationRevoked())); + RemoteReservationRevoked())); } else { ceph_abort(); } @@ -8679,25 +8679,25 @@ void OSD::handle_pg_recovery_reserve(OpRequestRef op) new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RequestRecoveryPrio(m->priority))); + RequestRecoveryPrio(m->priority))); } else if (m->type == MRecoveryReserve::GRANT) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RemoteRecoveryReserved())); + RemoteRecoveryReserved())); } else if (m->type == MRecoveryReserve::RELEASE) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::RecoveryDone())); + RecoveryDone())); } else if (m->type == MRecoveryReserve::REVOKE) { evt = PGPeeringEventRef( new PGPeeringEvent( m->query_epoch, m->query_epoch, - PG::DeferRecovery(0.0))); + DeferRecovery(0.0))); } else { ceph_abort(); } @@ -8767,7 +8767,7 @@ void OSD::handle_pg_query(OpRequestRef op) PGPeeringEventRef( new PGPeeringEvent( it->second.epoch_sent, it->second.epoch_sent, - PG::MQuery(pg_shard_t(from, it->second.from), + MQuery(pg_shard_t(from, it->second.from), it->second, it->second.epoch_sent)))); continue; } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 787449b14b8..5a4adc350cc 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -90,8 +90,6 @@ static ostream& _prefix(std::ostream *_dout, T *t) return *_dout << t->gen_prefix(); } -MEMPOOL_DEFINE_OBJECT_FACTORY(PGPeeringEvent, pg_peering_evt, osd); - void PGStateHistory::enter(PG* pg, const utime_t entime, const char* state) { // Ignore trimming state machine for now diff --git a/src/osd/PG.h b/src/osd/PG.h index f8d63079b01..4cb8637db6a 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1803,49 +1803,6 @@ protected: }; public: - struct MInfoRec : boost::statechart::event< MInfoRec > { - pg_shard_t from; - pg_info_t info; - epoch_t msg_epoch; - MInfoRec(pg_shard_t from, const pg_info_t &info, epoch_t msg_epoch) : - from(from), info(info), msg_epoch(msg_epoch) {} - void print(std::ostream *out) const { - *out << "MInfoRec from " << from << " info: " << info; - } - }; - struct MLogRec : boost::statechart::event< MLogRec > { - pg_shard_t from; - boost::intrusive_ptr msg; - MLogRec(pg_shard_t from, MOSDPGLog *msg) : - from(from), msg(msg) {} - void print(std::ostream *out) const { - *out << "MLogRec from " << from; - } - }; - - struct MNotifyRec : boost::statechart::event< MNotifyRec > { - pg_shard_t from; - pg_notify_t notify; - uint64_t features; - MNotifyRec(pg_shard_t from, const pg_notify_t ¬ify, uint64_t f) : - from(from), notify(notify), features(f) {} - void print(std::ostream *out) const { - *out << "MNotifyRec from " << from << " notify: " << notify - << " features: 0x" << hex << features << dec; - } - }; - struct MQuery : boost::statechart::event< MQuery > { - pg_shard_t from; - pg_query_t query; - epoch_t query_epoch; - MQuery(pg_shard_t from, const pg_query_t &query, epoch_t query_epoch): - from(from), query(query), query_epoch(query_epoch) {} - void print(std::ostream *out) const { - *out << "MQuery from " << from - << " query_epoch " << query_epoch - << " query: " << query; - } - }; protected: struct AdvMap : boost::statechart::event< AdvMap > { @@ -1882,44 +1839,6 @@ protected: } }; public: - struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > { - unsigned priority; - explicit RequestBackfillPrio(unsigned prio) : - boost::statechart::event< RequestBackfillPrio >(), - priority(prio) {} - void print(std::ostream *out) const { - *out << "RequestBackfillPrio: priority " << priority; - } - }; - struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > { - unsigned priority; - explicit RequestRecoveryPrio(unsigned prio) : - boost::statechart::event< RequestRecoveryPrio >(), - priority(prio) {} - void print(std::ostream *out) const { - *out << "RequestRecoveryPrio: priority " << priority; - } - }; -#define TrivialEvent(T) struct T : boost::statechart::event< T > { \ - T() : boost::statechart::event< T >() {} \ - void print(std::ostream *out) const { \ - *out << #T; \ - } \ - }; - struct DeferBackfill : boost::statechart::event { - float delay; - explicit DeferBackfill(float delay) : delay(delay) {} - void print(std::ostream *out) const { - *out << "DeferBackfill: delay " << delay; - } - }; - struct DeferRecovery : boost::statechart::event { - float delay; - explicit DeferRecovery(float delay) : delay(delay) {} - void print(std::ostream *out) const { - *out << "DeferRecovery: delay " << delay; - } - }; struct UnfoundBackfill : boost::statechart::event { explicit UnfoundBackfill() {} void print(std::ostream *out) const { @@ -1942,17 +1861,9 @@ protected: protected: TrivialEvent(Backfilled) TrivialEvent(LocalBackfillReserved) - public: - TrivialEvent(RemoteBackfillReserved) - protected: TrivialEvent(RejectRemoteReservation) public: - TrivialEvent(RemoteReservationRejected) - TrivialEvent(RemoteReservationRevokedTooFull) - TrivialEvent(RemoteReservationRevoked) - TrivialEvent(RemoteReservationCanceled) TrivialEvent(RequestBackfill) - TrivialEvent(RecoveryDone) protected: TrivialEvent(RemoteRecoveryPreempted) TrivialEvent(RemoteBackfillPreempted) @@ -1969,7 +1880,6 @@ protected: TrivialEvent(DoRecovery) TrivialEvent(LocalRecoveryReserved) public: - TrivialEvent(RemoteRecoveryReserved) protected: TrivialEvent(AllRemotesReserved) TrivialEvent(AllBackfillsReserved) diff --git a/src/osd/PGPeeringEvent.cc b/src/osd/PGPeeringEvent.cc new file mode 100644 index 00000000000..52aff7dc209 --- /dev/null +++ b/src/osd/PGPeeringEvent.cc @@ -0,0 +1,8 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "include/mempool.h" +#include "osd/PGPeeringEvent.h" +#include "messages/MOSDPGLog.h" + +MEMPOOL_DEFINE_OBJECT_FACTORY(PGPeeringEvent, pg_peering_evt, osd); diff --git a/src/osd/PGPeeringEvent.h b/src/osd/PGPeeringEvent.h index f328a7d81bf..9234838ece8 100644 --- a/src/osd/PGPeeringEvent.h +++ b/src/osd/PGPeeringEvent.h @@ -5,6 +5,10 @@ #include +#include "osd/osd_types.h" + +class MOSDPGLog; + class PGPeeringEvent { epoch_t epoch_sent; epoch_t epoch_requested; @@ -40,3 +44,100 @@ public: } }; typedef ceph::shared_ptr PGPeeringEventRef; + +struct MInfoRec : boost::statechart::event< MInfoRec > { + pg_shard_t from; + pg_info_t info; + epoch_t msg_epoch; + MInfoRec(pg_shard_t from, const pg_info_t &info, epoch_t msg_epoch) : + from(from), info(info), msg_epoch(msg_epoch) {} + void print(std::ostream *out) const { + *out << "MInfoRec from " << from << " info: " << info; + } +}; + +struct MLogRec : boost::statechart::event< MLogRec > { + pg_shard_t from; + boost::intrusive_ptr msg; + MLogRec(pg_shard_t from, MOSDPGLog *msg) : + from(from), msg(msg) {} + void print(std::ostream *out) const { + *out << "MLogRec from " << from; + } +}; + +struct MNotifyRec : boost::statechart::event< MNotifyRec > { + pg_shard_t from; + pg_notify_t notify; + uint64_t features; + MNotifyRec(pg_shard_t from, const pg_notify_t ¬ify, uint64_t f) : + from(from), notify(notify), features(f) {} + void print(std::ostream *out) const { + *out << "MNotifyRec from " << from << " notify: " << notify + << " features: 0x" << hex << features << dec; + } +}; + +struct MQuery : boost::statechart::event< MQuery > { + pg_shard_t from; + pg_query_t query; + epoch_t query_epoch; + MQuery(pg_shard_t from, const pg_query_t &query, epoch_t query_epoch): + from(from), query(query), query_epoch(query_epoch) {} + void print(std::ostream *out) const { + *out << "MQuery from " << from + << " query_epoch " << query_epoch + << " query: " << query; + } +}; + +struct RequestBackfillPrio : boost::statechart::event< RequestBackfillPrio > { + unsigned priority; + explicit RequestBackfillPrio(unsigned prio) : + boost::statechart::event< RequestBackfillPrio >(), + priority(prio) {} + void print(std::ostream *out) const { + *out << "RequestBackfillPrio: priority " << priority; + } +}; + +struct RequestRecoveryPrio : boost::statechart::event< RequestRecoveryPrio > { + unsigned priority; + explicit RequestRecoveryPrio(unsigned prio) : + boost::statechart::event< RequestRecoveryPrio >(), + priority(prio) {} + void print(std::ostream *out) const { + *out << "RequestRecoveryPrio: priority " << priority; + } +}; + +#define TrivialEvent(T) struct T : boost::statechart::event< T > { \ + T() : boost::statechart::event< T >() {} \ + void print(std::ostream *out) const { \ + *out << #T; \ + } \ + }; + +TrivialEvent(RemoteBackfillReserved) +TrivialEvent(RemoteReservationRejected) +TrivialEvent(RemoteReservationRevokedTooFull) +TrivialEvent(RemoteReservationRevoked) +TrivialEvent(RemoteReservationCanceled) +TrivialEvent(RemoteRecoveryReserved) +TrivialEvent(RecoveryDone) + +struct DeferRecovery : boost::statechart::event { + float delay; + explicit DeferRecovery(float delay) : delay(delay) {} + void print(std::ostream *out) const { + *out << "DeferRecovery: delay " << delay; + } +}; + +struct DeferBackfill : boost::statechart::event { + float delay; + explicit DeferBackfill(float delay) : delay(delay) {} + void print(std::ostream *out) const { + *out << "DeferBackfill: delay " << delay; + } +}; -- 2.39.5