]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: limit number of inc osdmaps send to peers, clients
authorSage Weil <sage@inktank.com>
Wed, 10 Jul 2013 18:02:08 +0000 (11:02 -0700)
committerSage Weil <sage@inktank.com>
Wed, 10 Jul 2013 18:03:08 +0000 (11:03 -0700)
We should not send an unbounded number of inc maps to our peers or clients.
In particular, if a peer is not contacted for a while, we may think they
have a very old map (say, 10000 epochs ago) and send thousands of inc maps
when the distribution shifts and we need to peer.

Note that if we do not send enough maps, the peers will make do by
requesting the map from somewhere else (currently the mon).  Regardless
of the source, however, we must limit the amount that we speculatively
share as it usually is not needed.

Backport: cuttlefish, bobtail
Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
(cherry picked from commit 653e04a79430317e275dd77a46c2b17c788b860b)

src/common/config_opts.h
src/osd/OSD.cc

index b19d274eb2a26b8ec96e38fd312902f2eaf46710..11da6c5bb211cff6c97f0a6af1b83c0208c7797e 100644 (file)
@@ -385,6 +385,7 @@ OPTION(osd_pool_default_flags, OPT_INT, 0)   // default flags for new pools
 OPTION(osd_map_dedup, OPT_BOOL, true)
 OPTION(osd_map_cache_size, OPT_INT, 500)
 OPTION(osd_map_message_max, OPT_INT, 100)  // max maps per MOSDMap message
+OPTION(osd_map_share_max_epochs, OPT_INT, 100)  // cap on # of inc maps we send to peers, clients
 OPTION(osd_op_threads, OPT_INT, 2)    // 0 == no threading
 OPTION(osd_op_pq_max_tokens_per_priority, OPT_U64, 4194304)
 OPTION(osd_op_pq_min_cost, OPT_U64, 65536)
index 7ed62c772e4667dad4addfd4791ee03a2959196e..c604953d027ca3e8bd7b94c5eafb9a4504b8a050 100644 (file)
@@ -4728,7 +4728,8 @@ void OSD::send_map(MOSDMap *m, Connection *con)
 
 void OSD::send_incremental_map(epoch_t since, Connection *con)
 {
-  dout(10) << "send_incremental_map " << since << " -> " << osdmap->get_epoch()
+  epoch_t to = osdmap->get_epoch();
+  dout(10) << "send_incremental_map " << since << " -> " << to
            << " to " << con << " " << con->get_peer_addr() << dendl;
 
   if (since < superblock.oldest_map) {
@@ -4736,14 +4737,18 @@ void OSD::send_incremental_map(epoch_t since, Connection *con)
     MOSDMap *m = new MOSDMap(monc->get_fsid());
     m->oldest_map = superblock.oldest_map;
     m->newest_map = superblock.newest_map;
-    epoch_t e = osdmap->get_epoch();
-    get_map_bl(e, m->maps[e]);
+    get_map_bl(to, m->maps[to]);
     send_map(m, con);
     return;
   }
 
-  while (since < osdmap->get_epoch()) {
-    epoch_t to = osdmap->get_epoch();
+  if (to > since && to - since > g_conf->osd_map_share_max_epochs) {
+    dout(10) << "  " << (to - since) << " > max " << g_conf->osd_map_share_max_epochs
+            << ", only sending most recent" << dendl;
+    since = to - g_conf->osd_map_share_max_epochs;
+  }
+
+  while (since < to) {
     if (to - since > (epoch_t)g_conf->osd_map_message_max)
       to = since + g_conf->osd_map_message_max;
     MOSDMap *m = build_incremental_map_msg(since, to);