]> git-server-git.apps.pok.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>
Mon, 4 Mar 2019 17:19:17 +0000 (09:19 -0800)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit ce153b811263932b42b04a7b8abe63e8241d0ddc)

Conflicts:
src/mds/SessionMap.cc
src/mds/SessionMap.h

src/mds/MDSDaemon.cc
src/mds/SessionMap.cc
src/mds/SessionMap.h

index 2f55ef825008282ce2002ff36cc0e189c68d1d25..d0a414a3c9b48f2cf0b850092a53a66f6688a75b 100644 (file)
@@ -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;
index 68ba509c23dbe4a1c0e9646aa4c1fac0bff4f1ee..a3ddd8e3aeabfc7de0bdf65894dcca4c976a8099 100644 (file)
@@ -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.
index 30743aa92f39c2f6c32c334bfc0c1b20bb88a49d..a5067b58f9e796e2a5174680915867723923db5c 100644 (file)
@@ -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<version_t, list<MDSInternalContextBase*> > 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<uint64_t> *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) {