]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge pull request #17309 from jcsp/wip-daemonserver-locks
authorKefu Chai <tchaikov@gmail.com>
Fri, 22 Sep 2017 04:30:41 +0000 (12:30 +0800)
committerGitHub <noreply@github.com>
Fri, 22 Sep 2017 04:30:41 +0000 (12:30 +0800)
mgr: locking fixes

Reviewed-by: Sage Weil <sage@redhat.com>
1  2 
src/mgr/DaemonServer.cc

index e1321f0b2a0456334b242d5e3f40509e6e5afc27,e384be395a62d5e3173cb49c1cded2498702cf27..88cf0285ef2f69f76710282a4a2df0b50520ee6f
@@@ -405,25 -417,35 +417,39 @@@ bool DaemonServer::handle_report(MMgrRe
      dout(20) << "updating existing DaemonState for " << key << dendl;
      daemon = daemon_state.get(key);
    } else {
 -    dout(4) << "constructing new DaemonState for " << key << dendl;
 -    daemon = std::make_shared<DaemonState>(daemon_state.types);
 -    // FIXME: crap, we don't know the hostname at this stage.
 -    daemon->key = key;
 -    daemon_state.insert(daemon);
 -    // FIXME: we should avoid this case by rejecting MMgrReport from
 -    // daemons without sessions, and ensuring that session open
 -    // always contains metadata.
 +    // we don't know the hostname at this stage, reject MMgrReport here.
 +    dout(1) << "rejecting report from " << key << ", since we do not have its metadata now."
 +          << dendl;
 +    // kill session
 +    MgrSessionRef session(static_cast<MgrSession*>(m->get_connection()->get_priv()));
 +    if (!session) {
 +      return false;
 +    }
 +    m->get_connection()->mark_down();
 +    session->put();
 +
 +    return false;
    }
+   // Update the DaemonState
    assert(daemon != nullptr);
-   auto &daemon_counters = daemon->perf_counters;
    {
      Mutex::Locker l(daemon->lock);
+     auto &daemon_counters = daemon->perf_counters;
      daemon_counters.update(m);
+     if (daemon->service_daemon) {
+       utime_t now = ceph_clock_now();
+       if (m->daemon_status) {
+         daemon->service_status = *m->daemon_status;
+         daemon->service_status_stamp = now;
+       }
+       daemon->last_service_beacon = now;
+     } else if (m->daemon_status) {
+       derr << "got status from non-daemon " << key << dendl;
+     }
    }
    // if there are any schema updates, notify the python modules
    if (!m->declare_types.empty() || !m->undeclare_types.empty()) {
      ostringstream oss;