Skip to content

Commit

Permalink
mon/PGMap: clear pool sum when last pg is deleted
Browse files Browse the repository at this point in the history
Use the x.0 pg as a sentinel for the existence of the pool.  Note that we
have to clean in up two paths: apply_incrmenetal (which is actually
deprecated) and the normal PGMonitor refresh.

Fixes: ceph#7912
Signed-off-by: Sage Weil <[email protected]>
  • Loading branch information
Sage Weil committed Mar 31, 2014
1 parent b3ffce8 commit 81853c6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/mon/PGMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
// adjust [near]full status
register_nearfull_status(osd, new_stats);
}
set<int64_t> deleted_pools;
for (set<pg_t>::const_iterator p = inc.pg_remove.begin();
p != inc.pg_remove.end();
++p) {
Expand All @@ -273,6 +274,14 @@ void PGMap::apply_incremental(CephContext *cct, const Incremental& inc)
stat_pg_sub(removed_pg, s->second);
pg_stat.erase(s);
}
if (removed_pg.ps() == 0)
deleted_pools.insert(removed_pg.pool());
}
for (set<int64_t>::iterator p = deleted_pools.begin();
p != deleted_pools.end();
++p) {
dout(20) << " deleted pool " << *p << dendl;
deleted_pool(*p);
}

for (set<int>::iterator p = inc.get_osd_stat_rm().begin();
Expand Down
7 changes: 7 additions & 0 deletions src/mon/PGMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ class PGMap {
const ceph::unordered_map<uint64_t, pool_stat_t>& pg_pool_sum_old);
void clear_delta();

void deleted_pool(int64_t pool) {
pg_pool_sum.erase(pool);
per_pool_sum_deltas.erase(pool);
per_pool_sum_deltas_stamps.erase(pool);
per_pool_sum_delta.erase(pool);
}

private:
void update_delta(CephContext *cct,
const utime_t ts,
Expand Down
11 changes: 11 additions & 0 deletions src/mon/PGMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl)
ceph::unordered_map<uint64_t, pool_stat_t> pg_pool_sum_old;

// pgs
set<int64_t> deleted_pools;
bufferlist::iterator p = dirty_pgs.begin();
while (!p.end()) {
pg_t pgid;
Expand All @@ -446,6 +447,8 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl)
pg_map.update_pg(pgid, bl);
} else {
pg_map.remove_pg(pgid);
if (pgid.ps() == 0)
deleted_pools.insert(pgid.pool());
}
}

Expand All @@ -467,6 +470,14 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl)
pg_map.update_global_delta(g_ceph_context, inc_stamp, pg_sum_old);
pg_map.update_pool_deltas(g_ceph_context, inc_stamp, pg_pool_sum_old);

// clean up deleted pools after updating the deltas
for (set<int64_t>::iterator p = deleted_pools.begin();
p != deleted_pools.end();
++p) {
dout(20) << " deleted pool " << *p << dendl;
pg_map.deleted_pool(*p);
}

// ok, we're now on the new version
pg_map.version = v;
}
Expand Down

0 comments on commit 81853c6

Please sign in to comment.