From: Greg Farnum Date: Tue, 9 May 2017 19:01:22 +0000 (-0700) Subject: mon: pgstats: move some creating_pgs maintenance into the PGStatService X-Git-Tag: ses5-milestone6~8^2~19^2~107 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9b03a163e939324cf0a6dd634036b91806eaec90;p=ceph.git mon: pgstats: move some creating_pgs maintenance into the PGStatService And remove get_pg_map() now that there are no users! Signed-off-by: Greg Farnum --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 4de827ad977..b67a4858fea 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -931,20 +931,11 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc) if (pending_creatings.last_scan_epoch > inc.epoch) { return pending_creatings; } - const auto& pgm = mon->pgservice->get_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()); - 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_creatings.pgs.emplace(pgid, created); - } - dout(7) << __func__ << total - pending_creatings.pgs.size() - << " pgs added from pgmap" << dendl; - } + 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; unsigned added = 0; added += scan_for_creating_pgs(osdmap.get_pools(), inc.old_pools, diff --git a/src/mon/PGStatService.h b/src/mon/PGStatService.h index b0e7ac8d469..a2914ae6a97 100644 --- a/src/mon/PGStatService.h +++ b/src/mon/PGStatService.h @@ -27,6 +27,7 @@ #define CEPH_PGSTATSERVICE_H #include "mon/PGMap.h" +struct creating_pgs_t; class PGStatService { public: @@ -45,10 +46,14 @@ public: virtual float get_nearfull_ratio() const = 0; virtual bool have_creating_pgs() const = 0; virtual bool is_creating_pg(pg_t pgid) const = 0; + /** + * 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 = 0; virtual epoch_t get_min_last_epoch_clean() const = 0; - virtual PGMap& get_pg_map() = 0; - virtual bool have_full_osds() const = 0; virtual bool have_nearfull_osds() const = 0; @@ -102,8 +107,6 @@ public: return NULL; } - PGMap& get_pg_map() { return parent; } - const pool_stat_t& get_pg_sum() const { return parent.pg_sum; } const osd_stat_t& get_osd_sum() const { return parent.osd_sum; } @@ -125,6 +128,18 @@ public: bool have_creating_pgs() const { return !parent.creating_pgs.empty(); } bool is_creating_pg(pg_t pgid) const { return parent.creating_pgs.count(pgid); } + virtual void maybe_add_creating_pgs(epoch_t scan_epoch, + creating_pgs_t *pending_creates) const { + if (parent.last_pg_scan >= scan_epoch) { + for (auto& pgid : parent.creating_pgs) { + auto st = parent.pg_stat.find(pgid); + assert(st != parent.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_creatings->pgs.emplace(pgid, created); + } + } + } epoch_t get_min_last_epoch_clean() const { return parent.get_min_last_epoch_clean(); } bool have_full_osds() const { return !parent.full_osds.empty(); }