From: Sage Weil Date: Tue, 18 Oct 2016 22:43:09 +0000 (-0500) Subject: osd: move Session class out of OSD X-Git-Tag: v12.0.1~441^2~12 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a0d2011787df8a49957468eeff3b05611f866782;p=ceph-ci.git osd: move Session class out of OSD Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 95b3062e65c..5b57864467d 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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( + Session *session = static_cast( con->get_priv()); epoch_t last_sent_epoch; if (session) { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 33cc7c02417..858fe753fa5 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -37,6 +37,7 @@ #include "include/CompatSet.h" #include "OpRequest.h" +#include "Session.h" #include #include @@ -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 waiting_on_map; - - OSDMapRef osdmap; /// Map as of which waiting_for_pg is current - map > 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); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 09af9200d4e..c5ad57b9a06 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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(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; diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index 0b87591a81e..18480d21b05 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -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 session((OSD::Session *)conn->get_priv()); + boost::intrusive_ptr 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 index 00000000000..aa862c299a6 --- /dev/null +++ b/src/osd/Session.h @@ -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 + * + * 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 waiting_on_map; + + OSDMapRef osdmap; /// Map as of which waiting_for_pg is current + map > 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 SessionRef; + +#endif diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 93f7a0717fb..284a2447f4c 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -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(con->get_priv())); + Session* sessionref(static_cast(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(conn->get_priv())); + Session* sessionref(static_cast(conn->get_priv())); if (sessionref) { sessionref->wstate.removeWatch(self.lock()); sessionref->put(); diff --git a/src/osd/Watch.h b/src/osd/Watch.h index 1897a50a519..31d628d769a 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -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; diff --git a/src/test/mon/test_mon_workloadgen.cc b/src/test/mon/test_mon_workloadgen.cc index 64a618d2ec8..1efc879d021 100644 --- a/src/test/mon/test_mon_workloadgen.cc +++ b/src/test/mon/test_mon_workloadgen.cc @@ -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();