]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: limit MOSDMap message size by bytes
authorSage Weil <sage@redhat.com>
Fri, 8 Feb 2019 13:22:28 +0000 (07:22 -0600)
committerNathan Cutler <ncutler@suse.com>
Wed, 24 Jul 2019 10:08:27 +0000 (12:08 +0200)
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit dcf1cd00cc6e2595c283b4a73a4de9df50e7330a)

Conflicts:
src/mon/OSDMonitor.cc
- g_conf(), ceph_assert

src/mon/OSDMonitor.cc

index 7cff9ee9fc0cd7283b8f6b8a6152a5589785d669..3052719f1a511391c23d8d5a9f582156f7bbc41e 100644 (file)
@@ -2163,17 +2163,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 = std::max(first, m->get_full_first());
-       e <= std::min(last, m->get_full_last()) && max > 0;
+       e <= std::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 = std::max(first, m->get_inc_first());
-       e <= std::min(last, m->get_inc_last()) && max > 0;
+       e <= std::min(last, m->get_inc_last()) && max > 0 && max_bytes > 0;
        ++e, --max) {
-    int r = get_version(e, features, reply->incremental_maps[e]);
+    bufferlist& bl = reply->incremental_maps[e];
+    int r = get_version(e, features, bl);
     assert(r >= 0);
+    max_bytes -= bl.length();
   }
   reply->oldest_map = first;
   reply->newest_map = last;