From 7f964fe48adb7cd62dd1ad09683f2e2d28ed2854 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 8 Mar 2017 11:27:31 +0800 Subject: [PATCH] mon/MonClient: don't return zero global_id active_con is reset after re-connecting. get_global_id() return 0 before mon client receives the MAuthReply. The zero global_id confuses mds code. in this change, MonClient promote the active_con's global_id to this->global_id once it's authorized. and returns this->global_id in get_global_id(). Fixes: http://tracker.ceph.com/issues/19134 Signed-off-by: "Yan, Zheng" Signed-off-by: Kefu Chai --- src/mon/MonClient.cc | 10 +++++++--- src/mon/MonClient.h | 7 ++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index c685996a8e6..f1ffef709af 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -480,6 +480,10 @@ void MonClient::handle_auth(MAuthReply *m) int ret = active_con->authenticate(m); m->put(); std::swap(auth, active_con->get_auth()); + if (global_id != active_con->get_global_id()) { + lderr(cct) << __func__ << " peer assigned me a different global_id: " + << active_con->get_global_id() << dendl; + } if (ret != -EAGAIN) { _finish_auth(ret); } @@ -524,8 +528,10 @@ void MonClient::handle_auth(MAuthReply *m) log_client->reset_session(); send_log(); } - if (active_con) + if (active_con) { std::swap(auth, active_con->get_auth()); + global_id = active_con->get_global_id(); + } } _finish_auth(auth_err); if (!auth_err) { @@ -574,8 +580,6 @@ void MonClient::_reopen_session(int rank) assert(monc_lock.is_locked()); ldout(cct, 10) << __func__ << " rank " << rank << dendl; - // save global_id if any before nuking active_con - const uint64_t global_id = active_con ? active_con->get_global_id() : 0; active_con.reset(); pending_cons.clear(); diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 6a154fc6fce..638c7db06b7 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -191,6 +191,7 @@ private: // authenticate std::unique_ptr auth; uint32_t want_keys = 0; + uint64_t global_id = 0; Cond auth_cond; int authenticate_err = 0; @@ -394,11 +395,7 @@ public: uint64_t get_global_id() const { Mutex::Locker l(monc_lock); - if (active_con) { - return active_con->get_global_id(); - } else { - return 0; - } + return global_id; } void set_messenger(Messenger *m) { messenger = m; } -- 2.39.5