From 9864a79abcc977b7254cfb40814f19ec69d6bc3a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 11 Oct 2015 22:06:33 -0400 Subject: [PATCH] mon/PGMonitor: avoid useless pg gets when pool is deleted If the .0 pg no longer exists, we know the entire pool was deleted, and can avoid querying every other pg. (This is a good thing because leveldb and rocksdb can be very slow to query missing keys.) Signed-off-by: Sage Weil --- src/mon/PGMonitor.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 0640b1a6e8c37..e250f59ee218f 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -432,16 +432,22 @@ void PGMonitor::apply_pgmap_delta(bufferlist& bl) while (!p.end()) { pg_t pgid; ::decode(pgid, p); - bufferlist bl; - int r = mon->store->get(pgmap_pg_prefix, stringify(pgid), bl); - dout(20) << " refreshing pg " << pgid << " got " << r << " len " - << bl.length() << dendl; - if (pg_pool_sum_old.count(pgid.pool()) == 0) - pg_pool_sum_old[pgid.pool()] = pg_map.pg_pool_sum[pgid.pool()]; + int r; + bufferlist pgbl; + if (deleted_pools.count(pgid.pool())) { + r = -ENOENT; + } else { + r = mon->store->get(pgmap_pg_prefix, stringify(pgid), pgbl); + dout(20) << " refreshing pg " << pgid << " got " << r << " len " + << pgbl.length() << dendl; + + if (pg_pool_sum_old.count(pgid.pool()) == 0) + pg_pool_sum_old[pgid.pool()] = pg_map.pg_pool_sum[pgid.pool()]; + } if (r >= 0) { - pg_map.update_pg(pgid, bl); + pg_map.update_pg(pgid, pgbl); } else { pg_map.remove_pg(pgid); if (pgid.ps() == 0) -- 2.39.5