]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: print log for the creating_pgs changes
authorKefu Chai <kchai@redhat.com>
Wed, 24 May 2017 11:34:08 +0000 (19:34 +0800)
committerSage Weil <sage@redhat.com>
Fri, 2 Jun 2017 17:06:46 +0000 (13:06 -0400)
print more log messages when updating creating_pgs.

see-also: http://tracker.ceph.com/issues/20067
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/CreatingPGs.h
src/mon/OSDMonitor.cc
src/mon/PGMonitor.cc
src/mon/PGStatService.h

index f2d8ed2869747460c3b7f9c2a3cc6465f4c6a8ae..4ba91575f3cc0d25317dc04b8100963f7974fbfa 100644 (file)
@@ -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<int64_t> 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) {
index 28b18605d3b0ccfe4330e64501fccb4835035088..1b9877f63339302ccde641b0cd111453136b805b 100644 (file)
@@ -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<int64_t,pg_pool_t>& pools,
   const mempool::osdmap::set<int64_t>& 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()
index 4cdc81aa2c828da34868a446138d3c558fb7622c..19a0fa6d1a80498d2e0612a9bcdb19331c061888 100644 (file)
@@ -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();
index 63ed09844d875b38e36301c3ac4d92ef2284187f..c714c6e4c90938d252064b249595287940f19cf1 100644 (file)
@@ -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