From: Sage Weil Date: Thu, 11 Jun 2015 00:41:27 +0000 (-0700) Subject: mon/PGMap: fix pgmap stat adjustment during map_pg_creates() X-Git-Tag: v9.0.3~200^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F4914%2Fhead;p=ceph.git mon/PGMap: fix pgmap stat adjustment during map_pg_creates() PGMonitor::map_pg_creates() is the only caller that passes sumonly=true, which is necessary to avoid modifying creating_pgs while it is iterating over it. However, everything else we *do* want to update--especially the osd counts. Rename the arg and skip only the creating bit. Signed-off-by: Sage Weil --- diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 0aa837af59d7..ada4db92fd03 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -459,22 +459,21 @@ void PGMap::remove_osd(int osd) } } -void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly, +void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating, bool sameosds) { pg_pool_sum[pgid.pool()].add(s); pg_sum.add(s); - if (sumonly) - return; - num_pg++; num_pg_by_state[s.state]++; - if (s.state & PG_STATE_CREATING) { - creating_pgs.insert(pgid); - if (s.acting_primary >= 0) - creating_pgs_by_osd[s.acting_primary].insert(pgid); + if (!nocreating) { + if (s.state & PG_STATE_CREATING) { + creating_pgs.insert(pgid); + if (s.acting_primary >= 0) + creating_pgs_by_osd[s.acting_primary].insert(pgid); + } } if (sameosds) @@ -492,7 +491,7 @@ void PGMap::stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly, pg_by_osd[*p].insert(pgid); } -void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly, +void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating, bool sameosds) { pool_stat_t& ps = pg_pool_sum[pgid.pool()]; @@ -501,19 +500,18 @@ void PGMap::stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly, pg_pool_sum.erase(pgid.pool()); pg_sum.sub(s); - if (sumonly) - return; - num_pg--; if (--num_pg_by_state[s.state] == 0) num_pg_by_state.erase(s.state); - if (s.state & PG_STATE_CREATING) { - creating_pgs.erase(pgid); - if (s.acting_primary >= 0) { - 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); + if (!nocreating) { + if (s.state & PG_STATE_CREATING) { + creating_pgs.erase(pgid); + if (s.acting_primary >= 0) { + 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); + } } } diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 3df2c49e7e59..733b2f0ebcbd 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -258,9 +258,9 @@ public: void redo_full_sets(); void register_nearfull_status(int osd, const osd_stat_t& s); void calc_stats(); - void stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool sumonly=false, + void stat_pg_add(const pg_t &pgid, const pg_stat_t &s, bool nocreating=false, bool sameosds=false); - void stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool sumonly=false, + void stat_pg_sub(const pg_t &pgid, const pg_stat_t &s, bool nocreating=false, bool sameosds=false); void stat_pg_update(const pg_t pgid, pg_stat_t &prev, bufferlist::iterator& blp); void stat_osd_add(const osd_stat_t &s);