From b4ad2601283b0a7170c853939b80cadfad205a79 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 10 Jun 2015 17:41:27 -0700 Subject: [PATCH] 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 --- src/mon/PGMap.cc | 34 ++++++++++++++++------------------ src/mon/PGMap.h | 4 ++-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index 0aa837af59d72..ada4db92fd030 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 3df2c49e7e591..733b2f0ebcbdf 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); -- 2.39.5