]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr: simplify handling of new pgs/pools
authorSage Weil <sage@redhat.com>
Fri, 19 May 2017 21:56:11 +0000 (17:56 -0400)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:02:51 +0000 (13:02 -0400)
Instantiate barebones pg records (creating+stale) in our PGMap when pgs
are created.  These will switch to 'creating' when the pgs is in the
process of creating, and peering etc.  The 'stale' is an indicator that
the mon may not have even asked the pg to create them yet.

All of the old meticulous tracking in PGMap for mappings for creating
pgs is useless to us; OSDMonitor has new code to handle it.  This is
fast and simple.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/ClusterState.cc
src/mon/PGMap.cc

index c2e7550fa5ee2f083f65a8c0d88f990b660cd8f1..127ac06d4dc5b955d4f1ab81fb4c35506f09ca92 100644 (file)
@@ -99,8 +99,6 @@ void ClusterState::notify_osdmap(const OSDMap &osd_map)
   pending_inc.version = pg_map.version + 1; // to make apply_incremental happy
 
   PGMapUpdater::check_osd_map(g_ceph_context, osd_map, pg_map, &pending_inc);
-  PGMapUpdater::update_creating_pgs(osd_map, pg_map, &pending_inc);
-  PGMapUpdater::register_new_pgs(osd_map, pg_map, &pending_inc);
 
   // brute force this for now (don't bother being clever by only
   // checking osds that went up/down)
index c0db8efd22c0e120475483e8216533d8c126b978..8a1a0efc995c4810a07b66e0649db114dde2692e 100644 (file)
@@ -3294,6 +3294,8 @@ void PGMapUpdater::check_osd_map(
       }
     }
   }
+
+  // deleted pgs (pools)?
   for (auto& p : pgmap.pg_pool_sum) {
     if (!osdmap.have_pg_pool(p.first)) {
       ldout(cct, 10) << __func__ << " pool " << p.first << " gone, removing pgs"
@@ -3313,6 +3315,36 @@ void PGMapUpdater::check_osd_map(
       }
     }
   }
+
+  // new pgs (split or new pool)?
+  for (auto& p : osdmap.get_pools()) {
+    int64_t poolid = p.first;
+    const pg_pool_t& pi = p.second;
+    auto q = pgmap.num_pg_by_pool.find(poolid);
+    unsigned my_pg_num = 0;
+    if (q != pgmap.num_pg_by_pool.end())
+      my_pg_num = q->second;
+    unsigned pg_num = pi.get_pg_num();
+    if (my_pg_num != pg_num) {
+      for (unsigned ps = my_pg_num; ps < pg_num; ++ps) {
+       pg_t pgid(ps, poolid);
+       if (pending_inc->pg_stat_updates.count(pgid) == 0) {
+         pg_stat_t &stats = pending_inc->pg_stat_updates[pgid];
+         stats.last_fresh = osdmap.get_modified();
+         stats.last_active = osdmap.get_modified();
+         stats.last_change = osdmap.get_modified();
+         stats.last_peered = osdmap.get_modified();
+         stats.last_clean = osdmap.get_modified();
+         stats.last_unstale = osdmap.get_modified();
+         stats.last_undegraded = osdmap.get_modified();
+         stats.last_fullsized = osdmap.get_modified();
+         stats.last_scrub_stamp = osdmap.get_modified();
+         stats.last_deep_scrub_stamp = osdmap.get_modified();
+         stats.last_clean_scrub_stamp = osdmap.get_modified();
+       }
+      }
+    }
+  }
 }
 
 void PGMapUpdater::register_pg(