From: Sage Weil Date: Fri, 19 May 2017 21:56:11 +0000 (-0400) Subject: mgr: simplify handling of new pgs/pools X-Git-Tag: v12.1.0~288^2~41 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=0612b716275403f2bd34846c6082654f35115847;p=ceph-ci.git mgr: simplify handling of new pgs/pools 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 --- diff --git a/src/mgr/ClusterState.cc b/src/mgr/ClusterState.cc index c2e7550fa5e..127ac06d4dc 100644 --- a/src/mgr/ClusterState.cc +++ b/src/mgr/ClusterState.cc @@ -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) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index c0db8efd22c..8a1a0efc995 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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(