From: Patrick Donnelly Date: Mon, 21 Jan 2019 18:57:45 +0000 (-0800) Subject: mds: cleanup Session init X-Git-Tag: v12.2.12~63^2~11 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c73b37af1c24477788b3462736a795492ffbc43e;p=ceph.git mds: cleanup Session init Signed-off-by: Patrick Donnelly (cherry picked from commit ce153b811263932b42b04a7b8abe63e8241d0ddc) Conflicts: src/mds/SessionMap.cc src/mds/SessionMap.h --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index 2f55ef825008..d0a414a3c9b4 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -1356,7 +1356,7 @@ bool MDSDaemon::ms_verify_authorizer(Connection *con, int peer_type, // It doesn't go into a SessionMap instance until it sends an explicit // request to open a session (initial state of Session is `closed`) if (!s) { - s = new Session; + s = new Session(nullptr); s->info.auth_name = name; s->info.inst.addr = con->get_peer_addr(); s->info.inst.name = n; diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 68ba509c23db..a3ddd8e3aeab 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -546,8 +546,8 @@ void SessionMapStore::decode_legacy(bufferlist::iterator& p) ::decode(n, p); while (n-- && !p.end()) { - bufferlist::iterator p2 = p; - Session *s = new Session; + auto p2 = p; + 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 30743aa92f39..a5067b58f9e7 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" @@ -96,9 +95,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 @@ -154,8 +153,8 @@ public: // Ephemeral state for tracking progress of capability recalls time recalled_at = time::min(); // When was I asked to SESSION_RECALL? time last_recall_sent = time::min(); - 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 @@ -244,8 +243,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: @@ -284,16 +283,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; @@ -368,18 +367,15 @@ 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() : - 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) { } + 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 + { + connection = std::move(con); + } ~Session() override { if (state == STATE_CLOSED) { item_session_list.remove_myself(); @@ -475,7 +471,7 @@ public: if (session_map_entry != session_map.end()) { s = session_map_entry->second; } else { - s = session_map[i.name] = new Session; + s = session_map[i.name] = new Session(ConnectionRef()); s->info.inst = i; s->last_cap_renew = Session::clock::now(); if (logger) {