]> 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)
committerNathan Cutler <ncutler@suse.com>
Thu, 24 Oct 2019 15:54:50 +0000 (17:54 +0200)
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit ce153b8)

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

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

index ac5cac593b3c20de803f7287ca90e54a5034c322..b8554107b727e4810a0613059e8303315d808d09 100644 (file)
@@ -1383,7 +1383,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 e2ff8b337d36e0ea7460a556cdda39d1e012f2eb..cb432571c488469ace71623db345b1e8ae2f7e44 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 289023a4ec1e8f83bb5c587d45dc9ef6bfcfca2d..47187e4a724b2c51caff17c493da7ba08b20c966 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
@@ -149,8 +148,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
 
@@ -239,8 +238,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:
@@ -285,16 +284,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;
@@ -369,18 +368,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();
@@ -476,7 +472,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) {