]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/PGMonitor: avoid duplicating map_pg_create() effort on same maps 372/head
authorSage Weil <sage@inktank.com>
Thu, 27 Jun 2013 00:34:39 +0000 (17:34 -0700)
committerSage Weil <sage@inktank.com>
Thu, 27 Jun 2013 00:34:39 +0000 (17:34 -0700)
If we have an election and refresh, but the osdmap does not change, there
is no need to recalculate the pg create maps.  However, if we register new
creating pgs, we do... when the last_pg_scan update gets pulled out of
paxos (i.e., on both leader and peon mons).

Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 88208354c8ea6588126a66036bfcb2dc10e5ffaf..ead42a05dcae181c883078069eef2f02e9e2bc04 100644 (file)
@@ -323,7 +323,12 @@ void PGMonitor::read_pgmap_meta()
   epoch_t last_pg_scan = mon->store->get(prefix, "last_pg_scan");
   pg_map.set_version(version);
   pg_map.set_last_osdmap_epoch(last_osdmap_epoch);
-  pg_map.set_last_pg_scan(last_pg_scan);
+
+  if (last_pg_scan != pg_map.get_last_pg_scan()) {
+    pg_map.set_last_pg_scan(last_pg_scan);
+    // clear our osdmap epoch so that map_pg_creates() will re-run
+    last_map_pg_create_osd_epoch = 0;
+  }
 
   float full_ratio, nearfull_ratio;
   {
@@ -369,8 +374,7 @@ void PGMonitor::read_pgmap_full()
   prefix = "pgmap_osd";
   for (KeyValueDB::Iterator i = mon->store->get_iterator(prefix); i->valid(); i->next()) {
     string key = i->key();
-    int osd;
-    osd = atoi(key.c_str());
+    int osd = atoi(key.c_str());
     bufferlist bl = i->value();
     pg_map.update_osd(osd, bl);
     dout(20) << " got osd." << osd << dendl;
@@ -1004,7 +1008,14 @@ bool PGMonitor::register_new_pgs()
 
 void PGMonitor::map_pg_creates()
 {
-  dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size() << " pgs" << dendl;
+  OSDMap *osdmap = &mon->osdmon()->osdmap;
+  if (osdmap->get_epoch() == last_map_pg_create_osd_epoch) {
+    dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size() << " pgs -- no change" << dendl;
+    return;
+  }
+
+  dout(10) << "map_pg_creates to " << pg_map.creating_pgs.size() << " pgs osdmap epoch " << osdmap->get_epoch() << dendl;
+  last_map_pg_create_osd_epoch = osdmap->get_epoch();
 
   for (set<pg_t>::iterator p = pg_map.creating_pgs.begin();
        p != pg_map.creating_pgs.end();
@@ -1015,7 +1026,7 @@ void PGMonitor::map_pg_creates()
     if (s.parent_split_bits)
       on = s.parent;
     vector<int> acting;
-    int nrep = mon->osdmon()->osdmap.pg_to_acting_osds(on, acting);
+    int nrep = osdmap->pg_to_acting_osds(on, acting);
 
     if (s.acting.size()) {
       pg_map.creating_pgs_by_osd[s.acting[0]].erase(pgid);
index 8117ee2bba8adaf9446e972c2a87475ec0c29d00..c6813eda3b133d174e74b0bf0860bc09c3d4ec75 100644 (file)
@@ -47,6 +47,9 @@ public:
 
   bool need_check_down_pgs;
 
+  epoch_t last_map_pg_create_osd_epoch;
+
+
 private:
   PGMap::Incremental pending_inc;
 
@@ -142,7 +145,8 @@ private:
 public:
   PGMonitor(Monitor *mn, Paxos *p, const string& service_name)
     : PaxosService(mn, p, service_name),
-      need_check_down_pgs(false)
+      need_check_down_pgs(false),
+      last_map_pg_create_osd_epoch(0)
   { }
   ~PGMonitor() { }