]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: introduce require_self_aliveness(OpRequestRef&,epoch_t) function
authorGreg Farnum <greg@inktank.com>
Mon, 28 Jul 2014 21:19:59 +0000 (14:19 -0700)
committerSage Weil <sage@redhat.com>
Sat, 9 Aug 2014 05:59:17 +0000 (22:59 -0700)
Take the self-aliveness checks out of require_same_or_newer_map() and use
the new function for that and for require_up_osd_peer().

Signed-off-by: Greg Farnum <greg@inktank.com>
(cherry picked from commit e179e9227b4a4482d8359682092fd7f426b9a919)

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

index 36cfa6dd4d1ffcdcc1039788f597b9eb1b19e739..bab983fcd6a05ecbeac11d4052fd72c7938ffad7 100644 (file)
@@ -6678,11 +6678,29 @@ bool OSD::require_osd_peer(OpRequestRef& op)
   return true;
 }
 
+bool OSD::require_self_aliveness(OpRequestRef& op, epoch_t epoch)
+{
+  epoch_t up_epoch = service.get_up_epoch();
+  if (epoch < up_epoch) {
+    dout(7) << "from pre-up epoch " << epoch << " < " << up_epoch << dendl;
+    return false;
+  }
+
+  if (!is_active()) {
+    dout(7) << "still in boot state, dropping message " << *op->get_req() << dendl;
+    return false;
+  }
+
+  return true;
+}
+
 bool OSD::require_up_osd_peer(OpRequestRef& op, OSDMapRef& map,
                               epoch_t their_epoch)
 {
   int from = op->get_req()->get_source().num();
-  if (!require_osd_peer(op)) {
+  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) ||
@@ -6726,9 +6744,7 @@ bool OSD::require_same_or_newer_map(OpRequestRef& op, epoch_t epoch)
     return false;
   }
 
-  epoch_t up_epoch = service.get_up_epoch();
-  if (epoch < up_epoch) {
-    dout(7) << "from pre-up epoch " << epoch << " < " << up_epoch << dendl;
+  if (!require_self_aliveness(op, epoch)) {
     return false;
   }
 
@@ -6755,12 +6771,6 @@ bool OSD::require_same_or_newer_map(OpRequestRef& op, epoch_t epoch)
     }
   }
 
-  // ok, we have at least as new a map as they do.  are we (re)booting?
-  if (!is_active()) {
-    dout(7) << "still in boot state, dropping message " << *m << dendl;
-    return false;
-  }
-
   return true;
 }
 
index 180951b8760ece9e98da1c75c1092a9116f66ae3..c2c113e72b0301e9bf40e4e1e08eb163e23a9c9b 100644 (file)
@@ -1810,6 +1810,11 @@ protected:
 
   bool require_mon_peer(Message *m);
   bool require_osd_peer(OpRequestRef& op);
+  /***
+   * Verifies that we were alive in the given epoch, and that
+   * still are.
+   */
+  bool require_self_aliveness(OpRequestRef& op, epoch_t alive_since);
   bool require_up_osd_peer(OpRequestRef& Op, OSDMapRef& map,
                            epoch_t their_epoch);