]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: move Session class out of OSD
authorSage Weil <sage@redhat.com>
Tue, 18 Oct 2016 22:43:09 +0000 (17:43 -0500)
committerSage Weil <sage@redhat.com>
Fri, 10 Feb 2017 22:59:50 +0000 (17:59 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PrimaryLogPG.cc
src/osd/Session.h [new file with mode: 0644]
src/osd/Watch.cc
src/osd/Watch.h
src/test/mon/test_mon_workloadgen.cc

index 95b3062e65c95c8b8b524a1ac1e0aca5e49d9793..5b57864467d15f572902e7e8810b188c50893e49 100644 (file)
@@ -4939,7 +4939,7 @@ void OSD::ms_handle_fast_accept(Connection *con)
 
 bool OSD::ms_handle_reset(Connection *con)
 {
-  OSD::Session *session = (OSD::Session *)con->get_priv();
+  Session *session = (Session *)con->get_priv();
   dout(1) << "ms_handle_reset con " << con << " session " << session << dendl;
   if (!session)
     return false;
@@ -4955,7 +4955,7 @@ bool OSD::ms_handle_refused(Connection *con)
   if (!cct->_conf->osd_fast_fail_on_connection_refused)
     return false;
 
-  OSD::Session *session = (OSD::Session *)con->get_priv();
+  Session *session = (Session *)con->get_priv();
   dout(1) << "ms_handle_refused con " << con << " session " << session << dendl;
   if (!session)
     return false;
@@ -8692,7 +8692,7 @@ public:
   }
 
   void finish(ThreadPool::TPHandle& tp) {
-    OSD::Session *session = static_cast<OSD::Session *>(
+    Session *session = static_cast<Session *>(
         con->get_priv());
     epoch_t last_sent_epoch;
     if (session) {
index 33cc7c02417fc079a55e3ee7516f22584e2a4bdb..858fe753fa559ac3f3144f97cdc639303e2048f4 100644 (file)
@@ -37,6 +37,7 @@
 #include "include/CompatSet.h"
 
 #include "OpRequest.h"
+#include "Session.h"
 
 #include <atomic>
 #include <map>
@@ -1440,36 +1441,6 @@ public:
     }
   }
 
-  struct Session : public RefCountedObject {
-    EntityName entity_name;
-    OSDCap caps;
-    int64_t auid;
-    ConnectionRef con;
-    WatchConState wstate;
-
-    Mutex session_dispatch_lock;
-    boost::intrusive::list<OpRequest> waiting_on_map;
-
-    OSDMapRef osdmap;  /// Map as of which waiting_for_pg is current
-    map<spg_t, boost::intrusive::list<OpRequest> > waiting_for_pg;
-
-    Spinlock sent_epoch_lock;
-    epoch_t last_sent_epoch;
-    Spinlock received_map_lock;
-    epoch_t received_map_epoch; // largest epoch seen in MOSDMap from here
-
-    explicit Session(CephContext *cct) :
-      RefCountedObject(cct),
-      auid(-1), con(0), wstate(cct),
-      session_dispatch_lock("Session::session_dispatch_lock"), 
-      last_sent_epoch(0), received_map_epoch(0)
-    {}
-    void maybe_reset_osdmap() {
-      if (waiting_for_pg.empty()) {
-       osdmap.reset();
-      }
-    }
-  };
 
 private:
   void update_waiting_for_pg(Session *session, OSDMapRef osdmap);
index 09af9200d4eb183f7a05dcba44fee442a0cfe27c..c5ad57b9a0634df71758e2e037ed78edddc9dab5 100644 (file)
@@ -23,6 +23,7 @@
 #include "OSD.h"
 #include "OpRequest.h"
 #include "ScrubStore.h"
+#include "Session.h"
 
 #include "common/Timer.h"
 #include "common/perf_counters.h"
@@ -1851,7 +1852,7 @@ bool PG::op_has_sufficient_caps(OpRequestRef& op)
 
   MOSDOp *req = static_cast<MOSDOp*>(op->get_req());
 
-  OSD::Session *session = (OSD::Session *)req->get_connection()->get_priv();
+  Session *session = (Session *)req->get_connection()->get_priv();
   if (!session) {
     dout(0) << "op_has_sufficient_caps: no session for op " << *req << dendl;
     return false;
index 0b87591a81e4904a1ad3fcd11f9c3361f78ac33c..18480d21b058cd08a539a20679d6305cbfe69db0 100644 (file)
@@ -22,6 +22,7 @@
 #include "OSD.h"
 #include "OpRequest.h"
 #include "ScrubStore.h"
+#include "Session.h"
 #include "objclass/objclass.h"
 
 #include "common/errno.h"
@@ -6457,7 +6458,7 @@ void PrimaryLogPG::do_osd_op_effects(OpContext *ctx, const ConnectionRef& conn)
 
   assert(conn);
 
-  boost::intrusive_ptr<OSD::Session> session((OSD::Session *)conn->get_priv());
+  boost::intrusive_ptr<Session> session((Session *)conn->get_priv());
   if (!session.get())
     return;
   session->put();  // get_priv() takes a ref, and so does the intrusive_ptr
diff --git a/src/osd/Session.h b/src/osd/Session.h
new file mode 100644 (file)
index 0000000..aa862c2
--- /dev/null
@@ -0,0 +1,54 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation.  See file COPYING.
+ *
+ */
+
+#ifndef CEPH_OSD_SESSION_H
+#define CEPH_OSD_SESSION_H
+
+#include "common/RefCountedObj.h"
+
+struct Session : public RefCountedObject {
+  EntityName entity_name;
+  OSDCap caps;
+  int64_t auid;
+  ConnectionRef con;
+  WatchConState wstate;
+
+  Mutex session_dispatch_lock;
+  boost::intrusive::list<OpRequest> waiting_on_map;
+
+  OSDMapRef osdmap;  /// Map as of which waiting_for_pg is current
+  map<spg_t, boost::intrusive::list<OpRequest> > waiting_for_pg;
+
+  Spinlock sent_epoch_lock;
+  epoch_t last_sent_epoch;
+  Spinlock received_map_lock;
+  epoch_t received_map_epoch; // largest epoch seen in MOSDMap from here
+
+  explicit Session(CephContext *cct) :
+    RefCountedObject(cct),
+    auid(-1), con(0),
+    wstate(cct),
+    session_dispatch_lock("Session::session_dispatch_lock"),
+    last_sent_epoch(0), received_map_epoch(0)
+    {}
+  void maybe_reset_osdmap() {
+    if (waiting_for_pg.empty()) {
+      osdmap.reset();
+    }
+  }
+};
+
+typedef boost::intrusive_ptr<Session> SessionRef;
+
+#endif
index 93f7a0717fb822dd8f9a2440590d5d5ee4b45a72..284a2447f4c90674a27e7bc4b8c84e3e480e6429 100644 (file)
@@ -9,6 +9,7 @@
 #include "OSD.h"
 #include "PrimaryLogPG.h"
 #include "Watch.h"
+#include "Session.h"
 
 #include "common/config.h"
 
@@ -368,7 +369,7 @@ void Watch::connect(ConnectionRef con, bool _will_ping)
   dout(10) << __func__ << " con " << con << dendl;
   conn = con;
   will_ping = _will_ping;
-  OSD::Session* sessionref(static_cast<OSD::Session*>(con->get_priv()));
+  Session* sessionref(static_cast<Session*>(con->get_priv()));
   if (sessionref) {
     sessionref->wstate.addWatch(self.lock());
     sessionref->put();
@@ -414,7 +415,7 @@ void Watch::discard_state()
   unregister_cb();
   discarded = true;
   if (conn) {
-    OSD::Session* sessionref(static_cast<OSD::Session*>(conn->get_priv()));
+    Session* sessionref(static_cast<Session*>(conn->get_priv()));
     if (sessionref) {
       sessionref->wstate.removeWatch(self.lock());
       sessionref->put();
index 1897a50a5193111f290d37d39d1033cabf846d2a..31d628d769aa58a960f5638c206e7a9c52005bea 100644 (file)
@@ -271,7 +271,7 @@ public:
 
 /**
  * Holds weak refs to Watch structures corresponding to a connection
- * Lives in the OSD::Session object of an OSD connection
+ * Lives in the Session object of an OSD connection
  */
 class WatchConState {
   Mutex lock;
index 64a618d2ec89a15a0d6816a77d8718e7ebcc544f..1efc879d02143d5b7b3cf797c4bcf1482df5c5f0 100644 (file)
@@ -902,7 +902,7 @@ class OSDStub : public TestStub
 
   bool ms_handle_reset(Connection *con) {
     dout(1) << __func__ << dendl;
-    OSD::Session *session = (OSD::Session *)con->get_priv();
+    Session *session = (Session *)con->get_priv();
     if (!session)
       return false;
     session->put();