From: Sage Weil Date: Wed, 7 Oct 2015 00:37:06 +0000 (-0400) Subject: mon/PGMonitor: track creating_pgs_by_osd_epoch X-Git-Tag: v10.0.1~26^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dd91837a8e945a6088a9aab899971ea2b90303e5;p=ceph.git mon/PGMonitor: track creating_pgs_by_osd_epoch Track pg creations, grouped by the first epoch they mapped to a particular OSD. This will be necessary to send messages only for new creations. Signed-off-by: Sage Weil --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 412b00b8760c..0f67ae7eb662 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -471,8 +471,10 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating, if (!nocreating) { if (s.state & PG_STATE_CREATING) { creating_pgs.insert(pgid); - if (s.acting_primary >= 0) + if (s.acting_primary >= 0) { creating_pgs_by_osd[s.acting_primary].insert(pgid); + creating_pgs_by_osd_epoch[s.acting_primary][s.mapping_epoch].insert(pgid); + } } } @@ -513,6 +515,13 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating, creating_pgs_by_osd[s.acting_primary].erase(pgid); if (creating_pgs_by_osd[s.acting_primary].size() == 0) creating_pgs_by_osd.erase(s.acting_primary); + + map >& r = creating_pgs_by_osd_epoch[s.acting_primary]; + r[s.mapping_epoch].erase(pgid); + if (r[s.mapping_epoch].empty()) + r.erase(s.mapping_epoch); + if (r.empty()) + creating_pgs_by_osd_epoch.erase(s.acting_primary); } } } diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 5f5f9f124d5b..3a3824027acc 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -183,6 +183,7 @@ public: set creating_pgs; map > creating_pgs_by_osd; + map > > creating_pgs_by_osd_epoch; // Bits that use to be enum StuckPG static const int STUCK_INACTIVE = (1<<0); diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 70b2241f3df1..3ca06fd9e393 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -1147,6 +1147,14 @@ void PGMonitor::map_pg_creates() pg_map.creating_pgs_by_osd[s->acting_primary].erase(pgid); if (pg_map.creating_pgs_by_osd[s->acting_primary].size() == 0) pg_map.creating_pgs_by_osd.erase(s->acting_primary); + + map >& r = + pg_map.creating_pgs_by_osd_epoch[s->acting_primary]; + r[s->mapping_epoch].erase(pgid); + if (r[s->mapping_epoch].empty()) + r.erase(s->mapping_epoch); + if (r.empty()) + pg_map.creating_pgs_by_osd_epoch.erase(s->acting_primary); } s->up = up; s->up_primary = up_primary; @@ -1165,8 +1173,11 @@ void PGMonitor::map_pg_creates() continue; if (acting_primary != -1) { - if (changed) + if (changed) { + pg_map.creating_pgs_by_osd_epoch[acting_primary][s->mapping_epoch].insert( + pgid); pg_map.creating_pgs_by_osd[acting_primary].insert(pgid); + } } else { dout(20) << "map_pg_creates " << pgid << " -> no osds in epoch " << mon->osdmon()->osdmap.get_epoch() << ", skipping" << dendl; @@ -1176,7 +1187,8 @@ void PGMonitor::map_pg_creates() for (map >::iterator p = pg_map.creating_pgs_by_osd.begin(); p != pg_map.creating_pgs_by_osd.end(); ++p) { - dout(10) << "map_pg_creates osd." << p->first << " has " << p->second.size() << " pgs" << dendl; + dout(10) << "map_pg_creates osd." << p->first + << " has " << p->second.size() << " pgs" << dendl; } }