]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: add require_same_peer_inst(OpRequestRef&,OSDMap&) helper
authorGreg Farnum <greg@inktank.com>
Tue, 29 Jul 2014 01:33:56 +0000 (18:33 -0700)
committerSage Weil <sage@redhat.com>
Sat, 9 Aug 2014 05:59:25 +0000 (22:59 -0700)
Signed-off-by: Greg Farnum <greg@inktank.com>
(cherry picked from commit e99acf9810976b1fc74b84ad289773af43be973f)

src/osd/OSD.cc
src/osd/OSD.h

index bab983fcd6a05ecbeac11d4052fd72c7938ffad7..b00219b57a3aa8f23bf8a9d5d4876a622632ddcb 100644 (file)
@@ -6694,22 +6694,19 @@ bool OSD::require_self_aliveness(OpRequestRef& op, epoch_t epoch)
   return true;
 }
 
-bool OSD::require_up_osd_peer(OpRequestRef& op, OSDMapRef& map,
-                              epoch_t their_epoch)
+bool OSD::require_same_peer_instance(OpRequestRef& op, OSDMapRef& map)
 {
-  int from = op->get_req()->get_source().num();
-  if (!require_self_aliveness(op, their_epoch)) {
-    return false;
-  } else if (!require_osd_peer(op)) {
-    return false;
-  } else if (map->get_epoch() >= their_epoch &&
-      (!map->have_inst(from) ||
-      map->get_cluster_addr(from) != op->get_req()->get_source_inst().addr)) {
-    dout(0) << "require_osd_peer_up received from non-up osd "
-            << op->get_req()->get_connection()->get_peer_addr()
-            << " " << *op->get_req() << dendl;
-
-    ConnectionRef con = op->get_req()->get_connection();
+  Message *m = op->get_req();
+  int from = m->get_source().num();
+  
+  if (!map->have_inst(from) ||
+      (map->get_cluster_addr(from) != m->get_source_inst().addr)) {
+    dout(5) << "from dead osd." << from << ", marking down, "
+           << " msg was " << m->get_source_inst().addr
+           << " expected " << (map->have_inst(from) ?
+                               map->get_cluster_addr(from) : entity_addr_t())
+           << dendl;
+    ConnectionRef con = m->get_connection();
     cluster_messenger->mark_down(con.get());
     Session *s = static_cast<Session*>(con->get_priv());
     if (s) {
@@ -6719,10 +6716,22 @@ bool OSD::require_up_osd_peer(OpRequestRef& op, OSDMapRef& map,
       s->session_dispatch_lock.Unlock();
       s->put();
     }
-
     return false;
   }
+  return true;
+}
 
+bool OSD::require_up_osd_peer(OpRequestRef& op, OSDMapRef& map,
+                              epoch_t their_epoch)
+{
+  if (!require_self_aliveness(op, their_epoch)) {
+    return false;
+  } else if (!require_osd_peer(op)) {
+    return false;
+  } else if (map->get_epoch() >= their_epoch &&
+            !require_same_peer_instance(op, map)) {
+    return false;
+  }
   return true;
 }
 
@@ -6749,26 +6758,9 @@ bool OSD::require_same_or_newer_map(OpRequestRef& op, epoch_t epoch)
   }
 
   // ok, our map is same or newer.. do they still exist?
-  if (m->get_connection()->get_messenger() == cluster_messenger) {
-    int from = m->get_source().num();
-    if (!osdmap->have_inst(from) ||
-       osdmap->get_cluster_addr(from) != m->get_source_inst().addr) {
-      dout(5) << "from dead osd." << from << ", marking down, "
-             << " msg was " << m->get_source_inst().addr
-             << " expected " << (osdmap->have_inst(from) ? osdmap->get_cluster_addr(from) : entity_addr_t())
-             << dendl;
-      ConnectionRef con = m->get_connection();
-      cluster_messenger->mark_down(con.get());
-      Session *s = static_cast<Session*>(con->get_priv());
-      if (s) {
-       s->session_dispatch_lock.Lock();
-       clear_session_waiting_on_map(s);
-       con->set_priv(NULL);   // break ref <-> session cycle, if any
-       s->session_dispatch_lock.Unlock();
-       s->put();
-      }
-      return false;
-    }
+  if (m->get_connection()->get_messenger() == cluster_messenger &&
+      !require_same_peer_instance(op, osdmap)) {
+    return false;
   }
 
   return true;
index c2c113e72b0301e9bf40e4e1e08eb163e23a9c9b..14a4dde82727ee781be98ebda43626bdae0e3182 100644 (file)
@@ -1815,6 +1815,12 @@ protected:
    * still are.
    */
   bool require_self_aliveness(OpRequestRef& op, epoch_t alive_since);
+  /**
+   * Verifies that the OSD who sent the given op has the same
+   * address as in the given map.
+   * @pre op was sent by an OSD using the cluster messenger
+   */
+  bool require_same_peer_instance(OpRequestRef& op, OSDMapRef& map);
   bool require_up_osd_peer(OpRequestRef& Op, OSDMapRef& map,
                            epoch_t their_epoch);