}
PG *OSD::_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Transaction& t,
- PG::Info::History history)
+ pg_history_t history)
{
assert(osd_lock.is_locked());
dout(20) << "_create_lock_new_pg pgid " << pgid << " -> " << acting << dendl;
osdmap->pg_to_up_acting_osds(info.pgid, up, acting);
int role = osdmap->calc_pg_role(whoami, acting, acting.size());
- PG::Info::History history = info.history;
+ pg_history_t history = info.history;
project_pg_history(info.pgid, history, epoch, up, acting);
if (epoch < history.same_interval_since) {
* Fill in the passed history so you know same_interval_since, same_up_since,
* and same_primary_since.
*/
-void OSD::project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
+void OSD::project_pg_history(pg_t pgid, pg_history_t& h, epoch_t from,
vector<int>& currentup, vector<int>& currentacting)
{
dout(15) << "project_pg_history " << pgid
for (set<pg_t>::iterator q = p->second.begin();
q != p->second.end();
q++) {
- PG::Info::History history;
+ pg_history_t history;
history.epoch_created = history.same_up_since =
history.same_interval_since = history.same_primary_since =
osdmap->get_epoch();
}
// figure history
- PG::Info::History history;
+ pg_history_t history;
history.epoch_created = created;
history.last_epoch_clean = created;
project_pg_history(pgid, history, created, up, acting);
int role = osdmap->calc_pg_role(whoami, acting, acting.size());
// same primary?
- PG::Info::History history = it->second.history;
+ pg_history_t history = it->second.history;
project_pg_history(pgid, history, m->get_epoch(), up, acting);
if (m->get_epoch() < history.same_interval_since) {
PG *_open_lock_pg(pg_t pg, bool no_lockdep_check=false); // create new PG (in memory)
PG *_create_lock_pg(pg_t pg, ObjectStore::Transaction& t); // create new PG
PG *_create_lock_new_pg(pg_t pgid, vector<int>& acting, ObjectStore::Transaction& t,
- PG::Info::History history);
+ pg_history_t history);
//void _remove_unlock_pg(PG *pg); // remove from store and memory
PG *lookup_lock_raw_pg(pg_t pgid);
void load_pgs();
void calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& pset);
- void project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
+ void project_pg_history(pg_t pgid, pg_history_t& h, epoch_t from,
vector<int>& lastup, vector<int>& lastacting);
void wake_pg_waiters(pg_t pgid) {
// -- pg creation --
struct create_pg_info {
- PG::Info::History history;
+ pg_history_t history;
vector<int> acting;
set<int> prior;
pg_t parent;
{
o.push_back(new Info);
o.push_back(new Info);
- list<History*> h;
- History::generate_test_instances(h);
+ list<pg_history_t*> h;
+ pg_history_t::generate_test_instances(h);
o.back()->history = *h.back();
o.back()->pgid = pg_t(1, 2, -1);
o.back()->last_update = eversion_t(3, 4);
o.back()->stats = *s.back();
}
-/******* PG::Info::History *******/
-
-void PG::Info::History::dump(Formatter *f) const
-{
- f->dump_int("epoch_created", epoch_created);
- f->dump_int("last_epoch_started", last_epoch_started);
- f->dump_int("last_epoch_clean", last_epoch_clean);
- f->dump_int("last_epoch_split", last_epoch_split);
- f->dump_int("same_up_since", same_up_since);
- f->dump_int("same_interval_since", same_interval_since);
- f->dump_int("same_primary_since", same_primary_since);
- f->dump_stream("last_scrub") << last_scrub;
- f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
-}
-
-void PG::Info::History::generate_test_instances(list<PG::Info::History*>& o)
-{
- o.push_back(new History);
- o.push_back(new History);
- o.back()->epoch_created = 1;
- o.back()->last_epoch_started = 2;
- o.back()->last_epoch_clean = 3;
- o.back()->last_epoch_split = 4;
- o.back()->same_up_since = 5;
- o.back()->same_interval_since = 6;
- o.back()->same_primary_since = 7;
- o.back()->last_scrub = eversion_t(8, 9);
- o.back()->last_scrub_stamp = utime_t(10, 11);
-}
/******* PG::Log ********/
pg_stat_t stats;
- struct History {
- epoch_t epoch_created; // epoch in which PG was created
- epoch_t last_epoch_started; // lower bound on last epoch started (anywhere, not necessarily locally)
- epoch_t last_epoch_clean; // lower bound on last epoch the PG was completely clean.
- epoch_t last_epoch_split; // as parent
-
- epoch_t same_up_since; // same acting set since
- epoch_t same_interval_since; // same acting AND up set since
- epoch_t same_primary_since; // same primary at least back through this epoch.
-
- eversion_t last_scrub;
- utime_t last_scrub_stamp;
-
- History() :
- epoch_created(0),
- last_epoch_started(0), last_epoch_clean(0), last_epoch_split(0),
- same_up_since(0), same_interval_since(0), same_primary_since(0) {}
-
- void merge(const History &other) {
- // Here, we only update the fields which cannot be calculated from the OSDmap.
- if (epoch_created < other.epoch_created)
- epoch_created = other.epoch_created;
- if (last_epoch_started < other.last_epoch_started)
- last_epoch_started = other.last_epoch_started;
- if (last_epoch_clean < other.last_epoch_clean)
- last_epoch_clean = other.last_epoch_clean;
- if (last_epoch_split < other.last_epoch_started)
- last_epoch_split = other.last_epoch_started;
- if (other.last_scrub > last_scrub)
- last_scrub = other.last_scrub;
- if (other.last_scrub_stamp > last_scrub_stamp)
- last_scrub_stamp = other.last_scrub_stamp;
- }
+ pg_history_t history;
- void encode(bufferlist &bl) const {
- __u8 struct_v = 3;
- ::encode(struct_v, bl);
- ::encode(epoch_created, bl);
- ::encode(last_epoch_started, bl);
- ::encode(last_epoch_clean, bl);
- ::encode(last_epoch_split, bl);
- ::encode(same_interval_since, bl);
- ::encode(same_up_since, bl);
- ::encode(same_primary_since, bl);
- ::encode(last_scrub, bl);
- ::encode(last_scrub_stamp, bl);
- }
- void decode(bufferlist::iterator &bl) {
- __u8 struct_v;
- ::decode(struct_v, bl);
- ::decode(epoch_created, bl);
- ::decode(last_epoch_started, bl);
- if (struct_v >= 3)
- ::decode(last_epoch_clean, bl);
- else
- last_epoch_clean = last_epoch_started; // careful, it's a lie!
- ::decode(last_epoch_split, bl);
- ::decode(same_interval_since, bl);
- ::decode(same_up_since, bl);
- ::decode(same_primary_since, bl);
- if (struct_v >= 2) {
- ::decode(last_scrub, bl);
- ::decode(last_scrub_stamp, bl);
- }
- }
- void dump(Formatter *f) const;
- static void generate_test_instances(list<History*>& o);
- } history;
-
Info()
: last_backfill(hobject_t::get_max())
{ }
void dump(Formatter *f) const;
static void generate_test_instances(list<Info*>& o);
};
- //WRITE_CLASS_ENCODER(Info::History)
WRITE_CLASS_ENCODER(Info)
__s32 type;
eversion_t since;
- Info::History history;
+ pg_history_t history;
Query() : type(-1) {}
- Query(int t, const Info::History& h) :
+ Query(int t, const pg_history_t& h) :
type(t), history(h) { assert(t != LOG); }
- Query(int t, eversion_t s, const Info::History& h) :
+ Query(int t, eversion_t s, const pg_history_t& h) :
type(t), since(s), history(h) { assert(t == LOG); }
void encode(bufferlist &bl) const {
utime_t expire) = 0;
};
-WRITE_CLASS_ENCODER(PG::Info::History)
WRITE_CLASS_ENCODER(PG::Info)
WRITE_CLASS_ENCODER(PG::Query)
WRITE_CLASS_ENCODER(PG::Missing::item)
WRITE_CLASS_ENCODER(PG::Interval)
WRITE_CLASS_ENCODER(PG::OndiskLog)
-inline ostream& operator<<(ostream& out, const PG::Info::History& h)
-{
- return out << "ec=" << h.epoch_created
- << " les/c " << h.last_epoch_started << "/" << h.last_epoch_clean
- << " " << h.same_up_since << "/" << h.same_interval_since << "/" << h.same_primary_since;
-}
-
inline ostream& operator<<(ostream& out, const PG::Info& pgi)
{
out << pgi.pgid << "(";
}
+// -- pg_history_t --
+
+void pg_history_t::encode(bufferlist &bl) const
+{
+ __u8 struct_v = 3;
+ ::encode(struct_v, bl);
+ ::encode(epoch_created, bl);
+ ::encode(last_epoch_started, bl);
+ ::encode(last_epoch_clean, bl);
+ ::encode(last_epoch_split, bl);
+ ::encode(same_interval_since, bl);
+ ::encode(same_up_since, bl);
+ ::encode(same_primary_since, bl);
+ ::encode(last_scrub, bl);
+ ::encode(last_scrub_stamp, bl);
+}
+
+void pg_history_t::decode(bufferlist::iterator &bl)
+{
+ __u8 struct_v;
+ ::decode(struct_v, bl);
+ ::decode(epoch_created, bl);
+ ::decode(last_epoch_started, bl);
+ if (struct_v >= 3)
+ ::decode(last_epoch_clean, bl);
+ else
+ last_epoch_clean = last_epoch_started; // careful, it's a lie!
+ ::decode(last_epoch_split, bl);
+ ::decode(same_interval_since, bl);
+ ::decode(same_up_since, bl);
+ ::decode(same_primary_since, bl);
+ if (struct_v >= 2) {
+ ::decode(last_scrub, bl);
+ ::decode(last_scrub_stamp, bl);
+ }
+}
+
+void pg_history_t::dump(Formatter *f) const
+{
+ f->dump_int("epoch_created", epoch_created);
+ f->dump_int("last_epoch_started", last_epoch_started);
+ f->dump_int("last_epoch_clean", last_epoch_clean);
+ f->dump_int("last_epoch_split", last_epoch_split);
+ f->dump_int("same_up_since", same_up_since);
+ f->dump_int("same_interval_since", same_interval_since);
+ f->dump_int("same_primary_since", same_primary_since);
+ f->dump_stream("last_scrub") << last_scrub;
+ f->dump_stream("last_scrub_stamp") << last_scrub_stamp;
+}
+
+void pg_history_t::generate_test_instances(list<pg_history_t*>& o)
+{
+ o.push_back(new pg_history_t);
+ o.push_back(new pg_history_t);
+ o.back()->epoch_created = 1;
+ o.back()->last_epoch_started = 2;
+ o.back()->last_epoch_clean = 3;
+ o.back()->last_epoch_split = 4;
+ o.back()->same_up_since = 5;
+ o.back()->same_interval_since = 6;
+ o.back()->same_primary_since = 7;
+ o.back()->last_scrub = eversion_t(8, 9);
+ o.back()->last_scrub_stamp = utime_t(10, 11);
+}
+
+
// -- OSDSuperblock --
void OSDSuperblock::encode(bufferlist &bl) const
+struct pg_history_t {
+ epoch_t epoch_created; // epoch in which PG was created
+ epoch_t last_epoch_started; // lower bound on last epoch started (anywhere, not necessarily locally)
+ epoch_t last_epoch_clean; // lower bound on last epoch the PG was completely clean.
+ epoch_t last_epoch_split; // as parent
+
+ epoch_t same_up_since; // same acting set since
+ epoch_t same_interval_since; // same acting AND up set since
+ epoch_t same_primary_since; // same primary at least back through this epoch.
+
+ eversion_t last_scrub;
+ utime_t last_scrub_stamp;
+
+ pg_history_t()
+ : epoch_created(0),
+ last_epoch_started(0), last_epoch_clean(0), last_epoch_split(0),
+ same_up_since(0), same_interval_since(0), same_primary_since(0) {}
+
+ void merge(const pg_history_t &other) {
+ // Here, we only update the fields which cannot be calculated from the OSDmap.
+ if (epoch_created < other.epoch_created)
+ epoch_created = other.epoch_created;
+ if (last_epoch_started < other.last_epoch_started)
+ last_epoch_started = other.last_epoch_started;
+ if (last_epoch_clean < other.last_epoch_clean)
+ last_epoch_clean = other.last_epoch_clean;
+ if (last_epoch_split < other.last_epoch_started)
+ last_epoch_split = other.last_epoch_started;
+ if (other.last_scrub > last_scrub)
+ last_scrub = other.last_scrub;
+ if (other.last_scrub_stamp > last_scrub_stamp)
+ last_scrub_stamp = other.last_scrub_stamp;
+ }
+
+ void encode(bufferlist& bl) const;
+ void decode(bufferlist::iterator& p);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<pg_history_t*>& o);
+};
+WRITE_CLASS_ENCODER(pg_history_t)
+
+inline ostream& operator<<(ostream& out, const pg_history_t& h) {
+ return out << "ec=" << h.epoch_created
+ << " les/c " << h.last_epoch_started << "/" << h.last_epoch_clean
+ << " " << h.same_up_since << "/" << h.same_interval_since << "/" << h.same_primary_since;
+}
+