From: Greg Farnum Date: Tue, 11 Feb 2014 21:34:39 +0000 (-0800) Subject: OSD: create a helper for handling OSDMap subscriptions, and clean them up X-Git-Tag: v0.78~171^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6db3ae851d1c936de045390d18b1c6ae95f2a209;p=ceph.git OSD: create a helper for handling OSDMap subscriptions, and clean them up We've had some trouble with not clearing out subscription requests and overloading the monitors (though only because of other bugs). Write a helper for handling subscription requests that we can use to centralize safety logic. Clear out the subscription whenever we get a map that covers it; if there are more maps available than we received, we will issue another subscription request based on "m->newest_map" at the end of handle_osd_map(). Notice that the helper will no longer request old maps which we already have, and that unless forced it will not dispatch multiple subscribe requests to a single monitor. Skipping old maps is safe: 1) we only trim old maps when the monitor tells us to, 2) we do not send messages to our peers until we have updated our maps from the monitor. That means only old and broken OSDs will send us messages based on maps in our past, and we can (and should) ignore any directives from them anyway. Signed-off-by: Greg Farnum --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 673b3a32d359..bc490a8ff571 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -5011,6 +5011,18 @@ struct C_OnMapApply : public Context { } }; +void OSD::osdmap_subscribe(version_t epoch, bool force_request) +{ + OSDMapRef osdmap = service.get_osdmap(); + if (osdmap->get_epoch() >= epoch) + return; + + if (monc->sub_want_increment("osdmap", epoch, CEPH_SUBSCRIBE_ONETIME) || + force_request) { + monc->renew_subs(); + } +} + void OSD::handle_osd_map(MOSDMap *m) { assert(osd_lock.is_locked()); @@ -5062,6 +5074,9 @@ void OSD::handle_osd_map(MOSDMap *m) return; } + // even if this map isn't from a mon, we may have satisfied our subscription + monc->sub_got("osdmap", last); + // missing some? bool skip_maps = false; if (first > osdmap->get_epoch() + 1) { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index cebceb7150e9..ed124c9ca8c0 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -673,7 +673,7 @@ protected: Messenger *cluster_messenger; Messenger *client_messenger; Messenger *objecter_messenger; - MonClient *monc; + MonClient *monc; // check the "monc helpers" list before accessing directly PerfCounters *logger; PerfCounters *recoverystate_perf; ObjectStore *store; @@ -825,6 +825,23 @@ public: }; private: + /** + * @defgroup monc helpers + * + * Right now we only have the one + */ + + /** + * Ask the Monitors for a sequence of OSDMaps. + * + * @param epoch The epoch to start with when replying + * @param force_request True if this request forces a new subscription to + * the monitors; false if an outstanding request that encompasses it is + * sufficient. + */ + void osdmap_subscribe(version_t epoch, bool force_request); + /** @} monc helpers */ + // -- heartbeat -- /// information about a heartbeat peer struct HeartbeatInfo {