]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: detect mds-mds messages not of type MMDSOp 36004/head
authorJos Collin <jcollin@redhat.com>
Thu, 15 Oct 2020 11:30:50 +0000 (17:00 +0530)
committerJos Collin <jcollin@redhat.com>
Thu, 22 Oct 2020 05:01:46 +0000 (10:31 +0530)
* Detect mds-mds messages not of type MMDSOp.
* Return true from MetricAggregator::ms_dispatch2 only when the peer is an MDS and the metrics is handled.

Fixes: https://tracker.ceph.com/issues/46426
Signed-off-by: Jos Collin <jcollin@redhat.com>
src/mds/MetricAggregator.cc
src/mds/MetricsHandler.cc

index 03e06db64998ac27451b554fcecfafe349ac3a4b..aee3bc2473b7d418817e5ef2df6962e1f2f9533d 100644 (file)
@@ -78,10 +78,14 @@ void MetricAggregator::ms_fast_dispatch2(const ref_t<Message> &m) {
 }
 
 bool MetricAggregator::ms_dispatch2(const ref_t<Message> &m) {
-  if (m->get_type() == MSG_MDS_METRICS) {
-    if (m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MDS) {
-      handle_mds_metrics(ref_cast<MMDSMetrics>(m));
-    }
+  if (m->get_type() == MSG_MDS_METRICS &&
+      m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MDS) {
+    const Message *msg = m.get();
+    const MMDSOp *op = dynamic_cast<const MMDSOp*>(msg);
+    if (!op)
+      dout(0) << typeid(*msg).name() << " is not an MMDSOp type" << dendl;
+    ceph_assert(op);
+    handle_mds_metrics(ref_cast<MMDSMetrics>(m));
     return true;
   }
   return false;
index e63b6aca092ed233378ade75897066666a363768..cfcf3994b8c4b10c102f912fd8dd6c9c29f4a151 100644 (file)
@@ -34,13 +34,16 @@ bool MetricsHandler::ms_dispatch2(const ref_t<Message> &m) {
       m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_CLIENT) {
     handle_client_metrics(ref_cast<MClientMetrics>(m));
     return true;
-  }
-  if (m->get_type() == MSG_MDS_PING &&
-      m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MDS) {
+  } else if (m->get_type() == MSG_MDS_PING &&
+             m->get_connection()->get_peer_type() == CEPH_ENTITY_TYPE_MDS) {
+    const Message *msg = m.get();
+    const MMDSOp *op = dynamic_cast<const MMDSOp*>(msg);
+    if (!op)
+      dout(0) << typeid(*msg).name() << " is not an MMDSOp type" << dendl;
+    ceph_assert(op);
     handle_mds_ping(ref_cast<MMDSPing>(m));
     return true;
   }
-
   return false;
 }