]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: limit MOSDMap message size by bytes 28640/head
authorSage Weil <sage@redhat.com>
Fri, 8 Feb 2019 13:22:28 +0000 (07:22 -0600)
committerKefu Chai <kchai@redhat.com>
Wed, 19 Jun 2019 03:51:05 +0000 (11:51 +0800)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit dcf1cd00cc6e2595c283b4a73a4de9df50e7330a)

Conflicts:
src/mon/OSDMonitor.cc:
1. replace g_conf() with g_conf, g_conf was replaced
with g_conf() to prepare for the crimson project. and that change was
not backported to luminous. so restore all `g_conf()` to `g_conf` in
this backport.
2. replace std::min() and std::max() with MIN() and
MAX() macros, as we modernize it in an unrelated change. and that
change was not backported to luminous. so let's be conservative, and
restore to the old style macros.

src/mon/OSDMonitor.cc

index f9a50f31c446c346e2f7f6c1bc078702c64ac48d..c798663470cc0da3537de3723414962e8641ddde 100644 (file)
@@ -1854,17 +1854,22 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op)
   epoch_t first = get_first_committed();
   epoch_t last = osdmap.get_epoch();
   int max = g_conf->osd_map_message_max;
+  ssize_t max_bytes = g_conf->osd_map_message_max_bytes;
   for (epoch_t e = MAX(first, m->get_full_first());
-       e <= MIN(last, m->get_full_last()) && max > 0;
+       e <= MIN(last, m->get_full_last()) && max > 0 && max_bytes > 0;
        ++e, --max) {
-    int r = get_version_full(e, features, reply->maps[e]);
+    bufferlist& bl = reply->maps[e];
+    int r = get_version_full(e, features, bl);
     assert(r >= 0);
+    max_bytes -= bl.length();
   }
   for (epoch_t e = MAX(first, m->get_inc_first());
-       e <= MIN(last, m->get_inc_last()) && max > 0;
+       e <= MIN(last, m->get_inc_last()) && max > 0 && max_bytes > 0;
        ++e, --max) {
-    int r = get_version(e, features, reply->incremental_maps[e]);
-    assert(r >= 0);
+    bufferlist& bl = reply->incremental_maps[e];
+    int r = get_version(e, features, bl);
+    ceph_assert(r >= 0);
+    max_bytes -= bl.length();
   }
   reply->oldest_map = first;
   reply->newest_map = last;