]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: track creating_pgs_by_osd_epoch
authorSage Weil <sage@redhat.com>
Wed, 7 Oct 2015 00:37:06 +0000 (20:37 -0400)
committerSage Weil <sage@redhat.com>
Mon, 23 Nov 2015 13:38:49 +0000 (08:38 -0500)
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 <sage@redhat.com>
src/mon/PGMap.cc
src/mon/PGMap.h
src/mon/PGMonitor.cc

index 412b00b8760c887cf1fdb6c25f217de004dfc197..0f67ae7eb66249eb9ea9aa13c29268f6ce64cf25 100644 (file)
@@ -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<epoch_t,set<pg_t> >& 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);
       }
     }
   }
index 5f5f9f124d5b8926e1546db9a35cf6403abde341..3a3824027accd3b9dc738d491a991a70d4748b2a 100644 (file)
@@ -183,6 +183,7 @@ public:
 
   set<pg_t> creating_pgs;
   map<int,set<pg_t> > creating_pgs_by_osd;
+  map<int,map<epoch_t,set<pg_t> > > creating_pgs_by_osd_epoch;
 
   // Bits that use to be enum StuckPG
   static const int STUCK_INACTIVE = (1<<0);
index 70b2241f3df1dd5eb2f809ab1645f6fcd6c11170..3ca06fd9e393c243739e25a47306ec26fe3c447b 100644 (file)
@@ -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<epoch_t,set<pg_t> >& 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<int, set<pg_t> >::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;
   }
 }