dout(10) << "Adding newly split pg " << *pg << dendl;
pg->handle_loaded(rctx);
pg->queue_null(e, e);
- map<spg_t, list<PG::CephPeeringEvtRef> >::iterator to_wake =
+ map<spg_t, list<PGPeeringEventRef> >::iterator to_wake =
peering_wait_for_split.find(pg->pg_id);
if (to_wake != peering_wait_for_split.end()) {
- for (list<PG::CephPeeringEvtRef>::iterator i =
+ for (list<PGPeeringEventRef>::iterator i =
to_wake->second.begin();
i != to_wake->second.end();
++i) {
const pg_history_t& orig_history,
const PastIntervals& pi,
epoch_t epoch,
- PG::CephPeeringEvtRef evt)
+ PGPeeringEventRef evt)
{
if (service.splitting(pgid)) {
peering_wait_for_split[pgid].push_back(evt);
history,
pi,
osdmap->get_epoch(),
- PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ PGPeeringEventRef(
+ new PGPeeringEvent(
osdmap->get_epoch(),
osdmap->get_epoch(),
PG::NullEvt()))
spg_t(it->first.info.pgid.pgid, it->first.to),
it->first.info.history, it->second,
it->first.query_epoch,
- PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ PGPeeringEventRef(
+ new PGPeeringEvent(
it->first.epoch_sent, it->first.query_epoch,
PG::MNotifyRec(pg_shard_t(from, it->first.from), it->first,
op->get_req()->get_connection()->get_features())))
handle_pg_peering_evt(
spg_t(m->get_pgid().pgid, m->to),
m->info.history, m->past_intervals, m->get_epoch(),
- PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ PGPeeringEventRef(
+ new PGPeeringEvent(
m->get_epoch(), m->get_query_epoch(),
PG::MLogRec(pg_shard_t(from, m->from), m)))
);
handle_pg_peering_evt(
spg_t(p->first.info.pgid.pgid, p->first.to),
p->first.info.history, p->second, p->first.epoch_sent,
- PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ PGPeeringEventRef(
+ new PGPeeringEvent(
p->first.epoch_sent, p->first.query_epoch,
PG::MInfoRec(
pg_shard_t(
if (!require_same_or_newer_map(op, m->query_epoch, false))
return;
- PG::CephPeeringEvtRef evt;
+ PGPeeringEventRef evt;
if (m->type == MBackfillReserve::REQUEST) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RequestBackfillPrio(m->priority)));
} else if (m->type == MBackfillReserve::GRANT) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteBackfillReserved()));
// (for older peers)
// and also replica -> primary "i revoke your reservation"
// (for older peers)
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteReservationRejected()));
} else if (m->type == MBackfillReserve::RELEASE) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteReservationCanceled()));
} else if (m->type == MBackfillReserve::TOOFULL) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteReservationRevokedTooFull()));
} else if (m->type == MBackfillReserve::REVOKE) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteReservationRevoked()));
if (!require_same_or_newer_map(op, m->query_epoch, false))
return;
- PG::CephPeeringEvtRef evt;
+ PGPeeringEventRef evt;
if (m->type == MRecoveryReserve::REQUEST) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RequestRecoveryPrio(m->priority)));
} else if (m->type == MRecoveryReserve::GRANT) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RemoteRecoveryReserved()));
} else if (m->type == MRecoveryReserve::RELEASE) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::RecoveryDone()));
} else if (m->type == MRecoveryReserve::REVOKE) {
- evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ evt = PGPeeringEventRef(
+ new PGPeeringEvent(
m->query_epoch,
m->query_epoch,
PG::DeferRecovery(0.0)));
if (service.splitting(pgid)) {
peering_wait_for_split[pgid].push_back(
- PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ PGPeeringEventRef(
+ new PGPeeringEvent(
it->second.epoch_sent, it->second.epoch_sent,
PG::MQuery(pg_shard_t(from, it->second.from),
it->second, it->second.epoch_sent))));
std::set<create_from_osd_t> pending_creates_from_osd;
unsigned pending_creates_from_mon = 0;
- map<spg_t, list<PG::CephPeeringEvtRef> > peering_wait_for_split;
+ map<spg_t, list<PGPeeringEventRef> > peering_wait_for_split;
PGRecoveryStats pg_recovery_stats;
PGPool _get_pool(int id, OSDMapRef createmap);
const pg_history_t& orig_history,
const PastIntervals& pi,
epoch_t epoch,
- PG::CephPeeringEvtRef evt);
+ PGPeeringEventRef evt);
bool maybe_wait_for_max_pg(spg_t pgid, bool is_mon_create);
void resume_creating_pg();
return *_dout << t->gen_prefix();
}
-MEMPOOL_DEFINE_OBJECT_FACTORY(PG::CephPeeringEvt, pg_peering_evt, osd);
+MEMPOOL_DEFINE_OBJECT_FACTORY(PGPeeringEvent, pg_peering_evt, osd);
void PGStateHistory::enter(PG* pg, const utime_t entime, const char* state)
{
assert(blocked_by.empty());
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
AllReplicasActivated())));
if (has_error) {
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
DoRecovery())));
{
dout(10) << "take_waiters" << dendl;
requeue_map_waiters();
- for (list<CephPeeringEvtRef>::iterator i = peering_waiters.begin();
+ for (list<PGPeeringEventRef>::iterator i = peering_waiters.begin();
i != peering_waiters.end();
++i) osd->queue_for_peering(this);
peering_queue.splice(peering_queue.begin(), peering_waiters,
void PG::process_peering_event(RecoveryCtx *rctx)
{
assert(!peering_queue.empty());
- CephPeeringEvtRef evt = peering_queue.front();
+ PGPeeringEventRef evt = peering_queue.front();
peering_queue.pop_front();
dout(10) << __func__ << ": " << evt->get_desc() << dendl;
write_if_dirty(*rctx->transaction);
}
-void PG::queue_peering_event(CephPeeringEvtRef evt)
+void PG::queue_peering_event(PGPeeringEventRef evt)
{
if (old_peering_evt(evt))
return;
{
dout(10) << "null" << dendl;
queue_peering_event(
- CephPeeringEvtRef(std::make_shared<CephPeeringEvt>(msg_epoch, query_epoch,
+ PGPeeringEventRef(std::make_shared<PGPeeringEvent>(msg_epoch, query_epoch,
NullEvt())));
}
{
dout(10) << "flushed" << dendl;
queue_peering_event(
- CephPeeringEvtRef(std::make_shared<CephPeeringEvt>(e, e,
+ PGPeeringEventRef(std::make_shared<PGPeeringEvent>(e, e,
FlushedEvt())));
}
{
dout(10) << "handle_query " << q << " from replica " << from << dendl;
queue_peering_event(
- CephPeeringEvtRef(std::make_shared<CephPeeringEvt>(msg_epoch, query_epoch,
+ PGPeeringEventRef(std::make_shared<PGPeeringEvent>(msg_epoch, query_epoch,
MQuery(from, q, query_epoch))));
}
if (rctx->query_map->empty()) {
string action;
if (state_test(PG_STATE_BACKFILLING)) {
- auto evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ auto evt = PGPeeringEventRef(
+ new PGPeeringEvent(
queued,
queued,
PG::UnfoundBackfill()));
queue_peering_event(evt);
action = "in backfill";
} else if (state_test(PG_STATE_RECOVERING)) {
- auto evt = PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ auto evt = PGPeeringEventRef(
+ new PGPeeringEvent(
queued,
queued,
PG::UnfoundRecovery()));
#include "messages/MOSDPGLog.h"
#include "include/str_list.h"
#include "PGBackend.h"
+#include "PGPeeringEvent.h"
#include <atomic>
#include <list>
ObjectStore::CollectionHandle ch;
- // -- classes --
- class CephPeeringEvt {
- epoch_t epoch_sent;
- epoch_t epoch_requested;
- boost::intrusive_ptr< const boost::statechart::event_base > evt;
- string desc;
- public:
- MEMPOOL_CLASS_HELPERS();
- template <class T>
- CephPeeringEvt(epoch_t epoch_sent,
- epoch_t epoch_requested,
- const T &evt_) :
- epoch_sent(epoch_sent), epoch_requested(epoch_requested),
- evt(evt_.intrusive_from_this()) {
- stringstream out;
- out << "epoch_sent: " << epoch_sent
- << " epoch_requested: " << epoch_requested << " ";
- evt_.print(&out);
- desc = out.str();
- }
- epoch_t get_epoch_sent() { return epoch_sent; }
- epoch_t get_epoch_requested() { return epoch_requested; }
- const boost::statechart::event_base &get_event() { return *evt; }
- string get_desc() { return desc; }
- };
- typedef ceph::shared_ptr<CephPeeringEvt> CephPeeringEvtRef;
-
class RecoveryCtx;
// -- methods --
bool set_force_recovery(bool b);
bool set_force_backfill(bool b);
- void queue_peering_event(CephPeeringEvtRef evt);
+ void queue_peering_event(PGPeeringEventRef evt);
void process_peering_event(RecoveryCtx *rctx);
void queue_query(epoch_t msg_epoch, epoch_t query_epoch,
pg_shard_t from, const pg_query_t& q);
pg(pg), epoch(epoch), evt(evt) {}
void finish(int r) override {
pg->lock();
- pg->queue_peering_event(PG::CephPeeringEvtRef(
- new PG::CephPeeringEvt(
+ pg->queue_peering_event(PGPeeringEventRef(
+ new PGPeeringEvent(
epoch,
epoch,
evt)));
};
- list<CephPeeringEvtRef> peering_queue; // op queue
- list<CephPeeringEvtRef> peering_waiters;
+ list<PGPeeringEventRef> peering_queue; // op queue
+ list<PGPeeringEventRef> peering_waiters;
struct QueryState : boost::statechart::event< QueryState > {
Formatter *f;
end_handle();
}
- void handle_event(CephPeeringEvtRef evt,
+ void handle_event(PGPeeringEventRef evt,
RecoveryCtx *rctx) {
start_handle(rctx);
machine.process_event(evt->get_event());
bool can_discard_replica_op(OpRequestRef& op);
bool old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch);
- bool old_peering_evt(CephPeeringEvtRef evt) {
+ bool old_peering_evt(PGPeeringEventRef evt) {
return old_peering_msg(evt->get_epoch_sent(), evt->get_epoch_requested());
}
static bool have_same_or_newer_map(epoch_t cur_epoch, epoch_t e) {
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include <boost/statechart/event.hpp>
+
+class PGPeeringEvent {
+ epoch_t epoch_sent;
+ epoch_t epoch_requested;
+ boost::intrusive_ptr< const boost::statechart::event_base > evt;
+ string desc;
+public:
+ MEMPOOL_CLASS_HELPERS();
+ template <class T>
+ PGPeeringEvent(
+ epoch_t epoch_sent,
+ epoch_t epoch_requested,
+ const T &evt_)
+ : epoch_sent(epoch_sent),
+ epoch_requested(epoch_requested),
+ evt(evt_.intrusive_from_this()) {
+ stringstream out;
+ out << "epoch_sent: " << epoch_sent
+ << " epoch_requested: " << epoch_requested << " ";
+ evt_.print(&out);
+ desc = out.str();
+ }
+ epoch_t get_epoch_sent() {
+ return epoch_sent;
+ }
+ epoch_t get_epoch_requested() {
+ return epoch_requested;
+ }
+ const boost::statechart::event_base &get_event() {
+ return *evt;
+ }
+ const string& get_desc() {
+ return desc;
+ }
+};
+typedef ceph::shared_ptr<PGPeeringEvent> PGPeeringEventRef;
if (osd->check_backfill_full(ss)) {
dout(1) << __func__ << ": Canceling backfill, " << ss.str() << dendl;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
BackfillTooFull())));
reply->set_priority(get_recovery_op_priority());
osd->send_message_osd_cluster(reply, m->get_connection());
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
RecoveryDone())));
if (is_recovery_unfound()) {
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
DoRecovery())));
} else if (is_backfill_unfound()) {
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
RequestBackfill())));
if (needs_recovery()) {
dout(10) << "activate not all replicas are up-to-date, queueing recovery" << dendl;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
DoRecovery())));
} else if (needs_backfill()) {
dout(10) << "activate queueing backfill" << dendl;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
RequestBackfill())));
dout(10) << "activate all replicas clean, no recovery" << dendl;
eio_errors_to_process = false;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
AllReplicasRecovered())));
dout(10) << "queueing RequestBackfill" << dendl;
backfill_reserving = true;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
RequestBackfill())));
if (needs_backfill()) {
dout(10) << "recovery done, queuing backfill" << dendl;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
RequestBackfill())));
eio_errors_to_process = false;
state_clear(PG_STATE_FORCED_BACKFILL);
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
AllReplicasRecovered())));
dout(10) << "recovery done, backfill done" << dendl;
eio_errors_to_process = false;
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
Backfilled())));
eio_errors_to_process = true;
assert(is_clean());
queue_peering_event(
- CephPeeringEvtRef(
- std::make_shared<CephPeeringEvt>(
+ PGPeeringEventRef(
+ std::make_shared<PGPeeringEvent>(
get_osdmap()->get_epoch(),
get_osdmap()->get_epoch(),
DoRecovery())));