From 984b07dabc319b8d1b881e8601f0e0214273300e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 9 Dec 2008 14:57:19 -0800 Subject: [PATCH] osd: drive primary recovery via missing map, not log --- src/osd/PG.cc | 33 +++++++-------------------------- src/osd/PG.h | 6 ++---- src/osd/ReplicatedPG.cc | 24 +++++++++++------------- 3 files changed, 20 insertions(+), 43 deletions(-) diff --git a/src/osd/PG.cc b/src/osd/PG.cc index e014454738a33..8e99007fe43d0 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -120,17 +120,13 @@ void PG::IndexedLog::trim(ObjectStore::Transaction& t, eversion_t s) if (backlog && s < bottom) s = bottom; - assert(complete_to == log.end() && - requested_to == log.end()); + assert(complete_to == log.end()); while (!log.empty()) { Entry &e = *log.begin(); if (e.version > s) break; - assert(complete_to != log.begin()); - assert(requested_to != log.begin()); - // remove from index, unindex(e); @@ -1174,18 +1170,6 @@ void PG::peer(ObjectStore::Transaction& t, } -void PG::init_recovery_pointers() -{ - dout(10) << "init_recovery_pointers" << dendl; - log.complete_to = log.log.begin(); - while (log.complete_to->version < info.last_complete) - log.complete_to++; - assert(log.complete_to != log.log.end()); - - if (is_primary()) - log.requested_to = log.complete_to; -} - void PG::activate(ObjectStore::Transaction& t, map *activator_map) { @@ -1239,9 +1223,11 @@ void PG::activate(ObjectStore::Transaction& t, log.reset_recovery_pointers(); } else { dout(10) << "activate - not complete, " << missing << dendl; - - init_recovery_pointers(); - + log.complete_to = log.log.begin(); + while (log.complete_to->version < info.last_complete) + log.complete_to++; + assert(log.complete_to != log.log.end()); + log.last_requested = object_t(); dout(10) << "activate - complete_to = " << log.complete_to->version << dendl; if (is_primary()) { dout(10) << "activate - starting recovery" << dendl; @@ -1908,12 +1894,7 @@ void PG::repair_object(ScrubMap::object *po, int bad_peer, int ok_peer) } else { missing.add(po->poid.oid, v, eversion_t()); missing_loc[po->poid.oid].insert(ok_peer); - - // primary recovery is log driven - if (v < info.last_complete) { - info.last_complete = v; - init_recovery_pointers(); - } + log.last_requested = object_t(); } uptodate_set.erase(bad_peer); osd->queue_for_recovery(this); diff --git a/src/osd/PG.h b/src/osd/PG.h index 4949e57602ed9..8e7367e7b427c 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -294,8 +294,8 @@ public: hash_set caller_ops; // recovery pointers - list::iterator requested_to; // not inclusive of referenced item list::iterator complete_to; // not inclusive of referenced item + object_t last_requested; // last object requested by primary /****/ IndexedLog() {} @@ -307,8 +307,8 @@ public: reset_recovery_pointers(); } void reset_recovery_pointers() { - requested_to = log.end(); complete_to = log.end(); + last_requested = object_t(); } bool logged_object(object_t oid) const { @@ -705,8 +705,6 @@ public: virtual void cancel_recovery() = 0; virtual int start_recovery_ops(int max) = 0; - void init_recovery_pointers(); - void purge_strays(); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 67b081f8e7ac3..6edbe4a11f655 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -2679,24 +2679,23 @@ int ReplicatedPG::recover_primary(int max) int started = 0; int skipped = 0; - list::iterator p = log.requested_to; - - while (p != log.log.end()) { - assert(log.objects.count(p->oid)); - latest = log.objects[p->oid]; + map::iterator p = missing.missing.lower_bound(log.last_requested); + while (p != missing.missing.end()) { + assert(log.objects.count(p->first)); + latest = log.objects[p->first]; assert(latest); dout(10) << "recover_primary " - << *p + << *latest << (latest->is_update() ? " (update)":"") << (missing.is_missing(latest->oid) ? " (missing)":"") << (pulling.count(latest->oid) ? " (pulling)":"") << (waiting_for_head.count(latest->oid) ? " (waiting for head)":"") << dendl; + + assert(latest->is_update()); - if (latest->is_update() && - !pulling.count(latest->oid) && - missing.is_missing(latest->oid)) { + if (!pulling.count(latest->oid)) { if (waiting_for_head.count(latest->oid)) { ++skipped; } else { @@ -2732,9 +2731,9 @@ int ReplicatedPG::recover_primary(int max) p++; - // only advance requested_to if we haven't skipped anything + // only advance last_requested if we haven't skipped anything if (!skipped) - log.requested_to = p; + log.last_requested = latest->oid; } // done? @@ -2753,8 +2752,7 @@ int ReplicatedPG::recover_primary(int max) info.last_complete = info.last_update; } - log.complete_to = log.log.end(); - log.requested_to = log.log.end(); + log.reset_recovery_pointers(); uptodate_set.insert(osd->whoami); if (is_all_uptodate()) { -- 2.39.5