]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: some minor refactoring/cleanup in handle_osd_ping
authorSage Weil <sage@redhat.com>
Tue, 18 Jun 2019 13:30:02 +0000 (08:30 -0500)
committerSage Weil <sage@redhat.com>
Mon, 5 Aug 2019 18:34:14 +0000 (13:34 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc

index d67002909e9ef25188a8be1e0e16bc0f34f334c6..f65086028a16feb51bd6f767f1c1d9876572b4db 100644 (file)
@@ -4525,6 +4525,8 @@ void OSD::handle_osd_ping(MOSDPing *m)
     return;
   }
 
+  utime_t now = ceph_clock_now();
+  ConnectionRef con(m->get_connection());
   OSDMapRef curmap = service.get_osdmap();
   if (!curmap) {
     heartbeat_lock.unlock();
@@ -4561,7 +4563,8 @@ void OSD::handle_osd_ping(MOSDPing *m)
       }
 
       if (!cct->get_heartbeat_map()->is_healthy()) {
-       dout(10) << "internal heartbeat not healthy, dropping ping request" << dendl;
+       dout(10) << "internal heartbeat not healthy, dropping ping request"
+                << dendl;
        break;
       }
 
@@ -4569,13 +4572,14 @@ void OSD::handle_osd_ping(MOSDPing *m)
                                curmap->get_epoch(),
                                MOSDPing::PING_REPLY, m->stamp,
                                cct->_conf->osd_heartbeat_min_size);
-      m->get_connection()->send_message(r);
+      con->send_message(r);
 
       if (curmap->is_up(from)) {
        if (is_active()) {
-         ConnectionRef con = service.get_con_osd_cluster(from, curmap->get_epoch());
-         if (con) {
-           service.maybe_share_map(con.get(), curmap, m->map_epoch);
+         ConnectionRef cluster_con = service.get_con_osd_cluster(
+           from, curmap->get_epoch());
+         if (cluster_con) {
+           service.maybe_share_map(cluster_con.get(), curmap, m->map_epoch);
          }
        }
       } else if (!curmap->exists(from) ||
@@ -4586,7 +4590,7 @@ void OSD::handle_osd_ping(MOSDPing *m)
                                  MOSDPing::YOU_DIED,
                                  m->stamp,
                                  cct->_conf->osd_heartbeat_min_size);
-       m->get_connection()->send_message(r);
+       con->send_message(r);
       }
     }
     break;
@@ -4597,13 +4601,13 @@ void OSD::handle_osd_ping(MOSDPing *m)
       if (i != heartbeat_peers.end()) {
         auto acked = i->second.ping_history.find(m->stamp);
         if (acked != i->second.ping_history.end()) {
-          utime_t now = ceph_clock_now();
           int &unacknowledged = acked->second.second;
-          if (m->get_connection() == i->second.con_back) {
+          if (con == i->second.con_back) {
             dout(25) << "handle_osd_ping got reply from osd." << from
                      << " first_tx " << i->second.first_tx
                      << " last_tx " << i->second.last_tx
-                     << " last_rx_back " << i->second.last_rx_back << " -> " << now
+                     << " last_rx_back " << i->second.last_rx_back
+                    << " -> " << now
                      << " last_rx_front " << i->second.last_rx_front
                      << dendl;
             i->second.last_rx_back = now;
@@ -4615,12 +4619,13 @@ void OSD::handle_osd_ping(MOSDPing *m)
               ceph_assert(unacknowledged > 0);
               --unacknowledged;
             }
-          } else if (m->get_connection() == i->second.con_front) {
+          } else if (con == i->second.con_front) {
             dout(25) << "handle_osd_ping got reply from osd." << from
                      << " first_tx " << i->second.first_tx
                      << " last_tx " << i->second.last_tx
                      << " last_rx_back " << i->second.last_rx_back
-                     << " last_rx_front " << i->second.last_rx_front << " -> " << now
+                     << " last_rx_front " << i->second.last_rx_front
+                    << " -> " << now
                      << dendl;
             i->second.last_rx_front = now;
             ceph_assert(unacknowledged > 0);
@@ -4667,9 +4672,10 @@ void OSD::handle_osd_ping(MOSDPing *m)
       if (m->map_epoch &&
          curmap->is_up(from)) {
        if (is_active()) {
-         ConnectionRef con = service.get_con_osd_cluster(from, curmap->get_epoch());
-         if (con) {
-           service.maybe_share_map(con.get(), curmap, m->map_epoch);
+         ConnectionRef cluster_con = service.get_con_osd_cluster(
+           from, curmap->get_epoch());
+         if (cluster_con) {
+           service.maybe_share_map(cluster_con.get(), curmap, m->map_epoch);
          }
        }
       }