mClockClientQueue.cc
OpQueueItem.cc
PeeringState.cc
+ PGStateUtils.cc
${CMAKE_SOURCE_DIR}/src/common/TrackedOp.cc
${CMAKE_SOURCE_DIR}/src/objclass/class_api.cc
${CMAKE_SOURCE_DIR}/src/mgr/OSDPerfMetricTypes.cc
return t->gen_prefix(*_dout);
}
-void PGStateHistory::enter(PG* pg, const utime_t entime, const char* state)
-{
- // Ignore trimming state machine for now
- if (::strstr(state, "Trimming") != NULL) {
- return;
- } else if (pi != nullptr) {
- pi->enter_state(entime, state);
- } else {
- // Store current state since we can't reliably take the PG lock here
- if ( tmppi == nullptr) {
- tmppi = std::unique_ptr<PGStateInstance>(new PGStateInstance);
- }
-
- thispg = pg;
- tmppi->enter_state(entime, state);
- }
-}
-
-void PGStateHistory::exit(const char* state) {
- // Ignore trimming state machine for now
- // Do nothing if PG is being destroyed!
- if (::strstr(state, "Trimming") != NULL || pg_in_destructor) {
- return;
- } else {
- bool ilocked = false;
- if(!thispg->is_locked()) {
- thispg->lock();
- ilocked = true;
- }
- if (pi == nullptr) {
- buffer.push_back(std::unique_ptr<PGStateInstance>(tmppi.release()));
- pi = buffer.back().get();
- pi->setepoch(thispg->get_osdmap_epoch());
- }
-
- pi->exit_state(ceph_clock_now());
- if (::strcmp(state, "Reset") == 0) {
- this->reset();
- }
- if(ilocked) {
- thispg->unlock();
- }
- }
-}
-
-void PGStateHistory::dump(Formatter* f) const {
- f->open_array_section("history");
- for (auto pi = buffer.begin(); pi != buffer.end(); ++pi) {
- f->open_object_section("states");
- f->dump_stream("epoch") << (*pi)->this_epoch;
- for (auto she : (*pi)->state_history) {
- f->dump_string("state", std::get<2>(she));
- f->dump_stream("enter") << std::get<0>(she);
- f->dump_stream("exit") << std::get<1>(she);
- }
- f->close_section();
- }
- f->close_section();
-}
-
void PG::get(const char* tag)
{
int after = ++ref;
#include <boost/statechart/transition.hpp>
#include <boost/statechart/event_base.hpp>
#include <boost/scoped_ptr.hpp>
-#include <boost/circular_buffer.hpp>
#include <boost/container/flat_set.hpp>
#include "include/mempool.h"
#include <atomic>
#include <list>
#include <memory>
-#include <stack>
#include <string>
#include <tuple>
class Store;
}
-using state_history_entry = std::tuple<utime_t, utime_t, const char*>;
-using embedded_state = std::pair<utime_t, const char*>;
-
-struct PGStateInstance {
- // Time spent in pg states
-
- void setepoch(const epoch_t current_epoch) {
- this_epoch = current_epoch;
- }
-
- void enter_state(const utime_t entime, const char* state) {
- embedded_states.push(std::make_pair(entime, state));
- }
-
- void exit_state(const utime_t extime) {
- embedded_state this_state = embedded_states.top();
- state_history.push_back(state_history_entry{
- this_state.first, extime, this_state.second});
- embedded_states.pop();
- }
-
- epoch_t this_epoch;
- utime_t enter_time;
- std::vector<state_history_entry> state_history;
- std::stack<embedded_state> embedded_states;
-};
-
-class PGStateHistory {
- // Member access protected with the PG lock
-public:
- PGStateHistory() : buffer(10) {}
-
- void enter(PG* pg, const utime_t entime, const char* state);
-
- void exit(const char* state);
-
- void reset() {
- pi = nullptr;
- }
-
- void set_pg_in_destructor() { pg_in_destructor = true; }
-
- void dump(Formatter* f) const;
-
- string get_current_state() {
- if (pi == nullptr) return "unknown";
- return std::get<1>(pi->embedded_states.top());
- }
-
-private:
- bool pg_in_destructor = false;
- PG* thispg = nullptr;
- std::unique_ptr<PGStateInstance> tmppi;
- PGStateInstance* pi = nullptr;
- boost::circular_buffer<std::unique_ptr<PGStateInstance>> buffer;
-
-};
-
#ifdef PG_DEBUG_REFS
#include "common/tracked_int_ptr.hpp"
uint64_t get_with_id(PG *pg);
*/
class PG : public DoutPrefixProvider {
+ friend class NamedState;
friend class PeeringState;
public:
using PeeringCtx = PeeringState::PeeringCtx;
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "PGStateUtils.h"
+#include "PG.h"
+
+/*------NamedState----*/
+NamedState::NamedState(
+ PG *pg_, const char *state_name_)
+ : state_name(state_name_), enter_time(ceph_clock_now()), pg(pg_) {
+ pg->pgstate_history.enter(pg, enter_time, state_name);
+}
+
+NamedState::~NamedState() {
+ pg->pgstate_history.exit(state_name);
+}
+
+/*---------PGStateHistory---------*/
+void PGStateHistory::enter(PG* pg, const utime_t entime, const char* state)
+{
+ // Ignore trimming state machine for now
+ if (::strstr(state, "Trimming") != NULL) {
+ return;
+ } else if (pi != nullptr) {
+ pi->enter_state(entime, state);
+ } else {
+ // Store current state since we can't reliably take the PG lock here
+ if ( tmppi == nullptr) {
+ tmppi = std::unique_ptr<PGStateInstance>(new PGStateInstance);
+ }
+
+ thispg = pg;
+ tmppi->enter_state(entime, state);
+ }
+}
+
+void PGStateHistory::exit(const char* state) {
+ // Ignore trimming state machine for now
+ // Do nothing if PG is being destroyed!
+ if (::strstr(state, "Trimming") != NULL || pg_in_destructor) {
+ return;
+ } else {
+ bool ilocked = false;
+ if(!thispg->is_locked()) {
+ thispg->lock();
+ ilocked = true;
+ }
+ if (pi == nullptr) {
+ buffer.push_back(std::unique_ptr<PGStateInstance>(tmppi.release()));
+ pi = buffer.back().get();
+ pi->setepoch(thispg->get_osdmap_epoch());
+ }
+
+ pi->exit_state(ceph_clock_now());
+ if (::strcmp(state, "Reset") == 0) {
+ this->reset();
+ }
+ if(ilocked) {
+ thispg->unlock();
+ }
+ }
+}
+
+void PGStateHistory::dump(Formatter* f) const {
+ f->open_array_section("history");
+ for (auto pi = buffer.begin(); pi != buffer.end(); ++pi) {
+ f->open_object_section("states");
+ f->dump_stream("epoch") << (*pi)->this_epoch;
+ for (auto she : (*pi)->state_history) {
+ f->dump_string("state", std::get<2>(she));
+ f->dump_stream("enter") << std::get<0>(she);
+ f->dump_stream("exit") << std::get<1>(she);
+ }
+ f->close_section();
+ }
+ f->close_section();
+}
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#pragma once
+
+#include "include/utime.h"
+
+#include <stack>
+#include <vector>
+#include <boost/circular_buffer.hpp>
+
+class PG;
+
+struct NamedState {
+ const char *state_name;
+ utime_t enter_time;
+ PG* pg;
+ const char *get_state_name() { return state_name; }
+ NamedState(PG *pg_, const char *state_name_);
+ virtual ~NamedState();
+};
+
+using state_history_entry = std::tuple<utime_t, utime_t, const char*>;
+using embedded_state = std::pair<utime_t, const char*>;
+
+struct PGStateInstance {
+ // Time spent in pg states
+
+ void setepoch(const epoch_t current_epoch) {
+ this_epoch = current_epoch;
+ }
+
+ void enter_state(const utime_t entime, const char* state) {
+ embedded_states.push(std::make_pair(entime, state));
+ }
+
+ void exit_state(const utime_t extime) {
+ embedded_state this_state = embedded_states.top();
+ state_history.push_back(state_history_entry{
+ this_state.first, extime, this_state.second});
+ embedded_states.pop();
+ }
+
+ epoch_t this_epoch;
+ utime_t enter_time;
+ std::vector<state_history_entry> state_history;
+ std::stack<embedded_state> embedded_states;
+};
+
+class PGStateHistory {
+ // Member access protected with the PG lock
+public:
+ PGStateHistory() : buffer(10) {}
+
+ void enter(PG* pg, const utime_t entime, const char* state);
+
+ void exit(const char* state);
+
+ void reset() {
+ pi = nullptr;
+ }
+
+ void set_pg_in_destructor() { pg_in_destructor = true; }
+
+ void dump(Formatter* f) const;
+
+ string get_current_state() {
+ if (pi == nullptr) return "unknown";
+ return std::get<1>(pi->embedded_states.top());
+ }
+
+private:
+ bool pg_in_destructor = false;
+ PG* thispg = nullptr;
+ std::unique_ptr<PGStateInstance> tmppi;
+ PGStateInstance* pi = nullptr;
+ boost::circular_buffer<std::unique_ptr<PGStateInstance>> buffer;
+
+};
<< "state<" << get_state_name() << ">: ")
#define psdout(x) ldout(context< PeeringMachine >().cct, x)
-/*------NamedState----*/
-PeeringState::NamedState::NamedState(
- PG *pg_, const char *state_name_)
- : state_name(state_name_), enter_time(ceph_clock_now()), pg(pg_) {
- pg->pgstate_history.enter(pg, enter_time, state_name);
-}
-
-PeeringState::NamedState::~NamedState() {
- pg->pgstate_history.exit(state_name);
-}
-
/*------Crashed-------*/
PeeringState::Crashed::Crashed(my_context ctx)
: my_base(ctx),
#include <boost/statechart/transition.hpp>
#include <boost/statechart/event_base.hpp>
+#include "PGStateUtils.h"
#include "PGPeeringEvent.h"
#include "os/ObjectStore.h"
#include "OSDMap.h"
/* Encapsulates PG recovery process */
class PeeringState {
public:
- struct NamedState {
- const char *state_name;
- utime_t enter_time;
- PG* pg;
- const char *get_state_name() { return state_name; }
- NamedState(PG *pg_, const char *state_name_);
- virtual ~NamedState();
- };
-
// [primary only] content recovery state
struct BufferedRecoveryMessages {
map<int, map<spg_t, pg_query_t> > query_map;
}
} snap_trimmer_machine;
- using NamedState = PeeringState::NamedState;
struct WaitReservation;
struct Trimming : boost::statechart::state< Trimming, SnapTrimmer, WaitReservation >, NamedState {
typedef boost::mpl::list <