diff options
-rw-r--r-- | src/messages/MOSDPGInfo.h | 2 | ||||
-rw-r--r-- | src/messages/MOSDPGLog.h | 6 | ||||
-rw-r--r-- | src/messages/MOSDPGMissing.h | 4 | ||||
-rw-r--r-- | src/messages/MOSDPGNotify.h | 8 | ||||
-rw-r--r-- | src/osd/OSD.cc | 22 | ||||
-rw-r--r-- | src/osd/OSD.h | 4 | ||||
-rw-r--r-- | src/osd/PG.cc | 112 | ||||
-rw-r--r-- | src/osd/PG.h | 151 | ||||
-rw-r--r-- | src/osd/ReplicatedPG.cc | 8 | ||||
-rw-r--r-- | src/osd/osd_types.cc | 88 | ||||
-rw-r--r-- | src/osd/osd_types.h | 67 |
11 files changed, 240 insertions, 232 deletions
diff --git a/src/messages/MOSDPGInfo.h b/src/messages/MOSDPGInfo.h index 21796f4b8cb..7e8fb57274b 100644 --- a/src/messages/MOSDPGInfo.h +++ b/src/messages/MOSDPGInfo.h @@ -23,7 +23,7 @@ class MOSDPGInfo : public Message { epoch_t epoch; public: - vector<PG::Info> pg_info; + vector<pg_info_t> pg_info; epoch_t get_epoch() { return epoch; } diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index 774e1357ae9..832e053f8b6 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -27,7 +27,7 @@ class MOSDPGLog : public Message { epoch_t query_epoch; public: - PG::Info info; + pg_info_t info; PG::Log log; PG::Missing missing; @@ -36,10 +36,10 @@ public: epoch_t get_query_epoch() { return query_epoch; } MOSDPGLog() {} - MOSDPGLog(version_t mv, PG::Info& i) : + MOSDPGLog(version_t mv, pg_info_t& i) : Message(MSG_OSD_PG_LOG), epoch(mv), query_epoch(mv), info(i) { } - MOSDPGLog(version_t mv, PG::Info& i, epoch_t query_epoch) : + MOSDPGLog(version_t mv, pg_info_t& i, epoch_t query_epoch) : Message(MSG_OSD_PG_LOG), epoch(mv), query_epoch(query_epoch), info(i) { } private: diff --git a/src/messages/MOSDPGMissing.h b/src/messages/MOSDPGMissing.h index 17b6bdb8f82..55debebf30f 100644 --- a/src/messages/MOSDPGMissing.h +++ b/src/messages/MOSDPGMissing.h @@ -22,13 +22,13 @@ class MOSDPGMissing : public Message { epoch_t epoch; public: - PG::Info info; + pg_info_t info; PG::Missing missing; epoch_t get_epoch() { return epoch; } MOSDPGMissing() {} - MOSDPGMissing(version_t mv, const PG::Info &info_, + MOSDPGMissing(version_t mv, const pg_info_t &info_, const PG::Missing &missing_) : Message(MSG_OSD_PG_MISSING), epoch(mv), info(info_), missing(missing_) { } diff --git a/src/messages/MOSDPGNotify.h b/src/messages/MOSDPGNotify.h index 3ea09b97adb..9c022d2443b 100644 --- a/src/messages/MOSDPGNotify.h +++ b/src/messages/MOSDPGNotify.h @@ -30,15 +30,15 @@ class MOSDPGNotify : public Message { /// query. This allows the recipient to disregard responses to old /// queries. epoch_t query_epoch; - vector<PG::Info> pg_list; // pgid -> version + vector<pg_info_t> pg_list; // pgid -> version public: version_t get_epoch() { return epoch; } - vector<PG::Info>& get_pg_list() { return pg_list; } + vector<pg_info_t>& get_pg_list() { return pg_list; } epoch_t get_query_epoch() { return query_epoch; } MOSDPGNotify() {} - MOSDPGNotify(epoch_t e, vector<PG::Info>& l, epoch_t query_epoch) : + MOSDPGNotify(epoch_t e, vector<pg_info_t>& l, epoch_t query_epoch) : Message(MSG_OSD_PG_NOTIFY), epoch(e), query_epoch(query_epoch) { pg_list.swap(l); @@ -65,7 +65,7 @@ public: } void print(ostream& out) const { out << "pg_notify("; - for (vector<PG::Info>::const_iterator i = pg_list.begin(); + for (vector<pg_info_t>::const_iterator i = pg_list.begin(); i != pg_list.end(); ++i) { if (i != pg_list.begin()) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d40ddb2dfda..316e7ca5c13 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1206,7 +1206,7 @@ void OSD::load_pgs() * look up a pg. if we have it, great. if not, consider creating it IF the pg mapping * hasn't changed since the given epoch and we are the primary. */ -PG *OSD::get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& created, +PG *OSD::get_or_create_pg(const pg_info_t& info, epoch_t epoch, int from, int& created, bool primary, ObjectStore::Transaction **pt, C_Contexts **pfin) @@ -1464,7 +1464,7 @@ void OSD::update_heartbeat_peers() _add_heartbeat_source(pg->acting[i], old_from, old_from_stamp, old_con); for (unsigned i=0; i<pg->up.size(); i++) _add_heartbeat_source(pg->up[i], old_from, old_from_stamp, old_con); - for (map<int,PG::Info>::iterator p = pg->peer_info.begin(); p != pg->peer_info.end(); ++p) + for (map<int,pg_info_t>::iterator p = pg->peer_info.begin(); p != pg->peer_info.end(); ++p) if (osdmap->is_up(p->first)) _add_heartbeat_source(p->first, old_from, old_from_stamp, old_con); } @@ -3599,7 +3599,7 @@ void OSD::activate_map(ObjectStore::Transaction& t, list<Context*>& tfin) dout(7) << "activate_map version " << osdmap->get_epoch() << dendl; - map< int, vector<PG::Info> > notify_list; // primary -> list + map< int, vector<pg_info_t> > notify_list; // primary -> list map< int, map<pg_t,PG::Query> > query_map; // peer -> PG -> get_summary_since map<int,MOSDPGInfo*> info_map; // peer -> message @@ -4272,10 +4272,10 @@ void OSD::handle_pg_create(MOSDPGCreate *m) * content for, and they are primary for. */ -void OSD::do_notifies(map< int, vector<PG::Info> >& notify_list, +void OSD::do_notifies(map< int, vector<pg_info_t> >& notify_list, epoch_t query_epoch) { - for (map< int, vector<PG::Info> >::iterator it = notify_list.begin(); + for (map< int, vector<pg_info_t> >::iterator it = notify_list.begin(); it != notify_list.end(); it++) { if (it->first == whoami) { @@ -4316,7 +4316,7 @@ void OSD::do_infos(map<int,MOSDPGInfo*>& info_map) for (map<int,MOSDPGInfo*>::iterator p = info_map.begin(); p != info_map.end(); ++p) { - for (vector<PG::Info>::iterator i = p->second->pg_info.begin(); + for (vector<pg_info_t>::iterator i = p->second->pg_info.begin(); i != p->second->pg_info.end(); ++i) { dout(20) << "Sending info " << *i << " to osd." << p->first << dendl; @@ -4329,7 +4329,7 @@ void OSD::do_infos(map<int,MOSDPGInfo*>& info_map) /** PGNotify * from non-primary to primary - * includes PG::Info. + * includes pg_info_t. * NOTE: called with opqueue active. */ void OSD::handle_pg_notify(MOSDPGNotify *m) @@ -4347,7 +4347,7 @@ void OSD::handle_pg_notify(MOSDPGNotify *m) map<int, MOSDPGInfo*> info_map; int created = 0; - for (vector<PG::Info>::iterator it = m->get_pg_list().begin(); + for (vector<pg_info_t>::iterator it = m->get_pg_list().begin(); it != m->get_pg_list().end(); it++) { PG *pg = 0; @@ -4442,7 +4442,7 @@ void OSD::handle_pg_info(MOSDPGInfo *m) int created = 0; - for (vector<PG::Info>::iterator p = m->pg_info.begin(); + for (vector<pg_info_t>::iterator p = m->pg_info.begin(); p != m->pg_info.end(); ++p) { ObjectStore::Transaction *t = 0; @@ -4641,7 +4641,7 @@ void OSD::handle_pg_query(MOSDPGQuery *m) if (!require_same_or_newer_map(m, m->get_epoch())) return; - map< int, vector<PG::Info> > notify_list; + map< int, vector<pg_info_t> > notify_list; for (map<pg_t,PG::Query>::iterator it = m->pg_list.begin(); it != m->pg_list.end(); @@ -4667,7 +4667,7 @@ void OSD::handle_pg_query(MOSDPGQuery *m) assert(role != 0); dout(10) << " pg " << pgid << " dne" << dendl; - PG::Info empty(pgid); + pg_info_t empty(pgid); if (it->second.type == PG::Query::LOG || it->second.type == PG::Query::FULLLOG) { MOSDPGLog *mlog = new MOSDPGLog(osdmap->get_epoch(), empty, diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 1fad6389ce8..5b301831b89 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -436,7 +436,7 @@ protected: PG *lookup_lock_raw_pg(pg_t pgid); - PG *get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& pcreated, bool primary, + PG *get_or_create_pg(const pg_info_t& info, epoch_t epoch, int from, int& pcreated, bool primary, ObjectStore::Transaction **pt, C_Contexts **pfin); @@ -579,7 +579,7 @@ protected: // -- generic pg peering -- - void do_notifies(map< int, vector<PG::Info> >& notify_list, + void do_notifies(map< int, vector<pg_info_t> >& notify_list, epoch_t query_epoch); void do_queries(map< int, map<pg_t,PG::Query> >& query_map); void do_infos(map<int, MOSDPGInfo*>& info_map); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 221681a5cf6..d39171c356b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -70,46 +70,6 @@ std::string PG::gen_prefix() const } -/******* PG::Info *******/ - -void PG::Info::dump(Formatter *f) const -{ - f->dump_stream("pgid") << pgid; - f->dump_stream("last_update") << last_update; - f->dump_stream("last_complete") << last_complete; - f->dump_stream("log_tail") << log_tail; - f->dump_stream("last_backfill") << last_backfill; - f->dump_stream("purged_snaps") << purged_snaps; - f->open_object_section("history"); - history.dump(f); - f->close_section(); - f->open_object_section("stats"); - stats.dump(f); - f->close_section(); - - f->dump_int("empty", is_empty()); - f->dump_int("dne", dne()); - f->dump_int("incomplete", is_incomplete()); -} - -void PG::Info::generate_test_instances(list<PG::Info*>& o) -{ - o.push_back(new Info); - o.push_back(new Info); - 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()->last_complete = eversion_t(5, 6); - o.back()->log_tail = eversion_t(7, 8); - o.back()->last_backfill = hobject_t(object_t("objname"), "key", 123, 456); - list<pg_stat_t*> s; - pg_stat_t::generate_test_instances(s); - o.back()->stats = *s.back(); -} - - /******* PG::Log ********/ void PG::Log::copy_after(const Log &other, eversion_t v) @@ -189,7 +149,7 @@ void PG::IndexedLog::trim(ObjectStore::Transaction& t, eversion_t s) /********* PG **********/ -void PG::proc_master_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, Missing& omissing, int from) +void PG::proc_master_log(ObjectStore::Transaction& t, pg_info_t &oinfo, Log &olog, Missing& omissing, int from) { dout(10) << "proc_master_log for osd." << from << ": " << olog << " " << omissing << dendl; assert(!is_active() && is_primary()); @@ -208,7 +168,7 @@ void PG::proc_master_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, Mi } void PG::proc_replica_log(ObjectStore::Transaction& t, - Info &oinfo, Log &olog, Missing& omissing, int from) + pg_info_t &oinfo, Log &olog, Missing& omissing, int from) { dout(10) << "proc_replica_log for osd." << from << ": " << oinfo << " " << olog << " " << omissing << dendl; @@ -313,9 +273,9 @@ void PG::proc_replica_log(ObjectStore::Transaction& t, peer_missing[from].swap(omissing); } -bool PG::proc_replica_info(int from, Info &oinfo) +bool PG::proc_replica_info(int from, pg_info_t &oinfo) { - map<int,PG::Info>::iterator p = peer_info.find(from); + map<int,pg_info_t>::iterator p = peer_info.find(from); if (p != peer_info.end() && p->second.last_update == oinfo.last_update) { dout(10) << " got dup osd." << from << " info " << oinfo << ", identical to ours" << dendl; return false; @@ -403,7 +363,7 @@ bool PG::merge_old_entry(ObjectStore::Transaction& t, Log::Entry& oe) } void PG::merge_log(ObjectStore::Transaction& t, - Info &oinfo, Log &olog, int fromosd) + pg_info_t &oinfo, Log &olog, int fromosd) { dout(10) << "merge_log " << olog << " from osd." << fromosd << " into " << log << dendl; @@ -539,7 +499,7 @@ void PG::merge_log(ObjectStore::Transaction& t, * TODO: if the missing set becomes very large, this could get expensive. * Instead, we probably want to just iterate over our unfound set. */ -bool PG::search_for_missing(const Info &oinfo, const Missing *omissing, +bool PG::search_for_missing(const pg_info_t &oinfo, const Missing *omissing, int fromosd) { bool stats_updated = false; @@ -721,7 +681,7 @@ bool PG::is_all_uptodate() const dout(10) << __func__ << ": osd." << peer << " has " << pm->second.num_missing() << " missing" << dendl; uptodate = false; } - map<int,Info>::const_iterator pi = peer_info.find(peer); + map<int,pg_info_t>::const_iterator pi = peer_info.find(peer); if (pi->second.last_backfill != hobject_t::get_max()) { dout(10) << __func__ << ": osd." << peer << " has last_backfill " << pi->second.last_backfill << dendl; uptodate = false; @@ -877,7 +837,7 @@ void PG::build_prior(std::auto_ptr<PriorSet> &prior_set) { if (1) { // sanity check - for (map<int,Info>::iterator it = peer_info.begin(); + for (map<int,pg_info_t>::iterator it = peer_info.begin(); it != peer_info.end(); it++) { assert(info.history.last_epoch_started >= it->second.history.last_epoch_started); @@ -948,13 +908,13 @@ void PG::clear_primary_state() * 2) Prefer longer tail if it brings another info into contiguity * 3) Prefer current primary */ -map<int, PG::Info>::const_iterator PG::find_best_info(const map<int, Info> &infos) const +map<int, pg_info_t>::const_iterator PG::find_best_info(const map<int, pg_info_t> &infos) const { - map<int, Info>::const_iterator best = infos.end(); + map<int, pg_info_t>::const_iterator best = infos.end(); // find osd with newest last_update. if there are multiples, prefer // - a longer tail, if it brings another peer into log contiguity // - the current primary - for (map<int, Info>::const_iterator p = infos.begin(); + for (map<int, pg_info_t>::const_iterator p = infos.begin(); p != infos.end(); ++p) { // Disquality anyone who is incomplete (not fully backfilled) @@ -972,7 +932,7 @@ map<int, PG::Info>::const_iterator PG::find_best_info(const map<int, Info> &info continue; } // Prefer longer tail if it brings another peer into contiguity - for (map<int, Info>::const_iterator q = infos.begin(); + for (map<int, pg_info_t>::const_iterator q = infos.begin(); q != infos.end(); ++q) { if (q->second.is_incomplete()) @@ -1009,14 +969,14 @@ map<int, PG::Info>::const_iterator PG::find_best_info(const map<int, Info> &info */ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const { - map<int, Info> all_info(peer_info.begin(), peer_info.end()); + map<int, pg_info_t> all_info(peer_info.begin(), peer_info.end()); all_info[osd->whoami] = info; - for (map<int,Info>::iterator p = all_info.begin(); p != all_info.end(); ++p) { + for (map<int,pg_info_t>::iterator p = all_info.begin(); p != all_info.end(); ++p) { dout(10) << "calc_acting osd." << p->first << " " << p->second << dendl; } - map<int, Info>::const_iterator newest_update_osd = find_best_info(all_info); + map<int, pg_info_t>::const_iterator newest_update_osd = find_best_info(all_info); if (newest_update_osd == all_info.end()) { if (up != acting) { @@ -1035,7 +995,7 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const newest_update_osd_id = newest_update_osd->first; // select primary - map<int,Info>::const_iterator primary; + map<int,pg_info_t>::const_iterator primary; if (up.size() && !all_info[up[0]].is_incomplete() && all_info[up[0]].last_update >= newest_update_osd->second.log_tail) { @@ -1046,8 +1006,8 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const << " selected as primary instead" << dendl; primary = newest_update_osd; } else { - map<int, Info> complete_infos; - for (map<int, Info>::iterator i = all_info.begin(); + map<int, pg_info_t> complete_infos; + for (map<int, pg_info_t>::iterator i = all_info.begin(); i != all_info.end(); ++i) { if (!i->second.is_incomplete()) @@ -1079,7 +1039,7 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const ++i) { if (*i == primary->first) continue; - const Info &cur_info = all_info.find(*i)->second; + const pg_info_t &cur_info = all_info.find(*i)->second; if (cur_info.is_incomplete() || cur_info.last_update < primary->second.log_tail) { if (backfill < 1) { dout(10) << " osd." << *i << " (up) accepted (backfill) " << cur_info << dendl; @@ -1095,7 +1055,7 @@ bool PG::calc_acting(int& newest_update_osd_id, vector<int>& want) const } } - for (map<int,Info>::const_iterator i = all_info.begin(); + for (map<int,pg_info_t>::const_iterator i = all_info.begin(); i != all_info.end(); ++i) { if (usable >= get_osdmap()->get_pg_size(info.pgid)) @@ -1191,7 +1151,7 @@ void PG::build_might_have_unfound() } // include any (stray) peers - for (map<int,Info>::iterator p = peer_info.begin(); + for (map<int,pg_info_t>::iterator p = peer_info.begin(); p != peer_info.end(); p++) might_have_unfound.insert(p->first); @@ -1314,7 +1274,7 @@ void PG::activate(ObjectStore::Transaction& t, list<Context*>& tfin, for (unsigned i=1; i<acting.size(); i++) { int peer = acting[i]; assert(peer_info.count(peer)); - PG::Info& pi = peer_info[peer]; + pg_info_t& pi = peer_info[peer]; dout(10) << "activate peer osd." << peer << " " << pi << dendl; @@ -1464,7 +1424,7 @@ void PG::_activate_committed(epoch_t e) epoch_t cur_epoch = get_osdmap()->get_epoch(); entity_inst_t primary = get_osdmap()->get_cluster_inst(acting[0]); MOSDPGInfo *m = new MOSDPGInfo(cur_epoch); - PG::Info i = info; + pg_info_t i = info; i.history.last_epoch_started = e; m->pg_info.push_back(i); osd->cluster_messenger->send_message(m, primary); @@ -3116,7 +3076,7 @@ void PG::share_pg_info() { dout(10) << "share_pg_info" << dendl; - // share new PG::Info with replicas + // share new pg_info_t with replicas for (unsigned i=1; i<acting.size(); i++) { int peer = acting[i]; MOSDPGInfo *m = new MOSDPGInfo(get_osdmap()->get_epoch()); @@ -3141,7 +3101,7 @@ void PG::share_pg_log() while (++a != end) { int peer(*a); PG::Missing& pmissing(peer_missing[peer]); - PG::Info& pinfo(peer_info[peer]); + pg_info_t& pinfo(peer_info[peer]); MOSDPGLog *m = new MOSDPGLog(info.last_update.epoch, info); m->log.copy_after(log, pinfo.last_update); @@ -3158,7 +3118,7 @@ void PG::share_pg_log() } void PG::fulfill_info(int from, const Query &query, - pair<int, Info> ¬ify_info) + pair<int, pg_info_t> ¬ify_info) { assert(!acting.empty()); assert(from == acting[0]); @@ -3467,7 +3427,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap, } } -void PG::proc_primary_info(ObjectStore::Transaction &t, const Info &oinfo) +void PG::proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &oinfo) { assert(!is_primary()); assert(is_stray() || is_active()); @@ -3860,7 +3820,7 @@ boost::statechart::result PG::RecoveryState::Primary::react(const AdvMap& advmap OSDMapRef osdmap = advmap.osdmap; // Remove any downed osds from peer_info - map<int,PG::Info>::iterator p = pg->peer_info.begin(); + map<int,pg_info_t>::iterator p = pg->peer_info.begin(); while (p != pg->peer_info.end()) { if (!osdmap->is_up(p->first)) { dout(10) << " dropping down osd." << p->first << " info " << p->second << dendl; @@ -4191,7 +4151,7 @@ boost::statechart::result PG::RecoveryState::Stray::react(const MQuery& query) { PG *pg = context< RecoveryMachine >().pg; if (query.query.type == Query::INFO) { - pair<int, Info> notify_info; + pair<int, pg_info_t> notify_info; pg->fulfill_info(query.from, query.query, notify_info); context< RecoveryMachine >().send_notify(notify_info.first, notify_info.second); } else { @@ -4316,7 +4276,7 @@ boost::statechart::result PG::RecoveryState::GetInfo::react(const MNotifyRec& in if (!osdmap->exists(o) || osdmap->get_info(o).lost_at > interval.first) continue; // dne or lost if (osdmap->is_up(o)) { - PG::Info *pinfo; + pg_info_t *pinfo; if (o == pg->osd->whoami) { pinfo = &pg->info; } else { @@ -4370,7 +4330,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) : return; } - const Info& best = pg->peer_info[newest_update_osd]; + const pg_info_t& best = pg->peer_info[newest_update_osd]; // am i broken? if (pg->info.last_update < best.log_tail) { @@ -4382,7 +4342,7 @@ PG::RecoveryState::GetLog::GetLog(my_context ctx) : // how much log to request? eversion_t request_log_from = pg->info.last_update; for (vector<int>::iterator p = pg->acting.begin() + 1; p != pg->acting.end(); ++p) { - Info& ri = pg->peer_info[*p]; + pg_info_t& ri = pg->peer_info[*p]; if (ri.last_update >= best.log_tail && ri.last_update < request_log_from) request_log_from = ri.last_update; } @@ -4495,7 +4455,7 @@ PG::RecoveryState::GetMissing::GetMissing(my_context ctx) for (vector<int>::iterator i = pg->acting.begin() + 1; i != pg->acting.end(); ++i) { - const Info& pi = pg->peer_info[*i]; + const pg_info_t& pi = pg->peer_info[*i]; if (pi.is_empty()) continue; // no pg data, nothing divergent @@ -4635,7 +4595,7 @@ void PG::RecoveryState::RecoveryMachine::log_exit(const char *state_name, utime_ #undef dout_prefix #define dout_prefix *_dout << machine.pg->gen_prefix() -void PG::RecoveryState::handle_notify(int from, PG::Info& i, +void PG::RecoveryState::handle_notify(int from, pg_info_t& i, RecoveryCtx *rctx) { dout(10) << "handle_notify " << i << " from osd." << from << dendl; @@ -4644,7 +4604,7 @@ void PG::RecoveryState::handle_notify(int from, PG::Info& i, end_handle(); } -void PG::RecoveryState::handle_info(int from, PG::Info& i, +void PG::RecoveryState::handle_info(int from, pg_info_t& i, RecoveryCtx *rctx) { dout(10) << "handle_info " << i << " from osd." << from << dendl; @@ -4723,7 +4683,7 @@ PG::PriorSet::PriorSet(const OSDMap &osdmap, const map<epoch_t, Interval> &past_intervals, const vector<int> &up, const vector<int> &acting, - const PG::Info &info, + const pg_info_t &info, const PG *debug_pg) : pg_down(false) { diff --git a/src/osd/PG.h b/src/osd/PG.h index 12db39687dd..9d519c7ced2 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -159,91 +159,7 @@ public: std::string gen_prefix() const; - /* - * PG::Info - summary of PG statistics. - * - * some notes: - * - last_complete implies we have all objects that existed as of that - * stamp, OR a newer object, OR have already applied a later delete. - * - if last_complete >= log.bottom, then we know pg contents thru log.head. - * otherwise, we have no idea what the pg is supposed to contain. - */ - struct Info { - pg_t pgid; - eversion_t last_update; // last object version applied to store. - eversion_t last_complete; // last version pg was complete through. - - eversion_t log_tail; // oldest log entry. - - hobject_t last_backfill; // objects >= this and < last_complete may be missing - - interval_set<snapid_t> purged_snaps; - - pg_stat_t stats; - - pg_history_t history; - - Info() - : last_backfill(hobject_t::get_max()) - { } - Info(pg_t p) - : pgid(p), - last_backfill(hobject_t::get_max()) - { } - - bool is_empty() const { return last_update.version == 0; } - bool dne() const { return history.epoch_created == 0; } - - bool is_incomplete() const { return last_backfill != hobject_t::get_max(); } - void encode(bufferlist &bl) const { - __u8 v = 25; - ::encode(v, bl); - - ::encode(pgid, bl); - ::encode(last_update, bl); - ::encode(last_complete, bl); - ::encode(log_tail, bl); - ::encode(last_backfill, bl); - ::encode(stats, bl); - history.encode(bl); - ::encode(purged_snaps, bl); - } - void decode(bufferlist::iterator &bl) { - __u8 v; - ::decode(v, bl); - - if (v < 23) { - old_pg_t opgid; - ::decode(opgid, bl); - pgid = opgid; - } else { - ::decode(pgid, bl); - } - ::decode(last_update, bl); - ::decode(last_complete, bl); - ::decode(log_tail, bl); - if (v < 25) { - bool log_backlog; - ::decode(log_backlog, bl); - } - if (v >= 24) - ::decode(last_backfill, bl); - ::decode(stats, bl); - history.decode(bl); - if (v >= 22) - ::decode(purged_snaps, bl); - else { - set<snapid_t> snap_trimq; - ::decode(snap_trimq, bl); - } - } - void dump(Formatter *f) const; - static void generate_test_instances(list<Info*>& o); - }; - WRITE_CLASS_ENCODER(Info) - - /** * Query - used to ask a peer for information about a pg. * @@ -843,7 +759,7 @@ public: WRITE_CLASS_ENCODER(Interval) // pg state - Info info; + pg_info_t info; const coll_t coll; IndexedLog log; hobject_t log_oid; @@ -898,7 +814,7 @@ public: const map<epoch_t, Interval> &past_intervals, const vector<int> &up, const vector<int> &acting, - const Info &info, + const pg_info_t &info, const PG *debug_pg=NULL); bool affected_by_map(const OSDMapRef osdmap, const PG *debug_pg=0) const; @@ -915,14 +831,14 @@ public: utime_t start_time; map< int, map<pg_t, Query> > *query_map; map< int, MOSDPGInfo* > *info_map; - map< int, vector<Info> > *notify_list; + map< int, vector<pg_info_t> > *notify_list; list< Context* > *context_list; ObjectStore::Transaction *transaction; RecoveryCtx() : query_map(0), info_map(0), notify_list(0), context_list(0), transaction(0) {} RecoveryCtx(map< int, map<pg_t, Query> > *query_map, map< int, MOSDPGInfo* > *info_map, - map< int, vector<Info> > *notify_list, + map< int, vector<pg_info_t> > *notify_list, list< Context* > *context_list, ObjectStore::Transaction *transaction) : query_map(query_map), info_map(info_map), @@ -959,8 +875,8 @@ public: struct MInfoRec : boost::statechart::event< MInfoRec > { int from; - Info &info; - MInfoRec(int from, Info &info) : + pg_info_t &info; + MInfoRec(int from, pg_info_t &info) : from(from), info(info) {} }; @@ -973,8 +889,8 @@ public: struct MNotifyRec : boost::statechart::event< MNotifyRec > { int from; - Info &info; - MNotifyRec(int from, Info &info) : + pg_info_t &info; + MNotifyRec(int from, pg_info_t &info) : from(from), info(info) {} }; @@ -1063,7 +979,7 @@ public: return state->rctx->context_list; } - void send_notify(int to, const Info &info) { + void send_notify(int to, const pg_info_t &info) { assert(state->rctx->notify_list); (*state->rctx->notify_list)[to].push_back(info); } @@ -1340,8 +1256,8 @@ public: machine.initiate(); } - void handle_notify(int from, Info& i, RecoveryCtx *ctx); - void handle_info(int from, Info& i, RecoveryCtx *ctx); + void handle_notify(int from, pg_info_t& i, RecoveryCtx *ctx); + void handle_info(int from, pg_info_t& i, RecoveryCtx *ctx); void handle_log(int from, MOSDPGLog *msg, RecoveryCtx *ctx); @@ -1367,7 +1283,7 @@ protected: bool need_up_thru; set<int> stray_set; // non-acting osds that have PG data. eversion_t oldest_update; // acting: lowest (valid) last_update in active set - map<int,Info> peer_info; // info from peers (stray or prior) + map<int,pg_info_t> peer_info; // info from peers (stray or prior) map<int, Missing> peer_missing; set<int> peer_log_requested; // logs i've requested (and start stamps) set<int> peer_missing_requested; @@ -1517,14 +1433,14 @@ public: virtual void calc_trim_to() = 0; - void proc_replica_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, + void proc_replica_log(ObjectStore::Transaction& t, pg_info_t &oinfo, Log &olog, Missing& omissing, int from); - void proc_master_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, + void proc_master_log(ObjectStore::Transaction& t, pg_info_t &oinfo, Log &olog, Missing& omissing, int from); - bool proc_replica_info(int from, Info &info); + bool proc_replica_info(int from, pg_info_t &info); bool merge_old_entry(ObjectStore::Transaction& t, Log::Entry& oe); - void merge_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, int from); - bool search_for_missing(const Info &oinfo, const Missing *omissing, + void merge_log(ObjectStore::Transaction& t, pg_info_t &oinfo, Log &olog, int from); + bool search_for_missing(const pg_info_t &oinfo, const Missing *omissing, int fromosd); void check_for_lost_objects(); @@ -1534,7 +1450,7 @@ public: void trim_write_ahead(); - map<int, Info>::const_iterator find_best_info(const map<int, Info> &infos) const; + map<int, pg_info_t>::const_iterator find_best_info(const map<int, pg_info_t> &infos) const; bool calc_acting(int& newest_update_osd, vector<int>& want) const; bool choose_acting(int& newest_update_osd); void build_might_have_unfound(); @@ -1545,7 +1461,7 @@ public: void _activate_committed(epoch_t e); void all_activated_and_committed(); - void proc_primary_info(ObjectStore::Transaction &t, const Info &info); + void proc_primary_info(ObjectStore::Transaction &t, const pg_info_t &info); bool have_unfound() const { return missing.num_missing() > missing_loc.size(); @@ -1724,16 +1640,16 @@ public: void set_last_peering_reset(); void fulfill_info(int from, const Query &query, - pair<int, Info> ¬ify_info); + pair<int, pg_info_t> ¬ify_info); void fulfill_log(int from, const Query &query, epoch_t query_epoch); bool acting_up_affected(const vector<int>& newup, const vector<int>& newacting); bool old_peering_msg(epoch_t reply_epoch, epoch_t query_epoch); // recovery bits - void handle_notify(int from, PG::Info& i, RecoveryCtx *rctx) { + void handle_notify(int from, pg_info_t& i, RecoveryCtx *rctx) { recovery_state.handle_notify(from, i, rctx); } - void handle_info(int from, PG::Info& i, RecoveryCtx *rctx) { + void handle_info(int from, pg_info_t& i, RecoveryCtx *rctx) { recovery_state.handle_info(from, i, rctx); } void handle_log(int from, @@ -1793,7 +1709,6 @@ public: utime_t expire) = 0; }; -WRITE_CLASS_ENCODER(PG::Info) WRITE_CLASS_ENCODER(PG::Query) WRITE_CLASS_ENCODER(PG::Missing::item) WRITE_CLASS_ENCODER(PG::Missing) @@ -1802,28 +1717,6 @@ WRITE_CLASS_ENCODER(PG::Log) WRITE_CLASS_ENCODER(PG::Interval) WRITE_CLASS_ENCODER(PG::OndiskLog) -inline ostream& operator<<(ostream& out, const PG::Info& pgi) -{ - out << pgi.pgid << "("; - if (pgi.dne()) - out << " DNE"; - if (pgi.is_empty()) - out << " empty"; - else { - out << " v " << pgi.last_update; - if (pgi.last_complete != pgi.last_update) - out << " lc " << pgi.last_complete; - out << " (" << pgi.log_tail << "," << pgi.last_update << "]"; - if (pgi.is_incomplete()) - out << " lb " << pgi.last_backfill; - } - //out << " c " << pgi.epoch_created; - out << " n=" << pgi.stats.stats.sum.num_objects; - out << " " << pgi.history - << ")"; - return out; -} - inline ostream& operator<<(ostream& out, const PG::Query& q) { out << "query(" << q.get_type_name() << " " << q.since; diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index d9234651fe6..1a05c40e622 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -580,7 +580,7 @@ void ReplicatedPG::do_op(MOSDOp *op) // operation won't apply properly on the backfill_target. (the // opposite is not a problem; if the target is after the line, we // don't apply on the backfill_target and it doesn't matter.) - Info *backfill_target_info = NULL; + pg_info_t *backfill_target_info = NULL; bool before_backfill = false; if (backfill_target >= 0) { backfill_target_info = &peer_info[backfill_target]; @@ -2769,7 +2769,7 @@ int ReplicatedPG::prepare_transaction(OpContext *ctx) info.stats.stats.add(ctx->delta_stats, ctx->obc->obs.oi.category); if (backfill_target >= 0) { - Info& pinfo = peer_info[backfill_target]; + pg_info_t& pinfo = peer_info[backfill_target]; if (soid < pinfo.last_backfill) pinfo.stats.stats.add(ctx->delta_stats, ctx->obc->obs.oi.category); else if (soid < backfill_pos) @@ -3035,7 +3035,7 @@ void ReplicatedPG::issue_repop(RepGather *repop, utime_t now, for (unsigned i=1; i<acting.size(); i++) { int peer = acting[i]; - Info &pinfo = peer_info[peer]; + pg_info_t &pinfo = peer_info[peer]; repop->waitfor_ack.insert(peer); repop->waitfor_disk.insert(peer); @@ -5470,7 +5470,7 @@ int ReplicatedPG::recover_backfill(int max) dout(10) << "recover_backfill (" << max << ")" << dendl; assert(backfill_target >= 0); - Info& pinfo = peer_info[backfill_target]; + pg_info_t& pinfo = peer_info[backfill_target]; BackfillInterval& pbi = peer_backfill_info; // Initialize from prior backfill state diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 788f97db858..bc686486545 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -997,6 +997,94 @@ void pg_history_t::generate_test_instances(list<pg_history_t*>& o) } +// -- pg_info_t -- + +void pg_info_t::encode(bufferlist &bl) const +{ + __u8 v = 25; + ::encode(v, bl); + + ::encode(pgid, bl); + ::encode(last_update, bl); + ::encode(last_complete, bl); + ::encode(log_tail, bl); + ::encode(last_backfill, bl); + ::encode(stats, bl); + history.encode(bl); + ::encode(purged_snaps, bl); +} + +void pg_info_t::decode(bufferlist::iterator &bl) +{ + __u8 v; + ::decode(v, bl); + + if (v < 23) { + old_pg_t opgid; + ::decode(opgid, bl); + pgid = opgid; + } else { + ::decode(pgid, bl); + } + ::decode(last_update, bl); + ::decode(last_complete, bl); + ::decode(log_tail, bl); + if (v < 25) { + bool log_backlog; + ::decode(log_backlog, bl); + } + if (v >= 24) + ::decode(last_backfill, bl); + ::decode(stats, bl); + history.decode(bl); + if (v >= 22) + ::decode(purged_snaps, bl); + else { + set<snapid_t> snap_trimq; + ::decode(snap_trimq, bl); + } +} + +/******* PG::Info *******/ + +void pg_info_t::dump(Formatter *f) const +{ + f->dump_stream("pgid") << pgid; + f->dump_stream("last_update") << last_update; + f->dump_stream("last_complete") << last_complete; + f->dump_stream("log_tail") << log_tail; + f->dump_stream("last_backfill") << last_backfill; + f->dump_stream("purged_snaps") << purged_snaps; + f->open_object_section("history"); + history.dump(f); + f->close_section(); + f->open_object_section("stats"); + stats.dump(f); + f->close_section(); + + f->dump_int("empty", is_empty()); + f->dump_int("dne", dne()); + f->dump_int("incomplete", is_incomplete()); +} + +void pg_info_t::generate_test_instances(list<pg_info_t*>& o) +{ + o.push_back(new pg_info_t); + o.push_back(new pg_info_t); + 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()->last_complete = eversion_t(5, 6); + o.back()->log_tail = eversion_t(7, 8); + o.back()->last_backfill = hobject_t(object_t("objname"), "key", 123, 456); + list<pg_stat_t*> s; + pg_stat_t::generate_test_instances(s); + o.back()->stats = *s.back(); +} + + // -- OSDSuperblock -- void OSDSuperblock::encode(bufferlist &bl) const diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 43fe6119f9e..0d14ab52da2 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -892,6 +892,73 @@ inline ostream& operator<<(ostream& out, const pg_history_t& h) { } +/** + * pg_info_t - summary of PG statistics. + * + * some notes: + * - last_complete implies we have all objects that existed as of that + * stamp, OR a newer object, OR have already applied a later delete. + * - if last_complete >= log.bottom, then we know pg contents thru log.head. + * otherwise, we have no idea what the pg is supposed to contain. + */ +struct pg_info_t { + pg_t pgid; + eversion_t last_update; // last object version applied to store. + eversion_t last_complete; // last version pg was complete through. + + eversion_t log_tail; // oldest log entry. + + hobject_t last_backfill; // objects >= this and < last_complete may be missing + + interval_set<snapid_t> purged_snaps; + + pg_stat_t stats; + + pg_history_t history; + + pg_info_t() + : last_backfill(hobject_t::get_max()) + { } + pg_info_t(pg_t p) + : pgid(p), + last_backfill(hobject_t::get_max()) + { } + + bool is_empty() const { return last_update.version == 0; } + bool dne() const { return history.epoch_created == 0; } + + bool is_incomplete() const { return last_backfill != hobject_t::get_max(); } + + void encode(bufferlist& bl) const; + void decode(bufferlist::iterator& p); + void dump(Formatter *f) const; + static void generate_test_instances(list<pg_info_t*>& o); +}; +WRITE_CLASS_ENCODER(pg_info_t) + +inline ostream& operator<<(ostream& out, const pg_info_t& pgi) +{ + out << pgi.pgid << "("; + if (pgi.dne()) + out << " DNE"; + if (pgi.is_empty()) + out << " empty"; + else { + out << " v " << pgi.last_update; + if (pgi.last_complete != pgi.last_update) + out << " lc " << pgi.last_complete; + out << " (" << pgi.log_tail << "," << pgi.last_update << "]"; + if (pgi.is_incomplete()) + out << " lb " << pgi.last_backfill; + } + //out << " c " << pgi.epoch_created; + out << " n=" << pgi.stats.stats.sum.num_objects; + out << " " << pgi.history + << ")"; + return out; +} + + struct osd_peer_stat_t { |