From: Patrick Donnelly Date: Mon, 21 Jan 2019 18:57:45 +0000 (-0800) Subject: mds: cleanup Session init X-Git-Tag: v14.1.0~240^2~9 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ce153b811263932b42b04a7b8abe63e8241d0ddc;p=ceph.git mds: cleanup Session init Signed-off-by: Patrick Donnelly --- diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 79ecb5644faf8..6d5ee3b3f33b7 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -547,7 +547,7 @@ void SessionMapStore::decode_legacy(bufferlist::const_iterator& p) while (n-- && !p.end()) { auto p2 = p; - Session *s = new Session(nullptr); + Session *s = new Session(ConnectionRef()); s->info.decode(p); if (session_map.count(s->info.inst.name)) { // eager client connected too fast! aie. diff --git a/src/mds/SessionMap.h b/src/mds/SessionMap.h index 58151c011cebd..9b568fcd14af2 100644 --- a/src/mds/SessionMap.h +++ b/src/mds/SessionMap.h @@ -30,7 +30,6 @@ using std::set; class CInode; struct MDRequestImpl; -class DecayCounter; #include "CInode.h" #include "Capability.h" @@ -97,9 +96,9 @@ public: } private: - int state; - uint64_t state_seq; - int importing_count; + int state = STATE_CLOSED; + uint64_t state_seq = 0; + int importing_count = 0; friend class SessionMap; // Human (friendly) name is soft state generated from client metadata @@ -156,8 +155,8 @@ public: // Ephemeral state for tracking progress of capability recalls time recalled_at = clock::zero(); // When was I asked to SESSION_RECALL? time last_recall_sent = clock::zero(); - uint32_t recall_count; // How many caps was I asked to SESSION_RECALL? - uint32_t recall_release_count; // How many caps have I actually revoked? + uint32_t recall_count = 0; // How many caps was I asked to SESSION_RECALL? + uint32_t recall_release_count = 0; // How many caps have I actually revoked? session_info_t info; ///< durable bits @@ -249,8 +248,8 @@ public: // -- caps -- private: - uint32_t cap_gen; - version_t cap_push_seq; // cap push seq # + uint32_t cap_gen = 0; + version_t cap_push_seq = 0; // cap push seq # map waitfor_flush; // flush session messages public: @@ -291,16 +290,16 @@ public: } // -- leases -- - uint32_t lease_seq; + uint32_t lease_seq = 0; // -- completed requests -- private: // Has completed_requests been modified since the last time we // wrote this session out? - bool completed_requests_dirty; + bool completed_requests_dirty = false; - unsigned num_trim_flushes_warnings; - unsigned num_trim_requests_warnings; + unsigned num_trim_flushes_warnings = 0; + unsigned num_trim_requests_warnings = 0; public: void add_completed_request(ceph_tid_t t, inodeno_t created) { info.completed_requests[t] = created; @@ -375,21 +374,14 @@ public: int check_access(CInode *in, unsigned mask, int caller_uid, int caller_gid, const vector *gid_list, int new_uid, int new_gid); - - Session(Connection *con) : - state(STATE_CLOSED), state_seq(0), importing_count(0), - birth_time(clock::now()), recall_count(0), - recall_release_count(0), auth_caps(g_ceph_context), - connection(NULL), item_session_list(this), - requests(0), // member_offset passed to front() manually - cap_gen(0), cap_push_seq(0), - lease_seq(0), - completed_requests_dirty(false), - num_trim_flushes_warnings(0), - num_trim_requests_warnings(0) { - if (con) { - set_connection(con); - } + Session() = delete; + Session(ConnectionRef con) : + birth_time(clock::now()), + auth_caps(g_ceph_context), + item_session_list(this), + requests(0) // member_offset passed to front() manually + { + set_connection(std::move(con)); } ~Session() override { if (state == STATE_CLOSED) { @@ -400,9 +392,11 @@ public: preopen_out_queue.clear(); } - void set_connection(Connection *con) { - connection = con; - socket_addr = con->get_peer_socket_addr(); + void set_connection(ConnectionRef con) { + connection = std::move(con); + if (connection) { + socket_addr = connection->get_peer_socket_addr(); + } } const ConnectionRef& get_connection() const { return connection; @@ -490,7 +484,7 @@ public: if (session_map_entry != session_map.end()) { s = session_map_entry->second; } else { - s = session_map[i.name] = new Session(nullptr); + s = session_map[i.name] = new Session(ConnectionRef()); s->info.inst = i; s->last_cap_renew = Session::clock::now(); if (logger) {