]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: subscribe osdmaps if any pending pgs 19059/head
authorKefu Chai <kchai@redhat.com>
Tue, 14 Nov 2017 10:42:02 +0000 (18:42 +0800)
committerPrashant D <pdhange@redhat.com>
Mon, 20 Nov 2017 12:27:47 +0000 (07:27 -0500)
subscribe from monitor continously for new osdmaps so osd is able to get
the osdmap instructing it to delete PGs even if nobody is poking it.

Fixes: http://tracker.ceph.com/issues/22113
Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit 4037ab44b30ab23b2e464b24a82fee6fff9a2d08)

src/osd/OSD.cc

index 926a3be7e03422c9a9bff9e4f3c5914385020110..4dcb3940cf4a40ade912b78a96b05fd33f3ab0ac 100644 (file)
@@ -4458,6 +4458,7 @@ static vector<int32_t> twiddle(const vector<int>& acting) {
 void OSD::resume_creating_pg()
 {
   bool do_sub_pg_creates = false;
+  bool have_pending_creates = false;
   MOSDPGTemp *pgtemp = nullptr;
   {
     const auto max_pgs_per_osd =
@@ -4490,14 +4491,40 @@ void OSD::resume_creating_pg()
       pg = pending_creates_from_osd.erase(pg);
       spare_pgs--;
     }
+    have_pending_creates = (pending_creates_from_mon > 0 ||
+                           !pending_creates_from_osd.empty());
   }
+
+  bool do_renew_subs = false;
   if (do_sub_pg_creates) {
     if (monc->sub_want("osd_pg_creates", last_pg_create_epoch, 0)) {
       dout(4) << __func__ << ": resolicit pg creates from mon since "
              << last_pg_create_epoch << dendl;
-      monc->renew_subs();
+      do_renew_subs = true;
+    }
+  }
+  version_t start = osdmap->get_epoch() + 1;
+  if (have_pending_creates) {
+    // don't miss any new osdmap deleting PGs
+    if (monc->sub_want("osdmap", start, 0)) {
+      dout(4) << __func__ << ": resolicit osdmap from mon since "
+             << start << dendl;
+      do_renew_subs = true;
+    }
+  } else if (pgtemp || do_sub_pg_creates) {
+    // no need to subscribe the osdmap continuously anymore
+    // once the pgtemp and/or mon_subscribe(pg_creates) is sent
+    if (monc->sub_want_increment("osdmap", start, CEPH_SUBSCRIBE_ONETIME)) {
+      dout(4) << __func__ << ": re-subscribe osdmap(onetime) since"
+             << start << dendl;
+      do_renew_subs = true;
     }
   }
+
+  if (do_renew_subs) {
+    monc->renew_subs();
+  }
+
   if (pgtemp) {
     pgtemp->forced = true;
     monc->send_mon_message(pgtemp);