]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: cleanup Session init
authorPatrick Donnelly <pdonnell@redhat.com>
Mon, 21 Jan 2019 18:57:45 +0000 (10:57 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 29 Jan 2019 23:16:30 +0000 (15:16 -0800)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/mds/SessionMap.cc
src/mds/SessionMap.h

index 79ecb5644faf8a0c3a59fae57f91391a0827e4f6..6d5ee3b3f33b76404535da85b6306cf54f1d3abd 100644 (file)
@@ -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.
index 58151c011cebd2fa6faad208119176fda167bffa..9b568fcd14af2bda2447b4e883984a7608908a24 100644 (file)
@@ -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<version_t, MDSInternalContextBase::vec > 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<uint64_t> *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) {