]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: remember is_primary when adding pending creating pgs
authorKefu Chai <kchai@redhat.com>
Sun, 29 Oct 2017 11:07:54 +0000 (19:07 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 21 Nov 2017 08:38:59 +0000 (16:38 +0800)
so mgr can avoid calculating the same PG from different OSDs.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h

index dee9f7ab1eb93658bf7ab8d683880972e4682c53..97b829a53339e14546507d6a6aaaf3f3f02a9438 100644 (file)
@@ -4162,7 +4162,8 @@ bool OSD::maybe_wait_for_max_pg(spg_t pgid, bool is_mon_create)
   if (is_mon_create) {
     pending_creates_from_mon++;
   } else {
-    pending_creates_from_osd.emplace(pgid.pgid);
+    bool is_primary = osdmap->get_pg_acting_rank(pgid.pgid, whoami) == 0;
+    pending_creates_from_osd.emplace(pgid.pgid, is_primary);
   }
   dout(5) << __func__ << " withhold creation of pg " << pgid
          << ": " << pg_map.size() << " >= "<< max_pgs_per_osd << dendl;
@@ -4213,8 +4214,8 @@ void OSD::resume_creating_pg()
        pgtemp = new MOSDPGTemp{osdmap->get_epoch()};
       }
       vector<int> acting;
-      osdmap->pg_to_up_acting_osds(*pg, nullptr, nullptr, &acting, nullptr);
-      pgtemp->pg_temp[*pg] = twiddle(acting);
+      osdmap->pg_to_up_acting_osds(pg->first, nullptr, nullptr, &acting, nullptr);
+      pgtemp->pg_temp[pg->first] = twiddle(acting);
       pg = pending_creates_from_osd.erase(pg);
       spare_pgs--;
     }
@@ -7875,7 +7876,7 @@ void OSD::consume_map()
     [[gnu::unused]] auto&& pending_create_locker = guardedly_lock(pending_creates_lock);
     for (auto pg = pending_creates_from_osd.cbegin();
         pg != pending_creates_from_osd.cend();) {
-      if (osdmap->get_pg_acting_rank(*pg, whoami) < 0) {
+      if (osdmap->get_pg_acting_rank(pg->first, whoami) < 0) {
        pg = pending_creates_from_osd.erase(pg);
       } else {
        ++pg;
index 9e3d4a0c84e1b6d95eebc5d039ff2ce79d06ea45..c0591a4d1ffc14bb25f34fc6ad187401886b0e62 100644 (file)
@@ -1925,7 +1925,8 @@ protected:
   ceph::unordered_map<spg_t, PG*> pg_map; // protected by pg_map lock
 
   std::mutex pending_creates_lock;
-  std::set<pg_t> pending_creates_from_osd;
+  using create_from_osd_t = std::pair<pg_t, bool /* is primary*/>;
+  std::set<create_from_osd_t> pending_creates_from_osd;
   unsigned pending_creates_from_mon = 0;
 
   map<spg_t, list<PG::CephPeeringEvtRef> > peering_wait_for_split;