diff --git a/src/osd/PG.cc b/src/osd/PG.cc index d0a2914a79f..27cf64c207c 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -1222,7 +1222,19 @@ bool PG::recover_master_log(map< int, map >& query_map, { dout(10) << "recover_master_log" << dendl; - // -- query info from everyone in prior_set. + if (is_down()) + return false; + + if (peer_info_requested.empty()) { + stringstream out; + prior_set->gen_query_map(*osd->osdmap, info, query_map); + dout(10) << out << dendl; + for (map< int, map >::const_iterator i = query_map.begin(); + i != query_map.end(); ++i) { + peer_info_requested.insert(i->first); + } + } + bool lack_info = false; for (set::const_iterator it = prior_set->cur.begin(); it != prior_set->cur.end(); @@ -1239,19 +1251,10 @@ bool PG::recover_master_log(map< int, map >& query_map, dout(10) << " waiting for osd" << *it << dendl; continue; } - - if (osd->osdmap->is_up(*it)) { - dout(10) << " querying info from osd" << *it << dendl; - query_map[*it][info.pgid] = Query(Query::INFO, info.history); - peer_info_requested.insert(*it); - } else { - dout(10) << " not querying info from down osd" << *it << dendl; - } } if (lack_info) return false; - // -- ok, we have all (prior_set) info. (and maybe others.) dout(10) << " have prior_set info. min_last_complete_ondisk " << min_last_complete_ondisk << dendl; @@ -1345,11 +1348,6 @@ bool PG::recover_master_log(map< int, map >& query_map, dout(10) << " oldest_update " << oldest_update << " (osd" << oldest_who << ")" << dendl; - if (is_down()) { - dout(10) << " down. we wait." << dendl; - return false; - } - have_master_log = true; return true; @@ -3906,3 +3904,20 @@ PG::PgPriorSet::PgPriorSet(int whoami, } } + +void PG::PgPriorSet::gen_query_map(const OSDMap &osdmap, + const PG::Info &info, + map< int, map >& query_map) +{ + for (set::const_iterator it = cur.begin(); + it != cur.end(); + ++it) { + // -- query info from everyone in prior_set. + if (osdmap.is_up(*it)) { + dout(10) << " querying info from osd" << *it << dendl; + query_map[*it][info.pgid] = Query(Query::INFO, info.history); + } else { + dout(10) << " not querying info from down osd" << *it << dendl; + } + } +} diff --git a/src/osd/PG.h b/src/osd/PG.h index fb986995740..b69633db15f 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -243,9 +243,9 @@ public: Info::History history; Query() : type(-1) {} - Query(int t, Info::History& h) : + Query(int t, const Info::History& h) : type(t), history(h) { assert(t != LOG); } - Query(int t, eversion_t s, Info::History& h) : + Query(int t, eversion_t s, const Info::History& h) : type(t), since(s), history(h) { assert(t == LOG); } void encode(bufferlist &bl) const { @@ -757,6 +757,10 @@ public: const vector &acting, const Info &info, const PG *pg); + + void gen_query_map(const OSDMap &osdmap, + const Info &info, + map< int, map >& query_map); }; friend std::ostream& operator<<(std::ostream& oss,