From e42e3d121d9005c681dedc941d53929305896004 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 12 Dec 2008 15:00:34 -0800 Subject: [PATCH] osd: simplify master log recreation; fix up Log::copy_after Pull log from a given point from peer with the largest last_update. Do not worry about divergence on the peer; that is handled by the new primary. Simplifies PG::Query struct. Fix copy_after to set an accurate .bottom, and to behave if the split point given is divergent (i.e. doesn't actually appear in the log). --- src/osd/OSD.cc | 7 +++++-- src/osd/PG.cc | 12 ++++++++---- src/osd/PG.h | 14 +++++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index f2a32f1c56a68..bfe66a532a2e1 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2999,14 +2999,17 @@ void OSD::handle_pg_query(MOSDPGQuery *m) MOSDPGLog *m = new MOSDPGLog(osdmap->get_epoch(), pg->info); m->missing = pg->missing; + // primary -> other, when building master log if (it->second.type == PG::Query::LOG) { - dout(10) << *pg << " sending info+missing+log since split " << it->second.split - << " from floor " << it->second.floor + dout(10) << *pg << " sending info+missing+log since " << it->second.floor << dendl; + /* if (!m->log.copy_after_unless_divergent(pg->log, it->second.split, it->second.floor)) { dout(10) << *pg << " divergent, sending backlog" << dendl; it->second.type = PG::Query::BACKLOG; } + */ + m->log.copy_after(pg->log, it->second.floor); } if (it->second.type == PG::Query::BACKLOG) { diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 7b2b0dfbb95c7..cbcd403e04b1b 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -44,15 +44,18 @@ static ostream& _prefix(PG *pg, int whoami, OSDMap *osdmap) { void PG::Log::copy_after(const Log &other, eversion_t v) { assert(v >= other.bottom); - top = bottom = other.top; + top = other.top; + bottom = other.bottom; for (list::const_reverse_iterator i = other.log.rbegin(); i != other.log.rend(); i++) { - if (i->version == v) break; + if (i->version <= v) { + bottom = i->version; + break; + } assert(i->version > v); log.push_front(*i); } - bottom = v; } bool PG::Log::copy_after_unless_divergent(const Log &other, eversion_t split, eversion_t floor) @@ -1034,7 +1037,8 @@ void PG::peer(ObjectStore::Transaction& t, << " v " << newest_update << ", querying since " << since << dendl; - query_map[newest_update_osd][info.pgid] = Query(Query::LOG, log.top, since, info.history); + query_map[newest_update_osd][info.pgid] = Query(Query::LOG, since, info.history); + //Query(Query::LOG, log.top, since, info.history); peer_log_requested.insert(newest_update_osd); } } else { diff --git a/src/osd/PG.h b/src/osd/PG.h index fadf684d75816..5cf8963cf1ffb 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -148,26 +148,30 @@ public: const static int LOG = 1; const static int BACKLOG = 2; const static int FULLLOG = 3; + const static int LOGFROM = 4; __s32 type; - eversion_t split, floor; + //eversion_t split; + eversion_t floor; Info::History history; Query() : type(-1) {} Query(int t, Info::History& h) : type(t), history(h) { assert(t != LOG); } - Query(int t, eversion_t s, eversion_t f, Info::History& h) : - type(t), split(s), floor(f), history(h) { assert(t == LOG); } + Query(int t, eversion_t f, Info::History& h) : + type(t), + //split(s), + floor(f), history(h) { assert(t == LOG); } void encode(bufferlist &bl) const { ::encode(type, bl); - ::encode(split, bl); + //::encode(split, bl); ::encode(floor, bl); history.encode(bl); } void decode(bufferlist::iterator &bl) { ::decode(type, bl); - ::decode(split, bl); + //::decode(split, bl); ::decode(floor, bl); history.decode(bl); } -- 2.39.5