]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/OSDMonitor: moving MOSDPGCreate2 creation out of the loop
authorMatan Breizman <mbreizma@redhat.com>
Wed, 22 Jun 2022 12:27:21 +0000 (12:27 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 27 Jun 2022 13:44:44 +0000 (13:44 +0000)
Since we no longer differentiate between MOSDCreate1/2,
we can refactor the message creation.

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/mon/OSDMonitor.cc

index c8774fdaa19de34e560d0462e084b0fc0a5b3cca..26020e7f1ef4d4a793a0147cd6f9818472846f08 100644 (file)
@@ -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<MOSDPGCreate2>(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;