]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: create a helper for handling OSDMap subscriptions, and clean them up
authorGreg Farnum <greg@inktank.com>
Tue, 11 Feb 2014 21:34:39 +0000 (13:34 -0800)
committerGreg Farnum <greg@inktank.com>
Tue, 25 Feb 2014 19:42:02 +0000 (11:42 -0800)
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 <greg@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 6db3ae851d1c936de045390d18b1c6ae95f2a209)

Conflicts:

src/osd/OSD.h

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

index 96b0b33906323ca96fbf691e5962e7cff51fb508..6d1979c0ecc59afe3a7ecbd69ae0fd26a83c71ea 100644 (file)
@@ -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) {
index c14636c5154cb3191977a767aa3846326833cca5..231ada583b84723c34e9adec02c08a6ec955b730 100644 (file)
@@ -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 {