From dcf1cd00cc6e2595c283b4a73a4de9df50e7330a Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 8 Feb 2019 07:22:28 -0600 Subject: [PATCH] mon/OSDMonitor: limit MOSDMap message size by bytes Signed-off-by: Sage Weil --- src/mon/OSDMonitor.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 0359653f08c..b0c9fa18d77 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -2234,17 +2234,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); ceph_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); ceph_assert(r >= 0); + max_bytes -= bl.length(); } reply->oldest_map = first; reply->newest_map = last; -- 2.39.5