]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client,mds: use ref_cast<Foo> instead of Foo::msgref_cast
authorKefu Chai <kchai@redhat.com>
Sun, 14 Apr 2019 04:34:24 +0000 (12:34 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 17 Apr 2019 22:59:41 +0000 (06:59 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/client/Client.cc
src/mds/Beacon.cc
src/mds/Locker.cc
src/mds/MDBalancer.cc
src/mds/MDCache.cc
src/mds/MDSDaemon.cc
src/mds/MDSRank.cc
src/mds/Migrator.cc
src/mds/Server.cc
src/tools/ceph-dencoder/ceph_dencoder.cc

index 4499cb194878d2c3e5da3487d694553d076e81a5..fad1a9a11e00a36760b8427244be46326761e9c4 100644 (file)
@@ -2573,53 +2573,53 @@ bool Client::ms_dispatch2(const MessageRef &m)
   switch (m->get_type()) {
     // mounting and mds sessions
   case CEPH_MSG_MDS_MAP:
-    handle_mds_map(MMDSMap::msgref_cast(m));
+    handle_mds_map(ref_cast<MMDSMap>(m));
     break;
   case CEPH_MSG_FS_MAP:
-    handle_fs_map(MFSMap::msgref_cast(m));
+    handle_fs_map(ref_cast<MFSMap>(m));
     break;
   case CEPH_MSG_FS_MAP_USER:
-    handle_fs_map_user(MFSMapUser::msgref_cast(m));
+    handle_fs_map_user(ref_cast<MFSMapUser>(m));
     break;
   case CEPH_MSG_CLIENT_SESSION:
-    handle_client_session(MClientSession::msgref_cast(m));
+    handle_client_session(ref_cast<MClientSession>(m));
     break;
 
   case CEPH_MSG_OSD_MAP:
-    handle_osd_map(MOSDMap::msgref_cast(m));
+    handle_osd_map(ref_cast<MOSDMap>(m));
     break;
 
     // requests
   case CEPH_MSG_CLIENT_REQUEST_FORWARD:
-    handle_client_request_forward(MClientRequestForward::msgref_cast(m));
+    handle_client_request_forward(ref_cast<MClientRequestForward>(m));
     break;
   case CEPH_MSG_CLIENT_REPLY:
-    handle_client_reply(MClientReply::msgref_cast(m));
+    handle_client_reply(ref_cast<MClientReply>(m));
     break;
 
   // reclaim reply
   case CEPH_MSG_CLIENT_RECLAIM_REPLY:
-    handle_client_reclaim_reply(MClientReclaimReply::msgref_cast(m));
+    handle_client_reclaim_reply(ref_cast<MClientReclaimReply>(m));
     break;
 
   case CEPH_MSG_CLIENT_SNAP:
-    handle_snap(MClientSnap::msgref_cast(m));
+    handle_snap(ref_cast<MClientSnap>(m));
     break;
   case CEPH_MSG_CLIENT_CAPS:
-    handle_caps(MClientCaps::msgref_cast(m));
+    handle_caps(ref_cast<MClientCaps>(m));
     break;
   case CEPH_MSG_CLIENT_LEASE:
-    handle_lease(MClientLease::msgref_cast(m));
+    handle_lease(ref_cast<MClientLease>(m));
     break;
   case MSG_COMMAND_REPLY:
     if (m->get_source().type() == CEPH_ENTITY_TYPE_MDS) {
-      handle_command_reply(MCommandReply::msgref_cast(m));
+      handle_command_reply(ref_cast<MCommandReply>(m));
     } else {
       return false;
     }
     break;
   case CEPH_MSG_CLIENT_QUOTA:
-    handle_quota(MClientQuota::msgref_cast(m));
+    handle_quota(ref_cast<MClientQuota>(m));
     break;
 
   default:
index e08bf3ee4d0fb4f77850ac478ca61b20ff00123d..de1284ba5dc564aa14ba55eabefda7cb6e3fb9f3 100644 (file)
@@ -102,7 +102,7 @@ bool Beacon::ms_dispatch2(const ref_t<Message>& m)
 {
   if (m->get_type() == MSG_MDS_BEACON) {
     if (m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MON) {
-      handle_mds_beacon(MMDSBeacon::msgref_cast(m));
+      handle_mds_beacon(ref_cast<MMDSBeacon>(m));
     }
     return true;
   }
index 00a8e317165f168870d230ac37725bec64346824..014d8d7f4aed3f48dec85a6db4ced92099a7726f 100644 (file)
@@ -95,21 +95,21 @@ void Locker::dispatch(const cref_t<Message> &m)
   switch (m->get_type()) {
     // inter-mds locking
   case MSG_MDS_LOCK:
-    handle_lock(MLock::msgref_cast(m));
+    handle_lock(ref_cast<MLock>(m));
     break;
     // inter-mds caps
   case MSG_MDS_INODEFILECAPS:
-    handle_inode_file_caps(MInodeFileCaps::msgref_cast(m));
+    handle_inode_file_caps(ref_cast<MInodeFileCaps>(m));
     break;
     // client sync
   case CEPH_MSG_CLIENT_CAPS:
-    handle_client_caps(MClientCaps::msgref_cast(m));
+    handle_client_caps(ref_cast<MClientCaps>(m));
     break;
   case CEPH_MSG_CLIENT_CAPRELEASE:
-    handle_client_cap_release(MClientCapRelease::msgref_cast(m));
+    handle_client_cap_release(ref_cast<MClientCapRelease>(m));
     break;
   case CEPH_MSG_CLIENT_LEASE:
-    handle_client_lease(MClientLease::msgref_cast(m));
+    handle_client_lease(ref_cast<MClientLease>(m));
     break;
   default:
     derr << "locker unknown message " << m->get_type() << dendl;
index ec4a03f2c9e2927b48394d01ee828f81332b1503..ee809fbcbf8ed2da65f09f70f7bb2bbb9ccd9639 100644 (file)
@@ -64,7 +64,7 @@ int MDBalancer::proc_message(const cref_t<Message> &m)
   switch (m->get_type()) {
 
   case MSG_MDS_HEARTBEAT:
-    handle_heartbeat(MHeartbeat::msgref_cast(m));
+    handle_heartbeat(ref_cast<MHeartbeat>(m));
     break;
 
   default:
index 464e25d67b918a7457c244d41475963ea6f57490..4d5398ac7fcee0293c146f929f9f7854608db98c 100644 (file)
@@ -7883,62 +7883,62 @@ void MDCache::dispatch(const cref_t<Message> &m)
 
     // RESOLVE
   case MSG_MDS_RESOLVE:
-    handle_resolve(MMDSResolve::msgref_cast(m));
+    handle_resolve(ref_cast<MMDSResolve>(m));
     break;
   case MSG_MDS_RESOLVEACK:
-    handle_resolve_ack(MMDSResolveAck::msgref_cast(m));
+    handle_resolve_ack(ref_cast<MMDSResolveAck>(m));
     break;
 
     // REJOIN
   case MSG_MDS_CACHEREJOIN:
-    handle_cache_rejoin(MMDSCacheRejoin::msgref_cast(m));
+    handle_cache_rejoin(ref_cast<MMDSCacheRejoin>(m));
     break;
 
   case MSG_MDS_DISCOVER:
-    handle_discover(MDiscover::msgref_cast(m));
+    handle_discover(ref_cast<MDiscover>(m));
     break;
   case MSG_MDS_DISCOVERREPLY:
-    handle_discover_reply(MDiscoverReply::msgref_cast(m));
+    handle_discover_reply(ref_cast<MDiscoverReply>(m));
     break;
 
   case MSG_MDS_DIRUPDATE:
-    handle_dir_update(MDirUpdate::msgref_cast(m));
+    handle_dir_update(ref_cast<MDirUpdate>(m));
     break;
 
   case MSG_MDS_CACHEEXPIRE:
-    handle_cache_expire(MCacheExpire::msgref_cast(m));
+    handle_cache_expire(ref_cast<MCacheExpire>(m));
     break;
 
   case MSG_MDS_DENTRYLINK:
-    handle_dentry_link(MDentryLink::msgref_cast(m));
+    handle_dentry_link(ref_cast<MDentryLink>(m));
     break;
   case MSG_MDS_DENTRYUNLINK:
-    handle_dentry_unlink(MDentryUnlink::msgref_cast(m));
+    handle_dentry_unlink(ref_cast<MDentryUnlink>(m));
     break;
 
   case MSG_MDS_FRAGMENTNOTIFY:
-    handle_fragment_notify(MMDSFragmentNotify::msgref_cast(m));
+    handle_fragment_notify(ref_cast<MMDSFragmentNotify>(m));
     break;
   case MSG_MDS_FRAGMENTNOTIFYACK:
-    handle_fragment_notify_ack(MMDSFragmentNotifyAck::msgref_cast(m));
+    handle_fragment_notify_ack(ref_cast<MMDSFragmentNotifyAck>(m));
     break;
 
   case MSG_MDS_FINDINO:
-    handle_find_ino(MMDSFindIno::msgref_cast(m));
+    handle_find_ino(ref_cast<MMDSFindIno>(m));
     break;
   case MSG_MDS_FINDINOREPLY:
-    handle_find_ino_reply(MMDSFindInoReply::msgref_cast(m));
+    handle_find_ino_reply(ref_cast<MMDSFindInoReply>(m));
     break;
 
   case MSG_MDS_OPENINO:
-    handle_open_ino(MMDSOpenIno::msgref_cast(m));
+    handle_open_ino(ref_cast<MMDSOpenIno>(m));
     break;
   case MSG_MDS_OPENINOREPLY:
-    handle_open_ino_reply(MMDSOpenInoReply::msgref_cast(m));
+    handle_open_ino_reply(ref_cast<MMDSOpenInoReply>(m));
     break;
 
   case MSG_MDS_SNAPUPDATE:
-    handle_snap_update(MMDSSnapUpdate::msgref_cast(m));
+    handle_snap_update(ref_cast<MMDSSnapUpdate>(m));
     break;
     
   default:
index 4f31316009630a3825737253f93b4e6525308d98..db0b7f543ae74b0bbe11a6cfe93bbd3568965142 100644 (file)
@@ -1190,12 +1190,12 @@ bool MDSDaemon::handle_core_message(const cref_t<Message> &m)
     // MDS
   case CEPH_MSG_MDS_MAP:
     ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON | CEPH_ENTITY_TYPE_MDS);
-    handle_mds_map(MMDSMap::msgref_cast(m));
+    handle_mds_map(ref_cast<MMDSMap>(m));
     break;
 
     // OSD
   case MSG_COMMAND:
-    handle_command(MCommand::msgref_cast(m));
+    handle_command(ref_cast<MCommand>(m));
     break;
   case CEPH_MSG_OSD_MAP:
     ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON | CEPH_ENTITY_TYPE_OSD);
index 78d7a40a900acb6ff5a25b4530b989466b622cb4..1791048e8a04ebefb649c02abc977c1c677014fa 100644 (file)
@@ -1193,7 +1193,7 @@ bool MDSRank::handle_deferrable_message(const cref_t<Message> &m)
     case MSG_MDS_TABLE_REQUEST:
       ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MDS);
       {
-        const cref_t<MMDSTableRequest> &req = MMDSTableRequest::msgref_cast(m);
+        const cref_t<MMDSTableRequest> &req = ref_cast<MMDSTableRequest>(m);
         if (req->op < 0) {
           MDSTableClient *client = get_table_client(req->table);
           client->handle_request(req);
index b35500aabda366a52d743c19b940d64679deeb15..b1868b53f15aa9cf6a79dc0363834ccc66fc0cce 100644 (file)
@@ -96,54 +96,54 @@ void Migrator::dispatch(const cref_t<Message> &m)
   switch (m->get_type()) {
     // import
   case MSG_MDS_EXPORTDIRDISCOVER:
-    handle_export_discover(MExportDirDiscover::msgref_cast(m));
+    handle_export_discover(ref_cast<MExportDirDiscover>(m));
     break;
   case MSG_MDS_EXPORTDIRPREP:
-    handle_export_prep(MExportDirPrep::msgref_cast(m));
+    handle_export_prep(ref_cast<MExportDirPrep>(m));
     break;
   case MSG_MDS_EXPORTDIR:
     if (unlikely(inject_session_race)) {
       dout(0) << "waiting for inject_session_race" << dendl;
       mds->wait_for_any_client_connection(new C_MDS_RetryMessage(mds, m));
     } else {
-      handle_export_dir(MExportDir::msgref_cast(m));
+      handle_export_dir(ref_cast<MExportDir>(m));
     }
     break;
   case MSG_MDS_EXPORTDIRFINISH:
-    handle_export_finish(MExportDirFinish::msgref_cast(m));
+    handle_export_finish(ref_cast<MExportDirFinish>(m));
     break;
   case MSG_MDS_EXPORTDIRCANCEL:
-    handle_export_cancel(MExportDirCancel::msgref_cast(m));
+    handle_export_cancel(ref_cast<MExportDirCancel>(m));
     break;
 
     // export 
   case MSG_MDS_EXPORTDIRDISCOVERACK:
-    handle_export_discover_ack(MExportDirDiscoverAck::msgref_cast(m));
+    handle_export_discover_ack(ref_cast<MExportDirDiscoverAck>(m));
     break;
   case MSG_MDS_EXPORTDIRPREPACK:
-    handle_export_prep_ack(MExportDirPrepAck::msgref_cast(m));
+    handle_export_prep_ack(ref_cast<MExportDirPrepAck>(m));
     break;
   case MSG_MDS_EXPORTDIRACK:
-    handle_export_ack(MExportDirAck::msgref_cast(m));
+    handle_export_ack(ref_cast<MExportDirAck>(m));
     break;
   case MSG_MDS_EXPORTDIRNOTIFYACK:
-    handle_export_notify_ack(MExportDirNotifyAck::msgref_cast(m));
+    handle_export_notify_ack(ref_cast<MExportDirNotifyAck>(m));
     break;
 
     // export 3rd party (dir_auth adjustments)
   case MSG_MDS_EXPORTDIRNOTIFY:
-    handle_export_notify(MExportDirNotify::msgref_cast(m));
+    handle_export_notify(ref_cast<MExportDirNotify>(m));
     break;
 
     // caps
   case MSG_MDS_EXPORTCAPS:
-    handle_export_caps(MExportCaps::msgref_cast(m));
+    handle_export_caps(ref_cast<MExportCaps>(m));
     break;
   case MSG_MDS_EXPORTCAPSACK:
-    handle_export_caps_ack(MExportCapsAck::msgref_cast(m));
+    handle_export_caps_ack(ref_cast<MExportCapsAck>(m));
     break;
   case MSG_MDS_GATHERCAPS:
-    handle_gather_caps(MGatherCaps::msgref_cast(m));
+    handle_gather_caps(ref_cast<MGatherCaps>(m));
     break;
 
   default:
index 56b87b26ac13a46cc766c5d1fa6a73f274348d4b..112a48bf898d048c024a5d77040753d25f14c0e4 100644 (file)
@@ -201,14 +201,14 @@ void Server::dispatch(const cref_t<Message> &m)
 {
   switch (m->get_type()) {
   case CEPH_MSG_CLIENT_RECONNECT:
-    handle_client_reconnect(MClientReconnect::msgref_cast(m));
+    handle_client_reconnect(ref_cast<MClientReconnect>(m));
     return;
   }
 
   // active?
   // handle_slave_request()/handle_client_session() will wait if necessary
   if (m->get_type() == CEPH_MSG_CLIENT_REQUEST && !mds->is_active()) {
-    const auto &req = MClientRequest::msgref_cast(m);
+    const auto &req = ref_cast<MClientRequest>(m);
     if (mds->is_reconnect() || mds->get_want_state() == CEPH_MDS_STATE_RECONNECT) {
       Session *session = mds->get_session(req);
       if (!session || session->is_closed()) {
@@ -259,16 +259,16 @@ void Server::dispatch(const cref_t<Message> &m)
 
   switch (m->get_type()) {
   case CEPH_MSG_CLIENT_SESSION:
-    handle_client_session(MClientSession::msgref_cast(m));
+    handle_client_session(ref_cast<MClientSession>(m));
     return;
   case CEPH_MSG_CLIENT_REQUEST:
-    handle_client_request(MClientRequest::msgref_cast(m));
+    handle_client_request(ref_cast<MClientRequest>(m));
     return;
   case CEPH_MSG_CLIENT_RECLAIM:
-    handle_client_reclaim(MClientReclaim::msgref_cast(m));
+    handle_client_reclaim(ref_cast<MClientReclaim>(m));
     return;
   case MSG_MDS_SLAVE_REQUEST:
-    handle_slave_request(MMDSSlaveRequest::msgref_cast(m));
+    handle_slave_request(ref_cast<MMDSSlaveRequest>(m));
     return;
   default:
     derr << "server unknown message " << m->get_type() << dendl;
index 18f9262b96eb51860558315846f2e3f52e93d9ec..cc7e4708f2ef631d351ac345f4939e5fb91745ce 100644 (file)
@@ -233,7 +233,7 @@ public:
        ss << "decoded type " << n->get_type() << " instead of expected " << m_object->get_type();
        throw std::runtime_error(ss.str());
       }
-      m_object = boost::static_pointer_cast<typename T::ref::element_type, std::remove_reference<decltype(n)>::type::element_type>(n);
+      m_object = ref_cast<T>(n);
     }
     catch (buffer::error& e) {
       return e.what();