From: Kefu Chai Date: Tue, 14 Nov 2017 10:42:02 +0000 (+0800) Subject: osd: subscribe osdmaps if any pending pgs X-Git-Tag: v12.2.3~114^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5f2e1660055d296640eebcfcaf13435dff212ef;p=ceph.git osd: subscribe osdmaps if any pending pgs 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 (cherry picked from commit 4037ab44b30ab23b2e464b24a82fee6fff9a2d08) --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 926a3be7e034..4dcb3940cf4a 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4458,6 +4458,7 @@ static vector twiddle(const vector& 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);