From 6fedbf8b5cf43c4915dbc1f81ab033af977048c5 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Tue, 28 Dec 2010 15:55:24 -0800 Subject: [PATCH] osd: de-globalize PG::oldest_update Making oldest_update a class variable complicates log merging and wastes space in the PG struct. Even though memory is big, cachelines are still small. Just calculate it when we need it. Signed-off-by: Colin McCabe --- src/osd/PG.cc | 46 ++++++++++++++++++++++++++++------------------ src/osd/PG.h | 4 +++- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index e6241b14dafed..f1d42dff468b7 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -253,10 +253,6 @@ void PG::proc_replica_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, M oinfo.last_update = lu; if (lu < oinfo.last_complete) oinfo.last_complete = lu; - if (lu < oldest_update) { - dout(10) << " oldest_update now " << lu << dendl; - oldest_update = lu; - } } } @@ -348,19 +344,12 @@ void PG::merge_log(ObjectStore::Transaction& t, log.index(); // first, find split point (old log.head) in new log. - // adjust oldest_updated as needed. list::iterator p = log.log.end(); while (p != log.log.begin()) { p--; if (p->version <= log.head) { dout(10) << "merge_log split point is " << *p << dendl; - if (p->version < log.head && p->version < oldest_update) { - dout(10) << "merge_log oldest_update " << oldest_update << " -> " - << p->version << dendl; - oldest_update = p->version; - } - if (p->version == log.head) p++; // move past the split point, if it also exists in our old log... break; @@ -1386,7 +1375,8 @@ bool PG::choose_acting(int newest_update_osd) } // if false, stop. -bool PG::recover_master_log(map< int, map >& query_map) +bool PG::recover_master_log(map< int, map >& query_map, + eversion_t &oldest_update) { dout(10) << "recover_master_log" << dendl; @@ -1523,6 +1513,22 @@ bool PG::recover_master_log(map< int, map >& query_map) return true; } +eversion_t PG::calc_oldest_known_update() const +{ + eversion_t oldest_update(info.last_update); + for (map::const_iterator it = peer_info.begin(); + it != peer_info.end(); + ++it) { + if (osd->osdmap->is_down(it->first)) + continue; + if (!is_acting(it->first)) + continue; + if (it->second.last_update < oldest_update) { + oldest_update = it->second.last_update; + } + } + return oldest_update; +} void PG::do_peer(ObjectStore::Transaction& t, list& tfin, map< int, map >& query_map, @@ -1540,15 +1546,19 @@ void PG::do_peer(ObjectStore::Transaction& t, list& tfin, dout(10) << "PG::do_peer: peer prior_set is " << *prior_set << dendl; + eversion_t oldest_update; if (!have_master_log) { - if (!recover_master_log(query_map)) - return; - } else if (up != acting) { - // are we done generating backlog(s)? - if (!choose_acting(osd->whoami)) + if (!recover_master_log(query_map, oldest_update)) return; } - + else { + if (up != acting) { + // are we done generating backlog(s)? + if (!choose_acting(osd->whoami)) + return; + } + oldest_update = calc_oldest_known_update(); + } // -- do i need to generate backlog? if (!log.backlog) { diff --git a/src/osd/PG.h b/src/osd/PG.h index 80917b650e2d2..4594b782ab7e2 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -856,7 +856,9 @@ public: void trim_write_ahead(); bool choose_acting(int newest_update_osd); - bool recover_master_log(map< int, map >& query_map); + bool recover_master_log(map< int, map >& query_map, + eversion_t &oldest_update); + eversion_t calc_oldest_known_update() const; void do_peer(ObjectStore::Transaction& t, list& tfin, map< int, map >& query_map, map *activator_map=0); -- 2.39.5