Skip to content

Commit 562c79c

Browse files
Merge pull request ceph#63792 from kamoltat/wip-ksirivad-small-refractor-68550
src/mgr/ClusterState.cc: micro improve ingest_pgstats
2 parents d315e3d + 70b41ea commit 562c79c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/mgr/ClusterState.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,16 @@ void ClusterState::ingest_pgstats(ref_t<MPGStats> stats)
8989
pending_inc.update_stat(from, std::move(empty_stat));
9090
}
9191

92+
const auto existing_pools_end_it = existing_pools.end();
93+
const auto pg_map_pg_stat_end_it = pg_map.pg_stat.end();
9294
for (auto p : stats->pg_stat) {
9395
pg_t pgid = p.first;
9496
const auto &pg_stats = p.second;
9597

9698
// In case we're hearing about a PG that according to last
9799
// OSDMap update should not exist
98100
auto r = existing_pools.find(pgid.pool());
99-
if (r == existing_pools.end()) {
101+
if (r == existing_pools_end_it) {
100102
dout(15) << " got " << pgid
101103
<< " reported at " << pg_stats.reported_epoch << ":"
102104
<< pg_stats.reported_seq
@@ -117,18 +119,18 @@ void ClusterState::ingest_pgstats(ref_t<MPGStats> stats)
117119
// In case we already heard about more recent stats from this PG
118120
// from another OSD
119121
const auto q = pg_map.pg_stat.find(pgid);
120-
if (q != pg_map.pg_stat.end() &&
122+
if (q != pg_map_pg_stat_end_it &&
121123
q->second.get_version_pair() > pg_stats.get_version_pair()) {
122124
dout(15) << " had " << pgid << " from "
123125
<< q->second.reported_epoch << ":"
124126
<< q->second.reported_seq << dendl;
125127
continue;
126128
}
127129

128-
pending_inc.pg_stat_updates[pgid] = pg_stats;
130+
pending_inc.pg_stat_updates.insert_or_assign(pgid, pg_stats);
129131
}
130132
for (auto p : stats->pool_stat) {
131-
pending_inc.pool_statfs_updates[std::make_pair(p.first, from)] = p.second;
133+
pending_inc.pool_statfs_updates.insert_or_assign(std::make_pair(p.first, from), p.second);
132134
}
133135
}
134136

0 commit comments

Comments
 (0)