From: Sage Weil Date: Wed, 24 Apr 2013 19:26:37 +0000 (-0700) Subject: mon: send clients away while sychronizing X-Git-Tag: v0.61~100^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a9791dae1b64cab4eca6e70d165d8a51eafc86cc;p=ceph.git mon: send clients away while sychronizing When we are out of quorum, we waitlist client messages or (eventually) send them elsewhere. If we are synchronizing, do the same. Signed-off-by: Sage Weil --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 2338e9320ead..aabf5f1eb76f 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -989,6 +989,8 @@ void Monitor::sync_finish(entity_inst_t &entity, bool abort) trim_enable_timer = new C_TrimEnable(this); timer.add_event_after(30.0, trim_enable_timer); } + + finish_contexts(g_ceph_context, maybe_wait_for_quorum); } void Monitor::handle_sync_finish(MMonSync *m) @@ -3009,6 +3011,35 @@ void Monitor::send_command(const entity_inst_t& inst, try_send_message(c, inst); } +void Monitor::waitlist_or_zap_client(Message *m) +{ + /** + * Wait list the new session until we're in the quorum, assuming it's + * sufficiently new. + * tick() will periodically send them back through so we can send + * the client elsewhere if we don't think we're getting back in. + * + * But we whitelist a few sorts of messages: + * 1) Monitors can talk to us at any time, of course. + * 2) auth messages. It's unlikely to go through much faster, but + * it's possible we've just lost our quorum status and we want to take... + * 3) command messages. We want to accept these under all possible + * circumstances. + */ + Connection *con = m->get_connection(); + utime_t too_old = ceph_clock_now(g_ceph_context); + too_old -= g_ceph_context->_conf->mon_lease; + if (m->get_recv_stamp() > too_old && + con->is_connected()) { + dout(5) << "waitlisting message " << *m << dendl; + maybe_wait_for_quorum.push_back(new C_RetryMessage(this, m)); + } else { + dout(1) << "discarding message " << *m << " and sending client elsewhere" << dendl; + messenger->mark_down(con); + m->put(); + } +} + bool Monitor::_ms_dispatch(Message *m) { bool ret = true; @@ -3037,36 +3068,9 @@ bool Monitor::_ms_dispatch(Message *m) s = NULL; } if (!s) { - if (!exited_quorum.is_zero() - && !src_is_mon) { - /** - * Wait list the new session until we're in the quorum, assuming it's - * sufficiently new. - * tick() will periodically send them back through so we can send - * the client elsewhere if we don't think we're getting back in. - * - * But we whitelist a few sorts of messages: - * 1) Monitors can talk to us at any time, of course. - * 2) auth messages. It's unlikely to go through much faster, but - * it's possible we've just lost our quorum status and we want to take... - * 3) command messages. We want to accept these under all possible - * circumstances. - */ - utime_t too_old = ceph_clock_now(g_ceph_context); - too_old -= g_ceph_context->_conf->mon_lease; - if (m->get_recv_stamp() > too_old - && connection->is_connected()) { - dout(5) << "waitlisting message " << *m - << " until we get in quorum" << dendl; - maybe_wait_for_quorum.push_back(new C_RetryMessage(this, m)); - } else { - dout(1) << "discarding message " << *m - << " and sending client elsewhere; we are not in quorum" - << dendl; - messenger->mark_down(connection); - m->put(); - } - return true; + if (!exited_quorum.is_zero() && !src_is_mon) { + waitlist_or_zap_client(m); + return true; } dout(10) << "do not have session, making new one" << dendl; s = session_map.new_session(m->get_source_inst(), m->get_connection()); @@ -3099,6 +3103,11 @@ bool Monitor::_ms_dispatch(Message *m) if (s) dout(20) << " caps " << s->caps.get_str() << dendl; + if (is_synchronizing() && !src_is_mon) { + waitlist_or_zap_client(m); + return true; + } + { switch (m->get_type()) { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 9e03c17d2d87..1a19914ba927 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -1332,6 +1332,7 @@ public: void resend_routed_requests(); void remove_session(MonSession *s); void remove_all_sessions(); + void waitlist_or_zap_client(Message *m); void send_command(const entity_inst_t& inst, const vector& com, version_t version);