From: Greg Farnum Date: Wed, 15 Jan 2014 23:25:49 +0000 (-0800) Subject: OSDMap: move temp manipulation functions out of OSDMonitor X-Git-Tag: v0.78~329^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b18311577a18cefa6f59791aec1a99391ed4c231;p=ceph.git OSDMap: move temp manipulation functions out of OSDMonitor In doing so, consolidate remove_down_pg_temp() and remove_down_primary_temp(). Signed-off-by: Greg Farnum --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 3a704c38d6e..3f5af18024b 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -410,80 +410,6 @@ void OSDMonitor::update_logger() mon->cluster_logger->set(l_cluster_osd_epoch, osdmap.get_epoch()); } -void OSDMonitor::remove_redundant_pg_temp() -{ - dout(10) << "remove_redundant_pg_temp" << dendl; - - for (map >::iterator p = osdmap.pg_temp->begin(); - p != osdmap.pg_temp->end(); - ++p) { - if (pending_inc.new_pg_temp.count(p->first) == 0) { - vector raw_up; - int primary; - osdmap.pg_to_raw_up(p->first, &raw_up, &primary); - if (raw_up == p->second) { - dout(10) << " removing unnecessary pg_temp " << p->first << " -> " << p->second << dendl; - pending_inc.new_pg_temp[p->first].clear(); - } - } - } - if (!osdmap.primary_temp->empty()) { - OSDMap templess(osdmap); - templess.primary_temp.reset(new map(*osdmap.primary_temp)); - templess.primary_temp->clear(); - for (map::iterator p = osdmap.primary_temp->begin(); - p != osdmap.primary_temp->end(); - ++p) { - if (pending_inc.new_primary_temp.count(p->first) == 0) { - vector real_up, templess_up; - int real_primary, templess_primary; - osdmap.pg_to_acting_osds(p->first, &real_up, &real_primary); - templess.pg_to_acting_osds(p->first, &templess_up, &templess_primary); - if (real_primary == templess_primary){ - dout(10) << " removing unnecessary primary_temp " - << p->first << " -> " << p->second << dendl; - pending_inc.new_primary_temp[p->first] = -1; - } - } - } - } -} - -void OSDMonitor::remove_down_pg_temp() -{ - dout(10) << "remove_down_pg_temp" << dendl; - OSDMap tmpmap(osdmap); - tmpmap.apply_incremental(pending_inc); - - for (map >::iterator p = tmpmap.pg_temp->begin(); - p != tmpmap.pg_temp->end(); - ++p) { - unsigned num_up = 0; - for (vector::iterator i = p->second.begin(); - i != p->second.end(); - ++i) { - if (!tmpmap.is_down(*i)) - ++num_up; - } - if (num_up == 0) - pending_inc.new_pg_temp[p->first].clear(); - } -} - -void OSDMonitor::remove_down_primary_temp() -{ - dout(10) << "remove_down_primary_temp" << dendl; - OSDMap tmpmap(osdmap); - tmpmap.apply_incremental(pending_inc); - - for (map::iterator p = tmpmap.primary_temp->begin(); - p != tmpmap.primary_temp->end(); - ++p) { - if (tmpmap.is_down(p->second)) - pending_inc.new_primary_temp[p->first] = -1; - } -} - /* Assign a lower weight to overloaded OSDs. * * The osds that will get a lower weight are those with with a utilization @@ -572,11 +498,10 @@ void OSDMonitor::create_pending() dout(10) << "create_pending e " << pending_inc.epoch << dendl; // drop any redundant pg_temp entries - remove_redundant_pg_temp(); + OSDMap::remove_redundant_temporaries(g_ceph_context, osdmap, &pending_inc); // drop any pg or primary_temp entries with no up entries - remove_down_pg_temp(); - remove_down_primary_temp(); + OSDMap::remove_down_temps(g_ceph_context, osdmap, &pending_inc); } /** diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index ec49c609f71..81ea4320d15 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -204,9 +204,6 @@ private: void send_incremental(PaxosServiceMessage *m, epoch_t first); void send_incremental(epoch_t first, entity_inst_t& dest, bool onetime); - void remove_redundant_pg_temp(); - void remove_down_pg_temp(); - void remove_down_primary_temp(); int reweight_by_utilization(int oload, std::string& out_str); bool check_source(PaxosServiceMessage *m, uuid_d fsid); diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 8d3bece58fa..4e31b193b6d 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -1029,6 +1029,74 @@ void OSDMap::dedup(const OSDMap *o, OSDMap *n) n->osd_uuid = o->osd_uuid; } +void OSDMap::remove_redundant_temporaries(CephContext *cct, const OSDMap& osdmap, + OSDMap::Incremental *pending_inc) +{ + ldout(cct, 10) << "remove_redundant_temporaries" << dendl; + + for (map >::iterator p = osdmap.pg_temp->begin(); + p != osdmap.pg_temp->end(); + ++p) { + if (pending_inc->new_pg_temp.count(p->first) == 0) { + vector raw_up; + int primary; + osdmap.pg_to_raw_up(p->first, &raw_up, &primary); + if (raw_up == p->second) { + ldout(cct, 10) << " removing unnecessary pg_temp " << p->first << " -> " << p->second << dendl; + pending_inc->new_pg_temp[p->first].clear(); + } + } + } + if (!osdmap.primary_temp->empty()) { + OSDMap templess(osdmap); + templess.primary_temp.reset(new map(*osdmap.primary_temp)); + templess.primary_temp->clear(); + for (map::iterator p = osdmap.primary_temp->begin(); + p != osdmap.primary_temp->end(); + ++p) { + if (pending_inc->new_primary_temp.count(p->first) == 0) { + vector real_up, templess_up; + int real_primary, templess_primary; + osdmap.pg_to_acting_osds(p->first, &real_up, &real_primary); + templess.pg_to_acting_osds(p->first, &templess_up, &templess_primary); + if (real_primary == templess_primary){ + ldout(cct, 10) << " removing unnecessary primary_temp " + << p->first << " -> " << p->second << dendl; + pending_inc->new_primary_temp[p->first] = -1; + } + } + } + } +} + +void OSDMap::remove_down_temps(CephContext *cct, + const OSDMap& osdmap, Incremental *pending_inc) +{ + ldout(cct, 10) << "remove_down_pg_temp" << dendl; + OSDMap tmpmap(osdmap); + tmpmap.apply_incremental(*pending_inc); + + for (map >::iterator p = tmpmap.pg_temp->begin(); + p != tmpmap.pg_temp->end(); + ++p) { + unsigned num_up = 0; + for (vector::iterator i = p->second.begin(); + i != p->second.end(); + ++i) { + if (!tmpmap.is_down(*i)) + ++num_up; + } + if (num_up == 0) + pending_inc->new_pg_temp[p->first].clear(); + } + for (map::iterator p = tmpmap.primary_temp->begin(); + p != tmpmap.primary_temp->end(); + ++p) { + if (tmpmap.is_down(p->second)) + pending_inc->new_primary_temp[p->first] = -1; + } +} + int OSDMap::apply_incremental(const Incremental &inc) { new_blacklist_entries = false; diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 194683cd594..468b4527493 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -465,6 +465,11 @@ private: /// try to re-use/reference addrs in oldmap from newmap static void dedup(const OSDMap *oldmap, OSDMap *newmap); + static void remove_redundant_temporaries(CephContext *cct, const OSDMap& osdmap, + Incremental *pending_inc); + static void remove_down_temps(CephContext *cct, const OSDMap& osdmap, + Incremental *pending_inc); + // serialize, unserialize private: void encode_client_old(bufferlist& bl) const;