From: Kefu Chai Date: Wed, 24 May 2017 11:34:08 +0000 (+0800) Subject: mon/OSDMonitor: print more log when updating creating_pgs X-Git-Tag: ses5-milestone6~9^2~43^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=50616b9e57f1a2c4eca8a8af5707364d0d1601f4;p=ceph.git mon/OSDMonitor: print more log when updating creating_pgs see-also: http://tracker.ceph.com/issues/20067 Signed-off-by: Kefu Chai --- diff --git a/src/mon/CreatingPGs.h b/src/mon/CreatingPGs.h index 7c909a5de3a1..46aaa7040772 100644 --- a/src/mon/CreatingPGs.h +++ b/src/mon/CreatingPGs.h @@ -11,6 +11,31 @@ struct creating_pgs_t { epoch_t last_scan_epoch = 0; std::map > pgs; std::set created_pools; + + unsigned create_pool(int64_t poolid, uint32_t pg_num, + epoch_t created, utime_t modified) { + if (created_pools.count(poolid)) { + return 0; + } + const unsigned total = pgs.size(); + for (ps_t ps = 0; ps < pg_num; ps++) { + const pg_t pgid{ps, static_cast(poolid)}; + if (pgs.count(pgid)) { + continue; + } + pgs.emplace(pgid, make_pair(created, modified)); + } + return pgs.size() - total; + } + + unsigned remove_pool(int64_t removed_pool) { + const unsigned total = pgs.size(); + auto first = pgs.lower_bound(pg_t{0, (uint64_t)removed_pool}); + auto last = pgs.lower_bound(pg_t{0, (uint64_t)removed_pool + 1}); + pgs.erase(first, last); + created_pools.erase(removed_pool); + return total - pgs.size(); + } void encode(bufferlist& bl) const { ENCODE_START(1, 1, bl); ::encode(last_scan_epoch, bl); diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index e28621cffafd..fa2eea154568 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -919,16 +919,20 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) if (pending_creatings.last_scan_epoch > inc.epoch) { return pending_creatings; } + unsigned removed = 0; for (auto& pg : pending_created_pgs) { pending_creatings.created_pools.insert(pg.pool()); - pending_creatings.pgs.erase(pg); + removed += pending_creatings.pgs.erase(pg); } pending_created_pgs.clear(); + dout(10) << __func__ << removed << " pgs removed because they're created" + << dendl; // PAXOS_PGMAP is less than PAXOS_OSDMAP, so PGMonitor::update_from_paxos() // should have prepared the latest pgmap if any const auto& pgm = mon->pgmon()->pg_map; if (pgm.last_pg_scan >= creating_pgs.last_scan_epoch) { // TODO: please stop updating pgmap with pgstats once the upgrade is completed + const unsigned total = pending_creatings.pgs.size(); for (auto& pgid : pgm.creating_pgs) { auto st = pgm.pg_stat.find(pgid); assert(st != pgm.pg_stat.end()); @@ -936,25 +940,25 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) // no need to add the pg, if it already exists in creating_pgs pending_creatings.pgs.emplace(pgid, created); } + dout(7) << __func__ << total - pending_creatings.pgs.size() + << " pgs added from pgmap" << dendl; } for (auto old_pool : inc.old_pools) { - pending_creatings.created_pools.erase(old_pool); - const auto removed_pool = (uint64_t)old_pool; - auto first = - pending_creatings.pgs.lower_bound(pg_t{0, removed_pool}); - auto last = - pending_creatings.pgs.lower_bound(pg_t{0, removed_pool + 1}); - pending_creatings.pgs.erase(first, last); - last_epoch_clean.remove_pool(removed_pool); - } - scan_for_creating_pgs(osdmap.get_pools(), - inc.old_pools, - inc.modified, - &pending_creatings); - scan_for_creating_pgs(inc.new_pools, - inc.old_pools, - inc.modified, - &pending_creatings); + auto removed = pending_creatings.remove_pool(old_pool); + dout(10) << __func__ << removed + << " pg removed because containing pool deleted: " + << old_pool << dendl; + } + unsigned added = 0; + added += scan_for_creating_pgs(osdmap.get_pools(), + inc.old_pools, + inc.modified, + &pending_creatings); + added += scan_for_creating_pgs(inc.new_pools, + inc.old_pools, + inc.modified, + &pending_creatings); + dout(10) << __func__ << added << " pg added for new pools" << dendl; pending_creatings.last_scan_epoch = osdmap.get_epoch(); return pending_creatings; } @@ -3159,12 +3163,13 @@ void OSDMonitor::check_pg_creates_sub(Subscription *sub) } } -void OSDMonitor::scan_for_creating_pgs( +unsigned OSDMonitor::scan_for_creating_pgs( const mempool::osdmap::map& pools, const mempool::osdmap::set& removed_pools, utime_t modified, creating_pgs_t* creating_pgs) const { + unsigned total = 0; for (auto& p : pools) { int64_t poolid = p.first; const pg_pool_t& pool = p.second; @@ -3185,24 +3190,13 @@ void OSDMonitor::scan_for_creating_pgs( << " " << pool << dendl; continue; } - dout(10) << __func__ << " scanning pool " << poolid + unsigned added = creating_pgs->create_pool(poolid, pool.get_pg_num(), + created, modified); + dout(10) << __func__ << added << " pgs added for pool "<< poolid << " " << pool << dendl; - if (creating_pgs->created_pools.count(poolid)) { - // split pgs are skipped by OSD, so drop it early. - continue; - } - // first pgs in this pool - for (ps_t ps = 0; ps < pool.get_pg_num(); ps++) { - const pg_t pgid{ps, static_cast(poolid)}; - if (creating_pgs->pgs.count(pgid)) { - dout(20) << __func__ << " already have " << pgid << dendl; - continue; - } - creating_pgs->pgs.emplace(pgid, make_pair(created, modified)); - dout(10) << __func__ << " adding " << pgid - << " at " << osdmap.get_epoch() << dendl; - } + total += added; } + return total; } void OSDMonitor::update_creating_pgs() diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 44f013f27f75..980cf3e1320b 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -453,7 +453,7 @@ private: creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc); void trim_creating_pgs(creating_pgs_t *creating_pgs, const PGMap& pgm); - void scan_for_creating_pgs( + unsigned scan_for_creating_pgs( const mempool::osdmap::map& pools, const mempool::osdmap::set& removed_pools, utime_t modified,