]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: make Objecter a Dispatcher
authorSage Weil <sage@redhat.com>
Sun, 20 Jul 2014 16:17:44 +0000 (09:17 -0700)
committerJohn Spray <john.spray@redhat.com>
Mon, 25 Aug 2014 00:34:00 +0000 (01:34 +0100)
Note that it's not actually doing it yet, though!

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osdc/Objecter.cc
src/osdc/Objecter.h

index 33ab0e59f193b023bb1a76e9fd0c7c9e20e95f74..7526610b128d545d082e93e427ae64e1eca6afcd 100644 (file)
@@ -5355,7 +5355,8 @@ bool OSD::heartbeat_dispatch(Message *m)
 
 bool OSDService::ObjecterDispatcher::ms_dispatch(Message *m)
 {
-  osd->objecter->dispatch(m);
+  if (!osd->objecter->ms_dispatch(m))
+    m->put();
   return true;
 }
 
@@ -5374,10 +5375,7 @@ bool OSDService::ObjecterDispatcher::ms_get_authorizer(int dest_type,
                                                       AuthAuthorizer **authorizer,
                                                       bool force_new)
 {
-  if (dest_type == CEPH_ENTITY_TYPE_MON)
-    return true;
-  *authorizer = osd->monc->auth->build_authorizer(dest_type);
-  return *authorizer != NULL;
+  return osd->objecter->ms_get_authorizer(dest_type, authorizer, force_new);
 }
 
 
index 392d7806ba20970cdb50b91e391b87dfc10ce12b..1d969ec77de8007186b8dbb7a9e337334eef5630 100644 (file)
@@ -490,37 +490,42 @@ void Objecter::_linger_submit(LingerOp *info)
 
 
 
-void Objecter::dispatch(Message *m)
+bool Objecter::ms_dispatch(Message *m)
 {
+  ldout(cct, 10) << __func__ << " " << cct << " " << *m << dendl;
   switch (m->get_type()) {
+    // these we exlusively handle
   case CEPH_MSG_OSD_OPREPLY:
     handle_osd_op_reply(static_cast<MOSDOpReply*>(m));
-    break;
-    
-  case CEPH_MSG_OSD_MAP:
-    handle_osd_map(static_cast<MOSDMap*>(m));
-    break;
+    return true;
+
+  case MSG_COMMAND_REPLY:
+    handle_command_reply(static_cast<MCommandReply*>(m));
+    return true;
 
   case MSG_GETPOOLSTATSREPLY:
     handle_get_pool_stats_reply(static_cast<MGetPoolStatsReply*>(m));
-    break;
-
-  case CEPH_MSG_STATFS_REPLY:
-    handle_fs_stats_reply(static_cast<MStatfsReply*>(m));
-    break;
+    return true;
 
   case CEPH_MSG_POOLOP_REPLY:
     handle_pool_op_reply(static_cast<MPoolOpReply*>(m));
-    break;
+    return true;
 
-  case MSG_COMMAND_REPLY:
-    handle_command_reply(static_cast<MCommandReply*>(m));
-    break;
+    // these we give others a chance to inspect
+
+    // MDS, OSD
+  case CEPH_MSG_OSD_MAP:
+    m->get();
+    handle_osd_map(static_cast<MOSDMap*>(m));
+    return false;
 
-  default:
-    ldout(cct, 0) << "don't know message type " << m->get_type() << dendl;
-    assert(0);
+    // Client
+  case CEPH_MSG_STATFS_REPLY:
+    m->get();
+    handle_fs_stats_reply(static_cast<MStatfsReply*>(m));
+    return false;
   }
+  return false;
 }
 
 void Objecter::_scan_requests(OSDSession *s,
@@ -3090,7 +3095,7 @@ void Objecter::ms_handle_connect(Connection *con)
     resend_mon_ops();
 }
 
-void Objecter::ms_handle_reset(Connection *con)
+bool Objecter::ms_handle_reset(Connection *con)
 {
   if (con->get_peer_type() == CEPH_ENTITY_TYPE_OSD) {
     //
@@ -3115,7 +3120,9 @@ void Objecter::ms_handle_reset(Connection *con)
     } else {
       ldout(cct, 10) << "ms_handle_reset on unknown osd addr " << con->get_peer_addr() << dendl;
     }
+    return true;
   }
+  return false;
 }
 
 void Objecter::ms_handle_remote_reset(Connection *con)
@@ -3126,6 +3133,16 @@ void Objecter::ms_handle_remote_reset(Connection *con)
   ms_handle_reset(con);
 }
 
+bool Objecter::ms_get_authorizer(int dest_type,
+                                AuthAuthorizer **authorizer,
+                                bool force_new)
+{
+  if (dest_type == CEPH_ENTITY_TYPE_MON)
+    return true;
+  *authorizer = monc->auth->build_authorizer(dest_type);
+  return *authorizer != NULL;
+}
+
 
 void Objecter::op_target_t::dump(Formatter *f) const
 {
index ee129af134dacd157ef24a22a515a902c3de05af..9fc9b836f27f2d670007b84f5c7807bdca32e87b 100644 (file)
@@ -996,7 +996,7 @@ struct ObjectOperation {
 // ----------------
 
 
-class Objecter : public md_config_obs_t {
+class Objecter : public md_config_obs_t, public Dispatcher {
 public:
   // config observer bits
   virtual const char** get_tracked_conf_keys() const;
@@ -1583,6 +1583,7 @@ public:
   Objecter(CephContext *cct_, Messenger *m, MonClient *mc,
           OSDMap *om, double mon_timeout,
           double osd_timeout) :
+    Dispatcher(cct),
     messenger(m), monc(mc), osdmap(om), cct(cct_),
     initialized(false),
     last_tid(0), client_inc(-1), max_linger_id(0),
@@ -1637,7 +1638,7 @@ public:
 
   // messages
  public:
-  void dispatch(Message *m);
+  bool ms_dispatch(Message *m);
   void handle_osd_op_reply(class MOSDOpReply *m);
   void handle_osd_map(class MOSDMap *m);
   void wait_for_osd_map();
@@ -2246,8 +2247,12 @@ public:
   }
 
   void ms_handle_connect(Connection *con);
-  void ms_handle_reset(Connection *con);
+  bool ms_handle_reset(Connection *con);
   void ms_handle_remote_reset(Connection *con);
+  bool ms_get_authorizer(int dest_type,
+                        AuthAuthorizer **authorizer,
+                        bool force_new);
+
   void blacklist_self(bool set);
 };