]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/MonClient: don't return zero global_id 13853/head
authorKefu Chai <kchai@redhat.com>
Wed, 8 Mar 2017 03:27:31 +0000 (11:27 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 10 Mar 2017 12:54:08 +0000 (20:54 +0800)
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" <zyan@redhat.com>
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/MonClient.cc
src/mon/MonClient.h

index c685996a8e64c6d7959327599c602d9b1ef2a83d..f1ffef709afb1e2b7ab95889c88cb08ce1f6ea33 100644 (file)
@@ -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();
 
index 6a154fc6fce7c339bc9bd38948847d5fe431ea00..638c7db06b70f022d7f89b3f5985448dc3542eed 100644 (file)
@@ -191,6 +191,7 @@ private:
   // authenticate
   std::unique_ptr<AuthClientHandler> 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; }