From: Kefu Chai Date: Wed, 24 May 2017 11:34:08 +0000 (+0800) Subject: mon: print log for the creating_pgs changes X-Git-Tag: ses5-milestone6~8^2~19^2~22 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=60a30ff9d9b8ce716978b221ed80cf22efb7f5bb;p=ceph.git mon: print log for the creating_pgs changes print more log messages 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 f2d8ed28697..4ba91575f3c 100644 --- a/src/mon/CreatingPGs.h +++ b/src/mon/CreatingPGs.h @@ -41,7 +41,7 @@ struct creating_pgs_t { /// pools that exist in the osdmap for which at least one pg has been created std::set created_pools; - void create_pool(int64_t poolid, uint32_t pg_num, + bool create_pool(int64_t poolid, uint32_t pg_num, epoch_t created, utime_t modified) { if (created_pools.count(poolid) == 0) { auto& c = queue[poolid]; @@ -49,6 +49,9 @@ struct creating_pgs_t { c.modified = modified; c.end = pg_num; created_pools.insert(poolid); + return true; + } else { + return false; } } unsigned remove_pool(int64_t removed_pool) { diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 28b18605d3b..1b9877f6333 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -952,23 +952,24 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) if (pending_creatings.last_scan_epoch < inc.epoch) { if (osdmap.get_epoch() && osdmap.require_osd_release < CEPH_RELEASE_LUMINOUS) { - const unsigned total = pending_creatings.pgs.size(); - mon->pgservice->maybe_add_creating_pgs(creating_pgs.last_scan_epoch, - &pending_creatings); - dout(7) << __func__ << total - pending_creatings.pgs.size() - << " pgs added from pgmap" << dendl; - } - 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 added = + mon->pgservice->maybe_add_creating_pgs(creating_pgs.last_scan_epoch, + &pending_creatings); + dout(7) << __func__ << " " << added << " pgs added from pgmap" << dendl; + } + unsigned queued = 0; + queued += scan_for_creating_pgs(osdmap.get_pools(), + inc.old_pools, + inc.modified, + &pending_creatings); + queued += scan_for_creating_pgs(inc.new_pools, + inc.old_pools, + inc.modified, + &pending_creatings); + dout(10) << __func__ << " " << queued << " pools queued" << dendl; for (auto deleted_pool : inc.old_pools) { auto removed = pending_creatings.remove_pool(deleted_pool); - dout(10) << __func__ << removed + dout(10) << __func__ << " " << removed << " pg removed because containing pool deleted: " << deleted_pool << dendl; last_epoch_clean.remove_pool(deleted_pool); @@ -979,17 +980,19 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) // trim them here. otherwise, they will be added back after being erased. unsigned removed = 0; for (auto& pg : pending_created_pgs) { + dout(20) << __func__ << " noting created pg " << pg << dendl; pending_creatings.created_pools.insert(pg.pool()); removed += pending_creatings.pgs.erase(pg); } pending_created_pgs.clear(); - dout(10) << __func__ << removed << " pgs removed because they're created" - << dendl; + dout(10) << __func__ << " " << removed + << " pgs removed because they're created" << dendl; pending_creatings.last_scan_epoch = osdmap.get_epoch(); } // process queue unsigned max = MAX(1, g_conf->mon_osd_max_creating_pgs); + const auto total = pending_creatings.pgs.size(); while (pending_creatings.pgs.size() < max && !pending_creatings.queue.empty()) { auto p = pending_creatings.queue.begin(); @@ -1023,7 +1026,8 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) } dout(10) << __func__ << " queue remaining: " << pending_creatings.queue.size() << " pools" << dendl; - + dout(10) << __func__ << " " << pending_creatings.pgs.size() - total + << " pgs added from queued pools" << dendl; return pending_creatings; } @@ -3239,12 +3243,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 queued = 0; for (auto& p : pools) { int64_t poolid = p.first; const pg_pool_t& pool = p.second; @@ -3267,8 +3272,12 @@ void OSDMonitor::scan_for_creating_pgs( } dout(10) << __func__ << " queueing pool create for " << poolid << " " << pool << dendl; - creating_pgs->create_pool(poolid, pool.get_pg_num(), created, modified); + if (creating_pgs->create_pool(poolid, pool.get_pg_num(), + created, modified)) { + queued++; + } } + return queued; } void OSDMonitor::update_creating_pgs() diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index 4cdc81aa2c8..19a0fa6d1a8 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -1299,18 +1299,23 @@ public: bool is_creating_pg(pg_t pgid) const override { return pgmap.creating_pgs.count(pgid); } - void maybe_add_creating_pgs(epoch_t scan_epoch, + unsigned maybe_add_creating_pgs(epoch_t scan_epoch, creating_pgs_t *pending_creates) const override { - if (pgmap.last_pg_scan >= scan_epoch) { - for (auto& pgid : pgmap.creating_pgs) { - auto st = pgmap.pg_stat.find(pgid); - assert(st != pgmap.pg_stat.end()); - auto created = make_pair(st->second.created, - st->second.last_scrub_stamp); - // no need to add the pg, if it already exists in creating_pgs - pending_creates->pgs.emplace(pgid, created); + if (pgmap.last_pg_scan < scan_epoch) { + return 0; + } + unsigned added = 0; + for (auto& pgid : pgmap.creating_pgs) { + auto st = pgmap.pg_stat.find(pgid); + assert(st != pgmap.pg_stat.end()); + auto created = make_pair(st->second.created, + st->second.last_scrub_stamp); + // no need to add the pg, if it already exists in creating_pgs + if (pending_creates->pgs.emplace(pgid, created).second) { + added++; } } + return added; } void maybe_trim_creating_pgs(creating_pgs_t *creates) const override { auto p = creates->pgs.begin(); diff --git a/src/mon/PGStatService.h b/src/mon/PGStatService.h index 63ed09844d8..c714c6e4c90 100644 --- a/src/mon/PGStatService.h +++ b/src/mon/PGStatService.h @@ -59,9 +59,10 @@ public: * For upgrades. If the PGMap has newer data than the monitor's new * creating_pgs (scan_epoch), insert them into the passed pending_creates. */ - virtual void maybe_add_creating_pgs(epoch_t scan_epoch, - creating_pgs_t *pending_creates) const { + virtual unsigned maybe_add_creating_pgs(epoch_t scan_epoch, + creating_pgs_t *pending_creates) const { ceph_abort(); + return 0; } /** * For upgrades. If some PGs are created before all OSDs are luminous