From 61b2aeee7c37e03d5f6691c08c7760c48a85a2e1 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Tue, 11 Feb 2014 13:34:39 -0800 Subject: [PATCH] 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 Reviewed-by: Sage Weil (cherry picked from commit 6db3ae851d1c936de045390d18b1c6ae95f2a209) Conflicts: src/osd/OSD.h --- src/osd/OSD.cc | 15 +++++++++++++++ src/osd/OSD.h | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 96b0b33906323..6d1979c0ecc59 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -4925,6 +4925,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()); @@ -4969,6 +4981,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 c14636c5154cb..231ada583b847 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -591,7 +591,7 @@ protected: Messenger *cluster_messenger; Messenger *client_messenger; - MonClient *monc; + MonClient *monc; // check the "monc helpers" list before accessing directly PerfCounters *logger; ObjectStore *store; @@ -741,6 +741,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 { -- 2.39.5