From 4bd6eb626fc46a7262517e5a8da5e8cabf5ba6a0 Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Wed, 22 Jun 2022 12:27:21 +0000 Subject: [PATCH] mon/OSDMonitor: moving MOSDPGCreate2 creation out of the loop Since we no longer differentiate between MOSDCreate1/2, we can refactor the message creation. Signed-off-by: Matan Breizman --- src/mon/OSDMonitor.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index c8774fdaa19de..26020e7f1ef4d 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -5041,7 +5041,7 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons return next; ceph_assert(!creating_pgs_by_epoch->second.empty()); - MOSDPGCreate2 *m = nullptr; + auto m = make_message(creating_pgs_epoch); epoch_t last = 0; for (auto epoch_pgs = creating_pgs_by_epoch->second.lower_bound(next); @@ -5056,9 +5056,6 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons // last_scrub_stamp upon pg creation. auto create = creating_pgs.pgs.find(pg.pgid); ceph_assert(create != creating_pgs.pgs.end()); - if (!m) { - m = new MOSDPGCreate2(creating_pgs_epoch); - } m->pgs.emplace(pg, make_pair(create->second.create_epoch, create->second.create_stamp)); if (create->second.history.epoch_created) { @@ -5071,8 +5068,8 @@ epoch_t OSDMonitor::send_pg_creates(int osd, Connection *con, epoch_t next) cons << " at " << create->second.create_epoch << dendl; } } - if (m) { - con->send_message(m); + if (!m->pgs.empty()) { + con->send_message2(std::move(m)); } else { dout(20) << __func__ << " osd." << osd << " from " << next << " has nothing to send" << dendl; -- 2.39.5