summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2019-04-15 08:39:11 +0200
committerKefu Chai <kchai@redhat.com>2019-04-18 00:59:42 +0200
commita50a91d24349c8147c53f7aa109974160e8db120 (patch)
tree0f7083aff7bfbb077d0a09b52210dcaf5712bcb0
parentmgr/DaemonState: pass const by reference (diff)
downloadceph-a50a91d24349c8147c53f7aa109974160e8db120.tar.xz
ceph-a50a91d24349c8147c53f7aa109974160e8db120.zip
mgr/{Mgr,MgrStandby}: use ref_t<M>
Signed-off-by: Kefu Chai <kchai@redhat.com>
-rw-r--r--src/messages/MMgrDigest.h2
-rw-r--r--src/mgr/Mgr.cc28
-rw-r--r--src/mgr/Mgr.h10
-rw-r--r--src/mgr/MgrStandby.cc8
-rw-r--r--src/mgr/MgrStandby.h4
5 files changed, 24 insertions, 28 deletions
diff --git a/src/messages/MMgrDigest.h b/src/messages/MMgrDigest.h
index b92a8c291e4..00e237b4c33 100644
--- a/src/messages/MMgrDigest.h
+++ b/src/messages/MMgrDigest.h
@@ -48,6 +48,8 @@ private:
Message{MSG_MGR_DIGEST} {}
~MMgrDigest() override {}
+ using RefCountedObject::put;
+ using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc
index 60f42e20ea0..5726dcda424 100644
--- a/src/mgr/Mgr.cc
+++ b/src/mgr/Mgr.cc
@@ -491,16 +491,14 @@ void Mgr::handle_osd_map()
daemon_state.cull("osd", names_exist);
}
-void Mgr::handle_log(MLog *m)
+void Mgr::handle_log(ref_t<MLog> m)
{
for (const auto &e : m->entries) {
py_module_registry->notify_all(e);
}
-
- m->put();
}
-void Mgr::handle_service_map(MServiceMap *m)
+void Mgr::handle_service_map(ref_t<MServiceMap> m)
{
dout(10) << "e" << m->service_map.epoch << dendl;
cluster_state.set_service_map(m->service_map);
@@ -520,23 +518,22 @@ void Mgr::handle_mon_map()
daemon_state.cull("mon", names_exist);
}
-bool Mgr::ms_dispatch(Message *m)
+bool Mgr::ms_dispatch2(const ref_t<Message>& m)
{
dout(4) << *m << dendl;
std::lock_guard l(lock);
switch (m->get_type()) {
case MSG_MGR_DIGEST:
- handle_mgr_digest(static_cast<MMgrDigest*>(m));
+ handle_mgr_digest(ref_cast<MMgrDigest>(m));
break;
case CEPH_MSG_MON_MAP:
py_module_registry->notify_all("mon_map", "");
handle_mon_map();
- m->put();
break;
case CEPH_MSG_FS_MAP:
py_module_registry->notify_all("fs_map", "");
- handle_fs_map((MFSMap*)m);
+ handle_fs_map(ref_cast<MFSMap>(m));
return false; // I shall let this pass through for Client
break;
case CEPH_MSG_OSD_MAP:
@@ -547,15 +544,13 @@ bool Mgr::ms_dispatch(Message *m)
// Continuous subscribe, so that we can generate notifications
// for our MgrPyModules
objecter->maybe_request_map();
- m->put();
break;
case MSG_SERVICE_MAP:
- handle_service_map(static_cast<MServiceMap*>(m));
+ handle_service_map(ref_cast<MServiceMap>(m));
py_module_registry->notify_all("service_map", "");
- m->put();
break;
case MSG_LOG:
- handle_log(static_cast<MLog *>(m));
+ handle_log(ref_cast<MLog>(m));
break;
default:
@@ -565,7 +560,7 @@ bool Mgr::ms_dispatch(Message *m)
}
-void Mgr::handle_fs_map(MFSMap* m)
+void Mgr::handle_fs_map(ref_t<MFSMap> m)
{
ceph_assert(lock.is_locked_by_me());
@@ -657,11 +652,11 @@ bool Mgr::got_mgr_map(const MgrMap& m)
return false;
}
-void Mgr::handle_mgr_digest(MMgrDigest* m)
+void Mgr::handle_mgr_digest(ref_t<MMgrDigest> m)
{
dout(10) << m->mon_status_json.length() << dendl;
dout(10) << m->health_json.length() << dendl;
- cluster_state.load_digest(m);
+ cluster_state.load_digest(m.get());
py_module_registry->notify_all("mon_status", "");
py_module_registry->notify_all("health", "");
@@ -669,8 +664,7 @@ void Mgr::handle_mgr_digest(MMgrDigest* m)
// the pgmap might have changed since last time we were here.
py_module_registry->notify_all("pg_summary", "");
dout(10) << "done." << dendl;
-
- m->put();
+ m.reset();
if (!digest_received) {
digest_received = true;
diff --git a/src/mgr/Mgr.h b/src/mgr/Mgr.h
index 0248c9df61e..252d946bbc2 100644
--- a/src/mgr/Mgr.h
+++ b/src/mgr/Mgr.h
@@ -80,16 +80,16 @@ public:
return server.get_myaddrs();
}
- void handle_mgr_digest(MMgrDigest* m);
- void handle_fs_map(MFSMap* m);
+ void handle_mgr_digest(ceph::ref_t<MMgrDigest> m);
+ void handle_fs_map(ceph::ref_t<MFSMap> m);
void handle_osd_map();
- void handle_log(MLog *m);
- void handle_service_map(MServiceMap *m);
+ void handle_log(ceph::ref_t<MLog> m);
+ void handle_service_map(ceph::ref_t<MServiceMap> m);
void handle_mon_map();
bool got_mgr_map(const MgrMap& m);
- bool ms_dispatch(Message *m);
+ bool ms_dispatch2(const ceph::ref_t<Message>& m);
void background_init(Context *completion);
void shutdown();
diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc
index 2b0715421e2..418a2114cd2 100644
--- a/src/mgr/MgrStandby.cc
+++ b/src/mgr/MgrStandby.cc
@@ -374,7 +374,7 @@ void MgrStandby::_update_log_config()
}
}
-void MgrStandby::handle_mgr_map(MMgrMap* mmap)
+void MgrStandby::handle_mgr_map(ref_t<MMgrMap> mmap)
{
auto &map = mmap->get_map();
dout(4) << "received map epoch " << map.get_epoch() << dendl;
@@ -429,19 +429,19 @@ void MgrStandby::handle_mgr_map(MMgrMap* mmap)
}
}
-bool MgrStandby::ms_dispatch(Message *m)
+bool MgrStandby::ms_dispatch2(const ref_t<Message>& m)
{
std::lock_guard l(lock);
dout(4) << state_str() << " " << *m << dendl;
if (m->get_type() == MSG_MGR_MAP) {
- handle_mgr_map(static_cast<MMgrMap*>(m));
+ handle_mgr_map(ref_cast<MMgrMap>(m));
}
bool handled = false;
if (active_mgr) {
auto am = active_mgr;
lock.Unlock();
- handled = am->ms_dispatch(m);
+ handled = am->ms_dispatch2(m);
lock.Lock();
}
if (m->get_type() == MSG_MGR_MAP) {
diff --git a/src/mgr/MgrStandby.h b/src/mgr/MgrStandby.h
index 7adab68d701..8a7e633b1d7 100644
--- a/src/mgr/MgrStandby.h
+++ b/src/mgr/MgrStandby.h
@@ -61,7 +61,7 @@ protected:
std::string state_str();
- void handle_mgr_map(MMgrMap *m);
+ void handle_mgr_map(ceph::ref_t<MMgrMap> m);
void _update_log_config();
void send_beacon();
@@ -71,7 +71,7 @@ public:
MgrStandby(int argc, const char **argv);
~MgrStandby() override;
- bool ms_dispatch(Message *m) override;
+ bool ms_dispatch2(const ceph::ref_t<Message>& m) override;
bool ms_handle_reset(Connection *con) override { return false; }
void ms_handle_remote_reset(Connection *con) override {}
bool ms_get_authorizer(int dest_type, AuthAuthorizer **authorizer) override;