]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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>
Wed, 31 Jan 2018 16:15:21 +0000 (00:15 +0800)
so mgr can avoid calculating the same PG from different OSDs.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 486515ae884b91571a9066296680fff78f93f66d)

src/osd/OSD.cc
src/osd/OSD.h

index 2a26bb8fe2e9c6e6db452197854a0d6cc42bdb0f..8628d0c547203397df4a0a331baa0501adbfb28e 100644 (file)
@@ -4435,7 +4435,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;
@@ -4485,8 +4486,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--;
     }
@@ -8326,7 +8327,7 @@ void OSD::consume_map()
     lock_guard<mutex> pending_creates_locker{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 e34bd518e7b3b5a8056085549a6831e49fdf92ec..235dfaa81631957169003eb0ca5a072aa7fcc614 100644 (file)
@@ -1947,7 +1947,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;