From: Greg Farnum Date: Mon, 28 Jul 2014 21:19:59 +0000 (-0700) Subject: OSD: introduce require_self_aliveness(OpRequestRef&,epoch_t) function X-Git-Tag: v0.85~96^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e179e9227b4a4482d8359682092fd7f426b9a919;p=ceph.git OSD: introduce require_self_aliveness(OpRequestRef&,epoch_t) function 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 --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d3b648cb8252..911e903baf14 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6564,11 +6564,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) || @@ -6612,9 +6630,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; } @@ -6641,12 +6657,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; } diff --git a/src/osd/OSD.h b/src/osd/OSD.h index cc9c108a637a..81158d04a6d6 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -1802,6 +1802,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);