return true;
}
- cluster_messenger->mark_down(con.get());
+ 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_same_peer_instance(OpRequestRef& op, OSDMapRef& map)
+ {
+ 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();
++ con->mark_down();
+ 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;
+ }
+ 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;
+ }
+
/*
* require that we have same (or newer) map, and that
* the source is the pg primary.